Repository navigation
Apply the Marriage Allowance rate test at the statutory limits - #2913
Conversation
The least-tax search counted a share as meeting the rate test only with about 3.9p of room below each limit. Where every qualifying share leaves non-savings income at the limit, which s. 10(2) allows, the search found none and denied the reduction: pay 40,200, savings 9,000 and dividends 1,570 in 2026-27 paid 7,440 in place of 7,288. The search now applies the limits themselves and keeps the TIE snapping for savings and dividends. Adds Cases 24 to 26 to least_tax_allocation.yaml and a property test that checks the model's tax against an oracle working ITA 2007 directly. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
d757380 took the room out of the search's rate test but left the model to test the float32 deductions on its own. Where the income left sat at the basic rate limit, rounding could carry it over, so the model denied a reduction the search had counted on. The search now rounds the least-tax share's deductions to float32 (_stored_share) and moves a person only where that stored share beats the old order as stored. meets_marriage_allowance_income_conditions reads the stored deductions through the same float64 arithmetic (share_meets_marriage_allowance_rate_test), so the model gives the reduction exactly where the search counted it. The rate test counts income within half a penny above a limit as at the limit (RATE_TEST_SLACK). Float32 carries a net income under £65,536 to within a fifth of a penny, so a recipient at the limit keeps the reduction and one a penny over it does not. Tests follow in the next commits. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
3d8460e tested a stored share in float64 with half a penny of slack (RATE_TEST_SLACK). The slack granted the reduction to some people a fraction of a penny over a limit, where both the law and the model's float32 test deny it. The slack goes. A share now meets the test where it does in float64 from the stored amounts or in float32 as main applied it (_rate_test_on_stored). The search prices the stored share and the old order with that function, and share_meets_marriage_allowance_rate_test gives the model's answer through it, so the model grants the reduction where the search counted it. _stored_share keeps the rounding with the least tax after the reduction and, among roundings within TOLERANCE of each other, prefers one inside the first component's bounds. It ranks last a rounding that sets more than half a penny beyond the shared allowances (OVER_DEDUCTION), since the test would then read less income than the law taxes. From 2027-28 the shared amount comes from float32 net income, so there the rounding nearest the exact deductions keeps its rank. Tests: no-room moves in 2026-27 and 2027-28; a recipient at the basic rate limit; seven recipients a penny over a limit; a 2028-29 recipient at a limit a Gift Aid gift raises; three 2026-27 recipients whose only passing rounding over-deducts; two Scottish recipients a penny inside a limit whom only the nearest rounding passes. The property test's oracle works ITA 2007 s. 55B(2)(b) and (ba) directly. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
_stored_share ranked every rounding that sets more than half a penny beyond the shared amount last, except the nearest rounding from 2027-28. In 2026-27 that removed the nearest rounding even where the exact share meets the rate test, so a recipient with no non-savings income and deductions above £131,072 lost the £252 reduction the law gives. It also moved non-recipients off the float32 value the model has always stored. Now the nearest rounding keeps its rank in every year unless it meets the rate test where the exact share fails it. Any other rounding more than half a penny beyond the shared amount still ranks last. Also corrects the docstrings on float32 storage of high incomes, the Gift Aid limit in the float64 test and the over-deduction test's expected tax, and rewords the changelog fragment. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Aggregate impact on certified data: passBase Checks: 0 broken by this change, 1 failing on both sides, 0 fixed. Moves flagged for review: 0 (thresholds in Notes
Moves flagged for reviewNone. Receipts by tax head
Spending by benefit and service
Caseloads
Government balance, each component counted once
Model totals
Household income totals
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
Household net income by decileNo household's net income changes in any year. No change in any year: population; poverty rates; people in poverty; inequality. Checks failing on both base and head (1)
Counted-once checkThe 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.
Provenance
Dataset: Receipts by tax head: head levels
Spending by benefit and service: head levels
Caseloads: head levels
Government balance, each component counted once: head levels
Model totals: head levels
Household income totals: head levels
Population: head levels
Poverty rates: head levels
People in poverty: head levels
Inequality: head levels
Mean household net income in each side's own deciles: head levels
Standard reform costings (change in gov_balance): head levels
Standard reforms: change in each reform's target: head levels
|
juaristi22
left a comment
There was a problem hiding this comment.
Reviewed 6788c8e39144c633c0ae7fa8c8c20a6a905ab47b: COMPLETE — request changes for one confirmed critical finding (C1); no material evidence gaps.
C1 — A rounded share can win an ineligible Marriage Allowance reduction. At income_tax_allocation.py:414, removing the below-limit safety room can award the whole £252 reduction after float32 rounding erased a real penny above the limit.
A source-qualified 2026–27 England couple, both 40, has a zero-income donor and a recipient with pay £190,529.99, savings £9,000.02, dividends £1,570, a genuinely qualifying current-year trade-loss claim of £50,275, and qualifying cash Gift Aid of £80,044. Assume a valid election, UK residence and no Married Couple’s Allowance claim.
- The loss fits s.24A’s cap: 25% of total income is £50,275.0025. Section64 permits the qualifying loss deduction.
- Gross Gift Aid is £100,055, giving an extended basic limit of £137,755 and adjusted net income of £50,770.01; the full £12,570 Personal Allowance applies (s.35, s.58 and s.414).
- Exact taxable income is £138,255.01, one penny above the extended basic limit plus the £500 savings allowance. Any share either leaves higher-rate income or disallowed counterfactual upper-rate dividends, so it cannot meet s.55B.
The current head rounds net income to £150,825, chooses deductions of £2,499.98046875 / £8,500.01953125 / £1,570, grants £252 and charges £27,299. The captured baseline allocator/rate-test control denies the reduction and charges £27,451, matching the statutory least liability (about £27,451.004) to pence. This PR therefore introduces an annual undercharge of about £152, rather than a penny-sized discrepancy.
Please preserve lawful equality at the limit while preventing low-precision totals from manufacturing an entitlement, and add this final-tax counterexample. The causal control replaces only the two baseline entrypoints in the same environment; it is not a separate full-main suite.
Validation: 116 focused tests passed (90 YAML, 26 Python), plus the source-qualified current/control reproduction above. The independent policy review corroborated the same finding from 24 verified official source/extract pairs; it is counted once. The queued RuleSpec545 packet is adequate. Current hosted checks were refreshed; their passing cases do not cover C1.
The search now always keeps the rank of the rounding nearest the exact deductions, as main does. 6788c8e ranked it last where it met the rate test and the exact share did not. Such a household can store the same float32 amounts as one entered at the limit, which the law gives the reduction: savings of £140,500.01 against £140,000.01 of shared deductions leave £500, but the model holds the savings as £140,500.015625, 0.56p over the band. The rule denied that recipient the £252 that main and the law give. A recipient entered 0.7p over the band holds the same amounts as one entered just under it, so no rule on the stored amounts can tell them apart. The model now gives both the reduction, as it does where float32 rounding of net income or the allowances puts income onto a limit. A new test pins the at-band recipient and the two twins. The over-deduction test keeps its two recipients whose passing rounding is not the nearest. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
juaristi22
left a comment
There was a problem hiding this comment.
Follow-up review of 7877bca514da83cc81e0b62059e7151353258671, incremental from 6788c8e: COMPLETE — request changes; C1 STILL OPEN; no new findings or material evidence gaps.
C1 — The same source-qualified household still receives an ineligible Marriage Allowance reduction. The new nearest-rounding exception at income_tax_allocation.py:919 does not repair the lost input precision behind the original finding.
The original 2026–27 England couple, both40 with a zero-income donor, still has recipient pay£190,529.99, savings£9,000.02, dividends£1,570, a genuinely eligible current-year trade loss£50,275 and qualifying cash Gift Aid£80,044. Valid election/residence and no Married Couple’s Allowance claim remain explicit premises.
The loss fits s.24A’s cap, and s.64 permits the qualifying deduction. Gross Gift Aid£100,055 gives adjusted net income£50,770.01, full Personal Allowance£12,570 and extended basic limit£137,755 (s.35, s.58, s.414). Exact taxable income£138,255.01 is a penny above that limit plus the£500 savings allowance. No feasible share qualifies under s.55B.
At this new head, the native model again grants £252 and charges £27,299, approximately £152 below the statutory least liability of£27,451.004. The original baseline-feature control charging£27,451 is retained separately; the current-head household was rerun with identical inputs. This is the same C1, counted once.
The new test’s stored-identical examples document a precision limitation; they do not establish a statutory entitlement exception. Please correct the source-qualified final-tax case and add it as a regression while preserving lawful equality at the limit.
Validation: 114 current tests passed (90YAML,24Python), zero failures/skips; three unaffected CPS results were retained separately and are not added to that count. Both independent roles completed;24 official source/extract pairs were byte-validated and reused, with no new source acquisition. Hosted CI is separately pending at the latest capture and Fix evidence is cancelled; neither passing focused tests nor a later CI clearance resolves C1. The PR remains Draft.
The search could pick a float32 rounding of the deductions from savings and dividends for the slack in the float32 rate test alone. For a recipient entered a penny or two over a limit, whose exact share fails the test in float64, that gave the Marriage Allowance reduction that main and the law deny. Such a rounding now ranks below every other, unless it is the rounding nearest the exact deductions, which the model has always stored. A new test holds a 2026-27 recipient whose savings sit 1p over the savings nil rate band once a Gift Aid gift raises the basic rate limit (s. 414(2)(b) ITA 2007). The model gives no reduction and charges £21,547.83, as the law does. Two tests take names, and a third a docstring, that say why the nearest rounding keeps its rank. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The r1 review found that no test needed the float64 arm of _rate_test_on_stored, and that the property test's explicit examples could not fail on main. - A unit test checks that the float64 arm counts an old order and a moved share that leave income at the limit in float64 but £0.0039 over it in float32. - A model test gives the reduction to two 2026-27 recipients whose pay, savings and dividends come to £50,270, which main denies. It denies the reduction a penny over. - The property test runs the table's second row, whose share leaves pay 2p under the limit, where the strict test passes too. - Docstrings now give the property test's margins and what invariant 10's last check guards. They also note that the 24% savings rate adds an announced rise, and that sub-penny float32 gaps can add up. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
juaristi22
left a comment
There was a problem hiding this comment.
Follow-up review of 965b9d177f2057ecb09d155920582e867e25f405, incremental from 7877bca: COMPLETE — request changes; C1 STILL OPEN; no new findings or material evidence gaps.
C1 — The original source-qualified household is still undercharged about £152 annually. The new non-nearest float32-only ranking guard at income_tax_allocation.py:935 does not restore the entered penny lost upstream. This retains the existing finding, rather than adding another precision finding.
The same 2026–27 England couple, both 40 with a zero-income donor, has recipient pay £190,529.99, savings £9,000.02, dividends £1,570, a genuinely qualifying current-year trade loss of £50,275 and qualifying cash Gift Aid of £80,044. Valid residence/election and no Married Couple’s Allowance claim remain explicit premises.
The loss fits s.24A’s cap. After the loss, gross Gift Aid and Personal Allowance, exact taxable income is £138,255.01: one penny above the £137,755 extended basic limit plus the £500 savings allowance (s.58, s.414). No feasible share meets s.55B.
The current head was rerun with identical inputs and again grants £252 Marriage Allowance, charging £27,299 instead of the statutory least liability of approximately £27,451.004. The original independently corroborated legal derivation and baseline-feature control are retained separately. Please correct this final-tax case and add it as a regression while preserving lawful equality at the limit.
Validation: 117 current tests passed (90 YAML, 27 Python), zero failures/skips. Three unaffected ordinary-pay-only CPS results were retained separately and are not added to that count. Both independent roles completed, reusing 24 hash-validated official source/extract pairs with no new acquisition. The new float64-boundary tests cover existing reader behavior; the changed ranking guard and final-tax controls were executed. No new parameter or statutory-rate claim is inferred from the pre-existing 2027 model fixtures.
The exact PR snapshot was tested. Its merge base is b007ac82; captured main has advanced to d3db7ac0, whose composition was not separately executed. Hosted CI remains pending and the PR remains Draft; neither a later CI clearance nor passing focused tests closes C1.
Before publication, both original reviewers assessed the updated description (bb27dbc…). It documents the reviewed guard and examples without changing the C1 disposition; no additional model or test run was required.
The property test asserted that no share leaves less liability under its strict rate test than the model charges. That was false for a recipient whose only qualifying share sets nothing against pay and leaves savings at the top of the savings nil rate band. Pay of £37,500, savings of £11,000.03 and dividends of £2,069.97 in 2026-27 is one: the law charges £7,248, and the model charges £7,329.78, as on main. Float32 holds the savings and dividends 0.024p over the £13,070 entered, so the share the search scores leaves the savings that much over the band. The search rounds only the share it scores lowest, so it never tries the rounding that puts them back. Check 2's strict test now asks for the savings above the limit to sit a penny inside the band, as it already asks for pay a penny under the limit. Check 1, at the model's own share, keeps its half penny. The test still fails on main, on the example whose share leaves pay a penny under the limit and savings a penny inside the band. The test runs that recipient and two more of the same shape as explicit examples. The docstring says why the strict check stops inside the band, and no longer says that only one share qualifies in the fourth example, where pay has 2p of room. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
The property test was false for a recipient entered exactly at a step of the Personal Allowance or the savings allowance, where float32 net income falls on the other side of the step. With pay of £44,703.42, savings of £1,673.39 and dividends of £3,893.19 in 2026-27, Step 3 income is the £37,700 basic rate limit, so the law gives a £1,000 savings allowance (s. 12B). The model sums net income to £50,270.0039, gives £500 and charges £100 more, as on main. With net income entered at £110,002 and held as £110,001.992, the model gives a Personal Allowance of £7,570 where s. 35 gives £7,569. Neither concerns the share or the rate test. Both checks now leave out a recipient for whom the law's Personal Allowance or savings allowance differs between the model's net income and the net income entered. The test first asserts that the two net incomes agree within its tolerance. On 4,200 recipients at the rate test's edges and 2,400 drawn ones, it leaves none out. The oracle also rounds the sum of the amounts entered to whole pence. For pay of £42,146.41, savings of £6,022.65 and dividends of £2,100.94, float64 addition carried the £50,270 sum over the limit, and the oracle took the £500 allowance where the model rightly gives £1,000. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
No test failed when OVER_DEDUCTION fell to TIE, or when _stored_share ranked last every rounding that passes only in float32. A new test runs a 2027-28 recipient with pay of £53,841.65, savings of £141,016.82, dividends of £17,661.55, other deductions of £174,818.25 and a £1.77 trading loss. Step 3 income is the £37,700 basic rate limit, so the law gives the reduction and charges £4,962.09. The model holds the shared amount midway between two float32 values. The one below leaves income 0.39p over the limit; main stores it and charges £5,214.10. The one above sets 0.39p more than the shared amount, within OVER_DEDUCTION, and meets the rate test. The model stores it and charges £4,962.09. The test fails with OVER_DEDUCTION at TIE. A second test pins the condition that the float32-only rule applies only where the exact share fails in float64. For a 2027-28 recipient whose exact share meets the test, two roundings leave the same f and one passes only in float32. _stored_share keeps that one, which it tries first. Without the condition it stores the other. On 384,936 synthetic recipients the condition changed the pair stored for two, each time between pairs that leave the same f, and the _stored_share docstring now says so. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Pay of £50,269.99, savings of £500 and dividends of 1p in 2026-27 ran only as an explicit example of the property test. Its one qualifying share leaves pay at the basic rate limit, where only the property test's loose rate test passes, so that example cannot fail on main. Case 27 of least_tax_allocation.yaml now pins the row. The share sets 1p against dividends and £12,569.99 against pay, which leaves £37,700 of pay and £500 of savings: £7,540 before the £252 reduction and £7,288 after it. main keeps the old order, denies the reduction and charges £7,539.998, so the case fails there. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
…tion One test guarded two rules: that a moved share counts where it meets the rate test only in float32, and that the rule ranking such a rounding last spares the nearest rounding. The test is the 2028-29 recipient at a basic rate limit that a Gift Aid gift raises to £38,909.30, and it guarded both only through a float32 tie that its docstring did not describe. The docstring now states the mechanism. The model holds Step 3 income 0.18p over the limit, so no share meets the test in float64. The float32 value nearest the deduction from dividends leaves float32 amounts that sum to the float32 value of the limit, so it meets the test in float32 alone. Two unit tests now pin each rule on the amounts the model holds for that recipient. The first asserts that the share fails _meets_rate_test, passes _float32_meets_rate_test and counts in _rate_test_on_stored. It fails when _rate_test_on_stored drops its float32 arm. The second asserts that _stored_share keeps the nearest rounding, which passes only in float32, where the exact share fails in float64. It fails when the float32-only rule applies to the nearest rounding too. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
The TOLERANCE comment said a float32 step moves a deduction only through tax at the person's rates. A step can also carry a Marriage Allowance recipient's share across a limit of the rate test and win the reduction, and the comment now says so. The module docstring and _old_order_meets_rate_test said the float32 test never denies the reduction where main's gave it. main rounds a limit to float32 before it adds a Gift Aid gift; the float32 test here rounds the sum. The two agree where the statutory limit is a float32 amount, as every limit from 2015-16 to 2028-29 is. The Scottish higher rate threshold is not one from 2029-30, when the two limits can sit a float32 step apart for a Scottish taxpayer with a gift. Both docstrings now state that condition. In test_income_tax_allocation.py: - The PENNY_OVER comment said float32 puts some recipients under the limit. The model holds all seven 0.2p to 0.5p over it. - test_rate_test_fails_a_rounding_that_sets_more_than_the_shared_allowances asserted £31,520 where its docstring works £31,520.005. It now asserts the docstring's figure. - The Scottish recipients' docstring said net income sums a fraction of a penny high. It is 0.69p high in 2027-28 and 1.375p high in 2028-29. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
The docstring said the gaps between the amounts the model holds and the amounts entered can add up to a penny while net income and the allowances stay under £131,072. They can add up to more. A 2026-27 Scottish recipient with a £2,127.75 Gift Aid gift and £128,677.12 of net income sits 1.25p over the raised limit under every share, and the model gives the reduction, as main does. It also said the model stores no rounding other than the nearest more than half a penny beyond the shared amount because rounding both deductions down never sets more than that amount. The reason is the ranking: any other rounding that sets more than half a penny beyond the shared amount ranks last, and the nearest never does. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
juaristi22
left a comment
There was a problem hiding this comment.
Follow-up review of 200dc10e0c3181fd8c2d234ba423c284b9317d79, incremental from 965b9d1: COMPLETE — request changes; C1 STILL OPEN; no new findings or material evidence gaps.
C1 — The original source-qualified household remains undercharged about £152 annually. The complete production-module AST, excluding docstrings, is identical to the last reviewed head; dependencies and parameters are unchanged. The new tests and documentation do not repair the existing finding. The stored rate test is now at income_tax_allocation.py:873, with the rounding-ranking guard at lines 946–948.
The same 2026–27 England couple, both 40 with a zero-income donor, has recipient pay £190,529.99, savings £9,000.02, dividends £1,570, a genuinely qualifying current-year trade loss of £50,275 and qualifying cash Gift Aid of £80,044. Valid residence/election, eligibility of the loss and Gift Aid, and no Married Couple’s Allowance claim remain explicit premises. The loss fits s.24A’s cap, and the calculation retains the s.64 loss relief, s.414 Gift Aid, s.25 allocation and s.55B conditions.
At this exact head, identical unforced household inputs again grant £252 Marriage Allowance and charge £27,299, instead of no Marriage Allowance and approximately £27,451.004 statutory least liability. The independent policy check preserves this conclusion under both stated dividend-counterfactual readings discussed in #2915; it does not resolve every inherited case in that issue. Please correct this final-tax case and add it as a regression while preserving lawful equality at the limit.
Validation: 34 current selected tests passed (27 YAML, seven Python), zero failures/skips: the allocation YAML including new Case 27, the revised independent oracle, and six relevant rounding/final-tax tests. The original C1 household was separately recalculated once. Prior 117 selected passes and three unaffected CPS cases were retained after executable/dependency/fixture relevance checks; they are historical, overlap current coverage, and are not added to the 34. Both independent roles completed; 24 official source/extract pairs were revalidated with no new acquisition.
Case 27’s penny-level final tax is supported, while its unique-allocation explanation is qualified by the unresolved fixed-share/counterfactual question. The revised oracle deliberately excludes PA/PSA step mismatches and requires savings a penny inside the band for strict minimization; its passing result does not certify excluded boundary cases or close C1. Broad author sweep counts and generic-deduction fixtures were not independently certified as statutory household outcomes.
The exact PR snapshot was tested and removed normally afterward. Captured main is d3db7ac0, distinct from merge base b007ac82; no synthetic current-main composition was executed. Current-head hosted checks and Draft status are refreshed before publication. Neither passing focused tests nor later CI clearance resolves C1.
From £65,536 the float32 step is 0.78p or more, so the amounts the model holds can put a recipient entered a penny over a limit of the Marriage Allowance rate test at the limit. The search then gave that recipient the £252 reduction, which main and the law deny. The #2913 review's C1 is one: pay £190,529.99, savings £9,000.02, dividends £1,570, a £50,275 trade loss and an £80,044 Gift Aid gift. The model charged £27,299; it now charges £27,451, as main does. Where any amount the test depends on reaches £65,536 (LOW_PRECISION), the float64 test keeps main's room below each limit (RATE_TEST_ROOM plus RATE_TEST_ROOM_FRACTION of the limits and the income after deductions). The amounts are net income, net income before the trade loss relief, the relief, the allowances, savings, dividends, an exclusion from earned income, the grossed-up gift and the limits it raises (_low_precision). For a recipient with such an amount the search decides the move as main does (_moves_with_room) and stores the nearest float32 rounding, and the model's answer keeps the float32 test, so the model gives main's result. A recipient entered exactly at a limit, with such an amount, is denied wherever main denies: the model holds pay of £190,529.98 as the same float32 value as £190,529.99. Under £65,536 nothing changes, and income at a limit still meets the test. _stored_share no longer asks that the exact share fail in float64 before it ranks last a rounding that passes only in float32. That condition only ever changed the share stored for recipients with large amounts, who now get the nearest rounding. On 671,793 synthetic recipients with every amount under £65,536 it changed no stored share. Tests: C1 and its £190,529.98 twin through a full Simulation; eight more recipients a penny over a limit with an amount of £65,536 or more (England, Scotland, Gift Aid, trade loss, 2026-27) and one in 2027-28; the limits each side of £65,536; a 2027-28 recipient at the limit who keeps main's nearest rounding. Three tests move to recipients with every amount under £65,536, so they still pin OVER_DEDUCTION and the float32-only rule. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Check 1 asks that the model's share is one the law allows: each deduction within its component. It allowed half a penny, the margin the rate test allows at the savings nil rate band. The model works the share from the float32 amounts it holds, so a deduction can pass its component by more. Two valid 2027-28 draws failed with "model share infeasible": pay £8,542.77, savings £58,071.67, dividends £9,471.52 (the model sets £4,027.2383 against savings, 0.83p more than the law leaves for them), and pay £11,743.36, savings £6,860.08, dividends £23,171.51 (0.52p less). feasibility_margin bounds that error: half a float32 step of each component, five half steps of net income (three additions and the old order's two subtractions), a step of the allowances, and a step of each stored deduction. Check 1 uses it for feasibility only. The rate test keeps its half penny, and no recipient is left out. Both rows run as explicit examples. The docstring and a comment said float32 leaves net income under a penny from the amounts drawn. That holds near the rate test's limits. A draw of £263,789.16 in all holds net income 3.5p lower, and the text now says so. The docstring also says why the room the search keeps from £65,536 never decides a recipient these strategies draw. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Two tests for a recipient the rate test holds to room (an amount of £65,536 or more). A 2026-27 recipient with £400,000 of dividends and £100,000.30 of deductions. The nearest float32 value of the deduction sits 0.3p under it. The value above sits within OVER_DEDUCTION and saves 0.3p of tax, and the search stored it before the room rule. The search now stores the nearest value, as main does. A Scottish recipient in 2027-28 whose least tax leaves as much property income as the rate test allows. The search finds that share on the line it adds at the limit less the room. With the line at the statutory limit only, it leaves £500 more of savings at 24% and charges £15 more. Each fails with the module of 200dc10, and with the one line it pins changed. On the message of 259bbb9: two tests moved to recipients with every amount under £65,536; test_search_ranks_last_a_rounding_more_than_half_a_ penny_beyond_the_allowances is new; and the unit test of the exact-share condition went with the condition. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
… income tested The room rule read only the amounts the Marriage Allowance rate test reads: net income, the allowances, savings, dividends, the gift and the limits. A penny can hide behind them. Pay of £148,609.46 less £108,409.45 of expenses is £40,200.01, but float32 holds that pay as £148,609.453125 and the model holds £40,200.00, at the limit, with every amount the test reads under £65,536. The model then gave the £252 reduction where the law and main deny it. _can_hide_an_excess now bounds the float32 error in net income, the allowances and the grossed-up gift, from the inputs up (_held_error): - an input's distance from whole pence, under £131,072, and no bound above; - for each sum on the way (adds, subtracts and the formulas in SUMS), the distance from the amount held to the float64 sum of its parts as held; - no bound for an amount the function cannot follow: another formula, a capped relief, or an amount supplied in place of its formula. The test keeps main's room where the bound reaches the least amount the entries can sit over a limit. That is a penny for whole-pence entries, and a quarter, a half or three quarters of a penny where a Gift Aid gift's gross amount leaves the limit between two pence. The search and the model's answer read the same flag (c.low_precision), with the £65,536 rule as before. Tests pin the review's rows (pay or profits less expenses, a gift, and the at-limit twin denied as on main), a hidden dividend row, three quarter-penny gift rows, an amount supplied in place of its formula, and five recipients at the limit who keep the reduction. Docstrings, the changelog fragment and the property test's note now state the rule as the code applies it. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
No code changes. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
juaristi22
left a comment
There was a problem hiding this comment.
Review status: COMPLETE — request changes at e4ad32cbb34fdfb0bf4167122e9ba92d7aec5c80.
C1 — RESOLVED. The original source-qualified over-limit household now receives £0 Marriage Allowance and pays £27,451 income tax, rather than £252/£27,299. The original negative result remains supported under both stated s.55B(2)(ba) readings.
C2 — Preserve the supported raw-input/YAML route in the precision guard (critical). At income_tax_allocation.py:709, _held_error treats a supplied employment_income value as unexplained formula error when its employment_income_before_lsr component is absent. For the ordinary 2026 married recipient with a zero-income spouse, pay £40,200, savings £9,000 and dividends £1,570, constructor inputs produce MA £252/final tax £7,288. The supported Simulation.set_input("employment_income", 2026, [40200, 0]) route with the same financial inputs produces MA £0/tax £7,440: the guard interprets the £40,200 as error and restores the room below the limit. Supplying the before-LSR component instead restores £7,288.
The source-qualified allocation leaves pay £37,700, savings £500 and dividends £0, so the reduction is available under ITA 2007 ss.10, 12B, 25 and 55B. Clearing dividends avoids the disputed ba counterfactual. The current campaign returned 118 passes and 5 failures: retained YAML Cases 24–27 and the new least-liability property's explicit £40,199.98 case. A narrow unmodified input-route replay established the cause; no second suite was run. Please make the guard recognize ordinary supported setter/YAML inputs consistently while retaining protection for genuine uncertain overrides. This blocks the PR's advertised boundary feature and functional tests; it is not a claim of a new £152 regression against main, which already missed this boundary.
A1 — Refresh the description (nonblocking). The present-tense text still says the room constants are removed and describes former high-income grants as current behavior. The new adaptive guard conditionally restores the room. Update that algorithm section and qualify the obsolete examples; results explicitly attributed to 200dc can remain historical.
Independent policy/source and code/test roles completed with no material evidence gaps; 24 official original/extract pairs were retained and validated. Hosted YAML CI also fails at this exact head; Python and aggregate checks remain pending. The hosted failure's cause is not inferred from the local log. The PR remains a draft. Remaining high-income precision approximations and the separate #2915 interpretation question are not certified by closing C1.
_held_error checked every amount with a sum (adds, subtracts or SUMS) against its parts. Pay set through Simulation.set_input, a YAML test or a dataset rebuilt in place sits in employment_income itself, and its parts are nil, so the check read the whole of the pay as unexplained error and the rate test kept its room. A married recipient with pay of £40,200, savings of £9,000 and dividends of £1,570 in 2026-27 was then denied the £252 reduction and charged £7,440, where the same amounts given to the constructor (which moves pay to employment_income_before_lsr) were charged the law's £7,288 (ITA 2007 ss. 10, 12B, 25 and 55B). The walk also calculated the parts of a supplied amount, which the tax calculation never does. After a rebuild in place from a dataset, that ran employer_ni_fixed_employer_cost_change against the previous population's baseline and raised (test_rebuilding_in_place_follows_the_new_source). An amount supplied as an input for the year is now an entry, whatever formula or sum the variable has: its bound is its distance from whole pence under £131,072 and infinite from there, and the function reads none of its parts. is_supplied_input in supplied_inputs.py answers for any variable from the value the engine returned: the walk follows lists a reform can change, so its names cannot all sit in SUPPLIED_INPUT_VARIABLES. A value the model stored itself (set_model_value), a neutralized variable and a formula a reform replaces keep the earlier rules. The test of taxable pay supplied in place of its formula now expects the law's answer: the reduction, £7,288, and a nil bound. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
…n the rule With a supplied amount read as an entry, _held_error stops at it. The Marriage Allowance rate test also reads savings, dividends, property income, the trade loss relief and pension relief on their own, so a supplied net income (or net income before the relief, or allowances) would leave those without a bound. _can_hide_an_excess now bounds each one the walk from net income and the allowances did not reach (READ_WITH_NET_INCOME). The rule replaces the check for savings and dividends a reform takes out of the parts of net income, and gives the same answer there. A grossed-up gift supplied in place of its formula is an entry too: its bound is its own distance from whole pence, not its distance from five quarters of a gift that was never entered. Tests, each with the law's or main's answer worked by hand: - pay of £40,200 set through Simulation.set_input after construction, and the same household through the constructor: the reduction and £7,288; - pay of £148,609.45 and £148,609.46 set through set_input, less £108,409.45 of expenses: no bound from £131,072, so the room stays and both are charged £7,440; - a reform that takes £10,000 off pay in taxable_employment_income: the amount held stops matching its parts, the room stays, £7,440; - a supplied net income with dividends of £201,570 less £200,000 behind it: the room stays, £7,440; with dividends of £1,570, £7,288; - a gross gift of £1,000 supplied as an input: £7,488; - a value stored with set_model_value gets its variable's own rule, and the same value set through set_input is an entry. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
…hangelog The module docstring said an amount supplied in place of its formula gets no bound. It now says what the code does: an amount supplied as an input for the year is an entry, bounded by its distance from whole pence under £131,072, and the guard reads none of the amounts its formula would; a value stored with set_model_value keeps its variable's rule; and where the walk stops at a supplied net income or supplied allowances, _can_hide_an_excess bounds the other amounts the test reads on their own. The changelog fragment gains one sentence with the same rule, and the property test's note says its amounts are set through set_input. No code changes. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
juaristi22
left a comment
There was a problem hiding this comment.
Review status: COMPLETE for this CI follow-up — request changes at unchanged head e4ad32cbb34fdfb0bf4167122e9ba92d7aec5c80.
C3 — Keep precision-error traversal safe after rebuilding a simulation (critical). The completed Python 4/8 job fails test_data_built_imputations.py::test_rebuilding_in_place_follows_the_new_source. A supported cloned simulation is rebuilt from a two-person situation into an 80-person dataset. Calculating attends_private_school reaches the new _inputs → _can_hide_an_excess → _held_error traversal at income_tax_allocation.py:703–709, then employer_ni_fixed_employer_cost_change.py:56, mixing current-population pay and baseline salary-sacrifice arrays. It raises ValueError: operands could not be broadcast together with shapes (80,) (2,).
Please keep the precision-error traversal compatible with rebuilt simulations. This is a distinct integration/functional-test blocker from C2; no new cash-error or standalone-main-control reproduction is claimed. The official log reports 1 failed, 1,981 passed, 6 skipped. Its checkout is synthetic merge 1614385aad8e5f95bdda32420e557891b8b7960c, explicitly merging this exact PR head into main d3db7ac07d3cc718400f38ba8ede429d38d6855e.
C2 remains open. The Python 7/8 job independently fails the known least-liability property's eight £40,199.98 rows: model £7,439.99609375 versus strict least liability £7,287.998. Its 1 failure, 2,064 passes and 11 skips corroborate C2 and are not another finding. The Result failure and Python 3 cancellation are not separate defects.
C1 remains resolved; A1 remains open. The code and description are unchanged from the prior reviewed head. This bounded follow-up used official job logs and a code trace, with no new local model or test execution and no repeat statutory review. The prior valid programme/source review remains applicable; hosted shard counts are separate from the retained local 118 passes/5 failures. Two critical findings remain: C2 and C3.
The reform and supplied-net-income tests now say the law gives the reduction and £7,288, so the £7,440 they assert is the cost of the room. The SUMS comment notes that a supplied amount is an entry. The KEEPS_ROOM_AT_THE_LIMIT dividend row's comment no longer says float32 holds £201,570 and £201,570.01 as one value (it holds 201,570.0 and 201,570.015625); both entries are £131,072 or more, so they get no bound. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
juaristi22
left a comment
There was a problem hiding this comment.
Review status: COMPLETE at e5216457d7f311807db6d85682f0ebabda1122d8 — C1, C2 and C3 resolved; A1 remains open and nonblocking.
C1 remains resolved. The original source-qualified over-limit household still receives MA £0 and pays £27,451 income tax. The retained large-input precision limitations remain qualified; this does not claim every lawful boundary outcome is solved.
C2 is resolved. The original constructor, raw employment_income setter and employment_income_before_lsr setter routes now all give MA £252/final tax £7,288 for the qualified £40,200 pay / £9,000 savings / £1,570 dividends household. The raw setter still leaves the backing before-LSR value zero, so the actual representation mismatch is exercised. The former five failed selectors also pass.
C3 is resolved. The actual previously failing test_rebuilding_in_place_follows_the_new_source test passes in 3.623 seconds on this captured head. It rebuilds the two-person clone into an 80-person multi-year dataset through the affected path, with no forced guard or replacement witness.
One combined campaign passed 191 tests (100 Python, 91 YAML), 0 failures, including changed guard tests, shared-input regressions, the actual C3 rebuild, direct MA/YAML/CPS regressions and the original financial controls. The exact snapshot/runtime, 17 lock pins and 194 Core payload files were verified. Independent policy/source review retained and validated 24 official original/extract pairs. No new source acquisition, dependency installation or population run was required. This is not an execution claim for a fresh synthetic merge with current main.
A1 — STILL OPEN: the description is unchanged. It still says the room constants are removed and presents older high-income grants as current behavior. Please describe the conditional room and new supplied-entry handling, and qualify obsolete examples by their historical heads. The Local-results section already labelled 200dc can remain historical.
Approval remains deferred while A1 is open, the PR is a draft and required hosted CI is incomplete. Current-head Python shards and aggregate checks were still running at the review capture; no old-head CI success or failure is transferred.
juaristi22
left a comment
There was a problem hiding this comment.
Approved at e5216457d7f311807db6d85682f0ebabda1122d8 after the same-head description and readiness follow-up.
A1 is resolved. The rewritten description now explains the conditional precision room, supplied-input handling, historical results and remaining limitations. Independent code/test and policy/source review agree. C1, C2 and C3 remain resolved on this unchanged commit; no open findings or material evidence gaps remain in the reviewed scope.
The current-head evidence remains 191 passing tests (100 Python, 91 YAML), zero failures, including the qualified final-tax/input-route controls and the actual rebuild regression. Its runtime and source custody were revalidated, including 24 official original/extract pairs. These are retained results; this follow-up did not rerun model tests or simulations. All 21 latest CI contexts pass at this exact head, including Result and Fix evidence, and the PR is ready for review.
The documented inherited precision limits, unexecuted-path caveats and the existing section 55B interpretation qualification remain as recorded in the full review. The current aggregate report is official CI evidence, with no independent private-data rerun. This approval does not adjudicate issue #2915 or broaden the prior legal interpretation into a unique oracle.
|
I've now run locally at e521645 the checks this description lists as not run there. Each compares this head with
|
|
An independent review of e521645 requested changes for six P1 issues. I reproduced five on this head against
This head also treats computed amounts as entries when callers use plain I'm changing I've moved the PR back to draft. María, your approval at e521645 came before these findings. |
Fixes #2912
What and why
Since #2830, the model sets reliefs and allowances against non-savings income, savings and dividends in the share that gives the least tax (ITA 2007 s. 25(2)). It also counts the Marriage Allowance reduction each share wins. To guard against float32 rounding, its search counts a share as meeting the rate test (s. 55B(2)(b) and (ba)) only with room below each limit. The room comes to about 3.9p near the £37,700 basic rate limit. Parliament charges the basic rate on income up to the basic rate limit (s. 10(2)), so non-savings income at the limit meets the test. Where every share that meets the test leaves income within the room, the search finds none, and the model denies the reduction.
For example, take a recipient in England in 2026-27 whose partner has no income, with pay of £40,200, savings of £9,000 and dividends of £1,570:
mainmaindenies the reduction in the first four rows, where the qualifying share leaves pay at the limit or, in the second row, 2p below it, inside the room. The recipient gains £252 less the extra tax that share costs: £152 in the first row. In the fifth rowmaingives the reduction but keeps the old order of pay, then savings, then dividends. That order sets £367.26 against savings that bear no tax at the 0% starting rate. Setting it against dividends instead costs £39.48 less and also leaves income at the limit. In the last row, a penny more pay than in the fourth leaves income a penny over a limit under every share, so neither gives it. By reading, every share leaves at least £37,700 of pay, so the law charges 37,700 × 20% = £7,540.The law column follows ss. 10, 12B, 25 and 55B, as the YAML cases and test docstrings work rows 1 to 6. Each
mainfigure comes from a run at the PR's merge base, b007ac8. The last column comes from runs that entered every amount in the situation: rows 1 to 5 on the working tree before commit 6aa9124, and rows 6 and 7 at 5c8c5e1. At e4ad32c, CI's YAML job failed rows 1 to 4 as Cases 24 to 27, and the property test failed row 2. By reading, both put the pay inemployment_income, asset_inputdoes. At e521645, CI's YAML job passed Cases 24 to 27, Python 7/8 passed the property test, and Python 2/8 passedtest_rate_test_lets_income_reach_the_basic_rate_limit. YAML Cases 24 to 27 assert rows 1 to 4, and that test asserts row 5. The property test runs rows 1 to 4 as examples, but requires the reduction only in row 2. By reading, e521645 applies the same rule to these rows whether the pay comes from a situation, a dataset, a YAML case orSimulation.set_input.The change
The search in
policyengine_uk/utils/income_tax_allocation.pynow applies the rate test at the statutory limits, unless one of two rules finds that float32 could hold income entered over a limit at the limit. It adds £0.000001 (TIE) to the non-savings and basic rate limits to absorb float64 rounding. Where a share leaves savings withinTIEof the savings allowance, or dividends withinTIEof nil, the search still sets them to the allowance or to nil.The model holds amounts in float32, and each amount and each float32 sum can sit half a float32 step from the amount entered. Under £65,536 the step stays at 0.39p or less, so it takes more than five roundings the same way to hide a penny. From £65,536 the step reaches 0.78p, and three roundings can hide one. From £131,072 it reaches 1.56p, and two whole-pence amounts can store as one. A recipient entered a penny over a limit can then hold income at the limit.
So the float64 test keeps
main's room below each limit for a person either rule catches (c.low_precision). The room comes to £0.001 (RATE_TEST_ROOM) plus a millionth (RATE_TEST_ROOM_FRACTION) of the larger of the limits and the income after the deductions: 3.9p at £37,700 and 13.9p at £138,255. It comes off the limit on non-savings income, the basic rate limit and the starting rate limit for savings.LOW_PRECISION)._low_precisionreads net income, net income before the trade loss relief, that relief, the allowances, savings, dividends, an exclusion from earned income, the grossed-up Gift Aid gift and the two limits._can_hide_an_excess). That amount is a penny where the limits fall on whole pence. A Gift Aid gift raises the limits by its grossed-up amount (s. 414(2)(b)), five quarters of the gift at the 20% basic rate. A limit can then fall between two pence, and the least excess comes to a quarter, a half or three quarters of a penny.How the second rule bounds the error
_can_hide_an_excessadds bounds on net income, the allowances, the grossed-up gift and the other amounts the test reads._held_errorworks each bound from the entries up:is_supplied_input). The function asks that question first. Under £131,072 (INDISTINCT) an entry sits within 0.39p of the whole-pence amount entered, so its bound is its distance from whole pence. From £131,072 an entry gets no bound. For a supplied amount, the function reads none of the parts its formula or sum would.addsandsubtracts, or an entry inSUMS), the function starts from the parts' bounds. It adds the distance between the amount held and the float64 sum of the parts as held, which measures the float32 rounding in the sum. Where a reform replaces a formula, the amount stops matching its parts, and the distance takes the difference.Then
_can_hide_an_excessbounds, on its own, each amount inREAD_WITH_NET_INCOMEthat the walk did not reach: taxable savings, dividends and property income, the trade loss relief and pension relief. The walk stops short of them where a caller supplies net income, net income before the relief or the allowances, or a reform takes savings or dividends out of net income. A grossed-up gift supplied as an input is an entry. Otherwise the gift's bound is the distance between the grossed-up gift held and five quarters of the gift, and a gift of £131,072 or more gets none. An exclusion from earned income, which only a reform gives, gets no bound.For example, pay of £148,609.46 less £108,409.45 of expenses comes to £40,200.01. With £9,000 of savings and £1,570 of dividends, the Personal Allowance leaves £38,200.01, a penny over the limit plus the savings allowance, so the law gives no reduction. Float32 holds the pay as £148,609.453125, so the model holds taxable pay of £40,200.00. Every amount the test reads sits under £65,536, so the first rule does not catch this recipient. The pay exceeds £131,072, so the second rule finds no bound, and, by reading, the model denies the reduction, as
maindoes.Amounts supplied as inputs
is_supplied_input(population, name, period, value), new inpolicyengine_uk/utils/supplied_inputs.py, says whether the value the engine returned is the input supplied for that year. That input can come from a situation, a dataset, a YAML case orSimulation.set_input. By reading, the constructor moves a situation's or dataset's pay intoemployment_income_before_lsr, and the walk reaches it throughemployment_income's sum.Simulation.set_input, a YAML case and a rebuild in place leave pay inemployment_income, where the walk stops.The helper needs no entry in
SUPPLIED_INPUT_VARIABLES. By reading, a valueset_model_valuestores over no supplied value, a neutralized variable, and a value the engine carries over or uprates from another year read as not supplied. So does every value under policyengine-core's legacy mode, which keeps no record of inputs. Only theset_model_valuecase has a test.By reading, the helper reads the stored input as
supplied_inputdoes, and also requires it to equal the value the engine returned. policyengine-core 3.34.9, the least versionpyproject.tomlallows, marks each value it fills in as derived: a formula result, or a carried-over, uprated or default value (Simulation._cache_result). By reading,stored_supplied_valuereads only a storage tier whereHolder._stores_user_inputfinds a value core did not mark derived.Two review findings at e4ad32c bear on this rule:
Simulation.set_input, or in a YAML case, as formula error. Lawful recipients at a limit then lost the reduction, and Cases 24 to 27 failed in the review's runs. By reading, at e521645 that pay is an entry. Float32 arithmetic on each case's entries and one three-part sum, a shorter tree than the model's, gives bounds of 0, 0.05p, 0 and 0.34p for Cases 24 to 27. Each sits under the penny of least excess.test_data_built_imputations.py::test_rebuilding_in_place_follows_the_new_sourceraisedValueErrorfor shapes (80,) and (2,) in CI. On a simulation rebuilt in place from a dataset, the guard worked out the parts ofemployment_income. One part,employer_ni_fixed_employer_cost_change, read the old two-person baseline. By reading this branch's tree,build_from_multi_year_datasetstores each column throughSimulation.set_input. The guard then stops at the suppliedemployment_incomeand calculates none of its parts. By reading,mainat d3db7ac keeps that loop, and itsset_inputadds checks only for stored draws and student loan take-up.The search
For a recipient either rule catches, the search decides and stores as
main's does (_moves_with_room). It counts on the reduction only where the exact share meets the test with the room, and it stores the float32 values nearest that share's deductions. The model's answer keepsmain's float32 test, so such a recipient can still get the reduction where that test passes.For anyone else, the search rounds each deduction of the least-tax share down and up to float32 and keeps the rounding that leaves the least tax after the reduction (
_stored_share). Among roundings within £0.001 (TOLERANCE), it prefers one that sets the whole shared amount and no more. A rounding ranks last if it sets more than half a penny beyond that amount (OVER_DEDUCTION), or meets a recipient's rate test only in float32. Neither rule applies to the nearest rounding. The search moves a person only where the stored share saves more than £0.001 against the old order.A share meets the test where it does in either arithmetic (
_rate_test_on_stored): in float32 as onmain, or in float64 from the amounts held, with the room for a person held to it. Pay of £37,401.34, savings of £5,081.08 and dividends of £7,787.58 in 2026-27 leave income at the £37,700 limit, but, by reading,main's float32 test reads it £0.0039 over (test_rate_test_on_stored_counts_shares_that_meet_the_test_only_in_float64).meets_marriage_allowance_income_conditionsapplies the same function to the stored deductions, so the model gives the reduction wherever the search counted it.Limits
main. Pay of £148,609.45 less £108,409.45 of expenses comes to £40,200.00, at the limit with £9,000 of savings and £1,570 of dividends, but float32 holds that pay as it holds £148,609.46. The law charges £7,288, and, by reading, the model charges £7,440: the room costs £152. Three of the supplied-amount tests below pin a £152 cost of the room.is_supplied_inputcannot tell an entry from a value the model computed and stored with plainSimulation.set_input, notset_model_value. The CPS marriage reform sets each comparison branch'snet_incomewith plainset_input(policyengine_uk/reforms/cps/marriage_tax_reforms.py, lines 206 and 219). On those branches the guard reads that net income as an entry. An amount hidden behind it, such as pay less expenses, does not keep the room there, though the main simulation's walk still reaches it.dynamics/labour_supply.py, throughinput_variable,employment_incomeby default), participation (dynamics/participation.py) and marginal-rate (variables/household/marginal_tax_rate.py) paths also set pay with plainset_input, so the guard reads that pay as an entry too. No run measures the effect of either item on tax.adjusted_net_incomekeeps the room unless the partsSUMSlists add up to the net income worked back from it.net_income's formula then works net income back from it (net_income_from_adjusted_net_income) without reading those parts. The guard checks that net income against their sum, and any difference counts as error.What stays as on
mainThe float32 test stays, so rounding can still put income entered over a limit back on it.
Storing savings in float32 can move them over the savings nil rate band. A 2026-27 recipient with pay of £157,600, savings of £140,500.01, £140,000.01 of deductions against them and a £96,000 gift has £500 left, at the band, so the law gives the reduction. The model holds the savings as £140,500.015625, and only the nearest rounding puts them back on the band. One entered 0.7p over the band can hold the same amounts, so the model gives both the reduction, as
maindoes.test_search_keeps_the_nearest_rounding_where_stored_savings_sit_over_the_bandasserts both. It passed on the working tree before 6aa9124 and in CI's Python 6/8 at e521645.The search rounds only the share with the least tax after the reduction, so it can miss a share that meets the test only once rounded. Take pay of £37,500, savings of £11,000.03 and dividends of £2,069.97 in 2026-27. The one qualifying share clears the dividends, leaves £500 of savings and sets nothing against pay, so the law charges 37,500 × 20% less £252: £7,248. The model holds savings and dividends 0.024p over the £13,070 entered, so the share the search scores fails the float64 test. The model charged £7,329.78 on
mainand at 5c8c5e1.The model still sums net income in float32. Pay of £44,266.35, savings of £4,869.28 and dividends of £1,634.37 sum to £50,770, but the model computed £50,770.0039 and charged £7,440.001, on
mainand at 5c8c5e1, against the law's £7,288. By reading, e521645 treats these three cases the same: the savings reach £65,536, and the other two bounds stay under a penny.Tests
What the tests pin
Supplied amounts, in
test_income_tax_allocation.py. Each but the last asserts a 2026-27 recipient's reduction and tax to the penny. The "fails if" notes come from reading the code.test_rate_test_reads_an_amount_supplied_in_place_of_its_formula_as_an_entry: taxable pay of £40,200 supplied as an input, with £9,000 of savings and £1,570 of dividends. It asserts £252 and £7,288, a nil bound on net income, and that the walk stops at taxable pay. It fails if_held_errordoes not askis_supplied_inputfirst.test_rate_test_reads_pay_set_as_an_input_as_an_entry: the same recipient with pay in the situation and with pay set byset_input("employment_income", 2026, [40_200, 0]), the review's call. Both routes assert £252, £7,288, a nil bound and no flag. Only the first reachesemployment_income_before_lsr.test_rate_test_keeps_room_for_pay_set_as_an_input_from_131_072: pay of £148,609.45 and £148,609.46 set withset_input, less £108,409.45 of expenses. Both store as £148,609.453125 and get no bound, so the test asserts £7,440 for both, though the law gives the first the reduction. It fails if an entry from £131,072 gets a bound.test_rate_test_keeps_room_where_a_reform_replaces_a_formula: a reform takes £10,000 off pay in taxable pay, so pay of £50,200 leaves £40,200. The check against the model's own formula leaves a £10,000 bound, and the model charges £7,440. It fails without the check of each sum against its parts.test_rate_test_bounds_the_amounts_behind_a_supplied_net_income: net income of £50,770 supplied for two recipients. Dividends of £201,570 less £200,000 of deficiency relief get no bound, so it asserts £7,440 for the first; for the second, with £1,570 of dividends, it asserts £252 and £7,288. It fails without theREAD_WITH_NET_INCOMEloop.test_rate_test_reads_a_gross_gift_supplied_as_an_input_as_an_entry: a £1,000 grossed-up gift supplied with no gift behind it raises the limit to £38,700. With pay of £41,200 it asserts £252 and 38,700 × 20% − 252 = £7,488. It fails if the guard checks a supplied gross gift against the gift.test_held_error_gives_a_value_the_model_stored_no_bound: a £500 trading allowance deduction stored withset_model_valuegets no bound, and the same £500 set withset_inputgets a nil bound.The rate test at the limits, and the two rules:
least_tax_allocation.yamlCases 24 to 27 pin the table's first four rows, and each fails onmainat b007ac8.test_rate_test_lets_income_reach_the_basic_rate_limitpins the fifth.test_model_tax_is_the_least_liability_the_law_allowsintest_marriage_allowance_least_liability_properties.py(new) checks the model against an oracle. Its oracle reads only rates, limits and allowances from the parameter tree. Hypothesis draws 40 examples of eight married recipients each, in London in 2026-27 or 2027-28. The test asserts that the model charges the law's liability at its own share, gives the reduction wherever a strict rate test passes, and gives it nowhere a loose one fails. It also asserts that no share on its grid leaves less liability, under the strict test, than the model charges. Rows 1 to 4, the £37,500 recipient and four more recipients run as explicit examples. The test sets its amounts withset_input.test_rate_test_denies_a_penny_over_the_limit_that_float32_cannot_holdruns C1: pay of £190,529.99, savings of £9,000.02, dividends of £1,570, a £50,275 trade loss and an £80,044 gift. That leaves a penny over the raised limit plus the savings allowance. A twin with pay of £190,529.98 sits at it. Both hold £190,529.984375 of pay, and the test asserts that both pay £27,451. Review 5915401118 reports no reduction and £27,451 of tax for the first at e4ad32c (C1).test_rate_test_denies_a_penny_over_a_limit_at_low_precision, its_from_2027twin andtest_rate_test_keeps_room_where_an_amount_reaches_65_536pin the £65,536 line.test_rate_test_reads_the_amounts_behind_the_income_it_testsruns 16 recipients. Nine sit over a limit with every amount the test reads under £65,536, behind pay less expenses, profits less capital allowances, dividends less relief, or a gift. It asserts no reduction for each, nor for two at the limit whose amounts float32 holds as it holds amounts a penny over. It asserts the reduction for five at the limit whose bound stays under a penny.test_held_error_follows_the_formulas_behind_the_rate_testchecks_held_erroron five people.What ran, and on which code
CI at e521645, merged into
mainat d3db7ac (code run), read at 08:45 UTC on 16 November:least_tax_allocation.yaml, Cases 24 to 27 included.test_rate_test_lets_income_reach_the_basic_rate_limit.test_data_built_imputations.py::test_rebuilding_in_place_follows_the_new_source.test_model_tax_is_the_least_liability_the_law_allows, whose explicit examples include the £40,199.98 row.sign:vat).CI at earlier commits:
Local runs at earlier commits. These entered amounts in the situation unless this section says otherwise.
test_income_tax_allocation.pypassed. One of them then asserted £7,440 for supplied taxable pay; at this head, under a new name, it asserts £7,288. Seven sweeps entered 46,500 synthetic 2026-27 households a penny under, at or a penny over a limit. The model gave the reduction over a limit only wheremaindoes, and denied it to nonemaingives it to. It gave every household it held to roommain's share and, to within £0.0001,main's tax.least_tax_allocation.yamlamong them, passed. The property test's checks held for 600 further draws. A sweep of 24,000 households a penny over a limit, each with an amount of £65,536 or more, gave all of themmain's tax and share.test_marriage_allowance_follows_the_liability_with_nil_ratesfailed on one drawn 2019-20 Scottish reform, as onmain; Marriage Allowance: which allowance share does the s. 55B(2)(ba) dividend test read? #2915 asks which share s. 55B(2)(ba) means.The sweep at 5c8c5e1 ran before the second rule existed, so its counts describe that commit. The property test and the Scottish property file (
test_tax_band_scottish_properties.py) set pay withset_input, and their local results above come from that commit too. By reading, the pay they set is an entry at e521645. The property test's docstring argues that its recipients' bounds then stay under a penny.Not run locally at e521645
No test, YAML case or simulation has run locally at c7cf190, dc87f9c, 2441024 or e521645, because the host was under a disk write-stop.
CI runs this branch merged into
mainat d3db7ac. Since b007ac8,mainhas changedsimulation.pyandsupplied_inputs.py, adding stored draws and checks on dataset periods. The claims above read this branch's tree. Ofmain's code, this description reads only the dataset loop,set_inputand the helpers_supplied_valuecalls. By reading,mainleaves those helpers as at b007ac8. No reading covers the rest ofmain's changes, but CI passed on the merged tree (see the block under Tests).Test plan
least_tax_allocation.yamlwork the tax from ITA 2007 ss. 10, 12B, 25(2) and 55B. CI's YAML job passed them at e521645 (see the block under Tests).changelog.d/marriage-allowance-rate-test-limit.fixed.mdReproducer
Reproducer:
policyengine_uk/tests/test_income_tax_allocation.py::test_rate_test_lets_income_reach_the_basic_rate_limitReproducer:
policyengine_uk/tests/policy/baseline/gov/hmrc/income_tax/allowances/received_allowances/least_tax_allocation.yaml::Case 24, a recipient's only qualifying share leaves pay exactly at the basic rate limitThe first enters its amounts in the situation and asserts the law's £3,707.52 for the table's fifth row, where
maincharges £3,747. Case 24 asserts the first row's £7,288, wheremaincharges £7,440.axiom: TheAxiomFoundation/rulespec-uk#545 queued
🤖 Generated with Claude Code