Libra CodeHub

CedarCopilot/cedar-mail

Branch: staging

Org admin/owner can view a teammate's agent workspace

merged#2759CedarCopilot

CedarCopilot wants to merge 4 commits into staging from feat/agent-org-admin-access

Live on prod since Fri, 2 of 10 surfaces workingTimeline and evidence
  1. Opened
    Sep 11, 2026, 9:42 AM
  2. Sep 11, 2026, 10:48 AM
  3. Live on staging
    Sep 11, 2026, 10:53 AM
  4. Pipelines steady after this deploy
    Sep 11, 2026, 10:53 AM
  5. Merged
    Sep 11, 2026, 10:53 AM
  6. Live on prod
    Sep 11, 2026, 10:53 AM
  7. Observed 38 hours, 10 surfaces, 110 requests
    Sep 11, 2026, 10:53 AM
  8. Pipelines steady after this deploy
    Sep 11, 2026, 10:53 AM
  9. Verified

    Live on prod since Fri, 2 of 10 surfaces working

    Sep 13, 2026, 12:37 AM

Behaviors Libra is checking

The agents grid can be narrowed to agents filed under a selected conversation type, defaults once to Deals when available, resets the selection when the administered user changes, and supports an explicit all-types view.Workinglow confidence

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

staging, checked Sep 14, 2026, 10:02 AM
Opening a teammate-owned document from the playbook file tree preserves that document's real owner through the Brain URL, document lookup, and embedded AgentDocumentView instead of relying on a stale ambient user picker.Inconclusivelow confidence

Verification reached its budget before a verdict.

prod, checked Sep 12, 2026, 8:24 PM
Org administrators and owners can access a teammate's agent workspace through the target-user context, while callers without administration rights remain denied.Inconclusivelow confidence

Verification reached its 130s outer budget before the verifier returned. Libra is keeping this intent verifying until the next check.

prod, checked Sep 12, 2026, 8:35 PM
Administrators can filter the selected teammate's agent grid by conversation type, with Deals selected by default and the filter reset when switching administered users.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 12, 2026, 8:37 PM
Administrators can inspect and update a teammate agent's MCP grants and connection scopes from the connections panel.Inconclusivelow confidence

The available telemetry shows no executions of the target-scoped MCP grant or connection-scope procedures since deployment; only unrelated agent tRPC traffic was observed. This is insufficient positive evidence to verify the behavior, so the result is inconclusive.

prod, checked Sep 12, 2026, 9:34 PM
The agent action menu applies supported publish, unpublish, preview, and delete operations to the teammate's agent rather than to an identically named agent owned by the administrator.Inconclusivehigh confidence

Since the 2026-09-11T17:53:34Z deploy, production telemetry contains no matching previewPublish, publishToOrg, unpublishFromOrg, or agent.delete mutation spans or CloudWatch operation logs (0 observed). There is positive agent verification traffic—78 agent.list calls and 11.

prod, checked Sep 12, 2026, 9:35 PM

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. 2 hits · no retained affected-user count · no retained trace sample.Introducedmedium confidence

internal_only

staging, first seen Sep 11, 2026, 12:20 PM
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. 2 hits · no retained affected-user count · no retained trace sample.Introducedmedium confidence

internal_only

staging, first seen Sep 11, 2026, 12:20 PM
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. 2 hits · no retained affected-user count · no retained trace sample.Introducedmedium confidence

internal_only

staging, first seen Sep 11, 2026, 12:20 PM
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. 2 hits · no retained affected-user count · no retained trace sample.Introducedmedium confidence

internal_only

staging, first seen Sep 11, 2026, 12:20 PM
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. 2 hits · no retained affected-user count · no retained trace sample.Introducedmedium confidence

internal_only

staging, first seen Sep 11, 2026, 12:20 PM
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 11, 2026, 12:20 PM
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 11, 2026, 6:11 PM
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 11, 2026, 6:11 PM

Libra measured 2 of 10 production surfaces on prod. 4 surfaces had under 20 requests, so Libra has not judged them; 4 surfaces had no requests at all. Libra checks hourly for 3 days after each deploy.

Summary

Karim (Adapt Insurance, org admin) reported he still couldn't view a teammate's (Jacob's) agent execution logs or open his Deal Risk agent, even after run-sql was fixed to allow admin reads (yesterday's fix). Root cause: two separate, unrelated gaps.

  • agent.ts's Agent Workspace router only ever resolved an agentId inside the caller's own AOP set , an org admin got a generic NOT_FOUND regardless of role, because it never went through the authorize() permission authority PR #2749 already proved out for the debug tool.
  • The frontend never had a way to reach it. CompanyExplorer's FileEditor makes an unscoped documents.getDoc call that throws FORBIDDEN for a teammate's private document before the page ever gets far enough to hit the agent-specific code , the more likely actual source of the "document access error," found during review of the first fix.

