Repository navigation
Lock policyengine-uk 2.179.2 and store UC's new-claimant draw by claim recency - #1687
juaristi22 wants to merge 10 commits into
Conversation
vahid-ahmadi
left a comment
There was a problem hiding this comment.
Thanks, María. This is a careful bump, and the draw stage is clean. Nothing blocks. Paths are under packages/microcosm-build/src/microcosm/build/.
One point (low, disclosure): the receipt's probe shares don't check both sides of each probe.
- Where:
share_below(uk_runtime/uc_new_claimant_draw.py:520-522) gatespopulation_share_belowandfirst_band_share_below(:551-559) only on the support of the whole population or 16–24 band. - The gap: nothing checks how many source households sit below and above each probe. The sibling receipts check both sides (
uk_runtime/carers_allowance_take_up.py:811-812,uk_runtime/frs_disability.py:725-727). - Example: in a synthetic case with 40 older units and 5 young households, where one young household is the most recent claim, the 16–24 band prints support "3-9" and shares of 0.2 at every probe. Each share rests on that single household.
- On the national file the young band is surely larger, so this is about the rule more than about this build.
- Suggestion: withhold a share when either side of its probe rests on 1 or 2 households, as the siblings do.
Notes, no change needed unless you want one:
- Two UC rows on one benefit unit:
frs_uc_claim_monthsrefuses such a unit (uk_runtime/frs_spine.py:2569-2572), whilefrs_uc_start_up_periodtakes the later start (:2470-2471). The refusal fails closed, and the 2024-25 file has no such unit, so the two rules can differ without harm. A one-line note in either place would help. - What sets a claim's recency: the order uses the UC claim start, not when LCWRA was found, which the FRS doesn't record. Is a sentence on that worth adding to the stage notes, since the protected group is described by when the health element applied?
- Disclosure sign-off: within the ranked population, the released draw is a monotone function of the admin-linked UCSTART recency, so each unit's recency rank can be read off it. This is probably covered by how
uc_is_in_startup_periodis already treated, but it's worth naming in the sign-off. - The signed
would_claim_student_loanentry:test_no_spine_column_writes_an_input_signed_at_the_engine_default(tests/engine_free/uk/test_uk_terminal_gates.py:549) checks onlyUK_ENGINE_DEFAULT_INPUTS, so a future stage writingwould_claim_student_loan(now in the take-up register) wouldn't trip it. This gap was already there; it's a small extension. - The 2.178.3 bullet leaves out upstream's 24-hours-of-work limit on the Child Tax Credit left-education routes. It only matters for 2024, so it's wording only.
- The lock-hash move (
APPROVED_UV_LOCK_SHA256,us_runtime/worker_identity.py:30) is required. It matches the newuv.lock, but a US primary-QRF worker identity recorded under main's lock will need regenerating.
Also checked, with no issues found:
Against the 2.179.2 wheel:
uc_reform.py:222-225pays the lower rate wheredraw < share, so the most recent claims get the lowest draws. The direction is right.- The draw is a benefit-unit yearly input, carried from the survey year.
- The engine conditions only on
uc_LCWRA_element > 0. - The population is read in 2025, before the first rebalancing year.
The stage:
- It is the last of the 57 spine stages.
- The order is months, then youngest age, then an identity tie-break.
- The midpoint uniform holds at the stage's weights (0.1101 / 0.1300 / 0.1601 / 0.2200 on a random 5,000-unit check).
- The pools work: empty and short bands merge, and zero-weight donors are never drawn.
- The salts are unique, and row order can't change the result.
- UCSTART parsing refuses malformed or future starts.
frs_uc_claim_monthsis dropped at release, the code identity covers the helpers, and the specs, schema, manifest and contract digests agree.
The bump:
uv.lockmoves only policyengine-uk, with no transitive change; core stays 3.34.10 for the UK and 3.32.5 for the US.- Exactly 25 inputs are added (378 to 403), with none removed or retyped. Each of the 24 signed texts matches the engine code, and nothing writes them.
- The core argument holds, and is a little stronger than stated. The engine's own consumers check
input_sourcebefore reading a draw, so the cached-default difference between 3.34.9 and 3.34.10 can't be reached from engine code. A probe of both unsupplied draws over 2025–2028 gives identical results on both cores. Upstream's qualification tests give 148 of 150 on 3.34.10 and 150 of 150 on 3.34.9, as you found. - The behaviour notes match upstream's changelog for the versions spot-checked, and the re-pinned rebalancing source matches the new
uc_reform.py.
Tests:
- The engine-free files for the stage, spine, graph, source stages, terminal gates, coverage, receipts, country spec, core pins, concept mapping and contract pass, about 2,000 tests with none failing.
- The engine-tier files I could run pass on 2.179.2 with core 3.34.10.
- I couldn't run the H2 parity test or
spec_engine_coverage.py --checkin a hand-built venv. CI passes all 12 checks at this head.
Review drafted with AI assistance and checked against the code at b3fb050.
b3fb050 to
eebf025
Compare
The UK side moves from policyengine-uk 2.177.7 to 2.179.2; uv.lock moves that package alone, so policyengine-core stays at 3.34.10 on the UK side and 3.32.5 on the US side, and APPROVED_UV_LOCK_SHA256 follows. 2.179.2 adds 25 engine inputs (378 to 403). Each stays at its default and is signed with the error it can make: the fourteen uk_total_* UK totals (2.178.0), the Child Benefit and Child Tax Credit routes for a young person who has left education (2.178.3), the four adoption, fostering and overnight-care inputs of the size criteria (2.178.7), the three stored draws (2.179.0; would_claim_student_loan in the take-up register) and the Northern Ireland rate rebate flag (2.179.2). The texts that describe the locked engine were checked against the diff from 2.177.7 to 2.179.2 and now cite 2.179.2. The concept coverage, the uprating pins and bonus anchor (stamps only), the core pin test and the release input coverage manifest follow. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
policyengine-uk 2.179.0 (PolicyEngine/policyengine-uk#2877) reads a stored uniform per benefit unit, uc_new_claimant_health_element_draw: in each rebalancing year a unit with the LCWRA element gets the new-claimant rate where its draw falls below new_claimant_share. Without it the engine draws in benefit-unit order, so who gets the lower rate is random with respect to everything the file records. A new last spine stage, uc_new_claimant_draw, stores the draw: - its population is the units the engine pays Universal Credit with the LCWRA element at the calibration year (one engine read); - within it, units are ordered by claim recency, the completed months from DWP's claim start (FRS BENEFITS.UCSTART) to the interview, then by the age of the youngest claimant or partner, youngest first; - a unit without a linked claim start takes months drawn from the linked claims in its age band, pooled to 30 source households; - each unit takes the midpoint of its slice of the population's weight, and every other unit an identity-keyed uniform, so the draw is uniform overall and the engine keeps the parameter's share. frs_spine carries the recency as the benefit-unit carrier frs_uc_claim_months, which the release drops. The draw leaves UK_ENGINE_DEFAULT_INPUTS and joins the export surface's allowed columns, so the data contract's gate digests follow, and the signed entry for uc_receives_new_claimant_health_element is restated. The stage spec and its schema branch, the graph cell, the kernel, spine and fixture registrations, the coverage manifest, the roster pins and the build graph doc follow. Tests: the stage's own (engine-free and on the locked engine) and the carrier's. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…179.2 2.179.0 changes add_universal_credit_reform in one way: inside each rebalancing year it reads the dataset's stored new-claimant draw where one reaches the year, and draws the seeded stream only for a year with none, lazily, with the same generator and length as before. The loop still iterates the module's REBALANCING_YEARS, which the adapter's cut (uk_rebalancing_years_through) narrows, and no year reads another, so the cut holds. _add_inactive_health_element_formula is unchanged. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The FRS asks salary sacrifice on adults' job records, so the forest is fitted on adults, but it predicted for everyone not asked who had pay. Since frs_spine carries a dependent child's CHILD.CHEARNS as employment_income (#1663), every child with pay was given a forest-predicted sacrifice. A dependent child not asked (is_hbai_dependent_child) now sacrifices none of their pay, the stage refuses a frame without the flag, and the receipt counts them beside the people not asked who have no pay. The stage spec's target population says so (Vahid's final review of #1663, and María's reply of 19 November 2026). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The HMRC pay leaf (hmrc_spi_pay, which hmrc_spi_employed_income sums) came from ADULT.INEARNS alone. Since #1663 a child whose CHILD.CHEARNS is above the personal allowance pays income tax, so they counted as a taxpayer with no HMRC employment income: out of the employment-income rows, or in too low an income band. frs_hmrc_spine_leaves now declares and checks child.tab and takes a child-table person's pay as max(0, CHILD.CHEARNS) * 52, as an adult's is max(0, ADULT.INEARNS) * 52. It refuses a person on both tabs. The spec's retained constituent and the source contract name both raw sources (Vahid's final review of #1663, and María's reply of 19 November 2026). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… fixes Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
draw_spi_bonuses' rule (BONUS_SACRIFICE_SPI_DRAW, and the stage spec's spi_bonus_draw) has SPI-channel adults draw a bonus share of pay from base-FRS adults, but its call passed every row. Since #1663 a dependent child's CHILD.CHEARNS is their pay, so paid children joined the donors with no bonus and moved the pay cells' edges, which set the adults' draws. Both masks are now gated on adult records (not is_hbai_dependent_child). A child can't become a bonus-sacrifice candidate below the upper earnings limit, so the fix moves only the adults' draws. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
policyengine-uk 2.178.0 (pe-uk#2901) lets data carry the UK totals of the components of its two share keys, corporate_sector_wealth and consumption, so a simulation of part of the file (a region, an extract, a household subset) gives each household its share of the national totals rather than of the part's own. The release boundary now writes the fourteen uk_total_* household columns, each the same on every row, as the component's sum at the frame's household weights, as policyengine_uk.utils.uk_totals.uk_totals sums it (national_frame.uk_household_totals). uk_dataset_year_frame sums them again at the weights the file stores, which policyengine-uk projects by population as it projects the weights. Every release writer and the graph's readback go through it. The fourteen leave UK_ENGINE_DEFAULT_INPUTS, and the export surface allows them as new since the reference build, which moves the gate battery's policy, manifest and fingerprint and the release cut's part digests in the data contract. Engine tests: the components and sums are policyengine-uk's own, and a household subset of a written release keeps each household's UK share (María's call of 19 November 2026; her ruling D-e on pe-uk#2896). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
María signed, for now, the ten inputs 2.179.2 adds that the build leaves at the engine's default, and the restated uc_receives_new_claimant_health_element entry: the three left-education routes, the four size-criteria and family inputs, pip_phase_in_draw, housing_benefit_report_is_rate_rebate_only and, in the take-up register, would_claim_student_loan. Each reason now ends with her signature of 19 November 2026, pending review, in place of the request for it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
b6c56eb to
41053d9
Compare
vahid-ahmadi
left a comment
There was a problem hiding this comment.
Follow-up at 41053d9, covering the six commits since my review at b3fb050: df8bdde79, b111fb0fa, eadf58035, 8c0e62e41, 713e0f05d and 41053d980. Paths are under packages/microcosm-build/src/microcosm/build/.
The child-pay fixes and the UK totals read well, and CI passes all 12 checks at this head. One request on the description and measurement, and one low point.
1. The description and the measurement predate these commits (medium).
- Stale description:
- "Not in this PR" still lists writing the
uk_total_*columns, which713e0f05dnow does. - "The new inputs, signed at their defaults" still counts 24, including the fourteen totals. Ten remain.
- "Signatures" still says awaiting.
41053d980signs them pending review. - The three child-pay fixes aren't described.
- "Not in this PR" still lists writing the
- Measurement: the arms ran at
9b89c7c45, before these commits. María's reply on #1663 (19 November) said the adult gate and the HMRC leaf "would move the build the final arm certified, so they go in a follow-up PR with its own measurement". They are now in this PR, together with the bonus-draw change, which moves adults' draws through the pay cells' edges. - Ask: could the head arm be rerun, or the moves reported? Specifically the bound
hmrc.salary_sacrifice.*rows, the HMRC employment-income and taxpayer rows, and the bonus-sacrifice totals. If nothing material moves, a line saying so would do.
2. The UK totals are tested at the dataset year only (low). test_a_household_subset_of_the_release_keeps_its_uk_share reads 2024. policyengine-uk uprates each uk_total_* "like the column it sums, times population" (utils/uk_totals.py), while the weights project by population. A second read in a projected year, such as 2027, would check that the shares still sum to one there and that the subset still matches.
Checked, with no issues found:
- Salary sacrifice (
uk_runtime/salary_sacrifice.py):predict_masknow excludesis_hbai_dependent_child, whichfrs_spinesets as~adult_record, the child-table people.- Paid children who weren't asked are set to 0 and counted in the receipt.
- A missing flag, or one that isn't boolean, is refused.
- The SPI bonus draw's donors and drawers are adults only.
- HMRC pay leaf (
uk_runtime/frs_hmrc_source.py):- A child-table person's pay is
max(0, CHILD.CHEARNS) * 52, the same as an adult'sINEARNS. - A person on both tabs, a duplicate, or non-finite earnings is refused.
child.tabis a declared, identity-checked artifact.
- A child-table person's pay is
- UK totals (
uk_runtime/national_frame.py,weight_year.py):- The release boundary writes the fourteen columns, and
uk_dataset_year_framesums them again at the stored weights. - Every release writer goes through both:
graph_national,graph_terminalandfull_build_cli. - The components match policyengine-uk 2.179.2's
uk_total_columns(). - The fourteen leave the defaults register.
- The release boundary writes the fourteen columns, and
- Local runs:
- The salary-sacrifice, FRS-HMRC-source, SPI-spine and engine-free weight-year files: 127 passed.
- Both new engine tests on policyengine-uk 2.179.2: 2 passed.
Review drafted with AI assistance and checked against the code at 41053d9.
Summary
The UK lock moves from policyengine-uk 2.177.7 to 2.179.2, the newest release (microcosm#1095).
uv.lockmoves that package alone: policyengine-core stays at 3.34.10 on the UK side and 3.32.5 on the US side.2.179.0 (PolicyEngine/policyengine-uk#2877) lets a dataset store
uc_new_claimant_health_element_draw, the uniform per benefit unit that the engine compares in each rebalancing year withgov.dwp.universal_credit.rebalancing.new_claimant_shareto pay the lower new-claimant health element. A new last spine stage,uc_new_claimant_draw, stores it ordered by claim recency and age, and keeps it uniform, so the engine keeps the parameter's share while the units on the lower rate are the most recent claims. This is item 2 of the plan for the Milburn gaps, kept out of #1663.The new inputs, signed at their defaults
2.179.2 adds 25 engine inputs (378 to 403). The build writes one of them, the draw. The other 24 stay at their defaults, each in
UK_ENGINE_DEFAULT_INPUTS(would_claim_student_loanin the take-up register) with the error it can make, for María's signature:uk_total_*UK totals (2.178.0, Give household situations no share of national totals, and let data carry UK totals policyengine-uk#2901), at 0. Where the data carries them, the shares of corporate wealth and consumption divide by the UK's totals, so a simulation of part of the UK gets each household's national share. At 0 the shares divide by the simulated households' own totals, as before 2.178.0. The whole released file and the build's engine blocks give the same shares either way, so no figure the build reads moves. A user who filters the file to one region or an extract allocates each national total over that part alone: business rates, corporate SDLT, corporate land, consumer-incident tax changes and the carbon tax's corporate part are overstated for its households.add_uk_totalscan write them at release (a follow-up).pip_phase_in_draw(2.179.0): only the opt-in PIP phase-in scenario reads it, and it keeps its own seeded draw, as before 2.179.0.would_claim_student_loan(2.179.0): the engine keeps its own draw for new borrowers in later years, keyed onperson_idat its 40% graduate rate, as before 2.179.0.housing_benefit_report_is_rate_rebate_only(2.179.2), at false: the FRS's Housing Benefit code does not tell a Northern Ireland rate rebate from a rent rebate, so the engine reads every report as a rent rebate or allowance; only the first-day test of the UC education condition in Northern Ireland reads it.uc_receives_new_claimant_health_element's signed entry is restated: the build still supplies no status for any year, and the engine now assigns it from the stored draw.What the build's engine reads return now
No economic pin moves: the vendored uprating pins and the bonus-sacrifice anchor change only their version stamps.
policyengine-core: 2.179.2 qualifies 3.34.9, the lock holds 3.34.10
2.179.2's stored-draw check reads policyengine-core's private storage members, and
QUALIFIED_CORE_VERSIONSnames only 3.34.9; policyengine-uk does not enforce it at runtime. Its qualification tests, run here on 3.34.10 (the six files its docstring names, withtest_uc_rebalancing.pyand the code-health draw reads): 293 tests, 291 passed and 2 failed. Both failures are intest_stored_draw_input_source.py, and that file passes in full on 3.34.9 (68 of 68). Both cover a simulation whose data supplies no draw: 3.34.9 caches the default it returns for a later year, and policyengine-uk then refuses a later input or a changed default; 3.34.10 leaves that default uncached (its own fix), so the later input or default takes effect and the refusal the tests expect never comes. The build supplies the draw before any read, and on that path the reads return the stored draw on 3.34.10: the route, consumer and rebalancing tests pass, and so does this PR's engine test. The core pin does not move here; qualifying 3.34.10 is policyengine-uk's.The new-claimant draw
frs_spinecarries the recency asfrs_uc_claim_months(benefit unit, -1 where none), which the release drops; the stage spec insources.yamlandsource_stages.jsonwith its operation schema; the graph cell, kernel, spine and fixture registrations; the coverage manifest; the export surface's allowed columns (terminal_gates,gates.json, and the data contract's gate digests); the H2 fixture.Measurement
Two national arms, each a spine and a calibration on this machine, on Chronicle
4ce631f5(main's feed pin) at review date 2026-11-17 with emitter 0.16.0:f86134f11(policyengine-uk 2.177.7). Main's later commits throughcfd5a2a5e, this branch's base, change no UK build code.9b89c7c45(policyengine-uk 2.179.2 and the new stage).The criteria were fixed before the head arm ran. The 2027-28 figures are Great Britain's, read on each arm's release at its own weights with its own engine; the head is also read without the stored draw, which isolates the draw on the same data and engine.
Health. Both arms pass 7 of 7 seam gates. The head's final loss is 0.00510 against the control's 0.00512, with 98.7% of the 1,534 bound rows within 10% against 98.8%: one row, which no release changes, crosses the line by a fraction of a point. The weight-ratio gate passes on both arms. The spine ran in 14 minutes; the new stage takes 20 seconds. The spine's peak memory was 14.0 GB, against 9.3 GB on the control and 12.4 GB on #1663's latest arm; the control ran on a busy machine, so the comparison is loose, and the new stage's share of the rise is not isolated.
The bump's own moves (2025). No bound row's error moves by more than about a point, and LCWRA households stay at 1.5%. The held-out checks of PR3 move by under a point; nine regional PIP award-category checks move by 1 to 5 points with the weights, and no release changes them. The draw changes nothing in 2025, where the new-claimant share is zero.
The draw. The release carries it on every benefit unit, and drops
frs_uc_claim_months. Over all benefit units at the release's weights, 10.8%, 12.8%, 15.8% and 22.2% fall below 0.11, 0.13, 0.16 and 0.22.Share of Great Britain's units paid UC with the element that get the new-claimant rate (head / control / head read without the draw):
The units the stage ranks are exactly the units the release pays the element in 2025, and at the stage's weights their draws are uniform (22.0% below 0.22). The calibration then gives the most recent claims a little more weight and the next ones a little less, which leaves 2029-30 two points short of the parameter. The engine's own draw lands a point short each year on the same file.
2027-28, Great Britain:
Tests
Local, on this machine, counted by
--junitxml, one process at a time:microcosm-data's contract tests andmicrocosm-frame's concept-mapping tests, in about 30-file processes. Every file passes at the head excepttest_uk_orrery_reconstruction.py, which needsnpm ciintools/orrery-contract(CI's runner does it). The files that failed on the first pass were the ones this PR's later steps fix (the H2 fixture, the release-cut gate digests), and they pass on rerun;test_uk_cgt_projection.py's check that the engine is absent passes with the engines blocked, as on CI, and so do the new stage's and the carrier's files (274 tests).tools/ci_test_plan.py verify,tools/spec_engine_coverage.py --check(42,404 of 42,404 fields), the concept coverage and the coverage manifest are current.CI at
b3fb0505a: all 12 checks pass (lint, wheels, installed-emitter, integration-uk, and engine-free, engine-uk and engine-us on Python 3.13 and 3.14).Signatures
Awaiting María's signature: the 24 defaults above, each with the error it can make, and the restated
uc_receives_new_claimant_health_elemententry.Not in this PR
uk_total_*columns at release withadd_uk_totals, so a regional filter of the file shares national totals correctly.QUALIFIED_CORE_VERSIONS(upstream).Disclosure
National figures only (UK, Great Britain), each on 30 or more survey households; sub-national rows appear only as how far their errors move, never singly by name or value; no record-level value, maximum or minimum; no cell under 3 households, and none that another figure here gives back by difference. The policyengine-uk figures are its parameters and versions.
🤖 Generated with Claude Code