Skip to content

Fix structural reforms for their requested periods - #2670

Open
juaristi22 wants to merge 9 commits into
mainfrom
fix-1800-structural-trigger-periods
Open

juaristi22 wants to merge 9 commits into
mainfrom
fix-1800-structural-trigger-periods

Conversation

@juaristi22

@juaristi22 juaristi22 commented Oct 25, 2026 •

Copy link
Copy Markdown
Collaborator

Fixes #1800

Reproducer: policyengine_uk/tests/test_structural_reform_periods.py::test_expanded_ma_share_search_keeps_inactive_year_current_law

Structural reform switches follow the calculation period. Bare-year keys in reform dictionaries and Scenario parameter_changes activate only the named year; explicit intervals stop at their end. Finite parameter histories also find future Scottish Child Payment activations beyond the previous five-year scan. Ordinary formulas apply outside each activation interval.

Parameter-driven disable_simulated_benefits uses reported amounts only in active years and preserves supplied inputs across reform replay, input changes, cache invalidation and cloning. Direct application retains its existing ten-year behavior. #2305 addressed dictionary/Scenario application ordering; this PR addresses activation dates.

axiom: n/a: structural activation and input/cache lifecycle engineering; no policy rule or numeric parameter changes.

Commit 70043325b7836ead8a2bbeb3301d7b9cca29839c addresses Vahid's latest review. The expanded Marriage Allowance reform now routes marriage_allowance_reduction_at_stake alongside its other two replacement variables. This keeps the share search on the unreformed rules outside the activation interval.

Four new cases use a self-contained equivalent of SHARE_COUPLE, whose savings and dividends make the allocation of reliefs affect Marriage Allowance. They cover dictionary and Scenario application with both a bare year and a calendar-year interval. Each checks the amount at stake, Marriage Allowance and income tax against inactive-year and active-reform controls, repeating years out of order.

Local validation used Python 3.13.15 and Core 3.34.9 with synthetic fixtures and frozen, offline execution. All four new cases failed on the original production code at the inactive-2025 income-tax assertion, then recorded complete setup/call/teardown PASS after the routing fix. The two affected files collected 118 distinct cases. Their combined run exceeded the 2 GiB memory cap after 113 complete PASS observations; that command remained incomplete, without JUnit or a session-finish result. It was not a successful combined run.

The fresh five-case complement also exceeded the 2 GiB memory cap during its first case. It contributes no normal-run PASS credit. Validation of the complete 118-case manifest remains incomplete.

Hosted checks for 70043325b7836ead8a2bbeb3301d7b9cca29839c require a fresh read after publication; earlier commits' results do not validate this commit.

The optional generic guard against unrouted replacements remains deferred. It needs a separate compatibility contract for existing-variable replacements, newly introduced helper variables and trial/clone behavior across the structural-reform callers.

Max's reported-input-ledger scope decision remains open: retain the ledger, observers and replay here, split reported-only mode into another PR, or keep that switch at build time with its dataset-year requirement documented. This fix leaves that implementation in place. Max's scope decision and formal review approval remain required; the local regression evidence does not clear the whole PR.

Main merge and CI conflict repair

Merge head 5356a0887e5c5754a8e24e874041d0edb28de49d combines the previous PR head 70043325 with main 00baa92d. It resolves five shard-count differences in the workflow and testing guide using main's ten-shard settings. The nine PR-only implementation, test and changelog files retain their exact previous contents.

All 129 focused CI sharding and runner tests passed, with no failures, errors or skips. Formatting, lint, changelog and fix-evidence checks passed. Hosted checks for this merge have not completed at publication.

This validation covers the conflict repair. The reported-input ledger scope decision, earlier incomplete 118-case local model validation and formal approval remain open.

@github-actions

github-actions Bot commented Oct 25, 2026 •

Copy link
Copy Markdown
Contributor

Aggregate impact on certified data: pass

Base 00baa92d4f against head 3ca3d21404, both on enhanced_frs_2024_25.h5 (policyengine-uk-data 1.58.1, sha256 056e80fd8e91), fiscal years 2025-26 to 2031-32. Each year is a full microsimulation run on each side.

Checks: 0 broken by this change, 1 failing on both sides, 0 fixed. Moves flagged for review: 0 (thresholds in report_spec.yaml; a flag does not fail the job).

Workflow run and full report

Notes

  • In the years a figure from fewer than 10 records is suppressed (spending.disabled_students_allowance), every total containing it, and the decile incomes, are rebuilt from their other components, so no published total includes it. Those totals are marked †. A change is withheld where the two sides leave out different figures and can't be lined up.

Moves flagged for review

None.

Spending by benefit and service

Measure 2025-26 2026-27 2027-28 2028-29 2029-30 2030-31 2031-32
Disabled Students' Allowance suppressed suppressed suppressed suppressed suppressed suppressed suppressed

Caseloads

Measure 2025-26 2026-27 2027-28 2028-29 2029-30 2030-31 2031-32
Disabled Students' Allowance suppressed suppressed suppressed suppressed suppressed suppressed suppressed

Household net income by decile

No household's net income changes in any year.

No change in any year: receipts by tax head; government balance, each component counted once; model totals; household income totals; population; poverty rates; people in poverty; inequality; mean household net income in each side's own deciles; standard reform costings (change in gov_balance); standard reforms: change in each reform's target.

Checks failing on both base and head (1)
  • VAT excluding private school fees is never negative (sign:vat): 2025-26: 76 units below zero, a weighted £-52,314,332 in total; 2026-27: 76 units below zero, a weighted £-54,150,722 in total; 2027-28: 76 units below zero, a weighted £-56,043,426 in total
Counted-once check

The check raised each of 92 components by £1 per unit in 2026-27 and read every head of its totals household by household: its own head must rise by exactly £1, no other tax head may move, no other benefit may rise, and the model's own total must move by what its heads moved. A response that is not finite breaks every rule. The check measures a head that breaks a rule twice more: once holding every other head at its baseline value, and once holding every other head at its value after the first £1 while the component rises again. The head fails where either measurement still shows the response. The check cannot hold a head at a value that is not finite. In each unit where another head is not finite after the first £1, it holds that head at its baseline value, and the second measurement judges no household the unit belongs to. There a head fails wherever it first broke a rule, or wherever the check could not confirm whether its response contains the component. 0 failed and the check skipped 0.

  • widowed_parents_allowance: pension_credit responds only through other heads in fewer than 10 households (other heads that moved there: carers_allowance; gov_spending; not a failure)
  • widowed_parents_allowance: pension_credit responds only through other heads in fewer than 10 households (other heads that moved there: carers_allowance; household_benefits; not a failure)
Provenance
Side Commit Runtime Environment hash Partition hash Time
base main 00baa92d4f uk 2.179.4 (files cd64778d3f6c), core 3.34.9, py 3.13.18 aarch64 a07d9b6f0b7f f5dab8526157 3299.2s
head #2670 merged into main 3ca3d21404 uk 2.179.4 (files 649580537bf5), core 3.34.9, py 3.13.18 aarch64 a07d9b6f0b7f f5dab8526157 3265.35s

Dataset: hf://policyengine/policyengine-uk-data-private/enhanced_frs_2024_25.h5@2526edbbb687a3b54dbb11272e5389e4b62d2ac2, sha256 056e80fd8e9151d78f432a25cde863340baee81304c6216a37fb575ce8563784 (verified on both sides), policyengine-uk-data 1.58.1.

