Skip to content

feat(accounts)!: reference accounts by account_id under AdCP 3.3 - #1954

Merged
bokelley merged 5 commits into
nextfrom
claude/issue-1478-account-id-references
Nov 26, 2026
Merged

bokelley merged 5 commits into
nextfrom
claude/issue-1478-account-id-references

Conversation

@bokelley

@bokelley bokelley commented Nov 24, 2026 •

Copy link
Copy Markdown
Contributor

Closes #1478.

AdCP 3.3 makes an account's account_id its identity (adcp#8474). The spec text this PR follows:

After opening, references use the account ID. Sellers MUST return account_id from sync_accounts once the account is resolved, accept it on every account-scoped task, and never change it. Buyers store it and send { "account_id": "..." }. The seller keeps accepting a natural-key reference throughout 3.x.

stable_account_id always holds, so buyers send account_id without checking it.

(docs/accounts/overview.mdx, Account identity, and the 3.3 migration guide's §Account identity is the account ID at v3.3.0-rc.3.) The natural key as a reference after provisioning is deprecated (adcp#7850), and so is account.stable_account_id itself. Per the re-scope on #1478, this PR builds no new logic around the flag.

Seller

  • NaturalKeyAccounts requires loader_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 as countries changes. An optional callback meant every store that omitted it answered ACCOUNT_NOT_FOUND to every id reference. A missing callback now fails at construction with a TypeError, not on a buyer's call. resolves_account_ids is removed, because it would always be True.
  • get_adcp_capabilities declares account.stable_account_id: true to callers at 3.3 or later whenever the capabilities carry an account block. Sellers SHOULD declare it while the field exists. An explicit Account(stable_account_id=...) wins. A caller below 3.3 never sees the field, and neither does a server pinned to 3.2. No account block is invented, since the schema requires supported_billing there.

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 doesn't check stable_account_id. The registry learns the id from accounts.ensure() or from any observed sync_accounts / list_accounts result.
  • The swap happens in AccountRegistry.preserve_wire_keys. That is the one send-time step that knows the negotiated release, and it already ran under every account_policy. It rewrites only the wire copy, after the policy's preflight, so the spend gate and the ACCOUNT_NOT_FOUND invalidation still key off the caller's natural key.
  • Per-item references swap too: report_usage usage[].account and sync_governance accounts[].account.
  • On request_proposals, buy_products and list_products, a natural-key account is 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 authored account brand moves to top-level brand when the request has none.
  • These keep the natural key: sync_accounts entries (provisioning and settings updates); list_accounts filters (the spec keeps the natural key valid there); requests carrying governance_context, whose authorization binds compute_governed_payload_hash of 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's accountReferenceMode: 'natural-key' (SingleAgentClient.ts). AccountReferenceMode is exported from adcp.

Where this differs from the TS SDK

@adcp/sdk 17.0.0-beta.39 (AdCP 3.3.0-rc.3) still sends account_id only when the seller declares stable_account_id or negotiates AdCP 4 (usesStableAccountIds in SingleAgentClient.ts). That predates the #8474 rule, under which buyers send account_id without checking the flag. This PR follows the spec; TS should follow.

Not in this PR

Docs

docs/account-lifecycle.md gets a new "Account IDs after provisioning" section and a rewritten NaturalKeyAccounts section. MIGRATION_v9_to_v10.md gets a row for this change, and docs/adcp-3.3-sdk-inventory.md is updated.

Test plan

  • tests/test_account_id_references.py (25 tests):
    • Buyer, with the wire mocked below the request converter (adapter._call_mcp_tool_wire), so preserve_wire_keys runs for real and ensure() goes through the real sync_accounts path:
      • A 3.3-rc.3 seller gets {"account_id": ...} on get_products, sync_creatives and create_media_buy, under account_policy off, auto and strict.
      • A 3.2-only seller keeps the natural key, and so does account_reference_mode="natural_key".
      • sync_accounts entries and list_accounts filters keep the natural key.
      • The caller's model is not mutated, and ACCOUNT_NOT_FOUND on an id-referenced call still invalidates the natural-key record.
      • A record without an id keeps the natural key, and a bad mode raises ValueError.
    • Seller, through create_tool_caller, so negotiation is real:
      • stable_account_id: true for 3.3-rc.3 and unversioned discovery.
      • An explicit False is kept.
      • No field for a 3.2 caller, or from a server pinned to 3.2.
      • No account block is invented.
    • NaturalKeyAccounts through the handler: the id and the natural key reach the same account after sync_accounts, and another principal's id gets ACCOUNT_NOT_FOUND.
  • The review fixes are covered in the same file:
    • The request_proposals, buy_products and catalog list_products wire payloads are validated against the 3.3 request schema.
    • A real issue_governance_authorization token over a governed create_media_buy still verifies with verify_governance_authorization after ensure(). As a control, the same payload with the account swapped fails with governance_token_not_applicable.
    • report_usage / sync_governance items are covered at 3.3, at 3.2 and under natural_key.
    • 8 of these fail on the pre-fix revision. The file has 44 tests.
  • tests/test_account_lifecycle.py: the natural-resolver test passes loader_by_id, and the removed-behavior test is replaced by test_loader_by_id_is_required.
  • Locally: the two files pass (81). Before the tests, a full parallel run of the implementation commit was clean apart from the tests these commits update and five reporting, packaging and WBA tests that fail only under parallel load; those pass in isolation. Hosted CI runs the full suite, per the host-load limit.

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

bokelley and others added 2 commits November 24, 2026 13:21
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>

@aao-secretariat aao-secretariat Bot left a comment

Copy link
Copy Markdown

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

bokelley and others added 2 commits November 24, 2026 13:42
…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>

@aao-secretariat aao-secretariat Bot left a comment

Copy link
Copy Markdown

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 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_keys additions 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 result guard 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

@aao-secretariat aao-secretariat Bot left a comment

Copy link
Copy Markdown

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

@bokelley
bokelley merged commit 6bc872e into next Nov 26, 2026
76 of 78 checks passed
@bokelley
bokelley deleted the claude/issue-1478-account-id-references branch November 26, 2026 17:44
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