BC5 readiness: pairwise BC4↔BC5 + check-bc5-compat orchestrator + scheduled CI

Merged
JE
4mo ago
+1977-12

Summary

Closes the BC5-readiness canary loop: PRs 1–3 built the per-backend live capture (TS) and cross-language decode (Ruby/Python/Go/Kotlin) infrastructure. PR 4 adds the pairwise BC4↔BC5 comparison that catches the additive-only invariant — and the orchestrator + scheduled CI that runs the whole pipeline end-to-end on a daily cron.

Stacked on #301 (PR 3 — cross-language wire-replay decoders). Once #301 merges, this PR retargets main.

Why pairwise

Per-backend schema validation alone can't detect a class of regression: with every new BC5 field marked optional, a case where BC4 emits memories: [items] and BC5 emits memories: [] passes each backend's schema independently — yet that's exactly the additive-only invariant the canary should catch. This is not hypothetical: BC5 ships precisely this divergence — now codified as documented contract (see below).

The canonical canary rule lives on GetMyNotifications. The intended invariant: BC5 memories[] should remain a superset of BC4's. But BC5 ships json.memories [] while BC4 (the four branch) still populates it — and bc3 has settled this as a permanent, documented contract divergence: doc/api/sections/my_notifications.md (bc3 #11628) codifies memories as an always-empty placeholder superseded by bubble_ups, and the once-planned alias (json.memories @bubble_ups, bc3 #10947) never shipped — #10947 is closed unmerged. So the pairwiseSupersetArray: ["memories"] rule stays as the encoded additive-only invariant, permanently waived by the pairwiseDeltaAllowed: ["memories"] entry — the machine-readable record of the accepted BC4→BC5 subtractive delta, tracked in spec/api-gaps/memories-emptied-regression.md and indexed by the public compatibility report. Retire the waiver only if BC4 empties memories too (the superset rule then passes clean) or BC5's documented contract changes.

