Repository navigation
feat(reporting): support PT5M reliable reporting periods - #3854
rachitm022 wants to merge 6 commits into
Conversation
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
bokelley
left a comment
There was a problem hiding this comment.
Thanks for this. PT5M support is a big step, and the DST and paging work is careful. A hand review while the bot is down: one blocker, plus a few issues to fix before merge. Line numbers are against the head I reviewed and may have shifted after the branch was updated from main.
Blocker: the seller's sub-day grid is counted from 1970, not from each local day
-
Where:
src/lib/reporting/service/index.ts~2304 anchors onorigin1970 + n·period. The phase scans (service/index.ts~2313 andproducer.ts~2116) check offsets from the anchor or the 400-day horizon, not from the local day. -
Effect: in zones whose 1970 offset isn't a whole multiple of the period, periods start off the local boundary. Probed against our own buyer calendar (
createReportingPeriodCalendarV1):Zone, period This PR (local) Spec/buyer (local) Asia/Singapore PT1H 08:30, 09:30 08:00, 09:00 Asia/Kathmandu PT30M 05:45, 06:15 06:00, 06:30 Africa/Monrovia PT5M 00:04, 00:09 00:00, 00:05 The buyer then reports every period as missing, so the ledger never becomes definitive. The spec says hourly periods start on the local hour in every zone, whatever its 1970 offset. The vector
sub-daily-local-periods-start-on-the-local-hour-asia-singaporein adcp'sreporting-subscriptions/vectors.jsonencodes exactly this. -
Fix: for local sub-day schedules, check that the anchor's local time of day is a multiple of the period, rather than
(anchor − origin1970) % period. Please run the seller grid against the sub-daily vectors.
Issues
- The change-only check can compare against a stale read after a crash (
producer.ts~749). If the process crashes aftercommitRevisionbut beforeupdateObligation, with no suppressed read before it,lastSourceReadis read N−1 while the ledger holds read N. An unchanged re-read then commits a duplicate revision, and content that reverts to N−1 is suppressed, leaving stale data. Suggest takinglatestSuccessfulReadas the newer oflastSourceReadand the latest publication (byobservedAt), plus a crash-after-commit test with no earlier suppressed read. - The UTC sub-day check now depends on the season (
service/index.ts~1956/1977).assertConstantUtcOffsetonly runs for day-length periods, so autc+ PT5M offering pinned to Europe/London validates in December and throws in July. Please keep the constant-offset check for UTC sub-day schedules. - The account-timezone guard is removed with no replacement (
service/index.ts~1243). Owed sub-day periods are no longer checked against the source timezone's grid. Please add a sub-day version of the guard. start_date/end_datenow carry either a date or an instant (inline.ts~41, ~2658), on the stablereporting/sourcesurface. A host that forwards them toget_media_buy_deliverybreaks that schema'sYYYY-MM-DDpattern. Please add explicitstart_time/end_timeinstead.- Semver:
@adcp/sdk/reporting/sourceis a stable subpath, andreportingUtcOffsetsPreservePeriodPhaseV1(source.ts~727) becomes public API there. Sub-day offerings that used to be refused are now accepted, so this should be a minor changeset. Please keep the phase helper internal unless it needs to be public.
Nits
- The producer uses
Date.now()instead of its injected clock, and the sub-day phase check is duplicated in the producer and the service with different scan windows. - The PG test went from 7 rows to 0, which loses the non-empty case.
- Paging is tested at 288 periods but not at 300 (fall-back day).
- Docs note: with the default
maxHistorySlicesPerSourceof 10, a day of backfill takes 29 cycles. One PT5M feed fills the buyer's defaultmaxRecords(100k) in about 85 days, so buyers needchanges_after.
Spec side: we'll add PT5M vectors to adcp: America/New_York spring-forward (276 periods) and fall-back (300), Africa/Monrovia, and Australia/Lord_Howe.
The baseline CI failures (registry types, security audit) are fixed on main. I've updated the branch, so they should clear.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Addressed the review in
The review nits are covered as well: the injected installation clock is reused, schedule validation is shared, the PostgreSQL non-empty notification case is restored, fall-back paging covers 300 periods/600 status records, and the history/paging budgets are documented. Verification completed for the changed surface: build, typecheck, boundary lint, formatting, changeset status, and 268 focused reporting tests all pass. The full local suite reached its slow CLI group with one unrelated child-process test exiting before it produced output under concurrent machine load; CI is now running against this commit. |
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Follow-up Coverage remains complete: the focused producer case keeps the unique 276-period New York spring-forward day; the Monrovia vector covers an ordinary 288-period day; and the paging/zero-row test covers the 300-period New York fall-back day. The service file now passes locally with the same 60-second timeout in 18.7 seconds. |
Summary
Verification
The PostgreSQL notification test requires a database URL and was skipped locally; CI supplies the integration environment.
Notification behavior
This intentionally preserves the current reporting.ledger_changed event for an empty first snapshot. If adcontextprotocol/adcp#9354 lands, the suppression belongs in packages/reporting-storage/src/postgres.ts commitRevision immediately before recordLedgerChanged.
Linear: AI-26996.