Repository navigation
Conversation
Stage 1 of the UK State Pension legal split (d3519) needs two person inputs: state_pension_flat_share (E1, a share of the full weekly rate) and state_pension_addon_weekly_base (E2, weekly pounds of CPI-linked pieces). This adds the pure core that computes them from arrays: a censored exponential share prior drawn at a person_id-keyed uniform, one bisected scale per cell to meet a weighted target or upper bound, and a receipt routed through receipt_counts. No stage is registered and no build output changes. The prior's family and floor are placeholders for the design owner's choice. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Stage 18, state_pension_split, stores policyengine-uk's data-year cap split at s = 1 after the SPI income redraw: it reads the report excluding the age addition, the type and both default inputs from the engine, and writes state_pension_flat_share and state_pension_addon_weekly_base with float32 asserts. A terminal copy-lineage gate checks the split, report, age, gender and months since last birthday within each SPI lineage key, including on the dense graph's geographic copies. Built in a Codex cloud task from the hub's reviewed brief against policyengine-uk d93236f5e1893ae4f9e17255138fb5c9afd1a684; applied here from the harvested patch (sha256 07ec37bb..., tree 9915ceb). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The stage commit regenerated the UK spine parity fixture in a container with policyengine-uk 2.180.2 installed from git. Three of its changes were not the stage's doing. A regeneration at the parent commit, on a fresh host with no new stage, reproduces all three byte for byte with both the locked 2.180.0 and the git engine: - sources/person.csv: 31 months_since_last_birthday values, from the root's floating-point cumulative sums over parsed gross4 weights; - sources/weights.json: two household weights one ulp apart, from the default float parser reading househol.tab; - sources/cgt_asset_type_facts.json: 24 synthetic CGT fact values derived from those root tables. Restore those three files to their committed bytes. Also pin the 59 graph nodes' policyengine-uk numerical dependency to the locked 2.180.0, as a regeneration under the lockfile records it; the stage node and the 36 rewired inputs stay. No CI job runs the fixture's --check, and no test pins these files' bytes; the H2 acceptance test derives the root from frs_raw in-process. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
In a period where basic_state_pension, new_state_pension or additional_state_pension carries an input, policyengine-uk drops the stored split for every person and falls back to its cap split without an error. The stage and uk.full.export.prepare now refuse a person table that stores any of the three. The names live in state_pension_split.py, which the stage kernel already hashes; export.prepare's implementation hash now includes that module too. No source stage or fixture writes these columns, so no build output moves. Engine-free tests cover each name at both points, and the H5 round trip checks that none comes back. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
A note on the gate manifest's room, because this PR adds a gate. It comes from the work on #1815. The room. The UK gate nodes carry the whole gate manifest as one parameter. It has 2,011 characters of room, and the room test fails under 1,024. About 65% of the string is notes. The nodes use the parameter for one thing: they build the manifest again from the package and compare. No reader takes a note from it. The change planned under #1815 carries the manifest without its notes in the parameter, which takes the room to about 86,000 characters. So the room is no reason to shorten a note here. A suggestion: make note edits free. Today an edit to any gate note re-keys much more than the gates:
Notes are prose. It may be worth taking them out of both places: a file of their own outside the solve's fingerprint, and a manifest digest without notes. The cost: the digest is shared gate code, so every country's gate report digests change once, and the signature then no longer covers the notes' text. Is that acceptable? |
Summary
This branch adds stage 1 of the UK State Pension legal split. The UK spine stores two person inputs that policyengine-uk reads at the data year:
state_pension_flat_share(E1) holds a share of the full weekly rate.state_pension_addon_weekly_base(E2) holds weekly pounds of CPI-linked pieces.At this stage every person's share s equals 1, so the stored pair matches the engine's own cap split and moves no figure. A later method commit fits s < 1 per cell; from then on the inputs change results.
The branch holds three parts:
uk_runtime/state_pension_split.py:split_state_pension(...)turns aligned arrays into E1, E2 and a receipt per cell (see the core, further down).state_pension_split, right afterhmrc_spi_income_spine. It reads each person's type, the report net of the age addition and both default inputs from policyengine-uk at the survey year. It checks the cap against the parameter leaf and writes both columns under float32 asserts. Its receipt counts support throughreceipt_counts.uk_state_pension_copy_lineage. Within each SPI lineage key, it checks that the split, the report, age, gender and months since last birthday agree, on the dense graph's geographic copies too.The stage and
uk.full.export.prepareboth refuse a person table that storesbasic_state_pension,new_state_pensionoradditional_state_pension. In a period where any of the three carries an input, policyengine-uk drops a stored split for every person and falls back to its cap split without an error. Export preparation also asserts that the export period equals the data year in the stage's evidence.Landing constraint
Once this branch merges main and CI runs,
engine-uk(3.13 and 3.14),integration-ukand the aggregate check will fail. The locked policyengine-uk 2.180.0 has neither input:engine-ukstops at collection onpolicyengine_uk.utils.state_pension, and the integration smoke run reaches the new stage. Merging waits on three steps:hmrc_uprating_engine_pins.json, whose guard refuses any other installed engine version;uk_spine.json, whose numerical dependencies stay at the locked 2.180.0 until then.A cloud task built the stage and ran its engine tests against policyengine-uk
d93236f5e1893ae4f9e17255138fb5c9afd1a684. All six acceptance cases passed there. Above the cap,additional_state_pensiondiffered from the engine's value only within tolerance.A 2040 row that types NEW
The after-d reform test prints the BASIC man's row in each projected year, and by 2040 that row types NEW. Static ageing, already on main, moves his implied birth to 1955 by 2040 (
birth_instant, policyengine-ukutils/dates.py:136), outside the male rule. Every run then types him NEW, and the split steps aside because his type changed. That's expected.The core
split_state_pension(...)takes aligned arrays and returns E1, E2 and a receipt per cell:person_id, the annual State Pension net of the age addition (R), andcap_weekly, the full weekly rate for the person's type at the data year. It also takes the type (NONE, BASIC or NEW), a cell key the caller builds, the household weight and the source household id. It optionally takes per-cell targets or upper bounds on the weighted CPI-linked total.SharePriorgives each person's share s of U as a censored exponential, s = lower + (1 − lower) × min(1, scale × −log u). The uniform u comes fromstable_identity_uniforms(person_id, seed=0, salt="state_pension_flat_share"), the conventionpip_pointsuses.unidentified. A target outside the reachable range raises.receipt_counts, and a cell underUK_DISCLOSURE_FLOORhas every figure withheld.The stage passes no targets, so every cell takes s = 1, and it stores the engine's own pair.
Open method choices
The code settles these only as placeholders. The design owner rules on each before any stage passes targets in:
lower = 0.5), neither calibrated empirically yet.lower, while a cell with no target takes s = 1.Other changes
contract.pyandtest_contract.py. The stage roster goes from 58 to 59, and every copy ofsource_manifest_sha256follows the newsource_stages.json.receipt_counts.complementary_suppressionmoves out ofpip_pointsunchanged. That moves the implementation hash of every counting stage, so their cached nodes rebuild once; outputs stay the same.uk.full.export.preparetakes the stage's evidence (orspine_provenance) as an input for its data-year assert.Tests
test_state_pension_split.py(Hypothesis properties of the core) andtest_uk_state_pension_split_stage.py(writer asserts at the cap edges, survey year, receipt suppression, copy-lineage gate, export data year and component refusals).tests/engine/uk/test_uk_state_pension_split_stage.py: the stored pair against the engine at d and in projected years, reforms in force at d, a reform starting after d, and positive controls. It needs the policyengine-uk release.ruff format --checkandruff checkpass on the touched files.axiom: n/a: data-build stage that stores engine inputs; the State Pension rules themselves change in PolicyEngine/policyengine-uk#2977
🤖 Generated with Claude Code