Repository navigation
feat(accounts)!: reference accounts by account_id under AdCP 3.3 - #1954
Conversation
AdCP 3.3 makes an account's account_id its identity (adcp#8474). Every
seller MUST return it from sync_accounts once the account is resolved,
accept {"account_id": ...} wherever it accepts an account reference, and
never change it. Using the natural key as the reference after provisioning
is deprecated (adcp#7850), and so is account.stable_account_id, since the
guarantee it declared now always holds.
Seller:
- NaturalKeyAccounts requires loader_by_id. No SDK default can resolve an
id without the adopter's lookup, and without one every account_id
reference was ACCOUNT_NOT_FOUND. The resolves_account_ids property is
gone.
- get_adcp_capabilities declares account.stable_account_id: true to
callers at 3.3 or later whenever an account block is declared (sellers
SHOULD while the field exists). An explicit declaration wins; callers
below 3.3 never see the field.
Buyer:
- Once the registry holds an account_id for a natural key, the client
sends {"account_id": ...} in place of that key on account-scoped tasks
negotiated at 3.3 or later. It does not check stable_account_id.
sync_accounts entries, list_accounts filters and sellers negotiated
below 3.3 keep the natural key. The swap happens on the wire copy,
after the account policy's preflight.
- ADCPClient(account_reference_mode="natural_key") keeps sending
references as written (TS: accountReferenceMode: 'natural-key').
BREAKING CHANGE: NaturalKeyAccounts(loader, ...) without loader_by_id
raises TypeError, and NaturalKeyAccounts.resolves_account_ids is removed.
ADCPClient sends account_id references to 3.3 sellers once provisioned.
Refs #1478
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Refs #1478 Co-Authored-By: Claude Sonnet <noreply@anthropic.com>
There was a problem hiding this comment.
Ladon verdict: Approve
Approve.
The reviewer returned a clean report with no blocking or Medium findings. Walking the decision table top-down:
- Row 1 (critical/high): no such findings — none at all.
- Row 2 (gated_paths unsatisfied): gated_paths is false; does not apply.
- Row 3 (high-risk deletion): high_risk is true but all three reasons are
(modified), none(deleted); does not apply. - Row 4 (medium + data-loss/schema/infra): no medium findings; does not apply.
- Row 5 (modified high-risk + medium): no medium findings; does not apply.
- Row 6 (sticky escalation): no prior decision.
- Row 7 (no-auto-approve team): no team match.
- Row 8 (≥3 medium): zero medium findings.
- Row 9: approve.
What was verified: this implements AdCP 3.3 "an account is its account_id" (#1478). The breaking public-surface changes (required loader_by_id, removed resolves_account_ids, new account_reference_mode) carry the correct feat(accounts)!: semver signal plus a MIGRATION_v9_to_v10.md migration row — satisfying the mandatory semver-signal gate. The version-translation pathway is handled both directions (3.3 replaces the full reference; a 3.2 seller keeps the natural key) and tested, satisfying the minor-release wire-change pathway requirement. The wire-key swap runs on the deepcopy after the policy preflight, so the spend gate and ACCOUNT_NOT_FOUND invalidation still key off the natural key. No generated-code hand-edits, type-layering violations, forward-compat/union regressions, or ctx_metadata credential issues. high_risk is a look-closer heuristic here on modified files with no medium-or-higher concern — presumed safe.
…to account_id Review of the account_id swap found three gaps: - request_proposals, buy_products and list_products use a natural-key account as the request's brand source, and the schemas forbid combining it with top-level brand. An id-only account is not a brand source, so the swap left these requests invalid. The authored account brand now moves to top-level brand when the request has none. - A request carrying governance_context is bound by its authorization to the hash of the payload as approved (compute_governed_payload_hash). Rewriting its account broke verification, so such a request keeps the authored reference. The natural key stays valid throughout 3.x. - report_usage usage[].account and sync_governance accounts[].account reference accounts per item and were not swapped. They are now. Refs #1478 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet <noreply@anthropic.com>
There was a problem hiding this comment.
Ladon verdict: Approve
Approve — clean subsequent pass with no blocking or medium findings.
This is a subsequent review (prior outcome: approve, clean). The reviewer verified the delta across MIGRATION_v9_to_v10.md, docs/account-lifecycle.md, src/adcp/accounts.py, and tests/test_account_id_references.py.
Key checks confirmed:
preserve_wire_keysadditions are correct per DR-0032/0033: governance_context exclusion from by_account_id preserves the authored account reference for payload-hash binding; per-item account swapping for report_usage/sync_governance with continuity=False; brand-move-to-top-level scoped to pointer=="/account".- Params dumped exclude_none, so the
"brand" not in resultguard has no brand:null false-positive. - Governed path's residual wire-key canonicalization is a no-op, confirmed by test hash-equality (L278) plus the real-verifier control (L300-L303).
- The 255-line test file is thorough across 3.3/3.2/natural_key modes and already-id items (largest-file rule satisfied).
Decision table: No critical/high/medium findings (rows 1, 4, 5, 8 don't fire). gated_paths is false and review_decision is APPROVED (row 2 n/a). high_risk is true but all reasons are (modified) with no medium finding (rows 3, 5 don't fire). No no-auto-approve team match (row 7 n/a). Prior decision was approve, not escalate (row 6 n/a). Falls through to row 9 — approve.
…ount-id-references # Conflicts: # MIGRATION_v9_to_v10.md # docs/adcp-3.3-sdk-inventory.md
There was a problem hiding this comment.
Ladon verdict: Approve
Approve — clean delta pass, no blocking or medium findings.
This is a subsequent review following a prior clean approve (head a585636). The reviewer re-covered the largest changed files and new surfaces: _dual_emit_platform_ids mismatch-raise parity across InMemory/Pg registries, coverage_guard.py frozen-coverage row guards, producer.py allow_partial publication with per-config turn leasing (end-of-turn re-raise aborts only that config after the obligation is parked/escalated), status.py page sizing with a terminating walk, check_companion_releases.py unreleased-floor gate, and the schema_loader/schema_validator fixes. Public-surface additions (platform_id_of, DEFAULT_STATUS_PAGE_NODE_BUDGET, coverage-guard errors) are captured in the API snapshot, and coverage_requirement rides in the stored schedule document leaving the storage contract unchanged. Version bumps (adcp 10.0.0b27, storage 0.2.0b5, floor 10.0.0b24) are consistent with RELEASING.md, with matching test coverage.
Decision table: no critical/high/medium findings (rows 1,4,5,6,8 don't fire). gated_paths is false (row 2 n/a); review_decision is APPROVED regardless. high_risk is true but all reasons are (modified) files with no medium findings — row 3 (deleted) and row 5 (modified+medium) don't apply. No no-auto-approve team match (row 7 n/a). Falls through to row 9 → approve.
Closes #1478.
AdCP 3.3 makes an account's
account_idits identity (adcp#8474). The spec text this PR follows:(
docs/accounts/overview.mdx, Account identity, and the 3.3 migration guide's §Account identity is the account ID atv3.3.0-rc.3.) The natural key as a reference after provisioning is deprecated (adcp#7850), and so isaccount.stable_account_iditself. Per the re-scope on #1478, this PR builds no new logic around the flag.Seller
NaturalKeyAccountsrequiresloader_by_id. Every 3.3 seller MUST accept{"account_id": ...}, and no SDK default can find an account by id without the adopter's lookup. A synthesized id would encode the natural key, which breaks once an attribute such ascountrieschanges. An optional callback meant every store that omitted it answeredACCOUNT_NOT_FOUNDto every id reference. A missing callback now fails at construction with aTypeError, not on a buyer's call.resolves_account_idsis removed, because it would always beTrue.get_adcp_capabilitiesdeclaresaccount.stable_account_id: trueto callers at 3.3 or later whenever the capabilities carry anaccountblock. Sellers SHOULD declare it while the field exists. An explicitAccount(stable_account_id=...)wins. A caller below 3.3 never sees the field, and neither does a server pinned to 3.2. Noaccountblock is invented, since the schema requiressupported_billingthere.Buyer
account_idfor a natural key, the client sends{"account_id": ...}in place of that key on account-scoped tasks negotiated at 3.3 or later. It doesn't checkstable_account_id. The registry learns the id fromaccounts.ensure()or from any observedsync_accounts/list_accountsresult.AccountRegistry.preserve_wire_keys. That is the one send-time step that knows the negotiated release, and it already ran under everyaccount_policy. It rewrites only the wire copy, after the policy's preflight, so the spend gate and theACCOUNT_NOT_FOUNDinvalidation still key off the caller's natural key.report_usageusage[].accountandsync_governanceaccounts[].account.request_proposals,buy_productsandlist_products, a natural-key account is the request's brand source, and the schemas forbid combining it with top-levelbrand. An id-only account is not a brand source, so the authored accountbrandmoves to top-levelbrandwhen the request has none.sync_accountsentries (provisioning and settings updates);list_accountsfilters (the spec keeps the natural key valid there); requests carryinggovernance_context, whose authorization bindscompute_governed_payload_hashof the payload as approved; and sellers negotiated below 3.3, for which accepting an id was optional.The per-item, brand-source and governance rules came from the cold review (codex/sol/max) of the first revision; they are in b2d05eb.
ADCPClient(account_reference_mode="natural_key")sends every reference as written. It mirrors the TS SDK'saccountReferenceMode: 'natural-key'(SingleAgentClient.ts).AccountReferenceModeis exported fromadcp.Where this differs from the TS SDK
@adcp/sdk17.0.0-beta.39 (AdCP 3.3.0-rc.3) still sendsaccount_idonly when the seller declaresstable_account_idor negotiates AdCP 4 (usesStableAccountIdsinSingleAgentClient.ts). That predates the #8474 rule, under which buyers sendaccount_idwithout checking the flag. This PR follows the spec; TS should follow.Not in this PR
account_idin the registry (Support account.stable_account_id (AdCP 3.3): send seller account IDs as buyer, accept them as seller #1478 item 3, for webhook and status-repair flows). The re-scope doesn't require it, and it's additive, so it can land in 10.1.sync_accountsrow withoutaccount_id. The rows are adopter-built; the docstring and docs state the MUST.Docs
docs/account-lifecycle.mdgets a new "Account IDs after provisioning" section and a rewrittenNaturalKeyAccountssection.MIGRATION_v9_to_v10.mdgets a row for this change, anddocs/adcp-3.3-sdk-inventory.mdis updated.Test plan
tests/test_account_id_references.py(25 tests):adapter._call_mcp_tool_wire), sopreserve_wire_keysruns for real andensure()goes through the realsync_accountspath:{"account_id": ...}onget_products,sync_creativesandcreate_media_buy, underaccount_policyoff,autoandstrict.account_reference_mode="natural_key".sync_accountsentries andlist_accountsfilters keep the natural key.ACCOUNT_NOT_FOUNDon an id-referenced call still invalidates the natural-key record.ValueError.create_tool_caller, so negotiation is real:stable_account_id: truefor 3.3-rc.3 and unversioned discovery.Falseis kept.accountblock is invented.NaturalKeyAccountsthrough the handler: the id and the natural key reach the same account aftersync_accounts, and another principal's id getsACCOUNT_NOT_FOUND.request_proposals,buy_productsand cataloglist_productswire payloads are validated against the 3.3 request schema.issue_governance_authorizationtoken over a governedcreate_media_buystill verifies withverify_governance_authorizationafterensure(). As a control, the same payload with the account swapped fails withgovernance_token_not_applicable.report_usage/sync_governanceitems are covered at 3.3, at 3.2 and undernatural_key.tests/test_account_lifecycle.py: the natural-resolver test passesloader_by_id, and the removed-behavior test is replaced bytest_loader_by_id_is_required.BREAKING CHANGE: NaturalKeyAccounts requires loader_by_id (TypeError without it) and NaturalKeyAccounts.resolves_account_ids is removed; ADCPClient sends {"account_id": ...} in place of a provisioned natural key to sellers negotiated at AdCP 3.3 or later (account_reference_mode="natural_key" keeps the old behavior).
🤖 Generated with Claude Code