Receipts by tax head: head levels
Measure (head) 2025-26 2026-27 2027-28 2028-29 2029-30 2030-31 2031-32
Final charge on cash interest in non-cash ISAs £0.00bn £0.00bn £0.00bn £0.00bn £0.00bn £0.00bn £0.00bn
Lifetime ISA withdrawal charge £0.00bn £0.00bn £0.00bn £0.00bn £0.00bn £0.00bn £0.00bn
Income tax £294.44bn £315.21bn £335.80bn £351.25bn £366.92bn £385.32bn £399.96bn
National Insurance (employee and self-employed) £51.70bn £54.14bn £56.13bn £57.73bn £59.76bn £61.64bn £63.51bn
National Insurance (employer) £148.71bn £155.37bn £160.88bn £165.09bn £172.06bn £177.36bn £182.57bn
Employer NI change borne by capital £0.00bn £0.00bn £0.00bn £0.00bn £0.00bn £0.00bn £0.00bn
Employer NI change borne by consumers £0.00bn £0.00bn £0.00bn £0.00bn £0.00bn £0.00bn £0.00bn
Capital gains tax £12.60bn £13.15bn £13.60bn £14.11bn £14.67bn £15.24bn £15.80bn
Student loan repayments £7.82bn £8.13bn £8.39bn £8.58bn £8.79bn £9.04bn £9.29bn
VAT excluding private school fees £242.22bn £249.47bn £258.67bn £264.86bn £270.95bn £277.04bn £283.21bn
Change in VAT from its baseline £0.00bn £0.00bn £0.00bn £0.00bn £0.00bn £0.00bn £0.00bn
VAT on private school fees £1.95bn £2.01bn £2.09bn £2.14bn £2.20bn £2.26bn £2.31bn
Change in private school VAT from its baseline £0.00bn £0.00bn £0.00bn £0.00bn £0.00bn £0.00bn £0.00bn
Fuel duties £24.71bn £24.13bn £26.00bn £26.83bn £26.51bn £25.78bn £24.63bn
Alcohol duties £0.00bn £0.00bn £0.00bn £0.00bn £0.00bn £0.00bn £0.00bn
Tobacco duties £0.00bn £0.00bn £0.00bn £0.00bn £0.00bn £0.00bn £0.00bn
Vehicle excise duties £0.00bn £0.00bn £0.00bn £0.00bn £0.00bn £0.00bn £0.00bn
Betting and gaming duties £0.00bn £0.00bn £0.00bn £0.00bn £0.00bn £0.00bn £0.00bn
TV licence fee £4.26bn £4.40bn £4.41bn £4.42bn £4.43bn £4.44bn £4.45bn
Council tax £49.21bn £52.16bn £54.89bn £57.95bn £61.16bn £64.47bn £67.91bn
High value council tax surcharge £0.00bn £0.00bn £0.00bn £0.48bn £0.49bn £0.50bn £0.51bn
Northern Ireland domestic rates £0.55bn £0.58bn £0.60bn £0.63bn £0.66bn £0.69bn £0.72bn
Business rates £34.68bn £36.20bn £38.00bn £39.46bn £42.27bn £43.25bn £44.29bn
Stamp duty land tax on the household's own purchases £6.88bn £7.32bn £7.66bn £8.06bn £8.47bn £8.91bn £9.35bn
Stamp duty land tax paid by companies £4.72bn £4.57bn £5.29bn £6.03bn £6.37bn £6.92bn £7.45bn
Land transaction tax (Wales) £0.07bn £0.08bn £0.08bn £0.09bn £0.10bn £0.10bn £0.11bn
Land and buildings transaction tax (Scotland) £0.31bn £0.32bn £0.33bn £0.35bn £0.36bn £0.38bn £0.40bn
Unspecified tax change borne by capital £0.00bn £0.00bn £0.00bn £0.00bn £0.00bn £0.00bn £0.00bn
Unspecified tax change borne by consumers £0.00bn £0.00bn £0.00bn £0.00bn £0.00bn £0.00bn £0.00bn
Wealth tax £0.00bn £0.00bn £0.00bn £0.00bn £0.00bn £0.00bn £0.00bn
Wealth tax excluding the main residence £0.00bn £0.00bn £0.00bn £0.00bn £0.00bn £0.00bn £0.00bn
Land value tax £0.00bn £0.00bn £0.00bn £0.00bn £0.00bn £0.00bn £0.00bn
Carbon tax £0.00bn £0.00bn £0.00bn £0.00bn £0.00bn £0.00bn £0.00bn
Spending by benefit and service: head levels
Measure (head) 2025-26 2026-27 2027-28 2028-29 2029-30 2030-31 2031-32
Lifetime ISA bonus £0.00bn £0.00bn £0.00bn £0.00bn £0.00bn £0.00bn £0.00bn
State Pension £121.68bn £125.92bn £126.72bn £129.48bn £132.98bn £136.65bn £140.41bn
Pension Credit £6.21bn £6.46bn £6.68bn £6.82bn £6.89bn £7.07bn £7.22bn
Winter Fuel Payment £1.86bn £1.85bn £1.79bn £1.77bn £1.78bn £1.78bn £1.78bn
Pension Age Winter Heating Payment (Scotland) £0.19bn £0.20bn £0.20bn £0.21bn £0.21bn £0.22bn £0.22bn
Universal Credit £75.71bn £81.81bn £84.29bn £86.34bn £87.51bn £89.06bn £89.70bn
Housing Benefit £8.57bn £8.52bn £8.85bn £9.06bn £9.29bn £9.57bn £9.84bn
Council Tax Reduction £2.19bn £2.32bn £2.44bn £2.58bn £2.72bn £2.87bn £3.02bn
Employment and Support Allowance (income-related) £0.79bn £0.00bn £0.00bn £0.00bn £0.00bn £0.00bn £0.00bn
Employment and Support Allowance (contribution-based) £5.20bn £5.37bn £5.56bn £5.69bn £5.82bn £5.95bn £6.09bn
Jobseeker's Allowance (income-based) £0.00bn £0.00bn £0.00bn £0.00bn £0.00bn £0.00bn £0.00bn
Jobseeker's Allowance (contribution-based) £0.29bn £0.30bn £0.31bn £0.31bn £0.32bn £0.33bn £0.34bn
Income Support £0.11bn £0.00bn £0.00bn £0.00bn £0.00bn £0.00bn £0.00bn
Working Tax Credit £0.00bn £0.00bn £0.00bn £0.00bn £0.00bn £0.00bn £0.00bn
Child Tax Credit £0.00bn £0.00bn £0.00bn £0.00bn £0.00bn £0.00bn £0.00bn
Incapacity Benefit £0.00bn £0.00bn £0.00bn £0.00bn £0.00bn £0.00bn £0.00bn
Personal Independence Payment £26.95bn £28.03bn £29.05bn £30.09bn £30.75bn £31.51bn £32.21bn
Disability Living Allowance £7.49bn £7.79bn £8.07bn £8.36bn £8.55bn £8.76bn £8.95bn
Attendance Allowance £8.68bn £9.03bn £9.36bn £9.69bn £9.90bn £10.15bn £10.38bn
Carer's Allowance £4.48bn £4.66bn £4.83bn £5.00bn £5.11bn £5.27bn £5.42bn
Carer Support Payment (Scotland) £0.31bn £0.32bn £0.33bn £0.34bn £0.35bn £0.36bn £0.37bn
Scottish Carer Supplement £0.00bn £0.04bn £0.04bn £0.05bn £0.05bn £0.05bn £0.05bn
Severe Disablement Allowance £0.03bn £0.03bn £0.03bn £0.03bn £0.03bn £0.03bn £0.03bn
Industrial Injuries Disablement Benefit £0.50bn £0.52bn £0.54bn £0.55bn £0.56bn £0.58bn £0.59bn
Armed Forces Compensation Scheme £0.61bn £0.63bn £0.65bn £0.66bn £0.68bn £0.69bn £0.71bn
War Widow's or Widower's Pension £0.00bn £0.00bn £0.00bn £0.00bn £0.00bn £0.00bn £0.00bn
Child Benefit £16.20bn £16.82bn £17.39bn £18.01bn £18.40bn £18.84bn £19.26bn
Scottish Child Payment £0.49bn £0.52bn £0.53bn £0.55bn £0.56bn £0.57bn £0.56bn
Two Child Limit Payment (Scotland, counterfactual) £0.00bn £0.00bn £0.00bn £0.00bn £0.00bn £0.00bn £0.00bn
Healthy Start vouchers £0.05bn £0.05bn £0.05bn £0.05bn £0.05bn £0.05bn £0.05bn
Maternity Allowance £0.00bn £0.00bn £0.00bn £0.00bn £0.00bn £0.00bn £0.00bn
Statutory Maternity Pay £3.30bn £3.41bn £3.54bn £3.62bn £3.70bn £3.78bn £3.87bn
Statutory Paternity Pay £0.00bn £0.00bn £0.00bn £0.00bn £0.00bn £0.00bn £0.00bn
Statutory Sick Pay £1.12bn £1.16bn £1.20bn £1.23bn £1.26bn £1.29bn £1.32bn
Sure Start Maternity Grant £0.01bn £0.01bn £0.01bn £0.01bn £0.01bn £0.01bn £0.01bn
Bereavement Support Payment £0.67bn £0.69bn £0.71bn £0.73bn £0.75bn £0.76bn £0.78bn
Widowed Parent's Allowance £0.00bn £0.00bn £0.00bn £0.00bn £0.00bn £0.00bn £0.00bn
Tax-Free Childcare £0.56bn £0.57bn £0.57bn £0.58bn £0.60bn £0.61bn £0.59bn
Extended childcare entitlement £2.99bn £3.50bn £3.59bn £3.71bn £3.78bn £3.86bn £3.93bn
Universal childcare entitlement £2.06bn £2.22bn £2.29bn £2.37bn £2.43bn £2.48bn £2.53bn
Targeted childcare entitlement £0.50bn £0.51bn £0.52bn £0.54bn £0.55bn £0.57bn £0.56bn
Childcare Offer for Wales £0.26bn £0.28bn £0.28bn £0.29bn £0.30bn £0.31bn £0.32bn
Care to Learn £0.00bn £0.00bn £0.00bn £0.00bn £0.00bn £0.00bn £0.00bn
Childcare Grant £0.00bn £0.00bn £0.00bn £0.00bn £0.00bn £0.00bn £0.00bn
Parents' Learning Allowance £0.20bn £0.20bn £0.20bn £0.20bn £0.20bn £0.20bn £0.20bn
Adult Dependants' Grant £0.06bn £0.06bn £0.04bn £0.04bn £0.04bn £0.04bn £0.04bn
Travel Grant £0.00bn £0.00bn £0.00bn £0.00bn £0.00bn £0.00bn £0.00bn
Disabled Students' Allowance suppressed suppressed suppressed suppressed suppressed suppressed suppressed
16 to 19 Bursary Fund £0.00bn £0.00bn £0.00bn £0.00bn £0.00bn £0.00bn £0.00bn
NHS spending £203.89bn £204.30bn £204.56bn £204.91bn £205.34bn £205.85bn £206.35bn
State education spending £0.02bn £0.02bn £0.02bn £0.02bn £0.02bn £0.02bn £0.02bn
Transport subsidy spending £25.05bn £25.10bn £25.14bn £25.18bn £25.23bn £25.30bn £25.36bn
Cost-of-living support payment £0.00bn £0.00bn £0.00bn £0.00bn £0.00bn £0.00bn £0.00bn
Energy Bills Rebate £0.00bn £0.00bn £0.00bn £0.00bn £0.00bn £0.00bn £0.00bn
Household Energy Payment £0.00bn £2.11bn £0.00bn £0.00bn £0.00bn £0.00bn £0.00bn
Energy Price Guarantee subsidy £0.00bn £0.00bn £0.00bn £0.00bn £0.00bn £0.00bn £0.00bn
Basic income £0.00bn £0.00bn £0.00bn £0.00bn £0.00bn £0.00bn £0.00bn
Disability basic income £0.00bn £0.00bn £0.00bn £0.00bn £0.00bn £0.00bn £0.00bn
Other public spending budget change £0.00bn £0.00bn £0.00bn £0.00bn £0.00bn £0.00bn £0.00bn
Caseloads: head levels
Measure (head) 2025-26 2026-27 2027-28 2028-29 2029-30 2030-31 2031-32
Lifetime ISA bonus 0k 0k 0k 0k 0k 0k 0k
State Pension 11,264k 11,145k 10,819k 10,700k 10,723k 10,750k 10,776k
Pension Credit 1,489k 1,484k 1,476k 1,454k 1,452k 1,457k 1,466k
Winter Fuel Payment 7,844k 7,783k 7,473k 7,375k 7,391k 7,409k 7,427k
Pension Age Winter Heating Payment (Scotland) 803k 802k 800k 797k 799k 801k 802k
Universal Credit 6,343k 6,419k 6,408k 6,369k 6,364k 6,343k 6,295k
Housing Benefit 1,249k 1,182k 1,181k 1,165k 1,164k 1,166k 1,168k
Council Tax Reduction 3,326k 3,344k 3,351k 3,364k 3,375k 3,388k 3,395k
Employment and Support Allowance (income-related) 71k 0k 0k 0k 0k 0k 0k
Employment and Support Allowance (contribution-based) 719k 720k 721k 722k 724k 726k 728k
Jobseeker's Allowance (income-based) 0k 0k 0k 0k 0k 0k 0k
Jobseeker's Allowance (contribution-based) 67k 67k 67k 67k 67k 68k 68k
Income Support 25k 0k 0k 0k 0k 0k 0k
Working Tax Credit 0k 0k 0k 0k 0k 0k 0k
Child Tax Credit 0k 0k 0k 0k 0k 0k 0k
Incapacity Benefit 0k 0k 0k 0k 0k 0k 0k
Personal Independence Payment 3,567k 3,575k 3,579k 3,585k 3,593k 3,602k 3,611k
Disability Living Allowance 1,291k 1,294k 1,296k 1,298k 1,300k 1,304k 1,307k
Attendance Allowance 1,695k 1,698k 1,700k 1,703k 1,707k 1,711k 1,715k
Carer's Allowance 1,034k 1,037k 1,038k 1,040k 1,042k 1,060k 1,062k
Carer Support Payment (Scotland) 71k 71k 71k 72k 72k 72k 72k
Scottish Carer Supplement 0k 71k 71k 72k 72k 72k 72k
Severe Disablement Allowance 4k 4k 4k 4k 4k 4k 4k
Industrial Injuries Disablement Benefit 137k 137k 137k 138k 138k 138k 139k
Armed Forces Compensation Scheme 93k 93k 94k 94k 94k 94k 94k
War Widow's or Widower's Pension 0k 0k 0k 0k 0k 0k 0k
Child Benefit 8,124k 8,121k 8,121k 8,131k 8,146k 8,162k 8,179k
Scottish Child Payment 351k 352k 352k 353k 350k 348k 337k
Two Child Limit Payment (Scotland, counterfactual) 0k 0k 0k 0k 0k 0k 0k
Healthy Start vouchers 200k 200k 200k 201k 201k 201k 202k
Maternity Allowance 0k 0k 0k 0k 0k 0k 0k
Statutory Maternity Pay 333k 333k 334k 334k 335k 336k 337k
Statutory Paternity Pay 0k 0k 0k 0k 0k 0k 0k
Statutory Sick Pay 181k 182k 182k 182k 182k 183k 183k
Sure Start Maternity Grant 26k 26k 26k 26k 26k 26k 26k
Bereavement Support Payment 98k 98k 98k 98k 98k 99k 99k
Widowed Parent's Allowance 0k 0k 0k 0k 0k 0k 0k
Tax-Free Childcare 1,043k 1,027k 1,014k 1,009k 1,011k 1,009k 993k
Extended childcare entitlement 795k 800k 796k 797k 798k 798k 792k
Universal childcare entitlement 1,071k 1,072k 1,072k 1,073k 1,076k 1,079k 1,074k
Targeted childcare entitlement 165k 156k 154k 154k 155k 155k 150k
Childcare Offer for Wales 39k 39k 39k 39k 39k 39k 39k
Care to Learn 0k 0k 0k 0k 0k 0k 0k
Childcare Grant 0k 0k 0k 0k 0k 0k 0k
Parents' Learning Allowance 98k 98k 98k 99k 99k 99k 99k
Adult Dependants' Grant 18k 18k 12k 12k 12k 12k 12k
Travel Grant 0k 0k 0k 0k 0k 0k 0k
Disabled Students' Allowance suppressed suppressed suppressed suppressed suppressed suppressed suppressed
16 to 19 Bursary Fund 0k 0k 0k 0k 0k 0k 0k
Cost-of-living support payment 0k 0k 0k 0k 0k 0k 0k
Energy Bills Rebate 0k 0k 0k 0k 0k 0k 0k
Household Energy Payment 0k 21,065k 0k 0k 0k 0k 0k
Energy Price Guarantee subsidy 0k 0k 0k 0k 0k 0k 0k
Basic income 0k 0k 0k 0k 0k 0k 0k
Disability basic income 0k 0k 0k 0k 0k 0k 0k
Government balance, each component counted once: head levels
Measure (head) 2025-26 2026-27 2027-28 2028-29 2029-30 2030-31 2031-32
Government receipts, each component once £884.82bn £927.25bn £972.82bn £1,008.07bn £1,046.18bn £1,083.32bn £1,116.48bn
Government spending £529.29bn † £545.33bn † £550.40bn † £559.11bn † £566.74bn † £575.46bn † £583.07bn †
Government balance, each receipt once £355.53bn † £381.92bn † £422.41bn † £448.95bn † £479.44bn † £507.86bn † £533.41bn †
Benefits in household_benefits but not in gov_spending £0.00bn £0.00bn £0.00bn £0.00bn £0.00bn £0.00bn £0.00bn
Model totals: head levels
Measure (head) 2025-26 2026-27 2027-28 2028-29 2029-30 2030-31 2031-32
gov_tax £884.82bn £927.25bn £972.82bn £1,008.07bn £1,046.18bn £1,083.32bn £1,116.48bn
household_tax £491.95bn £520.39bn £551.18bn £575.98bn £600.96bn £626.66bn £648.39bn
pre_budget_change_household_tax £484.13bn £512.26bn £542.79bn £566.92bn £591.68bn £617.12bn £638.58bn
gov_spending £529.29bn † £545.33bn † £550.40bn † £559.11bn † £566.74bn † £575.46bn † £583.07bn †
household_benefits £529.29bn † £545.33bn † £550.40bn † £559.11bn † £566.74bn † £575.46bn † £583.07bn †
gov_balance £355.53bn † £381.92bn † £422.41bn † £448.95bn † £479.44bn † £507.86bn † £533.41bn †
Household income totals: head levels
Measure (head) 2025-26 2026-27 2027-28 2028-29 2029-30 2030-31 2031-32
Household market income £1,637.96bn £1,702.77bn £1,757.35bn £1,806.41bn £1,855.97bn £1,912.43bn £1,970.44bn
Household net income £1,636.63bn † £1,687.51bn † £1,715.12bn † £1,747.12bn † £1,778.28bn † £1,816.57bn † £1,859.19bn †
Household net income (HBAI definition) £1,449.51bn £1,499.52bn £1,530.52bn £1,564.80bn £1,597.47bn £1,635.15bn £1,676.12bn
Population: head levels
Measure (head) 2025-26 2026-27 2027-28 2028-29 2029-30 2030-31 2031-32
People 69,245k 69,383k 69,473k 69,592k 69,738k 69,912k 70,080k
Benefit units 35,110k 35,181k 35,226k 35,286k 35,360k 35,449k 35,534k
Households 31,046k 31,108k 31,149k 31,201k 31,267k 31,345k 31,420k
Poverty rates: head levels
Measure (head) 2025-26 2026-27 2027-28 2028-29 2029-30 2030-31 2031-32
Absolute poverty, before housing costs: everyone 16.2% 15.4% 16.3% 16.2% 16.4% 16.4% 16.5%
Absolute poverty, before housing costs: children 24.6% 21.8% 23.0% 22.7% 22.9% 23.0% 23.2%
Absolute poverty, before housing costs: working-age adults 14.0% 13.7% 14.6% 14.6% 14.7% 14.7% 14.9%
Absolute poverty, before housing costs: pensioners 13.7% 13.4% 14.0% 13.9% 14.0% 14.0% 13.9%
Absolute poverty, after housing costs: everyone 21.5% 21.0% 22.0% 22.5% 22.8% 23.0% 23.4%
Absolute poverty, after housing costs: children 33.1% 31.2% 32.1% 32.4% 32.8% 33.2% 34.0%
Absolute poverty, after housing costs: working-age adults 19.9% 19.8% 20.8% 21.5% 21.8% 22.0% 22.2%
Absolute poverty, after housing costs: pensioners 12.7% 12.4% 13.2% 13.2% 13.3% 13.4% 13.6%
Relative poverty, before housing costs: everyone 16.9% 15.9% 16.3% 16.2% 16.3% 16.2% 16.5%
Relative poverty, before housing costs: children 25.7% 22.6% 23.0% 22.7% 22.8% 22.6% 23.2%
Relative poverty, before housing costs: working-age adults 14.4% 14.0% 14.6% 14.6% 14.7% 14.6% 14.9%
Relative poverty, before housing costs: pensioners 14.5% 14.1% 14.0% 13.8% 13.8% 13.9% 13.9%
Relative poverty, after housing costs: everyone 21.4% 20.9% 21.2% 21.3% 21.3% 21.5% 21.7%
Relative poverty, after housing costs: children 32.9% 31.0% 31.1% 31.0% 31.0% 31.2% 31.7%
Relative poverty, after housing costs: working-age adults 19.8% 19.7% 20.2% 20.4% 20.4% 20.6% 20.8%
Relative poverty, after housing costs: pensioners 12.5% 12.4% 12.2% 11.8% 11.7% 11.8% 12.1%
People in poverty: head levels
Measure (head) 2025-26 2026-27 2027-28 2028-29 2029-30 2030-31 2031-32
Absolute poverty, before housing costs: everyone 11,246k 10,704k 11,333k 11,298k 11,407k 11,448k 11,584k
Absolute poverty, before housing costs: children 3,676k 3,270k 3,455k 3,406k 3,441k 3,463k 3,509k
Absolute poverty, before housing costs: working-age adults 5,947k 5,858k 6,277k 6,330k 6,387k 6,400k 6,490k
Absolute poverty, before housing costs: pensioners 1,624k 1,576k 1,602k 1,562k 1,579k 1,585k 1,584k
Absolute poverty, after housing costs: everyone 14,869k 14,565k 15,263k 15,690k 15,910k 16,094k 16,373k
Absolute poverty, after housing costs: children 4,940k 4,671k 4,814k 4,873k 4,931k 5,015k 5,145k
Absolute poverty, after housing costs: working-age adults 8,424k 8,435k 8,943k 9,324k 9,474k 9,559k 9,683k
Absolute poverty, after housing costs: pensioners 1,504k 1,460k 1,505k 1,493k 1,505k 1,520k 1,545k
Relative poverty, before housing costs: everyone 11,694k 11,032k 11,318k 11,297k 11,348k 11,350k 11,584k
Relative poverty, before housing costs: children 3,847k 3,389k 3,454k 3,406k 3,427k 3,414k 3,509k
Relative poverty, before housing costs: working-age adults 6,128k 5,990k 6,270k 6,330k 6,356k 6,359k 6,490k
Relative poverty, before housing costs: pensioners 1,719k 1,652k 1,594k 1,561k 1,565k 1,576k 1,584k
Relative poverty, after housing costs: everyone 14,800k 14,518k 14,756k 14,791k 14,867k 15,002k 15,214k
Relative poverty, after housing costs: children 4,916k 4,649k 4,661k 4,651k 4,673k 4,701k 4,796k
Relative poverty, after housing costs: working-age adults 8,396k 8,414k 8,699k 8,813k 8,870k 8,959k 9,049k
Relative poverty, after housing costs: pensioners 1,488k 1,455k 1,395k 1,326k 1,324k 1,342k 1,369k
Inequality: head levels
Measure (head) 2025-26 2026-27 2027-28 2028-29 2029-30 2030-31 2031-32
Gini coefficient, equivalised HBAI income before housing costs 0.3076 0.3049 0.3055 0.3054 0.3059 0.3064 0.3080
Mean household net income in each side's own deciles: head levels
Measure (head) 2025-26 2026-27 2027-28 2028-29 2029-30 2030-31 2031-32
Decile 1: mean household_net_income per household £17,748 † £17,980 † £17,927 † £18,181 † £18,318 † £18,538 † £18,742 †
Decile 2: mean household_net_income per household £28,029 † £29,037 † £28,754 † £28,997 † £29,258 † £29,676 † £30,171 †
Decile 3: mean household_net_income per household £34,252 † £35,426 † £36,069 † £36,548 † £37,157 † £37,774 † £38,103 †
Decile 4: mean household_net_income per household £38,926 † £40,769 † £41,716 † £42,763 † £43,387 † £44,167 † £44,499 †
Decile 5: mean household_net_income per household £43,346 † £45,603 † £46,054 † £47,001 † £47,755 † £48,626 † £50,309 †
Decile 6: mean household_net_income per household £47,933 † £49,175 † £50,879 † £52,032 † £52,922 † £53,942 † £54,719 †
Decile 7: mean household_net_income per household £55,672 † £56,650 † £57,493 † £57,674 † £58,791 † £59,706 † £61,106 †
Decile 8: mean household_net_income per household £68,786 † £70,811 † £71,870 † £73,483 † £73,890 † £75,325 † £77,181 †
Decile 9: mean household_net_income per household £78,891 † £81,011 † £80,860 † £82,646 † £85,464 † £86,940 † £89,508 †
Decile 10: mean household_net_income per household £116,864 † £120,162 † £124,545 † £126,420 † £125,756 † £128,269 † £130,694 †
Standard reform costings (change in gov_balance): head levels
Measure (head) 2025-26 2026-27 2027-28 2028-29 2029-30 2030-31 2031-32
Raise basic rate by 1pp £6.41bn £6.66bn £6.63bn £6.85bn £7.03bn £7.25bn £7.47bn
Raise higher rate by 1pp £3.61bn £3.87bn £4.00bn £4.22bn £4.44bn £4.71bn £4.83bn
Raise personal allowance by ~800GBP/year £-3.82bn £-3.93bn £-4.01bn £-4.05bn £-4.11bn £-4.24bn £-1.95bn
Raise child benefit by 25GBP/week per additional child £-1.99bn £-1.75bn £-1.55bn £-1.38bn £-1.30bn £-1.18bn £-1.07bn
Reduce Universal Credit taper rate to 20% £-20.83bn £-21.38bn £-21.81bn £-22.02bn £-22.37bn £-22.77bn £-22.96bn
Raise Class 1 main employee NICs rate to 10% £10.89bn £11.30bn £11.71bn £12.01bn £12.31bn £12.62bn £13.00bn
Raise VAT standard rate by 2pp £24.17bn £24.97bn £25.86bn £26.46bn £27.07bn £27.68bn £28.31bn
Raise additional rate by 3pp £2.90bn £3.15bn £3.22bn £3.41bn £3.61bn £3.85bn £4.14bn
Raise the Universal Credit standard allowance by 10% £-3.06bn £-3.23bn £-3.30bn £-3.40bn £-3.48bn £-3.53bn £-3.55bn
Raise the State Pension by 10% £-7.76bn £-7.99bn £-8.22bn £-8.44bn £-8.79bn £-8.52bn £-8.86bn
Standard reforms: change in each reform's target: head levels
Measure (head) 2025-26 2026-27 2027-28 2028-29 2029-30 2030-31 2031-32
Raise basic rate by 1pp: change in income_tax £6.55bn £6.86bn £6.79bn £7.00bn £7.20bn £7.44bn £7.66bn
Raise higher rate by 1pp: change in income_tax £3.61bn £3.92bn £4.01bn £4.23bn £4.45bn £4.72bn £4.84bn
Raise personal allowance by ~800GBP/year: change in income_tax £-3.94bn £-4.07bn £-4.14bn £-4.18bn £-4.22bn £-4.40bn £-1.76bn
Raise child benefit by 25GBP/week per additional child: change in child_benefit £2.33bn £2.14bn £1.95bn £1.76bn £1.65bn £1.52bn £1.40bn
Reduce Universal Credit taper rate to 20%: change in universal_credit £20.79bn £21.36bn £21.84bn £22.07bn £22.39bn £22.80bn £23.01bn
Raise Class 1 main employee NICs rate to 10%: change in national_insurance £11.15bn £11.63bn £12.00bn £12.29bn £12.61bn £12.94bn £13.31bn
Raise VAT standard rate by 2pp: change in vat £23.98bn £24.77bn £25.66bn £26.24bn £26.85bn £27.46bn £28.07bn
Raise additional rate by 3pp: change in income_tax £2.90bn £3.15bn £3.22bn £3.42bn £3.62bn £3.86bn £4.12bn
Raise the Universal Credit standard allowance by 10%: change in universal_credit £3.06bn £3.22bn £3.32bn £3.41bn £3.48bn £3.54bn £3.55bn
Raise the State Pension by 10%: change in state_pension £10.68bn £11.17bn £11.28bn £11.60bn £12.03bn £12.46bn £12.96bn

