Repository navigation
feat(reporting): hold subscription obligations in the reporting ledger - #3517
Conversation
Add the pure expectedSubscriptionPeriods rule for AdCP 3.3 principal-level reporting subscriptions (experimental media_buy.reporting_subscriptions), the normative period_generation calendar it uses, selector resolution (exact, finest, all with byte-order ties), scope membership, and a builder for the 3.3 registration capabilities (configuration_tasks, the deprecated configuration_task, and the subscriptions block). createAdcpServerFromPlatform adds media_buy.reporting_subscriptions to experimental_features only beside a subscriptions block. installConfiguration now throws a typed ReportingConfigurationImmutableError with the unchanged message. The cross-SDK parity table is test/fixtures/reporting-subscriptions/coverage-cases.json. Refs #3504 Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
…al ships Advertising media_buy.reporting_subscriptions also requires adcp.principal.supported_sections to list reporting_subscriptions, which the SDK does not emit yet. Keep the capability builder pure in this slice and add the feature id together with the principal block in the runtime slice, so an adopter can never produce a 3.3-invalid capabilities response. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Adopt the rules adcontextprotocol/adcp#8585 settled: - Selection reads each offering's published standard_dimensions and unmapped_dimensions, and fails closed on an offering without them. - period_timezone: a utc offering matches only UTC or Etc/UTC; a source_timezone offering only its own published zone (never an account-resolved one). - The coverage function takes the readback's inactive_intervals in wire shape, per-offering timezone_cutovers with previous_timezone (account.timezone is now the current zone), and per-offering gaps. - The parity table fixes the billing-cycle case's scope (both keys, which maxProperties 1 forbids), adds cases for the settled rules, and its subscriptions are now schema-validated. The new wire fields are hand-modeled in subscriptions/wire.ts until 3.3.0-beta.2 ships. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
- An empty flight (stop at or before start) overlaps nothing. - A cutover carries the outgoing stretch's own owing start into E, so two cutovers inside one period never owe a period twice. - Sub-daily periods under a local alignment restart at each local midnight on wall-clock multiples (adcp#8588); calendars gain next() and the walk iterates by instant with an iteration budget and skip-ahead. - A billing anchor in a DST fold is interval zero itself. - A wire authorized_at equal to the chain start continues the chain. - The start rule lives in one function for the pending owner decision. - Schema validation accepts unknown reporting-dimension values. - The parity table grows to 79 cases with obligations on every case and non-wire inputs labelled. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
The start bound is the first boundary at or after the later of the version's accepted_at and the account's authorized_at; a buy is owed every period that ends after its confirmed_at and overlaps its flight, so the period in which the buy is confirmed is owed in full. The rule stays in firstOwedBoundary. Parity table: the mid-period confirmed_at and hourly cases change, plus every case whose first period contains confirmed_at; new cases for an ASAP buy confirmed mid-day and a monthly billing buy confirmed on the 12th. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
…time
Opt-in support for the AdCP 3.3 sync_principal reporting_subscriptions
section (experimental media_buy.reporting_subscriptions):
- createPrincipalLifecycle({ reportingSubscriptions }) validates, versions
and reads back subscriptions (core/reporting-subscription-state.json),
honours dry_run and expected_configuration_version, applies
replace_account_configs once per version through a host hook, derives
action_required from the destination, and emits principal.changed with
reason reporting_subscription_changed. It also exposes the adcp.principal
capability block.
- createReportingSubscriptionEngineV1 turns three host hooks into grant
history, max_accounts slots, precedence, exceptions at cutover instants,
timezone cutovers, re-grant gaps, accounts_unauthorized, the receipt
roster and the post-loss receipt window, and computes owed periods with
the same expectedSubscriptionPeriods rule buyers run.
- createReliableReportingService({ reportingSubscriptions }) advertises
configuration_tasks and the subscriptions block and adds
subscription_coverage to summary and periods views.
- createAdcpServerFromPlatform passes capabilities.principal and
capability_changes through, adds protocol.principal and
media_buy.reporting_subscriptions to experimental_features, refuses
subscriptions without the reporting_subscriptions section, and strips
3.3-only fields for callers pinned below 3.3.
Without the options every response is byte-for-byte unchanged; a golden
transcript captured from the pre-change runtime proves it.
Refs #3504
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
… by release - readFacts refuses a roster that does not finish within the page cap, as it already did for a repeating cursor: a partial roster would read as revocations and fabricate accounts_unauthorized entries. - Callers pinned below 3.2 no longer see protocol.principal once the adcp.principal block is removed for them. - subscription_coverage is added only for callers served 3.3 or later; earlier get_reporting_status response shapes are closed. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
The placeholder regex backtracked polynomially on runs of '{' (CodeQL).
Tokenize braces in a single pass instead, which also rejects nested and
unbalanced braces explicitly.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
… test Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
- The principal readback lists inactive_intervals; the engine feeds them to the coverage function in wire shape. - Timezone cutovers carry previous_timezone and gaps are recorded per offering_id when covered offerings' boundaries differ. - authorized_at is the start of the authorization chain: a re-grant inside retention keeps it, so the engine stamps the re-grant when authority is observed again. - The service requires standard_dimensions on every offering when subscriptions are advertised. - Responses served at 3.3.0-beta.1 omit the fields its closed schemas do not define; they reach callers served 3.3.0-beta.2 or later. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
…ts, sharded engine state Addresses the expert review of the subscription runtime: - Owed periods are frozen as they elapse and never recomputed; pruning past status_retention_days never re-owes or drops an elapsed period. A product, package or offering change applies from the E of its observation, and periods of that buy starting earlier keep resolving from the buy as it was. - Change instants come from source data (granted_at, timezone_changed_at, resolveRevocationInstant, the overriding configuration's active_until). - The engine store is sharded per principal and per account; the receipt roster is tenant-scoped; an unobserved revocation followed by a new chain opens a gap. - replace_account_configs runs after commit and is retried on failure; a destination transport change needs a version; inactive_intervals over 64 is rejected; shared path_templates that can expand to the same path are rejected; the delivery-config clash check is required unless opted out; coverage recording rejects oversized lists and no longer bumps configuration_version. - Post-beta.1 fields are gated on the served bundle's schema, and an unknown served version emits none of them. prior_versions[] carries configuration (adcp#8588). Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
…counts A small max_accounts against a large roster gives every account past the cap a capacity exception, which can exceed the readback's 1000-entry limit. The reconcile used to throw for the whole principal on every pass. Now that subscription keeps its last published lists, every other subscription still updates, and the pass reports it in readback_overflow and through onReadbackOverflow. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
…criptions - syncReportingSubscriptionsV1 writes and reads back the reporting_subscriptions section through the guarded sync_principal lifecycle. - reportingSubscriptionVersionRecordsV1 rebuilds coverage version records from the readback plus the buyer's own per-version configurations, and subscriptionExpectedReportingPeriodsV1 maps owed obligations onto the consumer runtime's ExpectedReportingPeriod. - The consumer runtime takes a per-account subscriptionExpectations hook fed with the summary view's subscription_coverage, and refreshes on an authenticated principal.changed through handleAuthenticatedPrincipalChanged. - createReportingSubscriptionEngineStateStoreV1 persists engine state as one CAS document per principal on any AdcpStateStore; PostgresStateStore makes it durable with no further migration. A PostgreSQL restart test joins the CI backend-contracts step. Refs #3504 Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
…ords Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
…he buyer side reportingSubscriptionVersionRecordsV1 no longer takes buyer-recorded inactive intervals: the readback's inactive_intervals (adcp#8585) pass to expectedSubscriptionPeriods unchanged. Test offerings publish standard_dimensions. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
listPrincipals feeds the receipt roster, so a list cut short at the page cap, or a repeating cursor, now throws instead of returning a partial list, matching the authorized-account walk. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
- The engine state store follows the engine's sharded interface: one CAS document per principal and per (principal, account), with listKeys and a tenant-scoped listPrincipals. - Subscription expectations get the summary's ledger_as_of (minus an optional grace) as now, and the hook is documented as requiring a seller that materializes subscription obligations. - Expectation templates must supply coverage; the old default could never match an obligation reporting packages or partial coverage. - principal.changed redeliveries are dropped by idempotency_key, and a burst during a run joins one trailing run. - syncReportingSubscriptionsV1 refuses a deactivation by omission unless allowDeactivation, checked against every configuration read it replaces, and verifies the stored configuration field by field. - reportingSubscriptionVersionRecordsV1 falls back to the readback's configuration and prior_versions[].configuration (adcp#8588). Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Owed-set generations for AdCP 3.3 principal-level reporting subscriptions (#3504): one generation per (account, owning principal, subscription_id, subscription_version, resolved offering), with an immutable `subscription` block and a mutable `owedSet` horizon outside the fingerprint. - producer.planSubscriptionObligations installs each generation once, writes every frozen owed obligation with its own period, media buys and constituents (periodOrdinal = start second), and then advances owedSet.through on every generation the subscription owns. - Coverage treats an owed set as complete by construction: gaps are not owed, so there is no continuity error, and the scope stays open until owedSet.through reaches its end. - get_reporting_status, get_media_buy_delivery and sync_reporting_status scope subscription generations to the caller's principal (resolveSubscriptionPrincipal, snapshot `subscription_principal`). - Status ingest accepts a status without reporting_obligation_id against an owed set only for an existing owed obligation. - PostgreSQL: additive `subscription_key` column and a unique index on (account_id, delivery_config_id, delivery_config_version, subscription_key) replacing the three-column constraint, found and dropped by its columns. Mirrored in the memory test store. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
There was a problem hiding this comment.
Ladon verdict: Approve
Approve — AdCP 3.3 principal-level reporting subscriptions (experimental, opt-in) across 52 files, no blocking findings.
Checked:
- No Critical/High/Medium findings reported.
- Witness-not-translator honored: 3.3-only wire fields (reporting-subscription-release.ts, create-adcp-server L6619-6656, handler offering_id gate) emitted only when the served bundle defines them, not fabricated; handler re-checks visibility (L1671-1681).
- Multi-tenant isolation enforced in SQL via EXISTS keyed on subscription tenant/principal (postgres.ts L389-401, L432-451); migration is additive/idempotent, preserving existing (account,id,version) uniqueness.
- engine.ts fails closed on partial rosters and freezes each elapsed period exactly once (no re-owing); coverage.ts owed-period walk is bounded; producer.ts widens owed-set before obligations land then advances
throughonce durable. - path_template guarded against traversal / shared-destination collision.
- Changesets correct (4 minor, incl. @adcp/reporting-storage for the migration); CI wires the pg test.
Decision table: no critical/high (row 1 n/a); gated_paths false (row 2 n/a); high_risk false (rows 3/5 n/a); no medium findings (rows 4/8 n/a); no prior decision (row 6 n/a); no no-auto-approve team match (row 7 n/a). Falls through to row 9 → approve. Note: review_decision is REVIEW_REQUIRED but gated_paths is false, so row 2 does not apply.
# Conflicts: # scripts/check-package-size.mjs
There was a problem hiding this comment.
Ladon verdict: Approve
Approve — clean subsequent pass over the beta.6/beta.7 delta.
What I checked:
- Task-envelope
statuspreservation:relaxResponseRootreplaced by per-releaseacceptEnvelopeOnClosedResponseRoot+omitsEnvelopeStatusForRelease. Release-accurate (3.2.x closed arms omit status, 3.3 composes/requires it), witness-preserving (seller payload untouched; status mutation is validation-view only viaprepareResponseForSchemaValidation), and backed by the response-envelope-status-gating suite. - Opt-in
collect_product_pageswholesale walker: merged logical view explicitly labelled separate from retained physical pages; per-page schema/invariant grading viaonCollectedProductPage; fresh unkeyed reads enforced at loader and dispatch. - Two new default-on discovery invariants (pricing-currency, required-metric): cite normative ProductFilters basis; report unproven cases as indeterminate rather than fabricating requirements — consistent with witness-not-translator.
- Changesets present and correctly typed (minor/minor/patch).
No Critical/High/Medium findings. Prior pass was also clean (approve). high_risk: false, no gated paths, no team gate. review_decision is REVIEW_REQUIRED but gated_paths is false, so row 2 does not fire. None of rows 1–8 apply → row 9 approve.
…bscription-coverage # Conflicts: # scripts/check-package-size.mjs
…dules after merging main Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
…/reporting-subscription-runtime # Conflicts: # scripts/check-package-size.mjs
…er merging main Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
…ndle Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
…/reporting-subscription-runtime
…cription tests Main adopted 3.3.0-beta.2, which no longer ships the beta.1 bundle and defines the fields settled after beta.1 (standard_dimensions, inactive_intervals, prior_versions[].configuration, previous_timezone, per-offering entries), so the release gate now emits them to beta.2 callers. inactive in coverage stays gated until beta.3. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
…reporting-subscription-consumer
…'s beta.2 adoption Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
…/reporting-subscription-ledger # Conflicts: # scripts/check-package-size.mjs
There was a problem hiding this comment.
Ladon verdict: Approve
Approve — clean pass on the AdCP 3.3.0-beta.1→beta.2 adoption.
Checked:
- Regenerated type/wire artifacts + version-string bumps (generated/trivial).
3.3.0-beta.2commercial-terms semantic overrides and the signalsSIGNAL_NOT_FOUND→REFERENCE_NOT_FOUNDconvention, consistent across docstring/example/skill.- Typed
RequestValidationError/isPreDispatchErrormarker (code='VALIDATION_ERROR' inherited from ValidationError;dispatched:falseat every pre-send gate; storyboard runner'scaughtErrormarker check in scope). - ESM envelope-status loader binding (#3529 — no circular static import; cache cleared on loader swap).
- Largest non-generated file
src/lib/v2/projection/creative-delivery.ts:reconcileLegacyAssignmentRefsper-axis merge with independent-set conflict detection and fail-closed on unparseable size/duration constraints is sound;packageSizeAcceptorstated-axis short-circuit is deliberate and locally documented. - Changesets present and typed correctly for the beta pre-mode train.
No critical/high/medium findings. high_risk false, gated_paths false, no author-team gate. Prior decision was approve; delta remains clean. Row 9 → approve.
Note: review_decision is REVIEW_REQUIRED, but since gated_paths is false, row 2 does not apply.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
…/reporting-subscription-runtime
…reporting-subscription-consumer
…/reporting-subscription-ledger
|
Ladon cannot review this PR until merge conflicts are resolved. |
…bscription-coverage Brings in #3548. The packed-byte cap keeps the higher of main's and this branch's. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
…/reporting-subscription-runtime # Conflicts: # scripts/check-package-size.mjs
…reporting-subscription-consumer # Conflicts: # scripts/check-package-size.mjs
…/reporting-subscription-ledger # Conflicts: # scripts/check-package-size.mjs
There was a problem hiding this comment.
Ladon verdict: Approve
Approve — clean subsequent pass, no blocking or medium findings.
This is a follow-up pass to a prior approve. The delta is 67 lines across 4 files, entirely CI/test-only:
scripts/check-package-size.mjs: tarball budget bump with a measured rationale (26,369,089 bytes after #3541 vs 26,520,000 cap).- A documentary empty-frontmatter changeset.
- A line-collapse in
reporting-subscription-coverage.test.js. pre-dispatch-errors.test.js: swaps a retired hardcoded3.3.0-beta.1pin forADCP_VERSION. The release/feature-gate test still assertsProtocolFeatureUnsupportedErrorwithdispatched:falseagainst a seller advertising only3.3-beta.0, so coverage holds and is forward-safe.
No src/lib or bin changes, so no changeset is required. Decision-table check: no critical/high/medium findings (row 1, 4-6, 8 don't fire); gated_paths is false (row 2 n/a); high_risk is false (rows 3/5 n/a); no no-auto-approve team match (row 7 n/a); prior decision was approve (row 6 n/a). Falls through to row 9 → approve.
A sub-daily billing_cycle was routed to the local sub-daily calendar, which aligns to local midnight and ignores period_anchor, so every boundary was off by the anchor's time of day. adcontextprotocol/adcp#8622 makes a sub-daily billing_cycle invalid; refuse it. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
…/reporting-subscription-runtime
…nt_configs A later write that merely omitted replace_account_configs cleared both the applied marker and a committed-but-unconfirmed replacement, so a failed host hook was silently abandoned. An omitted flag now leaves both untouched; an explicit false clears them, so a later true applies again. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
…t owed period end - An open action_required exception now takes the host's current pending_action (url, message, reason) when it changes, keeps its from, and notifies principal.changed. It used to keep the first action forever. - accounts_unauthorized last_owed_period_end takes the latest frozen period_end. Frozen periods are not stored in end order, so the last entry could under-state the window. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
…reporting-subscription-consumer
…/reporting-subscription-ledger
There was a problem hiding this comment.
Ladon verdict: Approve
Approve — subsequent pass on delta (229 lines, 6 files); prior pass was clean and approved.
What I checked:
- Decision table top-down: no critical/high findings (row 1 n/a); gated_paths is false (row 2 n/a despite review_decision REVIEW_REQUIRED — row 2 only fires when gated_paths is true); high_risk is false (rows 3/5 n/a); no medium findings so rows 4/8 n/a; prior decision was
approveso sticky row 6 n/a; no no-auto-approve team match (row 7 n/a). Falls through to row 9 → approve. - Reviewer surfaced no findings. Three defensive fixes reviewed as sound and tested: calendar.ts fail-closed refusal of sub-daily billing_cycle (adcp#8622); engine.ts latestPeriodEnd now scans for max period_end instead of trusting last-appended; in-place refresh of open action_required exclusion's pending_action with canonicalize ?? null guard; server replace_account_configs reset narrowed from !== true to === false so an omitted flag no longer wipes a failed-hook pending retry.
- Changesets present (4 reporting-subscription changeset files) covering the src/lib/** changes — changeset-vs-wire-impact satisfied.
- No witness-not-translator concerns; changes are defensive/fail-closed, not fabrication.
No blocking or medium findings. Clean net-positive iteration on an already-clean PR.
The merge-base changed after approval.
Fourth of the series for #3504, and the first of two stacked PRs that write subscription obligations into the reporting ledger. It stacks on #3509, so it contains the commits of #3505, #3508 and #3509. Review only
feat(reporting): hold subscription obligations in the reporting ledger(a74b552). It targetsmainbecause CI runs only for PRs intomain. The follow-up PR wires the service to the engine.The engine already computes the seller's owed set, but nothing wrote it into the ledger, so the producer never executed subscription obligations. This PR makes the ledger and the PostgreSQL store hold them, and adds a planner API.
What ships
Identity
There is one ledger generation per (account, owning principal,
subscription_id,subscription_version, resolvedoffering_id).delivery_config_idis thesubscription_idanddelivery_config_versionis thesubscription_version, asget-reporting-status-response.jsonsubscription_coveragerequires.ReportingLedgerConfigurationV1.subscriptionis an immutable block in the fingerprint:{ tenantId, principalId, subscriptionId, offeringId, ownership: 'owed_set' }. Obligations copy it, so ownership can be checked from the obligation alone.configurationIddigests the owner and offering as well. Account generations keep exactly today's id and fingerprint (tested), and so do their rows.installConfigurationrefuses asubscriptionblock; subscription generations go only through the planner.Planner API
producer.planSubscriptionObligations({ account_id, principal, subscriptionId, configurations, obligations, owedThrough, now? }):ReportingConfigurationImmutableError.store.putObligation. Each one carries:media_buy_idsfrozen at itsscope_resolved_at(the period end)periodOrdinal = floor(period_start_ms / 1000)expected_at= period end + the offering'sdelivery_slaowedSet.throughon every generation this subscription owns on the account, after the obligations are durable.Obligations are never grid-filled:
planObligationsskips owed-set generations. Retired periods are skipped.Owed-set completeness
owedSetis mutable and outside the fingerprint, the same wayhistoryStartis. It holds:through: the completeness horizonfrom,untilandmediaBuyIds: a monotonic summary of the written obligations, used for relevance andmedia_buy_idsscope matchingThe generation's own
mediaBuyIds/constituentsare empty and never read.evaluateReportingLedgerCoverageV1has an owed-set branch:createSnapshot.throughreturnsowedSetOpen. The handler then reportsscope_closed: falseand keepscoverage_complete: true, because an owed set still being frozen is not missing history (coverage_complete: falsewould forceHISTORY_UNAVAILABLE).The other grid paths use only existing obligations for an owed set:
next_expected_atprojects nothing from the grid.reporting_obligation_idmatches an existing owed obligation by ordinal (new optionalfindObligationByOrdinal, falling back tolistObligations), never a bare grid slot.Visibility
ReportingLedgerSnapshotQueryV1.subscription_principalscopes snapshots to account generations plus the caller's own subscription generations and obligations. With no principal, no subscription generation is visible. It is part of the snapshot query, so cursors and changes checkpoints are bound to it.createReportingStatusHandler,createReportingDeliveryHandlerandcreateSyncReportingStatusHandlertakeresolveSubscriptionPrincipal.get_media_buy_deliveryanswers another principal's revision withREFERENCE_NOT_FOUNDand never falls through to the legacy reader.offering_idis emitted on subscription obligations to callers served 3.3. It is in 3.3.0-beta.1'sreporting-obligation.json.Store contract and PostgreSQL
ReportingLedgerStore.recordOwedSetProgress(monotonic merge under the account fence) andfindObligationByOrdinal. The producer refuses to plan into a store withoutrecordOwedSetProgress.REPORTING_LEDGER_MIGRATIONchanges the generation key:subscription_key TEXT NOT NULL DEFAULT ''under a catalog guard. The key isreportingLedgerSubscriptionKeyV1: a digest of owner and offering, empty for account generations.adcp_reporting_configurations_generation (account_id, delivery_config_id, delivery_config_version, subscription_key)before dropping the published three-column constraint.DO $$block finds that constraint inpg_constraintby its columns, not by name.subscription_key = ''.data->'subscription'.EXISTSinstead of a join, since several visible generations can share an (id, version). For account generations the result is the same, because the join matched at most one row.Tests
test/lib/reporting-subscription-ledger.test.js(memory store):owedThroughcompleteness: scope open, then closed, and never regressingsubscription_id: generations, snapshots, revision reads, and a leaky-store refusalmedia_buy_idsper period, and media-buy scope matchingpackages/reporting-storage/test/reporting-subscription-ledger-pg.test.js, in the reporting-storage parallel group that CI runs withREPORTING_LEDGER_PG_URL:findObligationByOrdinalSpec ambiguities
scope.delivery_config_generationsitems are(delivery_config_id, delivery_config_version, feed_purpose)withuniqueItems. Every offering one subscription version resolves shares the selector'sfeed_purpose, so per-offering generations collapse into one wire entry. Obligations tell them apart byoffering_id.(delivery_config_id, delivery_config_version, report_definition_id, period)cannot tell apart two offerings of one version that share a report definition and a period. Ingest accepts the status against any matching visible generation.next_expected_atin a complete summary "MUST" name the next scheduled period start. An owed set's future periods depend on buys the ledger cannot see, so owed-set generations contribute none.scope_closed: falseand leavecoverage_completetrue.Deviations from the brief
data->'subscription'rather than adding a column besidesubscription_key.subscription_idexplicitly. That way a cycle with no new obligations still advances the horizon of existing generations.owedSetalso carriesfrom,untilandmediaBuyIds. Relevance andmedia_buy_idsscope checks need them. All of them only widen.account_timezone, sub-daily) and stores the offering's schedule identity verbatim.Local checks
typecheck,typecheck:reporting-storage,lint:boundaries,check:package-sizeand Prettier pass. The packed budget is +60 KB with a comment; no module files were added.reporting-history-pgand most ofreporting-status-ingest-pgpass against PGlite locally. CI runs them on PostgreSQL 16.Update:
main's beta release (#3521) changedscripts/check-package-size.mjs, which conflicted with the stack. I mergedorigin/mainintobokelley/reporting-subscription-ledgerand carried that merge up through the stacked branches. The only conflict was the file-count budget, and I resolved it by keeping both sides' entries. The merge commits change nothing else.Refs #3504
🤖 Generated with Claude Code