Skip to content

Hold UC trade tax parts in the trading loss netted world - #2849

Merged
juaristi22 merged 2 commits into
mainfrom
claude/uc-trading-loss-property-2jsgw2
Nov 5, 2026
Merged

juaristi22 merged 2 commits into
mainfrom
claude/uc-trading-loss-property-2jsgw2

Conversation

@MaxGhenis

Copy link
Copy Markdown
Collaborator

Fixes #2832

Reproducer: policyengine_uk/tests/test_trading_loss_properties.py::test_means_tests_see_the_loss_only_through_tax

axiom: n/a: test-only change; no rule or parameter value changes

What the code does now

This PR changes no model code. uc_individual_earned_income_before_mif takes uc_income_tax_on_trade and uc_national_insurance_on_trade off the reg 57(2) trade total before the nil floor, and takes the rest of uc_income_tax_on_earnings and uc_national_insurance_on_earnings off employed earnings. uc_income_tax_on_trade takes uc_income_tax_on_earnings_slice with the trade, less the same slice without it, and caps the difference at uc_income_tax_on_earnings. The slice takes earnings as the lowest slice of non-savings income, and counts as other income net_income, less the exclusions, less the earnings. Trade loss relief lowers net_income but not earnings, so the slice takes the relief off the other income above earnings first.

test_means_tests_see_the_loss_only_through_tax compares UC with the loss against a netted world: the same family with the profit cut by min(loss, profit) and the tax and NI deductions held at their with-loss values. Before this change the netted world held the totals on earnings but let the formula recompute the parts in respect of the trade for the cut profit. Where the loss exceeds the profit, that moved the trade's share of the tax from the trade total, where the reg 57(2) step 3 nil floor absorbs it, onto employed earnings. The netted world now holds uc_income_tax_on_trade and uc_national_insurance_on_trade too, so it holds every tax and NI deduction the UC formula reads.

The #2832 family

One person aged 18 in London in 2026: wages £40,000, profit £9,000, private pension £20,000, trading loss £16,000.

With the loss Netted world, totals held (before) Netted world, totals and trade parts held (now)
uc_income_tax_on_earnings 7,286.00 7,286.00 7,286.00
uc_income_tax_on_trade 1,800.00 0.00 1,800.00
uc_national_insurance_on_earnings 2,194.40 2,194.40 2,194.40
uc_national_insurance_on_trade 0.00 0.00 0.00
Employed part 32,319.60 30,519.60 32,319.60
Self-employed part (before the floor) 0.00 (-1,800.00) 0.00 (0.00) 0.00 (-1,800.00)
uc_earned_income 32,319.60 30,519.60 32,319.60

Relief of £16,000 leaves net income £53,000 and taxable income £40,430. The slice puts earnings of £49,000 lowest, which leaves £4,000 of other income, so the tax on earnings comes to (40,430 - 4,000) x 20% = £7,286. Without the trade, other income comes to £13,000 and the tax to 27,430 x 20% = £5,486, so the trade bears £1,800. Class 1 comes to 27,430 x 8% = £2,194.40. With the loss, self-employed earnings come to max(0, 9,000 - 9,000 - 1,800) = 0 and employed earnings to 40,000 - 5,486 - 2,194.40 = £32,319.60. The netted world before this change recomputed the trade's part as nil, so all £7,286 came off employed earnings: £30,519.60.

The law

  • UC Regs 2013 reg 57(2): step 2 adds every trade's profit or loss; step 3 deducts the income tax and contributions paid "in respect of any trade", and a nil or negative result makes self-employed earnings nil.
  • UC Regs 2013 reg 55(5)(b): DWP deducts the income tax and primary Class 1 contributions paid "in respect of the employment" from employed earnings.
  • ITA 2007 s. 64 and s. 65: a taxpayer who claims trade loss relief against general income deducts it in calculating net income, at Step 2 of s. 23.
  • ITA 2007 s. 25(2) and (3A): the taxpayer deducts reliefs in the way that gives the greatest reduction in liability, and from income other than property, savings and dividend income first.

None of these says which non-savings income a trade loss relieves when UC splits one tax bill between the employment and the trade. Employment, trade and pension income share the same rate bands, so s. 25(2) does not choose between them.

Readings weighed

uc_earned_income with the loss, for the #2832 family (loss £16,000, which exceeds the profit) and the same family with a loss of £4,000:

Reading Loss £16,000 Loss £4,000
A (the model): the trade bears the tax on its own profit; the relief comes off other non-savings income first 32,319.60 35,519.60
B: the trade bears the tax on the trades' net result after step 2; the relief comes off the trades first, then other income 32,319.60 36,319.60
B': as B, but relief left after the trades comes off the employment before the pension 33,719.60 36,319.60
The test's old netted world (totals held, trade parts recomputed) 30,519.60 35,519.60

The old netted world matches no reading for the #2832 family. Readings A and B agree there, because the step 3 nil floor absorbs the £1,800 that reading A puts on the trade. They differ by £800 (20% of the loss) for the £4,000 family. These provisions leave both readings defensible, so this change follows the convention that uc_income_tax_on_earnings_slice states in policyengine_uk/utils/uc_income_tax.py (earnings form the lowest slice, so tax on other income never comes off earnings), fixes the test and leaves the model alone. A comment on #2832 sets out reading B, its households and what it would change.

Invariant

Invariant 4 in the test's docstring now says that UC, its benefit cap earnings test and the capped award with the loss equal the same family with the other trades' profits cut by the loss and every tax and NI deduction the UC formula reads held at its with-loss value: the totals on earnings and the parts of them in respect of the trade. The person pays those deductions with the loss, and the parts record the model's split of that payment between the employment and the trade; no loss rule sets them.

