diff --git a/.changeset/ledger-changed-empty-first-snapshot.md b/.changeset/ledger-changed-empty-first-snapshot.md new file mode 100644 index 00000000000..0af1a82386d --- /dev/null +++ b/.changeset/ledger-changed-empty-first-snapshot.md @@ -0,0 +1,5 @@ +--- +"adcontextprotocol": patch +--- + +Reliable Reporting (experimental): a seller SHOULD NOT fire `reporting.ledger_changed` for an empty first snapshot revision, meaning a `snapshot` revision with `row_count` 0 when no earlier revision of the same logical slice was ever committed. Firstness comes from the slice's commit history, not from whether `supersedes_reporting_revision_id` is present, because a predecessor may have aged out of retention. A short-period pacing feed commits a revision for every period, including quiet ones, so a five-minute feed can ring 288 doorbells per account per day with nothing changed. Every other revision still fires: one with rows, any later snapshot, and every `official` revision, including a zero-row one. Every adjustment still fires. Unchanged: every elapsed period still gets its obligation and revision, `get_reporting_status` with `changes_after` still returns every revision, polling stays authoritative, and `reporting.status_changed` still announces health transitions. Buyers already poll, so they learn about empty periods by reading. The advisory rule is recorded as `x-adcp-validation.empty_first_snapshot` on `core/reporting-ledger-changed-webhook.json`; the webhook, notification-type, and capability descriptions and the reporting docs now say the same. No field, enum, or capability changes. diff --git a/docs/media-buy/reporting-core-implementation-guide.mdx b/docs/media-buy/reporting-core-implementation-guide.mdx index 3c039531c3f..c6a970e0aac 100644 --- a/docs/media-buy/reporting-core-implementation-guide.mdx +++ b/docs/media-buy/reporting-core-implementation-guide.mdx @@ -169,9 +169,13 @@ obligation appears in the first ledger snapshot strictly after `02:00Z`; with If you do offer push, Core's doorbell is `reporting.status_changed` — an invalidation for health transitions in either direction, with stable `issue_ids`. `reporting.ledger_changed` is the separate optional invalidation - for every new revision or adjustment, including changes that leave health - untouched. `reporting.delivery_ready` belongs to the managed-delivery tier - and never fires for Core configurations. + for each new revision or adjustment, including changes that leave health + untouched. It SHOULD NOT fire for an empty first snapshot: a `snapshot` + revision with `row_count` `0` when no earlier revision of the same logical + slice was ever committed. Firstness comes from that commit history, not from + whether `supersedes_reporting_revision_id` is present. The revision is still + committed and readable through `changes_after`. `reporting.delivery_ready` + belongs to the managed-delivery tier and never fires for Core configurations. - **No delivery machinery.** Core offerings omit `method`: the status ledger and its immutable revision metadata are required, while any existing `get_media_buy_delivery` read or legacy reporting webhook remains an @@ -302,7 +306,9 @@ digest is intentionally retained). 7. **Treat push as a wake-up.** `reporting.ledger_changed` starts a `changes_after` repair. Because a clock-only health transition may commit no ledger record, `reporting.status_changed` starts a non-incremental current - summary or periods read. Poll periodically even when notifications are enabled. + summary or periods read. Poll periodically even when notifications are enabled: + an empty first snapshot revision may ring no ledger doorbell, so your poll is + how you reliably see it. ## How to verify diff --git a/docs/media-buy/task-reference/get_reporting_status.mdx b/docs/media-buy/task-reference/get_reporting_status.mdx index 39cabef1e25..29f219984d5 100644 --- a/docs/media-buy/task-reference/get_reporting_status.mdx +++ b/docs/media-buy/task-reference/get_reporting_status.mdx @@ -422,9 +422,24 @@ offered. Three doorbells exist, with different purposes: readiness for one materialization at a destination. Core configurations never fire it. - **`reporting.ledger_changed`** (any tier, including Core) — invalidation - for every new revision or adjustment, even when an already-healthy period + for each new revision or adjustment, even when an already-healthy period remains healthy. Its record identity lets receivers deduplicate; repair uses the receiver's own durable checkpoint rather than trusting event order. + It SHOULD NOT fire for an empty first snapshot (see below). + +A seller SHOULD NOT fire `reporting.ledger_changed` for a `snapshot` revision +with `row_count` `0` when no earlier revision of the same logical slice was ever +committed. Firstness comes from the slice's commit history, not from whether +`supersedes_reporting_revision_id` is present: a later correction still fires +when its predecessor has aged out of retention and the field is absent. Control +totals do not affect whether a revision is empty. A short-period +pacing feed commits one of these for every quiet period, and a doorbell for each +one announces nothing. The period still gets its obligation and its revision, +and a `changes_after` read still returns that revision; receivers learn about +empty periods by reading. Every other revision fires: one with rows, any later +snapshot, and every `official` revision, including a zero-row one. Every +adjustment fires. Health transitions remain the separate concern of +`reporting.status_changed`. When offered (advertised via `readiness_notification`), `reporting.delivery_ready` is an account-anchored doorbell registered through diff --git a/docs/protocol/get_adcp_capabilities.mdx b/docs/protocol/get_adcp_capabilities.mdx index 8f8fa8fa20d..209ceb205b8 100644 --- a/docs/protocol/get_adcp_capabilities.mdx +++ b/docs/protocol/get_adcp_capabilities.mdx @@ -938,7 +938,9 @@ tier-independent invalidation for health transitions in either direction — valid for Core, since it names no destination, and repaired through a full current status read; `ledger_notification` (`reporting.ledger_changed`) announces each new revision or adjustment even when -health is unchanged; and `readiness_notification` (`reporting.delivery_ready`) +health is unchanged, but SHOULD NOT announce a `snapshot` revision with +`row_count` `0` when no earlier revision of its logical slice was ever committed; +and `readiness_notification` (`reporting.delivery_ready`) is managed-delivery-only positive readiness. Ledger changes repair through `changes_after`; health-only changes use a non-incremental summary or periods read. diff --git a/docs/reference/implementor-faq.mdx b/docs/reference/implementor-faq.mdx index f110a367633..94d90dbffb4 100644 --- a/docs/reference/implementor-faq.mdx +++ b/docs/reference/implementor-faq.mdx @@ -30,9 +30,17 @@ adjustment separately. ### Q: How does a buyer learn about a correction that does not change health? -**A:** `reporting.ledger_changed` is the optional doorbell for every new +**A:** `reporting.ledger_changed` is the optional doorbell for each new revision or adjustment. It is separate from `reporting.status_changed`, which -only reports health transitions. Push remains optional and non-authoritative: +only reports health transitions. A correction always rings it: a superseding +snapshot, an `official` revision, and every adjustment fire. A seller SHOULD NOT +fire it for an empty first snapshot: a `snapshot` revision with `row_count` `0` +when no earlier revision of the same logical slice was ever committed. Firstness +comes from commit history, not the presence of `supersedes_reporting_revision_id`; +control totals do not determine emptiness. This lets a short-period pacing feed +avoid ringing once per quiet period. That revision is still committed and +returned by `changes_after`. +Push remains optional and non-authoritative: after fully consuming a periods read, persist `changes_checkpoint` and pass it as `changes_after` to repair missed, duplicate, or out-of-order events without re-reading the entire retained history. diff --git a/static/compliance/source/test-vectors/reporting-subscriptions/vectors.json b/static/compliance/source/test-vectors/reporting-subscriptions/vectors.json index 25f03a4565a..1b8a9f97eae 100644 --- a/static/compliance/source/test-vectors/reporting-subscriptions/vectors.json +++ b/static/compliance/source/test-vectors/reporting-subscriptions/vectors.json @@ -2,7 +2,7 @@ "contract_version": "3.3", "feature": "media_buy.reporting_subscriptions", "status": "experimental", - "description": "Canonical, SDK-independent coverage vectors for experimental principal-level reporting subscriptions: for each input, every period the seller owes. Each case gives the buyer-side input and either the exact owed periods (expected, one row per buy, resolved offering, and period, and expected_obligations, the same rows grouped the way obligations carry them) or the input error (expected_error). Every expected row is derived from the spec text cited in spec_refs. scripts/reference/reporting-coverage is a brute-force reference model, written from the same text, that reproduces every case; tests/reporting-subscription-coverage-vectors.test.cjs runs it. Each case validates against case.schema.json in this directory. Like the feature, the vectors are experimental and change with it.", + "description": "Canonical, SDK-independent vectors for experimental principal-level reporting subscriptions. cases covers every period the seller owes: each entry gives the buyer-side input and either the exact owed periods (expected, one row per buy, resolved offering, and period, and expected_obligations, the same rows grouped the way obligations carry them) or the input error (expected_error). ledger_notification_cases covers the reporting.ledger_changed recommendation for committed records. Every expected result is derived from the spec text cited in spec_refs. scripts/reference/reporting-coverage is a brute-force reference model for the coverage cases; tests/reporting-subscription-coverage-vectors.test.cjs runs it. Each coverage case validates against case.schema.json in this directory. Like the feature, the vectors are experimental and change with it.", "tzdata": { "version": "2026f", "source": "https://data.iana.org/time-zones/releases/tzdata2026f.tar.gz", @@ -16,8 +16,117 @@ "now": "Only resolved periods are expected: those whose period_end is at or before input.now.", "input": "The input is what the buyer holds: its subscription versions as the get_principal readback shows them, the account's grants and timezone, the buys it can see through get_media_buys, the seller's offerings, and this subscription's get_reporting_status subscription_coverage entry for the account. case.schema.json describes each field.", "expected_error": "When the input cannot determine coverage, expected_error gives the error code and detail an SDK raises, from error-codes.json in this directory (COVERAGE_INPUT_INCOMPLETE or COVERAGE_INPUT_INVALID). wire_valid is false when the input also fails AdCP schema validation.", - "vocabularies": "error-codes.json freezes the error codes SDKs raise for subscriptions and coverage; reason-codes.json freezes the reasons a period is or is not owed. Both SDKs use them verbatim." + "vocabularies": "error-codes.json freezes the error codes SDKs raise for subscriptions and coverage; reason-codes.json freezes the reasons a period is or is not owed. Both SDKs use them verbatim.", + "ledger_notifications": "ledger_notification_cases freezes the recommended reporting.ledger_changed decision for a committed record. slice_commit_count_before is the number of revisions previously committed for the same logical slice, including revisions whose retention window has ended. should_not_fire is an advisory SHOULD NOT outcome; fire identifies records outside that exception." }, + "ledger_notification_cases": [ + { + "id": "empty-first-snapshot-zero-rows", + "rule": "A rowless snapshot is the first revision because the slice has no earlier commit, so the seller should not fire reporting.ledger_changed; control totals do not change emptiness.", + "spec_refs": [ + "static/schemas/source/core/reporting-ledger-changed-webhook.json#/x-adcp-validation/empty_first_snapshot" + ], + "slice_commit_count_before": 0, + "record": { + "kind": "revision", + "finality": "snapshot", + "row_count": 0, + "control_totals": [ + { "name": "spend", "value": "12.00" } + ] + }, + "expected": "should_not_fire" + }, + { + "id": "empty-first-snapshot-without-control-totals", + "rule": "A rowless snapshot is the first revision because the slice has no earlier commit, so the seller should not fire reporting.ledger_changed.", + "spec_refs": [ + "static/schemas/source/core/reporting-ledger-changed-webhook.json#/x-adcp-validation/empty_first_snapshot" + ], + "slice_commit_count_before": 0, + "record": { + "kind": "revision", + "finality": "snapshot", + "row_count": 0, + "control_totals": [] + }, + "expected": "should_not_fire" + }, + { + "id": "first-snapshot-with-rows-and-zero-control-total", + "rule": "A first snapshot with rows fires reporting.ledger_changed even when its profile-specific control total is zero.", + "spec_refs": [ + "static/schemas/source/core/reporting-ledger-changed-webhook.json#/x-adcp-validation/empty_first_snapshot" + ], + "slice_commit_count_before": 0, + "record": { + "kind": "revision", + "finality": "snapshot", + "row_count": 2, + "control_totals": [ + { "name": "spend", "value": "0.00" } + ] + }, + "expected": "fire" + }, + { + "id": "empty-correction-after-predecessor-retention", + "rule": "A rowless correction fires because the slice has an earlier commit, even after that predecessor aged out and supersedes_reporting_revision_id is absent.", + "spec_refs": [ + "static/schemas/source/core/reporting-ledger-changed-webhook.json#/x-adcp-validation/empty_first_snapshot" + ], + "slice_commit_count_before": 1, + "record": { + "kind": "revision", + "finality": "snapshot", + "row_count": 0, + "control_totals": [] + }, + "expected": "fire" + }, + { + "id": "empty-superseding-snapshot", + "rule": "A rowless superseding snapshot fires because the logical slice already has an earlier committed revision.", + "spec_refs": [ + "static/schemas/source/core/reporting-ledger-changed-webhook.json#/x-adcp-validation/empty_first_snapshot" + ], + "slice_commit_count_before": 1, + "record": { + "kind": "revision", + "finality": "snapshot", + "row_count": 0, + "control_totals": [], + "supersedes_reporting_revision_id": "rrv_prior" + }, + "expected": "fire" + }, + { + "id": "zero-row-first-official", + "rule": "An official revision fires even when it is the slice's first commit and has zero rows.", + "spec_refs": [ + "static/schemas/source/core/reporting-ledger-changed-webhook.json#/x-adcp-validation/empty_first_snapshot" + ], + "slice_commit_count_before": 0, + "record": { + "kind": "revision", + "finality": "official", + "row_count": 0, + "control_totals": [] + }, + "expected": "fire" + }, + { + "id": "reporting-adjustment", + "rule": "Every reporting adjustment fires reporting.ledger_changed.", + "spec_refs": [ + "static/schemas/source/core/reporting-ledger-changed-webhook.json#/x-adcp-validation/empty_first_snapshot" + ], + "record": { + "kind": "adjustment" + }, + "expected": "fire" + } + ], "cases": [ { "id": "baseline", diff --git a/static/schemas/source/core/reporting-delivery-capabilities.json b/static/schemas/source/core/reporting-delivery-capabilities.json index b9a9ae6d800..a13ce194a83 100644 --- a/static/schemas/source/core/reporting-delivery-capabilities.json +++ b/static/schemas/source/core/reporting-delivery-capabilities.json @@ -99,7 +99,7 @@ "ledger_notification": { "type": "string", "const": "reporting.ledger_changed", - "description": "Optional tier-independent invalidation for every newly committed revision or post-official adjustment, even when health does not change. Receivers repair through get_reporting_status changes_after; polling remains authoritative." + "description": "Optional tier-independent invalidation for each newly committed revision or post-official adjustment, even when health does not change. A seller SHOULD NOT fire it for an empty first snapshot: a snapshot revision with row_count 0 when no earlier revision of the same logical slice was ever committed. Firstness comes from the slice's commit history, not the presence of supersedes_reporting_revision_id. Receivers repair through get_reporting_status changes_after; polling remains authoritative." }, "offerings": { "type": "array", diff --git a/static/schemas/source/core/reporting-ledger-changed-webhook.json b/static/schemas/source/core/reporting-ledger-changed-webhook.json index 8c75b4076e7..43e483b20f4 100644 --- a/static/schemas/source/core/reporting-ledger-changed-webhook.json +++ b/static/schemas/source/core/reporting-ledger-changed-webhook.json @@ -3,7 +3,7 @@ "$id": "/schemas/core/reporting-ledger-changed-webhook.json", "title": "Reporting Ledger Changed Webhook", "x-status": "experimental", - "description": "Optional account-anchored invalidation fired for every newly committed reporting revision or post-official adjustment, whether or not health changes. Valid in every reporting tier. Receivers repair from their own durable changes_after checkpoint through get_reporting_status; this event is never the source of truth.", + "description": "Optional account-anchored invalidation fired for a newly committed reporting revision or post-official adjustment, whether or not health changes. A seller SHOULD NOT fire it for an empty first snapshot revision (see x-adcp-validation.empty_first_snapshot). Valid in every reporting tier. Receivers repair from their own durable changes_after checkpoint through get_reporting_status; this event is never the source of truth.", "type": "object", "properties": { "idempotency_key": { "type": "string", "minLength": 16, "maxLength": 255, "pattern": "^[A-Za-z0-9_.:-]{16,255}$", "description": "Random per distinct fire and stable across transport retries, scoped to the authenticated sender." }, @@ -35,7 +35,8 @@ } ], "x-adcp-validation": { - "logical_record": "One destination-independent revision or adjustment produces one logical account event even when it fans out through multiple obligations or delivery configurations. Receivers use changes_after to resolve the affected obligations and deduplicate by the immutable record identity." + "logical_record": "One destination-independent revision or adjustment produces one logical account event even when it fans out through multiple obligations or delivery configurations. Receivers use changes_after to resolve the affected obligations and deduplicate by the immutable record identity.", + "empty_first_snapshot": "The seller SHOULD NOT fire this event for a revision that meets all three conditions: (a) no earlier revision of the logical slice was ever committed; (b) its finality is snapshot; and (c) row_count is 0. Firstness comes from the slice's commit history, not from whether supersedes_reporting_revision_id is present: a predecessor may have aged out of retention, and a later revision still fires when that field is absent. Control totals do not determine whether a revision is empty. The seller still commits the obligation and the revision for that period, and get_reporting_status with changes_after still returns it; receivers learn about empty periods by reading, not from this event. Every other revision fires: a revision with rows, any later snapshot revision, and every official revision, including a zero-row official revision. Every adjustment fires." }, "additionalProperties": true } diff --git a/static/schemas/source/enums/notification-type.json b/static/schemas/source/enums/notification-type.json index 740951758ab..4fd14f51d81 100644 --- a/static/schemas/source/enums/notification-type.json +++ b/static/schemas/source/enums/notification-type.json @@ -68,7 +68,7 @@ "capabilities.changed": "Agent-anchored fire. Sent when the seller's advertised `get_adcp_capabilities` document materially changes. Fires per subscriber against each caller-scoped agent `notification_configs[]` entry managed through `sync_principal` or `sync_agent_notification_configs` whose `event_types` includes this value. Payload: `capabilities-changed-webhook.json`. The payload does not include the full capability document; receivers SHOULD re-run `get_adcp_capabilities`, compare `adcp.capability_changes.capabilities_version` or `last_modified` when present, and update their cache from that fresh response. **notification_id**: stable per material capability revision; re-emissions of the same revision reuse the id, and a later material revision receives a new id.", "reporting.delivery_ready": "Experimental account-anchored readiness doorbell, managed-delivery tier only (it names a materialization at a destination; Core configurations never fire it). Fires after one immutable reporting materialization is observable through the intended consumer path. Payload: `reporting-delivery-ready-webhook.json`; it carries identities and readiness metadata, never report rows or credentials. Receivers repair missed, duplicate, or out-of-order fires through `get_reporting_status`. **notification_id**: stable per reporting_materialization_id reaching its ready state across re-emissions; a new retry/materialization receives a new id.", "reporting.status_changed": "Experimental account-anchored invalidation, valid in every reporting tier including Core. Fires when an obligation or configuration health state transitions in either direction — waiting to delayed, delayed to action_required, and recovery back to healthy or complete — including purely clock-driven transitions that no positive doorbell would ever announce. Payload: `reporting-status-changed-webhook.json`; it carries identifiers, the new health, and stable issue ids, never report rows. Push is optional in every tier: polling `get_reporting_status` remains the authoritative recovery path, and receivers repair every fire through it. **notification_id**: stable per (reporting_obligation_id or delivery_config_id, health transition); re-emissions reuse the id, and a later distinct transition receives a new id.", - "reporting.ledger_changed": "Experimental account-anchored invalidation, valid in every reporting tier including Core. Fires for each newly committed revision or post-official adjustment whether or not obligation health changes. Payload: `reporting-ledger-changed-webhook.json`; it carries the immutable record identity but no rows or credentials. Receivers repair missed, duplicate, or out-of-order fires from their own durable get_reporting_status changes_after checkpoint. **notification_id**: stable per reporting_revision_id or reporting_adjustment_id; re-emissions reuse it.", + "reporting.ledger_changed": "Experimental account-anchored invalidation, valid in every reporting tier including Core. Fires for each newly committed revision or post-official adjustment whether or not obligation health changes. A seller SHOULD NOT fire it for an empty first snapshot: a snapshot revision with row_count 0 when no earlier revision of the same logical slice was ever committed. Firstness comes from the slice's commit history, not the presence of supersedes_reporting_revision_id; control totals do not determine emptiness. Receivers learn about empty periods by reading. Payload: `reporting-ledger-changed-webhook.json`; it carries the immutable record identity but no rows or credentials. Receivers repair missed, duplicate, or out-of-order fires from their own durable get_reporting_status changes_after checkpoint. **notification_id**: stable per reporting_revision_id or reporting_adjustment_id; re-emissions reuse it.", "principal.changed": "Caller-anchored invalidation. Sent when the seller changes the authenticated principal's standing configuration through a seller-driven transition that does not advance configuration_version: a reporting destination moving between validating, ready, action_required, and rejected, a setup action nearing or passing expires_at, a proof invalidation, a change to the accepted declarations intersection, or a reporting subscription change (accounts_unauthorized changing, a coverage exception opening or closing, or the subscription moving to action_required). Not fired for the caller's own mutations — the sync response already reports those. Payload: `principal-changed-webhook.json`, an invalidation signal only; receivers repair by re-reading `get_principal`. **notification_id**: stable per logical principal-state transition; re-emissions reuse the id, and a later distinct transition receives a new id.", "proposal.created": "Experimental (media_buy.open_opportunities) account-anchored invalidation. Sent when the seller creates a later proposal for an opportunity under the buyer's later_proposals consent, after the creating task completed. A seller offer against an accepted media buy is not a later proposal and uses the buy-scoped sibling `proposal.offered` (media_buy.seller_offers); `media_buy_update` is out of scope for later proposals. Never sent for proposals returned in a task response, and never delivered to a task's push_notification_config. Payload: `proposal-created-webhook.json`, identifiers only; the payload is not the proposal, and receivers MUST read the snapshot with `list_proposals` before refining, accepting, or declining it. **anchor**: account. **notification_id**: equals `proposal_id`; a proposal is created once, so retries and deliberate re-emissions reuse it. **repair key**: `proposal_id` within the account, read through `list_proposals`. **classification**: invalidation.", "account_request.changed": "Experimental (account.requests) caller-anchored invalidation: a seller-driven change to one of the caller's account requests. **anchor**: caller. **notification_id**: per request transition; re-emissions reuse it. **repair key**: `request_id` via `list_accounts (include_requests)`. **classification**: invalidation.", diff --git a/tests/reporting-status-contract.test.cjs b/tests/reporting-status-contract.test.cjs index 46d64ca509a..1a54bea422b 100644 --- a/tests/reporting-status-contract.test.cjs +++ b/tests/reporting-status-contract.test.cjs @@ -1734,6 +1734,33 @@ describe('managed reporting status contract', () => { assert.equal(validateLedgerWebhook(event), true, JSON.stringify(validateLedgerWebhook.errors)); }); + it('drives the empty-first-snapshot ledger recommendation from conformance vectors', () => { + const validation = readSchema('/schemas/core/reporting-ledger-changed-webhook.json')['x-adcp-validation'].empty_first_snapshot; + assert.match(validation, /SHOULD NOT fire this event/); + assert.match(validation, /no earlier revision of the logical slice was ever committed/); + assert.match(validation, /row_count is 0/); + assert.doesNotMatch(validation, /control_totals.*zero/i); + + const vectors = JSON.parse(fs.readFileSync( + path.join(__dirname, '..', 'static', 'compliance', 'source', 'test-vectors', 'reporting-subscriptions', 'vectors.json'), + 'utf8', + )).ledger_notification_cases; + const recommendation = ({ slice_commit_count_before: priorCommits, record }) => { + if (record.kind === 'adjustment') return 'fire'; + return priorCommits === 0 && record.finality === 'snapshot' && record.row_count === 0 + ? 'should_not_fire' + : 'fire'; + }; + assert.equal(new Set(vectors.map(vector => vector.id)).size, vectors.length, 'vector ids are unique'); + for (const vector of vectors) { + assert.ok(vector.rule, `${vector.id}: rule`); + assert.deepEqual(vector.spec_refs, [ + 'static/schemas/source/core/reporting-ledger-changed-webhook.json#/x-adcp-validation/empty_first_snapshot', + ], `${vector.id}: spec_refs`); + assert.equal(recommendation(vector), vector.expected, vector.id); + } + }); + it('uses readiness as a secret-free account doorbell repaired through status', () => { assert.equal(validateNotificationConfig({ subscriber_id: 'reporting-ingest',