@vahid-ahmadi

Copy link
Copy Markdown
Collaborator

Review of #2670 at f5deeeb25d (first round from me). Fixes #1800.

The fix works: the four structural switches now follow the year being calculated, and a time-limited switch stops at its end date. One existing test on main has to change with it, which is why CI is red. I'd also like the Core floor raised and the aggregate impact job re-run before this leaves draft.

What I checked

Household probe, couple with one child in England (HITC: £50,000 + £30,000; Marriage Allowance: £80,000 + £0), Scenario(applied_before_data_load=True) unless marked, years 2026, 2027, 2028, 2033, 2034:

Switch Base 4ed874f23 Head f5deeeb25d
cb_hitc_household "2025" £1,406 / 1,455 / 1,486 / 1,624 / 1,656 (on in every year) 0 in every year
cb_hitc_household "2027" (scenario and reform dict) 0 in every year £1,455 in 2027 only
cb_hitc_household "2033" 0 in every year £1,624 in 2033 only, 0 in 2034
cb_hitc_household 2027-01-01.2028-12-31 0 in every year £1,455, £1,486 in 2027-28 only
expanded_ma.remove_income_condition "2027" 0 in every year £1,260 in 2027 only
Issue reproducer, 2026-01-01.2026-12-31, reform dict 0 £1,260 in 2026 only

