Skip to content

test(compliance): canonical reporting-subscription coverage vectors and reference model - #8616

Merged
bokelley merged 4 commits into
mainfrom
bokelley/reporting-coverage-vectors
Oct 30, 2026
Merged

bokelley merged 4 commits into
mainfrom
bokelley/reporting-coverage-vectors

Conversation

@bokelley

@bokelley bokelley commented Oct 30, 2026 •

Copy link
Copy Markdown
Contributor

Summary

This PR adds a canonical, SDK-independent conformance foundation for AdCP 3.3 reporting-subscription coverage (experimental media_buy.reporting_subscriptions). It follows the protocol expert review: canonical vectors in the spec repo, an independent reference model, and property tests.

  • Vectors. static/compliance/source/test-vectors/reporting-subscriptions/ holds vectors.json (113 cases), case.schema.json, and a README. It is registered in docs/reference/test-vectors, and build:compliance copies it to dist/compliance like every other set.
    • Ported cases. 81 cases come from the feat(reporting): buyer-computable coverage for reporting subscriptions (#3504, 1/3) adcp-client#3505 parity table at 2ad906d8. I re-derived every expected row from the spec text. Each case has spec_refs citations.
    • New cases (32):
      • Midnight DST gaps and folds in America/Havana and Africa/Cairo, alongside the existing Santiago cases.
      • Australia/Lord_Howe's 30-minute DST, hourly and half-hourly.
      • Asia/Kathmandu sub-daily periods.
      • 31st-anchor month-end clamps, including P3M.
      • Weeks: P7D under utc and account_timezone, and P1W, which the pattern refuses.
      • P1Y calendar years, and utc PT7H counted from the 1970 epoch.
      • Compound changes at one instant: reactivation, deactivation, or revocation together with a new version.
      • Grant chains of four, including a re-grant exactly at unauthorized_at + status_retention_days.
      • A max_accounts capacity exception per offering.
      • Fractional seconds and non-Z offsets.
      • An empty flight later extended.
      • The confirmation period, including confirmed_at 1 ms before a boundary, exactly on one, and after the stop.
      • Per-product resolution, and the remaining input errors.
    • tzdata. The vectors pin IANA tzdata 2026f, recorded with the tarball's SHA-512. Dates were chosen so releases 2026b through 2026f give identical rows; I checked this by running the model on both the 2026b and 2026f sources. For example, Cuba's fall-back is tested on 2025-11-02 because 2026f removed the 2026-11-01 one.
  • Frozen vocabularies (DX plan slice X1). Both SDKs use them verbatim.
    • error-codes.json has 14 codes, following the DX plan's §2.12 table. Each has recovery (transient, correctable, or terminal) and dispatched (false, absent, or not_applicable), plus the fix the message ends with and the TS and Python classes. Coverage errors split into COVERAGE_INPUT_INCOMPLETE, COVERAGE_INPUT_INVALID, and COVERAGE_BUDGET_EXCEEDED, each with a frozen detail. A case's expected_error is now {code, detail}.
    • reason-codes.json has 20 reasons, following §2.5. It fixes the rule order (scope … timezone) and defines each rule and reason precisely. A period takes the reason of the first rule that rejects it, then period_not_ended or an owed* variant.
    • case.schema.json carries both vocabularies. Tests check them against:
      • the case schema;
      • the wire ReportingSubscriptionExclusionReason and gaps[].reason enums;
      • every CoverageInputError the reference model can raise.
  • Reference model. scripts/reference/reporting-coverage/ enumerates every period of every schedule in play. The owed set is the intersection of one predicate per clause: cutover ownership, authority chains, confirmed_at, the flight at scope_resolved_at, exceptions, and now.
    • Time zone stack. tz.cjs evaluates the zic source lines of the pinned release itself; tzdata.json is extracted by extract-tzdata.cjs after a SHA-512 check. It uses no ICU, Intl, Temporal, TZif files, or host zoneinfo. The TS SDK uses Intl/ICU and Python uses zoneinfo/TZif, so this shares no time zone code or compiled data with either. Temporal isn't a dependency here.
    • zic check. The evaluator matches zic(8) and zdump(8) for every pinned zone from 1900 to 2100. Those transitions for 1970 to 2040 are committed and asserted in CI.
  • Tests.
    • tests/reporting-subscription-coverage-vectors.test.cjs checks that:
      • every case validates against case.schema.json;
      • every wire object in each input validates against the AdCP schemas, with unknown values of x-extensible enums allowed;
      • each spec_refs file exists;
      • non_wire_inputs matches the fields the case actually uses;
      • the model reproduces every case;
      • the zic transitions match;
      • the host's Intl agrees with the pin around every case, where a mismatch fails only when the host runs the pinned release.
    • tests/reporting-subscription-coverage-properties.test.cjs runs seeded property tests. fast-check is only a transitive dependency, so it uses a mulberry32 generator. Properties:
      • exceptions only remove periods;
      • nothing is owed twice;
      • the cutover stretch is shorter than one incoming period, and empty when the incoming duration divides the outgoing one;
      • the owed set is prefix-stable as now advances;
      • an extension never adds an elapsed period;
      • backfill, and confirming earlier, only add periods;
      • calendar invariants: tiling, local midnights, wall-clock multiples, hours per local day, PT24H equals P1D where midnight never moves, month-end clamping, and Thursday weeks.
    • Both run in test:schemas.

Where the TS table disagrees with the re-derivation

  • numeric offset timezone is refused. The TS table expects an error for account.timezone: "+05:00", but its offering is utc-aligned. Under period_generation, a utc schedule never reads the account timezone, so its periods are derivable, and the refusal doesn't follow from the coverage rule or iana_timezone. The canonical case uses an account_timezone offering instead; see changed_from_origin.
  • Billing and managed offerings in six cases don't validate against reporting-delivery-offering.json. They lack method.provider, use formats where the schema has method.format, and the consumer_receipt offerings lack the canonicalization_* fields. The canonical cases complete them. Coverage is unchanged.

The other 80 expected rows match my derivation.

Running the #3505 TS code on the new cases turns up two SDK divergences, which aren't table errors:

  • max-accounts-capacity-per-offering: the TS code ignores excluded[].offering_id, so it drops off_a's 11-07 period.
  • p1w-is-not-a-schedule-duration: it returns [] instead of refusing the input.

Vocabulary decisions to confirm

  • COVERAGE_INPUT_INVALID is added. The DX plan has only COVERAGE_INPUT_INCOMPLETE, but an invalid zone or duration isn't incomplete input.
  • Overlapping reasons are resolved by rule order:
    • excluded:excluded_by_buyer sits under the scope rule, because exclude_account_ids is scope.
    • before_coverage_start covers the first chain only; periods between chains are not_authorized.
    • cutover_stretch also covers timezone-rule rejections, since the frozen list has no separate code for them.
    • owed_under_other_version is defined by comparing the period end with the side's handoff E.
  • Per-period reasons aren't emitted yet. The reference model doesn't produce them, and the vectors carry no expected traces. That is X2.

Spec ambiguities

  1. Sub-daily periods when local midnight doesn't exist. period_generation says "a wall time that does not exist yields no boundary". In Havana, Santiago, or Cairo on a spring-forward day, PT2H, PT3H, or PT24H then has no boundary at the day's advanced start. So PT24H is not "exactly like P1D" there (Havana's 2026-03-07 PT24H period would be 47 h), and P1D and PT2H don't nest. The vectors pin only PT1H there, where both readings agree.
  2. Sub-daily periods in 30-minute DST zones. Lord Howe takes the literal "whole multiple of the duration after local midnight, wall-clock" reading. That gives 90-minute periods on transition days, not hours elapsed from midnight. The vectors pin it.
  3. Two cutovers inside one period (TS two-cutovers-inside-one-period). The cutover text doesn't define E when the outgoing side owes nothing before T. The model and the TS table carry the outgoing side's own start forward, which is the reading under which "nothing is owed twice" holds.
  4. Reactivation after a schedule change made while inactive. Reactivation is a fresh start at the first boundary at or after reactivated_at, not a cutover. So after a version change to a misaligned schedule during the inactive interval, the first new period can overlap the last one owed before deactivation. Example: a New York day ending 05:00Z and a UTC day starting 00:00Z are both owed. No vector pins this. The property test leaves inactive intervals out of its single-offering overlap check.
  5. "Empty when both schedules share boundaries (nested durations)." This holds only when the incoming duration divides the outgoing one. Fine to coarse, for example hourly to daily, leaves a non-empty stretch.
  6. UTC aliases. period_timezone matches a utc offering only for "UTC or Etc/UTC". IANA links such as Etc/Universal and Zulu, and GMT, are excluded by the literal text. The vectors pin GMT as non-matching, as the TS table does.
  7. Per-product selection. The vectors read "resolves the selector separately for ... each buy's products" as resolving per package and taking the union. A buy can then owe two offerings under finest.
  8. Sub-daily billing_cycle ignores the anchor. It counts from local midnight, so the anchor's time of day has no effect. No vector.
  9. P1W. The duration pattern has no W, and utc P7D weeks start on Thursday from the 1970 origin. Monday weeks need a billing_cycle anchor.
  10. status_retention_days as 24-hour days. The model treats them that way; the spec doesn't say whether they are 24-hour or civil days.

Test plan

  • node --test tests/reporting-subscription-coverage-vectors.test.cjs tests/reporting-subscription-coverage-properties.test.cjs tests/reporting-subscriptions.test.cjs
  • node scripts/lint-conformance-doc-freshness.cjs, test:compliance-source-authority, test:compliance-packaged-refs, changeset scope check
  • Time zone evaluator checked against zic/zdump for 1900–2100; model rerun on tzdata 2026b gives identical rows
  • CI

🤖 Generated with Claude Code

@aao-secretariat

Copy link
Copy Markdown
Contributor

Ladon cannot review this PR until merge conflicts are resolved.

…nd reference model

Adds the SDK-independent conformance foundation for AdCP 3.3
reporting-subscription coverage (experimental media_buy.reporting_subscriptions):

- static/compliance/source/test-vectors/reporting-subscriptions/: 113 cases
  with case.schema.json, pinned to IANA tzdata 2026f. 81 are ported from the
  adcp-client#3505 parity table and re-derived from the spec text. 32 are new:
  midnight DST in Santiago, Havana, and Cairo; Lord Howe's 30-minute DST;
  Kathmandu sub-daily; month-end clamps; P7D, P1W, and P1Y; compound changes
  at one instant; four-grant chains; max_accounts per offering; fractional
  seconds and offsets; empty flights; the confirmation period.
- scripts/reference/reporting-coverage/: a brute-force reference model that
  enumerates every period and intersects one predicate per clause. Its time
  zone evaluator reads the pinned zic source itself and is checked against
  zic output; it uses no ICU, Intl, or zoneinfo.
- tests: the model reproduces every vector; each case's wire objects validate
  against the AdCP schemas. Seeded property tests cover exception monotonicity,
  nothing owed twice, cutover stretch bounds, prefix stability, no retroactive
  extension, and calendar invariants.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
@bokelley
bokelley force-pushed the bokelley/reporting-coverage-vectors branch from 9da247f to 0236d31 Compare October 30, 2026 16:49
aao-secretariat[bot]
aao-secretariat Bot previously approved these changes Oct 30, 2026

@aao-secretariat aao-secretariat Bot 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.

Ladon verdict: Approve

Approve — additive, experimental reporting-subscription coverage test vectors plus an independent brute-force reference model (coverage/calendar/tz scripts), with no edits to static/schemas/source/**.

What I checked:

  • No wire-shape changes: no schema source edits, so schema↔docs coherence and oneOf-audit gates don't trigger.
  • Changeset present (patch, non-breaking, in-scope compliance surface); not Breaking-class, not 3.1.x.
  • No released-artifact mutations (dist/** untouched).
  • Reference-model correctness spot-checked: coverage.cjs owed/authorized predicates and boundary handling cite spec; tz.cjs resolveWall fold/gap handling matches period_generation; baseline expected rows consistent with stated rule; property tests assert real invariants.
  • high_risk is true only via docs/reference/test-vectors/index.mdx (modified), with no medium-or-higher finding on that file, so the modification is presumed safe (no escalation on the flag alone).
  • extract-tzdata.cjs execFileSync lacks a timeout but is a manual dev-only regeneration tool, not a production/worker path — out of scope.

No no-auto-approve team match, gated_paths false. No blocking or medium findings. Falls through to row 9.

@aao-secretariat aao-secretariat Bot 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.

Ladon verdict: Approve

Approve.

The delta since the prior approve is a single file: scripts/reference/reporting-coverage/extract-tzdata.cjs. It replaces a TOCTOU existsSync/readFileSync read of tzdata.json with a hoisted readPrevious() helper that returns null only on ENOENT and rethrows all other errors — so malformed JSON, EISDIR, and permission failures now surface instead of being silently masked. This is a clean refactor with correct error handling in developer-only reference tooling (not published protocol surface).

Checked: changeset present (.changeset/reporting-subscription-coverage-vectors.md); no static/schemas/source/** changes so no schema↔docs coherence or oneOf-discriminator concerns; no dist/** artifact modifications; no hand-edited package.json version; no breaking-class protocol change. The high-risk flag fires only on docs/reference/test-vectors/index.mdx (modified), but the reviewer surfaced no medium-or-higher concerns on it, so the modification is presumed safe.

No critical/high/medium findings. No gated paths, no no-auto-approve team match, no deletions in sensitive paths. Prior decision was approve with no findings; nothing here changes that. Rows 1–8 do not fire → row 9 approve.

aao-secretariat[bot]
aao-secretariat Bot previously approved these changes Oct 30, 2026

@aao-secretariat aao-secretariat Bot 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.

Ladon verdict: Approve

Approve — clean re-review, no blocking or medium findings.

This PR adds experimental reporting-subscription coverage test vectors, a case schema, a docs index row, and a self-contained brute-force reference model (calendar/coverage/tz + zic-cross-checked tzdata) with vector and seeded property tests. All additions are experimental compliance assets.

Checks performed:

  • Changeset present, scoped and typed correctly (patch; additive experimental compliance assets).
  • No edits to static/schemas/source, published schemas, or dist artifacts — release-artifact immutability preserved.
  • case.schema.json oneOf is cleanly discriminated; no oneOf discriminator regression.
  • coverage.cjs owed-period intersection and authority/cutover logic are consistent and test-backed.
  • No package.json version hand-edit.

High-risk flag is true only because docs/reference/test-vectors/index.mdx is modified (adding a docs index row); this is a benign additive modification with no reviewer-found concerns, so the flag does not warrant escalation. gated_paths is false, no no-auto-approve team match, and no critical/high/medium findings. Head SHA matches the prior-approved SHA — net state is clean. Falls through to row 9.

@bokelley
bokelley dismissed stale reviews from aao-secretariat[bot] via c579d63 October 30, 2026 17:11
Adds error-codes.json (SDK error codes with recovery, dispatched, and fix)
and reason-codes.json (why a period is or isn't owed, with the fixed rule
order) beside the coverage vectors. The case schema carries both
vocabularies, and expected_error now gives a frozen COVERAGE_INPUT_* code
and detail. Tests check the vocabularies against the case schema, the wire
exclusion and gap reasons, and every error the reference model raises.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>

@aao-secretariat aao-secretariat Bot 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.

Ladon verdict: Approve

Approve — subsequent review with a clean diff and no findings.

This PR adds a reporting-subscription coverage test-vector suite (new compliance assets, coverage scripts, and tests) plus a modified normative reference page (docs/reference/test-vectors/index.mdx). The delta since the prior approve is a single-line cleanup at scripts/reference/reporting-coverage/coverage.cjs:757, replacing an iteration that destructured an unused schedule binding with side.offerings.keys(). Semantically identical, no behavior change; the second loop at line 783 still uses the binding where needed.

Gate checks:

  • No no-auto-approve team match.
  • gated_paths: false, so row 2 does not fire despite review_decision: REVIEW_REQUIRED.
  • high_risk: true only from docs/reference/test-vectors/index.mdx (modified); no medium-or-higher finding on that file, so rows 4/5 do not fire. No (deleted) reasons (row 3 N/A).
  • Prior decision was approve, so sticky-escalation (row 6) does not apply.
  • No critical/high/medium findings (rows 1, 8 N/A).
  • No released-artifact mutation (changes are under static/compliance/source/**, not dist/**). A changeset is present.

Falls through to row 9 → approve.

@aao-secretariat aao-secretariat Bot 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.

Ladon verdict: Approve

Approve — no blocking or medium findings.

This is a subsequent review on top of a prior clean approve. The only delta is a single-line cleanup in scripts/reference/reporting-coverage/coverage.cjs:757: the floors-computation loop now iterates side.offerings.keys() instead of destructuring [offeringId, schedule], dropping an unused schedule binding. .keys() yields the same offering IDs in insertion order, so behavior is unchanged; the second loop at line 783 correctly retains full entry destructuring since it uses schedule. No semantic change.

Decision-table walk:

  • Rows 1 (critical/high): no findings.
  • Row 2 (gated paths): gated_paths is false — does not fire.
  • Row 3 (deleted high-risk): the high-risk match is docs/reference/test-vectors/index.mdx (modified), not deleted.
  • Row 4 (medium data-loss/schema/infra): no findings.
  • Row 5 (modified high-risk + medium finding): high-risk file is modified but there are zero medium findings — does not fire.
  • Row 6 (sticky escalate): prior decision was approve, not escalate.
  • Row 7 (no-auto-approve team): no team match.
  • Row 8 (3+ medium): zero medium findings.
  • Row 9: approve.

Note: review_decision is REVIEW_REQUIRED, but that only forces escalation when gated_paths is true (row 2), which it is not here. This is a test-vector / coverage-tooling PR (new test vectors, coverage scripts, tests) with a changeset present; no schema source edits, no artifact mutation, no breaking-class wire change. Falls through to row 9.

@aao-secretariat aao-secretariat Bot 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.

Ladon verdict: Approve

Approve — clean, additive compliance-vector addition with no blocking findings.

This PR extracts the coverage error vocabulary into code+detail and adds two frozen vocabulary files (error-codes.json, reason-codes.json) with schema definitions and coherence tests for reporting-subscription coverage. The reviewer verified:

  • calendar.cjs startsWith('missing_') derivation maps all 11 raised details correctly (7 INCOMPLETE, 4 INVALID) against error-codes.json;
  • coverage.cjs null-config guard raises an in-vocabulary detail;
  • the new wire-enum assertions match ReportingSubscriptionExclusionReason and gaps reason enums;
  • case.schema.json reason/rule enums match reason-codes.json order;
  • the changeset is patch, correct for an experimental compliance-vector addition.

No Critical/High/Medium findings.

Decision-table walk: Rows 1 (no critical/high), 2 (gated_paths false), 3 (no deletions), 4/5 (no medium findings), 6 (prior decision was approve, not escalate), 7 (no no-auto-approve team match), 8 (fewer than three medium findings) do not fire. Falls through to row 9 → approve. The high_risk flag is set only via a (modified) docs/reference index file, and with no medium-or-higher finding on it the modification is presumed safe — not escalation-worthy on the flag alone. review_decision: REVIEW_REQUIRED does not block because gated_paths is false and no author/gated-path hard gate applies.

@bokelley
bokelley merged commit 023bbd2 into main Oct 30, 2026
64 checks passed
@bokelley
bokelley deleted the bokelley/reporting-coverage-vectors branch October 30, 2026 18:10
bokelley added a commit that referenced this pull request Oct 31, 2026
… the coverage vectors

Rulings on ambiguities the canonical coverage vectors surfaced (#8616): the
local day start is always a boundary (PT24H equals P1D and days nest in
sub-daily schedules where midnight does not exist); Lord Howe's 90-minute
hour stands; E never precedes the outgoing side's own start; reactivation
resumes after the last period owed before deactivation; UTC aliases are
exactly UTC and Etc/UTC; billing_cycle needs a date component; P7D weeks
start on Thursday; status_retention_days counts 24-hour days. The reference
model and vectors pin each.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
bokelley added a commit that referenced this pull request Oct 31, 2026
… the coverage vectors

Rulings on ambiguities the canonical coverage vectors surfaced (#8616): the
local day start is always a boundary (PT24H equals P1D and days nest in
sub-daily schedules where midnight does not exist); Lord Howe's 90-minute
hour stands; E never precedes the outgoing side's own start; reactivation
resumes after the last period owed before deactivation; UTC aliases are
exactly UTC and Etc/UTC; billing_cycle needs a date component; P7D weeks
start on Thursday; status_retention_days counts 24-hour days. The reference
model and vectors pin each.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
bokelley added a commit that referenced this pull request Oct 31, 2026
… the coverage vectors (#8622)

Rulings on ambiguities the canonical coverage vectors surfaced (#8616): the
local day start is always a boundary (PT24H equals P1D and days nest in
sub-daily schedules where midnight does not exist); Lord Howe's 90-minute
hour stands; E never precedes the outgoing side's own start; reactivation
resumes after the last period owed before deactivation; UTC aliases are
exactly UTC and Etc/UTC; billing_cycle needs a date component; P7D weeks
start on Thursday; status_retention_days counts 24-hour days. The reference
model and vectors pin each.

Co-authored-by: Claude Opus 5.5 (1M context) <[email protected]>
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