Skip to content

fix(training): isolate controller seed replays by caller - #8591

Merged
bokelley merged 1 commit into
mainfrom
fix/controller-seed-replay-isolation
Oct 29, 2026
Merged

bokelley merged 1 commit into
mainfrom
fix/controller-seed-replay-isolation

Conversation

@bokelley

Copy link
Copy Markdown
Contributor

Two authenticated sandbox callers could collide in the native controller replay cache when they used the same correlation ID and account ID with different fixtures. The second caller received INVALID_PARAMS before its independently owned account could be seeded. This affected main and 3.2; the demonstrated impact is compliance-test availability.

Namespace the SDK's bounded replay cache with the trusted tenant/caller scope already established by the transport router. Apply it to all native tenant configurations, retaining SDK cache limits, same-caller divergent-replay rejection, authentication and sandbox gates. Caller-supplied session/private fields cannot choose the namespace. No protocol schema, package dependency or release artifact changes; no protocol changeset is required.

Validation:

  • Required real-MCP regression across sales, signals, governance, creative and creative-builder: distinct caller state, equivalent replay, divergent same-caller rejection, unchanged state after rejection, ignored ownership/session spoofs. The original runtime fails all five controls; patched runtime passes.
  • Independent code, protocol/patch-eligibility and security reviews are clear; direct security MCP probes verify all five tenant endpoints.
  • Normal Docker pre-commit hook passed:1,276 root tests,13,405 server tests (31 existing opt-in skips), typecheck. One existing emitted-worker diagnostic passed the hook's built-in isolated retry; its intermittent failure is recorded separately, with no test/engine changes.
  • Scope/title and normal Docker pre-push gates pass. The documented advisory local storyboard skip is used; GitHub's full training-agent matrix must pass before merge.

Fixes #8589 on main. The 3.1 repair is included in #8590; a 3.2 backport follows this main change.

@bokelley bokelley added this to the P0 Bugs milestone Oct 29, 2026
@bokelley bokelley added bug Something isn't working compliance-testing labels Oct 29, 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 — clean multi-tenant isolation fix for the training-agent comply seed cache.

Checked:

  • getTrainingCallerScope() reads only the router-established AsyncLocalStorage scope (never a caller-supplied session), and createPrincipalScopedSeedCache prefixes every seed-replay key with trainingTaskScope(tenantId, principal), closing the cross-caller cache collision.
  • Scope resolves lazily inside the request context (router.ts:626); the underlying cache is built once and persists.
  • The adversarial 5-tenant test (including spoofed private fields) verifies both isolation and replay/conflict.
  • Server-only change — no protocol surface (static/schemas/source/**, docs/reference/**, dist/**), no migrations, so no changeset required and no schema↔docs or oneOf concerns.

No blocking, Medium, or escalation triggers. gated_paths: false, high_risk: false, no author team gate. Falls through to row 9.

@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 — multi-tenant isolation fix, server-only, 1 medium finding (falls through to row 9).

What I checked

  • Scope is server-only (server/src/training-agent/**). No protocol surface touched (no static/schemas/source/**, docs/reference/**, dist/**), so no changeset is required — correctly none added.
  • getTrainingCallerScope() reads the trusted AsyncLocalStorage scope (tenant+principal) rather than caller-supplied overrides; the new principal-scoped seed cache keys replays per-caller. Fail-closed: unscoped cache ops throw instead of falling back to a shared key.
  • Test proves spoofing __training_principal/__training_task_owner_scope does not cross callers and that divergence detection stays per-caller.
  • No critical/high findings. gated_paths: false, high_risk: false, no author-team gate. Only 1 medium → row 8 (≥3 mediums) does not fire; falls through to row 9.

Medium findings

  • server/src/training-agent/tenants/comply.ts:43 — Principal-scoped seed cache drops the v5 per-caller cap (risk of cross-caller eviction weakening isolation, or unbounded growth on a public surface). Worth a follow-up but non-blocking.

Note: review_decision is REVIEW_REQUIRED, but gated_paths is false so row 2 does not apply; this is informational only per the current decision table.

Medium findings

  • server/src/training-agent/tenants/comply.ts:43 — Principal-scoped seed cache drops the v5 per-caller cap

@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 — namespaces the SDK comply controller's seed-replay cache by trusted caller scope.

The change scopes the comply seed-replay cache to the per-request training caller scope (AsyncLocalStorage) established by runWithTrainingTaskScope. Reviewer verified fail-closed behavior (throws without a scope), lazy per-request resolution inside get/has/set, and that comply configs build once at registry init so the shared cache is correctly namespaced per caller. Test coverage is thorough — asserts cross-caller isolation and same-caller conflict detection across 5 tenants. No protocol-surface / schema / static/schemas/source/** / dist/** / docs changes, so no changeset is required. One low, sandbox-only follow-up noted (no visible per-caller cap on the shared fixture cache) — benign re-seed behavior, not blocking.

No critical, high, or medium findings. Not path-gated (gated_paths: false), not high-risk, no author team gate, first review. Falls through to approve.

@bokelley
bokelley merged commit d1bdc77 into main Oct 29, 2026
58 checks passed
@bokelley
bokelley deleted the fix/controller-seed-replay-isolation branch October 29, 2026 19:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working compliance-testing

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Training controller replay cache collides across authenticated callers

1 participant