Skip to content

feat(training-agent): support WorkOS buyer sign-in and keyless canary credentials - #8039

Merged
bokelley merged 9 commits into
bokelley/training-agent-gcs-rolloutfrom
bokelley/training-buyer-sign-in
Oct 9, 2026
Merged

bokelley merged 9 commits into
bokelley/training-agent-gcs-rolloutfrom
bokelley/training-buyer-sign-in

Conversation

@bokelley

@bokelley bokelley commented Oct 8, 2026 •

Copy link
Copy Markdown
Contributor

Buyers without an organization API key cannot run the private reporting canary while key creation remains contained. This adds WorkOS Connect sign-in for the canonical sales tenant and a public PKCE buyer login helper. Reporting remains owned by the configured organization, and every request requires current direct WorkOS owner/admin membership plus an exact-credential local grant.

This PR builds on #8012 and targets its branch. Buyer OAuth and GCS reporting remain disabled. The Fly configuration mounts the staged dedicated external-account configuration at the explicit reporting credential path and permits its bounded Fly OIDC executable source. No private key or operator ADC is deployed.

  • Verify native Connect RS256 tokens against the exact issuer/JWKS and sales MCP audience. Require user/organization/client/consent claims, bounded lifetime/age, and reject machine-to-machine tokens and foreign organization selectors.
  • Read primary-database authority, bans and current WorkOS membership on each request. Recheck local identity/authorization epoch after the provider lookup. Dependency outages return 503 and log only fixed dependency/error classifications, excluding exceptions, requests and credentials.
  • Share a persistent OAuth provider between official SDK MCP calls and the reporting REST operation. The VM helper validates PKCE/state/callbacks, keeps credentials outside the synced repository, serializes refresh rotation and bounds requests. Five-minute native tokens reserve a 30-second request budget.
  • Preserve the API-key creation fence. Organization admin authority is required directly; platform admin status is not a buyer admission fallback.

The actual native issuer is https://clean-gradient-46.authkit.app. A dedicated public PKCE client and explicit sales resource are configured. Real WorkOS code exchange, resource-bound refresh and RS256 identity/audience verification passed. The signed-in buyer currently has direct role member and no exact local owner/admin grant, so deployed admission is expected to be denied until the already-approved temporary access change starts. No WorkOS/local role changes have occurred.

Live Google federation also passed: the WorkOS assertion exchanges into the separate keyless reader, which currently has no bucket permissions. Fly Google exchange and the exact four runtime storage permissions passed on all three current machines. Native runtime write/read/delete and actual deleted-generation 404 passed; listing, metadata mutation and IAM reads are denied; independent REST listing confirms no probe objects remain. Project/organization IAM is unchanged and neither account has user-managed keys. The corrected credential command is qualified through the actual Google auth parser and production Storage credential-file path, and staged without a deployment/restart (configuration SHA-256 cf1b65d11462916943a3d737aeba8b52db9e24adf3e6c15e36c02b392a224423).

Validation:

  • Required checks passed on final synchronized head 67f485616: 1,106 root tests, all 746 server unit files (12,482 unique passing tests, 31 existing skips), both typechecks and boundary guards. Two HTTP teardown hooks exceeded their parallel wall-clock budget; the repository hook's supported isolated rerun passed all eight tests in those two files. No required check was bypassed. The merged lockfile includes main's proxy-addr 2.0.8 fix.
  • Four real primary PostgreSQL / HTTP MCP buyer-auth integration tests passed on the synchronized tree. Eight reporting PostgreSQL / HTTP regressions also passed. Provider ports are controlled; these tests do not establish deployed buyer admission.
  • OAuth/MCP tests cover resource binding, persisted refresh rotation, private file storage and invalid callbacks. JWT tests cover signatures/claims, exact organization/grant authority, revocation and safe outage logs. Local socket/source controls and real Google exchanges qualify credential preparation separately from delivery.
  • Local storyboard runs are advisory and explicitly skipped on push; CI is authoritative. Main/release-base workflows will run when this stacked PR is retargeted after feat(training-agent): add private GCS reporting with SDK 15.2 #8012 lands.

The parent now uses reporting migration 620 after main claimed 619. All fresh-database entry points document mandatory namespace bootstrap even when reporting is disabled; the local procedure was executed against real PostgreSQL and preserved existing installation state while refusing an unexpected owner. The isolated namespace is provisioned on the managed primary. Both feature flags remain false; the approved 72-hour access window has not started; the reader's authoritative-prefix/deadline grant is unset. Reviewed deployment, live buyer admission, real canary delivery/recovery/capacity and business-generation revocation remain pending. This PR is not merge-qualified until its main-base checks and final review requirements pass.