What's in this PR

  • conformance/schema.json — pairwiseAssertions[] with four rule types: pairwiseSupersetArray, pairwiseSupersetKeys, pairwiseEqual, pairwiseDeltaAllowed (with required reason so a future public compatibility report can index accepted divergences).
  • conformance/tests/live-my-surface.json — the memories SupersetArray rule + a top-level SupersetKeys rule on GetMyNotifications.
  • scripts/compare-canary-runs.sh — applies pairwise rules to a pair of snapshot directories. Exit 0 clean / 1 violation / 2 operator error.
  • Makefile — make conformance-live (one backend's capture + 4 replays) and make check-bc5-compat (BC4 pass + BC5 pass + pairwise). Both opt-in; not in make check.
  • .github/workflows/live-canary.yml — nightly cron + workflow_dispatch, gated on repo secrets (no-ops with a log message when missing rather than failing the run). Uploads snapshots as a 14-day artifact so failures can be inspected post-hoc without rerunning.
  • CONTRIBUTING.md — new "Pairwise BC4↔BC5 comparison", "Orchestrator", and "Scheduled CI" subsections under "Live canary".

Path syntax (dotted identifiers on each snapshot)

  • "" (empty string) addresses the body root.
  • foo.bar defaults to pages[0].body.foo.bar — the common single-page case.
  • pages[N].body.X addresses a specific page.
  • pages[*].body.X aggregates across pages into a list (each page's value becomes one element; useful when you want a per-page count, not a sum of inner lengths).

Test plan

  • jq empty conformance/schema.json — clean JSON
  • jq empty conformance/tests/live-my-surface.json — clean JSON
  • bash -n scripts/compare-canary-runs.sh — shell syntax clean
  • Synthetic-fixture test: pairwiseSupersetArray flags BC5 memories shorter than BC4
  • Synthetic-fixture test: pairwiseSupersetKeys flags BC5 missing a top-level key BC4 has
  • Synthetic-fixture test: pairwiseEqual flags value divergence
  • Synthetic-fixture test: pairwiseDeltaAllowed waives a flagged path
  • Synthetic-fixture test: pages[*].body aggregation collects per-page values
  • make -n check-bc5-compat resolves correctly
  • actionlint .github/workflows/live-canary.yml clean
  • zizmor .github/workflows/live-canary.yml clean
  • make validate-api-gaps clean
  • make check-bucket-flat-parity clean
  • Real-backend run — requires BASECAMP_TOKEN/ACCOUNT_ID/BC5_HOST; CI will be the first opportunity once secrets are configured.

Operational requirement

Pairwise rules assume identical account state across the BC4 and BC5 runs. The same project list, same notifications, etc. Without that, naturally-drifting collections (unreads, etc.) will false-fail rules. CONTRIBUTING.md calls this out explicitly; the canary needs a dedicated test account with stable, equivalent fixtures replicated to each backend before scheduled CI can pass meaningfully.

Sequencing

After this lands, the BC5-readiness canary infrastructure is feature-complete (PRs 1–4). Remaining BC5 readiness work:

  • PR 5 — scripts/detect-api-gaps.sh + weekly cron workflow (api-gap detection tooling; validation already shipped in PR 1).
  • PR 6 — Go wrapper forward-compat audit + drift check (filed separately; unblocks basecamp-cli Phase 1).
  • PR 7+ — BC3 contract-drift handoff passes (5 passes targeting main).

Summary by cubic

Adds pairwise BC4↔BC5 comparison with a check-bc5-compat orchestrator, nightly CI, and a hardened compare script + Makefile backed by a regression harness. The canonical memories rule stays encoded and is permanently waived via pairwiseDeltaAllowed to reflect BC5’s documented always‑empty memories; violation output redacts live values, path grammar is strictly validated, and pages[*] compares item totals.

  • New Features

    • conformance/schema.json: pairwiseAssertions[] with pairwiseSupersetArray, pairwiseSupersetKeys, pairwiseEqual, pairwiseDeltaAllowed; paths require at least one entry; waivers require non‑empty reason.
    • Orchestrator: make conformance-live and make check-bc5-compat; .github/workflows/live-canary.yml (nightly + manual, gated on secrets, defaults BASECAMP_HOST to https://3.basecampapi.com, uploads decode‑only artifacts; excludes wire/).
    • conformance/tests/live-my-surface.json: GetMyNotifications carries top‑level pairwiseSupersetKeys and a SupersetArray rule on memories, permanently waived via pairwiseDeltaAllowed (BC5’s documented always‑empty memories).
    • Regression suite: make check-compare-canary runs scripts/test-compare-canary-runs.sh (bash ≥ 4.4, jq required; uses portable grep -E on BSD/macOS).
  • Bug Fixes

    • Compare script: exact TS snapshot filename mapping; missing snapshots hard‑fail (exit 2); validates snapshot shape (including per‑page key types) and recorded operation; strict path grammar (only dotted segments or leading pages[N]/pages[*] into .body; no hyphens or jq punctuation; rejects bare [] streams and non‑leading [*]); shorthand paths are forbidden once either capture paginates; pages[N] must exist on both; pages[*] arrays compare total item counts; pairwiseSupersetKeys rejects non‑object targets and does not accept pages[*]; pairwiseEqual uses deep equality and fully redacts live values in messages.
    • Rule/waiver validation: tests file must be a top‑level array; reject unknown rule types up‑front (before waiver skips); rule paths must be non‑empty arrays of strings; waivers require non‑empty reason and non‑empty paths; waiver paths validated like enforcing paths (waivers do not bypass path checks).
    • Makefile/CI/docs: absolutizes LIVE_RECORD_DIR; safe cleanup with segment‑aware .. checks, checkout‑ancestor refusal, full trailing‑slash strip, refusal when the canonicalized path is the filesystem root, and rm -rf -- on the original path; GNU make 3.81‑safe env defaults; fast env preflight; check-compare-canary wired into make check; CI artifacts upload decode results only and exclude raw wire/.