Repository navigation
Value share-like capital by asset type for the sale-expense deduction - #2131
Conversation
…le-expense-share-split
…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>
vahid-ahmadi
left a comment
There was a problem hiding this comment.
Thanks Max. Reviewed at head b1a66004.
The "+10.5k lines" is the main merge carried in through #1974. The real diff over #1969 + #1974 (merged at their heads) is 11 files, +710/−125:
- the six
sale_expenses.sourceslists; - the new
capital_valuation_share_split.yaml; - the property tests;
test_stock_capital_periods.py;- a changelog fragment.
That's what I reviewed.
Guidance:
- ADM H1674 is explicit: unit trusts have "no costs of sale. This applies even if persons use an agent, such as a stockbroker."
- H1665 applies the 10% to quoted shares.
- H1656 values an ISA at "what people would get if they withdrew their investment".
The lists now apply the 10% to directly_held_shares and the unitemised residual only, which is right for shares and unit trusts. SPC Sch V and UC Sch 10 have no disregard that changes this.
Probes:
- savings £5,000, shares £4,000, trusts £3,000, ISA £5,000 (
corporate_wealth£12,000) gives £16,600 for UC, HB and IS. The same holdings with only the components entered also give £16,600. - An unsplit
corporate_wealthof £12,000 still gives #1969's £15,800. - Your monthly case (£12,300) matches.
Tests:
- At the head: the capital-valuation, share-component, wealth-component, stock-period and PC reported-capital property tests, 26 passed. DWP, family and household YAML, 1,064 passed.
- Merged into current main (the merge is clean): YAML, 1,389 passed. Properties: 19 passed and 2 failed. The two failures are the same stale
applies()oracle as on #1969 (here attests/test_capital_valuation_properties.py:240), not the new share-split properties. They'll clear when #1969's fix is carried through. - There's no CI on this PR, because its base isn't main, so these local runs are the only test evidence so far.
Findings:
-
Should fix (merge order). Retarget to main as soon as #1969 merges, and get CI green on the retargeted head before merging. Until then, nothing hosted has run on these lists. This PR must land in the same window as #1969 and #1974 (see my notes there): with those two in and this one out, the 10% on shares disappears.
-
Should fix.
parameters/gov/dwp/universal_credit/means_test/capital/sale_expenses/sources.yaml:20-22, and the same sentence in the other five lists. The ISA exemption is weaker than the unit-trust one:- H1674 says outright that unit trusts have no costs of sale. For ISAs, the guidance is silent and you're inferring from H1656 ("withdrawal value").
- A stocks-and-shares ISA holding quoted shares has to sell them through the ISA manager. That is a broker sale under H1605, and reg 49(1)(a) applies wherever "there would be expenses attributable to sale".
I'd keep ISAs exempt, since most ISA money is in funds, but describe it as a judgement, like the investment-trust one, rather than "no ISA paragraph applies the 10%". Give the directly-held-shares share of stocks-and-shares ISAs from HMRC Table 9.6 alongside it.
-
Nit.
variables/input/directly_held_shares.py:9. Employee share options now take the 10% as "shares". An unexercised option isn't sold through a broker and is often not realisable at all. It's fine as an approximation, but say so in the list descriptions next to the investment-trust caveat. -
Nit.
tests/test_capital_share_components.py. You removed the itemising-invariance test on purpose. A one-line comment pointing to the replacement differential intest_capital_valuation_properties.pywould stop someone restoring it.
|
Independent review (GPT-6.1 Sol, UK hub sweep, 2026-10-12): REQUEST_CHANGES at VERDICT: REQUEST_CHANGES
The stated mechanisms and invariants match the code under the chosen methodology. Property tests cover the load-bearing logic; replacing the old itemising-invariance test is justified. The exemption commit adds no skips or xfails. Ruff formatting and lint passed for its three changed Python files. Shell testing was attempted below the 30 GB compressor threshold. GB regulations and programme manuals were reviewed; several NI references and the HMRC percentages remain unverified. Requested |
…ale-expense-share-split # Conflicts: # docs/book/assumptions/growthfactors.md # policyengine_uk/data/uprating_indices.yaml # policyengine_uk/tests/test_capital_valuation_properties.py
…le-expense-share-split # Conflicts: # docs/book/assumptions/growthfactors.md # policyengine_uk/data/uprating_indices.yaml # policyengine_uk/tests/test_capital_share_components.py
#1974 replaced the components-plus-residual design with one share_like_capital block that keeps the supplied corporate_wealth exactly. This follow-up now splits that block in two: - share_like_capital_with_sale_expenses: share_like_capital less the itemised holdings in gov.dwp.share_like_capital.without_sale_expenses (unit and investment trusts, stocks and shares ISAs), floored at nil; all of it when nothing is itemised. - share_like_capital_without_sale_expenses: the rest, exactly nil when nothing is itemised. The six capital lists name both parts and the six sale-expense lists the first, so datasets that carry only corporate_wealth keep #1969's flat 10% exactly (differential test, annual and monthly, against the lists before itemising, including negative aggregates and a value whose 90% is a fraction of a penny over the limit). The exempt holdings are a parameter list, so the methodology call on investment trusts and ISAs (d1396) is a one-line change. Merged the refreshed #1969 (54ed063) and #1974 (7784193). #1969's property oracle reads the share-like sources from an unitemised household's corporate_wealth; the split invariants (definition of both parts, the unitemised differential, split effect = 10% of trusts plus ISAs on UC capital, components-only valuation) are in test_capital_share_components. Dropping the nothing-itemised branch from the formula fails the differential. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…uping Review of b7e6bc5: - gov.dwp.share_like_capital.without_sale_expenses started in 2013, after the legacy capital lists (JSA from 1996-10-07), so a 2012 simulation with unitemised corporate_wealth raised ParameterNotFoundError; it now starts at 1996-10-07, and Income Support and JSA capital in 2012 are tested (both fail with the 2013 start). - An empty exempt list made add() return None; the exempt holdings are now summed from a numeric zero, and an empty-list reform (every share-like holding less 10%) is tested. - The property oracle now follows the engine's float32 grouping (components left to right, exempt holdings summed before subtraction) and compares exactly; the reviewer's example (trusts £200,000, ISA £199,999.984375) is pinned. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ale-expense-share-split
…le-expense-share-split # Conflicts: # policyengine_uk/tests/test_capital_share_components.py
…ale-expense-share-split
…le-expense-share-split # Conflicts: # policyengine_uk/tests/test_capital_share_components.py
vahid-ahmadi
left a comment
There was a problem hiding this comment.
Needs changes before merge. The split itself is right and well tested. But this branch carries both CI failures from #1969 and #1974, it inherits the #1965 holding problem in both forms, and nothing hosted has run on it.
@MaxGhenis, this is a delta review. My last review was at b1a66004; this one is at 6a5a13a4. Since then the split has been rebuilt on #1974's block: share_like_capital_with_sale_expenses and _without_sale_expenses, with an exempt-holdings parameter. I reviewed the diff against #1969 + #1974 merged at their current heads: 21 files, +678/−186.
Status of my earlier findings:
- F1 (retarget to main, CI): still open. See finding 2.
- F2 (ISA exemption described as a judgement): partly addressed. The body now has a methodology note, but the parameter text still states it as settled. See finding 3.
- F3 (employee share options caveat): not taken. See finding 5.
- F4 (invariance test comment): addressed. The module docstring now points to the differential.
Findings:
-
must (carried in from #1969 and #1974). This head contains both CI failures and the #1965 interaction:
test_projection_horizon.py:181fails, as on #1974. The ISA variables are now mapped inuprating_indices.yaml.test_savings_credit_only_receipt_properties.py:508fails, as on #1969. It expects 601.02 where reg 19 gives 621.82.- Company holdings, probed on this head merged into current main. Take a single UC claimant who is sole owner of a trading company, with a £10,000 holding and £5,000 savings:
- with
corporate_wealth£10,000, UC capital is £4,000 (expected £5,000); - with only
directly_held_shares£10,000, UC capital is £14,000 (expected £5,000), because the pool cap still readscorporate_wealth.
- with
- On this head merged into main, the same 8
uc_company_analogous_business.yamlcases and 3test_uc_company_owner_properties.pyproperties fail as on #1969. Five of those YAML cases are the holding problem; three are the plain 90% revaluation and only need new expectations (see my #1969 review). - Here the holding should come off
share_like_capital_with_sale_expensesat 90%, since an owner's shares are directly held shares.
Once the fixes land on #1969 and #1974, merge them through and re-run.
-
must. No CI has run on this PR, because its base is
uc-capital-sale-expenses. The body's "Local runs" line is still "pending". Retarget to main and get the full suite green before anything in the stack merges. If this PR lands alone, it carries #1969 and #1974 with no window where the 10% on shares disappears. On a #1969 + #1974 tree without this PR, £5,000 savings +corporate_wealth£12,000 gives £17,000 for UC; this head gives £15,800. -
should.
parameters/gov/dwp/share_like_capital/without_sale_expenses.yaml:10-12still says "no ISA paragraph applies the deduction", as if that settled it. The changelog fragment states the ISA exemption flatly too.- ADM H1656 and DMG 29662 value an ISA at "what people would get if they withdrew their investment" and say nothing about costs of sale.
- The body parks this, and the investment-trust question, for a decision (d1396).
- Until it's decided, the parameter text should call the exemption a judgement, as it already does for investment trusts. I'm not suggesting which way to decide.
-
nit. The six
capital/sources.yamldescriptions each have an unwrapped line of about 175 characters. An example isuniversal_credit/means_test/capital/sources.yaml:8("share_like_capital_with_sale_expensesandshare_like_capital_without_sale_expensessplit ..."). Rewrap to match the rest. -
nit.
share_like_capital_with_sale_expenses.py:3hardcodesCOMPONENTSfor the "is anything itemised" gate, while the exempt list is a parameter. A reform adding a new exempt variable outsideCOMPONENTSwould be ignored for a household that itemises only that variable. Consider a comment saying the exempt list must be a subset of the components, or a test asserting it. Separately, employee share options still take the 10% as "directly held shares" with no caveat (my F3). One clause inwithout_sale_expenses.yamlwould cover it.
What I checked:
-
Guidance, re-read from the current PDFs:
- ADM H1656-H1658 (ISA at withdrawal value; nothing on costs of sale);
- ADM H1673-H1674 and DMG 29680-29681 (unit trusts: "no costs of sale ... even if persons use an agent");
- DMG 29662 and 29664 (ISA), and DMG 29671 (10% on shares).
The paragraph numbers in the parameters match. I didn't check the NI or HBGM numbers, or the HMRC Table 9.6 percentages.
-
Probes on this head:
- unsplit £5,000 +
corporate_wealth£12,000 gives £15,800 (UC, IS; PC at 70), as on #1969; - split shares £4,000, trusts £3,000, ISA £5,000 gives £16,600;
- components only with £1,000 savings gives £1,000 + 90% × £4,000 + £3,000 + £5,000 = £12,600, matching the body.
- unsplit £5,000 +
-
Revert check.
capital_valuation_share_split.yamlrun on #1969 + #1974 without this PR's source changes: 10 failed. At this head: 10 passed. -
Tests. I ran the same property files and YAML directories as on #1969 and #1974, plus #1965's company-owner tests.
- At this head: 2 failed (the two carried CI failures) and 2,360 passed; YAML 1,889 passed.
- Merged into current main (clean): 5 failed (those two plus the three #1965 properties) and 2,405 passed; YAML 8 failed (company cases) and 1,980 passed. Current main
714b1438con the same set: all 2,363 pass, and YAML 1,964 pass.
-
Lint.
ruff checkandruff format --checkon the 11 changed Python files: clean. -
Repo process. The
.fixedfragment and the Reproducer and axiom lines are present, and the named reproducer case exists. The branch also carries #1974's.addedfragment, which is fine if it lands as one unit. -
Overlap with my open PRs. #2382 merges cleanly with it.
-
Not checked. Any dataset run, or uk-data #501.
🤖 Generated with Claude Code
|
UK hub takeover for the Budget fix sprint (Max, 21 Oct). The owner session If the owner session wakes, please don't push to this branch; comment here instead, so there's only one writer. 🤖 Generated with Claude Code |
When trusts and an ISA exceed corporate_wealth only by float32 rounding, share_like_capital keeps corporate_wealth and subtracting the exempt holdings goes below nil. £16,000 of corporate_wealth with £8,000.01 of trusts and an £8,000 ISA leaves -£0.009765625 without the floor. No fixed case reached the floor before: the grouping case lands at exactly nil either way. A fixed test and a matching @example on the property pin it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Picking this up for the UK hub. Reply here if you're mid-change and I'll stop. Generated by Claude Code |
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01LwQq6JPpGLuS9js3RjsmWH
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01LwQq6JPpGLuS9js3RjsmWH
|
Generated by Claude Code |
|
Generated by Claude Code |
|
Ready for hub review Head
I pushed nothing to Before starting (07:41Z), I checked the branches and comments. Findings and resolutions1. Merge of #1969 (
The merge kept this branch's 2. Stored-totals test (
3. #2779's growth-factors page.
Against
4. Body.
Tests at
|
| Command | Result |
|---|---|
pytest -n 4 test_stored_household_totals.py |
42 passed (184 s) |
test_isa_balances.py |
8 passed |
test_capital_valuation_properties.py |
18 passed (276 s) |
test_stock_capital_periods.py |
3 passed |
test_uc_company_owner_properties.py |
7 passed |
test_uc_company_override_properties.py |
11 passed |
test_uc_property_capital.py |
65 passed |
test_uc_property_capital_mock.py |
26 passed |
test_capital_share_components.py::test_unitemised_inputs_match_the_lists_before_itemising, on its own, under timeout 2400 |
1 passed (1,791 s); did not stop |
test_capital_share_components.py, deselecting that node, -n 4 |
21 passed (571 s) |
Other files naming the five variables, -n 4 per file: test_uc_capital_allocation.py 1, test_benunit_reported_capital_properties.py 7, test_corporate_land_value.py 4, test_corporate_receipts_statistics.py 141, test_dataframe_dataset.py 90, test_isa_accounting.py 12, test_lifetime_isa_capital.py 3, test_mixed_age_couple_properties.py 1, test_pension_credit_reported_capital_properties.py 4, test_process_time_reforms.py 71, test_sdlt_counted_once_properties.py 1, test_uc_income_from_capital_properties.py 6, test_uc_legacy_closure_properties.py 4, test_uc_single_claim_properties.py 8, test_wealth_components.py 3, test_wealth_tax_net_base_properties.py 2, test_weighted_incidence.py 19 |
377 passed |
policyengine-core test: capital_valuation.yaml 26, capital_valuation_share_split.yaml 10, cash_isa_capital.yaml 8, lifetime_isa_capital.yaml 24, household/wealth/isa_balances.yaml 2 |
70 passed |
policyengine-core test, the other *capital*.yaml files: ESA esa_income_capital 10 and legacy_capital 3; HB housing_benefit_capital 13, housing_benefit_residential_capital 7 and legacy_capital 2; IS income_support_capital 10 and legacy_capital 3; JSA jsa_income_capital 9 and legacy_capital 3; UC uc_income_from_capital 7, uc_assessable_capital 6 and gov/dwp/universal_credit/uc_property_capital 9; PC pension_credit_reported_capital 9; household/wealth/benunit_reported_capital 6 |
97 passed |
pytest -n 4 policyengine_uk/tests/code_health |
3,113 passed (234 s) |
.github/check_fix_pr.py on the posted title and body, label ci-recheck, changes git diff --name-status --no-renames -z b4e872273 HEAD, --head-sha ce91e92e… |
Fix evidence: PASS — "Changed executable tests: 6." |
uvx ruff@0.17.2 format --check . / check . / check --select F811,F821 policyengine_uk |
2,180 files already formatted / All checks passed / All checks passed |
git diff --check 6a0d26d61..HEAD |
clean |
git merge-tree --write-tree --name-only HEAD origin/main (52b30809f, unchanged since the brief) |
clean, tree 427e7bb71 |
git merge-tree --write-tree --name-only HEAD af3758c64 |
conflict in docs/book/assumptions/growthfactors.md only |
test_isa_balances.py gives 8 here. The brief's review counted 8 on its scratch merge, and #1969's head has 2.
Mutation check
I made a scratch worktree at ce91e92e and removed - stocks_and_shares_isa from policyengine_uk/parameters/gov/dwp/share_like_capital/without_sale_expenses.yaml. I confirmed that policyengine_uk.__file__ resolved to the worktree. test_stored_household_totals_grow_past_the_projection_horizon then failed: AssertionError: 2025, assert np.float64(5800.0) == 6000.0 ± 0.06. I restored the file with git checkout, and git status --short came back empty.
Judgment calls
- The long node's name. The brief names
test_capital_share_components.py::test_capital_matches_the_original_lists, which is Value means-tested capital less 10% sale expenses and secured debt #1969's name for it. At this head pytest reports "not found". This PR renamed that testtest_unitemised_inputs_match_the_lists_before_itemising(2f1051e9f), with the same 1,299 s line inshard_durations.toml. I ran the renamed node on its own instead. - Extra YAML files. I ran
cash_isa_capital.yaml,lifetime_isa_capital.yaml(both undergov/dwp, not a programme directory) andhousehold/wealth/isa_balances.yamlwith the YAML set, because the body cites them. I left out the fourcapital_gains_taxYAML files under HMRC. - No YAML changes since
b4e872273. This PR adds no YAML test, and changes none, beyondcapital_valuation_share_split.yaml. - The
owned_land_secured_debtpage entry. I left it in this PR's page edit, as Value share-like capital by asset type for the sale-expense deduction #2131 already had it. The name comes from Value means-tested capital less 10% sale expenses and secured debt #1969's uprating change, so whichever PR lands second resolves the Bring the growth factors page into line with the uprating map #2779 conflict with the one-name insertion above. - "Changed executable tests". I ran
check_fix_pr.pywith changes fromb4e872273, as the brief asks, so it counts 6. Against Value means-tested capital less 10% sale expenses and secured debt #1969's branch it would count this PR's full changes.
Skipped
- Nothing needed a survey dataset.
- I didn't rerun the earlier aggregate-impact or differential checks. The body keeps them, labelled
2f1051e9f. - I didn't run the full suite. CI hasn't run on this head, because the branch has no PR.
Generated by Claude Code
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
left a comment
There was a problem hiding this comment.
@MaxGhenis, following up on my review at 6a5a13a4 at 3fe76ee.
Done.
- Company holding.
household_uc_company_holding_pool_scale.py:6now takes the holding offshare_like_capital_with_sale_expenses, andtest_capital_share_components.py:398-403pins it. - Long lines. This PR's diff no longer adds any parameter line over 120 characters.
- Exempt list.
test_capital_share_components.py:136-137now pins the baseline exempt list to the two itemised components. That covers theCOMPONENTSpoint at baseline; a comment atshare_like_capital_with_sale_expenses.py:3would still help a future reform.
1. Land this with #1969. My #1969 review asks for exactly that, and this head does the restoring:
_person_capital_pool.py:15mapsstocks_and_shares_isa_countable_capitaltoshare_like_capital_without_sale_expenses, which is not on any sale list.- Person route.
person_isa_capital.yamlCases 2, 7 and 9 are back to main's values: £9,000 (:82), PC £9,000 (:224) and £11,000 (:284). #1969 alone gives £8,400, £8,800 and £10,700. - Household route.
test_isa_balances.pyandtest_stored_household_totals.pynow count the stocks and shares ISA throughshare_like_capital_without_sale_expenses, at full value. - The PR is still a draft on #1969's branch with no checks. Please take it out of draft and merge it into #1969's branch (or fold it in) before #1969 merges, so CI runs on the combined tree.
2. should (still open): the ISA wording.
parameters/gov/dwp/share_like_capital/without_sale_expenses.yaml:10-12still reads "no ISA paragraph applies the deduction", andchangelog.d/sale-expense-share-split.fixed.mdstates the ISA treatment flatly.- Full value is the reasonable reading of ADM H1656, which values an ISA at "what people would get if they withdrew their investment" (ADM H1, p.55).
- Please have the parameter say that it rests on H1656's silence on costs of sale, as the PR body already does.
3. nit (still open): employee share options.
directly_held_sharesincludes "employee shares and share options" (variables/input/directly_held_shares.py:9), so they take the 10%.- One clause in
without_sale_expenses.yamlnoting this as an approximation would cover it.
Review drafted with AI assistance and checked against the code at 3fe76ee.
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>
|
Thanks for the follow-up at
Any further points on the combined change are best raised on #1969. |
#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>
This PR values share-like capital by asset type in the means tests. It stacks on #1969 (head
a418a0040), where PolicyEngine deducts 10% for expenses of sale. Through #1969 it includes main at83c2554b2, and it includes #1974. This PR adds the asset split and its tests, updates the CI shard table and main's stored-totals test, and documents secured-debt uprating.Reproducer:
policyengine_uk/tests/test_isa_balances.py::test_person_isa_balances_count_in_full_in_every_means_testWhat changes
Under #1969, PolicyEngine takes 10% off all of
share_like_capital. DWP tells decision makers to value its parts differently in ADM chapter H1:This PR splits
share_like_capitalin two:share_like_capital_with_sale_expensesby subtracting the holdings ingov.dwp.share_like_capital.without_sale_expensesfromshare_like_capital, with a floor at nil. The list contains unit and investment trusts and stocks and shares ISAs. For households that itemise nothing, PolicyEngine keeps all share-like capital in this part and retains Value means-tested capital less 10% sale expenses and secured debt #1969's flat 10%.share_like_capital_without_sale_expenses, or nil when the household itemises no holding.All six capital lists name both parts beside savings and cash ISAs: Universal Credit, Housing Benefit, Income Support, income-based JSA, income-related ESA and Pension Credit. Their sale-expense lists name the first part and exclude savings and cash ISAs.
Stocks and shares ISAs
On main, PolicyEngine sums
cash_isaandstocks_and_shares_isafrom each person's balance (#2712), and readsstocks_and_shares_isaas an itemised holding. It puts stocks and shares ISAs in the part without sale expenses, whether a dataset stores household totals or person balances. Each means test counts the ISA at its withdrawal value.Under #1969, PolicyEngine takes 10% off the ISA, so this PR changes the expectation in
test_isa_balances.py. The stored case supplies £1,000 of savings, a £3,000 cash ISA and a £2,000 stocks and shares ISA for 2025. UC capital in 2027 rises from (£1,000 + £3,000 + 90% × £2,000) × 1.07224 = £6,218.99 to (£1,000 + £3,000 + £2,000) × 1.07224 = £6,433.44. Per capita GDP growth of 4.0% in 2026 and 3.1% in 2027 compounds to 1.07224. A new test gives a single adult the same amounts and supplies their own ISA balances. It checks £6,000 of capital in all six means tests.mainnow also counts each member's stocks and shares ISA balance in the holder's own benefit unit (stocks_and_shares_isa_countable_capital), and subtracts it from the household source before it allocates the pool. Onmainthat source isshare_like_capital. This PR names the two parts in every capital list in its place, so the merge maps the ISA person source toshare_like_capital_without_sale_expenses(HOUSEHOLD_SOURCE_OF), the part that holds the ISA becausegov.dwp.share_like_capital.without_sale_expenseslistsstocks_and_shares_isa. No programme's sale-expense list names that part, so each means test counts the member's balance at face value in the holder's unit. Main's person ISA tests expected 90% of each balance;65cebd3f6anddf8c1ea79move them to face value (see Merge notes).The mapping is fixed in code and doesn't follow the parameter. After a reform that removes
stocks_and_shares_isafromgov.dwp.share_like_capital.without_sale_expenses, a single adult with £1,000 of savings and a £2,000 stocks and shares ISA balance gets UC capital of £2,800, the ISA at 90%, as the reform intends. We haven't tested how such a reform allocates a member's ISA between the benefit units of one household.Main's
test_stored_household_totals_grow_past_the_projection_horizonreaches this PR through #1969. Its household stores the same three amounts, and #1969 makes it expect UC capital of 5.8 × savings. This PR makes the test expect savings, the cash ISA and the stocks and shares ISA at face value, 6 × savings in every year from 2025 to 2040, and drops its check that capital stays below face value.Regulation 77 company holdings
An owner-manager holds company shares that UC disregards under reg 77(2), and selling shares incurs expenses. This PR moves
HOLDINGS_SOURCEfromshare_like_capitaltoshare_like_capital_with_sale_expenses. PolicyEngine budgets company holdings against that source in the UC pool, so it never deducts them from unit trusts or ISAs. It removes the holding from the pool and any complete override at 90%, matching UC's valuation of shares. On data that don't itemise, PolicyEngine calculates the same value for both sources.CI shard table
Main's
shard_durations.tomlnames three share-component tests that this PR replaces, andtest_ci_test_shards.pyfails when a line names a test that doesn't exist. This PR points those lines at the successors and keeps their measured durations.Growth factors page
main'sgrowthfactors.mdnow lists the three secured-debt inputs this PR documented (owned_land_secured_debt,other_residential_property_secured_debtandnon_residential_property_secured_debt) in its per capita GDP list, so the merge takesmain's page and this PR no longer edits it.Methodology
The Wealth and Assets Survey asks about unit and investment trusts in one question. Investment trusts trade as quoted shares; we infer that decision makers apply H1665's 10% deduction to directly held investment trusts. 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, and we use that composition as a proxy when treating the combined trust bucket outside ISAs as unit trusts. The survey does not separate the two trust types.
We give the whole trust bucket the treatment of unit trusts and count ISAs at their withdrawal value with no deduction. Under H1656, decision makers value an ISA at what its holder would get by withdrawing it; the paragraph does not mention the 10%. PolicyEngine retains the 10% for directly held shares and all of an unitemised
corporate_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. Applying the 10% to part of a holding, such as the investment trusts in the bucket, would require a weight parameter and a formula change.Impact
CI compared #1969's head
3a3241cf6with2f1051e9fon the certified Enhanced FRS (enhanced_frs_2024_25.h5, policyengine-uk-data 1.58.1). It found no change in any household's net income from fiscal year 2025-26 to 2031-32, or in receipts, the government balance, poverty or inequality.policyengine-uk-data (
mainate1acdf966) imputes onecorporate_wealth. It sums WAS non-defined-benefit pension wealth, employee shares and options, UK shares, investment ISAs, and unit and investment trusts. It doesn't impute the three holdings separately, so PolicyEngine retains #1969's flat 10% for every household in that dataset.Microcosm's UK build writes
directly_held_shares,unit_and_investment_trustsandstocks_and_shares_isaso that they sum tocorporate_wealth(was_wealth.pyatc0513dbae). On data from that build, PolicyEngine excludes trusts and stocks and shares ISAs from the 10% deduction. CI's aggregate report doesn't cover those data.Invariants
test_capital_share_components.pyuses Hypothesis to check these properties on pounds-and-pence inputs that the engine stores as float32:share_like_capitalkeeps the suppliedcorporate_wealthunless the itemised holdings exceed it beyond float32 rounding, and then equals their sum.share_like_capitaland the other part holds nil. Otherwise the first equalsshare_like_capitalless trusts and ISAs, never below nil, and the two parts sum toshare_like_capital.1e-5.The capital property suite from #1969 (
test_capital_valuation_properties.py) keeps its oracle. The oracle specifies which assets take the 10% from the law, independently of the parameters. It maps the part with sale expenses to the household'scorporate_wealthand the part without to nil. It still raises aKeyErrorfor any source it doesn't map.test_stored_household_totals_grow_past_the_projection_horizonchecks that a household's UC capital equals savings plus its 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:
corporate_wealthbeside £200,000 of trusts and a £199,999.984375 ISA, PolicyEngine leaves nil with sale expenses. It rounds both totals to £400,000 in float32 and sums the trusts and ISA before subtracting them;corporate_wealthbeside £8,000.01 of trusts and an £8,000 ISA, PolicyEngine sums the holdings in float32 to £16,000.009765625. It leaves nil with sale expenses and £16,000 without;corporate_wealthas £11,800 in 2012;corporate_wealthwhen float32 rounding pushes the components' sum above £16,000 or £16,384.01;test_stock_capital_periods.py).Validation
CI runs only on pull requests into
main, so it skips this PR while it targets #1969's branch, and we start it by hand. Run 43252893454 atdf8c1ea79passed the YAML job, lint, the documentation and release builds, the smoke imports and seven of the eight Python shards. Shard 3 failed one test (1 failed, 1,970 passed), which3fe76ee3efixes (see Merge notes). Run 43444525978 at3fe76ee3epassed all 18 jobs: 13,482 Python tests passed (61 skipped and 2 xfailed, as allowlisted), and the YAML job, lint, the documentation and release builds and the smoke imports on Python 3.11 to 3.14 passed.Merge notes
2a1725e50merges #1969's heada418a0040, which mergesmainat83c2554b2, intoce91e92ea. Git stopped on three files:shard_durations.toml: the merge takesmain's regenerated table and keeps this PR's three renamed share-component tests at the same durations.growthfactors.md: the merge takesmain's page (see Growth factors page).uc_assessable_capital.py: the merge keeps this PR'ssale_expenses.sourceswording withinmain's prose, and the stocks and shares ISA at its withdrawal value.The merge maps the ISA person source to
share_like_capital_without_sale_expenses(see Stocks and shares ISAs); without that,counted_person_sourceswould have dropped it, because no capital list namesshare_like_capitalany more. Two commits movemain's person ISA tests to face value:65cebd3f6(person_isa_capital.yaml): 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.df8c1ea79(test_person_isa_capital.py): the helpers value each part by whether the programme'ssale_expenses.sourceslists it, so the producer-shape households give UC capital of £10,900, £8,950, £14,000 and £11,000, and the list-reform test dropsshare_like_capital_without_sale_expenses, the source that holds the ISA.3fe76ee3e(test_capital_share_components.py):test_itemised_holdings_are_valued_by_type_in_every_means_testchecked each total to within £0.011. The engine holds totals in float32. Its sum can round a penny under the exact total, which the test allows, and it then stores that figure to float32's step. CI atdf8c1ea79drew 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. It pins that household and one expected at £37,747.34, which the engine holds as 37,747.328, £0.0119 under. With the £0.011 bound the second pinned household fails; with the new bound the test passes.We ran these on the code at
df8c1ea79, one process at a time with a 2 GB memory cap,HUGGING_FACE_TOKENandPOLICYENGINE_UK_DEFAULT_DATASETunset:policyengine-core teston 17 YAML files:capital_valuation.yaml,capital_valuation_share_split.yaml,person_isa_capital.yaml,isa_balances.yaml,isa_subscription_limits.yaml, the ESA, HB, IS and JSA capital files,uc_property_capital.yaml,uc_company_analogous_business.yaml,uc_unearned_income.yaml,is_UC_eligible.yaml,pension_credit_income.yaml,council_tax_reduction_pension_credit.yaml,private_pension_wealth.yamlandwealth_tax.yaml65cebd3f6)test_person_isa_capital.py, each test in its own processtest_isa_balances.pytest_stored_household_totals.pytest_capital_valuation_properties.pycode_health/test_ci_test_shards.py, the check that the shard table names existing testsThe figures in the rest of this section come from
ce91e92eaand earlier commits.We ran these at
ce91e92ea9d2d7c7025d932ba613438bf4a70a8d, afteruv sync --frozen --extra dev, withHUGGING_FACE_TOKENandPOLICYENGINE_UK_DEFAULT_DATASETunset:uv run pytest -n 4ontest_stored_household_totals.pytest_isa_balances.pytest_capital_valuation_properties.pytest_stock_capital_periods.pytest_uc_company_owner_properties.pytest_uc_company_override_properties.pytest_uc_property_capital.pytest_uc_property_capital_mock.pyuv run pytest test_capital_share_components.py::test_unitemised_inputs_match_the_lists_before_itemising, on its ownuv run pytest -n 4 test_capital_share_components.py, deselecting that nodeuv run pytest -n 4, one file at a time, on the other test files that nameshare_like_capital,corporate_wealth,stocks_and_shares_isa,uc_assessable_capitalorsale_expenses:test_uc_capital_allocation.py1,test_benunit_reported_capital_properties.py7,test_corporate_land_value.py4,test_corporate_receipts_statistics.py141,test_dataframe_dataset.py90,test_isa_accounting.py12,test_lifetime_isa_capital.py3,test_mixed_age_couple_properties.py1,test_pension_credit_reported_capital_properties.py4,test_process_time_reforms.py71,test_sdlt_counted_once_properties.py1,test_uc_income_from_capital_properties.py6,test_uc_legacy_closure_properties.py4,test_uc_single_claim_properties.py8,test_wealth_components.py3,test_wealth_tax_net_base_properties.py2,test_weighted_incidence.py19uv run policyengine-core test -c policyengine_ukoncapital_valuation.yaml26,capital_valuation_share_split.yaml10,cash_isa_capital.yaml8,lifetime_isa_capital.yaml24,isa_balances.yaml2, and the*capital*.yamlfiles under ESA 13, HB 22, IS 13, JSA 12, UC 22, PC 9 andhousehold/wealth6uv run pytest -n 4 policyengine_uk/tests/code_health.github/check_fix_pr.pyon this title and body, with the changes fromb4e872273to the headFix evidence: PASS, "Changed executable tests: 6"uvx ruff@0.17.2 format --check ./check ./check --select F811,F821 policyengine_ukgit diff --check 6a0d26d61..HEADgit merge-tree --write-tree --name-only HEAD origin/main(52b30809f)git merge-tree --write-tree --name-only HEAD af3758c64(#2779)docs/book/assumptions/growthfactors.mdonlyWe ran each mutant with Hypothesis shrinking off:
2f1051e9fHOLDINGS_SOURCEon all ofshare_like_capital2f1051e9f2f1051e9f6a0d26d61@examplefind −£0.009765625 with sale expenses6a0d26d61corporate_wealthstocks_and_shares_isadropped fromgov.dwp.share_like_capital.without_sale_expenses, run on the stored-totals node (a fixed case, no Hypothesis)ce91e92eaassert np.float64(5800.0) == 6000.0 ± 0.06, 2025Runs at earlier commits
6a0d26d616a0d26d616a0d26d612f1051e9f3a3241cf6(run 41225446226)2f1051e9f3a3241cf6for 400 households that don't itemise: each programme's assessable capital and award, UC eligibility and the UC company-holding variables in 2025, 2026 and 2027, and UC capital, eligibility and award in January 2026 (58 outputs, 27,616 values)2f1051e9ftest_isa_balances.py,test_wealth_components.py,test_isa_accounting.py,test_lifetime_isa_capital.py,test_uc_property_capital_mock.py,test_uc_company_override_properties.py,test_uc_company_owner_axiom_parity.pyce360946acode_health/test_ci_test_shards.py,test_stock_capital_periods.py6a0d26d61capital_valuation_share_split.yaml,cash_isa_capital.yaml,isa_balances.yaml,lifetime_isa_capital.yaml6a0d26d61ruff format --check,ruff check,--select F811,F821,git diff --check6a0d26d61ce360946adiffers from2f1051e9fonly inshard_durations.toml, and6a0d26d61adds the floor case totest_capital_share_components.py. CI at6a0d26d61passed every case in these files:test_capital_share_components.pytest_capital_valuation_properties.pytest_uc_property_capital.pytest_uc_company_owner_properties.pytest_uc_tax_free_childcare_choice.pytest_input_records.pytest_fiscal_partition.pyCI also passed the 70 cases in
capital_valuation.yaml,lifetime_isa_capital.yaml,capital_valuation_share_split.yaml,cash_isa_capital.yamlandisa_balances.yamlat6a0d26d61.axiom: TheAxiomFoundation/rulespec-uk#395 queued
We added the asset-type distinction and hand-computed companion cases to the issue (TheAxiomFoundation/rulespec-uk#395 (comment)).
🤖 Generated with Claude Code