Skip to content

fix(training-agent): support organization OAuth sandboxes - #8202

Merged
bokelley merged 2 commits into
mainfrom
bokelley/adcp-issue-8196
Oct 14, 2026
Merged

bokelley merged 2 commits into
mainfrom
bokelley/adcp-issue-8196

Conversation

@bokelley

@bokelley bokelley commented Oct 14, 2026 •

Copy link
Copy Markdown
Contributor

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:

  • Security, code/testing, and buyer-flow/documentation expert reviews; findings addressed.
  • Real PostgreSQL and HTTP MCP integration, including an ordinary member with no local grant, separate organizations, private reporting denial, and credential revocation.
  • HTTP task completion regression covering another organization using the same OAuth client and renewed credentials.
  • Root unit tests and pre-commit guards, TypeScript typechecking, documentation navigation and schema-link checks.

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 main application code; the current main commit 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.

aao-secretariat[bot]
aao-secretariat Bot previously approved these changes Oct 14, 2026

@aao-secretariat aao-secretariat Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@aao-secretariat aao-secretariat Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@bokelley
bokelley merged commit 05dcacf into main Oct 14, 2026
73 of 75 checks passed
@bokelley
bokelley deleted the bokelley/adcp-issue-8196 branch October 14, 2026 18:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Training agent: OAuth sign-in succeeds but /sales/mcp returns 403 to anyone outside the private canary org

2 participants