Repository navigation
Conversation
scottish_carer_supplement paid 52 weekly rates for any positive
carer_support_payment. It now pays the weekly supplement rate for
min(52, max(carer_support_payment_pre_overlap, carer_support_payment)
/ weekly Carer Support Payment rate)
award weeks where carer_support_payment is positive (SSI 2023/302 reg
14A), so 13 weeks of Carer Support Payment after a move to England (reg
42) bring 13 weekly rates of supplement, £152.10 in 2026-27, rather than
£608.40. The formula holds 52 weekly rates in the amount's float32 dtype,
so where the model computes both amounts the supplement equals main's
bit for bit, and it guards the division against a zero rate.
The documentation names the four cases where the count differs from the
law. YAML cases worked from reg 16(1) and (1A) and Hypothesis properties
cover the bounds, payment, differential, monotonicity, whole weeks, full
year, zero rate and the disable_simulated_benefits path.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Generated by Claude Code |
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. Spending by benefit and service
Caseloads
Standard reform costings (change in gov_balance)
The report suppresses a reform's costing and target change in these years, for the reasons below (
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: 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)
Counted-once checkEach 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.
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
|
|
Ready for hub review Head: Before starting I checked #2791: no comments, no PR, and no Changes
Findings and resolutionsI found F1 myself. F2 to F12 came from an independent three-part review (correctness, tests, writing) of the diff before I opened the PR. I verified each one before changing anything.
Tests run
Revert checkIn a scratch worktree of
MutationsI ran each mutation of the formula against both YAML files (23 cases) and the 7 property tests, and restored the mutation copy's formula afterwards.
Aggregate impactCI's report has finished: run 41630694642, comment 6604442305. Its headline is "Aggregate impact on certified data: pass", comparing base
The only rows it lists are figures that privacy rules suppress on both sides: Disabled Students' Allowance spending and caseload in every year, and two standard reform costings in 2030-31 and 2031-32 (£0 in the other years). The fiscal partition reports Skipped
Judgment calls
Generated by Claude Code |
SSI 2023/302 defines "award week" in regulation 2, which has no numbered paragraphs. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Ready for hub review Verdict: REQUEST_CHANGES at The formula is right. It computes the body's expression, matches FindingsP2-1. The count departs from the law in more than four cases
I ran the head (scratch worktree at
Replace "The count differs from the law in four cases." with "The count differs from the law in these cases." Then add after the sentence that ends "a report of a full year counts fewer weeks in later years.":
In the body, change "In four cases the formula counts weeks differently from the law" to "In six cases the formula counts weeks differently from the law", and add the two bullets in the same words. P2-2. "At most 13 weeks, or up to 25 in all" counts 7-day periods from the move, not award weeksThe body's "The law" section ("So such a carer receives Carer Support for at most 13 weeks, or up to 25 in all after a death in that time"), Reg 42(4) starts the 13-week period "on the date the individual ceases to be ordinarily resident in Scotland", which can be any day. Reg 42(1A) runs "12 award weeks after the first day of the award week following the award week in which the cared for person died". Take a move on a Monday (day 0, in the award week that starts on Sunday, day −1):
Reg 14A counts award weeks, and the supplement is a weekly rate for each. So the stated maxima hold for 7-day periods counted from a Sunday move, not for award weeks in general. The YAML cases still describe situations the law allows: a Sunday move gives exactly 13 and 25 award weeks. Replacement for the body:
For P3-1. The float32 quotient is 52.0, not 51.999999The body says "If the formula divided the float32 amount by the rate instead, it would count 51.999999 weeks in 2026 and pay £608.39996". F1 in the hand-off says the same. I put that division into the formula (mutation M7, The £608.39996 reproduces. In the engine, though, the float32 amount over the Python float rate stays float32 and gives exactly 52.0. The 51.999999 is the float64 quotient. The penny gap comes from multiplying 52 by £11.70 in float32, where
P3-2. "The 2027 rate above" points to nothing
P3-3. The hub's rulespec-uk#398 comment overstates what #2857 counts
Its law quotes and cases W and X are correct (see below). Checked and soundPrevious round (hand-off F1 to F12).
The law.
Code.
Cases.
Invariants and mutations. The 7 tests match invariants 1 to 7 as the body states them. Each mutation ran against both YAML files and the property file in a scratch clone, and I restored the formula after each (
Text.
Tests (local).
CI at the head. All 21 check runs from
None fails. The Aggregate impact report (comment 6604442305, updated 14:53:06Z, run 41646429313 on head Merges.
What I couldn't check
Generated by Claude Code |
juaristi22
left a comment
There was a problem hiding this comment.
Reviewed c79f7e6092102043b8fd3838cc3bd5f7ac57d3ab. COMPLETE — no critical findings or material evidence gaps; two nonblocking documentation findings remain.
A1 — Make the annual-proxy limitation list non-exhaustive. The new “four cases” statement in scottish_carer_supplement.py:25 and the description omits a supplied part-year pre-overlap award with a constant overlapping benefit. For example, £1,123.85 pre-overlap CSP for 13 award weeks and £2,000 State Pension across the year makes the existing annual CSP formula net to £0. Weekly overlap would leave £623.85 CSP during those weeks and £152.10 supplement. This is an existing annual-netting limitation, not a new underpayment caused by this patch. Document it and qualify the broad annual-week description in the filed Axiom #398 follow-up; fractional inferred weeks are also a proxy.
A2 — State the award-week alignment for the 13/25-week examples. Regulation 42 starts the residence-continuation period on the actual move date, whereas regulation 2 defines Sunday–Saturday award weeks. A Sunday-aligned 13-week period spans 13 award weeks; a Monday-starting period touches 14. Qualify the variable prose, YAML examples/header and description with the complete-award-week/Sunday assumption, including the death-continuation example. This is a scope clarification, not an allegation of 14 or 26 cash payments.
The core weekly rule, rates, tax/benefit treatment and actual filed Axiom #398 contract/companions were independently checked against official sources. One focused invocation passed 153 checks, with three final-accounting cases also verified: the conditional 13-week England receipt gives £152.10 rather than £608.40, reduces final income/spending once by £456.30 in the zero-tax case, and reduces net income by £365.04 when the tax reduction is £91.26. The fully computed steady Scottish carer is unchanged. The England cases use a justified supplied continuing award and timing assumptions; annual inputs do not reconstruct migration or historical eligibility.
Current-head CI is green. Approval is withheld while these findings remain and the PR is a draft.
Fixes #2791
Reproducer:
policyengine_uk/tests/policy/baseline/gov/social_security_scotland/scottish_carer_supplement.yaml::Carer in England with 13 weeks of Carer Support Payment gets 13 weeks of supplementaxiom: TheAxiomFoundation/rulespec-uk#398 queued
What the formula does
scottish_carer_supplementnow pays the weekly supplement rate foraward weeks where
carer_support_paymentexceeds 0, and nothing for a carer with nocarer_support_payment. It reads both weekly rates fromgov.social_security_scotland.carer_support_payment. Onmainthe formula pays 52 weekly rates for any positive payment. A carer who moves to England keeps Carer Support Payment for 13 weeks (13 × £86.45 = £1,123.85).maingives them £608.40 of supplement in 2026-27, where Social Security Scotland would pay 13 × £11.70 = £152.10.The formula uses four terms:
carer_support_payment > 0. Social Security Scotland pays the supplement only for an award week in which Carer Support Payment is payable (regulation 14A). Where an overlapping benefit equals or exceeds the payment, Social Security Scotland gives £0 of it that week (regulation 16(2)(b)), and the formula pays no supplement, asmaindoes.carer_support_payment_pre_overlap. Where the model computes this amount,carer_support_payment_pre_couple_limitreturns 52 weekly rates or nothing, andlimit_carer_benefit_to_one_partnerkeeps that amount or sets it to nothing. So a carer whose overlapping benefit reduces the payment but leaves some keeps all 52 weeks.carer_support_payment. Where a user supplies the payment and the model finds no amount before the reduction, as for a carer who has moved to England, the formula divides the payment by the weekly rate to count the weeks.WEEKS_IN_YEAR), so the formula never pays more than 52 weekly rates.The formula doesn't round the weeks, so it counts part of a week for a payment that falls between whole numbers of weekly rates. It works out the share of the year, the amount over 52 weekly rates, and pays 52 weekly supplement rates times that share, up to 1. That product equals the weekly rate times the weeks above. The engine stores amounts in float32, so the formula holds the 52 weekly rates in the amount's dtype, as
carer_support_payment_pre_couple_limitdoes for the earnings limit. For a full-year entitlement the formula then computes a share of 1, and wherever the model computes both amounts the supplement equalsmain's bit for bit. If the formula divided the float32 amount by the rate instead, it would count 51.999999 weeks in 2026 and pay £608.39996, wheremainpays £608.40002. Under a reform that sets the weekly rate to zero, the formula pays no supplement and never divides by zero.The law
The Carer's Assistance (Carer Support Payment) (Scotland) Regulations 2023 (SSI 2023/302):
Where the count differs from the law
In four cases the formula counts weeks differently from the law, and we name each in the variable's documentation:
maincounts the same way, from the annual amounts ofcarer_support_paymentandcarer_support_payment_pre_overlap.Carer in Scotland the model finds eligible keeps 52 weeks of supplement with a supplied part-year payment).Carer with a supplied payment that State Pension reduced keeps 52 weeks of supplement with the amount before the reduction).gov.contrib.policyengine.disable_simulated_benefits, the reform makes a Scottish carer's reported Carer's Allowance theircarer_support_paymentand leaves the amount before the reduction to the model (the comment abovereported_careindisable_simulated_benefits.py). So the formula counts 52 weeks for a reported carer the model finds eligible, even where the report covers only part of the year. For any other reported carer, it counts the weeks the report implies at each year's weekly rate. The reform doesn't uprate the report, so for a report of a full year the formula counts fewer weeks in later years.In line 166 of
docs/book/assumptions/carer-support-payment-earnings.md, the supplement "follows CSP actually payable". The formula still pays it only where Carer Support Payment is payable, so we leave that line as it is.Invariants
For single people aged 14 to 90 in each UK country, in each year from 2024 to 2030:
carer_support_paymentexceeds 0, in years with a positive supplement rate.carer_support_payment, the formula never lowers the supplement.carer_support_paymentnorcarer_support_payment_pre_overlap, the supplement equals, bit for bit,main'scsp.supplement * WEEKS_IN_YEAR * (carer_support_payment > 0), which the test rebuilds.Tests
YAML.
scottish_carer_supplement.yamlgains 9 cases. We worked each value by hand from regulation 16(1) and (1A), at £86.45 and £11.70 a week in 2026 and at the model's 2027 projections, £89.50 and £12.10:Carer in England with 13 weeks of Carer Support Payment gets 13 weeks of supplementCarer in England whose cared-for person dies in week 13 after the move gets 25 weeks of supplementOne week of Carer Support Payment gives one week of supplementCarer Support Payment worth more than 52 weeks gives 52 weeks of supplementCarer in Scotland with no caring inputs and 13 weeks of Carer Support Payment gets 13 weeks of supplementCarer in Scotland the model finds eligible keeps 52 weeks of supplement with a supplied part-year paymentCarer whose State Pension reduces Carer Support Payment and leaves some keeps 52 weeks of supplementCarer with a supplied payment that State Pension reduced keeps 52 weeks of supplement with the amount before the reductionCarer in England with 13 weeks of Carer Support Payment gets 13 weeks of supplement in 2027All 13 cases in the file pass, as do the 10 in
carer_support_payment_overlapping_benefits.yaml.Properties.
test_scottish_carer_supplement_award_weeks_properties.pyholds 7 tests. Each Hypothesis example puts every drawn person in one simulation, with inputs in each year from 2024 to 2030, and checks every year. Each property test draws 12 derandomised examples besides its pinned ones.test_supplied_payment_bounds_and_reference: invariants 1 to 3 with supplied payments, and sometimes supplied amounts before the reduction. It pins the 2026 cases above, and a batch in which the test supplies both amounts.test_computed_payment_bounds_and_reference: invariants 1 to 3 and 6 with State Pension below, above and equal to a year of Carer Support Payment. In a third of the batches it also supplies an amount before the reduction and checks invariants 1 to 3 only.test_supplement_is_monotonic_in_a_supplied_payment: invariant 4, with no tolerance.test_whole_weeks: invariant 5 for k from 1 to 52 and for 52, 52.001, 53, 60, 104 and 1,000 weekly rates, in each year from 2026 to 2030.test_zero_rate_gives_no_supplement(supplied and computed): invariant 7, with only the formula running undernp.errstate(all="raise").test_disable_simulated_benefits_pays_the_weeks_the_report_implies: two Scottish carers who each report £4,000 in 2025. The one who would claim keeps 52 weeks (£608.40 in 2026, £629.20 in 2027). The one who wouldn't gets 4,000 / 86.45 × 11.70 = £541.35 in 2026 and 4,000 / 89.50 × 12.10 = £540.78 in 2027.The 7 tests pass in 62 seconds with
-n 4.Revert check. We ran these tests on a copy of
main:main's 52 weeks, £608.40 or £629.20. The other 4 pass onmain, which pays 52 weeks there too: 60 weeks, the eligible Scottish carer with a supplied part-year payment, and the two State Pension cases.main, whose supplement also never falls as the payment rises and comes to £0 when the model pays nothing.Mutations. We ran each mutation of the formula against both YAML files (23 cases) and the 7 property tests:
FloatingPointError)Tests that read these variables. Every test file that names
scottish_carer_supplementorcarer_support_payment(git grep -l) passes when we run it on its own with-n 4: 19 Python files with 229 tests, and 14 YAML files with 279 cases.policyengine_uk/tests/code_healthpasses 3,091 tests. Invariant 5 oftest_carer_overlapping_benefits_properties.pystill holds. Intest_disable_simulated_benefits_carers.py, no carer's supplement changes: in a copy that logged each call, the formula ran 485 times over 1,294 person-years, 456 of them with a positive payment, and every value equalledmain's bit for bit.ruff format --check,ruff check,ruff check --select F811,F821 policyengine_ukandgit diff --checkpass.Aggregate impact
The Aggregate impact check on certified data passes and flags no move: no household's net income changes in any year from 2025-26 to 2031-32. The certified file,
enhanced_frs_2024_25.h5from policyengine-uk-data 1.58.1, storescarers_allowance_reportedbut neithercarer_support_paymentnorcarer_support_payment_pre_overlap. So the model computes both amounts for every carer in it, and by invariant 6 each supplement equalsmain's bit for bit.🤖 Generated with Claude Code