Repository navigation
fix(reporting): pick each obligation's current revision by its own finality - #3831
Conversation
…nality A seller can owe a snapshot obligation and an official obligation for the same account, report, media buys and period. Revisions do not name their obligation, so the consumer joined both obligations to every revision in the slice: once the official revision existed it became the snapshot obligation's current revision, failed that generation's finality check, and the buyer posted revision_missing over the snapshot obligation's received. Both obligations were also flagged ASSOCIATED_HISTORY_INCOMPLETE. When obligations at different required_finality share a slice, each now chooses among the revisions at its own finality (core/reporting-obligation "complete requires a published revision at required_finality"). Explicit materialization joins stay candidates, a predecessor attributed to the sibling is not reported missing, and revision_count matches either the obligation's own revisions or the slice. reconcileReportingCoreV1 joins the same way instead of throwing. Single-obligation slices are unchanged. getMediaBuyDelivery now receives options.reportingObligation naming the obligation each exact-revision read is for. The wire request is unchanged. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
There was a problem hiding this comment.
Ladon verdict: Approve
Approve.
Clean, additive finality-sibling fix. selectCurrent (reconciliation.ts:2060) and reconcileReportingCoreV1 (core-reconciliation.ts:422) finality-filter slice candidates only when a sibling obligation shares the slice at a different required_finality; candidates === slice reference-equality (reconciliation.ts:2070) keeps the single-obligation path byte-identical. Ledger finality is binary ('snapshot'|'official'), so no third-value edge. Relaxations only loosen in sibling mode; a genuinely missing snapshot still surfaces via MISSING_CURRENT_REVISION. New optional field + exported type is additive; minor changeset is correct and exports resolve.
No Critical/High/Medium findings. Not a no-auto-approve-team author; gated_paths is false; high_risk is false. Rows 1–8 do not fire — falls through to row 9.
…nality (#1988) A seller can owe two obligations for one account, report, reporting profile, media buys and period that differ only in required_finality: a snapshot pacing feed and an official billing feed. A revision does not name its obligation, so without explicit ownership the buyer joined both obligations to every revision of the slice. Once the official revision existed, the snapshot obligation selected it, both obligations were diagnosed AMBIGUOUS_REVISION_OWNERSHIP and ASSOCIATED_HISTORY_INCOMPLETE, and reconcile_reporting_core refused to plan any consumer status (ConsumerStatusPlanError: the slice's revisions against a per-obligation revision_count). When another obligation shares the slice at a different required_finality, each obligation now selects among the revisions at its own finality, plus any the seller materialized for it. Supersession and fork checks run over those options; an official revision naming the snapshot it replaces from the sibling's chain is not a missing predecessor. revision_count matches if it equals either the obligation's own revisions or the whole slice; any other count is diagnosed with the logical-slice bounds as before. The finality join settles attribution only: known owners and count bounds keep the logical-slice association, so no ledger that was diagnosed before now raises. A slice with one obligation, or whose obligations all require one finality, takes the existing code path. reconcile_reporting_core feeds the planner the evaluator's own partition. plan_consumer_statuses takes an optional revision_slices mapping for callers who build partitions themselves. ReportingReconciliationResult.revision_reads lists each exact-revision read with a ReportingRevisionReadObligation (reporting_obligation_id, delivery_config_id, delivery_config_version), local context that is never part of the request sent to the seller. Matches adcontextprotocol/adcp-client#3831. Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Problem
A seller can owe two obligations for the same account, report, media buys and period that differ only in
required_finality: a provisional (snapshot) feed and an official feed. A revision doesn't name its obligation.core/reporting-revision.jsonsays "one canonical revision may fan out through many caller/account-bound obligations", soreconcileReportingjoined both obligations to every revision in the slice.Once the official revision existed:
officials[0] ?? current[0]). The snapshot generation pins no official finality rule, so the selection failed withEXPECTED_FINALITY_POLICY_MISMATCH. Nothing was read, and the buyer postedrevision_missingfor the snapshot obligation, superseding its earlierreceived.ASSOCIATED_HISTORY_INCOMPLETE. The SDK seller countsrevision_countper obligation, but the consumer counted the whole slice.reconcileReportingCoreV1threwCore reporting revision history is incomplete or ambiguousfor the same ledger.getMediaBuyDeliverydidn't receive the obligation being read, so a client serving several obligations had to infer which one a revision belonged to.Fix
Selection (
selectCurrent,reconcileReportingCoreV1). This only applies when another obligation shares the slice at a differentrequired_finality. In that case each obligation chooses among the revisions at its own finality.core/reporting-obligation.jsonsayscomplete"requires a published revision at required_finality … A snapshot-required pacing obligation may therefore become complete from a snapshot revision".core/reporting-consumer-status.jsonsaysrevision_missing"means the obligation existed but no required revision was available".revision_countmatches if it equals either the obligation's own candidates (one chain per obligation, as the SDK seller does) or the whole slice (one chain fanned out).Unchanged behaviour. A slice with one obligation, or whose obligations all require the same finality, takes the exact pre-change code path: candidates are the whole slice and a unique official still takes precedence. Every existing reconciliation test passes unchanged, including the official-precedence matrix.
Reader context.
client.getMediaBuyDelivery(params, options)now receivesoptions.reportingObligation, which is{ reportingObligationId, deliveryConfigId, deliveryConfigVersion }(exported typeReportingRevisionReadObligation). It is backwards compatible:It's documented in
docs/guides/REPORTING-RECONCILIATION.md.Tests
test/lib/reporting-consumer-finality-siblings.test.jsruns the real SDK seller: two producers on one in-memory ledger, one generation per finality.receivedand the official obligation isrevision_missingwithMISSING_CURRENT_REVISION. Then the official close publishes, then the official obligation isreceivedand the snapshot obligation staysreceived(unchanged). Norevision_missingis ever posted for the snapshot chain, and neither obligation getsASSOCIATED_HISTORY_INCOMPLETE,EXPECTED_FINALITY_POLICY_MISMATCHorAMBIGUOUS_REVISION_CHAIN.options.reportingObligation, and the wire params are unchanged.reconcileReportingCoreV1joins each obligation to its own finality instead of throwing.packages/reporting-storage/test/reporting-consumer-finality-siblings-pg.test.jsruns the same end-to-end flow against the PostgreSQL store.On the unfixed code the end-to-end test fails with
revision_missingwherereceivedis expected, and the Core reconciler throws.Local runs:
npm run typecheck,typecheck:reporting-storage,lint,lint:boundariesand prettier are clean.reporting-issue-events-pg.test.js"the dispatcher renders and delivers an opened event…", which fails identically on a cleanorigin/mainbuild and doesn't touch this code.🤖 Generated with Claude Code