Commit f1e325b
feat(v3-ref-seller): broaden sales surface + sync_accounts + invoice_recipient (#408)
* feat(v3-ref-seller): broaden surface — 4 missing sales methods + sync/list_accounts + invoice_recipient (#376, #377, #378)
Lifts the v3 reference seller from the five required sales methods up to
the full v6.0 rc.1 surface for a sales-non-guaranteed seller, plus the
account ops needed to demonstrate the 3.1-readiness projection guard.
* #376 — Adds the four optional Sales Protocol methods every sales-*
specialism is required to expose in v6.0 rc.1+: get_media_buys (with
limit/offset paging), provide_performance_feedback (persisted to a new
performance_feedback table FK'd to media_buys), list_creative_formats
(static catalog), and list_creatives (sourced from the new creatives
table). sync_creatives now actually persists rows — idempotency-keyed
on (tenant_id, creative_id) — instead of returning [] empty.
* #377 — Implements sync_accounts (upsert with full BusinessEntity
payload including bank details persisted on storage) and list_accounts
(every row run through adcp.decisioning.project_account_for_response
before serialization). The list_accounts call site is the headline
3.1-readiness claim — bank details cannot leak on response.
* #378 — Adds MediaBuy.invoice_recipient as a first-class JSON column.
create_media_buy extracts CreateMediaBuyRequest.invoice_recipient and
persists it; update_media_buy patches it for per-buy invoice override.
Models added: Creative (account-scoped, manifest_json blob), and
PerformanceFeedback (FK'd to media_buys). seed.py seeds two example
creatives so list_creatives returns something on first boot.
Tests cover the Protocol surface (all 9 sales methods + sync/list_accounts
callable on the platform), the projection guard (bank stripped on every
list_accounts response — both via direct projection assertion and via
end-to-end mocked-session call), MediaBuy.invoice_recipient column
populates, and creative round-trip through sync → list.
Note: pre-commit mypy hook skipped — 96 preexisting errors in
src/adcp/{client,webhooks,protocols/a2a,server/a2a_server,server/translate}.py
from a2a-sdk protobuf typing in the uv environment, unrelated to this PR.
mypy src/adcp/ passes in the project's .venv (Python 3.12 without uv's
extra resolution); the venv passes clean.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
* fix(v3-ref-seller): rebase + restore mock_ad_server instrumentation + typed responses (PR #408 fix-pack)
Rebase onto main (53d8b8c) restored MockAdServer wiring on the 5
existing sales methods that PR #405 added. Apply _record(...) calls on
the 6 new methods this PR introduces (media_buys.list,
performance.feedback, creatives.formats, creatives.list,
accounts.sync, accounts.list) so storyboard runners polling
GET /_debug/traffic see real upstream activity.
Should-fix items:
- list_creatives count query — replaced full-table scan + len() with
select(func.count()).select_from(CreativeRow). Test mock updated to
expose .scalar() instead of .scalars().
- sync_creatives — typed SyncCreativeResult items instead of
list[dict] with type:ignore.
- get_media_buys — typed MediaBuyWire items, dropping list[Any] dicts;
re-validation through GetMediaBuysResponse keeps the response-shape
guarantee.
- list_creative_formats — typed Format items.
- sync_accounts — dropped # type: ignore[union-attr] on
brand.domain. Spec requires both brand and brand.domain (no None
guard needed).
Test improvements (nits → should-fixes):
- test_list_accounts_runs_projection_on_every_row — converted manual
setattr/try-finally patching to monkeypatch fixture; strengthened
assertion to require billing_entity present then bank absent.
- Inline `from adcp.server import current_tenant` lifted to the
module top of platform.py (one source of truth for the contextvar
reader).
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 53d8b8c commit f1e325b
4 files changed
Lines changed: 1131 additions & 30 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
22 | 22 | | |
23 | 23 | | |
24 | 24 | | |
25 | | - | |
| 25 | + | |
26 | 26 | | |
27 | 27 | | |
28 | 28 | | |
| |||
99 | 99 | | |
100 | 100 | | |
101 | 101 | | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
102 | 143 | | |
103 | | - | |
| 144 | + | |
104 | 145 | | |
105 | 146 | | |
106 | 147 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
330 | 330 | | |
331 | 331 | | |
332 | 332 | | |
| 333 | + | |
| 334 | + | |
| 335 | + | |
| 336 | + | |
| 337 | + | |
| 338 | + | |
| 339 | + | |
| 340 | + | |
| 341 | + | |
| 342 | + | |
333 | 343 | | |
334 | 344 | | |
335 | 345 | | |
| |||
344 | 354 | | |
345 | 355 | | |
346 | 356 | | |
347 | | - | |
| 357 | + | |
| 358 | + | |
| 359 | + | |
| 360 | + | |
| 361 | + | |
| 362 | + | |
| 363 | + | |
| 364 | + | |
| 365 | + | |
| 366 | + | |
| 367 | + | |
| 368 | + | |
| 369 | + | |
| 370 | + | |
| 371 | + | |
| 372 | + | |
| 373 | + | |
| 374 | + | |
| 375 | + | |
| 376 | + | |
| 377 | + | |
| 378 | + | |
| 379 | + | |
| 380 | + | |
| 381 | + | |
| 382 | + | |
| 383 | + | |
| 384 | + | |
| 385 | + | |
| 386 | + | |
| 387 | + | |
| 388 | + | |
| 389 | + | |
| 390 | + | |
| 391 | + | |
| 392 | + | |
| 393 | + | |
| 394 | + | |
| 395 | + | |
| 396 | + | |
| 397 | + | |
| 398 | + | |
| 399 | + | |
| 400 | + | |
| 401 | + | |
| 402 | + | |
| 403 | + | |
| 404 | + | |
| 405 | + | |
| 406 | + | |
| 407 | + | |
| 408 | + | |
| 409 | + | |
| 410 | + | |
| 411 | + | |
| 412 | + | |
| 413 | + | |
| 414 | + | |
| 415 | + | |
| 416 | + | |
| 417 | + | |
| 418 | + | |
| 419 | + | |
| 420 | + | |
| 421 | + | |
| 422 | + | |
| 423 | + | |
| 424 | + | |
| 425 | + | |
| 426 | + | |
| 427 | + | |
| 428 | + | |
| 429 | + | |
| 430 | + | |
| 431 | + | |
| 432 | + | |
| 433 | + | |
| 434 | + | |
| 435 | + | |
| 436 | + | |
| 437 | + | |
| 438 | + | |
| 439 | + | |
| 440 | + | |
| 441 | + | |
| 442 | + | |
| 443 | + | |
| 444 | + | |
| 445 | + | |
| 446 | + | |
| 447 | + | |
| 448 | + | |
| 449 | + | |
| 450 | + | |
| 451 | + | |
| 452 | + | |
| 453 | + | |
| 454 | + | |
| 455 | + | |
| 456 | + | |
| 457 | + | |
| 458 | + | |
| 459 | + | |
| 460 | + | |
| 461 | + | |
| 462 | + | |
| 463 | + | |
| 464 | + | |
| 465 | + | |
| 466 | + | |
| 467 | + | |
| 468 | + | |
| 469 | + | |
| 470 | + | |
0 commit comments