Skip to content

feat(reporting): support reporting scope all_media_buys for sellers - #1945

Merged
rachitm022 merged 13 commits into
nextfrom
claude/issue-1944-reporting-all-media-buys-scope
Nov 24, 2026
Merged

rachitm022 merged 13 commits into
nextfrom
claude/issue-1944-reporting-all-media-buys-scope

Conversation

@rachitm022

Copy link
Copy Markdown
Collaborator

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_scope is persisted in the content hash, the in-memory store and Postgres (migration 0009, storage contract 2 → 3).
  • Explicit configurations keep their existing hash.
  • An empty media_buy_ids never 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 become obligation.media_buy_ids and 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 / ReportingScopeBuy is 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 by period.end (known_at <= period.end).

Coverage is reported per buy.

  • PerMediaBuyPackageRoster and UnsupportedMediaBuyRoster are new package-roster results.
  • build_reporting_coverage enforces the partition and status rules from reporting-coverage.json.
  • With coverage_requirement=full, a period whose coverage isn't full becomes action_required / REPORTING_COVERAGE_INCOMPLETE and nothing is published.
  • Sellers that return a whole-configuration roster, or none, keep the previous status-only coverage. This is pinned by a test, because embedded-sales-agent's UTC package feed depends on it.

Zero-buy periods. An empty frozen set at snapshot finality publishes a zero-row snapshot without calling the source. At official finality it still fails closed, and all-scope with official is refused at admission.

Admission is opt-in. ReliableReportingService(..., media_buy_scope_resolver=..., admit_all_media_buys=False) refuses all-scope generations with UNSUPPORTED_FEATURE until the seller sets admit_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. ReportingProductionSupport always refuses all-scope, because per-period source binding for the production path isn't supported yet.

Docs.

  • Fixed the stale paragraph in docs/reporting-interop-matrix.md: the typed sync_accounts already sends exactly one scope selector.
  • Release notes are in 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 at snapshot finality now publishes a zero-row snapshot instead of raising EMPTY_DENOMINATOR. That includes obligations already open at upgrade. official finality is unchanged.

Release checklist

  • Release adcp and adcp-reporting-storage together. Storage contract 3 is checked at startup, so a mismatched pair fails loudly.
  • Raise the storage package's adcp>= floor to the adcp release that ships contract 3, and update tests/test_release_configuration.py:175.
  • Confirm the hard-coded first contract-3 versions: storage 0.2.0b5 and adcp 10.0.0b24.

Deferred

  • Per-period production source binding (ReportingProductionSourceBinding, producer_constituents, the service_context.sql hash guard). Until it lands, production admission refuses all-scope.
  • allow_partial publication.
  • An official zero-buy close backed by a seller attestation.
  • A storyboard upstream that exercises all_media_buys.

Test plan

  • make lint and make typecheck-all (mypy, adopter strict mypy, pyright, the type-ignore contract).
  • make test: 22157 passed, 7 failed. All 7 also fail on clean origin/next: 6 environment failures (node, /etc/os-release) and test_installed_cleanup_still_writes_evidence_when_pipe_draining_expires.
  • New tests: 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.
  • Postgres conformance at -n 2: 5003 passed. 23 of the 37 failures also fail on origin/next; the other 14 pass when run serially (they are load-sensitive).
  • Integration against embedded-sales-agent (editable install): reporting integration 137/137.
  • Independent code review. All findings are fixed in 657cc8e..0162ccc.

🤖 Generated with Claude Code

rachitm022 and others added 12 commits November 23, 2026 23:09
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]>
…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]>

@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.

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]>

@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 — 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.

@rachitm022
rachitm022 merged commit f386ba7 into next Nov 24, 2026
41 checks passed
@rachitm022
rachitm022 deleted the claude/issue-1944-reporting-all-media-buys-scope branch November 24, 2026 08:08
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