Add the UK national calibration step over ledger-backed target references - #729
Add the UK national calibration step over ledger-backed target references#729MaxGhenis wants to merge 4 commits into
Conversation
051c9ab to
7ff3f16
Compare
…nces Part of #623 and #701: a named national stage that resolves activated references against pinned chronicle facts (any unresolvable activated reference aborts the build), builds the benefit-unit target matrix, and calibrates household weights through microcosm-calibrate's public front door. Activates the UC caseload and UC-in-cap expenditure references at period 2025. Post-calibration aggregate scalers stay out of scope per the open adjudication on #623.
Rebasing over merged #727 (and #730 beneath it): main's TestUnevidencedArms now enumerates the closed set of gates that report evidence_absent when the battery runs unarmed, so the new uk_calibration_reference_coverage gate joins that set. Also squares the indentation of the earlier enumeration update in the national-build terminal-batch test. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
e077f5d to
9dcc83b
Compare
Adding uk_calibration_reference_coverage to uk/gates.json moves the three vintage pins (policy sha256, gates-manifest sha256, spec fingerprint) and the entry-gates mirror in the data contract, plus the schema-3-style local copies in the data shard's contract tests. The new entry carries no legacy detail schema and contributes no evidence digest, so the legacy-name and evidence-id mirrors are unchanged; the all-passing fixture mirrors the evaluator's activated/resolved/matrix detail block. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
The calibration stage exposed checkpoint_metadata but no resume_from_checkpoint, so a resumed build left manifest None, the evidence getter handed the coverage gate an empty mapping, and the release-blocking uk_calibration_reference_coverage entry failed closed on a KeyError despite a completed calibration checkpoint (the driver sidecar wrote null diagnostics). Mirror the retained-leaves and SPI restoration precedents: record the output frame's content identity in the checkpoint record, and rehydrate manifest/diagnostics on resume with fail-closed validation of the three coverage counts and a drifted-record refusal. Tests cover the JSON round-trip and its refusals, the resumed evidence feeding the real coverage evaluator, and an end-to-end crash-resume build asserting the gate passes without re-executing calibration. The e2e cleanup stage drops the stage's prepared scratch column before the staging write — the pandas staging writer refuses "/" in column names, a latent issue for real armed builds recorded on the PR. Implemented via Codex (gpt-5.4) from the reviewed plan. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Adversarial review of the rebased branch: findings and dispositionsA Codex adversarial review ran against this branch after the rebase onto post-#727 main (all findings independently reproduced before being accepted). Disposition of each: Fixed in this PR (6c8a95a)3. Checkpoint resume dropped calibration evidence. Arriving with the stacked #622-completion PR2. Benunit-grain references cannot compile against household weights. 1. The 2025 UC caseload activation binds the December stock, not the intended basis. With chronicle#184's monthly facts now landed, Discovered while implementing the resume fix (needs an owner)4. Prepared scratch columns crash the real staging writer. The stage's prepared measure columns are slash-named ( Rebase housekeeping already on the branch
🤖 Generated with Claude Code |
Summary
The national calibrate step scoped in #623, stacked on #727 (base branch; the first commit here is tree-identical to its head). Part of #623 and #701 — the post-calibration aggregate-scaler adjudication (2026-08-14 comment) stays open and out of scope: no incumbent scalers are ported.
uk_runtime/national_calibration.py: resolves activated references fromuk/target_references.jsonagainst the pinned chronicle facts; an activated reference that cannot compile aborts the build (the policyengine-uk-data#456 silent-drop class is impossible by construction). Builds the benefit-unit-grain target matrix per the reference declarations and calibrates household weights viamicrocosm.calibrate.calibrate()(public API only).dwp.uc.households(caseload, sum of benefit units withuniversal_credit.amount > 0) andobr.universal_credit_in_cap(expenditure), both period 2025 under the resolver's per-reference resolve-at-or-before semantics. Facts: chronicle#184 (fixture-backed here; live resolution needs the released chronicle bundle carrying Add proximal L1 solver path #184 — stated dependency).uk/gates.json).tools/build_uk_national_dataset.pygrows an opt-in calibration flag + diagnostics JSON output; the staging seam's behaviour without the flag is unchanged.No dataset was built; running this on the real staging H5 is a later, gated act. Refs: #707, #727, chronicle#184, policyengine-uk-data#452.
🤖 Generated with Claude Code