Changes

  1. agent.ts , requireAgent now accepts targetUserId and routes through resolveAgentForAdmin (org-admin gated via authorize()'s subagent_execution:user policy) instead of resolveAgentForCaller when it names someone else. All 31 procedures updated; runNow/createWebhookSource correctly execute as the target, not the calling admin (their own connections/credentials, not the admin's). duplicate stays self-only , its single-userId design has no clean cross-user answer , and now rejects a cross-user targetUserId rather than silently ignoring it (a thermo-review finding on the first commit).
  2. AgentView/AgentDocumentView , accept targetUserId as an explicit prop (never read ambiently , both are mounted on surfaces with no admin picker) and thread it into every trpc.agent.* call.
  3. CompanyExplorer/PlaybookAopSection/brain-routes.tsx , the file tree already resolves the administered teammate correctly; that owner now rides the URL (brainDocumentPath's new ownerUserId param → ?targetUserId=) into CompanyExplorer's one blocking documents.getDoc call, which already accepted targetUserId server-side.
  4. contract.ts , asserts every new agent.* scoped call site actually accepts targetUserId; the documents.getDoc call needed no new assertion (already covered).

Test plan

  • pnpm --filter @zero/server run types , clean
  • pnpm --filter @zero/mail run types , clean
  • New server tests: org-admin/plain-member/cross-org matrix, runNow identity-correctness, duplicate rejection (10 tests, agent-router-org-admin.test.ts)
  • Existing server tests unaffected: agent-router-auth.test.ts, agent-scoped-reads.test.ts (36/36 total)
  • administeredUser contract-coverage test , confirms every new scoped call site is both detectable and asserted (3/3)
  • modules/agents, modules/company, modules/brain Jest suites , 269/269
  • eslint clean on all 10 touched files
  • Self-reviewed with /thermo-review; findings addressed inline (see commit messages) or noted as deliberate scope boundaries (route-layer authz logic staying in agent.ts rather than a new service , flagged as a follow-up, not blocking)

Greptile Summary

This PR extends the agent workspace and Brain discovery surfaces so organization administrators can inspect and manage a teammate's agents, threads explicit owner scope through agent queries and mutations, and prevents impersonated chat turns from being recorded under the teammate.

  • Adds effective-user authorization and resolution across the agent router.
  • Carries teammate ownership through document navigation and nested workspace components.
  • Adds administered-user and conversation-type filtering to the Brain agent catalog.
  • Marks admin-view chat execution so it can avoid writing into the viewed user's history.
  • The latest changes leave an unsafe client-controlled admin-view fallback and an owner-scope navigation regression.

Confidence Score: 1/5

The PR is not safe to

Show production surfaces and changed-file mapping

Production surfaces

SurfaceRequestsErrorsp95UsersVerdict
orchestrator_agent_step86 → 670 → 0 (0%)208413 ms → 171212 ms31Working
67 requests since the deploy with 0 errors (0 errors in the 86-request baseline before it). p95 171212 ms, was 208413 ms.
model_chunk On-Event Execution Agent (Understudy)63 → 200 → 0 (0%)5 ms → 1 ms0Working
20 requests since the deploy with 0 errors (0 errors in the 63-request baseline before it). p95 1 ms, was 5 ms.
/api/trpc/agentExecutions.getAgentExecutions15 → 180 → 0 (0%)9318 ms → 200 ms0Insufficient traffic
18 requests, under the 20 Libra needs
invoke_agent Next Steps and Tasks Manager22 → 140 → 0 (0%)643205 ms → 58600 ms0Insufficient traffic
14 requests, under the 20 Libra needs
orchestrator_agent_step32 → 90 → 0 (0%)139410 ms → 365450 ms6Insufficient traffic
9 requests, under the 20 Libra needs
model_chunk Automation Agent (Understudy)47 → 60 → 0 (0%)3 ms → 1 ms0Insufficient traffic
6 requests, under the 20 Libra needs
model_chunk On-Event Execution Agent (Understudy)12 → 50 → 0 (0%)1 ms → 2 ms0Insufficient traffic
5 requests, under the 20 Libra needs
/api/trpc/agent.list0 → 30 → 0 (0%)not measured → 415 ms0Insufficient traffic
3 requests, under the 20 Libra needs
/api/trpc/agentExecutions.executeFromClientSend0 → 20 → 0 (0%)not measured → 12935 ms0Insufficient traffic
2 requests, under the 20 Libra needs
invoke_agent Next Steps and Tasks Manager0 → 10 → 0 (0%)not measured → 80282 ms0Insufficient traffic
1 request, under the 20 Libra needs
/api/trpc/agentExecutions.getAgentExecutions8 → 10 → 0 (0%)20979 ms → 5 ms0Insufficient traffic
1 request, under the 20 Libra needs
model_chunk Automation Agent (Understudy)3 → 00 → 0 (0%)not measured0No traffic
No requests recorded since this deploy.
model_chunk Automation Agent (Kimi K3 experiment)0 → 00 → 0 (0%)not measured0No traffic
No requests recorded since this deploy.
/api/trpc/agent.getInvocationSources3 → 00 → 0 (0%)3209 ms → not measured0No traffic
No requests recorded since this deploy.
/api/trpc/agentExecutions.executeFromClientSend0 → 00 → 0 (0%)not measured0No traffic
No requests recorded since this deploy.
/api/trpc/settings.updateAgentSettings2 → 00 → 0 (0%)167 ms → not measured0No traffic
No requests recorded since this deploy.
model_chunk Automation Agent (Kimi K3 experiment)0 → 00 → 0 (0%)not measured0No traffic
No requests recorded since this deploy.
/api/trpc/agent.list3 → 00 → 0 (0%)12584 ms → not measured0No traffic
No requests recorded since this deploy.
/api/trpc/agent.getInvocationSources0 → 00 → 0 (0%)not measured0No traffic
No requests recorded since this deploy.
/api/trpc/settings.updateAgentSettings0 → 00 → 0 (0%)not measured0No traffic
No requests recorded since this deploy.

Changed files → surfaces

  • apps/server/src/trpc/routes/agent.tsorchestrator_agent_stepmodel_chunk On-Event Execution Agent (Understudy)/api/trpc/agentExecutions.getAgentExecutionsinvoke_agent Next Steps and Tasks Managerorchestrator_agent_stepmodel_chunk Automation Agent (Understudy)+14
  • apps/mail/modules/administeredUser/contract.tsno production surface mapped
  • apps/mail/modules/agents/components/AgentActionMenu.tsxno production surface mapped
  • apps/mail/modules/agents/components/AgentAddConnectionDialog.tsxno production surface mapped
  • apps/mail/modules/agents/components/AgentConnectionsPanel.tsxno production surface mapped
  • apps/mail/modules/agents/components/AgentDocumentView.tsxno production surface mapped
  • apps/mail/modules/agents/components/AgentHeader.tsxno production surface mapped
  • apps/mail/modules/agents/components/AgentInstructionsSection.tsxno production surface mapped
  • apps/mail/modules/agents/components/AgentMemoryTab.tsxno production surface mapped
  • apps/mail/modules/agents/components/AgentOutputTab.tsxno production surface mapped
  • apps/mail/modules/agents/components/AgentSettingsSection.tsxno production surface mapped
  • apps/mail/modules/agents/components/AgentSourcesPanel.tsxno production surface mapped
  • apps/mail/modules/agents/components/AgentView.tsxno production surface mapped
  • apps/mail/modules/agents/components/AgentsGrid.tsxno production surface mapped
  • apps/mail/modules/agents/hooks/use-rename-agent.tsno production surface mapped
  • apps/mail/modules/agents/hooks/use-set-agent-default-file.tsno production surface mapped
  • apps/mail/modules/agents/queries.tsno production surface mapped
  • apps/mail/modules/agents/utils/agent-paths.tsno production surface mapped
  • apps/mail/modules/brain/brain-routes.tsxno production surface mapped
  • apps/mail/modules/brain/components/BrainHero.tsxno production surface mapped
  • apps/mail/modules/brain/components/PlaybookAopSection.tsxno production surface mapped
  • apps/mail/modules/company/components/CompanyExplorer.tsxno production surface mapped
  • apps/mail/tests/modules/brain/brainHero.test.tsxno production surface mapped
  • apps/server/src/http/app.tsno production surface mapped
  • apps/server/src/mastra/routeHandlers/chat/handleChat.tsno production surface mapped
  • apps/server/src/mastra/workflows/chat/chat-workflow.tsno production surface mapped
  • apps/server/src/services/agent-workspace/agent-read.tsno production surface mapped
  • apps/server/src/trpc/routes/__tests__/agent-router-org-admin.test.tsno production surface mapped