Repository navigation
fix(training-agent): support organization OAuth sandboxes - #8202
Conversation
There was a problem hiding this comment.
Ladon verdict: Approve
Approve — sales training OAuth widening from private-canary-only to organization sandbox.
Verified against the decision table (top-down): no critical/high findings (row 1 clear); gated_paths is false so row 2 does not apply; high_risk is false (rows 3/5 clear); no medium findings in any escalation category (row 4 clear); no prior decision (row 6 clear); no no-auto-approve team match (row 7 clear); zero medium findings, well under the three required for row 8. Falls through to row 9 → approve.
What I checked: This is an app/operational change with no protocol surface (static/schemas/source/**, task defs, normative docs/reference/**, dist artifacts) touched — so no changeset required, no oneOf/discriminator concern, no released-artifact immutability concern, no schema↔docs coherence obligation. The two docs files touched are quickstart and a runbook, not normative reference pages.
The authorization chain is sound per the reviewer: buyer-oauth.ts:194 validates selected against the token-verified org_id; sandbox access gates on fresh direct active WorkOS membership with a re-read after snapshot; privateBuyer determination fail-closes. Critically, /sales/reporting stays owner/admin-only after requireSalesAuth widened by routing through requireReportingAuth (index.ts:283). Buyer-agent state is isolated per-principal hash. Tests cover member admit, canary-role isolation, reporting denial, and revocation demotion. No multi-tenant boundary break or auth bypass present.
There was a problem hiding this comment.
Ladon verdict: Approve
Approve — subsequent pass, net improvement over a prior clean approve.
This PR is a value-equivalent refactor of the OAuth sandbox key derivation in the training-agent module. buyer-agent-registry.ts now reads a dedicated, server-stamped extra.training_buyer_principal (fail-closed on missing/empty) instead of reaching into training_oauth_actor.principal_id; buyer-oauth.ts stamps both fields from the same principal in a single object literal, and a test pins the equivalence. No path sets one field without the other, and the sha256 key value is unchanged.
No protocol surface touched (no static/schemas/source/**, no dist/** artifacts, no changeset-requiring published surface) — this is server-side app code plus docs/runbook. No critical/high/medium findings in this run. Prior pass was also a clean approve with no blockers.
Gate checks: no no-auto-approve team match; gated_paths false; high_risk false. No escalation triggers fire. Falls through to row 9.
Blocking findings: none.
Medium findings: none.
OAuth sign-in on the sales training agent succeeded for general callers, then every authenticated call returned 403 because authorization required a manually provisioned private canary grant. Active organization members can now use an organization-scoped sandbox through fresh direct WorkOS membership, while private reporting and the canary buyer identity retain their local owner/admin grant checks.
Buyer-agent task identities include the authorized principal and OAuth client. The test controller uses the same trusted identity, including after token renewal. Access denials include an OAuth challenge and explanation, and discovery links to current connection instructions served by the application.
Closes #8196.
Validation:
The full local server run passed 746 of 753 files. Seven unrelated files exceeded startup or bounded-worker timing budgets in this VM, including on isolated reruns. The representative native HTTP startup timeout also reproduces with unmodified
mainapplication code; the currentmaincommit passed GitHub's full build/test workflow. No test thresholds were changed. Merge depends on the PR's full CI results.The final head passes the full GitHub build/test, integration, and security checks. One unrelated bounded statistical fixture required a CI rerun; all numerical assertions and production guards remain unchanged. CodeQL's identifier-hashing finding was resolved by separating the public principal identifier from the OAuth actor audit context, with fresh security review and a green scan.
The PostgreSQL OAuth regression now provisions its isolated database from the standard loopback CI integration service, so it runs in CI instead of silently skipping. This is application and operational-documentation work; no protocol changeset is needed.
OAuth task ownership moves from a client-only identity to a principal-and-client identity. Start fresh async sandbox tasks after deployment; existing canary account/reporting principal IDs are preserved.