Repository navigation
feat(reporting): support reporting scope all_media_buys for sellers - #1945
Conversation
A ReportingConfiguration with media_buy_scope="all_media_buys" has no fixed
buy list. At each period close ReportingProducer asks the new
media_buy_scope_resolver which buys the period owes; the frozen set becomes
the obligation's media_buy_ids and is what the package roster resolver
receives (replace(configuration, media_buy_ids=frozen)). A committed period is
never re-resolved. MissingHistoricalMediaBuyScope commits nothing and leaves
the period, and every later one, open for a later turn without advancing
producer progress. freeze_all_media_buys/ReportingScopeBuy implement the
membership rule: known by period.end, flight overlapping the half-open period.
Persistence: the scope mode is part of the generation content hash (only for
all_media_buys, so exact-scope digests are unchanged) and is stored by the
in-memory and PostgreSQL stores; migration 0009 adds the column. Storage
contract 3.
Coverage: obligations freeze a per-buy partition built by the public
build_reporting_coverage helper. Package roster resolvers may return
PerMediaBuyPackageRoster (keys equal the frozen buys) with
UnsupportedMediaBuyRoster entries; Missing maps to an unknown buy with
limitation capability_unknown. The status projection serves the partition
instead of collapsing to full or unknown. An account generation whose frozen
coverage is not full publishes no revision; status reports
REPORTING_COVERAGE_INCOMPLETE.
A proven zero-buy period at required_finality snapshot closes with a zero-row
snapshot revision and full empty coverage, without calling the source. An
official zero-buy period is never closed from roster proof and keeps failing
closed.
Admission: ReliableReportingService(media_buy_scope_resolver=...) and
ReportingProductionSupport(media_buy_scope_resolver=...) admit all_media_buys
only with a resolver and only at snapshot finality; otherwise
UNSUPPORTED_FEATURE. Production admission maps {all_media_buys: true} to the
scope mode and refuses it as an explicit empty list.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
…e selector Co-Authored-By: Claude Opus 5.5 <[email protected]>
…edger DDL The media_buy_scope and coverage columns live in the idempotent reporting_ledger.sql, so every DDL chain that builds a ledger (create_schema, migrate, legacy ownership import, the notification and status stores) carries them and the required-object manifest holds. Migration 0009 re-runs that file for ledgers upgraded by migrate alone. Legacy ownership import fills the new columns with their defaults, and the PostgreSQL ledger store no longer imports an adcp symbol newer than the contract check. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…ters An exact media_buy_ids generation whose seller wires no package roster resolver, or returns a whole-configuration roster, again freezes the status-only coverage it had before (unknown with no limitations) and keeps publishing revisions. A coverage partition is retained, and an incomplete one withholds publication, only for per-buy roster evidence (PerMediaBuyPackageRoster, UnsupportedMediaBuyRoster) and for all_media_buys generations. Subscription owed sets follow the same retention rule. Co-Authored-By: Claude Opus 5.5 <[email protected]>
A buy's effective flight can be several half-open intervals (package flights with gaps). ReportingScopeBuy accepts flights=((start, end), ...) beside the single start_time/end_time form, which it fills with the envelope, and freeze_all_media_buys counts a buy when any interval overlaps the period. Membership keeps known_at <= period.end: the buy is known at the cutoff instant. Co-Authored-By: Claude Opus 5.5 <[email protected]>
A production configuration task that returns a ready state with a truthful but incomplete current_coverage partition is no longer refused. Every admitted generation requires full coverage, so the SDK validates the partition over the generation's buys and restates the state as action_required with a REPORTING_COVERAGE_INCOMPLETE issue, keeping the reported partition. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…act 3 Published ledgers gain the all_media_buys columns on boot and through migration 0009 (additive, applied while the contract step waits). adcp 10.0.0b4 (contract 2) is now refused by this storage at construction, before any DDL or write. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Production binds one source buy set per generation, so an all_media_buys generation would be admitted and then never fulfilled. Production admission now refuses it with UNSUPPORTED_FEATURE whether or not a scope resolver is wired, naming the missing per-period production source binding. The ReliableReportingService.configure path is unchanged. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Production refuses all_media_buys at admission, so its ready states again require full coverage over the generation's explicit buys and agree with the ledger. This reverts restating incomplete ready coverage as action_required and removes the production media buy scope resolver and its unreachable ready-state branch. Co-Authored-By: Claude Opus 5.5 <[email protected]>
A process of an earlier release reads an all_media_buys generation as an exact empty scope and permanently commits zero-buy obligations for it, and the SDK cannot see other processes. ReliableReportingService now refuses all_media_buys with UNSUPPORTED_FEATURE until it is built with admit_all_media_buys=True, which a seller sets once every reporting process reads storage contract 3; wiring a resolver alone admits nothing. The migration notes and storage README say so plainly, and no longer call the column upgrade online-safe. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…y deadline A period whose media buy scope stays unresolved, or whose package roster contradicts the frozen buys, commits nothing and holds every later period. It no longer waits silently: once the period's automated recovery deadline passes, each worker turn adds the would-be obligation's identifier to WorkerTurn.escalated, the signal an obligation out of automated recovery raises. A contradictory roster is now a resolver contract error that leaves the period open instead of an exception raised every turn. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
There was a problem hiding this comment.
Ladon verdict: Approve
Approve.
Checked: AdCP 3.2 all_media_buys reporting scope — additive feat: with no public model break (media_buy_scope defaults to media_buy_ids, coverage defaults to None), which is the correct semver signal. Fail-closed behavior throughout (no resolver → UNSUPPORTED_FEATURE, official finality refused, production refused, old-process gate via admit_all_media_buys). The media_buy_scope_resolver reuses _resolve_roster_until with a bounded roster_deadline, so the external call stays timeout-wrapped. Partition/status enforcement at coverage.py:650-669 is schema-validated by test_reporting_coverage_builder.py. Storage contract 2→3 + migration 0009 covered by conformance tests. New exports tracked in public_api_snapshot.json; reporting-ledger symbols are not AGENTS.md handler-table entries (consistent with existing roster exports). The empty-snapshot behavior change is documented and gated to snapshot finality.
No critical/high/medium findings. high_risk false, gated_paths false, no author team gate, no prior decision. Falls through to row 9.
… built A seller that overrides ReliableReportingService.configure without calling super skipped the admit_all_media_buys check. The service now hands its media buy scope resolver to a producer only when admit_all_media_buys is set, on every route that builds one, including restart recovery. Without the opt-in an all_media_buys generation closes no period: each worker turn reports UNSUPPORTED_FEATURE in configuration_errors and to the worker error handler. The configure-level check stays. Co-Authored-By: Claude Opus 5.5 <[email protected]>
There was a problem hiding this comment.
Ladon verdict: Approve
Approve — clean subsequent pass with no findings.
This is a subsequent review (prior outcome: approve) over a small 3-file delta. The reviewer surfaced no critical, high, or medium findings. service.py now gates the media_buy_scope_resolver on admit_all_media_buys so a configure() override that skips the class's admission check still fails closed at the producer (UNSUPPORTED_FEATURE); non-all_media_buys configs never use the resolver, so dropping it is harmless. producer.py is message-only, and a new parametrized test covers both branches of the gate — satisfying the wire-change-pathway test requirement.
Gate checks:
- No no-auto-approve team match.
- gated_paths: false; review_decision: APPROVED (no conflict).
- high_risk: false.
- No findings at any severity.
Decision table: rows 1–8 do not fire (no critical/high/medium findings, no gated path, no deletions, no team gate). Falls through to row 9 → approve.
Closes #1944
Summary
Sellers can now accept the AdCP 3.2 reliable-reporting scope
{all_media_buys: true}. At each period's end the seller freezes which media buys the period covers, and coverage is reported per buy.Scope mode is stored with the configuration.
ReportingConfiguration.media_buy_scopeis persisted in the content hash, the in-memory store and Postgres (migration0009, storage contract 2 → 3).media_buy_idsnever means "all".The buy set is frozen at period close. The seller supplies a resolver,
media_buy_scope_resolver(configuration, period), which returns one of:CompleteMediaBuyScope(ids): the frozen ids becomeobligation.media_buy_idsand are passed to the package roster resolver.MissingHistoricalMediaBuyScope: the period stays open, nothing is committed and progress doesn't advance. Once the period's recovery deadline passes it escalates.freeze_all_media_buys/ReportingScopeBuyis a pure helper that sellers can use inside their resolver. A buy belongs to the period when any of its flight intervals overlaps the period half-open and the seller knew of it byperiod.end(known_at <= period.end).Coverage is reported per buy.
PerMediaBuyPackageRosterandUnsupportedMediaBuyRosterare new package-roster results.build_reporting_coverageenforces the partition and status rules fromreporting-coverage.json.coverage_requirement=full, a period whose coverage isn't full becomesaction_required/REPORTING_COVERAGE_INCOMPLETEand nothing is published.Zero-buy periods. An empty frozen set at
snapshotfinality publishes a zero-row snapshot without calling the source. Atofficialfinality it still fails closed, and all-scope withofficialis refused at admission.Admission is opt-in.
ReliableReportingService(..., media_buy_scope_resolver=..., admit_all_media_buys=False)refuses all-scope generations withUNSUPPORTED_FEATUREuntil the seller setsadmit_all_media_buys=True. Do that only after every reporting process reads storage contract 3. An older process would otherwise read an all-scope generation as()and permanently commit empty obligations.ReportingProductionSupportalways refuses all-scope, because per-period source binding for the production path isn't supported yet.Docs.
docs/reporting-interop-matrix.md: the typedsync_accountsalready sends exactly one scope selector.docs/reporting-release-notes.md.Behaviour change for existing adopters
An explicit
media_buy_ids=()(only an adopter-built configuration can produce this; the wire schema requires at least one id) or an empty subscription owed set atsnapshotfinality now publishes a zero-row snapshot instead of raisingEMPTY_DENOMINATOR. That includes obligations already open at upgrade.officialfinality is unchanged.Release checklist
adcpandadcp-reporting-storagetogether. Storage contract 3 is checked at startup, so a mismatched pair fails loudly.adcp>=floor to the adcp release that ships contract 3, and updatetests/test_release_configuration.py:175.Deferred
ReportingProductionSourceBinding,producer_constituents, theservice_context.sqlhash guard). Until it lands, production admission refuses all-scope.allow_partialpublication.all_media_buys.Test plan
make lintandmake typecheck-all(mypy, adopter strict mypy, pyright, the type-ignore contract).make test: 22157 passed, 7 failed. All 7 also fail on cleanorigin/next: 6 environment failures (node,/etc/os-release) andtest_installed_cleanup_still_writes_evidence_when_pipe_draining_expires.test_reporting_all_media_buys_scope.py,test_reporting_coverage_builder.py, Postgres scope and coverage round-trips, and the production-admission and escalation tests.-n 2: 5003 passed. 23 of the 37 failures also fail onorigin/next; the other 14 pass when run serially (they are load-sensitive).🤖 Generated with Claude Code