Skip to content

Value means-tested capital less 10% sale expenses and secured debt - #1969

Open
MaxGhenis wants to merge 74 commits into
mainfrom
uc-capital-sale-expenses
Open

MaxGhenis wants to merge 74 commits into
mainfrom
uc-capital-sale-expenses

Conversation

@MaxGhenis

@MaxGhenis MaxGhenis commented Sep 30, 2026 •

Copy link
Copy Markdown
Collaborator

Fixes #1960.

Reproducer: policyengine_uk/tests/policy/baseline/gov/dwp/capital_valuation.yaml::UC values a mortgaged holiday home as in ADM H1602, policyengine_uk/tests/policy/baseline/gov/dwp/capital_valuation.yaml::UC shares valued less sale expenses bring capital within the limit, policyengine_uk/tests/test_capital_valuation_properties.py::test_valuation_matches_the_regulation_and_never_adds_capital, policyengine_uk/tests/policy/baseline/gov/dwp/capital_valuation.yaml::A Lifetime ISA value given as an input is counted as given, policyengine_uk/tests/test_capital_valuation_properties.py::test_lifetime_isa_reformed_value_is_kept_as_stored, policyengine_uk/tests/test_isa_balances.py::test_person_isa_balances_count_in_full_in_every_means_test

The model now values capital as the regulations require in Universal Credit, Housing Benefit, Income Support, income-based JSA, income-related ESA and Pension Credit. It takes 10% off market value where a sale would incur expenses, then deducts any debt secured on the asset.

Land, property, directly held shares and any corporate_wealth a dataset does not itemise take the 10%. Savings, cash ISAs, unit and investment trusts and stocks and shares ISAs count at full value. The helper floors each encumbered source at nil, so negative equity in one source can't reduce another.

This PR includes PolicyEngine/policyengine-uk#2131, which values share-like capital by asset type. This branch now carries all its commits, so GitHub closed it as merged. See that PR for its full record.

The law

Programme Great Britain provision Northern Ireland equivalent
Universal Credit UC Regs 2013 reg 49(1) S.R. 2016/216 reg 49(1)
Housing Benefit HB Regs 2006 reg 47; HB (SPC) Regs 2006 reg 45 S.R. 2006/405 reg 44; S.R. 2006/406 reg 43
Income Support IS Regs 1987 reg 49 S.R. 1987/459 reg 49, as S.R. 2007/396 reg 4(10) substitutes it
Income-based JSA JSA Regs 1996 reg 111 S.R. 1996/198 reg 111, as S.R. 2007/396 reg 7(11) substitutes it
Income-related ESA ESA Regs 2008 reg 113 S.R. 2008/280 reg 113
Pension Credit SPC Regs 2002 reg 19 S.R. 2003/28 reg 19

The decision maker takes the 10% from gross value before debt, and only where a sale incurs expenses; real property always has them (ADM H1604–H1608). The decision maker then deducts only the debt secured on that source (ADM H1615–H1616). Each programme's parameters start from its existing capital-source list and cite the provision in its own instrument.

Which sources take the 10%

Source 10% Guidance
Savings and cash ISAs No An account counts at its balance, and the costs of withdrawing money are not costs of sale (ADM H1607, H1675).
Land, and other residential and non-residential property Yes Real property always has sale costs (ADM H1606). The model takes supplied property values as gross.
Directly held shares (directly_held_shares) Yes Quoted shares have sale costs: ADM H1665; DMG 29671, 52671, 84763; HBGM W1.513. The input includes employee shares and share options, which the survey asks about together, so share options also take the 10%, an approximation.
Unit and investment trusts (unit_and_investment_trusts) No Bid price, with no costs of sale even through a broker: ADM H1673–H1674; DMG 29680–29681, 52680–52681, 84771–84772; HBGM W1.530–W1.531. The survey's bucket also holds investment trusts (see Methodology limits).
Stocks and shares ISAs (stocks_and_shares_isa, and balances tied to a person) No Withdrawal value: ADM H1656–H1658; DMG 29662–29664, 52662, 84748–84750. H1656 says nothing about costs of sale, and the model reads that silence as full value. Housing Benefit cites the DMG chapter 29 paragraphs as parallel guidance.
corporate_wealth that a dataset does not itemise Yes The whole aggregate keeps the 10% (see Methodology limits).

What changes

Valuation and rounding

  • Each programme has capital.sale_expenses.rate: 0.1, an explicit list of sources and its own capital.round_down rule. valued_capital applies the deduction before secured debt, in float64. UC's existing property route uses the same rate.
  • UC and HB round to the nearest penny, half up (UC reg 6(1); HB reg 80 and SPC HB reg 61(6)). IS, JSA, ESA and PC round down under their own regulations. Each valuation and final assessment follows that rule, as do UC holdings and property allocations.
  • exact_amount recovers an unambiguous whole penny from float32 storage below £131,072 and preserves other stored amounts. Above that boundary, original pennies can be ambiguous, so a result can differ by a penny either way. This PR can't recover digits that float32 storage lost before valuation.
  • The model values a Lifetime ISA with the baseline surrender-value calculation in float64. It rounds each person's value under each programme's rule before summing. A £0.26 balance below the charge-free age gives £0.195: UC and HB count £0.20, and the down-rounding programmes £0.19.
  • The valuation counts explicit Lifetime ISA inputs as given, and replacement formulas keep their stored results. The model recalculates a Lifetime ISA only where the baseline formula applies and no input supplies the value. An explicit £0.195 stores as 0.19499999284744263, the baseline's float32 value, and a regression covers that collision.
  • The float64 recalculation applies the active variable's defined_for mask through Core's entity mapping and keeps Core's stored value outside it. It calculates the mask first and runs the formula only when at least one person applies.

Share-like capital by asset type

On main, #1974 builds share_like_capital from corporate_wealth, or from the sum of its itemised components (directly_held_shares, unit_and_investment_trusts, stocks_and_shares_isa) where they exceed it beyond float32 rounding. This PR splits it in two:

  • share_like_capital_with_sale_expenses holds share_like_capital less the holdings that gov.dwp.share_like_capital.without_sale_expenses lists, kept between nil and share_like_capital. The list holds unit and investment trusts and stocks and shares ISAs. Where the itemised holdings sum to nil or less, this part keeps all of share_like_capital, so data that carry only corporate_wealth keep the flat 10%.
  • share_like_capital_without_sale_expenses holds the rest: between nil and share_like_capital where the itemised holdings sum to more than nil, and nil otherwise.

The formula caps the part with sale expenses at share_like_capital, so the two parts add up to share_like_capital within half its float32 spacing, whatever the signs of the holdings. With only a floor at nil, shares of £1 billion, trusts of −£1 billion and a £1 ISA would split their £1 total into £1 billion and −£1 billion.

All six capital lists name both parts beside savings and cash ISAs. All six sale-expense lists name the part with sale expenses and not the part without, and none names savings or cash ISAs.

The exempt list starts on 7 October 1996, the earliest start of the six capital lists, and the formula sums it from zero, so an empty list works. The formula reads only COMPONENTS to decide whether a household itemises. A comment there says that every exempt name must be one of them.

Stocks and shares ISAs

Main sums cash_isa and stocks_and_shares_isa from each person's balance (#2712). Since #2839, it counts each balance tied to a member in the holder's own benefit unit (cash_isa_countable_capital, stocks_and_shares_isa_countable_capital). It subtracts that balance from the household source that holds it before it allocates the rest.

  • Household route. The exempt list names stocks_and_shares_isa, so a stored household total, or the sum of person balances, sits in the part without sale expenses. Each of the six assessments counts it at its withdrawal value.
  • Person route. household_sources reads the exempt list for the period and maps stocks_and_shares_isa_countable_capital to the part that holds the household's ISAs: the part without sale expenses while the list names stocks_and_shares_isa, and the part with them once a reform removes it. The formulas subtract, value and bound each balance against that part. No sale-expense list names the part without sale expenses, so at baseline each assessment counts a member's balance at face value in the holder's unit.
  • Each of the six formulas passes valued_capital the household sources less those balances (pooled_person_capital). valued_capital values the remainder less 10% where sale_expenses.sources lists the source, then less any debt secured on it. valued_person_capital values each balance as valued_capital values its household source.
  • uc_assessable_capital keeps main's ~covered mask. A reporting unit's claimant's and partner's ISAs stay in the pool, valued with it, and the formula subtracts the report.

A reform that removes stocks_and_shares_isa from the exempt list moves the balances with the household's ISAs into the part with sale expenses, so each assessment counts them at 90%. In test_a_reform_that_takes_isas_out_of_the_exempt_list_values_person_isas_less_10_percent, each household's share-like capital is £5,000 of ISAs held as person balances. Under the reform, the five working-age assessments count a sole holder's £5,000 as £4,500, and Pension Credit does the same for a pension-age holder. Where a tenant and a lodger share £1,000 of savings and the lodger holds the ISA, capital moves from [£500, £5,500] to [£500, £5,000].

The bound on person ISA balances

Main bounds a household's stocks and shares ISA balances by the smaller of stocks_and_shares_isa and share_like_capital. stocks_and_shares_isa_countable_capital adds a third bound: the holdings behind the part that holds the ISAs. Without it, a balance could count capital that part doesn't hold, and the pool would net the balance out of nothing. For example, shares of £8,388,608, trusts of −£1 and a £1 ISA balance leave the part without sale expenses at nil. The balance now holds nil, and with the part with sale expenses off UC's lists, UC counts nothing, where the two-way bound counted £1.

  • At baseline, holdings_without_sale_expenses takes the float32 sum of the listed holdings, kept between nil and share_like_capital where the itemised holdings sum to more than nil, and nil otherwise. The part with sale expenses subtracts that same sum. The stored part without sale expenses comes from a second subtraction, which can round it below the sum, so the bound reads the sum.
  • Under a reform that moves the ISAs into the part with sale expenses, holdings_with_sale_expenses takes share_like_capital less the listed holdings, computed in float64 and kept the same way, or all of share_like_capital where the itemised holdings sum to nil or less. Float64 holds those sums exactly unless one amount exceeds 2^29 times another, so the bound rounds once, to float32.
  • For exempt lists of one or two names, each of these holdings rounds at most once, so a balance they cover keeps its whole value, and the parts' formulas stay within share_like_capital's float32 spacing of them. A longer list can round its sum more than once, and that guarantee doesn't extend to it.

The stored part can still fall short of these holdings, through its own rounding, or because a direct input, a replaced formula or a neutralised formula sets either part. formula_split recomputes the part with sale expenses with its own formula, from the stored share_like_capital and itemised holdings, and casts the result to float32 as the engine stores a formula result. It takes the other part as share_like_capital less that, and reports whether both stored parts equal these values. stocks_and_shares_isa_countable_capital then sets the bound:

  • Where both stored parts equal the formulas' split, the balances may exceed the stored part by up to share_like_capital's float32 spacing, and the pool absorbs that rounding. Past one spacing, the stored part bounds them. For example, a sole holder's £100.01 balance in £20,000.01 of corporate_wealth keeps all £100.01 against a stored part of £100.009765625, and UC counts £18,010.01.
  • Where either stored part differs from the formulas' split, the stored part bounds the balances wherever it falls short of the holdings, however little. An input of the part that doesn't hold the ISAs makes such a split too wherever it changes that part's value, so it also removes the one-spacing allowance. An input or reform that gives the formulas' values changes no result.
  • bounded_holdings floors the bound at nil, so where the stored part falls below nil, the balances hold nil and the pool counts the negative part as it stands.
  • A missing (NaN) stored part never equals its recomputation and never falls below the holdings, so the holdings stay the bound. A missing stocks_and_shares_isa or share_like_capital makes the overall bound missing, and bounded_holdings then leaves finite balances of nil or more unchanged, as it does on main. No committed test covers the missing-value cases.

The bound tests check Universal Credit; the other five assessments read the same stocks_and_shares_isa_countable_capital.

Regulation 77 company holdings

UC disregards an owner-manager's company shares under reg 77(2), and selling shares incurs expenses. HOLDINGS_SOURCE names share_like_capital_with_sale_expenses, so the UC pool budgets company holdings against that part and never deducts them from unit trusts or ISAs.

uc_assessable_capital takes a disregarded holding off the pool and off any complete override at 90%, as UC values shares, and off a recorded financial total in full. In its place, it adds the claimant's or partner's share of the company's capital (reg 77(2)), outside the sale-expense helper. On data that don't itemise, both sources give the same value.

household_uc_company_holding_pool_scale returns nil when UC's sources doesn't list share_like_capital_with_sale_expenses. A reform that stops UC counting that part then takes no holding out of the pool, so no holding removes unit trusts or ISAs in its place. With £30,000 of shares, £10,000 of trusts and a disregarded £30,000 holding, such a reform leaves the £10,000 of trusts in the pool: [£5,000, £5,000] for the owner's and a lodger's units. With a £40,000 report for the owner's unit, the owner's own assessment still takes the holding off the report, and the report takes the £10,000 pool: [£10,000, £0].

Secured debt

Three household inputs hold the debt secured on other residential property, non-residential property and land. Main's #2447 added the first two. This PR adds owned_land_secured_debt and deducts all three in every programme that counts the asset. UC counts no land, so the land input changes the five legacy means tests only. Each input defaults to zero. uprating_indices.yaml lists each once, and the growth factors page lists owned_land_secured_debt under per capita GDP.

Council tax reduction

The council tax reduction formula takes Pension Credit's capital on a savings-credit-only award. It takes UC's capital for a working-age applicant with a UC award, except under Scotland's scheme from April 2022. It inherits their valuation on those routes.

