Repository navigation
fix(training): isolate controller seed replays by caller - #8591
Conversation
There was a problem hiding this comment.
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), andcreatePrincipalScopedSeedCacheprefixes every seed-replay key withtrainingTaskScope(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.
There was a problem hiding this comment.
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 (nostatic/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_scopedoes 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
There was a problem hiding this comment.
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.
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_PARAMSbefore 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:
Fixes #8589 on main. The 3.1 repair is included in #8590; a 3.2 backport follows this main change.