So base samples the switch once at 2025 and applies the result to every year, as #1800 says. Head reads it per year, and the "2033" case shows a switch inside the projected (uprating) years ends at its stop and does not carry into 2034. All five routed variables (CB_HITC, marriage_allowance, meets_marriage_allowance_income_conditions, net_income, scottish_child_payment) are YEAR variables, so active(root, period) reads the right annual value.

The new test file fails on base (46 of 53 fail, with head's test file copied onto 4ed874f23) and passes at head (53 of 53).

Findings

  1. must: test_child_benefit_charge_rounding_properties.py::test_the_household_based_reform_charges_on_combined_income fails at head (CI shard 2/5, and locally: assert 0.0 == 1406). The test is what is wrong, not the fix. HOUSEHOLD_BASED (:114-117) keys the switch {"2025": True} and the test calculates 2026. dated_reforms.py documents a bare year on parameter_changes as that fiscal year only, so 0 in 2026 is now the right answer; the test passed on main only because of the bug this PR fixes. Please key it "2026" (or a start.stop range covering the years the file calculates) and update the comment at :112-113, which explains the old build-time sampling. The other test using HOUSEHOLD_BASED (:142) still passes at head, but now without the reform: a single parent's baseline charge is the same £1,391, so it no longer tests anything. The same key fix restores it. I found no other test keying one of these switches by a bare year. The PR body's "240 selected Python tests" did not include this file; the full shard did.

    This is also a behaviour change for callers: a single-year key on any of these trigger paths now means one year, not every year. Worth one sentence in the changelog fragment.

  2. should: raise the Core floor. pyproject.toml:27 still allows policyengine-core>=3.32.27, but the PR uses _calculation_frames, _note_input_change, _value_signature (policyengine_core.simulations.simulation), store_history.next_sequence_number and Holder._stores_user_input, _record_store, _record_input_storage, _evict_fast_cache, _storage_period. None of these is in 3.32.29 (the last 3.32 tag); all are in 3.33.0 and still in 3.33.12. The imports sit inside method bodies, so an install on 3.32.x would fail only at run time, and only once reported-benefit inputs are installed. >=3.33.0 at least.

  3. should: re-run Aggregate impact. It was cancelled at the 60-minute mark (11:19 to 12:19): base measured 220 figures in 1,760 s, then head wrote no result. Three other PRs' runs today were cancelled at the same mark and the successful ones take 57-60 min, so this looks like the workflow timeout rather than this PR. It still needs a result before this leaves draft, since the PR changes how every structural reform is built. If head times out twice, the per-calculate _reported_benefit_context wrapper is the first thing I'd time, even though it should do nothing when no reported inputs are installed.

  4. nit: the changelog's second sentence is imperative ("Preserve original formulas..."), where the first is declarative. Something like "Original formulas and genuine supplied inputs apply outside each reform interval."

  5. nit: Structural-trigger parameters are sampled at a fixed instant, so reforms gating structural changes can silently fail to activate #1800 also points at the same pattern in policyengine-us (DEFAULT_START_DATE). Fine to close Structural-trigger parameters are sampled at a fixed instant, so reforms gating structural changes can silently fail to activate #1800 here; a US issue might be worth opening separately.

Question (for Max, not a finding): about 520 of the 598 lines added to simulation.py exist to make disable_simulated_benefits period-aware (the reported-input ledger, observers, replay rebinding), and they depend on the Core internals in 2. The formula-based reforms need only apply_period_aware_reform (about 90 lines in reforms.py). One alternative is to keep that one diagnostic switch build-time and document that its key must cover the dataset year, or to split it into its own PR. That is a maintenance-cost call for Max, so I am not making it a finding.

Verdict: not ready to leave draft yet. 1 must change; 2 and a green 3 should come with it. Comment only, since this is a draft.

What I ran: in a fresh venv (Python 3.13, Core 3.33.2 from the lock), one process, no -n: test_structural_reform_periods.py and test_child_benefit_charge_rounding_properties.py at head (61 passed, 1 failed, the one in 1); head's test_structural_reform_periods.py on base (7 passed, 46 failed); the probe above on base and head. CI at head: 4 of 5 Python shards and YAML green, shard 2/5 fails on 1. I did not run the full suite. I did not read the 786-line test file beyond its test names and parametrisations, and I did not trace the _calculate / _invalidate_all_caches observer logic line by line. I did not run disable_simulated_benefits on survey data, so I have not checked the reported-only mode across years myself beyond the new tests.

🤖 Generated with Claude Code

@juaristi22
juaristi22 force-pushed the fix-1800-structural-trigger-periods branch from f5deeeb to a63f18e Compare October 26, 2026 15:52
@juaristi22

Copy link
Copy Markdown
Collaborator Author

Pushed commit a63f18e6 addresses the concrete review requests:

  • The household-based fixture enables the reform in 2026, matching both tests. Its comment now describes that setup.
  • pyproject.toml and uv.lock require Core >=3.33.2; the lock retains Core 3.33.2.
  • The changelog states that bare-year switch keys apply only to that year and describes the behavior outside each interval.

The rebase onto 944238d2 retains the main branch’s ISA, BSP and input-refresh behavior alongside the reported-input observer. Four new regression functions cover 12 parameterized cases for cleanup failures, refusal ordering, BSP dispatch and ISA clone isolation. The original assertions remain unchanged.

Scoped Ruff formatting and lint passed. Local model tests, including the 12 new cases, have not run locally. Matching-head GitHub CI is underway, and the Aggregate impact result remains required. I am keeping this PR in draft until the Aggregate impact check and all applicable checks succeed. I have not opened a separate US issue.

@juaristi22
juaristi22 marked this pull request as ready for review October 26, 2026 17:37
@vahid-ahmadi

Copy link
Copy Markdown
Collaborator

Round 2 at a63f18e67. Round 1 was at f5deeeb25d; the branch has since been rebased onto 944238d26.

Every round 1 finding is resolved, CI is green and Aggregate impact passes. The one thing still open is the design question from round 1, which needs an answer from @MaxGhenis before I approve. That point has got bigger since round 1.

Status of round 1 findings

  1. must (rekey the HITC test): fixed. test_child_benefit_charge_rounding_properties.py:114-117 now keys the switch {"2026": True} and the comment at :112-113 matches. Both tests that use it (:139-148) now run with the reform on, so the single-parent test checks something again. The changelog (changelog.d/1800.fixed.md) now says that a bare-year key applies to that year only.
  2. should (Core floor): fixed. pyproject.toml:27 is policyengine-core>=3.33.2 and the lock still pins 3.33.2. All the Core internals I listed are in 3.33.2.
  3. should (Aggregate impact): fixed. The run at this head passes against current main 5b94537f61: nothing broken, nothing flagged, and no household's net income changes in any year. Head took 1,892 s against 1,934 s for base, so the per-calculate wrapper costs nothing measurable.
  4. nit (changelog wording): fixed.
  5. nit (US issue): not opened. That's fine; it was optional.

Still open

  1. should, for Max: should the disable_simulated_benefits handling be split out? The round 1 question still applies, and the branch now carries more of this code. simulation.py is now +638/-54 against main, up from +598. Of those added lines, 499 are a single block holding the reported-input ledger, observers and replay (simulation.py:573-1071), and it uses Core internals (_calculation_frames, _note_input_change, _value_signature, next_sequence_number, Holder privates). The rebase onto main's ISA, BSP and input-refresh work added two things:

    • set_input now catches every BaseException from each cleanup step and re-raises the first, restoring its traceback, cause and context (:1136-1183).
    • Four new mock tests (test_structural_reform_periods.py:789-1049, 12 cases) pin the order of those internals, not modelled outcomes.

    All of this has to be kept working with each Core release. The formula-based switches need only apply_period_aware_reform in reforms.py. The options are the same as in round 1: merge as is, split the reported-only mode into its own PR, or keep that one switch build-time and document that its key must cover the dataset year. This is a maintenance-cost call, so I'm leaving it to Max and not approving until he answers. If he is happy to merge as is, I have no other findings and will approve.

New findings: none.

Verdict: no open must, but one should (6) is waiting on Max, so I am not approving or adding this to the merge queue at this head. If Max says merge as is, I will check CI again and approve at a63f18e67, since CI and Aggregate impact are already green there.

What I ran: I used a fresh worktree and venv (Python 3.13, Core 3.33.2 from the lock, dev extras) and ran one process with no -n and no full microsimulation.

  • At head: test_structural_reform_periods.py and test_child_benefit_charge_rounding_properties.py, 74 passed.
  • Head's test_structural_reform_periods.py against base 944238d26's simulation.py and reforms/: 56 failed, 9 passed. Leaving out the 12 new cases, which test head-only internals, the original 53 tests split exactly as in round 1: 46 fail on old code and all 53 pass at head. So the year-keyed fix still holds after the rebase.
  • CI at a63f18e67: every check is green, including all 5 Python shards, YAML and the release tests.

I did not run the full suite locally. I read the new tests and the set_input and _calculate changes, but I did not re-trace the observer and replay logic line by line.

🤖 Generated with Claude Code

@vahid-ahmadi

Copy link
Copy Markdown
Collaborator

Round 3 at 808692bbc. Round 2 was at a63f18e67. Since then there are two merges of main (3f67112c8, 808692bbc) and no other commits. I checked what they change, re-ran the PR's tests, and probed how the structural switches choose their years on the reform-dict, Scenario and policyengine.py routes.

What the merges changed

Against merge base 0080274d7, the PR's diff is line-for-line the same as it was against 944238d26 at round 2 in every file except test_structural_reform_periods.py: simulation.py, all five reform files, the changelog fragment, pyproject.toml and uv.lock. The only new material is test code:

  • test_structural_reform_periods.py:1013-1057: the clone test now also checks that the UK clone copies _savings_income_projection itself, rather than relying on Core.
  • :1060-1108: a new test (2 cases) that build_from_populations drops the old reported inputs and keeps the donor's supplied-versus-model provenance.

Both cover main's clone and population code meeting this PR's ledger, and both pass. The head also merges cleanly with current main (1d4d020aa, 63 commits further on).

Earlier items

  1. must (rekey the HITC test): fixed at round 2, unchanged (test_child_benefit_charge_rounding_properties.py:112-116).
  2. should (Core floor): fixed, pyproject.toml:27 >=3.33.2. The lock now resolves Core 3.33.12, which is what I ran.
  3. should (Aggregate impact): passes at this head (run 41522709392, base 0080274d78 against the job's test merge d213b07e39): 0 broken, 0 moves flagged, and 1 check failing on both sides, which is not this PR's. One caveat: its standard reform costings don't switch on any of the four structural reforms, so it shows the baseline is untouched but doesn't exercise the routing.
  4. nit (changelog): fixed, unchanged.
  5. nit (US issue): not opened, which was optional.
  6. should, for @MaxGhenis (split out disable_simulated_benefits's reported-input ledger?): still open, and still the only thing between this PR and merge. Nothing in these merges makes it smaller: the 499-line block is unchanged and the new tests add more pinning of private state (_reported_benefit_requests, _reported_benefit_observers, _reported_benefit_observer_error).

How the switches choose their years (checked at this head)

create_structural_reforms_from_parameters is still called once, at construction (simulation.py:430). Each create_period_aware_* installs its route only if the switch is true at any point in its finite history (finite_parameter_activation, reforms.py:35-62). After that, apply_period_aware_reform (reforms.py:70-115) picks the contributed formula or the original one on each calculate from parameters(period). Household probe: a couple, £50,000 + £30,000 with one child for HITC, £80,000 + £0 for Marriage Allowance:

Key Base 0080274d7 Head
HITC 2026-01-01.2100-12-31 (policyengine.py and app style) 0 in every year 0 in 2025, then £1,406 / 1,455 / 1,505 in 2026-28 and £1,553 in 2030
HITC 2026-04-06.2027-04-05 0 in every year £1,406 in 2026 only
HITC "2027", queried 2030, 2027, 2026, 2028, 2025 in that order 0 in every year £1,455 in 2027 only
HITC "2026" + expanded MA "2027" together 0 / 0 HITC in 2026 only, MA £1,260 in 2027 only
Scenario with HITC from 2026, sim.baseline 0 0 in every year (no leak into the baseline)
Expanded MA 2025-01-01.2030-12-31 (policyengine.py's structural_switch contract key), 2026 / 2031 £1,260 / £1,290 (carries on past the stop) £1,260 / 0
SCP in_effect from 2031, Scottish child under 1, 2031 £1,672 (the 5-year scan misses it) £2,254
SCP in_effect from 2028, 2028 £2,122 £2,122

So a one-year request stays in its year on each side, the order of queries doesn't matter, two reforms with different years don't interfere, and the baseline is untouched. A fiscal-year key (6 April to 5 April) lands on that fiscal year because dated_reforms.py annualises at 30 April. policyengine.py's reform_dict_from_parameter_values always writes start.stop keys and hands them to Microsimulation(reform=...), which is the first row. Its own structural_switch contract case checks 2026 only, so it passes on both sides and would not have caught the 2031 leak on main.

Which results move

Default-baseline results don't move: every contrib switch defaults to false, and Aggregate impact agrees. Reform runs move in four ways:

  • HITC household (cb_hitc_household) and the CPS marriage reforms (expanded_ma.*, marriage_neutral_it.*). On main, the switch is sampled once at default_input_period (2025, simulation.py:268). One that starts later is off in every year, which covers any app or policyengine.py run of these reforms starting in 2026 or later (first row). One that is on in 2025 applies in every year, even after its stop (MA row). At head, both follow the key. max_child_age is now read for each year, not once.
  • SCP baby bonus: only activations five or more years after the dataset year change (last row). In years when it is off, the contributed formula and variables/gov/social_security_scotland/scottish_child_payment.py compute the same amount, so switching back to the original formula in those years changes nothing.
  • disable_simulated_benefits from parameters: reported amounts only in active years, where main used them in all ten years once the switch was on in the dataset year. Calling the reform directly keeps the ten-year mode.

I searched the PolicyEngine org for callers. uk-2024-manifestos-comparison keys cb_hitc_household 2026-01-01.2039-12-31, which is exactly the case main gets wrong, but it pins policyengine-uk==2.22.0, so it doesn't move unless it is upgraded. scottish-budget-2026-2027 switches SCP in_effect with Parameter.update after construction. The route is then never installed, on main or at head, so it doesn't move either. For disable_simulated_benefits the only hits outside this repo are parameter-name lists in policyengine-scorecard replay packets, not callers. I found no other published caller of any of the four switches.

New findings: none.

Checked and fine

  • finite_parameter_activation index arithmetic for MA: values[1] != values[6] compares the reform's ma_rate with the baseline's (marriage_tax_reforms.py:300). All of these YAMLs start on 2000-01-01 or earlier, so the first_covered cut-off only matters for keys before 2000.
  • The routed variables are all YEAR, and apply_period_aware_reform refuses a replacement whose entity, period, defined_for, end, uprating or other storage metadata differ.
  • The PR's tests fail on main. With head's test_structural_reform_periods.py run on 0080274d7: 58 failed, 9 passed. Round 2 had 56 failed, 9 passed; the 2 extra failures are the new provenance cases, which test state that only exists at head. At head the two touched test files give 76 passed.

CI at 808692bbc: every check is green, including Aggregate impact, all 7 Test and 7 Release-test Python shards, YAML and the release installs. So the release timeout noted in the body (#2770) didn't recur.

Verdict: no open must or should of mine. The scope decision in 6 is still with Max. If he says merge as is, I have nothing further at this head.

What I ran: a fresh clone and uv sync --frozen --extra dev (Python 3.13, Core 3.33.12), one process, no -n, synthetic households only. I ran test_structural_reform_periods.py and test_child_benefit_charge_rounding_properties.py at head, head's test file against base, and the probe above on base and head. I did not run the full suite or any survey data, and I did not re-trace the observer and replay block, which is unchanged since round 2.

🤖 Generated with Claude Code

@vahid-ahmadi vahid-ahmadi left a comment •

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One new issue at c658df33c, which arrived with the main merges after round 3. The scope question for Max from round 3 is still open and separate.

Expanded MA still applies in years when its switch is off, through marriage_allowance_reduction_at_stake

Main's 6c91a3c added marriage_allowance_reduction_at_stake, and create_expanded_ma_reform now updates it (policyengine_uk/reforms/cps/marriage_tax_reforms.py:105-123, :129). The period-aware wrapper routes only meets_marriage_allowance_income_conditions and marriage_allowance (marriage_tax_reforms.py:349-356). apply_period_aware_reform applies the whole reform (reforms.py:96) and re-routes only those two. So the reform's where(meets_expanded_ma_conditions, 0, ...) formula runs in every year. With the default max_child_age of 0, meets_expanded_ma_conditions is True for everyone (marriage_tax_reforms.py:43). In inactive years, the least-tax share search (utils/income_tax_allocation.py:248, :462-464) then stops weighing the allowance and can pick a share that fails the s.55B rate test.

Running the head on main's SHARE_COUPLE fixture (test_marriage_allowance_cps_switch.py:467), with situation inputs for 2025 and 2026, gives:

reform 2025: at stake / MA / income tax 2026: at stake / MA / income tax
none 252 / 1,260 / 7,248 252 / 1,260 / 7,248
expanded_ma.remove_income_condition: {"2026": True} 0 / 0 / 7,354.625 0 / 1,260 / 7,124.025
same, keyed 2026-01-01.2026-12-31 0 / 0 / 7,354.625 0 / 1,260 / 7,124.025

So in 2025, with the switch off, the couple loses the allowance and pays £106.625 more than with no reform. Adding "marriage_allowance_reduction_at_stake" to the routed tuple gives 252 / 1,260 / 7,248 in 2025 and leaves 2026 unchanged (checked locally).

Suggested changes:

  • Route marriage_allowance_reduction_at_stake with the other two.
  • Add an inactive-year case with SHARE_COUPLE to test_structural_reform_periods.py. The existing cases use couple() (test_structural_reform_periods.py:73), which defaults to £80,000 + £0 with no savings or dividends. For that couple the share of reliefs never decides the allowance, so those cases can't catch this.
  • Consider having apply_period_aware_reform raise when the trial reform updates an existing variable that isn't in names, so the next variable added on main can't leak the same way.

Review drafted with AI assistance and checked against the code at c658df33c.

@juaristi22

Copy link
Copy Markdown
Collaborator Author

Addressed the routing and regression points in your latest review in 70043325b7836ead8a2bbeb3301d7b9cca29839c.

marriage_allowance_reduction_at_stake now joins the other two expanded Marriage Allowance variables in the period-aware routing tuple. Four appended cases use a self-contained SHARE_COUPLE equivalent: dictionary/Scenario × bare-year/calendar-year interval. They check all three outputs against inactive-year and active-reform controls, including repeated, out-of-order calculations.

The four cases first failed on the unchanged production code at the inactive-2025 income-tax assertion, then recorded complete setup/call/teardown PASS after the fix. Validation used Python 3.13.15 and Core 3.34.9. The combined 118-case attempt hit its 2 GiB memory cap after 113 complete PASS observations; it remained incomplete, without JUnit or session-finish evidence.

The fresh five-case complement also exceeded the 2 GiB memory cap during its first case. It contributes no normal-run PASS credit. Validation of the complete 118-case manifest remains incomplete.

I deferred the optional generic replacement guard because it needs separate compatibility coverage for existing replacements, new helper variables and trial/clone behavior across the structural-reform callers. Max's reported-input-ledger scope decision remains open. Formal approval and fresh hosted checks at the published commit remain pending.

@vahid-ahmadi vahid-ahmadi left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Round 5 at 5356a08. Round 4 was at c658df33c. Since then: 70043325b, then a merge of main to resolve the CI shard conflicts.

My round 4 finding is fixed.

  • marriage_allowance_reduction_at_stake now sits in the routed tuple (marriage_tax_reforms.py:354).
  • The four new cases use a SHARE_COUPLE-style couple across reform dictionary and Scenario, with bare-year and calendar-interval keys. They check MA, the reduction at stake and income tax in the inactive and active years, including repeated and out-of-order calculations. That's the case couple() couldn't catch.
  • test_structural_reform_periods.py gives 71 passed locally at the head (about 9 minutes).
  • The merge brings only main's commits. The PR's own files differ from round 4 only by 70043325b.
  • CI is green: Test / Result and Aggregate impact pass. Of the two Fix evidence runs, the cancelled one was superseded by a pass a few seconds later.

Still open, optional: my third round 4 suggestion. apply_period_aware_reform could raise when the trial reform updates an existing variable that isn't in the routed names. reforms.py raises for changed routing metadata (:95) and for a missing formula route (:112), but not for an unrouted update. That is how marriage_allowance_reduction_at_stake leaked when main added it. Without the guard, the next variable main adds to an expanded reform can leak the same way. Fine as a follow-up if you'd rather not widen this PR.

The design question for @MaxGhenis from rounds 1 to 3 is separate and still unanswered as far as I can see. That's the only thing between this PR and approval from my side.

Review drafted with AI assistance and checked against the code at 5356a0887.

This branch has not been deployed

No deployments
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.

Structural-trigger parameters are sampled at a fixed instant, so reforms gating structural changes can silently fail to activate

2 participants