Skip to content

feat(decisioning): resolve account_id references in NaturalKeyAccounts for AdCP 3.3 - #1653

Merged
bokelley merged 1 commit into
nextfrom
claude/issue-1478-seller-account-id
Oct 27, 2026
Merged

bokelley merged 1 commit into
nextfrom
claude/issue-1478-seller-account-id

Conversation

@bokelley

Copy link
Copy Markdown
Contributor

Summary

First half of #1478, the seller side, which doesn't depend on the 3.3 regeneration.

AdCP 3.3 sellers that declare account.stable_account_id MUST accept {"account_id": ...} wherever an AccountRef is accepted, including for buyer-declared accounts. NaturalKeyAccounts.resolve refused every account_id reference with ACCOUNT_NOT_FOUND, so a Python seller couldn't declare the capability without writing its own store.

  • NaturalKeyAccounts(..., loader_by_id=...): an optional (account_id, auth_info) -> Account | None hook, sync or async. Like loader, it must scope the lookup to accounts the caller may operate.
  • An account whose id differs from the requested account_id is treated as a miss, so the id and the natural key can't resolve to different accounts.
  • NaturalKeyAccounts.resolves_account_ids reports whether the hook is configured. The capability declaration will read it after regen.
  • Without the hook, behaviour is unchanged (ACCOUNT_NOT_FOUND).
  • Docs: docs/account-lifecycle.md.

This is additive; the 9.x API is unchanged.

Follow-up after the 3.3 regeneration (stays on #1478)

  • Declare account.stable_account_id from the store, and require account_id on every non-failed sync_accounts row when it's declared.
  • Buyer: AccountRegistry.prepare sends {account_id} to sellers declaring the capability, with a natural-key override and lookup by id. The 3.2 capability model drops stable_account_id (extra="ignore"), so this needs the 3.3 types.
  • Storyboard media_buy_seller/stable_account_id against the reference seller.

Test plan

  • New tests in tests/test_account_lifecycle.py: the id and the natural key reach the same account, with state shared; an id never crosses principals; a loader returning another account is a miss; no hook means ACCOUNT_NOT_FOUND; handler-level discovery by account_id.
  • tests/test_account_lifecycle.py and tests/test_public_api.py: 79 passed. ruff and mypy are clean on the changed module.

Refs #1478 · Tracking #1648

🤖 Generated with Claude Code

…s for AdCP 3.3

AdCP 3.3 sellers that declare account.stable_account_id must accept
{"account_id": ...} wherever an AccountRef is accepted, including for
buyer-declared accounts. NaturalKeyAccounts refused every account_id
reference, so a Python seller could not declare the capability without
writing its own store.

NaturalKeyAccounts now takes an optional loader_by_id(account_id,
auth_info). It must scope the lookup to the caller, and an account whose
id differs from the requested account_id is treated as a miss, so the id
and the natural key cannot resolve to different accounts. Without the
hook, account_id references keep returning ACCOUNT_NOT_FOUND.

The capability declaration and the buyer side need the 3.3 generated
capability types and follow after the regeneration.

Refs #1478

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>

@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 — additive AdCP 3.3 account.stable_account_id support on the seller side.

Checked:

  • NaturalKeyAccounts gains an optional loader_by_id hook and a resolves_account_ids property — purely additive, no public-surface break, so feat(decisioning): is the correct semver signal.
  • The by_id.id != account_id guard (accounts.py:98) blocks the id/natural-key state-split; principal scoping is delegated to the adopter loader consistent with the existing path; the no-hook path preserves ACCOUNT_NOT_FOUND.
  • No forward-compat / import-layering / generated-code violations; no credentials introduced into ctx_metadata.
  • Sync + async loader paths, cross-principal isolation, loader-mismatch, no-hook, and handler discovery are all covered by new tests.

high_risk is true only because src/adcp/decisioning/accounts.py (modified) matches src/adcp/decisioning/**, but the reviewer found no medium-or-higher concerns, so the modification is presumed safe (not an escalation trigger on the flag alone). No gated paths, no no-auto-approve team match, no prior decision. No findings at any severity → decision table falls through to row 9.

@bokelley bokelley mentioned this pull request Oct 27, 2026
10 of 21 tasks
@bokelley
bokelley merged commit dca87b9 into next Oct 27, 2026
41 checks passed
@bokelley
bokelley deleted the claude/issue-1478-seller-account-id branch October 27, 2026 01:25
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