Repository navigation
feat(decisioning): resolve account_id references in NaturalKeyAccounts for AdCP 3.3 - #1653
Merged
Merged
Conversation
…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]>
There was a problem hiding this comment.
Ladon verdict: Approve
Approve — additive AdCP 3.3 account.stable_account_id support on the seller side.
Checked:
NaturalKeyAccountsgains an optionalloader_by_idhook and aresolves_account_idsproperty — purely additive, no public-surface break, sofeat(decisioning):is the correct semver signal.- The
by_id.id != account_idguard (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 preservesACCOUNT_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.
10 of 21 tasks
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.
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_idMUST accept{"account_id": ...}wherever anAccountRefis accepted, including for buyer-declared accounts.NaturalKeyAccounts.resolverefused everyaccount_idreference withACCOUNT_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 | Nonehook, sync or async. Likeloader, it must scope the lookup to accounts the caller may operate.iddiffers from the requestedaccount_idis treated as a miss, so the id and the natural key can't resolve to different accounts.NaturalKeyAccounts.resolves_account_idsreports whether the hook is configured. The capability declaration will read it after regen.ACCOUNT_NOT_FOUND).docs/account-lifecycle.md.This is additive; the 9.x API is unchanged.
Follow-up after the 3.3 regeneration (stays on #1478)
account.stable_account_idfrom the store, and requireaccount_idon every non-failedsync_accountsrow when it's declared.AccountRegistry.preparesends{account_id}to sellers declaring the capability, with a natural-key override and lookup by id. The 3.2 capability model dropsstable_account_id(extra="ignore"), so this needs the 3.3 types.media_buy_seller/stable_account_idagainst the reference seller.Test plan
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 meansACCOUNT_NOT_FOUND; handler-level discovery byaccount_id.tests/test_account_lifecycle.pyandtests/test_public_api.py: 79 passed. ruff and mypy are clean on the changed module.Refs #1478 · Tracking #1648
🤖 Generated with Claude Code