Skip to content

feat(reporting): skip ledger_changed for empty first snapshot revisions - #9354

Merged
bokelley merged 3 commits into
mainfrom
feat/reporting-ledger-changed-empty-first-snapshot-main
Dec 6, 2026
Merged

bokelley merged 3 commits into
mainfrom
feat/reporting-ledger-changed-empty-first-snapshot-main

Conversation

@rachitm022

Copy link
Copy Markdown
Collaborator

Why

reporting.ledger_changed fires for every newly committed reporting revision or adjustment. Its job is to tell a buyer that reporting content changed when health didn't, for example a correction.

A short-period pacing feed (say period_duration: PT5M with snapshot finality) has to commit a revision for every elapsed period, empty ones included, because a zero-row report is different from no report. So a quiet campaign rings 288 doorbells per account per day, and none of them announces a change.

What changes for sellers

A seller MUST NOT fire reporting.ledger_changed for a revision that meets all three conditions:

  1. It is the first revision of its logical slice: it has no supersedes_reporting_revision_id.
  2. Its finality is snapshot.
  3. It carries no delivery: row_count is 0, or control_totals is non-empty and every value in it is zero.

Everything else fires exactly as it does today:

  • any revision with delivery
  • any snapshot revision that supersedes another (a restatement), even an empty one
  • every official revision, including a zero-row one
  • every adjustment

There is no new field, flag or capability. The rule is recorded as x-adcp-validation.empty_first_snapshot on core/reporting-ledger-changed-webhook.json.

What changes for buyers

You will no longer get a doorbell for an empty first snapshot. You already have to poll, and polling still shows these revisions: get_reporting_status with changes_after returns every revision, empty ones included. You learn about empty periods by reading.

What doesn't change

  • Every elapsed period still gets its obligation and its revision, including empty ones.
  • get_reporting_status with changes_after still returns every revision.
  • Polling stays the authoritative recovery path.
  • reporting.status_changed still announces late and missing periods.
  • Corrections still ring the doorbell: restated snapshots, official closes and adjustments all fire.

Files

  • static/schemas/source/core/reporting-ledger-changed-webhook.json: description, plus the new empty_first_snapshot validation rule.
  • static/schemas/source/enums/notification-type.json and static/schemas/source/core/reporting-delivery-capabilities.json: descriptions aligned.
  • docs/media-buy/task-reference/get_reporting_status.mdx (Readiness and recovery), docs/media-buy/reporting-core-implementation-guide.mdx (What Core is not; Treat push as a wake-up), docs/reference/implementor-faq.mdx, docs/protocol/get_adcp_capabilities.mdx: prose aligned.
  • tests/reporting-status-contract.test.cjs: a new case pins the rule with schema-valid revisions. An empty first snapshot gets no doorbell. A first snapshot with delivery, a superseding empty snapshot, an official revision, a zero-row official revision and an adjustment each get one. A revision with rows and no control totals also gets one, so an empty control_totals never counts as "every total is zero".
  • .changeset/ledger-changed-empty-first-snapshot.md: patch.

Compatibility

  • The webhook schema is x-status: experimental (media_buy.reporting_delivery).
  • The doorbell is already documented as optional and non-authoritative, and buyers MUST already poll. A buyer that follows the spec misses nothing.
  • No wire shape changes. The only behavior change is that a seller stops sending one kind of optional event.
  • A seller that fires on every revision today has to stop for empty first snapshots. Reviewers should confirm that this seller-side tightening is acceptable without the 6-week experimental notice. The argument for skipping the notice: no buyer behavior that conforms to the spec depends on the suppressed events.

Release line: this targets main (the 4.0 line). Please also cherry-pick it to 3.3.x as a patch, so 3.3 implementations can adopt it; 3.3 is GA and there is no 3.4, and the touched files are identical on 3.3.x. The webhook schema is x-status: experimental and the doorbell is optional and non-authoritative, but sellers that fire on every revision would have to adapt, so please confirm whether this needs the experimental-change notice.

The reference training agent needs no change in this repo. It emits reporting notifications through the @adcp/reporting-storage SDK outbox, so the emission rule belongs in that package.

🤖 Generated with Claude Code

@bokelley bokelley left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed on the problem: a 5-minute pacing feed rings 288 empty doorbells per account per day. A hand review while the bot is down. Requesting changes because the rule as written breaks sellers that conform today, but a softened version can go to 3.3.x as a patch.

1. MUST NOT is stronger than it needs to be (static/schemas/source/.../reporting-ledger-changed-webhook.json ~39, get_reporting_status.mdx ~430)

  • Both reference SDKs ring the doorbell for every revision today:
    • TS: packages/reporting-storage/src/notifications/notification-activity.ts ~1076 sets notificationRequired: true unconditionally.
    • Python: src/adcp/reporting/ledger/store.py ~1274 calls revision_event unconditionally.
  • Under MUST NOT, both become non-conformant overnight. The playbook (.agents/playbook.md ~552) also requires 6 weeks' notice and a migration note for breaking changes to an experimental surface, which rules out a patch.
  • Buyers already MUST poll, so being guaranteed the event never arrives gains them nothing.
  • Please use SHOULD NOT. That gets the noise reduction without breaking sellers, and it fits a 3.3.x patch. If you'd rather keep MUST NOT, it belongs on main only (4.0), with a migration note and an update to the media_buy.reporting_delivery row in experimental-status.mdx.

