Commit dabf4fb
fix(decisioning): wire sync_accounts/list_accounts dispatch to AccountStore Protocols (#610)
* fix(decisioning): wire sync_accounts/list_accounts dispatch to AccountStore Protocols
PlatformHandler.sync_accounts and PlatformHandler.list_accounts were
inherited as _not_supported stubs from ADCPHandler — every adopter
implementing AccountStoreUpsert / AccountStoreList saw their account
roster invisible on the wire regardless of what the store declared.
This wires real shims that route through platform.accounts.upsert /
.list with a ResolveContext carrying the caller's verified AuthInfo
and registry-resolved BuyerAgent (same threading AccountStore.resolve
already uses, so adopter impls implementing principal-keyed gates —
e.g. spec BILLING_NOT_PERMITTED_FOR_AGENT — read the principal off
the canonical context).
Wire advertisement: _ACCOUNT_ADVERTISED_TOOLS = {"sync_accounts",
"list_accounts"} unioned into every sales-* entry of
SPECIALISM_TO_ADVERTISED_TOOLS. The per-instance filter at
advertised_tools_for_instance drops the tool when the store doesn't
expose the corresponding optional Protocol method (with a one-line
logger.info breadcrumb on first drop), so adopters who haven't wired
the optional Protocols don't over-advertise.
Defense-in-depth: shims project results through
strip_credentials_from_wire_result on the final envelope so loose
dicts and Pydantic extra='allow' rows can't smuggle
governance_agents[i].authentication or billing_entity.bank past the
typed projections.
Closes #609.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
* fix(examples): sales-proposal-mode seller emits spec-shape sync_accounts rows
The example's _SingleTenantAccounts.upsert returned rows shaped as
``{ref, account, operation}`` — a custom layout that worked while the
framework's sync_accounts dispatch was a no_supported stub but trips
schema output validation now that the dispatch actually invokes
accounts.upsert.
Reshape each row to the wire schema per
schemas/cache/account/sync-accounts-response.json:
``{account_id, brand, operator, action, status, ...}``. The framework
wraps the list as ``{"accounts": [...]}``.
Verified end-to-end against the running seller: storyboard runner's
sync_accounts step now passes output validation.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
* fix(decisioning): unblock sync_accounts/list_accounts bootstrap on explicit-mode stores
The shims called ``await self._resolve_account(None, tool_ctx)`` purely
to side-effect-stash the registry-resolved buyer-agent on
``ctx.metadata``. For ``AccountStore.resolution == "explicit"`` impls
without a principal/subdomain fallback, that no-ref resolve raised
``ACCOUNT_NOT_FOUND`` — deadlocking the bootstrap path that uses
``sync_accounts`` to populate the store in the first place.
Extract the side-effect into a ``_prime_auth_context`` helper that
runs the buyer-agent registry gate (suspended/blocked rejection still
fires) WITHOUT calling ``AccountStore.resolve``. Use it in both
account-roster shims; ``_resolve_account`` delegates to it for the
buyer-agent stash.
Also:
- Warn on unexpected ``upsert`` / ``list`` return shapes (None, tuple,
bare string) so adopter contract violations aren't silent — the
credential scrubber relies on dict-or-list shape.
- Document that the per-tenant handler created by
``LazyPlatformRouter`` emits the dropped-tool boot log per (tenant,
tool) — intentional, since stores can be wired differently per
tenant.
- Doc nit: ``AccountStoreList.list`` example shows binding ``filter``
to ``filter_`` to avoid shadowing the builtin in the method body.
Test additions:
- explicit-mode bootstrap regression: shim must NOT call
``ExplicitAccounts.resolve(None, ...)`` first.
- unexpected-shape return triggers the new ``logger.warning``.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>1 parent 7a712ae commit dabf4fb
5 files changed
Lines changed: 943 additions & 30 deletions
File tree
- docs
- examples/sales_proposal_mode_seller/src
- src/adcp/decisioning
- tests
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
738 | 738 | | |
739 | 739 | | |
740 | 740 | | |
| 741 | + | |
| 742 | + | |
| 743 | + | |
| 744 | + | |
| 745 | + | |
| 746 | + | |
| 747 | + | |
| 748 | + | |
| 749 | + | |
| 750 | + | |
| 751 | + | |
| 752 | + | |
| 753 | + | |
| 754 | + | |
| 755 | + | |
| 756 | + | |
| 757 | + | |
| 758 | + | |
| 759 | + | |
| 760 | + | |
| 761 | + | |
| 762 | + | |
| 763 | + | |
| 764 | + | |
| 765 | + | |
| 766 | + | |
| 767 | + | |
| 768 | + | |
| 769 | + | |
| 770 | + | |
| 771 | + | |
| 772 | + | |
| 773 | + | |
| 774 | + | |
| 775 | + | |
| 776 | + | |
| 777 | + | |
| 778 | + | |
| 779 | + | |
| 780 | + | |
| 781 | + | |
| 782 | + | |
| 783 | + | |
| 784 | + | |
| 785 | + | |
| 786 | + | |
| 787 | + | |
| 788 | + | |
| 789 | + | |
| 790 | + | |
| 791 | + | |
| 792 | + | |
| 793 | + | |
| 794 | + | |
| 795 | + | |
| 796 | + | |
| 797 | + | |
| 798 | + | |
| 799 | + | |
| 800 | + | |
| 801 | + | |
| 802 | + | |
| 803 | + | |
| 804 | + | |
| 805 | + | |
| 806 | + | |
| 807 | + | |
| 808 | + | |
| 809 | + | |
| 810 | + | |
| 811 | + | |
| 812 | + | |
| 813 | + | |
| 814 | + | |
| 815 | + | |
| 816 | + | |
| 817 | + | |
| 818 | + | |
| 819 | + | |
| 820 | + | |
| 821 | + | |
| 822 | + | |
| 823 | + | |
| 824 | + | |
| 825 | + | |
| 826 | + | |
| 827 | + | |
| 828 | + | |
| 829 | + | |
| 830 | + | |
| 831 | + | |
| 832 | + | |
| 833 | + | |
| 834 | + | |
| 835 | + | |
| 836 | + | |
| 837 | + | |
| 838 | + | |
| 839 | + | |
| 840 | + | |
| 841 | + | |
| 842 | + | |
| 843 | + | |
| 844 | + | |
| 845 | + | |
| 846 | + | |
| 847 | + | |
741 | 848 | | |
742 | 849 | | |
743 | 850 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
79 | 79 | | |
80 | 80 | | |
81 | 81 | | |
82 | | - | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
83 | 85 | | |
84 | 86 | | |
85 | 87 | | |
| |||
95 | 97 | | |
96 | 98 | | |
97 | 99 | | |
98 | | - | |
99 | | - | |
100 | | - | |
101 | | - | |
102 | | - | |
103 | | - | |
104 | | - | |
105 | | - | |
106 | | - | |
107 | | - | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
108 | 107 | | |
109 | 108 | | |
110 | 109 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
280 | 280 | | |
281 | 281 | | |
282 | 282 | | |
283 | | - | |
284 | | - | |
285 | | - | |
| 283 | + | |
| 284 | + | |
| 285 | + | |
| 286 | + | |
| 287 | + | |
| 288 | + | |
| 289 | + | |
| 290 | + | |
| 291 | + | |
| 292 | + | |
| 293 | + | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
| 297 | + | |
| 298 | + | |
| 299 | + | |
| 300 | + | |
| 301 | + | |
286 | 302 | | |
287 | 303 | | |
288 | 304 | | |
| |||
0 commit comments