Libra CodeHub

CedarCopilot/cedar-mail

Branch: staging

feat(permissions): one authority for every access decision

merged#2645CedarCopilot

CedarCopilot wants to merge 9 commits into staging from feat/permissions-authorize

Live on prod since Wed, 1 of 8 behaviors workingTimeline and evidence
  1. Opened
    Sep 1, 2026, 8:02 AM
  2. Sep 2, 2026, 3:13 PM
  3. Merged
    Sep 2, 2026, 3:54 PM
  4. Live on staging
    Sep 2, 2026, 3:54 PM
  5. Live on prod
    Sep 2, 2026, 3:54 PM
  6. Observed 39 hours
    Sep 2, 2026, 3:54 PM
  7. Pipelines steady after this deploy
    Sep 2, 2026, 3:54 PM
  8. Pipelines steady after this deploy
    Sep 2, 2026, 3:54 PM
  9. Verified

    Live on prod since Wed, 1 of 8 behaviors working

    Sep 4, 2026, 6:42 AM

Behaviors Libra is checking

Background jobs behavior from agent-action-queue/queries.ts, routes/agent-action-queue.ts keeps working in prod.Workingmedium confidence

Post-deploy production telemetry shows healthy Background jobs activity: scheduled_task_queue_processing ran 16 times across 12 users <id> 59.2s, p99 62.1s); processScheduledEmails produced 32 spans, all STATUS_CODE_OK (p95 171ms, p99 236ms), with 32 matching cron success.

prod, checked Sep 4, 2026, 4:43 AM
AOP context behavior from components/ActionQueueView.tsx, components/AgentDocHeader.tsx, components/AgentFieldsCallout.tsx keeps working in prod.Inconclusivelow confidence

Strict CloudWatch fallback saw 1,988 success-shaped log lines matching pipeline, analytics, quota, aop, but no tied operation was present, so Libra is not calling this working.

prod, checked Sep 4, 2026, 3:41 AM
Authentication and access behavior from auth/authorize.ts, auth/org-access.ts keeps working in prod.Inconclusivelow confidence

Strict CloudWatch fallback found 10 recent prod failure log lines for [processIncomingSlackChannelData] Error processing channel (No valid connection tokens found for user <id>), but the same failure had 5 log lines in the comparable pre-deploy baseline. Libra is not blaming.

prod, checked Sep 4, 2026, 3:41 AM
Chat workflow behavior from chat-agent/page.tsx, crm/conversation-members.ts keeps working in prod.Inconclusivelow confidence

Strict CloudWatch fallback found 254 prod failure log lines for mirror.upsertEmailThread failed (Failed query: insert into \), but this domain-wide failure family is not tied to this intent.

prod, checked Sep 4, 2026, 4:43 AM
CRM integration behavior from tools/apply-systems-change.ts, tools/applyConfigChangeTool.ts, tools/getSentEmailsTool.ts keeps working in prod.Inconclusivelow confidence