2. "First revision" isn't defined unambiguously

  • The PR treats "no supersedes_reporting_revision_id" as first. But reporting-obligation.json ~465 only requires a revision to name the immediately prior retained snapshot.
  • So a late restatement whose predecessor has aged out of retention also has no supersedes, and a correction down to zero rows would be silently suppressed.
  • Please define first-ness by the slice's history ("no earlier revision of this slice was ever committed"), not by whether the field is present.

3. Drop the control-totals branch

  • What "every control total is zero" means depends on the profile, so the rule becomes profile-dependent and can suppress revisions that have rows.
  • Please use row_count == 0 only.

4. Open question: status_changed fires on every obligation health change (TS notification-activity.ts ~1055). If each period's obligation moves from waiting to complete, do the 288 a day just move to that event?

Other notes

  • The PR touches three files under static/schemas/source/** (a gated path), so it needs explicit maintainer approval before merge.
  • The patch changeset is right only for the SHOULD NOT version.
  • No storyboard references ledger_changed, so none need to change.
  • The new test writes its own copy of the rule and checks it against hand-picked revisions; it doesn't exercise an implementation. A vector in reporting-subscriptions/vectors.json would be stronger.
  • I couldn't find the issue or discussion where this rule was agreed. Could you link it?
  • With SHOULD NOT, follow-up issues in both SDKs to skip the empty first doorbell are enough.

rachitm022 and others added 2 commits December 6, 2026 15:25
A short-period pacing feed (for example PT5M snapshot periods) commits a
revision for every elapsed period, including empty ones, so a quiet
campaign rang 288 reporting.ledger_changed doorbells per account per day
with nothing changed.

A seller now MUST NOT fire reporting.ledger_changed for a revision that
is the first of its logical slice (no supersedes_reporting_revision_id),
has finality snapshot, and carries no delivery (row_count 0, or a
non-empty control_totals whose values are all zero). Every other
revision still fires, including superseding snapshots and every
official revision (zero-row included), and every adjustment still fires.

Unchanged: every elapsed period still commits its obligation and
revision, changes_after still returns every revision, polling stays
authoritative, and reporting.status_changed still announces late or
missing periods.

The rule is recorded as x-adcp-validation.empty_first_snapshot on the
experimental webhook schema; the notification-type and capability
descriptions and the reporting docs are aligned, and the reporting
status contract test pins the rule with schema-valid revisions.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@rachitm022
rachitm022 force-pushed the feat/reporting-ledger-changed-empty-first-snapshot-main branch from 543b15e to 85adec2 Compare December 6, 2026 10:04
@rachitm022

Copy link
Copy Markdown
Collaborator Author

Addressed review items 1–3 in 85adec2b51:

  • softened the empty-first-snapshot rule from MUST NOT to SHOULD NOT;
  • defined firstness from the logical slice’s complete commit history, including predecessors aged out of retention, rather than from supersedes_reporting_revision_id;
  • defined empty solely as row_count == 0, with control totals explicitly excluded; and
  • moved the recommendation cases into reporting-subscriptions/vectors.json, including retention and control-total counterexamples.

GitHub exposes the feedback as one top-level review rather than separate line threads, so this reply covers the three implemented comments.

@bokelley bokelley left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approved, with the gated-path OK for static/schemas/source/**. All three requested changes are in: the rule is SHOULD NOT, a first revision is decided by the slice's commit history, and empty means row_count == 0. As advisory guidance it's patch-safe, so it will also be cherry-picked to 3.3.x.

@bokelley
bokelley merged commit 473cd6d into main Dec 6, 2026
70 checks passed
@bokelley
bokelley deleted the feat/reporting-ledger-changed-empty-first-snapshot-main branch December 6, 2026 11:35
bokelley added a commit that referenced this pull request Dec 6, 2026
…ns (#9354) (#9397)

* feat(reporting): skip ledger_changed for empty first snapshot revisions

A short-period pacing feed (for example PT5M snapshot periods) commits a
revision for every elapsed period, including empty ones, so a quiet
campaign rang 288 reporting.ledger_changed doorbells per account per day
with nothing changed.

A seller now MUST NOT fire reporting.ledger_changed for a revision that
is the first of its logical slice (no supersedes_reporting_revision_id),
has finality snapshot, and carries no delivery (row_count 0, or a
non-empty control_totals whose values are all zero). Every other
revision still fires, including superseding snapshots and every
official revision (zero-row included), and every adjustment still fires.

Unchanged: every elapsed period still commits its obligation and
revision, changes_after still returns every revision, polling stays
authoritative, and reporting.status_changed still announces late or
missing periods.

The rule is recorded as x-adcp-validation.empty_first_snapshot on the
experimental webhook schema; the notification-type and capability
descriptions and the reporting docs are aligned, and the reporting
status contract test pins the rule with schema-valid revisions.



* fix(reporting): refine empty snapshot notification rule

---------



(cherry picked from commit 473cd6d)

Co-authored-by: Rachit <43431004+rachitm022@users.noreply.github.com>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
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.

2 participants