Spec:Documentation Index
Fetch the complete documentation index at: https://docs.encoreos.io/llms.txt
Use this file to discover all available pages before exploring further.
specs/pf/specs/PF-101-google-workspace-integration.md
Plan: specs/pf/plans/PF-101-google-workspace-integration-PLAN.md
Tasks: specs/pf/tasks/PF-101-TASKS.md
Integration contract: docs/architecture/integrations/PF-101-google-workspace-integration-INTEGRATION.md
Status: Alpha — WS1/WS2/WS5 complete; WS6 partial; WS7 in progress.
What this integration does
PF-101 makes Google Workspace a first-class platform connector alongside Microsoft Entra. It owns:- Directory lifecycle — provision / suspend / restore Workspace users from HR-01 employee events.
- Gmail — outbound mail via Workspace Domain-Wide Delegation, replacing the legacy
GMAIL_SERVICE_ACCOUNT_JSONenv-only path. - Calendar + Meet — event creation and Meet conferencing for CE scheduling.
- Licensing — assign / revoke Google licenses (e.g.,
Google-Apps-For-Business) per user. - Reports — ingest
admin,login, andtokenaudit activities intopf_audit_log(actor email SHA-256 hashed; no PHI). - Drive (deferred) — metadata-only mapping in MVP; explicit PF-11 export/import for content.
- Chat (deferred) — PHI is always blocked; only PF-10 approved templates allowed.
Multi-tenant model
- One row in
pf_google_workspace_connectionsper(organization_id, primary_domain). - All four PF-101 tables
ENABLEandFORCErow level security and use the canonicalpf_has_org_access/pf_is_org_adminSECURITY DEFINER helpers. - Service account JSON, OAuth client secrets, and refresh tokens never live in tables, env vars, or logs — they resolve through PF-76 Credential Vault by stable
credential_vault_ref.
Capability flags & PHI gating (fail-closed)
Every Workspace operation runs throughassertCapabilityAllowed(connection, capability) in supabase/functions/_shared/google-workspace-client.ts. The check denies by default and requires:
- The capability column is
trueon the connection (e.g.,capability_gmail_enabled). - For PHI-capable capabilities (Gmail, Calendar, Drive, Chat),
baa_attested_at IS NOT NULL. - Sender domain (Gmail) matches the connection’s
primary_domainallowlist.
pf_google_workspace_sync_runs with status = 'failed' and a sanitized reason_code — never the error body.
Edge functions
| Function | Purpose | Trigger |
|---|---|---|
google-workspace-test-connection | Per-capability health check (Directory, Gmail, Calendar, …) | UI / cron |
google-workspace-provision-user | Create or update Workspace user; upsert pf_google_workspace_user_links | HR-01 events |
google-workspace-offboard-user | Suspend user; queue license revoke / group removal | HR-01 events |
google-workspace-hr-event-subscriber | Routes HR-01 employee events to provision / offboard | pgmq subscriber |
google-workspace-directory-reconcile | Compares HR employees vs Workspace suspended state | Cron (T5.5) |
google-workspace-calendar-event | Create event with optional Meet link | Platform API |
google-workspace-license-manage | Idempotent SKU assign / revoke | Platform API + offboard |
google-workspace-reports-ingest | Audit activity → pf_audit_log (hashed actor) | Cron |
Cross-core consumption
Cores never import Google client code directly. The only allowed surface is:supabase/functions/_shared/email-provider.ts, which prefers a PF-101 connection and falls back to the legacy GMAIL_SERVICE_ACCOUNT_JSON env until each tenant migrates.
Open decisions (per PLAN)
| Decision | MVP resolution |
|---|---|
| HR update events | Scheduled directory reconciliation (T5.5) until HR-01 ships hr_employee_updated |
| DWD key strategy | PF-76-managed service-account key; harden toward IAM signJwt |
| Drive content sync | Metadata-only; explicit PF-11 action for content transfer |
| Chat PHI | Always blocked in Chat; PF-10 templates only |
See also
GOOGLE_WORKSPACE_SETUP.md— admin runbookGOOGLE_WORKSPACE_COMPLIANCE.md— BAA, scopes, audit, retention