Skip to content

Add the release diff for event replays and its issue packets - #161

Draft
MaxGhenis wants to merge 6 commits into
w6/replay-variantsfrom
w6/diff-uk-event-runs
Draft

MaxGhenis wants to merge 6 commits into
w6/replay-variantsfrom
w6/diff-uk-event-runs

Conversation

@MaxGhenis

Copy link
Copy Markdown
Contributor

Stacked on #160. WIP: W6 of the Autumn Budget 2026 CI plan.

What this adds

pipeline/diff_uk_event_runs.py compares two complete replay namespaces (the legacy results/uk/events or a variant's results/uk/replays/<variant_id>). It re-verifies each side's staging, comparison and artifact receipts before reading anything.

It flags at three levels: source row, measure-year total, and PE head. Spec: docs/uk_replay/RELEASE_REPLAY.md, "Release differences".

Flag Raised when
numerical abs(head − base) > max(£1m, 1% × max(abs)), strictly
structural sign reversal, zero crossing (abs ≤ £0.50), artifact schema or construction orientation changed
coverage counterpart, artifact or source row on one side only, in a year both sides support
mapping head variables, channels or definitions changed
support year supported on one side only; only rows that could carry a counterpart; never also coverage
inertness inert in-force construction on one side only
construction executed reform dicts or premise checks changed. A current-law value change is context only.

Flags are investigation prompts. Nothing passes or fails, and the PE/OBR ratio bins appear unchanged, as transitions.

Each flagged (event, measure, year) gets a packet (packets/*.json|md) containing:

  • the OBR source cells;
  • both execution identities and the artifact digests;
  • the executed reform dicts;
  • focused rerun commands for each side;
  • the sources the registry cites;
  • empty minimal_case/statutory_evidence sections for the investigating lane.

The pipeline files no issues. --check re-renders and compares bytes, for CI's no-drift gate.

Invariants (tests/test_uk_event_diff.py)

  • diff(a, a) has no row flags, including on the committed legacy namespace end to end.
  • Swapping sides keeps flag sets and swaps values and delta signs.
  • There is no numerical flag at the threshold and there is one just above it. The threshold is symmetric, and the £1m floor dominates below £100m.
  • A year supported on one side is support, never coverage. Outside-scope rows are never support-flagged.
  • Each measure-year change equals the sum of its head changes (accounting identity).
  • Output bytes are independent of input row order.
  • Each flag type has a minimal synthetic case built with the real artifact, staging and comparison writers.
  • Packets exist for flagged moves and never for support-only rows.
  • An unverifiable side is refused.

Status

  • Tool and tests (17 passing; legacy outputs byte-identical)
  • Independent review
  • First real use, legacy → pe6.2.6_uk2.125.1_policyengine-uk-data-1.58.0: 304 numerical, 15 structural, 34 support flags; no coverage, mapping, inertness or construction flags. That result lands in its own PR with the 6.2.6 namespace.

axiom: n/a: replay comparison tooling in scorecard, no policy encoding.

🤖 Generated with Claude Code

pipeline/diff_uk_event_runs.py compares two complete replay namespaces after
re-verifying each side's staging, comparison and artifact receipts. It
flags, at source-row, measure-year and PE-head level: numerical moves above
max(£1m, 1% of the larger magnitude); sign reversals and zero crossings;
coverage, mapping, support, inertness and construction changes regardless
of size. A year one side cannot support is a support flag, never coverage,
and only on rows that could carry a counterpart. Ratio bins are reported as
transitions. Flags are investigation prompts; nothing passes or fails.

Each flagged (event, measure, year) gets a packet with the OBR source
cells, both execution identities, artifact digests, executed reform
dictionaries, focused rerun commands and the sources the registry cites.
--check re-renders and compares bytes for CI.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@vercel

vercel Bot commented Oct 11, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
policyengine-scorecard Ready Ready Preview Oct 12, 2026 12:40am UTC

Request Review

…ruction

On the first real premise diff (2.89.2 to 2.125.1) every reversal's reform
world, which is current law, moved with current law: the employer-NIC
secondary threshold (96 to 96.153846), the Class 2 small-profits
threshold, float noise in the blended CGT rates. Those were raised as
construction flags, which release qualification proposes to fail on. A
baseline or reform world value change is now a construction flag only
where one side's world overrides that side's current law; otherwise the
move is recorded in current_law_changed context. Premise-check changes
(the CGT annualisation premise) still flag.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
MaxGhenis and others added 4 commits October 11, 2026 20:26
Co-Authored-By: GPT-6.1 Sol (Subfleet lane) <noreply@openai.com>
Co-Authored-By: GPT-6.1 Sol (Subfleet lane) <noreply@openai.com>
After #160, staging checks a manifest's variant against its record in a
variants document, and the diff re-stages each run to revalidate it. The
diff now takes --variants-file (default data/uk/replay_variants.json) and
passes it to staging, so a qualification run can diff a candidate whose
record lives only in its work file. The diff tests build synthetic variants
(several share an id with different data years), so they stand in a record
derived from each manifest; staging's variant checks are tested in
test_uk_replay_variants.py, and a new test checks the file reaches staging.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

This branch was successfully deployed

1 active deployment
Preview — 8700d29a Deployed Oct 12, 2026 by vercel[bot]
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.

1 participant