@bokelley
bokelley marked this pull request as ready for review October 9, 2026 01:32
@bokelley bokelley changed the title feat(training-agent): support WorkOS buyer sign-in for private reporting feat(training-agent): support WorkOS buyer sign-in and keyless canary credentials Oct 9, 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 — WorkOS Connect OAuth buyer sign-in for the training agent's canonical sales tenant.

This is an operational/app-scoped change touching server, scripts, docs/runbooks, and fly.toml. No protocol surface (static/schemas/source, docs/reference, task definitions, dist artifacts) is touched, so no changeset is required (operational-only). No schema↔docs coherence, oneOf discriminator, released-artifact, or 3.1.x patch-eligibility concerns apply. The auth boundary is well-constructed and heavily tested: RS256 verify pinned to issuer/JWKS/audience, ≤1h token age, before/after authorization-snapshot recheck, bans check, explicit-org-selector reconciliation, fail-closed 503 on dependency outage, rate limiting, raw-token suppression, bounded timeouts (WorkOS 10s, JWKS 5s, snapshot 2s). Login helper enforces PKCE/state, loopback callback, O_NOFOLLOW + 0600 storage, and serialized refresh rotation.

Medium findings

  • server/src/training-agent/buyer-oauth.ts:116 — Buyer OAuth 503 outage branch has no observability (no logging/Sentry on the dependency-outage branch).

Decision: no critical/high findings (row 1 N/A); gated_paths false; high_risk false; the single medium is category observability, not data-loss/schema/infra (row 4 N/A); only 1 medium (row 8 N/A); no team gate. Falls through to row 9 → approve. Note: the author flagged this PR as not yet merge-qualified (stacked on #8012, CI pending retarget); that is a merge-readiness signal for humans, not an arbiter blocking trigger.

Medium findings

  • server/src/training-agent/buyer-oauth.ts:116 — Buyer OAuth 503 outage branch has no observability

@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.

The delta since the prior approve is confined to fly.toml: it wires TRAINING_REPORTING_GCS_CREDENTIALS_FILE to a keyless external_account config staged via a new [[files]] block from the TRAINING_REPORTING_GCS_CREDENTIALS_BASE64 secret (guest_path matches the env var), and enables GOOGLE_EXTERNAL_ACCOUNT_ALLOW_EXECUTABLES for Fly OIDC. The executable-source flag is process-wide, but the only external_account JSON loaded is the controlled staged secret (passed as keyFilename), the whole path is gated behind TRAINING_REPORTING_GCS_ENABLED=false, and the keyless/no-ADC tradeoff is deliberately documented in the PR body. No new findings in this run.

The prior Medium (buyer-oauth.ts:116 — OAuth 503 branch observability) is outside the current delta and not rechecked per pass scope. No blocking findings, no medium findings in scope.

Decision rules: no critical/high findings (row 1 n/a); gated_paths false and review_decision APPROVED (row 2 n/a); high_risk false (rows 3/5 n/a); no medium findings (rows 4/8 n/a); prior decision was approve, not escalate (row 6 n/a); no no-auto-approve team match (row 7 n/a). Falls through to row 9 — approve.

@bokelley
bokelley merged commit 2d2e21b into bokelley/training-agent-gcs-rollout Oct 9, 2026
5 checks passed
@bokelley
bokelley deleted the bokelley/training-buyer-sign-in branch October 9, 2026 10:17
bokelley added a commit that referenced this pull request Oct 9, 2026
* feat(training-agent): add private GCS reporting with SDK 15.2

* fix(training-agent): provision reporting schema outside runtime boundary

* fix(training-agent): isolate reporting readiness from liveness

* docs(training): require reporting namespace before bootstrap

* docs(deploy): require namespace before manual migrations

* feat(training-agent): support WorkOS buyer sign-in and keyless canary credentials (#8039)

* feat(training-agent): support WorkOS buyer sign-in for private reporting

* fix(training-agent): bound buyer refresh and reporting requests

* fix(training-agent): reuse short-lived WorkOS buyer tokens

* chore(training-agent): stage keyless Fly reporting credentials

* fix(training-agent): log sanitized buyer authorization outages

* test(training): assert exact buyer request origins
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.

1 participant