Repository navigation
fix(training-agent): resolve controller-seeded rights grants for operator_unit accounts - #7730
Merged
Merged
Conversation
…ator_unit accounts
The storyboard runner builds seed_rights_grant from the test-kit account and
drops the authored operator_unit, so the grant lands in the
{brand, operator: buyer_domain, sandbox} partition while update_rights reads
the full operator_unit account. On an exact-account miss, update_rights now
re-reads the same natural key without operator_unit, accepting only a
sandbox, controller-seeded grant bought by the request operator.
brand_rights/update_rights_lifecycle passes 4/4 on /brand.
Fixes #7729
Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Contributor
There was a problem hiding this comment.
Ladon verdict: Approve
Approve — clean pass, no blocking findings.
Checked:
- Scope: PR touches only
server/src/training-agent/brand-handlers.tsand its unit test. Training-agent-only, no protocol surface (static/schemas/source/**,docs/reference/**,dist/**) touched — so no changeset required and no schema↔docs coherence concern. - The new
findControllerSeededGrantfallback is fail-closed: sandbox-only, gated on seedFingerprint and buyerDomain, resolving controller-seeded rights grants for operator_unit-scoped buyers after #7601's partition isolation. - Persistence: mutation flushes correctly via the existing dirty-session path.
- Multi-tenant isolation preserved: the new test exercises both the positive path and the other-operator / live-account rejection cases.
Gate checks: gated_paths=false, high_risk=false, no no-auto-approve team match, no prior decision. review_decision is REVIEW_REQUIRED, but with gated_paths=false that does not force escalation. No critical/high/medium findings → decision table falls through to row 9.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #7729
Summary
brand_rights/update_rights_lifecyclehas failed on the training agent's/brandtenant since at least 2026-09-17.pause_seeded_grantreturnedREFERENCE_NOT_FOUNDfor the grant the controller had just seeded, and CI stayed green only because of the tenant floor. #7708 doesn't touch this path.Root cause
#7601 isolated the storyboard's account with an
operator_unit.@adcp/sdk's runner builds non-force_*controller calls from the test-kit account, soseed_rights_grantnever receives that unit. The seed stores the grant under{brand, operator: buyer_domain, sandbox}. The buyer'supdate_rightsreads{brand, operator, operator_unit, sandbox}, which is a different session. Temporary logging confirmed both accounts (details in #7729).The
update-rights-response.jsonmessage the audit flagged (/errors: must have required property 'errors') comes from the same failure. The success step'sresponse_schemacheck graded theREFERENCE_NOT_FOUNDbody. That body is the SDK's thrown-AdcpErrorshape (adcp_erroronly, no payloaderrors[]), which every v6 tenant produces. Once the grant resolves, the check passes. The SDK-wide "SHOULD populate both layers" gap is noted in #7729 as an adcp-client follow-up.Fix (training agent only, no changeset)
handleUpdateRightsnow falls back tofindControllerSeededGrantwhen the exact-account lookup misses. The fallback bridges only the field the runner drops. It re-reads the same natural key withoutoperator_unit, and only when all of these hold:operator_unit;seedFingerprint, meaning it was controller-seeded, not acquired throughacquire_rights;buyerDomainequals the request'soperator.Live accounts, other operators, and organically acquired grants still return
REFERENCE_NOT_FOUND. Mutations persist through the normal per-request session snapshot flush.Storyboard results
npm run build:compliance, thenTENANT_PATH=brand PUBLIC_TEST_AGENT_TOKEN=storyboard-local-token ADCP_COMPLIANCE_DIR=dist/compliance/latest ADCP_SCHEMA_ROOT=dist/schemas/latest npx tsx server/tests/manual/run-storyboards.ts --storyboard-id brand_rights/update_rights_lifecyclepause_seeded_grantREFERENCE_NOT_FOUND;update_unknown_grantskipped)Full
/brandtenant run (same env, no--storyboard-id): 56/56 clean, 122 passed, 0 failed. The latest main CI run had 55 clean and 120 passed.Testing
server/tests/unit/comply-test-controller.test.ts. It seeds through the brand-owned controller account, then pauses the grant through anoperator_unitaccount. It also asserts that another operator and a live account still getREFERENCE_NOT_FOUND. The test fails without the fix and passes with it.npx vitest run --config server/vitest.config.ts server/tests/unit/comply-test-controller.test.ts server/tests/unit/idempotency.test.ts server/tests/unit/training-agent-governance-intent-binding.test.ts server/tests/unit/training-agent-webhook-contract.test.ts: 152/152 pass.npx tsc --noEmit -p server/tsconfig.json: passes.node scripts/check-changeset-protocol-scope.cjs origin/main: passes (training-agent-only, no changeset).--no-verify. In this sandbox, the full pre-commit server suite fails 9tests/unit/addie/fixed-trace-*tests because they assert a worktree-localnode_modulespath, andnode_moduleshere is a symlink. It also OOM-kills one worker. Neither is related to this change.Follow-ups (not in this PR)
comply_test_controllerrequest builder drops authored accounts for non-force_*scenarios, includingoperator_unit. This is the same root issue noted in fix(compliance): unblock the account_change_feed storyboard webhook and drain steps #7716 and fix(compliance): make the reporting_core non-empty phase pass on the training agent #7717.AdcpErroremits onlyadcp_error, not the payloaderrors[]too.🤖 Generated with Claude Code