Elsewhere, outside the routes that disregard all capital, council_tax_reduction_assessable_capital takes its own household route (main's #1995). That route counts savings at face value, and land and property other than the home less 10% and less the debt secured on them. This PR adds owned_land_secured_debt to its SECURED_DEBT, as councils deduct it under SI 2012/2885 Sch 1 para 32(b) and its equivalents.

The route floors a negative source or debt at nil, works in float32 and keeps fractions of a penny. valued_capital uses a negative source or debt as given, works in float64 and rounds each valuation to the penny. Both take the 10% before the debt and floor each encumbered source at nil. No test shows a wrong result from those differences, so this PR leaves them.

CI shard table

Main's shard_durations.toml names three share-component tests that this PR replaces, and test_ci_test_shards.py fails on a line that names a missing test. This PR points those lines at the successors and keeps their measured durations.

Methodology limits

  • The Wealth and Assets Survey asks about unit and investment trusts in one question, and the model gives the whole bucket the treatment of unit trusts. Investment trusts trade as quoted shares, and we infer that decision makers apply H1665's 10% to those held directly.
  • HMRC's ISA statistics, Table 9.6, put investment trusts at 8.2% of pooled funds in stocks and shares ISAs at 5 April 2022 and 6.9% at 5 April 2025. Those figures describe ISA holdings. The model uses that composition as a proxy for the trust bucket outside ISAs.
  • The ISA treatment rests on a reading: H1656 values an ISA at what its holder would get by withdrawing it and says nothing about costs of sale. Share options take the 10% as an approximation.
  • On a dataset that doesn't itemise, all of corporate_wealth takes the 10%. That aggregate can still fold in unit trusts, ISAs and, on datasets that predate the private pension split, non-defined-benefit pension wealth.
  • A parameter edit can put a whole holding, such as stocks and shares ISAs, back under the 10%: remove it from gov.dwp.share_like_capital.without_sale_expenses. The person balances follow the list. Applying the 10% to part of a holding, such as the investment trusts in the bucket, would need a weight parameter and a formula change.

Existing tests whose expected values move

Against main at 83c2554b2:

  • person_isa_capital.yaml (main's Count each person's ISAs in their own benefit unit's capital #2839):

    • Case 3's adult child holds a £6,000 ISA inside £9,000 of corporate_wealth. The £3,000 left in the pool counts as £2,700, split £1,800 to the parents and £900 to the child's unit. That unit adds the ISA at face value, so UC and HB capital move from [2,000, 7,000] to [1,800, 6,900].
    • Case 13's ISA moves from £34,000 to £30,600, and its expected capital from [0, 34,000] to [0, 30,600]. Pooled, the ISA would now give each claimant £15,300, within the limit.
    • Case 14's stocks holder's balance moves from £16,790 to £18,567, still above the £16,000 household total, and its expected values stay.
    • Every other case keeps main's outputs, among them Cases 2, 7 and 9.
  • test_person_isa_capital.py (main's Count each person's ISAs in their own benefit unit's capital #2839): the pound-counts-once checks value each part of share_like_capital at the share each programme counts, and allow each programme's penny rounding.

    • In test_household_only_data_keep_todays_capital, UC capital moves from [8,000, 4,000] to [7,800, 3,900]: the 2,000 ISA counts at face value and the other 3,000 of corporate_wealth at 2,700.
    • In test_person_balances_without_household_totals_count_with_their_holders, UC capital moves from [11,000, 9,000, 14,000, 11,000] to [10,900, 8,950, 14,000, 11,000]. The first pool's 1,500 of directly held shares count less 10%. Pension Credit stays at 19,000.
    • In the Pension Credit pound-counts-once check, each pension-age adult's share of the last stored-totals household's pool moves from 2,750 to 2,525.
    • In test_both_forms_in_one_dataset_add_up_to_the_stored_total, UC and Housing Benefit round each unit's capital to the nearest penny, so a household's two units can come to a penny over its total; the test allows that penny.
    • The list-reform test drops share_like_capital_without_sale_expenses, the source that holds the ISA, where main dropped share_like_capital.
  • pension_credit_income.yaml Case 4 (main's Treat income derived from capital as capital in the legacy means tests #1995): the £55,370 let property counts less 10%. Capital moves from £55,825 to £50,288 and deemed income from £92 to £81 a week. Guarantee credit moves from £7,592 to (238 − 81) × 52 = £8,164.

  • pension_credit_income.yaml Case 5: £87,285 of savings and £12,650 of corporate_wealth count as £98,670, where main counted £99,935. Deemed income falls from £9,360 to £9,256 a year, and guarantee credit rises from £3,016 to £3,120.

  • test_savings_credit_only_receipt_properties.py (main's Treat income derived from capital as capital in the legacy means tests #1995): main gave the owner £12,000 of savings and £4,400 of property, so Pension Credit's £16,400 exceeds the £16,000 limit and council tax reduction's £15,960 doesn't. Pension Credit now counts the property at £3,960 too. The test adds £500 of corporate_wealth, which Pension Credit counts at £450 and the council tax route leaves out. The savings credit stays £621.82 a year.

  • test_isa_balances.py (main's Model the ISA subscription limits, with per-person ISA subscriptions and balances #2712) and test_stored_household_totals.py (main's Keep stored household ISA totals after 2032 #2781) keep main's expected values: £6,000 × growth in 2027, and 6 × savings in every year from 2025 to 2040. Both now also check that capital equals its parts at face value, and test_isa_balances.py that the ISA sits in the part without sale expenses.

  • test_capital_share_components.py (main's Itemise corporate_wealth's share-like components for the means tests #1974): the split's tests replace main's, which expected one share_like_capital source in every list.

  • Expectations in these existing files also change, and their new comments cite the 10% or the programmes' penny rounding:

    • the ESA, HB, IS and JSA capital files, is_UC_eligible.yaml, uc_company_analogous_business.yaml, uc_property_capital.yaml, pension_credit_deemed_income.yaml and council_tax_reduction_pension_credit.yaml;
    • test_uc_company_owner_properties.py, test_uc_company_override_properties.py, test_uc_property_capital.py, test_uc_property_capital_mock.py, test_pension_credit_reported_capital_properties.py and test_uc_capital_allocation.py.

    For example, income-related ESA now counts £1,000 of savings and £9,500 of land, shares and property as £9,550, where main counted £10,500.

Invariants

This PR adds capital_valuation.yaml (27 cases), capital_valuation_share_split.yaml (10 cases), council_tax_reduction_capital_valuation.yaml (1 case) and test_capital_valuation_properties.py. It also adds tests to test_isa_balances.py, test_capital_share_components.py and test_stock_capital_periods.py.

The capital property suite (test_capital_valuation_properties.py) checks valuation against an oracle that specifies, from the law and independently of the parameters, which assets take the 10%. It maps the part with sale expenses to corporate_wealth and the part without to nil. It raises a KeyError for any source it doesn't map, and it generates cash ISAs as well as savings.

It now also asserts, for all six programmes, that the counted sources include every name on sale_expenses.sources (d6cf32529; test_capital_valuation_properties.py:235 at 0f35157f9). valued_capital reads only sources, so it would never value a listed name outside them, and the intersection check can't see that name.

test_capital_share_components.py uses Hypothesis on pounds-and-pence inputs that the engine stores as float32:

  1. share_like_capital keeps the supplied corporate_wealth unless the itemised holdings exceed it beyond float32 rounding, and then equals their sum.
  2. Where the itemised holdings sum to nil or less, the part with sale expenses equals share_like_capital and the other part holds nil. Otherwise the first equals share_like_capital less trusts and ISAs, kept between nil and share_like_capital. The property draws signed holdings, from −£5,000 to £200,000, and checks in exact arithmetic that the two parts add up to share_like_capital within half its float32 spacing.
  3. On unitemised inputs, every programme's assessable capital and UC eligibility equal those under the lists before itemising, exactly, for 2026, January 2026, 2027 and January 2027.
  4. For a consistent split, UC capital rises by 10% of a working-age adult's trusts and ISAs, to within the greater of £0.05 and a relative 1e-5.
  5. Given only itemised holdings, with the ISAs as person balances, all six means tests count savings, cash ISAs, trusts and stocks and shares ISAs in full, and directly held shares less 10%. Each total must match after the programme's rounding rule, to within a penny plus one float32 step.

test_stored_household_totals_grow_past_the_projection_horizon checks that UC capital equals savings plus the stored cash and stocks and shares ISA totals, and keeps one ratio to savings, in every year from 2025 to 2040.

Fixed cases pin these results:

  • £1,000 of savings, £4,000 of shares, £3,000 of trusts and a £5,000 ISA give UC capital of £12,600.
  • With an empty exempt list, UC counts £12,000 of share-like capital beside £1,000 of savings as £11,800, whether the household itemises or not.
  • Income Support and income-based JSA count £1,000 of savings and £12,000 of corporate_wealth as £11,800 in 2012.
  • UC denies eligibility when a household holds a penny of shares beside £16,000 of savings.
  • £16,000 of corporate_wealth beside £8,000.01 of trusts and an £8,000 ISA leaves nil with sale expenses and £16,000 without.
  • The model removes a £30,000 company holding from the UC pool at £27,000.
  • UC and Pension Credit count itemised holdings in a monthly period without proration (£12,300, in test_stock_capital_periods.py).

test_capital_share_components.py also tests the ISA routing, the bound and the company-holding budget on cases worked by hand:

  • test_a_reform_that_takes_isas_out_of_the_exempt_list_values_person_isas_less_10_percent: the reform figures under "Stocks and shares ISAs", for all six assessments.
  • test_a_balance_its_listed_holdings_cover_keeps_its_whole_value: the £100.01 case. Beside it, £6,000 of shares, −£5,000 of trusts and a lodger's £5,000 balance leave the part without sale expenses at nil, so the lodger holds nil and UC counts [£2,700, £2,700].
  • test_a_balance_counts_nothing_the_holdings_behind_its_part_do_not_hold: the £8,388,608 case and two like it, one with the itemised holdings summing below nil and one with the ISAs off the exempt list. Each balance holds nil.
  • test_isa_balances_stay_within_the_holdings_behind_their_part: 1,440 sole adults with signed holdings at and beside 2, 2^10, 2^23, 2^24 and 2^25, under the baseline list and two lists without the ISAs, with UC counting both parts or either one. Exact rational arithmetic on the float32 inputs gives each bound, part and UC total.
  • test_a_balance_the_complement_covers_keeps_its_whole_value: an exempt list of shares and trusts, with £16,777,216 of shares, £3 of trusts, a £3 balance and £16,777,222 of share_like_capital, whose float32 spacing is £2. The part with sale expenses holds £2, the £3 of holdings behind it cover the balance, and the holder keeps £3. With the other part off UC's lists, UC counts £2.70.
  • test_a_stored_part_short_of_its_holdings_bounds_the_balances: a holder with a £5,000 balance and a lodger share £10,000 of savings. Entering the part without sale expenses as nil gives [£5,000, £5,000], and as £2,000 gives [£7,000, £5,000]. Entering the part with sale expenses as all £5,000 gives [£7,250, £7,250]. With the ISAs off the list, entering the part with sale expenses as nil gives [£7,500, £7,500].
  • test_an_override_within_rounding_still_bounds_the_balances: six overrides leave the part £1 short of its holdings, within the £1 spacing of £8,388,608: an input, a formula replaced to give nil, a neutralised formula and a replaced other part, and on the reform route an input and a replaced formula. Each £1 balance holds nil, and UC counts [£5,000, £5,000].
  • test_only_a_split_that_differs_from_the_formulas_loses_the_rounding: a replacement formula that gives the same values keeps the £100.01 and the £3. Entering the part without sale expenses as nil in the £3 case leaves the holder £2, and UC counts £1.80.
  • test_a_holding_leaves_no_pool_that_stops_counting_the_part_with_sale_expenses: the reg 77 figures under "Regulation 77 company holdings".

The tests in this table fail against the code before their fix:

Tests Code Result
The signed-parts property, the exempt-list reform test and the company-holding test 8f755b981 all 3 fail
The £8,388,608 test, and the sweep with the ISAs on and off the list 1b41af993 3 fail; the £1 balances hold £1
The complement test, the sweep's shares-and-trusts list and three stored-part cases a238aa223 5 fail
The six override cases and the case that enters the part without sale expenses as nil 45c48dc2e 7 fail; each override's £1 balance holds £1, and the entered case's balance £3

Review responses

Review of #1969 at a418a0040

  • Merge condition (itemised ISAs and unit trusts lose 10%). Folding Value share-like capital by asset type for the sale-expense deduction #2131 into this PR resolves it: for holdings of nil or more, main never takes the 10% off an itemised ISA or unit trust. Line numbers below refer to 0f35157f9.
    • Person route: household_sources replaces HOUSEHOLD_SOURCE_OF. While the exempt list names stocks_and_shares_isa, it maps the ISA balance to the part without sale expenses (variables/gov/dwp/_person_capital_pool.py:25-29). valued_person_capital takes the 10% off a balance only where a sale-expense list names that part (utils/capital_valuation.py:92), and none does. person_isa_capital.yaml Cases 2, 7 and 9 keep main's £9,000 (:83), £9,000 for Pension Credit (:225) and £11,000 (:285).
    • Household route: the exempt list puts unit trusts and stocks and shares ISAs in the part without sale expenses (parameters/gov/dwp/share_like_capital/without_sale_expenses.yaml:32-35). In test_components_alone_are_valued_by_type, UC counts £3,000 of trusts and a £5,000 ISA in full, beside £1,000 of savings and £4,000 of shares at £3,600: £12,600 (test_capital_share_components.py:1001). test_isa_balances.py and test_stored_household_totals.py keep main's full-value expectations.
    • The six sale_expenses/sources.yaml descriptions now name the part with sale expenses and point to the exempt list for trusts and ISAs.
    • 8f755b981 rewrites the Value means-tested capital less 10% sale expenses and secured debt #1969 changelog fragment, which still applied the 10% to all of share_like_capital and to unit trusts "until the data separate them".
      • The same commit updates docs/book/assumptions/isa-inputs-and-capital-flows.md, which named share_like_capital as the source the stocks and shares ISA balances leave.
  • General "every sale-list name is counted" guard. d6cf32529 asserts that each programme's sources list includes every name on its sale_expenses.sources (test_capital_valuation_properties.py:235 at 0f35157f9), before the intersection check.
  • Savings-credit-only case, reg 77 holding, Itemise corporate_wealth's share-like components for the means tests #1974 rename, record-level figures. The savings-credit case and the record-level figures stand as the review found them. share_like_capital keeps Itemise corporate_wealth's share-like components for the means tests #1974's name, but the six capital lists now name its two parts in its place, and test_lists_name_the_two_parts replaces test_lists_name_share_like_capital_only. The reg 77 holding now comes off the part with sale expenses, still at 90%.

Review of #2131 at 3fe76ee3e

Point Response
Company holding, long parameter lines, pinned exempt list Done at 3fe76ee3e, as the review found.
1. Land with #1969 #1969's branch now carries #2131's commits, and CI runs on the combined tree here.
2. ISA wording 690a56222 makes without_sale_expenses.yaml say the model counts an ISA's withdrawal value in full, "a reading that rests on ADM H1656 saying nothing about costs of sale". 8f755b981 makes the sale-expense-share-split changelog fragment and the four test comments that cite H1656 say the same.
3. Employee share options 690a56222 adds to the same description that directly held shares include employee shares and share options, which take the deduction as an approximation. 8f755b981 says the survey records them as one total.
COMPONENTS comment 690a56222 adds a comment on COMPONENTS in share_like_capital_with_sale_expenses.py: every exempt name must be one of them. 8f755b981 adds that share_like_capital sums the same names, so a reform that adds a holding must add it there too.

Earlier reviews

Validation

CI at 0f35157f9 passed every job on its second attempt. On the first, the 90-minute limit cancelled Python shard 3, and only that shard was rerun. The aggregate-impact job passed; "Impact on the certified data" gives its result.

This head merges main at 83c2554b2, and main has moved on since. CI tests this head merged into current main.

None of the Code changes runs at 8f755b981, 1b41af993 and 45c48dc2e (under "Runs at earlier commits") passed every job. In each, the YAML job, lint, the builds, the smoke imports and every Python shard that finished passed, and the 90-minute limit (.github/workflows/test-suite.yaml:215) cancelled one or two shards. At 45c48dc2e, shard 7 had passed all 2,074 of its tests, with 11 skipped, when the limit stopped it, and shard 2 had reached 97% with none failing. PolicyEngine/policyengine-uk#2919, still open, splits the Python tests over ten shards.

After 45c48dc2e, only 2d4b7adf9 changes code. 84bda06a1, 74980bdd8 and 0f35157f9 change docstrings, comments and documentation only.

Local runs, one process at a time with a 2 GB memory cap, and HUGGING_FACE_TOKEN, HF_TOKEN and POLICYENGINE_UK_DEFAULT_DATASET unset:

Command Commit Result
test_capital_share_components.py 0f35157f9 41 passed
test_capital_share_components.py, over 19 processes 84bda06a1 41 passed
test_person_isa_capital.py / test_capital_valuation_properties.py / test_isa_balances.py / test_stored_household_totals.py 84bda06a1 32 / 18 / 8 / 42 passed
test_uc_company_override_properties.py / test_uc_company_owner_properties.py / test_stock_capital_periods.py 84bda06a1 11 / 7 / 3 passed
policyengine-core test on 17 YAML files, among them capital_valuation.yaml, capital_valuation_share_split.yaml, person_isa_capital.yaml, uc_company_analogous_business.yaml, uc_property_capital.yaml and the council tax reduction capital files 84bda06a1 345 passed
uvx ruff@0.17.2 format --check . and check . 0f35157f9 clean

We didn't run test_dated_reform_routes.py, code_health/test_ci_test_shards.py or any test that needs the Enhanced FRS locally; CI runs them.

Impact on the certified data

The aggregate-impact job at 0f35157f9 compared main 2c570224b with 5b0b7205b, which merges 0f35157f9 into that main. Both ran on enhanced_frs_2024_25.h5 (policyengine-uk-data 1.58.1). The job passed: no check broke, sign:vat fails on both sides, and it flagged 205 moves for review. In every row of the table from #1969's run at a418a0040 (under "Runs at earlier commits"), it reports the same change, so on these data the combined tree moves those measures as #1969 alone does.

That result fits #2131's finding that policyengine-uk-data (main at e1acdf966) imputes one corporate_wealth and none of its three components. Every Enhanced FRS household would then keep all its share-like capital in the part with sale expenses. #2131's aggregate-impact run at 2f1051e9f against #1969's 3a3241cf6 also found no change in any year. Both commits predate main's person ISA route (#2839).

In #1969's run at a418a0040 (under "Runs at earlier commits"), the model assessed less capital, so it paid the same or more of each of the six benefits in every year. Some lines moved the other way because of higher awards:

  • Council Tax Reduction counts the UC award as income in the default-scheme formula (council_tax_reduction/_legacy.py:50-53), so a larger award lowers it.
  • Tax-Free Childcare excludes a family with universal_credit_pre_benefit_cap above nil (tax_free_childcare_program_eligible.py), unless the family gives up a smaller award (forgoes_universal_credit_for_tax_free_childcare).
  • A household with someone aged 75 or over on Pension Credit gets a free TV licence (tv_licence_free_licence_share.py).
  • VAT on private school fees moves both ways, because attendance ranks households by net income including benefits (attends_private_school.py).
  • Relative poverty rises in a few cells, because each run sets its line at 60% of its own median. Absolute poverty falls or holds in every cell.

Microcosm's UK build writes directly_held_shares, unit_and_investment_trusts and stocks_and_shares_isa so that they sum to corporate_wealth (was_wealth.py at c0513dbae). On data from that build, trusts and stocks and shares ISAs escape the 10%. CI's aggregate report doesn't cover those data.

Runs at earlier commits

Check Commit Result
CI on this PR 45c48dc2e the YAML job, lint, the builds, the smoke imports and Python shards 1, 3, 4, 5, 6 and 8 passed. The 90-minute limit cancelled shard 7 after its 2,074 tests passed (11 skipped), and shard 2 at 97% with none failing
Aggregate impact on this PR 45c48dc2e passed; every row of the a418a0040 table below shows the same change
CI on this PR 1b41af993 the YAML job, lint, the builds, the smoke imports and Python shards 1, 3, 4, 5, 6 and 8 passed; the 90-minute limit cancelled shards 2 and 7
Aggregate impact on this PR 1b41af993 passed
CI on this PR 8f755b981 the YAML job, lint, the builds, the smoke imports and Python shards 1 to 6 and 8 passed; the 90-minute limit cancelled shard 7 in both attempts
Aggregate impact on this PR 8f755b981 passed
CI on #2131's branch 3fe76ee3e all 18 jobs passed; 13,482 Python tests passed, 61 skipped and 2 xfailed as allowlisted. This tree merges main 83c2554b2, #2839 included. Python shard 8 ran the dataset tests on enhanced_frs_2024_25.h5 (policyengine-uk-data 1.58.1): 44 passed, 1 xfailed
CI on #2131's branch df8c1ea79 seven of eight Python shards, the YAML job, lint, the documentation and release builds and the smoke imports passed; shard 3 failed one test (1 failed, 1,970 passed), which 3fe76ee3e fixes
CI on this PR a418a0040 all 22 checks passed
CI, CI, CI on this PR 59a1c4ad2, b4e872273, 3a3241cf6 passed
CI on #2131's branch 6a0d26d61 11,425 Python tests and 5,451 YAML cases passed
Aggregate impact against 3a3241cf6 2f1051e9f no change in any household's net income, receipts, the government balance, poverty or inequality, 2025-26 to 2031-32
Differential against 3a3241cf6 for 400 households that don't itemise (58 outputs, 27,616 values, 2025 to 2027 and January 2026) 2f1051e9f identical

3fe76ee3e fixed a test tolerance. CI at df8c1ea79 drew a household the property expects at £16,834.13, which the engine holds as 16,834.119, £0.0109 under. The check now subtracts in float64 and allows a penny plus one float32 step. It pins that household and one at £37,747.34.

Local runs at df8c1ea79, one process at a time with a 2 GB memory cap, HUGGING_FACE_TOKEN and POLICYENGINE_UK_DEFAULT_DATASET unset:

Command Result
policyengine-core test on 17 YAML files, among them capital_valuation.yaml, capital_valuation_share_split.yaml, person_isa_capital.yaml and the ESA, HB, IS and JSA capital files 227 passed
test_person_isa_capital.py, each test in its own process 32 passed
test_isa_balances.py / test_stored_household_totals.py / test_capital_valuation_properties.py 8 / 42 / 18 passed
code_health/test_ci_test_shards.py 1 passed

Local runs at 3dbdb0027 (#1969, before main's last merge), after uv sync --frozen --extra dev, with no survey data:

Command Result
policyengine-core test on tests/policy/baseline/gov/dwp, finance/benefit/family and council_tax_reduction 997, 1,761 and 352 passed
pytest -n 4 on test_capital_valuation_properties.py, test_uc_property_capital.py, test_uc_property_capital_mock.py, test_person_isa_capital.py, test_savings_credit_only_receipt_properties.py, test_stored_household_totals.py 18, 65, 26, 32, 6 and 42 passed
pytest -n 4 policyengine_uk/tests/code_health 3,181 passed
uvx ruff@0.17.2 format --check . and check . clean

Mutants, with Hypothesis shrinking off for the properties:

Mutant Commit Result
Stocks and shares ISAs back under the 10% 2f1051e9f killed: all 7 selected ISA-balance tests and all 3 selected share-component tests fail
HOLDINGS_SOURCE on all of share_like_capital 2f1051e9f killed: the reg 77 test fails
Income-based JSA's capital list drops the part without sale expenses 2f1051e9f killed: the JSA list test, the valuation-by-type property (£7,600 against £15,600) and the JSA ISA test fail
No floor at nil 6a0d26d61 killed: the floor case finds −£0.009765625 with sale expenses
No branch for households that itemise nothing 6a0d26d61 killed: UC capital of £5,999.00 against £5,999.20
stocks_and_shares_isa dropped from the exempt list, on the stored-totals test ce91e92ea killed: £5,800 against £6,000 in 2025
owned_land_secured_debt dropped from council tax reduction's SECURED_DEBT 3dbdb0027 killed: the land case gives £45,000 against £25,000

The aggregate-impact job at a418a0040 compared main 83c2554b2 with bed0b12b8e, which merges a418a0040 into that main. Both ran on enhanced_frs_2024_25.h5 (policyengine-uk-data 1.58.1). The job passed: no check broke, sign:vat fails on both sides, and it flagged 205 moves for review.

Change 2025-26 2026-27 2027-28 2028-29 2029-30 2030-31 2031-32
Universal Credit +£222.8m +£324.7m +£546.0m +£1.27bn +£1.53bn +£1.08bn +£1.09bn
Universal Credit caseload +12.5k +35.0k +51.0k +91.5k +96.8k +73.8k +69.3k
Housing Benefit +£0.9m +£0.3m +£0.4m +£0.5m +£19.9m +£42.2m +£16.3m
Pension Credit +£1.0m +£1.0m +£1.1m +£1.0m +£0.9m +£0.8m +£0.7m
ESA (income-related) +£0.4m 0 0 0 0 0 0
JSA (income-based) +£13,640 0 0 0 0 0 0
Income Support +£43,929 0 0 0 0 0 0
Council Tax Reduction +£0.8m +£0.9m +£0.3m +£0.3m +£1.1m −£1.9m −£2.0m
Scottish Child Payment +£0.3m 0 0 0 +£6.0m +£11.0m +£24.1m
Tax-Free Childcare −£0.6m −£1.4m −£0.7m 0 −£10.2m −£11.2m −£1.7m
Targeted childcare entitlement 0 0 0 0 0 0 +£7.0m
Household net income † +£225.7m +£325.7m +£547.4m +£1.27bn +£1.55bn +£1.12bn +£1.14bn
Government balance † −£225.7m −£325.7m −£547.8m −£1.27bn −£1.55bn −£1.12bn −£1.14bn
Absolute poverty AHC, children −0.01pp −0.17pp −0.21pp −0.27pp −0.28pp −0.09pp −0.35pp

† The report rebuilds these totals without the Disabled Students' Allowance figure, which it withholds.

Coordination

axiom: TheAxiomFoundation/rulespec-uk#395 queued

The issue also carries the asset-type distinction and hand-computed companion cases; its ISA line predates the H1656 wording above.

🤖 Generated with Claude Code

UC Regs 2013 reg. 49(1) and its legacy equivalents (HB Regs 2006 reg. 47,
HB (SPC) Regs 2006 reg. 45, IS Regs 1987 reg. 49, JSA Regs 1996 reg. 111,
ESA Regs 2008 reg. 113, SPC Regs 2002 reg. 19) calculate capital at market
or surrender value less 10% where a sale would incur expenses and less any
encumbrance secured on it. The model summed every capital source at full
value.

Each programme gets a capital.sale_expenses node (rate 0.1 and the sources
whose sale incurs expenses: land, property and corporate_wealth, not cash
savings). A shared helper applies the 10% before the encumbrance and never
values an encumbered asset below nil. New household inputs carry debt
secured on other residential property, non-residential property and land;
the Enhanced FRS has none, so they default to zero.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
MaxGhenis and others added 2 commits September 30, 2026 22:07
- Each programme's sale-expense parameters now cite its GB and NI
  regulations, the guidance paragraph that orders the 10% before the
  encumbrance, and per-asset guidance with exact PDF page anchors (DMG ch 52
  for ESA, HBGM Annex F for HB savings, H1656/H1665/H1673-H1675 for UC).
- The source-list descriptions and changelog say plainly that
  corporate_wealth also holds unit trusts, ISAs, employee share options and,
  in datasets built before the pension split, non-DB pension wealth.
- The helper and secured-debt docs say debts net within a source category.
- The property-test oracle fixes the sale-expense assets and the 10% itself
  instead of reading the parameters, checks pension-age HB, and runs on
  larger populations. New hand-computed cases cover HB second homes and
  premises, per-source flooring between two encumbered sources, pension-age
  HB, and a monthly secured debt.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
HBGM W1.430 states only the general 10% rule; the rule that real property
always has costs of sale comes from R(IS) 21/93, as DMG 29622 applies it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@MaxGhenis

Copy link
Copy Markdown
Collaborator Author

Coordination note from #1950 (UC capital income). If this PR lands after #1950, please update the "reg 49 is #1960" notes #1950 adds:

  • in uc_income_from_capital.yaml, the header and both let-property cases (GB and NI);
  • in uc_unearned_income.yaml, the savings-0 let-property case.

Those cases enter £10,000 of property as capital. At 90% that is 12 tariff steps, not 16, so either update the expected values or restate the input as a property value of £11,111.11. If #1950 lands second, I'll do it on rebase. #1950's merge is waiting on a decision from Max (over the £1bn/yr line).

🤖 Generated with Claude Code

@MaxGhenis

Copy link
Copy Markdown
Collaborator Author

#1950 merged (770bc06), so this PR is second. Please update the "reg 49 is #1960" notes:

  • in uc_income_from_capital.yaml, the header and the GB and NI let-property cases;
  • in uc_unearned_income.yaml, the savings-0 let-property case.

At 90% valuation, £10,000 of property is 12 tariff steps, not 16, so either update the expected values or enter £11,111.11.

🤖 Generated with Claude Code

Max Ghenis and others added 2 commits October 3, 2026 17:20
Resolve the capital variables onto main's claimant/partner allocation and
person-level sources, valuing household sources through valued_capital.
Update the let-property tests #1950 added: £10,000 of property is now £9,000
of capital under reg. 49(1), so 12 tariff steps, not 16.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Two tests main added after this branch's earlier base assumed full-value
capital:

- The CTR savings-credit-only case holds savings 10,000 and a 7,000 second
  property: capital is 10,000 + 90% of 7,000 = 16,300 (SPC Regs 2002 reg.
  19(a)), still over the 16,000 limit, so CTR stays nil. Deemed income is 13
  steps x 52 = 676, Pension Credit income 13,314 + 676 = 13,990, and savings
  credit 60% of (12,376 - 208.07 x 52) less 40% of (13,990 - 12,376) =
  288.22.
- The reported-capital property test's proxy oracle now values land,
  property and shares at 90% and savings at face value.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
MaxGhenis added a commit that referenced this pull request Oct 4, 2026
The six capital sources lists (UC, HB, IS, JSA, ESA, PC) name
directly_held_shares, unit_and_investment_trusts and stocks_and_shares_isa
in place of corporate_wealth, plus a new formula variable,
unitemised_corporate_wealth = max(0, corporate_wealth - components), for
whatever a dataset does not itemise. Datasets without the components keep
counting corporate_wealth in full; datasets that build corporate_wealth as
the components' exact sum count the same total, now itemised, so each
component can carry its own valuation rule (the sale-expense deduction stacked
on #1969 exempts unit trusts and ISAs). No dataset's capital changes: a
differential property test checks that every programme's assessable capital
equals the same holdings entered as one corporate_wealth.

Review nits: the growth-factor sentence now matches uprating_indices.yaml
exactly; the variable docs cite the DMG for the legacy benefits, the expert
valuation of unquoted shares and the quoted-share rule for investment trusts.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
MaxGhenis and others added 2 commits October 4, 2026 06:42
…eduction

corporate_wealth is now itemised in the capital sources lists (#1974), so the
sale-expense lists name directly_held_shares, which DWP values less 10% for
costs of sale (ADM H1665; DMG 29671/52671/84763; HBGM W1.513), and
unitemised_corporate_wealth, which keeps the previous flat treatment on
datasets that do not itemise. Unit trusts have no costs of sale even when sold
through a broker (ADM H1673-H1674; DMG 29680-29681, 52680-52681,
84771-84772; HBGM W1.530-W1.531), and an ISA is valued at what the holder
would get by withdrawing it, with no paragraph applying the 10% (ADM
H1656-H1658; DMG 29662-29664, 52662, 84748-84750). The survey bucket of
unit and investment trusts is treated as having no costs of sale; investment
trusts were 8.2% and 6.9% of the pooled funds in stocks and shares ISAs at
5 April 2022 and 2025 (HMRC ISA Table 9.6).

The property tests keep their own legal asset set and assert each
programme's list against it, and gain the split invariants: the residual,
backward compatibility with every component nil, conservation at a zero rate,
split effect = rate x (trusts + ISA), and no double counting. #1974's
itemising-invariance test no longer holds by design and is replaced by them.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@MaxGhenis

Copy link
Copy Markdown
Collaborator Author

Stacked follow-up: #2131 lists only directly_held_shares and unitemised_corporate_wealth as share-like sources with sale expenses, so unit and investment trusts (ADM H1673-H1674) and stocks and shares ISAs (ADM H1656) count at full value. It builds on this branch's head 22274ca and includes #1974, which itemises corporate_wealth in the six capital lists. Datasets that don't itemise keep this PR's flat treatment exactly.

🤖 Generated with Claude Code

@vahid-ahmadi vahid-ahmadi left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Thanks Max. Reviewed at head 22274cad.

The law is right in every programme. I re-fetched each provision from legislation.gov.uk:

  • UC Regs 2013 reg 49(1): "Capital is to be calculated at its current market value or surrender value less— (a) where there would be expenses attributable to sale, 10%; and (b) the amount of any encumbrances secured on it."

  • The same rule appears, in older wording ("10 per cent", "encumbrance/incumbrance"), in:

    • SPC Regs 2002 reg 19;
    • HB Regs 2006 reg 47 and HB (SPC) Regs 2006 reg 45;
    • IS Regs 1987 reg 49;
    • JSA Regs 1996 reg 111;
    • ESA Regs 2008 reg 113.

    The regulation numbers are right (JSA 111 and ESA 113).

  • CTR Prescribed Requirements SI 2012/2885 Sch 1 para 32 has the same 10% rule for pension-age CTR.

  • SPC Sch V has no disregard that touches share, unit trust or ISA valuation. Para 9 is business assets only.

The helper follows the guidance. valued_capital takes the 10% off gross value before the debt (ADM H1608) and floors each encumbered source on its own (H1615-H1616).

Probes all match hand arithmetic:

  • savings £5,000 + corporate_wealth £12,000 gives £15,800 for UC, HB and IS, and £15,800 for PC at 70 (main: £17,000);
  • a £100,000 second home with £95,000 debt plus £3,000 savings gives £3,000;
  • a second home of £20,000 with £25,000 debt plus premises of £10,000 gives £9,000.

Tests:

  • At the head: properties, PC reported capital and stock periods, 9 passed. DWP, family and CTR YAML, 967 passed.
  • Merged into current main b5b09231 (the merge is clean; the branch is 280 commits behind): the same YAML set, 1,274 passed. But two of the new property tests fail; see finding 1. The green CI is from the stale merge ref.

Findings:

  1. Blocking (rebase). On main + this branch, test_valuation_matches_the_regulation_and_never_adds_capital and test_cash_only_households_have_no_deduction fail (2 failed, 8 passed). The valuation isn't the problem; the test's oracle is out of date.

    • Main now sets HB capital to nil for anyone on UC, IS, income-based JSA or income-related ESA (HB Regs Sch 6 para 5, housing_benefit_on_passporting_benefit). It also switches the pension-age rules on housing_benefit_pension_age_regulations_apply rather than age 67.
    • So a working-age single person with £2,441.62 of cash now has HB capital of nil (on main too), while applies() at tests/test_capital_valuation_properties.py:127 still expects their savings.
    • I reproduced the cash-only failure directly. The other failing test uses the same applies() predicate, so it is most likely the same cause.
    • Fix: rebase and key the pension-age branch on housing_benefit_pension_age_regulations_apply. Then either skip units where housing_benefit_on_passporting_benefit is true, or give the generated units enough earnings to stay off UC. Skipping alone would hollow out the working-age HB branch, because the strategy's no-income singles are nearly all on UC.
  2. Blocking (merge order with #1974). Git merges this branch and #1974 cleanly, but together they undo this PR:

    • #1974 takes corporate_wealth out of every capital.sources list, while this PR's sale_expenses.sources still names it. So the 10% on shares silently stops.
    • On a 1969 + 1974 tree, the probe above goes back to £17,000. Seven YAML cases fail: 3 in capital_valuation.yaml, and 2 each in the IS and ESA capital files.
    • #2131 fixes this. So either merge #1974 first and then this PR and #2131 together, or merge this PR and then #2131 retargeted to main (it carries #1974).
    • A cheap guard in tests/test_capital_valuation_properties.py: assert set(sale_expenses.sources) <= set(capital.sources) for each programme. The existing check at line 160 intersects both sides with counted, so it can't see a stale name.
  3. Should fix (body, disclosure). In "A few records carry each figure", the UC, PC and HB bullets, and the poverty bullet, attribute most of each year's change to one or a handful of records, with percentages and counts. Read against the impact table, that is effectively a record-level weighted amount. Keep the caveat ("driven by a handful of records; not an estimate") and drop the percentages, record counts and the median gain.

  4. Nit. parameters/gov/dwp/income_support/means_test/capital/sale_expenses/rate.yaml:9. This starts on 2010-01-01, to match sources. IS reg 49 has applied the 10% since 11.4.1988. Add a sentence saying the date follows the sources list, as the HB and PC files already explain their own dates.

  5. Nit. utils/capital_valuation.py:18-19. Netting debt across assets within a category is documented. H1616 actually allows it where one debt is secured on several assets. You could cite that, so the approximation reads as partly lawful rather than purely a data limitation.

  6. Coordination with #1965. Merged with #1965 there is no textual conflict, but the holding comes off at 100% while it is counted at 90%: savings £5,000 + a £10,000 holding gives £4,000 instead of £5,000. I've put the fix on #1965, since it rebases second.

Max Ghenis and others added 2 commits October 11, 2026 20:55
Keep main's recorded benefit-unit capital (benunit_reported_capital), which
replaces the valued household sources as recorded, and register the
secured-debt inputs beside main's uprating entries.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
£20,000 of shares is £18,000 of Pension Credit capital (SPC Regs 2002
reg. 19(a)), still over the CTR limit: deemed income 16 x 52 = 832,
Pension Credit income 14,146, savings credit 933.816 - 0.4 x 1,770 =
225.82.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
uprating_indices.yaml grows owned_land_secured_debt with per capita GDP, but
the growth factors page left it out of that list. The page's list now
matches the index file's per capita GDP entry.

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

Copy link
Copy Markdown
Collaborator Author

PR_BODY_1969.md

Fixes #1960.

The model now takes the statutory 10% for sale expenses, and any secured debt, off capital in Universal Credit, Housing Benefit, Income Support, income-based JSA, income-related ESA and Pension Credit. It counts savings and cash ISAs at face value. The helper floors each encumbered source at nil, so negative equity in one source can't reduce another.

Reproducer: `policyengine_uk/tests/policy/baseline/gov/dwp/capital_valuation.yaml::UC values a mortgaged holiday home as in ADM H1602`, `policyengine_uk/tests/policy/baseline/gov/dwp/capital_valuation.yaml::UC shares valued less sale expenses bring capital within the limit`, `policyengine_uk/tests/test_capital_valuation_properties.py::test_valuation_matches_the_regulation_and_never_adds_capital`, `policyengine_uk/tests/policy/baseline/gov/dwp/capital_valuation.yaml::A Lifetime ISA value given as an input is counted as given`, `policyengine_uk/tests/test_capital_valuation_properties.py::test_lifetime_isa_reformed_value_is_kept_as_stored`

## The law

| Programme | Great Britain provision | Northern Ireland equivalent |
|---|---|---|
| Universal Credit | [UC Regs 2013 reg 49(1)](https://www.legislation.gov.uk/uksi/2013/376/regulation/49) | S.R. 2016/216 reg 49(1) |
| Housing Benefit | [HB Regs 2006 reg 47](https://www.legislation.gov.uk/uksi/2006/213/regulation/47); [HB (SPC) Regs 2006 reg 45](https://www.legislation.gov.uk/uksi/2006/214/regulation/45) | S.R. 2006/405 reg 44; S.R. 2006/406 reg 43 |
| Income Support | [IS Regs 1987 reg 49](https://www.legislation.gov.uk/uksi/1987/1967/regulation/49) | S.R. 1987/459 reg 49 |
| Income-based JSA | [JSA Regs 1996 reg 111](https://www.legislation.gov.uk/uksi/1996/207/regulation/111) | S.R. 1996/198 reg 111 |
| Income-related ESA | [ESA Regs 2008 reg 113](https://www.legislation.gov.uk/uksi/2008/794/regulation/113) | S.R. 2008/280 reg 113 |
| Pension Credit | [SPC Regs 2002 reg 19](https://www.legislation.gov.uk/uksi/2002/1792/regulation/19) | S.R. 2003/28 reg 19 |

The decision maker takes the 10% from gross value before debt, only where sale incurs expenses, and real property always has sale costs (ADM H1604–H1608). The decision maker then deducts only debt secured on that source (H1615–H1616). Each programme's parameters start from its existing capital-source list and cite the provision in its own instrument, including the later UC and ESA instruments.

## What changes

- Each programme has `capital.sale_expenses.rate: 0.1`, an explicit list of sources, and its own `capital.round_down` rule. `valued_capital` applies the deduction before secured debt, with float64 arithmetic.
- UC and HB round to the nearest penny, half up (UC reg 6(1); HB reg 80 / SPC HB reg 61(6)). IS, JSA, ESA and PC round down under their respective regulations. Each valuation and final assessment follows that rule; UC holdings and property allocations also follow its penny rule.
- `exact_amount` recovers an unambiguous whole penny from float32 storage below £131,072. It preserves other stored amounts. Above that boundary, original pennies can be ambiguous; the result can differ by a penny in either direction. This PR can't recover every digit that float32 storage lost before valuation.
- The model values Lifetime ISAs with the baseline surrender-value calculation in float64, and rounds each person's value under each programme's rule before summing. A £0.26 balance below the charge-free age gives £0.195: UC/HB count £0.20 and the down-rounding programmes count £0.19. The whole-penny property draws every penny, including this half-penny example.
- The valuation counts explicit LISA inputs as given. Replacement formulas keep their stored results, and neutralising the variable still works. The model recalculates a Lifetime ISA only where the baseline formula applies and no input supplies the value for that period and branch. Equality with the baseline float32 value cannot establish provenance: an explicit £0.195 also stores as 0.19499999284744263, but nearest-penny rounding of that supplied amount gives £0.19 where the baseline calculation gives £0.20. A regression covers this collision.
- The float64 LISA recomputation now applies the active variable's `defined_for` mask through Core's entity mapping. It keeps the stored result outside the mask. Regressions cover mixed masked/counted people across all six means tests and UC eligibility at the £16,000 capital limit. Commit `dbc0c587f` calculates the Lifetime ISA mask before its high-precision recomputation. It runs the formula only when at least one person applies and keeps Core's stored value outside the mask. The regression makes `lifetime_isa_balance` raise when a reform masks everyone and checks capital for all six programmes against a run without a Lifetime ISA.
- The capital property suite now generates `cash_isa` as well as `savings`. Its cash-only property checks their sum at face value. Direct source lookup still raises a `KeyError` for a source the oracle omits; cash ISAs stay outside both the sale-expense and secured-debt mappings.
- All six lists name #1974's `share_like_capital` as the sale-expense source, and `corporate_wealth` stays its backing household input. UC company-holding deductions use `HOLDINGS_SOURCE` consistently, including pool and reported-capital budgets read through `exact_amount`. Property oracles map the renamed source to the backing input.
- Main's #2839 counts each cash and stocks and shares ISA balance the data tie to a person in the holder's own benefit unit (`cash_isa_countable_capital`, `stocks_and_shares_isa_countable_capital`) and subtracts it from the household source that holds it (`cash_isa`, `share_like_capital`) before the formula allocates the rest. Each of the six formulas passes `valued_capital` each household source less those balances (`pooled_person_capital`), so it values the remainder as before: less 10% where `sale_expenses.sources` lists the source, then less any debt secured on it. `valued_person_capital` counts the claimant's and partner's balances in their own unit and values each as `valued_capital` values its household source: a stocks and shares ISA balance less 10%, because all six lists name `share_like_capital`, and a cash ISA balance at face value. A pound of a stocks and shares ISA therefore counts at 90% whether it stays in the pool or moves to its holder. `uc_assessable_capital` keeps main's `~covered` mask, so a reporting unit's claimant's and partner's ISAs stay in the pool, valued with it, and the formula subtracts the report.
- UC's existing property route shares the same sale-expense rate. `uc_assessable_capital` takes a disregarded company holding off at its counted value. In its place, it adds the claimant's or partner's share of the company's capital (reg 77(2)), outside the sale-expense helper. Recorded financial totals and complete reported-capital overrides keep their existing distinct meanings.
- Three household inputs hold the debt secured on other residential property, non-residential property and land. #2447 put the first two on main; this PR adds `owned_land_secured_debt` and deducts all three in every programme that counts the asset. UC counts no land, so the land input changes the five legacy means tests only. Each defaults to zero, and `uprating_indices.yaml` lists each once.
- Council tax reduction takes Pension Credit's capital on a savings-credit-only award, and UC's capital for a working-age applicant with a UC award outside Scotland's scheme from April 2022, so it inherits their valuation there. Outside those routes and the routes that disregard all capital, main's #1995 gives `council_tax_reduction_assessable_capital` its own household route, which counts savings at face value and land and property other than the home less 10% and less the debt secured on them. This PR adds `owned_land_secured_debt` to that route's `SECURED_DEBT`, so it deducts the debt secured on land as the schemes require (SI 2012/2885 Sch 1 para 32(b) and its equivalents). The route floors a negative source or debt at nil, works in float32 and keeps fractions of a penny, where `valued_capital` uses a negative source or debt as given, works in float64 and rounds each valuation to the penny; both take the 10% before the debt and floor each encumbered source at nil. No test shows a wrong result from those differences, so this PR leaves them.

### Which sources take the 10%

| Source | Deduction | Basis / limitation |
|---|---|---|
| Savings and cash ISAs | None | Account balance / withdrawal value; the decision maker doesn't count incidental withdrawal costs as sale costs (ADM H1675, H1607). |
| Land and other residential/non-residential property | 10% | Real property has sale costs (H1606); the model takes supplied property values as gross. |
| `share_like_capital` | 10% | Direct shares have sale costs (H1665). The aggregate can also include unit trusts and stocks-and-shares ISAs, whose legal treatment differs (H1674, H1656). We state this limit in the parameter descriptions, and the data need a source split. |
| Stocks and shares ISA balances counted in their holders' units (`stocks_and_shares_isa_countable_capital`) | 10% | The formulas move each balance out of `share_like_capital` and value it as that source, so the same limitation applies. #2131 values itemised ISAs without the 10%. |

### Existing tests whose expected values move

- `test_isa_balances.py` (main's #2712): UC capital for a household with £1,000 of savings, a £3,000 cash ISA and a £2,000 stocks-and-shares ISA moves from £6,000 × growth to (1,000 + 3,000 + 2,000 × (1 − rate)) × growth, £5,800 × growth. The ISA reaches capital through `share_like_capital`, which UC values less its sale-expense rate. `fc066bd31` made this change.
- `test_stored_household_totals.py::test_stored_household_totals_grow_past_the_projection_horizon` (main's #2781): the same household, stored as household ISA totals. UC capital moves from 6 × savings (£6,000 in 2025) to savings + cash ISA + stocks-and-shares ISA × (1 − rate), 5.8 × savings (£5,800 in 2025), in every year from 2025 to 2040, for the same reason (UC Regulations 2013 reg. 49(1)(a)). The test reads each part and the rate from the simulation, checks that capital stays more than a penny below the three parts at face value, and still checks that capital keeps one ratio to savings in every year.
- `person_isa_capital.yaml` (main's #2839): seven cases count each stocks and shares ISA balance, and the `share_like_capital` left in the pool, less 10%. For example, Case 3's adult child holds a £6,000 ISA inside £9,000 of `corporate_wealth`: the pool's £3,000 counts as £2,700, split £1,800 to the parents and £900 to the child's unit, which adds the ISA at £5,400, so UC capital moves from [2,000, 7,000] to [1,800, 6,300]. Cases 14 and 15 raise the household stocks and shares ISA totals to £17,777.78 and £6,666.67, so that 90% of each, rounded to the nearest penny, still lands on the £16,000 limit and the £6,000 threshold.
- `test_person_isa_capital.py` (main's #2839): the pound-counts-once checks value `share_like_capital`, and each stocks and shares ISA moved out of it, at each programme's sale-expense share, and allow each programme's penny rounding. The worked examples move with them: in `test_person_balances_without_household_totals_count_with_their_holders`, UC capital moves from [11,000, 9,000, 14,000, 11,000] to [10,666.67, 8,833.33, 13,800, 10,300] and Pension Credit's from 19,000 to 18,700. In `test_both_forms_in_one_dataset_add_up_to_the_stored_total`, UC and Housing Benefit round each unit's capital to the nearest penny, so savings of £1,268.69 in 2032 split between two units as £634.345 each and come to a penny over the household's total; the test allows that penny.
- `pension_credit_income.yaml` Case 4 (main's #1995): the £55,370 let property counts less 10%, so capital moves from £55,825 to £50,288, deemed income from £92 to £81 a week (£4,212 a year) and guarantee credit from £7,592 to (238 − 81) × 52 = £8,164. The case follows main's #1995, under which the formula doesn't count the rent as Pension Credit income (the case cites SPC Regs 2002 Sch IV para 18); this PR's earlier version of the case counted it.
- `test_savings_credit_only_receipt_properties.py` (main's #1995): main gave the owner with capital £12,000 of savings and £4,400 of property, so that Pension Credit's assessment (£16,400) exceeds the £16,000 limit while council tax reduction's own route (£12,000 + £3,960 = £15,960) doesn't. With this PR, Pension Credit counts the property at £3,960 too, so the test also gives the owner £500 of shares (`corporate_wealth`), which Pension Credit counts at £450 and council tax reduction's household route leaves out. Pension Credit's capital comes to £16,410, the route's to £15,960, and the savings credit stays £621.82 a year (13 a week of deemed income).

## Review responses and integration

| Finding | Response |
|---|---|
| v6: LISA half pennies lost on the float32 round-trip | Compute the baseline surrender value in float64 and round each person's value under the programme's rule. Widen the whole-penny property beyond multiples of 4p and cover UC boundaries, explicit inputs and equal-float32 provenance collisions. |
| v6: Incorrect claimant-favourable claim for large float32 values | Correct the documentation and test commentary: ambiguous pennies from £131,072 can produce a penny either way after valuation; plain amounts from £262,144 have the same issue. |
| v6: Float32 cast outside `errstate` | Put the cast inside the overflow/underflow/invalid guard. |
| v7: Baseline LISA recomputation bypassed `defined_for` | Apply the active mask to the float64 result and keep Core's stored result outside it (`696ae34ad`). Add mixed-person and UC-limit regressions. The v8 follow-up below also preserves Core's all-masked short circuit. |
| v7: Property generator omitted main's new `cash_isa` source | Generate cash ISAs, count them at face value, and check savings plus cash ISAs in the cash-only property (`b168dc509`). Keep direct lookup and existing tolerances. |
| v8: all-masked LISA recomputation evaluated unused dependencies (P2) | `dbc0c587f` evaluates the mask first and runs the formula only when someone applies. The new raising-dependency regression checks all six programmes. |
| v9: no finding (APPROVE at `dbc0c587f`) | No change. |
| CI at `dbc0c587f`: main's new `test_isa_balances.py` expected a stocks-and-shares ISA at full value in UC capital | `fc066bd31` expects UC's sale-expense deduction on it: the ISA reaches capital through `share_like_capital`, which UC values less 10% until the data separate ISAs from shares. #2131 then values itemised ISAs without the 10%. |
| v10: no P1 or P2 on this PR; one optional nit in the edited test | Optional: read the rate at the instant the formula uses. v10 also records one defect already on main (below) for a separate issue. |
| Review at `b4e872273`: the description named `c11d7c1d9` and an open #2765 conflict (P2), plus three wording points (P3) | Describe `b4e872273`'s merge of #2765 and the runs at that head. Correct the sentence on what `exact_amount` can't recover, name `test_isa_balances.py` as the mutated test, and cite ADM H1675 and reg 77(2) in brackets. |

- `646743859` merges main at `41fa5ddb5`. The supplied-input registry retains both this PR's LISA entry and main's `monthly_domestic_energy_consumption` entry.
- `d5c2a57e8` ports #2688's company-capital conservation oracle correction from `1193614a6`. The file matches that source revision byte for byte and keeps main's claimant/partner roles. The oracle reflects stored-input precision, holdings-budget scaling, separately rounded valuations and company capital, and the sum of rounded benefit units. The pinned example yields £25.28 + £25.28 = £50.56. The port changes no production code or tolerance. All seven company-owner properties passed in v7's CI.
- `5efb62cef` merges main at `2d437ebba`. Of 3,660 paths, only `policyengine_uk/data/uprating_indices.yaml` changed on both sides since `41fa5ddb`, and the merge commit's combined diff shows no hand-resolved hunk in it. The merged file keeps main's new `cash_isa_balance` and `stocks_and_shares_isa_balance`, drops main's duplicate `cash_isa` and `stocks_and_shares_isa` entries, and keeps all three secured-debt inputs. It lists each of its 124 variables once, under 14 distinct indices. The merge keeps every one-sided change: 59 files from this branch and 123 from main.
- `fc066bd31` changes only `test_isa_balances.py`. Main's #2712 (issue #2710) added the test; the edit makes it expect UC capital of (1,000 + 3,000 + 2,000 × (1 − rate)) × growth, which comes to £5,800 × 1.07224 = £6,218.99 in 2027. It reads the rate from the parameters. The test still checks first that the stored household totals grow with savings.
- Main's other changes since `41fa5ddb` leave the valuation alone. #2712 changes how `cash_isa` and `stocks_and_shares_isa` read their values but not which sources the means tests count, and its subscription limits move no balance. #2717 changes growth rates, not sources or deductions. #2732's household subsets slice every stored array and `_model_values` to the kept households, and its tests, which cover the ancestor walk that `supplied_input` uses, pass here. #2092, #2229 and #2716 touch no capital code.
- `30d48c01b` merges main at `2da212abc`. Only `uprating_indices.yaml` conflicted. The merged file keeps main's move of `other_investment_income`, `savings_interest_income` and `non_cash_isa_cash_interest` to `per_capita.savings_income` and main's new company-car and `income_not_otherwise_charged` entries. It adds `owned_land_secured_debt` under `per_capita.gdp`, next to `owned_land`, and lists each of its 128 variables once, under 15 indices. Against main's file, the only added line is `owned_land_secured_debt`.
- Main's #2754 lets a family give up a UC award worth less than its Tax-Free Childcare top-up. A London lone parent earning £44,000, with £10,000 of childcare and £17,000 of `corporate_wealth`, had £588.70 of UC and no top-up on this PR's old base, £1,411.30 worse off. At the merge the family counts £15,300 of capital, gives up the award and takes the £2,000 top-up. In eight cases, UC, Tax-Free Childcare and Scottish Child Payment together never fall below main at the merge.
- `3a3241cf6` corrects the `owned_land_secured_debt` documentation, which named UC. It changes no calculation.
- The review covered `30d48c01b54532603c0fad233a30935adab9280c`, and that documentation commit follows it.
- `ba4de95d6` merges main at `0080274d78e2b48e57682ac6a035fda6e11334e9`, 86 commits after `2da212abc`, #2781 among them. Git merged it with no conflict. Only `policyengine_uk/data/uprating_indices.yaml` changed on both sides since `2da212abc`; against main's file, the merged file adds only `owned_land_secured_debt`.
- `c11d7c1d9` changes only `test_stored_household_totals.py`, which main's #2781 added: it now expects the stocks-and-shares ISA in UC capital less the sale-expense rate (see "Existing tests whose expected values move"). Main's other test changes since `2da212abc` read no means-tested capital variable.
- `b4e872273` merges main at `52b30809ff5681ebfede4d559e72a44f4c893cd2`, which includes #2765. Git stopped on one hunk in `SUPPLIED_INPUT_VARIABLES` (`policyengine_uk/utils/supplied_inputs.py`), where both PRs added a name at the same place. The merge keeps this PR's `lifetime_isa_countable_capital` and #2765's `miscellaneous_income_trading_allowance_deduction`. Main's other changes since `0080274d7` name no means-tested capital variable or parameter.
- `154f92286` merges main at `af9361114425a1457545503f2801c68fc6ed5d47`, which includes #2839 (`d3c06225d`) and #1995 (`8717d5a26`). Git stopped on eight files: the six assessable-capital formulas, `pension_credit_income.yaml` and `test_savings_credit_only_receipt_properties.py`. Each formula combines the two changes as "What changes" describes, and the six `capital/sources.yaml` lists, which git merged, keep every entry from both sides. The two test files keep both sides' cases and work each moved value by hand (see "Existing tests whose expected values move"). The merge also values the stocks and shares ISA balances that `valued_person_capital` counts as their household source, moves main's person ISA tests to the 10%, adds `owned_land_secured_debt` to council tax reduction's household route, and adds two cases. In `capital_valuation.yaml`, one benefit unit with a £4,000 cash ISA, £3,000 of savings and a £100,000 second home carrying a £60,000 mortgage counts £3,000 + £4,000 + (£100,000 − £10,000 − £60,000) = £37,000 in all six programmes. In `council_tax_reduction_capital_valuation.yaml`, £50,000 of land carrying a £20,000 debt counts £50,000 − £5,000 − £20,000 = £25,000 on council tax reduction's household route; without the `SECURED_DEBT` entry the case gives £45,000 and fails.
- `76242a05b` changes only `test_person_isa_capital.py`: `test_both_forms_in_one_dataset_add_up_to_the_stored_total` allows the penny each unit's nearest-penny rounding adds.
- `3c395c3e4` merges main at `95dfc62f818058007f28e42d7c550ad00578eaef`. Git merged it without conflict. Main's #2744, #2760, #2763, #2768, #2769, #2786, #2787, #2788, #2794, #2809 and #2810 change no file this PR changes, no capital source list and no assessable-capital formula. #2788's legacy tariff tests set assessable capital directly.
- `3dbdb0027` adds `owned_land_secured_debt` to the per capita GDP list on the growth factors page, which now matches `uprating_indices.yaml`'s per capita GDP entry.
- #2131 (head `ce91e92ea`) merges this PR at `b4e872273` and expects the stocks-and-shares ISA at face value in the stored-totals test. `git merge-tree --write-tree --name-only ce91e92ea 3dbdb0027` stops on `docs/book/assumptions/growthfactors.md` and on `uc_assessable_capital.py`'s documentation string. One more change won't show as a conflict. #2131 replaces `share_like_capital` in every programme's `sources` with `share_like_capital_with_sale_expenses` and `share_like_capital_without_sale_expenses`, and main's `counted_person_sources` counts `stocks_and_shares_isa_countable_capital` only while `sources` lists `share_like_capital` (`HOUSEHOLD_SOURCE_OF`). On that merge the formulas stop counting stocks and shares ISA balances in their holders' units and leave them in the pool: with the two documentation conflicts resolved to this head's text, `person_isa_capital.yaml` fails 10 of 21 cases and `test_person_isa_capital.py` 24 of 32 tests. When #2131 takes this head, it needs to count those balances against the source that holds them, for example by mapping `stocks_and_shares_isa_countable_capital` to `share_like_capital_without_sale_expenses`, which holds the itemised stocks and shares ISAs, and to expect the balances at face value in main's person ISA tests.

## Validation

We ran each command below on its own at `3dbdb00276578089c68949b31658239386af9420`, on a clean checkout after `uv sync --frozen --extra dev`, and loaded no survey data.

| Command | Result |
| --- | --- |
| `uv run --frozen policyengine-core test policyengine_uk/tests/policy/baseline/gov/dwp -c policyengine_uk` | 997 passed |
| `uv run --frozen policyengine-core test policyengine_uk/tests/policy/baseline/finance/benefit/family -c policyengine_uk` | 1,761 passed |
| `uv run --frozen policyengine-core test policyengine_uk/tests/policy/baseline/gov/local_authorities/council_tax_reduction -c policyengine_uk` | 352 passed |
| `uv run --frozen pytest -n 4 policyengine_uk/tests/test_capital_valuation_properties.py` | 18 passed (246 s) |
| `uv run --frozen pytest -n 4 policyengine_uk/tests/test_stock_capital_periods.py` | 2 passed |
| `uv run --frozen pytest -n 4 policyengine_uk/tests/test_uc_property_capital.py` | 65 passed |
| `uv run --frozen pytest -n 4 policyengine_uk/tests/test_uc_property_capital_mock.py` | 26 passed |
| `uv run --frozen pytest -n 4 policyengine_uk/tests/test_person_isa_capital.py` | 32 passed |
| `uv run --frozen pytest -n 4 policyengine_uk/tests/test_savings_credit_only_receipt_properties.py` | 6 passed |
| `uv run --frozen pytest -n 4 policyengine_uk/tests/test_stored_household_totals.py` | 42 passed |
| `uv run --frozen pytest -n 4 policyengine_uk/tests/code_health` | 3,181 passed (203 s) |
| `.github/check_fix_pr.py` on this title and body, as `pr_fix_evidence.yaml` runs it, with the diff from the merge base `95dfc62f8` | passed, with 26 changed executable tests |
| `uvx ruff@0.17.2 format --check .` | 2,229 files already formatted |
| `uvx ruff@0.17.2 check .` and `uvx ruff@0.17.2 check --select F811,F821 policyengine_uk` | all checks passed |
| `git diff --check b4e872273..3dbdb0027` | clean |
| `git merge-tree --write-tree --name-only 3dbdb0027 origin/main`, with `main` at `95dfc62f8` | no conflict |

Without `owned_land_secured_debt` in council tax reduction's `SECURED_DEBT`, the land case in `council_tax_reduction_capital_valuation.yaml` gives £45,000 against £25,000 and fails. CI hasn't run at this head.

A review of `b4e872273c4695cf728d0d2811670b7300504ba4` ran these checks after `uv sync --frozen --extra dev`, one command at a time, with no survey data.

| Command | Result |
| --- | --- |
| `uv run pytest -n 4 policyengine_uk/tests/test_stored_household_totals.py` | 42 passed (214 s) |
| `uv run pytest -n 4 policyengine_uk/tests/test_isa_balances.py` | 2 passed |
| `uv run pytest -n 4 policyengine_uk/tests/test_capital_valuation_properties.py` | 18 passed (328 s) |
| `uv run policyengine-core test policyengine_uk/tests/policy/baseline/gov/dwp/capital_valuation.yaml -c policyengine_uk` | 26 cases passed |
| `uv run pytest -n 4 policyengine_uk/tests/code_health` | 3,110 passed |
| `.github/check_fix_pr.py`, as `pr_fix_evidence.yaml` runs it | passed, with 23 changed executable tests |
| `uvx ruff@0.17.2 format --check .`, `ruff check .`, `ruff check --select F811,F821 policyengine_uk` | clean |
| `git diff --check 3a3241cf6..b4e872273` | clean |

[CI at `b4e872273`](https://github.com/PolicyEngine/policyengine-uk/actions/runs/41588793430) passed every job, including the seven Python shards, the YAML job and `Test / Result`.

Local runs at `c11d7c1d92faeab80bf37a3019463f0b4ecbc103`, after `uv sync --frozen --extra dev`, one command at a time. We loaded no survey data and skipped no test.

| Command | Result |
| --- | --- |
| `uv run pytest -n 4 policyengine_uk/tests/test_stored_household_totals.py` | 42 passed (161 s) |
| `uv run pytest policyengine_uk/tests/test_capital_share_components.py::test_capital_matches_the_original_lists` | 1 passed (1,837 s) |
| `uv run pytest -n 4 policyengine_uk/tests/test_capital_share_components.py --deselect …::test_capital_matches_the_original_lists` | 13 passed (226 s) |
| `uv run pytest -n 4 policyengine_uk/tests/test_capital_valuation_properties.py` | 18 passed (296 s) |
| `uv run pytest -n 4 policyengine_uk/tests/test_isa_balances.py` | 2 passed |
| `uv run pytest -n 4 policyengine_uk/tests/test_pension_credit_reported_capital_properties.py` | 4 passed |
| `uv run pytest -n 4 policyengine_uk/tests/test_savings_credit_only_receipt_properties.py` | 6 passed |
| `uv run pytest -n 4 policyengine_uk/tests/test_stock_capital_periods.py` | 2 passed |
| `uv run pytest -n 4 policyengine_uk/tests/test_uc_company_override_properties.py` | 11 passed |
| `uv run pytest -n 4 policyengine_uk/tests/test_uc_company_owner_properties.py` | 7 passed |
| `uv run pytest -n 4 policyengine_uk/tests/test_uc_property_capital.py` | 65 passed |
| `uv run pytest -n 4 policyengine_uk/tests/test_uc_property_capital_mock.py` | 26 passed |
| `uv run pytest -n 4 …/universal_credit/test_uc_capital_allocation.py` | 1 passed |
| `uv run policyengine-core test <file> -c policyengine_uk` for the 12 YAML files this PR adds or changes and every other `*capital*.yaml` file under the UC, HB, IS, JSA, ESA and PC tests and `household/wealth` (22 files) | 238 cases passed, none failed |
| `uv run pytest -n 4 policyengine_uk/tests/code_health` | 3,108 passed |
| `uvx ruff@0.17.2 format --check .`, `ruff check .`, `ruff check --select F811,F821 policyengine_uk` | clean |
| `git diff --check 3a3241cf6..HEAD` | clean |

At the merge commit without the test change, `test_stored_household_totals_grow_past_the_projection_horizon` fails at line 222 with £5,800.00 against £6,000.00 ± 0.06; it passes on main at `0080274d7`. When we set UC's sale-expense rate to 0 in a scratch copy, the edited test fails (capital of £6,000.00 doesn't fall below the £6,000.00 face value) and main's version passes; once we restore the rate, the edited test passes.

A review of the merge at `30d48c01b` reran the changed tests one file at a time, and every test that finished passed.

| Check at `30d48c01b` | Result |
| --- | --- |
| `test_capital_valuation_properties.py` | 18 passed |
| `test_capital_share_components.py` | 14 passed |
| `test_uc_property_capital.py` and `test_uc_property_capital_mock.py` | 91 passed |
| `test_uc_company_owner_properties.py` and `test_uc_company_override_properties.py` | 18 passed |
| `test_lifetime_isa_capital.py` and `lifetime_isa_capital.yaml` | 3 passed, 24 cases passed |
| `test_uc_tax_free_childcare_choice.py` and the two Tax-Free Childcare YAML files | 20 passed, 12 cases passed |
| `test_input_records.py` | 11 passed |
| `test_projection_horizon.py` | 14 passed |
| `test_fiscal_partition.py` and `test_aggregate_impact_partition.py` | 43 and 11 passed |
| HB accommodation disregard YAML file | 50 cases passed |

Three files hit local time caps under host load before finishing: `test_household_subset.py`, `test_housing_benefit_accommodation_dates.py` and the pair `test_isa_accounting.py` and `test_wealth_components.py`. None of those that ran failed, and CI ran them all at `3a3241cf6` and passed.

An earlier review (v10) ran these checks against `fc066bd318f2e059623ab30df56985e3605e24d0`, one file at a time, and every unmutated test passed.

| Check | Result |
| --- | --- |
| `test_isa_balances.py` | 2 passed |
| `test_wealth_components.py` | 3 passed |
| `test_capital_valuation_properties.py` | 18 passed |
| `test_lifetime_isa_capital.py` | 3 passed |
| `test_household_subset.py` (main's #2732) | 9 passed |
| 17 YAML files that `git grep -l` finds naming `cash_isa`, `stocks_and_shares_isa`, `share_like_capital` or `corporate_wealth` | 210 cases passed |
| `lifetime_isa_capital.yaml` | 24 cases passed |
| Six-programme ISA probes on small in-memory datasets | 165 of 176 checks match; the other 11 fail identically on main (below) |
| Head against main on the same 176 checks | head never exceeds main; main − head equals 10% of `share_like_capital` to within 2.8p of penny rounding |

The probes cover UC, HB, PC, IS, income-based JSA and income-related ESA in 2025, 2027, 2032 and 2033. They use four kinds of data: stored household ISA totals, person balances, person balances with a Lifetime ISA, and `corporate_wealth` that already holds the ISA. Each programme counts savings and cash ISAs in full, takes 10% off `share_like_capital`, and counts a Lifetime ISA once, through `valued_person_capital`. No source counts twice.

The review made four mutations in place on `test_isa_balances.py`, and restored the file after each:

- Dropping the stocks-and-shares ISA from `share_like_capital` failed it at £4,288.96 (£4,000 × growth).
- Taking the 10% twice failed it at £6,025.99 (£5,620 × growth).
- Removing `share_like_capital` from UC's sale-expense sources failed it at £6,433.44 (£6,000 × growth).
- A nil sale-expense rate passed it, because the test reads the rate, but `capital_valuation.yaml` failed 8 cases.

`cash_isa` and `stocks_and_shares_isa` sum person balances through `adds`, so after the 2032 projection horizon main loses both on a dataset that stores only the household totals, and this PR leaves that as it stands. In the 2033 probe, main and this PR both count £1,310.81 of UC capital, the savings alone, where the stored totals give £7,602.69. policyengine-uk-data's Enhanced FRS writes neither total, but Microcosm's UK exports store both, so their runs for 2033 and later lose them. [#2740](https://github.com/PolicyEngine/policyengine-uk/issues/2740) tracks it: #2712 replaced the totals' `uprating` attribute with `adds`.

[CI at `3a3241cf6`](https://github.com/PolicyEngine/policyengine-uk/actions/runs/41203464649) passed: both required checks, all six Python shards and the YAML job.

## Impact on the certified data

The [aggregate-impact comment](https://github.com/PolicyEngine/policyengine-uk/pull/1969#issuecomment-6277352471), updated at 2026-11-03T07:24:43Z, compares main `52b30809f` with `6396ca1dc`, which merges `b4e872273` into that main and has the same tree. The [workflow run](https://github.com/PolicyEngine/policyengine-uk/actions/runs/41588793376) reports `b4e872273` as its head, and both sides use `enhanced_frs_2024_25.h5` (policyengine-uk-data 1.58.1). The job passed: no check broke, `sign:vat` fails on both sides, and the head fixes no failing check. Every figure below matches the run at `3a3241cf6` against main `2da212abc`. The job hasn't measured `3dbdb0027` against `main` at `95dfc62f8`.

| Change | 2025-26 | 2026-27 | 2027-28 | 2028-29 | 2029-30 | 2030-31 | 2031-32 |
|---|---:|---:|---:|---:|---:|---:|---:|
| Universal Credit | +£222.8m | +£324.3m | +£543.0m | +£1.26bn | +£1.53bn | +£1.08bn | +£1.09bn |
| Universal Credit caseload | +12.5k | +35.0k | +51.0k | +91.4k | +96.8k | +73.8k | +69.3k |
| Housing Benefit | +£0.9m | +£0.3m | +£0.4m | +£2.8m | +£19.9m | +£42.6m | +£16.1m |
| Pension Credit | +£1.0m | +£1.0m | +£1.1m | +£1.0m | +£0.9m | +£0.8m | +£0.7m |
| ESA (income-related) | +£0.4m | +£0.4m | +£0.4m | +£2.6m | +£0.4m | +£0.4m | +£0.5m |
| JSA (income-based) | +£13,640 | 0 | 0 | 0 | 0 | 0 | 0 |
| Income Support | +£43,929 | 0 | 0 | 0 | 0 | 0 | 0 |
| Council Tax Reduction | +£0.8m | +£0.8m | +£0.3m | +£0.3m | +£1.0m | −£55,441 | −£51,533 |
| Scottish Child Payment | +£0.3m | 0 | 0 | 0 | +£6.0m | +£11.0m | +£24.1m |
| Tax-Free Childcare | −£0.6m | −£1.4m | −£0.7m | 0 | −£10.2m | −£11.2m | −£1.7m |
| Targeted childcare entitlement | 0 | 0 | 0 | 0 | 0 | 0 | +£7.0m |
| Household net income † | +£225.7m | +£325.6m | +£544.7m | +£1.27bn | +£1.55bn | +£1.13bn | +£1.14bn |
| Government balance † | −£225.7m | −£325.6m | −£545.2m | −£1.27bn | −£1.55bn | −£1.13bn | −£1.14bn |
| Absolute poverty AHC, children | −0.01pp | −0.17pp | −0.21pp | −0.27pp | −0.28pp | −0.09pp | −0.35pp |

† The report rebuilds these totals without the Disabled Students' Allowance figure, which it withholds.

The model now assesses less capital, so it pays the same or more of each of the six benefits in every year. The report shows 0.0% of people losing over £1 in every year, and every base-run decile gains or holds. The moves the other way follow from higher awards:

- Council Tax Reduction counts the UC award as income in the default-scheme formula (`council_tax_reduction/_legacy.py:50-53`), so a larger award lowers it.
- Tax-Free Childcare excludes any family with `universal_credit_pre_benefit_cap` above nil (`tax_free_childcare_program_eligible.py`; `disqualifying_benefits.yaml`), unless the family gives up a smaller award through `forgoes_universal_credit_for_tax_free_childcare`.
- The TV licence fee falls by £0.1m to £0.3m a year: a household with someone aged 75 or over on Pension Credit gets a free licence (`tv_licence_free_licence_share.py`).
- VAT on private school fees moves both ways, from −£1.6m to +£2.0m, because attendance ranks households by net income including benefits (`attends_private_school.py`).
- Relative poverty rises in a few cells, such as +0.14pp for children before housing costs in 2030-31, because each run sets its line at 60% of its own median. Absolute poverty falls or holds in every cell.
- The report's own-decile means move both ways as households change deciles.

The targeted childcare entitlement moves only in 2031-32: a UC award above nil gives a family one route to it (`meets_universal_credit_criteria_for_targeted_childcare_entitlement.py`).

`share_like_capital` can also hold unit trusts and stocks-and-shares ISAs, so these aggregates take 10% off some sources whose legal treatment differs.

## Coordination

- This PR incorporates #1974's source rename. Keep `share_like_capital` in programme lists and retain `corporate_wealth` only as the backing input or an explanation of it.
- #2688 targets main and lands after this PR. This PR ports only #2688's company-capital rounding oracle correction (`1193614a6`).
- This PR keeps #1950's capital-income cases and #1965's company-substitution rules on valued capital.
- Later PRs should split direct shares, funds, ISAs and pension wealth in the data; export secured property debt; extend council tax reduction's household capital to ISAs and shares; review omitted UC land; and add independent rulespec capital valuation rather than feeding model capital into the oracle.

axiom: TheAxiomFoundation/rulespec-uk#395 queued

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Generated by Claude Code

@MaxGhenis

Copy link
Copy Markdown
Collaborator Author

Ready for hub review

Head: 3dbdb00276578089c68949b31658239386af9420 on claude/merge-main-council-tax-m72rh7-1969, four commits on #1969's b4e872273. I didn't push to uc-capital-sale-expenses or to claude/merge-main-council-tax-dgxwjl-1969. The new PR_BODY_1969.md is in the comment above; the title stays "Value means-tested capital less 10% sale expenses and secured debt", so there's no PR_TITLE_1969.txt.

Commit What it does
154f92286fafeadf5fc5d525f10d506a15f487cd Brief 1031's merge of main at af9361114, kept as it was after the review below
76242a05bba75b73c007226f348d96293e15f795 Brief 1031's penny tolerance in test_person_isa_capital.py, kept
3c395c3e4ffa873bbae481fd7fe73e36f2a52530 Merges main at 95dfc62f8; no conflict
3dbdb00276578089c68949b31658239386af9420 Adds owned_land_secured_debt to the growth factors page's per capita GDP list (docs only)

Late writer

Before I started (03:23Z), at each push, and again before posting, claude/merge-main-council-tax-dgxwjl-1969 pointed at 76242a05b, uc-capital-sale-expenses at b4e872273 and property-wealth-overseas-other at 80e0d344f. No comment or review on #1969 or #2688 after 14:22:43Z on 4 Nov held a hub document or a hand-off; the only newer comments are my two Picking this up comments (6648811730, 6648811951).

Review of brief 1031's commits

I read every resolution in git show --remerge-diff 154f92286 and both commits' diffs. Both hold; I made no fix on top.

  • The six formulas (esa_income_, jsa_income_, income_support_, housing_benefit_, pension_credit_ and uc_assessable_capital.py). Each passes valued_capital a value_of that returns the household source less pooled_person_capital, so Value means-tested capital less 10% sale expenses and secured debt #1969's per-source valuation (10% off listed sources, then secured debt, floored at nil) applies to the remainder Count each person's ISAs in their own benefit unit's capital #2839 leaves in the pool. Each counts person sources through valued_person_capital, which now iterates counted_person_sources (Count each person's ISAs in their own benefit unit's capital #2839) and values a source that HOUSEHOLD_SOURCE_OF maps to a listed sale-expense source less the rate (capital_valuation.py:83-90). UC keeps Count each person's ISAs in their own benefit unit's capital #2839's ~covered mask (uc_assessable_capital.py:72-82). Each formula's code matches main's pooling call and Value means-tested capital less 10% sale expenses and secured debt #1969's valuation call exactly; only the documentation strings were hand-written, and they read correctly (two of them keep a stray "The " string fragment, cosmetic only).
  • The lists. For all six programmes, every dated entry in sources.yaml, person_sources.yaml, property_sources.yaml and sale_expenses/sources.yaml from either b4e872273 or af9361114 survives in the merge, with no extras (script over yaml.safe_load of each file at the three commits).
  • pension_credit_income.yaml Case 4. By hand: capital 455 + 0.9 × 55,370 = 50,288; deemed income ceil((50,288 − 10,000) / 500) = 81 a week, 4,212 a year; rent disregarded, so income 4,212; guarantee credit (238 − 81) × 52 = 8,164; savings credit nil (81 a week of qualifying income). All six outputs match.
  • test_savings_credit_only_receipt_properties.py. With Value means-tested capital less 10% sale expenses and secured debt #1969, main's owner (savings 12,000, property 4,400) would give Pension Credit 12,000 + 3,960 = 15,960, the same as council tax reduction's own route, so the test would no longer tell the routes apart. The merge adds 500 of corporate_wealth: Pension Credit counts 450, the route counts none, so 16,410 against 15,960. Savings credit by hand: deemed income ceil(6,410 / 500) = 13 a week, so 0.6 × (238.00 − 208.07) − 0.4 × (253.00 − 238.00) = 11.958 a week, 621.82 a year, as asserted.
  • Main's ISA tests. I reworked the worked examples by hand. test_person_balances_without_household_totals_count_with_their_holders: first pool 7,000 + 0.9 × 2,000 = 8,800, 2,933.33 per claimant; couple 5,866.67 + 3,000 + 1,800 = 10,666.67; other unit 2,933.33 + 5,000 + 900 = 8,833.33; second pool 12,000 + 0.9 × 3,000 = 14,700, so 9,800 + 4,000 = 13,800 and 4,900 + 5,400 = 10,300; Pension Credit 14,700 + 4,000 = 18,700. person_isa_capital.yaml Cases 2, 3, 6, 7, 9, 13 and 18 check the same way, and Cases 14 and 15 land on 16,000.00 and 6,000.00 (0.9 × 17,777.78 = 16,000.002 and 0.9 × 6,666.67 = 6,000.003, nearest penny).
  • The merge's other edits. Council tax reduction's sale_expenses/rate.yaml description now names land among the secured-debt inputs, and the changelog fragment adds that council tax reduction's household capital deducts the debt secured on land. Both match the code.
  • 76242a05b. Its code is right: savings of 1,268.69 in 2032 split between two units as 634.345 each, and UC and Housing Benefit round each to 634.35, a penny over the household's 1,268.69 (rerun: UC and HB both give 634.35 and 634.35). Its message overstates the commit: the oracle changes it describes ("now value share_like_capital, and each stocks and shares ISA balance moved out of it, less the programme's sale-expense rate") are in 154f92286; 76242a05b only adds the penny tolerances. I left the history alone.

Task 1's benefit unit

One person aged 70 with a £4,000 cash ISA, £3,000 of savings and a £100,000 second home carrying a £60,000 mortgage. By hand: the cash ISA moves to its holder at face value (4,000), savings count 3,000, and the home counts 100,000 − 10,000 − 60,000 = 30,000, so 37,000 in UC, HB, IS, JSA, ESA and PC. The merge's case in capital_valuation.yaml ("Every means test counts a cash ISA and savings at face value and a mortgaged second home less sale expenses and the mortgage") pins exactly this mix, so I added no case. The model gives 37,000 in all six, at age 70 and, except Pension Credit (0, no pension-age adult), at age 40. Council tax reduction's own route gives 33,000 for the same unit: its capital/sources.yaml lists no cash ISA (main's scope, unchanged here).

Council tax reduction's household route against #1969's valuation

Run on hand-built households at the head (ctr_compare.py):

Case DWP programmes (valued_capital) CTR household route
Land 50,000 with 20,000 secured on it 25,000 25,000 with the merge's SECURED_DEBT entry; 45,000 without it
Second home 100,000, mortgage 150,000, savings 5,000 (negative equity) 5,000 5,000
Land 50,000, land debt 80,000, savings 5,000 5,000 5,000
Savings −1,000, land 50,000 44,000 45,000 (floors the source at nil)
Land 50,000, land debt −20,000 65,000 45,000 (floors the debt at nil)
Land 1,000.05 HB 900.05, IS/JSA/ESA 900.04 900.045 (no penny rounding)
Land 16,001 14,400.9004 (float64, stored as float32) 14,400.8994 (float32 arithmetic)
  • Order of deductions: the same in both (10% of the gross value, then the debt, then the floor at nil per source).
  • Negative equity: the same (each encumbered source floors at nil, so it can't reduce savings).
  • Land: main's route had no land debt because main has no owned_land_secured_debt. council_tax_reduction_capital_valuation.yaml's land case gives 25,000 with 154f92286's change to council_tax_reduction_assessable_capital.py (passes) and 45,000 without it (fails, "differs from 25000.0"), run in a scratch copy with main's version of the file. The schemes deduct "the amount of any encumbrance secured on it" (SI 2012/2885 Sch 1 para 32(b) and equivalents), so the change stands.
  • Negative inputs, rounding, precision: different, as in the table, but no test shows a wrong legal result, so I changed nothing.

main at 95dfc62f8

main merged eleven PRs since af9361114, not seven: #2744, #2760, #2763, #2768, #2769, #2786, #2787 and also #2788, #2794, #2809 and #2810. None changes a file this branch changes (the intersection of git diff --name-only af9361114 95dfc62f8 with git diff --name-only 95dfc62f8 3dbdb0027 is empty), a capital source list or an assessable-capital formula. #2788's new legacy tariff tests set *_assessable_capital as an input, so the valuation can't move them. Git merged main without conflict.

#2131

ce91e92ea now merges #1969 at b4e872273. git merge-tree --write-tree --name-only ce91e92ea 3dbdb0027 stops on docs/book/assumptions/growthfactors.md and on uc_assessable_capital.py (its documentation string only). The merge also breaks something git won't flag: #2131's lists replace share_like_capital with share_like_capital_with_sale_expenses and share_like_capital_without_sale_expenses, and #2839's counted_person_sources keeps stocks_and_shares_isa_countable_capital only while sources lists share_like_capital. In a scratch trial merge (both conflicts taken from this head), counted_person_sources for UC, HB and PC drops the stocks and shares ISA source, person_isa_capital.yaml fails 10 of 21 cases and test_person_isa_capital.py 24 of 32. #2131 needs to count those balances against the source that holds them, for example by mapping the person source to share_like_capital_without_sale_expenses in HOUSEHOLD_SOURCE_OF, and to expect them at face value in main's person ISA tests. I didn't touch #2131. The body's #2131 note says this.

Tests at 3dbdb0027

Each command on its own, clean checkout, uv sync --frozen --extra dev, no survey data:

  • policyengine-core test: gov/dwp 997 passed, finance/benefit/family 1,761 passed, council tax reduction 352 passed.
  • pytest -n 4: test_capital_valuation_properties.py 18, test_stock_capital_periods.py 2, test_uc_property_capital.py 65, test_uc_property_capital_mock.py 26, test_person_isa_capital.py 32, test_savings_credit_only_receipt_properties.py 6, test_stored_household_totals.py 42, all passed; code_health 3,181 passed.
  • .github/check_fix_pr.py with main's checker as pr_fix_evidence.yaml runs it (title and body without a trailing newline, empty labels, git diff --name-status --no-renames -z 95dfc62f8 3dbdb0027): PASS, 26 changed executable tests.
  • uvx ruff@0.17.2 format --check .: 2,229 files already formatted; ruff check . and --select F811,F821 policyengine_uk: all checks passed; git diff --check b4e872273..3dbdb0027: clean.
  • git merge-tree --write-tree --name-only 3dbdb0027 origin/main (95dfc62f8): no conflict.
  • main moved to 47a2817e2 while I worked: it merged Count Maternity Allowance in the benefit cap #2811 (benefit cap and Maternity Allowance), which changes no file either branch changes. git merge-tree --write-tree --name-only merges both heads with 47a2817e2 without conflict. I didn't merge it, since the job names 95dfc62f8.

The same YAML directories and Python files gave the same counts at 3c395c3e4 (the head before the docs commit), and the four YAML files the first merge touched passed at 76242a05b (1, 27, 10 and 21 cases), with test_person_isa_capital.py 32 and test_savings_credit_only_receipt_properties.py 6.

Skipped

  • Tests that need a survey dataset, the full suite and the documentation build: CI covers them once the branch moves.
  • The Aggregate impact job at this head: the body says the job hasn't measured 3dbdb0027.

Judgment calls


Generated by Claude Code

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
MaxGhenis added a commit that referenced this pull request Nov 5, 2026
The merge brings in #1969's changelog fragment and changes nothing else.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@MaxGhenis
MaxGhenis requested a review from juaristi22 November 5, 2026 11:22
MaxGhenis and others added 5 commits November 12, 2026 09:12
No conflicts. Four files both sides changed merged on their own:
uprating_indices.yaml, supplied_inputs.py, esa_income_capital.yaml and
council_tax_reduction_pension_credit.yaml.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Resolve three conflicts and keep main's person-level ISA allocation:

- shard_durations.toml: main's regenerated table, with this PR's three
  renamed share-component tests (same durations).
- growthfactors.md: main's text, which already lists the three
  secured-debt inputs this PR documents and moves main_residence_value and
  other_residential_property_value to house prices.
- uc_assessable_capital.py: this PR's sale_expenses.sources wording with
  main's prose, and the stocks and shares ISA at its withdrawal value.

Main (#2712, through #1969) moves each stocks and shares ISA balance out of
share_like_capital into its holder's unit. This PR replaces
share_like_capital in every capital list with its two parts, so
counted_person_sources would have dropped the ISA person source. The ISA
now maps to share_like_capital_without_sale_expenses, which holds it
because gov.dwp.share_like_capital.without_sale_expenses lists
stocks_and_shares_isa; no programme's sale-expense list names that part, so
each means test counts the balance at face value. The parameter and
variable descriptions name the new household source.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This branch values stocks and shares ISAs without the deduction for
expenses of sale (ADM H1656-H1658), and the ISA person source now comes out
of share_like_capital_without_sale_expenses. Main's person ISA cases
expected 90%, so each counted ISA rises by a tenth. Cases 13 to 15 test a
boundary, so their inputs move to keep it: a 30,600 ISA in Case 13, and
household totals of 16,000 and 6,000 in Cases 14 and 15.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Main's tests valued all of share_like_capital, and each stocks and shares
ISA, at 90%. On this branch only share_like_capital_with_sale_expenses takes
the deduction, and the ISA person source comes out of
share_like_capital_without_sale_expenses at face value. The helpers now
value each part by whether the programme's sale_expenses.sources lists it,
and the hand-worked cases follow: the producer-shape households give UC
capital of 10,900, 8,950, 14,000 and 11,000, and the list-reform test drops
share_like_capital_without_sale_expenses, the source that holds the ISA.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The test checked each total to within £0.011, and CI at df8c1ea failed it.
The engine holds totals in float32. Its float32 sum can round a penny under
the exact total, which the test's docstring allows, and it then stores that
figure to float32's step, which the £0.011 bound didn't allow for above about
£16,000. CI drew a household the test expects at £16,834.13: the engine gives
£16,834.12, held as 16,834.119, which is £0.0109 under, and the test's own
float32 subtraction read £0.0117.

The check now subtracts in float64 and allows a penny plus one float32 step at
the expected value. Two households are pinned: CI's, and one expected at
£37,747.34 that the engine holds as 37,747.328, which is £0.0119 under and
fails the old bound in float64 too.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>

@vahid-ahmadi vahid-ahmadi left a comment •

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

@MaxGhenis, delta review at a418a00 (my last was at 1efee62b). Status of my October findings:

  • the savings-credit-only case expects £621.82;
  • the reg 77 holding now leaves the pool and a complete override at 90%. Probes at this head give £5,000 and £14,000;
  • #1974 landed and its share_like_capital rename is carried through;
  • the record-level figures are gone from the body.
  • the generic sale-list guard is only partly addressed: #1974's test_lists_name_share_like_capital_only covers the share case, but there is still no general "every sale-list name is counted" check (test_capital_valuation_properties.py:224 still intersects with counted). Low risk now that #1974 has landed.

One thing came in with the merges of #1974 and #2839 and needs a merge condition.

Itemised ISAs and unit trusts now lose 10%. Main counts them in full.

  • Person route (utils/capital_valuation.py:86-89). valued_person_capital values stocks_and_shares_isa_countable_capital, a balance tied to a named holder, at 90% through HOUSEHOLD_SOURCE_OF. Main's person_isa_capital.yaml expectations fall: Case 2's child from £9,000 to £8,400 (:79), Case 7's PC from £9,000 to £8,800 (:221) and Case 9 from £11,000 to £10,700 (:281).
  • Household route (:46-53). valued_capital takes 10% off all of share_like_capital, which since #1974 is built from itemised stocks_and_shares_isa and unit_and_investment_trusts where they exceed corporate_wealth. Main's test_isa_balances.py and test_stored_household_totals.py are edited to count a stored £2,000 stocks and shares ISA at £1,800.
  • The guidance. ADM H1674: unit-trust holders "apply to the manager of the trust to withdraw their money so there are no costs of sale". H1656 values an ISA at "what people would get if they withdrew their investment" (ADM H1, pp.55 and 59).
  • This PR's text says the same. The sale_expenses/sources.yaml descriptions say the deduction reaches these "until the data separate them". On main the data already do, for both the person balances and the household components.
  • Merge condition. The body defers the fix to #2131, a draft stacked on this branch. Please land #2131 together with this PR (or fold it in), so main never counts an itemised ISA or unit trust below its current value.

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

MaxGhenis and others added 3 commits November 16, 2026 05:31
The without_sale_expenses description and the changelog fragment now say
the model counts a stocks and shares ISA at its full withdrawal value
because H1656 says nothing about costs of sale, not that a paragraph
exempts it. The description also notes that employee share options, which
the survey asks about with employee shares, take the deduction as an
approximation. A comment on COMPONENTS says every name on the exempt list
must be one of them, since the formula reads only COMPONENTS to decide
whether a household itemises.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
valued_capital reads only each programme's capital.sources, so a name on
capital.sale_expenses.sources outside them is never valued. The property
now asserts the sale list is a subset of the counted sources for all six
programmes, which the intersection check alone could not see.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…omments

#1969's changelog fragment said the 10% reached all of share_like_capital,
unit trusts included, "until the data separate them". It now names what
takes the deduction after the split: land, property, directly held shares
and any corporate_wealth a dataset does not itemise.

The ISA docs named share_like_capital as the source the stocks and shares
ISA balances leave. They now name share_like_capital_without_sale_expenses,
and say every means test counts that part at withdrawal value.

The test comments and the parameter description say the model reads ADM
H1656's silence on costs of sale as no deduction, rather than saying H1656
rules one out. The COMPONENTS comment notes that share_like_capital sums the
same names, and invariant 7 allows float32's step as well as a penny.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@MaxGhenis

Copy link
Copy Markdown
Collaborator Author

Thanks for the delta review at a418a00. The head is now 8f755b981, which folds in all of #2131, so GitHub shows #2131 as merged into this branch.

  • Merge condition. At this head, the model never takes the 10% off an itemised ISA or unit trust.
    • Person route: _person_capital_pool.py:15 maps the ISA balance to share_like_capital_without_sale_expenses, which no sale list names. person_isa_capital.yaml Cases 2, 7 and 9 keep main's £9,000, £9,000 (Pension Credit) and £11,000.
    • Household route: test_isa_balances.py and test_stored_household_totals.py keep main's full-value expectations.
  • "Until the data separate them." This PR's changelog fragment still carried that clause. 8f755b981 rewrites it: the 10% applies to land, property, directly held shares and any corporate_wealth a dataset does not itemise.
  • General sale-list guard. d6cf32529 asserts, for all six programmes, that the counted sources include every name on sale_expenses.sources (test_capital_valuation_properties.py:235). The assert runs before the intersection check.

CI is running on the combined tree. The description's Validation and Impact sections will give the results, and an independent review of a418a0040..8f755b981 will follow.

MaxGhenis added a commit that referenced this pull request Nov 16, 2026
#1969 now values unit trusts and stocks and shares ISAs at full value in
every means test, through share_like_capital_without_sale_expenses, and
takes the 10% only from share_like_capital_with_sale_expenses. This branch
held #1969 at 59a1c4a, before that split.

Each of the six sale-expense lists keeps #2688's overseas and other real
estate and names the part with sale expenses, and Pension Credit's capital
sources name both parts. test_isa_balances.py and
test_stored_household_totals.py take #1969's full-value ISA expectations,
which reverses e041345. test_property_wealth_components.py now checks
the two parts, and the property-wealth docs say which part takes the 10%.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
MaxGhenis and others added 9 commits November 16, 2026 10:15
…pany deductions consistent under reforms

Answers review fold-r1 at 8f755b9.

- P1: household_sources(law) replaces the HOUSEHOLD_SOURCE_OF constant. It maps a stocks and shares ISA balance to the share-like part that holds the household's ISAs under the period's gov.dwp.share_like_capital.without_sale_expenses. counted_person_sources, pooled_person_capital (now given parameters by all six formulas) and valued_person_capital read it, so a reform that takes stocks_and_shares_isa off the exempt list nets the balance out of the part with sale expenses and values it less 10%. stocks_and_shares_isa_countable_capital bounds balances by that part where it falls short of min(stocks_and_shares_isa, share_like_capital) by more than share_like_capital's float32 spacing; rounding alone leaves it short by at most half that, so nonnegative holdings keep today's bound.
- P2: the part with sale expenses is held between nil and share_like_capital where the itemised sum is positive, so signed holdings can't push the parts apart. The property test draws signed components, includes the 1e9 / -1e9 / 1 case, and asserts the parts sum to the total within half its float32 spacing.
- P3: household_uc_company_holding_pool_scale is nil when UC's sources don't list share_like_capital_with_sale_expenses, so no holding leaves the pool; the owner's own assessment still takes it off a report.
- P4: the CTR docstring says the household route doesn't yet count share_like_capital, and older datasets may mix it with pension wealth.
- P5/P6: the share-split fragment, the exempt parameter, the ISA docs page and two test docstrings name the six DWP capital assessments instead of every means test; the ISA docs page and the touched docstrings describe the routing and bound.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…rings

Comments and documentation strings only.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…e the means-test wording

Review fold-r2 P1: the rounding exception bounded a balance by the part
that holds the ISAs only where the part fell short by more than
share_like_capital's float32 spacing, so exact signed cancellation could
leave a pound the part does not hold (2**23 shares, -1 trusts, a 1 ISA).
The bound is now the smallest of stocks_and_shares_isa, share_like_capital
and the holdings behind the part: the listed holdings' float32 sum, clamped
as the part with sale expenses clamps it (nil where the itemised sum is not
positive), or, under a reform that moves the ISAs, the part with sale
expenses itself, which rounds once from that complement. Adds the witness,
its mirror and an unitemised case as regressions, and an exact sweep over
signed holdings near powers of two with the ISA exemption on and off and
UC counting each part or both.

P3: scope the each-means-test claims in the ISA variable, the docs page and
the person-ISA test to the six DWP capital assessments, with Council Tax
Reduction using them only through its UC and Pension Credit routes, and
state the share parts' ranges for signed itemised sums.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The sweep counts the parts under Universal Credit only, so the module
docstring now says so rather than claiming every programme.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… and round the reform-route complement once

On the baseline route the bound read only the listed holdings, so a direct
input or a reformed formula of either share part could leave the part that
holds the ISAs short while the balances kept their value, sending the pool
below nil (a lodger's UC capital fell from £5,000 to £2,500). Where the stored
part falls short of the holdings behind it by more than share_like_capital's
float32 spacing, which the parts' own formulas never do for a list of two
holdings, the stored part now bounds the balances, on either route.

Under a reform that takes the ISAs off the exempt list, the holdings behind
the part with sale expenses are now share_like_capital less the listed
holdings computed in float64, so they round once. The stored part rounds the
listed float32 sum and then the subtraction, so for a list of two holdings it
could fall a pound short of a balance the holdings cover. One-name lists, the
default reform included, give the same holdings as before.

Rename the £100.01 test, whose name described the old slack rule.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ls short

Review r3 (P2). The fallback in stocks_and_shares_isa_countable_capital
switched to the stored part only where it fell more than
share_like_capital's float32 spacing short of the holdings behind it, so it
could not tell the parts' own rounding from a direct input or a replaced or
neutralised formula within that spacing. With share_like_capital of 2**23,
a £1 ISA balance and the part that holds the ISAs entered as nil, the holder
kept £1 the part did not hold: UC for a holder and a lodger sharing £10,000
of savings came to [£5,000.50, £4,999.50], or [£5,000.45, £4,999.55] with
the ISAs off the exempt list, instead of [£5,000, £5,000].

The rounding allowance now applies only where both stored parts equal the
split the parts' own formulas give. formula_split recomputes
share_like_capital_with_sale_expenses with its own formula from the same
share_like_capital, itemised holdings and exempt list, casts it to float32
as the engine stores a formula result, and takes the other part as
share_like_capital less it, as that part's formula does. The same float32
operations on the same values give the same result, so the formulas' own
split always matches and keeps its rounding allowance exactly as before.
Where either stored part differs, the stored part bounds the balances
wherever it falls short of the holdings. Values equal to the formulas'
split, however supplied, give the formulas' results. The variable's
documentation and the ISA assumptions page say so.

Adds the reviewer's two witnesses (both routes) and structural variants,
replacing either part's formula or neutralising the part, as regressions
that fail at 45c48dc, and a test that a replacement giving the formulas'
values changes nothing while an input of the other part still bounds the
balances by the part that holds the ISAs.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Review r3 (P3). Invariant 10 and the docstring of
test_a_stored_part_short_of_its_holdings_bounds_the_balances said a
directly supplied part falling short of its holdings forces the balances
below it, while the code at 45c48dc switched to the part only beyond
share_like_capital's float32 spacing. With the previous commit the claim
holds for any shortfall once either stored part differs from the formulas'
split. Invariant 10 now says the balances exceed the stored part only where
both parts are the formulas' split, and then by no more than that spacing;
that an input or a replaced or neutralised formula making either part differ
bounds them by the stored part however little it falls short; and that
values equal to the formulas' change no result. The test docstring notes its
shortfalls all exceed the spacing and points to the test of those within it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…l or less, holdings for NaN

Invariant 10, the variable's documentation and formula comment, and the
ISA assumptions page said the balances hold no more than the stored part
that holds the ISAs, and that the pool never counts less than nil of it.
That overstates the guarantee. bounded_holdings floors the bound at nil,
so a stored part below nil cannot bound the balances below nil. With the
part entered as -1, or given as -20 by the formulas' own split (the
verifier's cases), the balances hold nil and the pool counts the negative
part as it stands. A missing (NaN) stored part is never the formulas'
split and never less than the holdings, so the holdings stay the bound.

Each passage now says what the code does: the balances hold no more than
the stored part, or nil where it is nil or less, plus at most
share_like_capital's float32 spacing where both parts are the formulas'
split, and a NaN part leaves the bound at the holdings. The claim that
the pool never counts less than nil now covers only overridden parts of
nil or more; the stored-part test's docstring says its parts are all nil
or more. Text only: no formula, assertion or expected value changes.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Review r4 found that invariant 10, the variable documentation and comment,
and the ISA assumptions page state the stored-part bound without
exception. Where stocks_and_shares_isa or share_like_capital is missing
(NaN), household_total and so the overall bound are NaN, the comparisons
are false, and bounded_holdings leaves finite balances of nil or more
unchanged, so a balance can exceed the stored part. Each passage now
limits the guarantees to the case where none of the bound's three amounts
is missing, and says what happens otherwise.

The text also said a missing stored part "leaves the bound at the
holdings". That is true of the holdings term only: the bound is still the
smallest of stocks_and_shares_isa, share_like_capital and the holdings. It
now says the missing part never replaces the holdings as a bound, and the
code comment says "overall bound" where it means the final one.

Text only: no executable line, assertion or expected value changes.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
MaxGhenis added a commit that referenced this pull request Nov 17, 2026
Brings #1969's answers to its fold-r1 review: person ISAs routed by the
exempt list, share parts that sum under signed inputs, no company-holding
deduction from trusts after a source-list reform, the CTR docstring, and
"the six DWP capital assessments" in place of "every means test".
No conflicts.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
MaxGhenis added a commit that referenced this pull request Nov 17, 2026
#1969's later rounds bound person ISA balances by the holdings behind their
stored part, round the reform-route complement once, and qualify the bound
text for missing aggregates. The merge is clean on top of 6e4c632, which
keeps review r1's two text fixes (CTR's capital route and the capital table).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

UC capital ignores reg 49 valuation (10% sale costs and secured debts)

3 participants