Tests

  • @example on test_means_tests_see_the_loss_only_through_tax pins the Trading-loss property test fails when a loss wipes out a profit beside a private pension (UC earned income) #2832 family, with the arithmetic in a comment.
  • test_trading_loss_properties.py: 12 passed, both on this branch and run against current main's code.
  • test_uc_earned_income_before_work_allowance_properties.py: 4 passed.
  • YAML under policyengine_uk/tests/policy/baseline/finance/benefit/family/universal_credit/income: 174 passed.
  • policyengine_uk/tests/code_health: 3,089 passed. Ruff format, ruff check, ruff F811/F821 and git diff --check: clean.
  • On main, the test with CI's settings but derandomize off fails for 1 of 20 Hypothesis seeds (seed 2584); with this change, all 20 pass. With CI's own settings (derandomize=True) the seed has no effect and main passes.
  • Mutants, each made alone and run against main's code: holding only the totals fails the pinned example (uc_earned_income 32,319.60 against 30,519.60); leaving the profit uncut in the netted world fails the pinned example (32,319.60 against 39,519.60) and four other explicit examples.
  • Search for other counterexamples: four runs of 250 examples each (seeds 7771 to 7774, derandomize off, otherwise CI's settings), 1,000 generated families in all, against main's code with this change. All passed; no new counterexample.

🤖 Generated with Claude Code

claude and others added 2 commits November 2, 2026 19:48
The netted world in test_means_tests_see_the_loss_only_through_tax held
UC's tax and NI totals on earnings at their with-loss values but let the
parts in respect of the trade be recomputed for the cut profit. For a
loss larger than the profit beside a private pension, that moved the
trade's share of the tax onto employed earnings. Hold both parts, pin the
minimised family from #2832 and restate invariant 4.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01LwQq6HiQgbqpFzJ8CLCXuP
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@github-actions

github-actions Bot commented Nov 3, 2026

Copy link
Copy Markdown
Contributor

Aggregate impact on certified data: pass

Base 52b30809ff against head 78192e71c3, 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

Standard reform costings (change in gov_balance)

Measure 2025-26 2026-27 2027-28 2028-29 2029-30 2030-31 2031-32
Raise Class 1 main employee NICs rate to 10% 0 0 0 0 0 suppressed suppressed
Raise additional rate by 3pp 0 0 0 0 0 suppressed suppressed

The report suppresses a reform's costing and target change in these years, for the reasons below (privacy.py):

  • Raise Class 1 main employee NICs rate to 10%, 2030-31 to 2031-32 (base and head): the reform changes income_tax in fewer than 10 records.
  • Raise additional rate by 3pp, 2030-31 to 2031-32 (base and head): the reform changes universal_credit in fewer than 10 records.

Standard reforms: change in each reform's target

Measure 2025-26 2026-27 2027-28 2028-29 2029-30 2030-31 2031-32
Raise Class 1 main employee NICs rate to 10%: change in national_insurance 0 0 0 0 0 suppressed suppressed
Raise additional rate by 3pp: change in income_tax 0 0 0 0 0 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.

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 £-53,888,684 in total; 2026-27: 76 units below zero, a weighted £-55,777,260 in total; 2027-28: 76 units below zero, a weighted £-57,727,917 in total
Counted-once check

Each of 92 components was raised by £1 per unit in 2026-27, and every head of its totals was read 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 head that breaks a rule is measured again twice: with every other head held at its baseline value, and with every other head held at its value after the first £1 while the component rises again. It fails where either still shows the response. 0 failed; 0 were skipped.

  • 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 52b30809ff uk 2.172.0 (files f8400aea019e), core 3.34.1, py 3.13.18 aarch64 18199314be15 7cb61324a46b 2113.67s
head #2849 merged into main 78192e71c3 uk 2.172.0 (files f8400aea019e), core 3.34.1, py 3.13.18 aarch64 18199314be15 7cb61324a46b 2118.28s

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.46bn £315.23bn £335.82bn £351.28bn £366.96bn £385.36bn £400.00bn
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 £249.37bn £256.87bn £266.33bn £272.70bn £278.97bn £285.24bn £291.59bn
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.49bn £132.99bn £136.66bn £140.42bn
Pension Credit £6.66bn £7.03bn £7.29bn £7.48bn £7.60bn £7.84bn £8.03bn
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.48bn £80.52bn £82.95bn £84.96bn £86.11bn £87.61bn £88.21bn
Housing Benefit £8.56bn £8.89bn £9.23bn £9.46bn £9.69bn £9.99bn £10.27bn
Council Tax Reduction £2.07bn £2.20bn £2.31bn £2.45bn £2.58bn £2.72bn £2.86bn
Employment and Support Allowance (income-related) £0.79bn £0.82bn £0.84bn £0.86bn £0.88bn £0.90bn £0.92bn
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
Carer's Allowance Supplement (Scotland) £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.19bn £16.82bn £17.39bn £18.00bn £18.39bn £18.84bn £19.25bn
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,486k 1,480k 1,472k 1,452k 1,450k 1,455k 1,464k
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,342k 6,347k 6,336k 6,297k 6,292k 6,271k 6,223k
Housing Benefit 1,249k 1,245k 1,244k 1,227k 1,227k 1,229k 1,232k
Council Tax Reduction 3,176k 3,195k 3,200k 3,214k 3,224k 3,235k 3,242k
Employment and Support Allowance (income-related) 71k 71k 71k 71k 71k 71k 71k
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
Carer's Allowance Supplement (Scotland) 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,123k 8,120k 8,120k 8,130k 8,145k 8,161k 8,178k
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 £892.00bn £934.66bn £980.50bn £1,015.93bn £1,054.24bn £1,091.56bn £1,124.89bn
Government spending £529.38bn † £545.66bn † £550.77bn † £559.51bn † £567.20bn † £575.95bn † £583.60bn †
Government balance, each receipt once £362.62bn † £389.00bn † £429.74bn † £456.42bn † £487.04bn † £515.61bn † £541.29bn †
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 £892.00bn £934.66bn £980.50bn £1,015.93bn £1,054.24bn £1,091.56bn £1,124.89bn
household_tax £491.97bn £520.41bn £551.21bn £576.01bn £601.00bn £626.70bn £648.42bn
pre_budget_change_household_tax £484.15bn £512.28bn £542.82bn £566.95bn £591.72bn £617.16bn £638.61bn
gov_spending £529.38bn † £545.66bn † £550.77bn † £559.51bn † £567.20bn † £575.95bn † £583.60bn †
household_benefits £529.38bn † £545.66bn † £550.77bn † £559.51bn † £567.20bn † £575.95bn † £583.60bn †
gov_balance £362.62bn † £389.00bn † £429.74bn † £456.42bn † £487.04bn † £515.61bn † £541.29bn †
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.69bn † £1,687.82bn † £1,715.45bn † £1,747.49bn † £1,778.69bn † £1,817.02bn † £1,859.69bn †
Household net income (HBAI definition) £1,449.57bn £1,499.83bn £1,530.86bn £1,565.17bn £1,597.89bn £1,635.60bn £1,676.61bn
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.3% 15.5% 16.4% 16.3% 16.5% 16.5% 16.6%
Absolute poverty, before housing costs: children 24.7% 22.1% 23.3% 22.9% 23.1% 23.2% 23.5%
Absolute poverty, before housing costs: working-age adults 14.1% 13.8% 14.7% 14.7% 14.8% 14.8% 15.0%
Absolute poverty, before housing costs: pensioners 13.7% 13.4% 14.0% 13.8% 13.9% 13.9% 13.9%
Absolute poverty, after housing costs: everyone 21.6% 21.0% 22.0% 22.6% 22.9% 23.1% 23.4%
Absolute poverty, after housing costs: children 33.3% 31.3% 32.3% 32.5% 32.9% 33.4% 34.2%
Absolute poverty, after housing costs: working-age adults 19.9% 19.8% 20.8% 21.6% 21.9% 22.0% 22.3%
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 17.0% 16.0% 16.4% 16.3% 16.4% 16.3% 16.6%
Relative poverty, before housing costs: children 25.9% 22.9% 23.3% 22.9% 23.0% 22.9% 23.5%
Relative poverty, before housing costs: working-age adults 14.5% 14.1% 14.6% 14.7% 14.7% 14.7% 15.0%
Relative poverty, before housing costs: pensioners 14.5% 14.0% 13.9% 13.8% 13.8% 13.9% 13.9%
Relative poverty, after housing costs: everyone 21.4% 21.0% 21.3% 21.3% 21.3% 21.5% 21.7%
Relative poverty, after housing costs: children 33.1% 31.1% 31.2% 31.0% 31.1% 31.2% 31.8%
Relative poverty, after housing costs: working-age adults 19.9% 19.8% 20.2% 20.4% 20.5% 20.6% 20.8%
Relative poverty, after housing costs: pensioners 12.5% 12.4% 12.2% 11.7% 11.7% 11.8% 12.0%
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,278k 10,779k 11,402k 11,365k 11,476k 11,513k 11,651k
Absolute poverty, before housing costs: children 3,688k 3,314k 3,496k 3,445k 3,480k 3,502k 3,549k
Absolute poverty, before housing costs: working-age adults 5,965k 5,893k 6,308k 6,362k 6,420k 6,430k 6,521k
Absolute poverty, before housing costs: pensioners 1,624k 1,572k 1,598k 1,558k 1,576k 1,580k 1,581k
Absolute poverty, after housing costs: everyone 14,944k 14,600k 15,310k 15,721k 15,937k 16,141k 16,426k
Absolute poverty, after housing costs: children 4,975k 4,682k 4,837k 4,888k 4,945k 5,040k 5,179k
Absolute poverty, after housing costs: working-age adults 8,463k 8,461k 8,971k 9,344k 9,491k 9,584k 9,706k
Absolute poverty, after housing costs: pensioners 1,506k 1,457k 1,502k 1,490k 1,501k 1,517k 1,542k
Relative poverty, before housing costs: everyone 11,750k 11,084k 11,388k 11,364k 11,416k 11,415k 11,651k
Relative poverty, before housing costs: children 3,872k 3,423k 3,496k 3,445k 3,466k 3,454k 3,549k
Relative poverty, before housing costs: working-age adults 6,159k 6,013k 6,301k 6,362k 6,389k 6,389k 6,521k
Relative poverty, before housing costs: pensioners 1,720k 1,648k 1,590k 1,557k 1,562k 1,572k 1,581k
Relative poverty, after housing costs: everyone 14,849k 14,552k 14,776k 14,809k 14,874k 15,014k 15,234k
Relative poverty, after housing costs: children 4,942k 4,660k 4,673k 4,663k 4,679k 4,707k 4,806k
Relative poverty, after housing costs: working-age adults 8,426k 8,440k 8,711k 8,823k 8,873k 8,967k 9,062k
Relative poverty, after housing costs: pensioners 1,482k 1,452k 1,392k 1,323k 1,322k 1,339k 1,365k
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.3080 0.3052 0.3058 0.3058 0.3063 0.3069 0.3085
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,681 † £17,997 † £17,915 † £18,152 † £18,307 † £18,531 † £18,717 †
Decile 2: mean household_net_income per household £27,939 † £29,023 † £28,711 † £29,013 † £29,276 † £29,691 † £30,150 †
Decile 3: mean household_net_income per household £34,320 † £35,485 † £36,073 † £36,611 † £37,197 † £37,737 † £38,187 †
Decile 4: mean household_net_income per household £38,933 † £40,687 † £41,723 † £42,727 † £43,334 † £44,132 † £44,432 †
Decile 5: mean household_net_income per household £43,239 † £45,567 † £46,014 † £46,959 † £47,712 † £48,584 † £50,282 †
Decile 6: mean household_net_income per household £47,927 † £49,210 † £50,892 † £51,939 † £52,945 † £53,942 † £54,680 †
Decile 7: mean household_net_income per household £55,662 † £56,571 † £57,442 † £57,670 † £58,729 † £59,657 † £61,082 †
Decile 8: mean household_net_income per household £68,789 † £70,803 † £71,858 † £73,466 † £73,880 † £75,320 † £77,178 †
Decile 9: mean household_net_income per household £78,890 † £81,013 † £80,861 † £82,646 † £85,464 † £86,946 † £89,509 †
Decile 10: mean household_net_income per household £117,005 † £120,339 † £124,742 † £126,632 † £125,971 † £128,600 † £130,938 †
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.49bn
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.80bn £-3.92bn £-3.98bn £-4.04bn £-4.10bn £-4.23bn £-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.77bn £-21.32bn £-21.75bn £-21.99bn £-22.34bn £-22.75bn £-22.94bn
Raise Class 1 main employee NICs rate to 10% £10.89bn £11.30bn £11.71bn £12.01bn £12.31bn suppressed suppressed
Raise VAT standard rate by 2pp £24.89bn £25.71bn £26.63bn £27.24bn £27.87bn £28.50bn £29.14bn
Raise additional rate by 3pp £2.90bn £3.15bn £3.22bn £3.41bn £3.61bn suppressed suppressed
Raise the Universal Credit standard allowance by 10% £-3.06bn £-3.18bn £-3.26bn £-3.35bn £-3.44bn £-3.49bn £-3.50bn
Raise the State Pension by 10% £-7.78bn £-8.01bn £-8.24bn £-8.47bn £-8.82bn £-8.55bn £-8.89bn
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.93bn £-4.07bn £-4.13bn £-4.18bn £-4.22bn £-4.40bn £-1.75bn
Raise child benefit by 25GBP/week per additional child: change in child_benefit £2.33bn £2.14bn £1.94bn £1.76bn £1.65bn £1.52bn £1.40bn
Reduce Universal Credit taper rate to 20%: change in universal_credit £20.74bn £21.31bn £21.78bn £22.04bn £22.37bn £22.78bn £22.99bn
Raise Class 1 main employee NICs rate to 10%: change in national_insurance £11.15bn £11.63bn £12.00bn £12.29bn £12.61bn suppressed suppressed
Raise VAT standard rate by 2pp: change in vat £24.69bn £25.51bn £26.42bn £27.03bn £27.65bn £28.28bn £28.91bn
Raise additional rate by 3pp: change in income_tax £2.90bn £3.15bn £3.22bn £3.42bn £3.62bn suppressed suppressed
Raise the Universal Credit standard allowance by 10%: change in universal_credit £3.06bn £3.19bn £3.28bn £3.37bn £3.43bn £3.49bn £3.51bn
Raise the State Pension by 10%: change in state_pension £10.68bn £11.17bn £11.28bn £11.60bn £12.03bn £12.47bn £12.97bn

@juaristi22 juaristi22 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.

Reviewed cd994ad23f01e42c90c6d760de77d221a4cac7eb. COMPLETE — no findings or material evidence gaps.

The corrected controlled comparison holds both trade tax/NI components alongside the totals, so the loss-netted world isolates the intended loss rule. It preserves the model's stated allocation convention; it does not claim that convention is uniquely required by the legislation.

Validation: 16 focused tests passed. Diagnostics reproduced £32,319.60 for the actual and corrected worlds versus £30,519.60 under the old oracle, and matched all four asserted UC outputs across five families, including four positive final UC awards. The limited UC/ITA source claims were independently checked against five validated official originals. The initial diagnostic-only output-name error was corrected without repeating the passing test suite.

Exact-head CI is green. Approval is deferred because the PR remains a draft; the completed review can be retained when readiness and current-head CI are checked later.

@MaxGhenis
MaxGhenis marked this pull request as ready for review November 3, 2026 17:04

@juaristi22 juaristi22 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.

Approval-only follow-up at unchanged cd994ad23f01e42c90c6d760de77d221a4cac7eb: COMPLETE, no findings or material gaps.

The previously completed code/source review, 16 passing tests and qualified final-UC diagnostics remain valid: head, body, dependencies, runtime and saved artifacts are unchanged. No tests were rerun. The controlled tax-allocation convention remains distinguished from a uniquely statutory allocation.

The PR is now ready; applicable exact-head required checks, activity and source evidence were refreshed before approval.

@juaristi22
juaristi22 added this pull request to the merge queue Nov 5, 2026
Merged via the queue into main with commit 93bc52d Nov 5, 2026
21 checks passed
@juaristi22
juaristi22 deleted the claude/uc-trading-loss-property-2jsgw2 branch November 5, 2026 15:54
@MaxGhenis

Copy link
Copy Markdown
Collaborator Author

Ready for hub review

Verdict: APPROVE WITH NITS at cd994ad23f01e42c90c6d760de77d221a4cac7eb

This PR merged unchanged at that head on 2026-11-05 at 15:54Z (93bc52d1c), after juaristi22 approved it, and #2832 closed with it. So this review covers the merged commit, and each fix below is a follow-up on main. Where the text still lives on main, I give its line at 98381bf49, the tip when I checked. The verdict approves the merged code; the three P2s are follow-ups, not blockers.

The test change is right:

  • The old netted world took tax off employed earnings that, with the loss, the formula leaves in a trade total it floors at nil.
  • The new netted world passes on the head, on its merge with 1d4d020aa and on current main.
  • Every mutant tried that changes how the loss reaches UC earned income fails it.

What needs follow-up is the text, a gap and a hub document:

  • The body and changelog misstate when the old test failed.
  • Invariant 4 says the tax split isn't a loss rule. The split does move with the loss, and no test pins it for anyone with a trading loss.
  • FOLLOWUP.md misdescribes reading A at larger losses. That would mislead the A/B ruling.

As the brief says, no earlier round reviewed this PR, so no findings carry over.

Findings

P1

None.

P2-1. The body and changelog misstate when the old test failed

Where.

  • PR body, "What the code does now", second paragraph: "Where the loss exceeds the profit, that moved the trade's share of the tax from the trade total, where the reg 57(2) step 3 nil floor absorbs it, onto employed earnings."
  • changelog.d/2832.fixed.md:1, released in 2.175.7 as CHANGELOG.md:234: "The test no longer fails when a loss exceeds the profit beside a private pension."

What I ran. A scratch pytest file calls each version's body, test_means_tests_see_the_loss_only_through_tax.hypothesis.inner_test, on the #2832 family with eleven losses. I ran main's test in a clone at 1d4d020aa, and the head's test in the merge of cd994ad23 with 1d4d020aa. Command: uv run --frozen pytest policyengine_uk/tests/test_zz_scratch_2832.py -p no:xdist -p no:cacheprovider -q -rA --tb=line.

Loss main's test: uc_earned_income, with loss vs netted Head's test
4,000, 7,000, 7,200 passed passed
8,000 failed: 32,319.60 vs 31,519.60 passed
9,000 and 16,000 failed: 32,319.60 vs 30,519.60 passed
21,000 failed: 32,319.60 vs 30,719.60 passed
25,000 failed: 32,319.60 vs 31,519.60 passed
28,900 failed: 32,319.60 vs 32,299.60 passed
29,000 and 30,000 passed passed

Why.

  • The move. The old netted world moved tax between the trade and the employment wherever its recomputed trade part differed from the with-loss part. At a loss of 4,000 it put employed earnings at 31,519.60 and the trade at 4,000; with the loss they are 32,319.60 and 3,200.
  • When it matters. That move changes uc_earned_income only where the trade's with-loss tax and NI exceed the profit the loss leaves, so that max_(0, trade) (uc_individual_earned_income_before_mif.py:92) drops part of the tax. Even then, the minimum income floor can lift both worlds to the same figure.
  • The range for this family. It runs from a loss just above 7,200 (9,000 less the trade's 1,800) to just below 29,000. At 29,000 the relief has used up the pension and the profit, and the trade's part falls to nil.
  • So the trigger isn't "a loss exceeds the profit". The old test failed at a loss of 8,000, below the profit, and passed at 29,000 and 30,000, far above it, beside the same pension.
  • Seed 2584. The family that failed main at that seed fits the same rule. Its loss of 19,543.35 exceeds its profit of 18,902.86, and its trade part of 2,975.92 exceeds the nil profit left.

Replacement, body. From "Before this change" to the end of that paragraph:

Before this change the netted world held the totals on earnings but let the formula recompute the income tax part in respect of the trade for the cut profit. Where other non-savings income above earnings absorbs the relief, that moved income tax between the trade and the employment. Where the trade's tax and NI parts then exceed the profit the loss leaves, it lowered the person's UC earned income before the minimum income floor: with the loss, the formula floors the trade total at nil (reg 57(2) step 3), while the netted world takes that tax off employed earnings. For the #2832 family the old test failed from a loss just above £7,200 to just below £29,000: at £8,000, £9,000, £16,000, £21,000, £25,000 and £28,900, but not at £7,200, £29,000 or £30,000. The netted world now holds uc_income_tax_on_trade and uc_national_insurance_on_trade too, so it holds every tax and NI deduction the UC formula reads.

Changelog. github-prs.md says not to edit CHANGELOG.md by hand in an ordinary PR, so I'd leave the released line alone. A corrected sentence 2 for the record on #2832:

The test no longer fails when the tax and NI the model puts on the trade exceed the profit left after the loss, as they can when a private pension absorbs the loss relief.

P2-2. Invariant 4 calls the split "not a loss rule", but the split moves with the loss and no test pins it

Where.

  • Docstring, head lines 41-45 (main 44-48): "Those deductions are what the person pays with the loss, and the parts are the model's split of that payment between the employment and the trade, not a loss rule. Recomputing the trade's part for the cut profit would move tax from the trade, where the step 3 nil floor can absorb it, to the employment, where nothing does."
  • PR body, "Invariant": "no loss rule sets them".
  • PR body, "Tests": "@example on test_means_tests_see_the_loss_only_through_tax pins the Trading-loss property test fails when a loss wipes out a profit beside a private pension (UC earned income) #2832 family, with the arithmetic in a comment."

The split moves with the loss. I swept the loss through a bare Simulation for wages 40,000, profit 9,000 and pension 20,000 (loss_sweep.py). The sweep gives the same figures at 1d4d020aa and 98381bf49:

Loss uc_income_tax_on_earnings uc_income_tax_on_trade Tax on pay
0 to 16,000 7,286 1,800 5,486
21,000 7,086 1,600 5,486
25,000 6,286 800 5,486
29,000 5,486 0 5,486
30,000 / 35,000 / 40,000 5,286 / 4,286 / 3,286 0 5,286 / 4,286 / 3,286

The slice reads net_income, which the relief lowers. Which income the relief comes off is the formula's choice, and that choice is the open question between readings A and B.

The property cannot see a change to the split. The netted world copies the split, so a split that moves wrongly with the loss passes.

  • Mutant M4 puts all of uc_income_tax_on_earnings on the trade whenever there is a loss. It survives the pinned example (37,805.60 on both sides), the other four explicit examples, CI's settings, and generated-only runs with seeds 1, 2 and 3.
  • A scratch reading-B slice passes too, under CI's settings and six seeds.
  • Of the suites this review ran, only test_zero_profit_trade_loss_cannot_raise_tax_or_reduce_programme_award[universal_credit-2026] kills M4, through a family with zero profit.

No test pins the split for anyone with a trading loss.

  • uc_trading_loss.yaml:99,122,143,166 supplies uc_income_tax_on_trade as an input.
  • uc_company_analogous_business.yaml:597,612 pins 3,886 for a person with no trading loss and no pension.
  • test_uc_company_owner_properties.py:419-422 uses the split only inside an identity.
  • On main since Set reliefs and allowances against income for the least tax #2830, test_uc_income_tax_properties.py:139-142 also pins it (4,967.20), again for a person with no loss.
  • No test asserts the @example comment's 7,286, 1,800 or 30,519.60.

The second and third sentences hold only under reading A. "Recomputing the trade's part for the cut profit would move tax" is false under reading B. With the scratch reading-B slice, main's totals-only test passes under CI's settings, under six seeds and in direct calls at six losses.

Fix, YAML. Pin reading A's split. The draft below passes at 1d4d020aa and at 98381bf49 (3 passed). It fails all three cases under the scratch reading-B slice and all three under M4 (3 failed). A reading-B ruling would change its expected values deliberately. Suggested path: policyengine_uk/tests/policy/baseline/gov/dwp/universal_credit/uc_trade_tax_split_with_loss.yaml.

# UC's income tax in respect of a trade that has a trading loss (UC Regs
# 2013 reg 57(2) step 3). The formula takes earnings as the lowest slice of
# non-savings income and the trade before this year's loss relief
# (uc_income_tax_on_earnings_slice), so it takes the relief off the private
# pension above earnings first. Wages 40,000, profit 9,000, private pension
# 20,000; personal allowance 12,570; basic-rate band 37,700 at 20%; Class 1
# (40,000 - 12,570) x 8% = 2,194.40.

- name: A loss larger than the profit leaves the trade the tax on its profit while the pension takes the relief
  # Relief of 16,000 leaves net income 53,000 and taxable income 40,430.
  # Other income comes to 53,000 - 49,000 = 4,000 and the tax on earnings to
  # (40,430 - 4,000) x 20% = 7,286. Without the trade, other income comes to
  # 13,000 and the tax to 27,430 x 20% = 5,486, so the trade bears 1,800.
  # Self-employed earnings come to max(0, 9,000 - 9,000 - 1,800) = 0 and
  # employed earnings to 40,000 - 5,486 - 2,194.40 = 32,319.60.
  period: 2026
  absolute_error_margin: 0.01
  input:
    age: 18
    employment_income: 40_000
    self_employment_income: 9_000
    private_pension_income: 20_000
    trading_loss: 16_000
    region: LONDON
  output:
    uc_income_tax_on_earnings: 7_286
    uc_income_tax_on_trade: 1_800
    uc_individual_earned_income_before_mif: 32_319.60

- name: A loss smaller than the profit leaves the trade the tax on its profit
  # Relief of 4,000 leaves taxable income 52,430 and other income 16,000, so
  # the tax on earnings comes to (52,430 - 16,000) x 20% = 7,286 and the
  # trade bears 7,286 - 5,486 = 1,800. Self-employed earnings come to
  # 9,000 - 4,000 - 1,800 = 3,200 and employed earnings to 32,319.60.
  period: 2026
  absolute_error_margin: 0.01
  input:
    age: 18
    employment_income: 40_000
    self_employment_income: 9_000
    private_pension_income: 20_000
    trading_loss: 4_000
    region: LONDON
  output:
    uc_income_tax_on_earnings: 7_286
    uc_income_tax_on_trade: 1_800
    uc_individual_earned_income_before_mif: 35_519.60

- name: Relief beyond the pension reduces the trade's part of the tax
  # Relief of 25,000 leaves net income 44,000 and taxable income 31,430.
  # Other income comes to max(0, 44,000 - 49,000) = 0, so the tax on
  # earnings comes to 31,430 x 20% = 6,286. Without the trade, other income
  # comes to 4,000 and the tax to 27,430 x 20% = 5,486, so the trade bears
  # 800. Self-employed earnings come to max(0, 0 - 800) = 0 and employed
  # earnings to 32,319.60.
  period: 2026
  absolute_error_margin: 0.01
  input:
    age: 18
    employment_income: 40_000
    self_employment_income: 9_000
    private_pension_income: 20_000
    trading_loss: 25_000
    region: LONDON
  output:
    uc_income_tax_on_earnings: 6_286
    uc_income_tax_on_trade: 800
    uc_individual_earned_income_before_mif: 32_319.60

Replacement, docstring head lines 41-45 (main 44-48). Keep "YAML cases pin the income tax split" only if the YAML lands with it.

The person pays those deductions with the loss. The formula puts Class 2 and Class 4 on the trade, and splits the income tax by taking earnings as the lowest slice of non-savings income and the trade before this year's loss relief, so the relief comes off other non-savings income above earnings first and reduces the trade's income tax part only once that income runs out. The test holds both parts rather than checking them; YAML cases pin the income tax split. Where other income above earnings absorbs the relief, a formula left to recompute the income tax part for the cut profit would move tax from the trade total, which it floors at nil (reg 57(2) step 3), to employed earnings, which have no floor of their own.

Replacement, body "Invariant", last sentence:

The person pays those deductions with the loss, and the parts record the model's split of that payment between the employment and the trade. The test holds that split, so it does not check how a loss moves it: which income the relief comes off is the open question between readings A and B.

Replacement, body "Tests", first bullet:

@example on test_means_tests_see_the_loss_only_through_tax adds the #2832 family as an explicit example, with its arithmetic in a comment; the test doesn't assert those figures.

P2-3. FOLLOWUP.md misdescribes reading A at larger losses, so its case against B' does not stand

Where. FOLLOWUP.md, comment 6600500550 on #2832:

  1. "so the trade bears the tax on its own gross profit, whatever the loss."
  2. On B': "This lets a trade loss lower the tax UC deducts from pay, which the model's slice convention (other income never shifts tax onto earnings) rules out."
  3. "The ruling needed: does income tax "in respect of any trade" under reg 57(2) step 3 follow the trades' net result after step 2 (reading B), or the gross profit with relief taken off other income first (reading A)?"
  4. "so the award falls by the taper on £800."

Evidence.

  • Item 1. The sweep in P2-2 shows the trade's part falling to 1,600 at a loss of 21,000, to 800 at 25,000 and to nil from 29,000.
  • Item 2. The model also lets a loss lower the tax on pay. The sweep gives 5,286 at a loss of 30,000, 4,286 at 35,000 and 3,286 at 40,000.
    • Without the pension (loss_sweep.py 0), a loss of 16,000 gives tax on pay of 4,086 and uc_individual_earned_income_before_mif of 33,719.60. Those are B''s own figures for the family with the pension.
    • So A and B' differ in when the relief reaches pay (after the pension, or before it), not in whether it can.
  • Item 3. The question therefore leaves out where relief left after the trades goes. That is the choice between B and B', and a reg 55(5)(b) question.
  • Item 4. universal_credit is 0.00 for this household in every world, at both losses (family_2832.py 16000 and 4000).
  • "Gross profit" (in "What the model does now" and items 1 and 3). The slice uses taxable_self_employment_income, which comes after the trading allowance, capital allowances and loss relief brought forward.
  • The reading-B change. "What reading B would change" subtracts the offset from self_employment_income. The scratch slice had to subtract it from taxable_self_employment_income, which the slice reads. The two agree for both families but differ where the trading allowance applies, so a reading-B change has to choose.

Replacements.

  1. "uc_income_tax_on_trade is the slice with the trade less the slice without it. So the trade bears the tax on its own taxable profit while the other non-savings income above earnings absorbs the relief. Once the relief exceeds that income, the formula takes the rest off the earnings slice and the trade's part falls: for the Trading-loss property test fails when a loss wipes out a profit beside a private pension (UC earned income) #2832 family, 800 at a loss of £25,000 and nil from £29,000."
  2. "This lets a trade loss lower the tax DWP deducts from pay before the pension has absorbed the relief. The model lowers that tax too, but only once the relief exceeds the pension and the trade (for the Trading-loss property test fails when a loss wipes out a profit beside a private pension (UC earned income) #2832 family, by £200 at a loss of £30,000). So B' changes the order in which the relief reaches pay, not whether it can."
  3. Add to the ruling question: "Where the relief exceeds the trades, does the rest reduce the tax "in respect of the employment" under reg 55(5)(b) before other income (reading B') or after it (readings A and B)?"
  4. "so for a household on UC the award falls by the taper on £800; this household gets no UC under either reading."
  5. Replace "gross profit" (all three times) with "taxable profit before this year's loss relief".
  6. In "What the model does now", replace "less the exclusions" with "less the excluded incomes (savings, dividend and property income)". The slice doesn't subtract the allowances on that list.

P3-1. Holding uc_national_insurance_on_trade changes nothing, though the new comment says it does

Where.

  • Comment, head lines 1003-1008 (main 1068-1073): "...recomputing them for the cut profit would move tax between the employment and the trade."
  • PR body: "let the formula recompute the parts in respect of the trade".
  • PR body, "Readings weighed": the row "The test's old netted world (totals held, trade parts recomputed)" should read "(totals held, income tax part recomputed)".

Why. uc_national_insurance_on_trade is min_(ni_class_2 + ni_class_4, uc_national_insurance_on_earnings) (uc_national_insurance_on_trade.py:22-25). The deductions list already holds all three inputs (head lines 967-970).

  • Mutant T3, which holds only the income tax part, survives the pinned example, the other explicit examples and CI's settings.
  • Recomputing the NI part gave every person the with-loss value: 234 people in 86 families, including all 33 in the explicit examples. Three of the 33 had a non-zero part.

Replacement comment:

    # The parts of UC's tax and NI deductions in respect of the trade (reg
    # 57(2) step 3). The UC formula takes them off the trade total and the
    # rest of the totals off employed earnings (reg 55(5)(b)), so the test
    # holds them with the totals in the netted world. If the test let the
    # formula recompute the income tax part for the cut profit, the formula
    # would move tax between the employment and the trade. It computes the
    # NI part from ni_class_2, ni_class_4 and
    # uc_national_insurance_on_earnings, which the test already holds.

P3-2. The @example comment ends on the old construction, in the passive

Where. Head lines 930-932 (main 946-948): "With the profit cut to nil and only the totals held, the trade's part is recomputed as nil, all 7,286 comes off employed earnings and they fall to 30,519.60. Holding the trade's part keeps 32,319.60." Lines 925-929 (main 941-945) also use "is" and "are" where the brief's writing rules ask for real verbs.

Replacement for lines 925-932:

        # (40,430 - 4,000) x 20% = 7,286. Without the trade, other income comes
        # to 13,000 and the tax to 27,430 x 20% = 5,486, so the trade bears
        # 1,800. Class 1 comes to 27,430 x 8% = 2,194.40 and the person pays no
        # Class 4. With the loss, self-employed earnings come to
        # max(0, 9,000 - 9,000 - 1,800) = 0 and employed earnings to
        # 40,000 - 5,486 - 2,194.40 = 32,319.60. In the netted world the test
        # cuts the profit to nil and holds the trade's part at 1,800, so the
        # formula again takes 5,486 off employed earnings: 32,319.60. If the
        # test held only the totals, the formula would recompute the trade's
        # part as nil and take all 7,286 off employed earnings: 30,519.60.

P3-3. Passives in the docstring sentences the PR rewrote

  • Head lines 37-41 (main 40-44).
    • Text: "equal the same family with those profits cut by the loss and every tax and NI deduction the UC formula reads held at its with-loss value: the totals on earnings and the parts of them in respect of the trade (reg 57(2) step 3), whose remainder is in respect of the employment (reg 55(5)(b))."
    • Replacement: "equal those of the same family in a world where the test cuts those profits by the loss and holds every tax and NI deduction the UC formula reads at its with-loss value: the totals on earnings and the parts of them in respect of the trade (reg 57(2) step 3). The formula takes the rest of the totals off employed earnings (reg 55(5)(b))."
  • Head lines 47-49 (main 50-52).
    • Text: "Pension Credit's tax attribution to employed and self-employed earnings is held alongside them, including the actual Class 2/4 components replaced by notional PC deductions."
    • Replacement: "The test holds Pension Credit's tax attribution to employed and self-employed earnings alongside them, including the actual Class 2 and Class 4 components, for which the PC formula uses notional deductions."

P3-4. The body's case for keeping reading A cites a convention reading B also keeps

Where. PR body, "Readings weighed": "...so this change follows the convention that uc_income_tax_on_earnings_slice states in policyengine_uk/utils/uc_income_tax.py (earnings form the lowest slice, so tax on other income never comes off earnings), fixes the test and leaves the model alone."

Why. Readings B and B' also keep earnings as the lowest slice; the scratch reading-B slice changes only what counts as the trade's earnings. What picks reading A is that the slice measures the trade before this year's loss relief. The body says so earlier: "Trade loss relief lowers net_income but not earnings".

Replacement:

...so this change keeps the model's reading: uc_income_tax_on_earnings_slice (policyengine_uk/utils/uc_income_tax.py) takes earnings as the lowest slice and measures the trade before this year's loss relief, so the relief comes off other income first. The change fixes the test and leaves the model alone.

P3-5. Slips in the body's figures and evidence

  • The search. "1,000 generated families in all" counts examples, not families. Each example draws st.lists(families(), min_size=4, max_size=10) (head line 953). Replacement: "four runs of 250 examples each (seeds 7771 to 7774, derandomize off, otherwise CI's settings), 1,000 examples of 4 to 10 families each, against main's code with this change." I did not rerun this search.
  • The seed check. "with CI's settings but derandomize off" leaves out that shrinking was off too; the author's report says so. Replacement: "with CI's settings but derandomize and shrinking off". Pass or fail per seed doesn't depend on shrinking.
  • The B' row in "Readings weighed" (33,719.60 and 36,319.60) is arithmetic: the model has no B', and nothing ran one. The brief's writing rules allow no number that wasn't run, so label the row "arithmetic, not model output".
  • "Less the exclusions" ("What the code does now"). The slice subtracts only the excluded incomes (uc_income_tax.py:42-46), not the two allowances on the exclusions list (received_allowances_earned_income and marriage_allowance). Replacement: "less the excluded incomes (savings, dividend and property income)".
  • Commands and gaps. The "Tests" section lists results and tool names but not the commands run, and uses passives ("each made alone and run", "run against current main's code"). documentation-review.md asks that "PR descriptions list commands run and any skipped tests or known gaps"; P2-2 is the known gap.

P3-6. In the body's "The law" and "Readings weighed", provisions act

Text Replacement
"step 2 adds every trade's profit or loss; step 3 deducts the income tax and contributions paid "in respect of any trade", and a nil or negative result makes self-employed earnings nil." "DWP adds every trade's profit or loss (step 2), deducts the income tax and contributions the person pays "in respect of any trade" (step 3), and treats a nil or negative result as nil self-employed earnings."
"None of these says which non-savings income a trade loss relieves when UC splits one tax bill between the employment and the trade." "In these provisions neither Parliament (ITA 2007) nor the Secretary of State (UC Regs 2013) says which non-savings income the relief for a trade loss comes off when DWP splits one tax bill between the employment and the trade."
"so s. 25(2) does not choose between them." "so the taxpayer gets the same reduction whichever of them the relief comes off, and has no order to choose under s. 25(2)."
"because the step 3 nil floor absorbs the £1,800 that reading A puts on the trade." "because the formula floors the trade total at nil (reg 57(2) step 3) and so drops the £1,800 that reading A puts on the trade."
"These provisions leave both readings defensible, so..." "Parliament and the Secretary of State leave both readings open in these provisions, so..." (then as P3-4)

P3-7. The author's report (HANDOFF-777.md, comment 6600510649), for the record

  • "Main's old netted world in fact embodies reading B."
    • This contradicts "Main's netted world matches no reading" a few lines earlier. The old netted world recomputes the trade's part as reading B does but holds reading A's total of 7,286, so it gives 30,519.60.
    • Replacement: "Main's old netted world recomputes the trade's part as reading B does but holds reading A's total, so it matches neither. If the model followed reading B, the old test would pass: the trade's tax would be on its net result, which never exceeds the profit the loss leaves, so the nil floor would never bind."
    • The scratch reading-B runs confirm that it would pass.
  • "I worked each reading by hand; the model reproduced every tax figure." The model computes only reading A. A scratch slice reproduces reading B's figures exactly; reading B' rests on arithmetic alone.
  • "The title is 57 characters." It has 56.

P3-8. Outside families(), cutting the profit can switch off UC's childcare work condition (predates this PR)

What I ran. The head's and main's test bodies on one family the strategy never draws:

  • an adult aged 30 with no hours, profit 5,000, a loss of 10,000 and childcare costs of 6,000;
  • a child aged 3;
  • rent 9,000 in London.

Both fail the UC check: universal_credit_pre_benefit_cap is 15,796.94 with the loss against 10,696.94 netted. The 5,100 gap is the childcare element. With 16 hours worked, both pass.

Why.

  • in_work (in_work.py:12-16) is true for any hours, pay or profit. With the loss, the profit of 5,000 makes the adult in work. The netted world cuts it to nil, so uc_childcare_work_condition fails.
  • The module docstring states its invariants "for any people and incomes". Invariant 4 holds only where the profit cut leaves the work condition as it was.

Fix. Either hold in_work at its with-loss value in the netted world, as the test holds uc_mif_applies, or say in invariant 4 that the comparison assumes the cut leaves the work condition unchanged.

Checked and sound

1. Diagnosis.

  • Reproduction. main's test body at 1d4d020aa fails on the Trading-loss property test fails when a loss wipes out a profit beside a private pension (UC earned income) #2832 family with AssertionError: ('uc_earned_income', array([32319.59765625]), array([30519.59765625]), ...) at test line 1008. The head's body passes.

  • The body's Trading-loss property test fails when a loss wipes out a profit beside a private pension (UC earned income) #2832 table. A bare Simulation (family_2832.py 16000) reproduces every figure at 1d4d020aa:

    • with the loss: tax on earnings 7,286.00 and on the trade 1,800.00; NI on earnings 2,194.40 and on the trade 0.00; employed part 32,319.60; self-employed part 0.00 (-1,800.00 before the floor); uc_earned_income 32,319.60;
    • totals only: trade part 0.00, employed 30,519.60, uc_earned_income 30,519.60;
    • totals and parts: 32,319.60.

    98381bf49 gives the same figures.

  • Hypothesis 6.170.11 (pinned in uv.lock):

    • get_random_for_wrapped_test (core.py:711-728) checks @seed first (715-716), then settings.derandomize (718-719, Random(int_from_bytes(function_digest(test)))), then global_force_seed (721-722).
    • _hypothesis_pytestplugin.py:183-189 sets global_force_seed from --hypothesis-seed. So derandomize=True beats --hypothesis-seed, as the author says.
    • The seed() docstring (core.py:365) says "Setting a seed overrides |settings.derandomize|". That holds only for @seed.
    • With a global seed, run_engine sets database_key = None (core.py:1415-1418), so seeded runs neither read nor write the example database.
    • Under CI's settings, seeds 1 and 2584 drew identical families.
  • Main and head draw differently under CI. function_digest (internal/reflection.py:83-116) hashes the source from def on; _clean_source (56-80) drops decorators and comments. So the head's two code hunks, not its @example, change the digest. Under CI's settings, main's test and the head's test draw different families; only the first, all-zero example is common.

  • Seeds. Scratch copies changed only derandomize=False and phases (the defaults less Phase.shrink), with max_examples=3. Two independent runs each covered all 20 of the author's seeds.

    • main's test failed only at 2584, on uc_earned_income. The failing family is the sixth of six in that example: one adult aged 36 with children aged 14 and 0; wages 59,045.75, profit 18,902.86, pension 8,080.30, loss 19,543.35.
    • The head's test passed all 20, drawing the same families seed by seed.

2. The fix.

  • What the formula reads. uc_individual_earned_income_before_mif reads exactly four tax and NI variables (lines 85-100; a simulation trace agrees): uc_income_tax_on_earnings, uc_income_tax_on_trade, uc_national_insurance_on_earnings and uc_national_insurance_on_trade. The netted world holds all four: the totals through held (head lines 969-970) and the parts at 1009-1012 and 1050-1052.

  • What else moves. The review compared 18 family lists: the 5 explicit examples, the 3 lists the test generates under CI's settings, and 10 drawn lists, which make 86 families and 234 people.

    • Of the inputs that formula reads, only self_employment_income and uc_trading_losses_set_against_profits differ between the worlds. Each moves by min(loss, profit) for 37 people, and the two cancel. The netted world also sets trading_loss to nil, which only the second of those reads.
    • uc_individual_earned_income_before_mif and the four UC_TESTS agree exactly.
    • The floor's inputs (uc_minimum_income_floor, is_uc_assessed_claimant, uc_mif_applies) and the benefit cap threshold agree too. The floor's own notional tax and NI (uc_minimum_income_floor_income_tax and uc_minimum_income_floor_national_insurance) aren't held, but they never move.
  • Three limits, none reached by families().

    • The cut equals UC's offset only while uc_company_self_employed_earnings is nil, which families() guarantees.
    • The netted world still recomputes adjusted_net_income and Pension Credit's tax attribution, which move with the loss. UC reaches them through Tax-Free Childcare, non-dependant deductions, Child Benefit (only when the family opts out) and Housing Benefit's savings-credit income, which cancels in the benefit cap. None changed a UC test in the lists compared.
    • Cutting the profit can switch off the childcare work condition (P3-8).

    So invariant 4's "every tax and NI deduction the UC formula reads" is right for the earned income formula.

3. Can the test still fail? Each mutant was applied alone to the merge and restored afterwards; two independent runs gave the same results.

Mutant Pinned #2832 example Other 4 explicit examples CI's settings Generated only, seeds 1-3
T1 hold the totals only (the author's) killed: 32,319.60 vs 30,519.60 survived killed (by #2832) not run
T2 leave the profit uncut (the author's) killed: 32,319.60 vs 39,519.60 all 4 killed killed not run
T3 hold the income tax part only survived survived survived not run
M1 drop the loss from the reg 57(2) trade total killed: 39,519.60 vs 32,319.60 all 4 killed killed killed 3/3
M2 also take the unused loss off pay killed: 25,319.60 vs 32,319.60 3 of 4 killed killed killed 3/3
M3 also take the whole loss off pay killed: 17,880.98 vs 32,319.60 3 of 4 killed killed killed 3/3
M4 move the tax on earnings onto the trade when there is a loss survived survived survived survived 3/3
M5 net the whole loss, uncapped survived survived survived survived 3/3
  • What the property still tests. It tests the loss rule invariant 4 states: reg 57(2) step 2 netting, and no loss against employed earnings or other income. Every mutant tried that changes how the loss reaches UC earned income (T1, T2, M1-M3) fails it. The pinned example alone kills each of those, and generated families alone kill M1-M3.
  • The survivors. M5 is equivalent for this test: the nil floor absorbs the excess, and uc_trading_loss.yaml kills it. T3 is P3-1, and M4 is P2-2.
  • Tests that pin the split on their own. At the head, only the two cases in uc_company_analogous_business.yaml (3,886 and 445.80), which have no trading loss and no pension. On main, test_uc_income_tax_properties.py:139-142 adds a third, also with no loss. test_zero_profit_trade_loss_cannot_raise_tax_or_reduce_programme_award[universal_credit-2026] constrains the split indirectly, for zero-profit families.

4. Readings A and B.

  • Arithmetic. Every figure in the issue, the body, FOLLOWUP.md, the author's report and the @example comment recomputes: 76 of 76. For losses of 16,000, 4,000 and 8,000, all 66 model values compared in the three worlds (reading A and both netted worlds) match the arithmetic to the penny (family_2832.py at 1d4d020aa). The 16,000 and 4,000 runs give the same figures at 98381bf49.

  • Reading B in code. A scratch reading-B slice changes only uc_income_tax.py: the trade's part of earnings becomes max_(0, taxable_self_employment_income - uc_trading_losses_set_against_profits). It reproduces FOLLOWUP.md's figures exactly:

    • at a loss of 16,000: tax on earnings 5,486, trade part 0, uc_earned_income 32,319.60;
    • at a loss of 4,000: 6,486, 1,000 and 36,319.60.

    I checked B' (33,719.60 and 36,319.60) with arithmetic only; the model has no B'.

  • The test under reading B. The head's property passes under B, with CI's settings and with seeds 2584, 1, 2, 3, 5 and 8. As FOLLOWUP.md says, main's totals-only test passes under B too, in the same runs and in direct calls at six losses. It fails under reading A, as a control.

  • Other suites under B. None of the suites run under B fails: the trading-loss module (12 passed), three UC property modules (16), the UC income YAML (174), uc_trading_loss.yaml (8), uc_company_analogous_business.yaml (26) and all 15 YAML files that set a trading loss (276).

  • What is quoted. Only two phrases are quoted: "in respect of any trade" (PR body, FOLLOWUP.md) and "in respect of the employment" (issue, PR body). Everything else, all of ITA 2007 included, is paraphrase. The shared-rate-bands premise cites no provision.

  • What the quoted text supports. The quoted words name a source of income, not a way to apportion one tax bill, so they don't decide between A and B. The PR's "None of these says which non-savings income a trade loss relieves..." is consistent with what was quoted. "Defensible" is a judgement that rests on unquoted law.

  • Where A and B differ. They leave the employment the same tax: 5,486 at every loss up to 29,000. They move tax between the trade, which UC deducts, and the pension, which it doesn't. So the quoted reg 55(5)(b) words bear only on B'.

  • Under either reading the test holds, by construction. Several texts describe reading A: the body, invariant 4's second and third sentences (head lines 41-45, main 44-48), the comment at head lines 1003-1008 and the @example arithmetic. A reading-B ruling would need them reworded (P2-2). Under B', the 32,319.60 figures change too.

5. The pinned example (head lines 918-952), to the penny.

  • 37,700 x 20% + 2,730 x 40% = 8,632; (40,430 - 4,000) x 20% = 7,286; 27,430 x 20% = 5,486; 7,286 - 5,486 = 1,800.
  • Class 1: the model's primary threshold is 241.73 x 52 = 12,569.96, giving 2,194.4032, which is 2,194.40 to the penny.
  • 40,000 - 5,486 - 2,194.40 = 32,319.60; 40,000 - 7,286 - 2,194.40 = 30,519.60.
  • All match the model.
  • Three facts hold but go unstated:
    • the relief cap doesn't bind (max(50,000, 25% of 69,000));
    • the personal allowance isn't tapered;
    • London takes the rest-of-UK rates.
  • The comment says "there is no Class 4" without the reason: the 9,000 profit is below the 12,570 lower profits limit.

6. Text.

  • Fix evidence. The review ran .github/check_fix_pr.py (blob 9c9452a38, the same at 52b30809f and 1d4d020aa) on the live title and body, built as pr_fix_evidence.yaml builds them. It used no labels, and the changes A changelog.d/2832.fixed.md and M policyengine_uk/tests/test_trading_loss_properties.py from merge base 6c6e229a5. Output: Fix evidence: PASS ('Hold UC trade tax parts in the trading loss netted world') / - Fix PR has valid reproducer evidence. Changed executable tests: 1., exit 0.
  • Body versions. The live body is identical to the body saved from the PR on 3 November. I compared it with the brief's PR_BODY.md by eye. The version posted on Trading-loss property test fails when a loss wipes out a profit beside a private pension (UC earned income) #2832 (comment 6600500271) is an earlier draft that differs in eight lines.
  • Title. 56 characters, sentence case, no rule broken.
  • Format. uvx ruff@0.17.2 format --check and check on the changed file, and git diff --check 6c6e229a5 cd994ad23, are clean.
  • Changelog. The fragment's name and fixed type follow github-prs.md.

7. Tests (-n 4; YAML with policyengine-core test ... -c policyengine_uk):

Suite Head cd994ad23 Merge with 1d4d020aa
test_trading_loss_properties.py 12 passed 12 passed
test_uc_earned_income_before_work_allowance_properties.py 4 passed 4 passed
policyengine_uk/tests/code_health 3,089 passed 3,092 passed
YAML .../universal_credit/income 174 passed 174 passed

At current main (98381bf49), test_means_tests_see_the_loss_only_through_tax passes (1 passed in 140.59s).

8. CI.

  • Check runs. gh api repos/PolicyEngine/policyengine-uk/commits/cd994ad23.../check-runs now lists 21 runs, all completed / success:
    • Fix evidence twice (10:05Z and 17:05Z on 3 November);
    • once each: Aggregate impact; Changelog fragments; Changes; Documentation build; Install + smoke-import (py3.11 to py3.14); Lint; Release build records the commit; Test / Python 1/7 to 7/7; Test / Result; Test / YAML.
  • Aggregate impact. Pass, base 52b30809ff against head merge 78192e71c3; no household's net income changes in any year.
  • Commits since CI's base. In 52b30809f..1d4d020aa, 17 commits change files the test reads. All arrive through Disregard WTC before the Housing Benefit childcare deduction #2776 (merge fb83b25af) and touch six Housing Benefit variable files and utils/supplied_inputs.py, all of which the test runs (coverage).
    • The review dumped 5,532 values from the 18 family lists: the 14 variables the test compares and four more, in all three worlds. All are identical between the merges with 52b30809f and 1d4d020aa.
    • Tax credits are inactive in 2026, so housing_benefit_wtc_disregard is nil.
    • The test passes on the merge.

9. Merges. git merge-tree --write-tree --name-only is clean for cd994ad23 against:

#1995 merged at 2026-11-04 02:50Z (8717d5a26) and this PR at 2026-11-05 15:54Z (93bc52d1c). main's test file carries both changes.

10. The author's writer check. Both other branches, claude/uc-trading-loss-property-8zmhka and -n0kzrs, point at 2947d73d4. Before the author's pick-up comment, #2832 had only the two earlier pick-up comments.

What I couldn't check


Generated by Claude Code

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.

Trading-loss property test fails when a loss wipes out a profit beside a private pension (UC earned income)

3 participants