Strict CloudWatch fallback found 143 recent prod failure log lines for [UpdateExternalCrmWorkflow] Driver update failed (Step updateOpportunityField failed: HTTP 400: [{\), but the same failure had 165 log lines in the comparable pre-deploy baseline. Libra is not blaming this.

prod, checked Sep 4, 2026, 5:41 AM
Dashboard UI behavior from ui-config/uiConfigTool.ts keeps working in prod.Inconclusivelow confidence

Verification reached its 120s wall-clock budget before a tied verdict. Libra is keeping this intent verifying until the next check.

prod, checked Sep 4, 2026, 5:43 AM

Failures attributed to this change

No prod customers are affected while this is only in staging. If promoted, prod impact is unknown because Libra still needs a concrete exception, route, and failed user action before assigning severity. 0 hits · no retained affected-user count · no retained trace sample.Introducedmedium confidence

internal_only

staging, first seen Sep 2, 2026, 4:55 PM

Libra has verdicts on 1 of 8 tracked behaviors on prod; 7 are still being checked. Libra checks hourly for 3 days after each deploy.

What this is

Every "may this caller act on this data" decision in the codebase now routes through one function, services/auth/authorize.ts. It returns a verdict, never a role , there is deliberately no isOrgAdmin on the return type, so no call site can branch on one, and changing the permission model is a change to the DEFAULT_POLICY table rather than a sweep through the codebase.

Ships with zero schema changes. resolvePolicy(orgId) is a private seam that returns a frozen constant today; when the model is decided it becomes a column read and no call site changes.

It replaces canActOnTarget, resolveOrgMembership, userIsOrgAdmin, an inline same-org check in listTasksTool, and eleven if (!isOrgAdmin) sites that each re-derived the rule. One of them computed it on the wrong user.

The feature

Org admins can administer a teammate's playbook and configuration. targetUserId is uniform across the tool layer, the tRPC layer gained the org-admin path (~20 routes), and the frontend gained a scoped provider and member picker built so that no surface ever renders one person's data labelled as another's.

Eleven holes closed

All the same shape: a caller-supplied identifier resolving to another user's data below the gate.

SiteIdentifierSeverity
applyConfigChangeTooluserId inputcross-tenant write
readConnectionSettingsTooluserId inputcross-tenant read
writeDocumentToolorg-linked playbook pathcross-tenant write
listDocumentsTool / displayDocumentToolsame path, ungatedmetadata leak
configureStrategistToolbare aopId, no check at allcross-tenant write
getSentEmailsTooluserId inputverbatim sent/drafted bodies
aopAgents.listForAopaopIdsubagent docs to any caller
agent-action-queue (5 routes)userId / runIddestructive: delete, replay
custom-field-managementownerId resolved then ignoredcross-user + cross-org write
overview-instanceorg scope, no tenant comparisoncross-tenant write
admin router + 14 sub-routers~45 proceduresreads, deletes, fleet enumeration

Two were destructive. Three were cross-tenant writes. One was introduced by an earlier fix in this same change set and caught by a later sweep.

Every one is pre-existing. Nothing here got worse; it got visible.

Enforcement

Five guards keyed on the live registry, not hand-written lists, each with an anti-vacuity floor, each proven by planting the violation and watching it fail:

  • no bare userId inputs on any registered tool
  • every file naming targetUserId reaches the authority
  • every mutating action is administrable or documented self-only
  • role reads confined to the authority (dependency-cruiser rule + source scan)
  • redirect sites consult the authority about the resolved target

The last one matters because a call site that asks the authority about the caller passes any "is authorize() called here" review and still leaks.

Decisions worth reviewing

  • agentExecutionEnabled is Cedar-staff-only, enforced in the single writer so no path can miss it. Stronger than SELF (the account owner cannot set it either), so deliberately not a policy row: every capability in that table is something an org can be granted, and this is grantable to nobody.
  • playbook:org and document:org are ANY_MEMBER, matching today's behaviour. 57 of 73 orgs have no admin at all, and 1,418 documents live under organisation/; ORG_ADMIN would have locked members out of their own knowledge base. Tightening is one cell once admins exist.
  • Two org-role gates were dead. ctx.sessionUser.organizationRole is not in better-auth's additionalFields, so it read undefined on every request and statistics.getOrgOverview refused everyone. Now works. This is a real widening from nobody to admins.
  • **A read-only viewer is now refused on `mergeConversati
Show production surfaces and changed-file mapping

Production surfaces

Libra has not measured any production surfaces for this change yet.

Changed files → surfaces

  • .dependency-cruiser.cjsno production surface mapped
  • apps/mail/app/(routes)/agents/playbook/page.tsxno production surface mapped
  • apps/mail/app/(routes)/brain/playbooks/chat-agent/page.tsxno production surface mapped
  • apps/mail/app/(routes)/brain/playbooks/page.tsxno production surface mapped
  • apps/mail/app/(routes)/brain/playbooks/routing/page.tsxno production surface mapped
  • apps/mail/app/(routes)/playground/components/PlaybookEditor.tsxno production surface mapped
  • apps/mail/app/(routes)/settings/appearance/page.tsxno production surface mapped
  • apps/mail/app/(routes)/settings/danger-zone/page.tsxno production surface mapped
  • apps/mail/app/(routes)/settings/general/page.tsxno production surface mapped
  • apps/mail/app/(routes)/settings/notifications/page.tsxno production surface mapped
  • apps/mail/app/(routes)/settings/security/page.tsxno production surface mapped
  • apps/mail/app/(routes)/settings/signature/page.tsxno production surface mapped
  • apps/mail/messages/en.jsonno production surface mapped
  • apps/mail/modules/administeredUser/components/AdminNotice.tsxno production surface mapped
  • apps/mail/modules/administeredUser/components/AdministeredUserBanner.tsxno production surface mapped
  • apps/mail/modules/administeredUser/components/AdministeredUserBar.tsxno production surface mapped
  • apps/mail/modules/administeredUser/components/AdministeredUserPicker.tsxno production surface mapped
  • apps/mail/modules/administeredUser/components/DocumentOwnerBanner.tsxno production surface mapped
  • apps/mail/modules/administeredUser/components/ScopeNotHonouredNotice.tsxno production surface mapped
  • apps/mail/modules/administeredUser/context.tsxno production surface mapped
  • apps/mail/modules/administeredUser/contract.tsno production surface mapped
  • apps/mail/modules/administeredUser/hooks/use-org-admin-access.tsno production surface mapped
  • apps/mail/modules/administeredUser/index.tsno production surface mapped
  • apps/mail/modules/administeredUser/permission-error.tsno production surface mapped
  • apps/mail/modules/aop/components/ActionQueueView.tsxno production surface mapped
  • apps/mail/modules/aop/components/AgentDocHeader.tsxno production surface mapped
  • apps/mail/modules/aop/components/AgentFieldsCallout.tsxno production surface mapped
  • apps/mail/modules/aop/components/CrmAgentConfigPanel.tsxno production surface mapped
  • apps/mail/modules/aop/components/PlaybookSettingsPanel.tsxno production surface mapped
  • apps/mail/modules/aop/components/StrategicOverviewConfigPanel.tsxno production surface mapped
  • apps/mail/modules/aop/hooks/use-aops.tsno production surface mapped
  • apps/mail/modules/brain/components/AopManageDialogs.tsxno production surface mapped
  • apps/mail/modules/brain/components/PlaybookAopSection.tsxno production surface mapped
  • apps/mail/modules/brain/components/PlaybookFileTree.tsxno production surface mapped
  • apps/mail/modules/cedar-os/__tests__/__mocks__/auth-client.tsno production surface mapped
  • apps/mail/modules/company/components/CompanyExplorer.tsxno production surface mapped
  • apps/mail/modules/documents/playbook/CompositePlaybookDocument.tsxno production surface mapped
  • apps/mail/modules/documents/playbook/PlaybookDocument.tsxno production surface mapped
  • apps/mail/modules/documents/playbook/PlaybookDocumentCreateDialog.tsxno production surface mapped
  • apps/mail/modules/documents/playbook/PlaybookStageNode.tsxno production surface mapped
  • apps/mail/modules/documents/playbook/PlaybookTriggerNode.tsxno production surface mapped
  • apps/mail/modules/documents/playbook/SubagentCreateDialog.tsxno production surface mapped
  • apps/mail/modules/documents/playbook/TriggerNode.tsxno production surface mapped
  • apps/mail/modules/documents/playbook/WebhookTriggerPanel.tsxno production surface mapped
  • apps/mail/modules/documents/playbook/playbookExtensions.tsno production surface mapped
  • apps/mail/modules/documents/playbook/structure/index.tsxno production surface mapped
  • apps/mail/modules/documents/playbook/useDocumentCreation.tsxno production surface mapped
  • apps/mail/modules/documents/playbook/usePlaybookAop.tsno production surface mapped
  • apps/mail/modules/documents/playbook/useSubagentCreation.tsxno production surface mapped
  • apps/mail/modules/home/components/DisplayArtifactPanel.tsxno production surface mapped
  • apps/mail/modules/userSettings/hooks/use-settings.tsno production surface mapped
  • apps/mail/providers/client-providers.tsxno production surface mapped
  • apps/mail/tests/modules/administeredUser/contract-coverage.test.tsno production surface mapped
  • apps/mail/tests/modules/administeredUser/permission-error.test.tsno production surface mapped
  • apps/mail/tests/modules/administeredUser/scope-not-honoured-notice.test.tsxno production surface mapped
  • apps/mail/tests/modules/playbook/playbook-document-owner.test.tsxno production surface mapped
  • apps/server/src/mastra/mcp/external/__tests__/mutating-actions-are-administrable.test.tsno production surface mapped
  • apps/server/src/mastra/mcp/external/__tests__/no-bare-user-id-inputs.test.tsno production surface mapped
  • apps/server/src/mastra/mcp/external/__tests__/scope-map.test.tsno production surface mapped
  • apps/server/src/mastra/mcp/external/scope-map.tsno production surface mapped
  • apps/server/src/mastra/mcp/external/server.tsno production surface mapped
  • apps/server/src/mastra/skills/account-config/tools/__tests__/apply-systems-change.test.tsno production surface mapped
  • apps/server/src/mastra/skills/account-config/tools/__tests__/applyConfigChangeTool.test.tsno production surface mapped
  • apps/server/src/mastra/skills/account-config/tools/__tests__/get-sent-emails-authorization.test.tsno production surface mapped
  • apps/server/src/mastra/skills/account-config/tools/__tests__/read-connection-settings-authorization.test.tsno production surface mapped
  • apps/server/src/mastra/skills/account-config/tools/apply-systems-change.tsno production surface mapped
  • apps/server/src/mastra/skills/account-config/tools/applyConfigChangeTool.tsno production surface mapped
  • apps/server/src/mastra/skills/account-config/tools/getSentEmailsTool.tsno production surface mapped
  • apps/server/src/mastra/skills/account-config/tools/readConnectionSettingsTool.tsno production surface mapped
  • apps/server/src/mastra/tools/config/__tests__/configTool.test.tsno production surface mapped
  • apps/server/src/mastra/tools/config/__tests__/configureStrategistTool.test.tsno production surface mapped
  • apps/server/src/mastra/tools/config/__tests__/listOrgMembers.test.tsno production surface mapped
  • apps/server/src/mastra/tools/config/__tests__/workspaceWriteTool.test.tsno production surface mapped
  • apps/server/src/mastra/tools/config/config-read-tool.tsno production surface mapped
  • apps/server/src/mastra/tools/config/config-tool-shared.tsno production surface mapped
  • apps/server/src/mastra/tools/config/config-write-tool.tsno production surface mapped
  • apps/server/src/mastra/tools/config/configTool.tsno production surface mapped
  • apps/server/src/mastra/tools/config/configureStrategistTool.tsno production surface mapped
  • apps/server/src/mastra/tools/config/connection-write-tool.tsno production surface mapped
  • apps/server/src/mastra/tools/config/systems-write-tool.tsno production surface mapped
  • apps/server/src/mastra/tools/config/workspace-write-tool.tsno production surface mapped
  • apps/server/src/mastra/tools/document/__tests__/document-redirect-authorization.test.tsno production surface mapped
  • apps/server/src/mastra/tools/document/__tests__/documentTool.test.tsno production surface mapped
  • apps/server/src/mastra/tools/document/__tests__/readDocumentTool.by-id.test.tsno production surface mapped
  • apps/server/src/mastra/tools/document/__tests__/writeDocumentTool.test.tsno production surface mapped
  • apps/server/src/mastra/tools/document/displayDocumentTool.tsno production surface mapped
  • apps/server/src/mastra/tools/document/documentTool.tsno production surface mapped
  • apps/server/src/mastra/tools/document/listDocumentsTool.tsno production surface mapped
  • apps/server/src/mastra/tools/document/readDocumentTool.tsno production surface mapped
  • apps/server/src/mastra/tools/document/writeDocumentTool.tsno production surface mapped
  • apps/server/src/mastra/tools/family-tool-names.tsno production surface mapped
  • apps/server/src/mastra/tools/mail/__tests__/mailTool.live-actions.test.tsno production surface mapped
  • apps/server/src/mastra/tools/mail/__tests__/mailTool.test.tsno production surface mapped
  • apps/server/src/mastra/tools/mail/mailTool.tsno production surface mapped
  • apps/server/src/mastra/tools/task/listTasksTool.tsno production surface mapped
  • apps/server/src/mastra/tools/ui-config/__tests__/uiConfigTool.test.tsno production surface mapped
  • apps/server/src/mastra/tools/ui-config/uiConfigTool.tsno production surface mapped
  • apps/server/src/mastra/utils/__tests__/target-user-scope.test.tsno production surface mapped
  • apps/server/src/mastra/utils/approval-policy.tsno production surface mapped
  • apps/server/src/mastra/utils/target-user-scope.tsno production surface mapped
  • apps/server/src/services/agent-action-queue/__tests__/execution-read-scope.test.tsno production surface mapped
  • apps/server/src/services/agent-action-queue/queries.tsno production surface mapped
  • apps/server/src/services/aop/__tests__/custom-field-management-ownership.test.tsno production surface mapped
  • apps/server/src/services/aop/__tests__/custom-field-management.test.tsno production surface mapped
  • apps/server/src/services/aop/custom-field-management.tsno production surface mapped
  • apps/server/src/services/auth/__tests__/authorize.test.tsno production surface mapped
  • apps/server/src/services/auth/__tests__/org-access.test.tsno production surface mapped
  • apps/server/src/services/auth/__tests__/role-reads-confined-to-authority.test.tsno production surface mapped
  • apps/server/src/services/auth/__tests__/target-user-id-reaches-the-authority.test.tsno production surface mapped
  • apps/server/src/services/auth/authorize.tsno production surface mapped
  • apps/server/src/services/auth/org-access.tsno production surface mapped
  • apps/server/src/services/crm/__tests__/company-merge-authorization.test.tsno production surface mapped
  • apps/server/src/services/crm/__tests__/conversation-members.test.tsno production surface mapped
  • apps/server/src/services/crm/__tests__/strategic-catalog-authorization.test.tsno production surface mapped
  • apps/server/src/services/crm/company-merge.tsno production surface mapped
  • apps/server/src/services/crm/conversation-members.tsno production surface mapped
  • apps/server/src/services/crm/overview-instance.tsno production surface mapped
  • apps/server/src/services/documents/__tests__/playbook-doctype.test.tsno production surface mapped
  • apps/server/src/services/documents/convention-paths.tsno production surface mapped
  • apps/server/src/services/documents/triggers/board-webhooks.tsno production surface mapped
  • apps/server/src/services/organizations/__tests__/org-admin.test.tsno production surface mapped
  • apps/server/src/services/organizations/members.tsno production surface mapped
  • apps/server/src/services/organizations/org-admin.tsno production surface mapped
  • apps/server/src/services/playbook/__tests__/playbook-webhook-registration.test.tsno production surface mapped
  • apps/server/src/services/playbook/playbook-path-access.tsno production surface mapped
  • apps/server/src/services/playbook/playbook-webhook-registration.tsno production surface mapped
  • apps/server/src/services/users/__tests__/categorized-key-access.test.tsno production surface mapped
  • apps/server/src/services/users/__tests__/staff-only-agent-execution.test.tsno production surface mapped
  • apps/server/src/services/users/__tests__/user-settings-merge.test.tsno production surface mapped
  • apps/server/src/services/users/__tests__/user-settings.test.tsno production surface mapped
  • apps/server/src/services/users/staff-only-settings.tsno production surface mapped
  • apps/server/src/services/users/user-settings.tsno production surface mapped
  • apps/server/src/trpc/assert-actor.tsno production surface mapped
  • apps/server/src/trpc/routes/__tests__/admin-agent-toggles-staff-gate.test.tsno production surface mapped
  • apps/server/src/trpc/routes/__tests__/admin-crm-sync-staff-gate.test.tsno production surface mapped
  • apps/server/src/trpc/routes/__tests__/admin-data-subrouter-target-gate.test.tsno production surface mapped
  • apps/server/src/trpc/routes/__tests__/admin-integrity-account-health-staff-gate.test.tsno production surface mapped
  • apps/server/src/trpc/routes/__tests__/admin-router-target-gate.test.tsno production surface mapped
  • apps/server/src/trpc/routes/__tests__/admin-subrouter-target-gate.test.tsno production surface mapped
  • apps/server/src/trpc/routes/__tests__/agent-action-queue-execution-scope.test.tsno production surface mapped
  • apps/server/src/trpc/routes/__tests__/analytics-guard.test.tsno production surface mapped
  • apps/server/src/trpc/routes/__tests__/aop-agents-list-scope.test.tsno production surface mapped
  • apps/server/src/trpc/routes/__tests__/aop-agents-router.test.tsno production surface mapped
  • apps/server/src/trpc/routes/__tests__/aop-create-playbook-document-owner.test.tsno production surface mapped
  • apps/server/src/trpc/routes/__tests__/aop-list-scope.test.tsno production surface mapped
  • apps/server/src/trpc/routes/__tests__/aop-sent-email-scope.test.tsno production surface mapped
  • apps/server/src/trpc/routes/__tests__/aop-staff-delegation.test.tsno production surface mapped
  • apps/server/src/trpc/routes/__tests__/credential-vault-org-admin.test.tsno production surface mapped
  • apps/server/src/trpc/routes/__tests__/crm-owner-reassignment-authority.test.tsno production surface mapped
  • apps/server/src/trpc/routes/__tests__/files-restore-node.test.tsno production surface mapped
  • apps/server/src/trpc/routes/__tests__/files-router-auth.test.tsno production surface mapped
  • apps/server/src/trpc/routes/__tests__/files-router-permission-request.test.tsno production surface mapped
  • apps/server/src/trpc/routes/__tests__/integrations-mcp-delete.test.tsno production surface mapped
  • apps/server/src/trpc/routes/__tests__/integrations-mcp-org-scope.test.tsno production surface mapped
  • apps/server/src/trpc/routes/__tests__/settings-router.test.tsno production surface mapped
  • apps/server/src/trpc/routes/__tests__/user-tasks-conversation-scope.test.tsno production surface mapped
  • apps/server/src/trpc/routes/admin-account-health.tsno production surface mapped
  • apps/server/src/trpc/routes/admin-boards.tsno production surface mapped
  • apps/server/src/trpc/routes/admin-crm-sync.tsno production surface mapped
  • apps/server/src/trpc/routes/admin-email-analysis.tsno production surface mapped
  • apps/server/src/trpc/routes/admin-integrity.tsno production surface mapped
  • apps/server/src/trpc/routes/admin.tsno production surface mapped
  • apps/server/src/trpc/routes/agent-action-queue.tsno production surface mapped
  • apps/server/src/trpc/routes/analytics-access.tsno production surface mapped
  • apps/server/src/trpc/routes/analytics.tsno production surface mapped
  • apps/server/src/trpc/routes/aop-agents.tsno production surface mapped
  • apps/server/src/trpc/routes/aop.tsno production surface mapped
  • apps/server/src/trpc/routes/cedar-admin.tsno production surface mapped
  • apps/server/src/trpc/routes/crm.tsno production surface mapped
  • apps/server/src/trpc/routes/documents.tsno production surface mapped
  • apps/server/src/trpc/routes/files.tsno production surface mapped
  • apps/server/src/trpc/routes/integrations.tsno production surface mapped
  • apps/server/src/trpc/routes/org-admin.tsno production surface mapped
  • apps/server/src/trpc/routes/organisation.tsno production surface mapped
  • apps/server/src/trpc/routes/settings.tsno production surface mapped
  • apps/server/src/trpc/routes/statistics.tsno production surface mapped
  • docs/design/admin-config-permissions-revamp.mdno production surface mapped