diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index d860209f36..e1004258f9 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -34,6 +34,9 @@ defaults: # to a multiple of 5 minutes: 1.5 times that leg for engine-free (158 minutes) # and engine-us (106), twice it for engine-uk (67) and integration-uk (9), and # for each shorter job at least 5 minutes and at least twice its slowest run. +# The engine-uk-after-merge cap is about 1.6x its expected leg: microcosm#931's +# clone-first H2 test runs about 2.6 times as long as the H2 parity test (10 +# minutes in engine-uk), so about 27 minutes, plus the sync. # Every job names its runner image. `ubuntu-latest` is whichever image GitHub # assigns: on 2026-11-10 it gave one engine-free job ubuntu-26.04 and another @@ -143,6 +146,27 @@ jobs: - name: Run UK engine tests run: bash tools/run_engine_uk_tests.sh + engine-uk-after-merge: + # UK engine tests too slow for every pull request run on pushes to main + # only, after merge (microcosm#931). ci needs this job: on a push it must + # pass, and on a pull request its skip passes. + if: github.event_name == 'push' + runs-on: ubuntu-24.04 + timeout-minutes: 50 + strategy: + fail-fast: false + matrix: + python-version: ["3.13", "3.14"] + steps: + - uses: actions/checkout@v4 + - uses: astral-sh/setup-uv@v6 + with: + python-version: ${{ matrix.python-version }} + - name: Sync workspace with the UK engine + run: uv sync --all-packages --locked --extra uk + - name: Run UK after-merge engine tests + run: bash tools/run_engine_uk_tests.sh engine-uk-after-merge + integration-uk: needs: select-countries if: needs['select-countries'].outputs.run_uk == 'true' @@ -199,7 +223,8 @@ jobs: ci: # ci gives the main ruleset one check that covers the country jobs. It # fails unless every other job passed, or skipped because select-countries - # succeeded and reported `false` for its country. A skipped matrix job + # succeeded and reported `false` for its country, or skipped because it + # runs after merge and the run is not a push. A skipped matrix job # reports under its unexpanded name, so a ruleset cannot require engine-us # or engine-uk by name. GitHub reports a skipped required check as passing, # so ci runs with `if: always()`. verify-workflow refuses any other shape @@ -211,6 +236,7 @@ jobs: - engine-free - engine-us - engine-uk + - engine-uk-after-merge - integration-uk - wheels - installed-emitter diff --git a/.gitignore b/.gitignore index 44ce9ecc74..2182a90c35 100644 --- a/.gitignore +++ b/.gitignore @@ -10,6 +10,13 @@ out/ *.h5 # Licensed run outputs: pool tables and audit directories (UKDS CD137 cl. 8). *.npz +# Except the H2 parity fixture's three toy conditioned atomic-area supports, +# which tools/graph_uk_spine_fixture.py writes from test support's invented +# table over public area codes, as toy_.npz: a real support keeps +# its own name and stays ignored (microcosm#931). +!packages/microcosm-graph/tests/fixtures/parity/uk_spine/sources/toy_uk_ew_output_area_2021_conditioned_support.npz +!packages/microcosm-graph/tests/fixtures/parity/uk_spine/sources/toy_uk_scotland_output_area_2022_conditioned_support.npz +!packages/microcosm-graph/tests/fixtures/parity/uk_spine/sources/toy_uk_ni_data_zone_2021_conditioned_support.npz audit-*/ !packages/*/build/ # microcosm.build is a real namespace package, not a build-artifact dir @@ -27,3 +34,8 @@ tools/route_a/route_a.env # file holds licensed-data review values and is never committed PRIVATE_review.csv signoff-draft/ + +# Spine stage profiles (--stage-profile-dir, microcosm#931): a record keeps the +# message of a failure its node raised, so profiles stay private +stage_profile.json +.stage_profile.json.lock diff --git a/changelog.d/1095-uk-scottish-owner-council-tax-bands.changed.md b/changelog.d/1095-uk-scottish-owner-council-tax-bands.changed.md index 15f6be5d92..14b33087d1 100644 --- a/changelog.d/1095-uk-scottish-owner-council-tax-bands.changed.md +++ b/changelog.d/1095-uk-scottish-owner-council-tax-bands.changed.md @@ -1 +1,3 @@ The UK dense build's post-geography band node now draws each Scottish owner clone's council-tax band from its council area's chargeable dwellings by band, A to H, at September 2025 (Scottish Government CTAXBASE 2025), at the same uniform as its value, its rank among Scotland's owners (microcosm#1095 B12). The counts are vendored from Chronicle into `uk/scotgov_chargeable_dwellings_by_band.json` and pinned as the graph source `uk_scotgov_band_mix`, beside the VOA mix England and Wales draw from. Renters keep their band, as in England and Wales, and so does Northern Ireland. The band node's receipt reports Scotland apart. The national build does not localise property, so it does not change. + +(Later in #931 the band node retires, and the dense line keeps the spine's bands: `931-dense-localisation-nodes-retired`.) diff --git a/changelog.d/1112-national-home-values.added.md b/changelog.d/1112-national-home-values.added.md index 27e29fcee0..9393c1fcf8 100644 --- a/changelog.d/1112-national-home-values.added.md +++ b/changelog.d/1112-national-home-values.added.md @@ -1,4 +1,4 @@ -The national release now carries Land Registry home values (microcosm#1112). A new spine stage, `regional_home_values`, runs after the high-value home support copies and gives every England-and-Wales owner household with a value the one its region's uprated Land Registry distribution holds at the household's weighted mid-rank among the owner households of its FRS region, at the spine's weights. It ranks as the dense line's value node does (ties broken by a keyed draw; the support copies spread over the top stratum by their own draws), reads the region level of the same knots resource (`uk/high_value_home_value_knots.json`; Wales is `W92000004`), and moves `property_wealth` by the value's change. Scotland, Northern Ireland, renters and owners without a value keep theirs, and the council-tax band is untouched. +The national release now carries Land Registry home values (microcosm#1112). A new spine stage, `regional_home_values`, runs after the high-value home support copies and gives every England-and-Wales owner household with a value the one its region's uprated Land Registry distribution holds at the household's weighted mid-rank among the owner households of its FRS region, at the spine's weights. It ranks as the dense line's value node does (ties broken by a keyed draw; the support copies spread over the top stratum by their own draws), reads the region level of the same knots resource (`uk/high_value_home_value_knots.json`; Wales is `W92000004`), and moves `property_wealth` by the value's change. Scotland, Northern Ireland, renters and owners without a value keep theirs, and the council-tax band is untouched. (Later in #931 the stage retires: the WAS chain reads each England and Wales owner's main residence off its assigned constituency instead, `931-spine-localises-home-values`.) Before it, the national line solved the bound spine with the WAS-imputed values after the regional uprating, not the regions' Land Registry values. The dense line is unchanged: the stage keeps the value it replaced in `main_residence_value_rank_basis`, the dense value node receives that column through its slice and ranks on it (refusing if it is missing), and the release boundary drops it on both lines. diff --git a/changelog.d/1240-high-value-homes.added.md b/changelog.d/1240-high-value-homes.added.md index badbec1d4d..8d50c8feb1 100644 --- a/changelog.d/1240-high-value-homes.added.md +++ b/changelog.d/1240-high-value-homes.added.md @@ -4,6 +4,8 @@ The UK build now places high-value homes where HM Land Registry sees them (micro **Per-clone home values and bands in the dense graph.** Two nodes after geography derivation, `uk.full.property.value` and `uk.full.property.band` (`--property-localisation price_paid`, the default; `none` keeps the spine's values for measurement builds), read each owner clone's home value off its assigned constituency's uprated sale distribution (`uk/high_value_home_value_knots.json`, winsorised at £20m) at the household's weighted rank among its region's owners, and its council-tax band off its LSOA's VOA band mix (`uk/voa_council_tax_band_mix_lsoa.json`) at the same uniform (owner-occupiers only; renters keep the spine's band). The uniform is keyed on the spine household, so every pool clone of one household shares it whatever K is; weights are untouched and property wealth moves by the value's change. Scotland and Northern Ireland keep the spine's values and bands. The `uk_support` gate binds the two rewritten columns to the knots' cap through `uk/price_paid_property_support_bounds.json`. +(Later in #931 both nodes retire. The WAS chain reads each England and Wales owner's main residence off its constituency's knots: `931-spine-localises-home-values`. The dense line keeps the spine's bands: `931-dense-localisation-nodes-retired`.) + **A spine stage, `high_value_home_support`,** after `regional_property_uprating` copies every owner household in the top five per cent of its region's value rank six ways at equal weight, each copy carrying `high_value_support_copy_index`, the lineage the geography identity keys on; the value node gives each copy its own keyed rank inside the stratum, so the tail households spread across seats. Mass is conserved exactly (`uk_stage_high_value_home_support_mass`). **Valuation basis.** `uk/regional_land_values.json` moves from the December-2025 HPI level to the calendar-2024 average, so the stored `main_residence_value` sits at the dataset period's prices and the engine's annual uprating projects it once rather than twice. diff --git a/changelog.d/1262-uk-brma-from-area.added.md b/changelog.d/1262-uk-brma-from-area.added.md index 6da29f92fd..023d086238 100644 --- a/changelog.d/1262-uk-brma-from-area.added.md +++ b/changelog.d/1262-uk-brma-from-area.added.md @@ -1 +1 @@ -A placed household's Broad Rental Market Area now follows its assigned area (microcosm#1262, B1). `tools/build_uk_brma_area_layer.py` places every 2021 LSOA of England and Wales and every 2022 output area of Scotland in one BRMA from Chronicle's raw registrations (PolicyEngine/chronicle#314): England and Wales by population-weighted centroid in the VOA May 2020 and Rent Officers Wales May 2012 polygons with uk-data#516's six overrides, Scotland by centroid in the Scottish Government's polygons corrected by Rent Service Scotland's postcode lookup with microcosm#1092's two overrides. The layer, `uk/brma_area_layer.json` (192 BRMAs, OGL v3.0), reproduces the region-by-BRMA support of uk-data#516's census table and microcosm#1092's 63 Scottish BRMA-by-council pairs exactly; its provenance records both checks. The post-geography node `uk.full.geography.brma` (`--brma-localisation area`, the default on the atomic assignment; `none` for measurement builds, refused by a release candidate) reads each placed Great Britain clone's BRMA off its LSOA or output area, so its LHA rate describes the same place as its local authority and constituency. Northern Ireland and the national line keep the spine's `frs_brma` draw. A terminal release-blocking gate, `uk_local_brma_enum_domain`, rechecks the rewritten column against the engine's enum; the local gate battery has seven entries. The dense and full-battery contract digests, the declared gate count and the certification exclusions move with it, so a national or dense release certified before this change fails `validate_release` after it. +A placed household's Broad Rental Market Area now follows its assigned area (microcosm#1262, B1). `tools/build_uk_brma_area_layer.py` places every 2021 LSOA of England and Wales and every 2022 output area of Scotland in one BRMA from Chronicle's raw registrations (PolicyEngine/chronicle#314): England and Wales by population-weighted centroid in the VOA May 2020 and Rent Officers Wales May 2012 polygons with uk-data#516's six overrides, Scotland by centroid in the Scottish Government's polygons corrected by Rent Service Scotland's postcode lookup with microcosm#1092's two overrides. The layer, `uk/brma_area_layer.json` (192 BRMAs, OGL v3.0), reproduces the region-by-BRMA support of uk-data#516's census table and microcosm#1092's 63 Scottish BRMA-by-council pairs exactly; its provenance records both checks. The post-geography node `uk.full.geography.brma` (`--brma-localisation area`, the default on the atomic assignment; `none` for measurement builds, refused by a release candidate) reads each placed Great Britain clone's BRMA off its LSOA or output area, so its LHA rate describes the same place as its local authority and constituency. Northern Ireland and the national line keep the spine's `frs_brma` draw. A terminal release-blocking gate, `uk_local_brma_enum_domain`, rechecks the rewritten column against the engine's enum; the local gate battery has seven entries. (Later in #931 the dense line takes its BRMAs from the spine, `uk_local_brma_enum_domain` retires, the local battery has six entries, and `uk_brma_enum_domain` checks the column at the spine's transferred boundary: `931-spine-localises-home-values`.) The dense and full-battery contract digests, the declared gate count and the certification exclusions move with it, so a national or dense release certified before this change fails `validate_release` after it. diff --git a/changelog.d/1262-uk-private-rent-from-area.added.md b/changelog.d/1262-uk-private-rent-from-area.added.md index 26a7847a50..bf7983a02f 100644 --- a/changelog.d/1262-uk-private-rent-from-area.added.md +++ b/changelog.d/1262-uk-private-rent-from-area.added.md @@ -1 +1,3 @@ A placed private renter's rent now comes from its assigned area's list of rents (microcosm#1262, B2; María's rulings of 2026-10-15/16). `tools/build_uk_brma_rent_quantiles.py` writes `uk/brma_rent_quantiles.json`, 25 quantile knots of the weekly rent for every Great Britain BRMA and LHA category B to E: England from VOA's April 2026 shadow list (lets from October 2024 to September 2025), Wales from Rent Officers Wales' list for October 2023 to September 2024 (Table 2 of FOI ATISN 25142), Scotland from the Scottish Government's 2025 quartiles and median by BRMA and bedrooms with the shape of Rent Service Scotland's 2016 to 2021 lettings outside them (implied means within 7 per cent of the published ones). A cell with 20 to 49 lets takes its own median and its nation's pooled shape. The post-geography node `uk.full.private_rent` (`--private-rent-localisation brma_list`, the default with area BRMAs) keeps each Great Britain private renter's rank among its FRS region and bedroom category's FRS-channel renters, in both channels, and reads that quantile off its assigned BRMA's list; one scale per region holds the region's FRS mean rent on the census private-renter mix, so the lists set the pattern within a region and the spread within a BRMA but not the level. Placement follows all households, so at design weights a region's level moves by the gap between that mix and where renters land until calibration's tenure rows restore it; after calibration the national line, which keeps FRS rents, agrees on regional levels. Category A is never used; owners, social renters, zero rents and Northern Ireland are untouched; the boarder, lodger, subletting, service-charge and reported Housing Benefit columns stay as reported. `ons.rent.private_rent` stays bound. + +(Later in #931 the node retires: `931-dense-localisation-nodes-retired`. The spine's `private_rent` stage reads each Great Britain private rent off its BRMA's list, at its rank among the FRS private rents of its region and size: `931-spine-assigns-areas`. The national line, now built on a one-clone spine with areas, carries those rents: `931-national-one-clone-areas`.) diff --git a/changelog.d/1308-uk-new-stage-health-gates.added.md b/changelog.d/1308-uk-new-stage-health-gates.added.md index f8b03405fa..45e91b20b4 100644 --- a/changelog.d/1308-uk-new-stage-health-gates.added.md +++ b/changelog.d/1308-uk-new-stage-health-gates.added.md @@ -1 +1 @@ -The three stages #1308 left ungated have stage-health gates (María's ruling of 2026-10-17, taken up with the next policyengine-uk bump), each release-blocking and blocking on an absent receipt. `uk_stage_property_purchases_fit` holds each purchase kind to HMRC's Stamp Tax transactions within 5% and to its value less a recorded shortfall of at most one fifth, the floor the stage itself refuses below. `uk_stage_regional_home_values_ranking` requires rows re-ranked in every English region and Wales on the 2024 knots, at the weighted midpoint within each FRS region, with no source at the value cap. `uk_stage_uc_legacy_closure_take_up_contract` checks what the Move to UC receipt prints, since it withholds what a thin combination realizes: the design-weight Great Britain basis, a probability and a declared source for every combination's rate, a printed support band, and a well-formed unreachable flag. The property purchases and regional home-values gates check the frame against published facts, so a synthetic smoke build records their failures without blocking on them (`population_fact_check`), as it does for the other fact gates; the legacy closure gate blocks every posture. The mirrored battery digests move. +The three stages #1308 left ungated have stage-health gates (María's ruling of 2026-10-17, taken up with the next policyengine-uk bump), each release-blocking and blocking on an absent receipt. `uk_stage_property_purchases_fit` holds each purchase kind to HMRC's Stamp Tax transactions within 5% and to its value less a recorded shortfall of at most one fifth, the floor the stage itself refuses below. `uk_stage_regional_home_values_ranking` requires rows re-ranked in every English region and Wales on the 2024 knots, at the weighted midpoint within each FRS region, with no source at the value cap. (Later in #931 it becomes `uk_stage_area_home_values_ranking`, on the WAS stage's area home values at the constituency level, with its maximum re-derived for the constituency knots: `931-spine-localises-home-values`.) `uk_stage_uc_legacy_closure_take_up_contract` checks what the Move to UC receipt prints, since it withholds what a thin combination realizes: the design-weight Great Britain basis, a probability and a declared source for every combination's rate, a printed support band, and a well-formed unreachable flag. The property purchases and regional home-values gates check the frame against published facts, so a synthetic smoke build records their failures without blocking on them (`population_fact_check`), as it does for the other fact gates; the legacy closure gate blocks every posture. The mirrored battery digests move. diff --git a/changelog.d/1418-uk-rfdr-area-flag.added.md b/changelog.d/1418-uk-rfdr-area-flag.added.md index 05acbcd148..a7491dbe4e 100644 --- a/changelog.d/1418-uk-rfdr-area-flag.added.md +++ b/changelog.d/1418-uk-rfdr-area-flag.added.md @@ -1 +1,3 @@ The dense build now sets policyengine-uk's `in_rural_fuel_duty_relief_area` on each placed household from its assigned output area, so the Rural Fuel Duty Relief prices its petrol and diesel at the relieved rate (#1418). HMRC Notice 2001 opens the relief in the Inner and Outer Hebrides, the Northern Isles, the Islands in the Clyde, the Isles of Scilly, the post town of Hawes and sixteen mainland postcode districts. It names the island groups without bounding them, so `tools/build_uk_rfdr_area_layer.py` declares Microcosm's translation into postcode districts, unit postcodes and excluded units, with sources. It then reads the ONS postcode lookup and writes `uk/rfdr_area_layer.json`, the 2021 output areas of England and Wales and 2022 output areas of Scotland more than half of whose postcodes lie in the scheme. That is 41 in England and 1,053 in Scotland, from 7,104 postcodes of the August 2026 lookup. Islands that share a sector with the mainland (Raasay, Seil, Easdale, Luing, Kerrera and Lismore) and the post town of Hawes are listed by unit postcode. The post-geography node `uk.full.geography.rfdr` (`--rfdr-localisation area`, the default with the atomic assignment; `none`, the default with the legacy assignment, is for measurement builds and refused by a release candidate) reads it. Northern Ireland has no area in the scheme. The national line, which has no areas, leaves the engine's default of false (María's ruling of 2026-10-28). The node refuses a Great Britain output-area code that is not well-formed for its system. On a full-scale build it also refuses a system (England and Wales, or Scotland) with households none of which is flagged, so a change of code format or vintage cannot publish its households unflagged; a sampled rung may place none of the 41 English areas, so it checks the codes only. The committed layer is built from the NSPL zip Chronicle registers. The tool pins the registration's package id, file and sha256, and `--check` rebuilds the layer in memory and compares it with the committed files. A test holds the provenance to the high value home stock's own record of the zip. + +(Later in #931 the node retires: `931-dense-localisation-nodes-retired`. The spine's `rfdr` stage sets the flag from each clone's drawn area: `931-spine-assigns-areas`. The national line, now built on a one-clone spine with areas, carries it: `931-national-one-clone-areas`.) diff --git a/changelog.d/931-atomic-assignment-tool-on-the-spine.changed.md b/changelog.d/931-atomic-assignment-tool-on-the-spine.changed.md new file mode 100644 index 0000000000..cc3428c740 --- /dev/null +++ b/changelog.d/931-atomic-assignment-tool-on-the-spine.changed.md @@ -0,0 +1,23 @@ +`tools/measure_uk_atomic_assignment.py` measures the clone-first spine's own area draw (#931): G2, the draw of the spine's `atomic_area_assign` stage (`spine_geography`), on a bound spine checkpoint, in process, with no engine and no graph. Since the dense line stopped drawing areas earlier in #931, the tool refused; it now measures in process, and its graph route and the readers of the retired dense nodes' manifests go. It records the assignment-only receipt the arms read and the Northern Ireland district check of decision 9. No build runs it, and its outputs stay with the run. + +- **What it reads.** `--input-h5` is a spine checkpoint, hashed (and held to `--input-sha256` where one is given), loaded and authenticated by `calibration_run.load_bound_spine_checkpoint` against its build sidecar and spine gate report (`--input-sidecar` and `--input-spine-gates`, the H5's `.build.json` and `.spine_gates.json` by default), as the dense and national lines bind a spine. The tool keeps its base rows: the households on no copy branch (geographic clone 0), read through the shared copy-path reader on the UK copy lineage, with each one's true source, region, IMD decile, council-tax band and band flag. A household's weight is its mass in its areas: the spine's household weights as the checkpoint holds them (importance weights, once the SPI support channel has moved part of each stratum's mass onto its copies), summed over every row that keeps its areas, its geographic clones and the copies later stages make of them; SPI-channel rows (`atomic_area_conditioning.uk_support_channel_copies`), which draw areas of their own, are left out. It refuses, naming columns only, a table without those inputs, the source columns or the clone index, a source with two base rows, geographic clones that disagree on an input and more than one source year. `--supports-dir` holds the three conditioned supports, `.npz` each as `tools/build_uk_conditioned_area_supports.py` writes them; each must be the conditioned register's bytes and the support it extends the register's (`country_adapter.uk_atomic_support_register`), unless `--no-pin-supports` (synthetic supports only). Supports that place a constituency or local authority in two regions are refused. +- **How it draws.** For each clone count in `--n-clones` (default `1,15`), the base rows go through the spine's geographic expansion (`expand_uk_geographic_clones`, G1) and geography identity (`key_uk_households_by_clone_path`, G1b) on a frame of the base households alone, so every clone draws on the key the spine gives it; each clone carries 1/K of its household's weight. Two laws (`--laws`, both by default) replace `legacy` and `keyed`: + - `region_only`, today's v1 definition (`atomic_area_support.uk_atomic_assignment_definition`, by census households within the FRS region) at `--region-only-seed` (the dense role's seed, 42, by default), over the registered supports the conditioned ones extend, drawn, derived and validated by the shared operator on the key and the region, as the dense line drew it; + - `conditioned`, G2's own draw (`spine_geography.draw_uk_spine_areas` with `uk_conditioned_assignment_definition` at the spine's seed, 0), its fallback levels included. + Each resolves the engine's local authority as the spine's local-authority stage does (`uk_local_authorities`). +- **What it records**, per cell {law} x {K}, at the spine's weights with no solve: + - expected rows per constituency and local authority, and their variance, read off the definition the law's draw runs (`expected_area_support`): each row draws an area among its support's rows that match every constraint input it carries, its region and, where its level keeps one, its decile, in proportion to the weight column its stage gives it, its band's where its level keeps the band and the declared default otherwise, each on its own key. Under the region-only law this is the old single-stage expectation, now on the supports' census households: the region's rows times the area's census household share within it; + - realized rows, Kish ESS and distinct source households on the supports' roster of areas, the 50-floor breach tables, z-scores against each law's own spread (the sum of p(1 - p)), the ladder gate's verdict and London's weighted household share; + - Northern Ireland's local government districts: each one's census household share beside its expected rows, rows, sources, z-score and weighted share, with the largest published |z| and share gap; + - identity stability: the same draw on reversed rows and on the clone-0 subset, unique keys and, where the checkpoint carries G2's columns, whether the spine drew the same areas; whether every clone's area at each lower K stays at the highest; and, for the conditioned law, the source households at each fallback level, rounded; + - the spine's file, digest, K, rounded source households and sampling rung (fraction, seed and rung token, never its household counts), the supports' and definitions' digests and the definitions' streams. +- **Disclosure.** The evidence and the receipt carry no unit record, say `"publishable": false`, and the tool refuses an output path inside a checkout (`receipt_counts.outside_work_trees`) before it reads any input. Neither is published or quoted: an area's rows, and the region-only law's expected rows, sum to each region's exact base households times K, so the rounded source counts protect only the receipt and the terminal. The evidence declares `disclosure_rule: 2`: + - an area's rows, ESS and sources read " 1 the quotient is snapped to the nearest integer when it is within K ulps of it, so a weight that is an exact multiple of 60 keeps its count at any K; at K = 7 the rounding of the clone weight would otherwise add a copy for some exact multiples. The snap gives up the converse case: a quotient within K ulps above an integer counts one copy fewer than at K = 1. At K = 1 nothing is snapped, and the count is `ceil(w / 60)` bit for bit, as before. + +- **Receipt and gate.** The stage receipt's parameters gain `clone_count`, and nothing else is new. The stage-health gate compares K times the heaviest copy, and K times the heaviest selected household, with the maximum copy weight, so a receipt at K > 1 no longer fails falsely. At K = 1 both checks and their messages are unchanged. A receipt without a positive integer `clone_count` is refused. The identity tool's recompute (`tools/verify_uk_identity_stability.py`) reads K from the pre-split table, as the stage reads it from its input, and its receipt keys are unchanged. Folding a family's copies back re-sums them, which can land ulps from the family's weight: for a weight a few ulps above a multiple of 60 (at K > 1, by more than the snap absorbs), or where an exact-total correction or the #970 anchor's and the residential arms' roundings moved a member. So neither the count check nor the family test recounts the fold. At any K, a family of more than three members is held exactly where at least four of its members show their two clone halves at equal weights and every member that does shares one pair sum c, whatever the others carry: its stored count n must be the count of a weight w with fl(w / n) = c. A member that took the split's own fallback correction keeps equal halves at another weight, since the incidence clone halves it exactly, so its family keeps the bracket. The split's own exact-total correction, the incidence clone's and the residential split's each move one row, so one of those four or more is uncorrected, and equal halves mean the anchor and the arms left its pair sum at exactly w / n, so c is exactly w / n. The stage counts n on each clone's own weight and gives every member fl(w / n), and the snapped count still rises with w, so this holds at K > 1 as at K = 1. Where every member shares c but fewer than four show equal halves, the hold reaches one float either side of c, the most the anchor's and the arms' roundings move an uncorrected member where the floats either side of c are as wide, and two floats where c sits within two floats of a power of two, below which they are half as wide; c lies in (45 / K, 60 / K] to within the snap, which can leave it a few floats above 60 / K (at most 16 for K up to 15, by design arithmetic over weights at and up to 40 floats above each multiple m × 60 / K, m from 4 to 3,999), and that range holds 16 at K = 3, 8 at K = 6 and 7, and 4 at K = 12 to 15. Every other family keeps the bracket: the stored count must lie between the counts at the folded weight times 1 − 1e-9 and 1 + 1e-9. The family test, which decides whether a household is a family at all, is held the same way at the K-aware count: a household the rule selects is possibly a family where its count at the folded weight times 1 + 1e-9 exceeds one and possibly whole where its count at the folded weight times 1 − 1e-9 is one, its stored state accepted in between, and the hold's counts decide where it applies. That bracket opens for a household whose source-scaled weight K × w lies within a relative 1e-9 of a multiple of 60 (at K = 1, its own weight), where it accepts n or n + 1 copies, a whole household or a family of two among them. A stored count moved there on its own is still reported, by the flag and family-weight checks, but a household the stage split consistently into one copy more there, every member at w / (n + 1), is not. Where the hold applies, that blind spot narrows from 4.5 to 9 million floats of w on each side of a multiple to a few floats next to the count's step, for some counts n. At K = 1 the step sits a float above the multiple, which leaves at most the multiple itself where the family is held exactly, or the multiple and the float either side of it where the hold reaches one float. At K from 2 to 15 the snap puts the step 3 to 17 floats above the multiple of 60 / K, which leaves at most the float on either side of the step where the family is held exactly, or up to three floats from it in the one-float tier, so a family on the multiple itself split into one copy more is reported. The receipt's `copies_recomputed` stays the exact recount from the re-summed fold, and its tolerance policy says all this. +- **Declarations.** The `copy_rule` text in the code dictionary, `sources.yaml` and `source_stages.json` now reads "copies = ceil(geographic clone count x household weight / maximum_copy_weight), the quotient snapped to the nearest integer within clone-count ulps when the clone count exceeds one; every copy carries weight / copies, except where none of the 64 heaviest households left whole, tried heaviest first, tied weights in row order, can carry the exact-total correction, when the shared fallback can put it on a root or copy, off weight / copies by about one ulp of the total weight; of those 64, a selected household left at one copy can carry the correction only where its corrected weight keeps its one copy and the walk's selection, a check the fallback does not make". The high-value home support split's (`high_value_home_support`) reads "every selected household becomes copies rows at weight / copies", followed by the same exception and no more, since it makes no one-copy check. Both stages' notes say where the correction lands, and the CGT stage's add that the shared fallback does not make the one-copy check, so it can put the correction on a one-copy household the check passed over, and that the identity tool's selection recompute can then count that household as a family the stage never made, which the bracketed family test does not report, or miss one it made, which the tool reports. Such a household, lifted across 60 / K, moves only `copies_recomputed`, since the bracketed family test cannot tell it from a whole household (see Receipt and gate). The CGT stage notes give the cap as 60 divided by the geographic clone count before the incidence clone, and name the incidence clone stage (`cgt_incidence_clone`) where they mean it. +- **Exact total.** The exact-total correction lands on a household the split left whole: a positive-weight household it did not divide, unselected or selected at one copy, whose weight the split left as it was. The stage tries the 64 heaviest of them (`CGT_SUPPORT_CORRECTION_CANDIDATES`), heaviest first with tied weights in row order, and the first that can carry the correction takes it, so every root and copy weighs bitwise w / n. A selected household left at one copy can carry it only where its corrected weight keeps its one copy and the walk's selection, the one-copy check `copy_rule` names, kept as a reading of the whole-households-first rule, so wherever one of the 64 carries it, the rule rerun on the stage's output, as the identity tool reruns it, divides the same households; on the synthetic probe frames, 11 corrections would otherwise have lifted a one-copy household to a weight that counts two copies, and the rule rerun on the stage's output would have counted a family the stage never made. Only where none of them can does spi_support's shared fallback place it, unchanged, and that row can be a root or a copy, then off w / n by about one ulp of the frame's total weight: thousands of ulps of its own weight, a relative error below 1e-12 on the synthetic frames. The fallback does not consult that check, so its row can also be a whole household, among them a one-copy household the check passed over; the rerun can then divide a different set. That can happen on synthetic frames, as it could under the rule before, with the weights the rule before gave: where the one-copy household sits one to three ulps below its band's support mass, the identity tool then reports a missing family, and where it weighs 60 at K = 1 and outweighs every copy, the rule rerun counts a family the stage never made, which the tool's family test, held to its bracket, does not report, since the corrected weight lies within a relative 1e-9 of 60. On the synthetic nesting scenario at K = 7 and 13 every whole household sits in the half of NumPy's pairwise sum whose other half carries exactly half an ulp of the total, so no change to its weight rounds the total onto the target, and the fallback still puts the correction on a copy. Before, the stage tried only the heaviest unselected household. That is still the first candidate unless a selected household left at one copy outweighs it, or ties it from an earlier row, which needs every unselected household to weigh at most 60 / K (to within the K-ulp snap at K > 1). The high-value home support split (`high_value_home_support`) corrects through the same helper and cap. Every household it selects becomes six rows, so its whole households are its unselected positive ones, and its first candidate is always the household it corrected before. The cap bounds the cost where no whole household can carry the correction: on a synthetic vector the size of a spine of fifteen clones, 64 such households and the fallback take about 0.4 s, against 0.02 s for the one candidate before. A selected household left at one copy that can carry it also costs a rerun of the selection walk, about 0.41 s at that size, so 64 that the check passes over would take about 26 s; a national frame does not reach that, since its 64 heaviest whole households are unselected ones, far heavier than 60 / K. +- **What moves.** The copy count moves no value at K = 1. Neither does the exact-total rule wherever the heaviest unselected household is still the first candidate and can carry the correction. Where it cannot and a later one of the 64 can, at `cgt_support_split` and `high_value_home_support` and at any K, a rounding-sized correction moves from the row the shared fallback picked, often a root or copy, to a whole household, so those two rows' weights move by rounding amounts and later stages can move with them; where none of the 64 can, nothing moves. At `cgt_support_split`, and at K = 1 too, a selected household left at one copy that outweighs the heaviest unselected household, or ties it from an earlier row, comes first, which needs every unselected household to be as light; where it can carry the correction and keep the split, it takes it even where the heaviest unselected household could have, so those two rows' weights move by rounding amounts. On the synthetic frames the copy count left the stage's output unchanged: ids, copy counts, weights bit for bit, mass records and frame content identity. The identity tool's receipt keys are unchanged, and its tolerance policy names the hold, the count bracket and the bracketed family test. Against the exact recount it replaces, it no longer reports a count problem for a family whose re-summed fold lands across a multiple of 60 from its stored count, nor a family missing, or extra, where a household's re-summed fold lands across the one-copy boundary (60 / K) from its stored state: on the synthetic frames, the one false missing family the full-chain probes found, a two-copy family a float above 60 that folds onto 60, and one false extra family at K = 2. It still reports a family of more than three members that the stage split consistently into one copy more on a multiple, as that recount did, where at least four of its members show equal halves and every member that does shares one weight, whatever the others carry: at K = 1 for all but 31 of the 9,995 counts n from 4 to 9,998, and at K from 2 to 15 for every count. Where fewer show equal halves but every member shares one weight, the hold reaches one float, which at K = 1 takes in the multiple itself for 6,393 of those counts, so such a family goes unreported there, as the full-chain test's 900 family does at one clone; at K > 1 it is reported. It no longer reports a family of three or fewer members, or one whose members fold to different weights without four equal halves among them, nor a household split into two copies at 60 / K, which the family test's bracket cannot tell from a whole one. The stage evidence gains `clone_count`. The stage contracts of `cgt_support_split` and `high_value_home_support` move with their texts. Their implementation hashes move, `high_value_home_support`'s because it binds `cgt_support`, and node keys chain on their inputs' keys, so every spine node from `high_value_home_support` on, and every node downstream of the spine, re-keys with them. The spine gates hash `stage_health`, which moved. Every node keyed on the UK country spec's or solve's fingerprint moves too, since the coverage manifest, `sources.yaml` and `source_stages.json` moved: the spine gate; the full, preflight and holdout gates; and the target compilation, target selection, problem, measures, national targets, national problem and national gate kernels. With the spine gate, every spine stage after the assembled gate moves. The coverage manifest's source digests and the H2 fixture's declarations and contract hashes are regenerated. diff --git a/changelog.d/931-cgt-keyed-offsets.changed.md b/changelog.d/931-cgt-keyed-offsets.changed.md new file mode 100644 index 0000000000..f3bcb6e484 --- /dev/null +++ b/changelog.d/931-cgt-keyed-offsets.changed.md @@ -0,0 +1,12 @@ +The CGT gains redraw (`hmrc_cgt_gains_spine`) and the BADR claims in the asset-type stage (`hmrc_cgt_asset_type_spine`) key each systematic walk's offset, and each plan's quantile jitter, on its own label instead of taking the next draw of one Generator (#931; María's ruling 6 of 7 Nov). The redraw built one Generator from its seed (552) and the build period and handed it to every Table 3 cell walk, every income band's pooled walk and every (gain band, income band) plan in run order, so the n-th uniform belonged to whichever walk or plan ran n-th: a cell that gained or lost its gainers, or skipped on its carried target, moved the uniform of every walk and plan after it. Each is now an identity-keyed uniform under the declared seed, read once: + +- a cell walk is keyed `cell:::` and an income band's pooled walk `pool:`, both salted `hmrc_cgt_gains_spine:offset:`; +- a plan is keyed `plan::`, salted `hmrc_cgt_gains_spine:jitter:`; +- a BADR band is keyed on its bounds, `|` (`open` for the top band), salted `assign_badr_qualifying_gains:offset:`, under the BADR seed (555). The band offsets never depended on rows, but each was its band's position in one draw of every band's offset, so a facts revision that added a band moved the offset of every band after it. + +Bands and age groups are named by their lower bounds, region groups by their labels. The period moved from the Generator's seed into each salt, so the declarations still read "seed combined with the build period". + +- **Shared scalar.** `microcosm.build.stochastic_assignment.stable_identity_uniform(key, *, seed, salt)` returns the draw `stable_identity_uniforms([key], ...)` gives for one label, and refuses a sequence. The duck-typed `random()` adapter the walks read (`_KeyedOffset`) moved from `isa_subscriptions` into `cgt_imputation`, beside `_walk_bands`; the ISA subscriptions take the adapter from `cgt_imputation` and the scalar from `stochastic_assignment`, and their walk offsets and band jitters are the uniforms they were, bit for bit. `property_components`' one receipts-walk offset stays as it is (ruling 6). +- **Declarations.** The redraw's `seed_mixing` and the BADR `realization` texts say the above, and the sub-AEA remainder's `mapping` text no longer names a walk and plan draw order, since there is none. Each is identical in the code dictionary, `sources.yaml` and `source_stages.json`. `hmrc_cgt_gains_spine` and `hmrc_cgt_asset_type_spine` now compute through `stochastic_assignment`, so both bind it, as the derived binding rule requires. +- **No nesting promised.** The offsets and jitters are the same at every geographic clone count, and whichever other cells walk or skip. The walks themselves stay pooled: the rounding carry runs through an income band's cells, the pooled walk takes the band's net shortfall over its unassigned gainers, each plan stratifies members pooled from every cell, and each BADR band walks its whole pool. A change in one cell can still move the assignments and amounts of the other cells in its income band, and a plan's amounts whenever its members change. Through the rake it can move cells in other income bands too: the rake seeds every cell from the frame's own (age group, region group | income band) gainer shares and fits the seed to the joint and to the Table 6 age and Table 5 region margins, which span every income band, so a change in one cell's gainers moves the raked targets of cells in other income bands, and with them possibly those cells' assignments and amounts. On a synthetic frame, adding one cell in the lowest income band moved all 20 positive raked targets of a two-cell higher band, by up to 0.8 per cent. +- **What moves.** Every Table 3 walk's offset and every plan's jitter changes, so band membership near each walk boundary and the within-band quantiles move. On three synthetic frames, 9 of 1,002, 9 of 3,000 and 126 of 1,512 gainers changed gain band, and 338, 2,920 and 1,300 changed amount; no non-gainer moved. On the third, 70 of the 1,512 gainers crossed the annual exempt amount, between a Table 3 plan and the sub-AEA remainder (none on the other two), so the liable set moves, and with it the households `cgt_residential_split` splits into arms and the row count from there. Every BADR band's offset changes, so each band's walk selects its claimants at new positions. On three synthetic frames of equal weights no claimant row of the old walk claims in the new one, while each frame's claimant count moved by one or two; the main asset types moved with the claims. ISA amounts do not move: on three synthetic frames every ISA output column is unchanged. The stage contracts of both stages, the H2 fixture's declarations and the 22 values of its synthetic asset-type facts (which the fixture tool sizes to the frame after the redraw), the coverage manifest's 25 source digests and `source_stages.json` are regenerated. Every spine node re-keys, since `graph_kernels` and `stochastic_assignment` changed and the spine's root binds `stochastic_assignment`, and on a bound spine the national line re-keys 5 of its 6 nodes, all but the bound checkpoint, since the national target, problem and gate kernels hash the country spec, which this change edits; values move from `hmrc_cgt_gains_spine` on, and `isa_subscriptions` re-keys through its `cgt_imputation` binding and its own module with no change in its output. diff --git a/changelog.d/931-council-tax-band-d.added.md b/changelog.d/931-council-tax-band-d.added.md new file mode 100644 index 0000000000..e893130235 --- /dev/null +++ b/changelog.d/931-council-tax-band-d.added.md @@ -0,0 +1,19 @@ +2024-25 Band D council tax for every Great Britain local authority, and the statutory band formula, in `microcosm.build.uk_runtime.council_tax_band_d` (#931). No stage reads them yet; council-tax localisation will. + +- **England and Wales.** `uk/council_tax_band_d_england_wales_2024_25.json`, built by the new `tools/build_uk_council_tax_band_d.py` from two raw-only Chronicle registrations (chronicle#413). Each file is held to the sha256, size and manifest its registration records at the Chronicle commit the UK feed pins. + - England: MHCLG's 2024-25 Table 8 (area council tax for a Band D dwelling occupied by two adults), read with the standard-library ODS reader `ods_tables.read_ods_tables`. Each amount must lie within 1e-9 of a whole number of pence and is kept as that pence. + - Wales: StatsWales' composition of average band D council tax (the 2024-25 total for each billing authority area), read with `csv` and kept as published. Each authority is joined to its April 2023 code by its exact name on `local_authority_names.json`, and the all-Wales row is a declared exclusion. + - The codes read must be exactly the roster's English and Welsh codes. `--built-on` is explicit, and `--check` rebuilds the resource and compares it with the committed one, `built_on` aside. +- **Scotland.** `uk/scotgov_band_d_council_tax_2024_25.json`, vendored by `tools/vendor_uk_ledger_facts.py` from the pinned feed: CTAS 2026's 2024-25 average Band D for the 32 council areas (`scotgov.ctas2026.band_d.fy2024`; the `local_authority` level leaves out the Scotland row). Its register entry in `ledger_fact_vendor_selections.json` names `uk_runtime.council_tax_band_d` as its consumer and carries the OGL v3.0 attribution. +- **The loader.** `load_uk_council_tax_band_d()` merges the two over the roster's Great Britain codes as exact rationals, each read as a `Fraction` through `Decimal`. Scottish rows are read through `vendored_rows`, so a copy taken from another feed is refused before any row is read, and each Scottish amount is kept as the pence it lies within 1e-9 of. + - It refuses a Northern Ireland code, a code off the roster or of a nation the resource does not cover, a missing or repeated authority, a value that is not a positive finite decimal, and an English value written with more than two decimal places, since England's amounts are at pence. + - It also refuses a wrong schema version, kind, resource, fiscal year or roster vintage, and a Scottish row of another record set, concept, unit, period, level or vintage. + - Refusals name codes, fields and record ids, never an amount. Test payloads replace the packaged resources as in `load_hmrc_isa_statistics`. + - `check_scotland_band_d_declaration` is the runtime arm of the `verify_vendored_fact_resource` operation a stage will declare for the Scottish resource. +- **The statute.** `UK_COUNCIL_TAX_BAND_RATIOS` gives each nation's band proportions to Band D as exact fractions: England and Wales 6, 7, 8, 9, 11, 13, 15 and 18 ninths for A to H, and Wales 21 ninths for I; Scotland 240, 280, 320, 360, 473, 585, 705 and 882 over 360 for A to H, in force from 2017-18. `UK_COUNCIL_TAX_SINGLE_ADULT_DISCOUNT` is a quarter, and `uk_statutory_council_tax(band_d, nation, band, *, single_adult)` returns the exact bill and refuses Northern Ireland, a band the nation does not use and a float Band D. Nations and band sets are read from `council_tax_constants`, which is unchanged. +- **Shared with the tool.** The tool takes the England-and-Wales resource's name, kind, schema version, method, fiscal year, pence tolerance and its amount checks (`band_d_pence`, `band_d_decimal`) from the runtime module, so the two cannot drift. +- **Keys.** The two packaged resources, the register entry and `country_package.json` move the UK country fingerprint and the solve fingerprint. The kernels that hash them (the spine gates, and the full line's target compilation and selection, measures, problem, preflight, gates, holdout and national nodes) move, and the nodes after them re-key. No stage declares the new resources, so no stage contract moves; no H2 file or value moves, and no other country's key moves. +- **Tests.** + - `tests/engine_free/uk/test_uk_council_tax_band_d.py`: the committed resources load over exactly the roster's Great Britain codes; England and Scotland are at pence and Wales has at most six decimals and is not rounded to pence; the England-and-Wales `sources` equal the tool's pins; the Scottish resource carries the feed pin. It also covers the loader's refusals on invented amounts, the runtime arm, and every band of every nation under the statute, which restates the proportions so a typo or Scotland's pre-2017 proportions fail. + - `tests/engine_free/uk/test_uk_council_tax_band_d_tool.py`: the tool on synthetic inputs, and its `--check` on the committed resource when the registrations are mounted. + - `tests/engine/uk/test_uk_council_tax_band_d_engine.py`: the proportions equal policyengine-uk's at 2024 within 1e-9 and the single-adult discount exactly, and every Great Britain code's engine key, and no Northern Ireland one, is a key of the engine's Band D amounts. diff --git a/changelog.d/931-council-tax-localisation-code.added.md b/changelog.d/931-council-tax-localisation-code.added.md new file mode 100644 index 0000000000..da35a7947f --- /dev/null +++ b/changelog.d/931-council-tax-localisation-code.added.md @@ -0,0 +1,21 @@ +Council-tax localisation for the clone-first spine, G6, in `microcosm.build.uk_runtime.spine_council_tax` (#931), unwired: no source manifest declares its stage, `council_tax_localise`, and nothing imports the module, so no key or value moves. Later in #931 group (d), the stage is declared between `private_rent` and `was_wealth`. + +- **The kept bill.** Before it rewrites anything, the stage writes `council_tax_frs_bill`, `max(council_tax - council_tax_rebate, 0)` on every row, float64 and nonnegative, by the expression `was_wealth.recipient_predictors` computes its council-tax predictor with. +- **The reference.** `uk_council_tax_references` recomputes each household's draw cell from the inputs the area draw (`atomic_area_assign`) read, with the area draw's definition built at seed 0 over the three conditioned supports (`uk_draw_inputs`, `uk_draw_levels`, `uk_draw_frame`). A Great Britain household's reference is the exact expected 2024-25 Band D of that cell under the draw's own weights, from `atomic_area_conditioning.uk_draw_cell_expectations`, which runs the shared `draw_cell_expectations` with each system's own arguments and which the housing shell's reference calls too. Its ratio is its own authority's Band D over that reference: one correctly rounded division of the two exact rationals. The rows the SPI support channel copied, SPI copies and income band donors, have their decile missing by rule and the band the housing shell drew, so their cell is their region by the households of that band where the region holds it (L2), else by households (L3), the cell the SPI-copy area stage drew them from (María's ruling of 25 Nov). +- **The draw-cell guard.** Each Great Britain row's drawn `atomic_area_code` must be an area of its recomputed cell with mass in the weight it samples by, and its `atomic_area_system` and `local_authority_code` must be that area's. +- **The paths**, by nation first and channel second. + - Northern Ireland's rows keep their bill, rebate and reduction bit for bit, with no cap. + - Great Britain's SPI-channel rows take the ratio, whatever bill provenance they inherit. + - Great Britain's FRS-channel rows follow `frs_council_tax`'s `council_tax_bill_provenance`. `observed_gross` takes the ratio. `missing` and `unknown_reduction` take the 2024-25 statute where `council_tax_band_observed` holds (`uk_statutory_council_tax` at the household's authority, nation and band, less the single-adult discount where `council_tax_single_adult_raw` is 1), and the ratio on `frs_council_tax`'s bill where it does not. `not_levied` is refused there. +- **Reductions.** On every Great Britain row, the rebate and the household's positive `council_tax_benefit_reported` move with the bill and are capped at it: `min(ratio x amount, new bill)` on a ratio path, and on a statute row whose old bill is positive `min(amount x new bill / old bill, new bill)`, one rounding of exact rationals, so a household whose reduction met its old bill pays nothing at the statute bill (Vahid's review of 16 Nov, item 7). A statute row whose old bill is zero takes the ratio. The rebate equals the reduction after the stage wherever it did before. +- **Checks and refusals.** After writing, the stage asserts, through the shared `amounts_within_bound` at tolerance 0, that Great Britain's reductions and rebates lie within their bills, finite and nonnegative. It also asserts that the rebate still equals the reduction wherever it did, and that Northern Ireland is unchanged. Its refusals name columns, dtypes and declared constants only. It refuses: + - a missing column, or a bill, rebate or reduction that is not float64, finite and nonnegative; + - more than one positive reduction in a household, or a person whose household is absent; + - a provenance outside `frs_council_tax`'s four values, `not_levied` in Great Britain, or another value on a Northern Ireland FRS-channel row; + - an authority without a 2024-25 Band D, on a row or in a row's cell, or a statute band its nation does not price; + - the guard, a frame that already carries the kept bill, and a frame period other than 2024. +- **The transform.** `UKCouncilTaxLocaliseStageTransform(stage, supports, band_d=None)` holds its stage to the reviewed declaration `council_tax_localise_operation_parameters()` states. That declaration has four operations, in order: `verify_vendored_fact_resource` for the Scottish Band D, `derive` for the kept bill, `localise_council_tax` and `record_mass_conservation_receipt`. The stage must also declare its two Band D artifacts with `runtime_sha256_required`, the kept bill as its one output and the three rewrites. The transform loads the committed Band D unless a test supplies one. Running it runs the Scottish resource's runtime arm with the frame's period, localises, and appends the stage's household mass record. +- **Evidence.** It starts with `stage`. Then come the method, the clone count, the Band D and support digests and distinct true source households by path: FRS-channel rows over every clone through `rounded_count`, support-channel rows in geographic clone 0. The households whose reductions were capped, on a ratio or a statute path, and the Northern Ireland households whose reductions exceed their bill are counted in clone 0 through `extreme_count`. The five checks follow as booleans, whether Northern Ireland's reductions lie within their bills read in clone 0 as their count is, then the outputs and the rewrites. Every field but `clone_count` is the same at every clone count, and no ratio, bill, authority, cell or level is printed. +- **Tests**, on invented households and an invented Band D. + - `test_support/microcosm_build/uk_council_tax_fixtures.py`: invented council-tax cases on the toy conditioned supports, covering every path, one statute row in a cell of two authorities among them. The spine's own steps clone, key and place them. The support channel's stand-in copies them, and the copies are re-keyed and re-placed at L2 or L3 by their band, as the SPI-copy area stage does it. Each toy authority has a Band D in thirds of a pound. A sweep holds one household for each Great Britain draw cell of the toys. + - `tests/engine_free/uk/test_uk_spine_council_tax.py`, at K = 1 and 3. Each level is the area draw's, and every SPI copy and band donor is at L2 or L3 by its drawn band. Each reference equals the cell's expected Band D worked again from the supports, and the ratio averages exactly one over every Great Britain cell of the toys. Ratio rows' bill, rebate and reduction are their ratio times the input, bit for bit. Statute rows follow each nation's proportions at their own authority's Band D, restated in the test, with the discount, and their rebate and reduction move by the bill's own change, in a cell of two authorities too; a statute row whose reduction met its old bill meets the statute bill exactly, where the ratio would have left a gap. The cap holds on ratio and statute rows. Northern Ireland is left bit for bit, a reduction above its zero bill included and counted. The kept bill is the paid bill from the columns before the rewrite, netting the rebate where it differs from the reduction. Clone 0 at K = 3 is K = 1's, and the result does not depend on row order. The evidence matches its counts, each its own where every FRS path holds a different number of sources. It counts the support channel's rows in clone 0 even where later clones copy other households, and the capped households and Northern Ireland's reductions above the bill, and whether they lie within it, in clone 0 even where later clones differ. It is byte-equal at K = 1 and 3 but for `clone_count`. Every refusal names no key, code or count of a household, and the declaration refuses a drifted stage. diff --git a/changelog.d/931-council-tax-provenance-and-check.added.md b/changelog.d/931-council-tax-provenance-and-check.added.md new file mode 100644 index 0000000000..cc978bbd53 --- /dev/null +++ b/changelog.d/931-council-tax-provenance-and-check.added.md @@ -0,0 +1,20 @@ +The council-tax bill's provenance in `frs_council_tax` and a stage-health check that holds council-tax reductions within the bill (#931), unwired: no stage writes the provenance and no gate declares the check, so no value moves. Later in #931 group (d), `frs_council_tax` writes the provenance, council-tax localisation reads it, and a transferred gate declares the check. + +- **The bill's provenance** (`microcosm.build.uk_runtime.frs_council_tax`). `derive_council_tax_provenance(household, household_raw)` names the branch `derive_council_tax` takes for each household's bill outside Northern Ireland, and `not_levied` there, as a `StringDtype("python")` series on the bill's index, for the column `FRS_COUNCIL_TAX_BILL_PROVENANCE_COLUMN` (`council_tax_bill_provenance`) that `frs_council_tax` will write. The first value that holds names the row: + - `not_levied` where raw GVTREGNO is 13 (`NORTHERN_IRELAND_GVTREGNO`, beside `SCOTLAND_GVTREGNO`): Northern Ireland pays domestic rates, not council tax; + - `missing` where CTANNUAL is negative or blank, or zero where CTPAID is 1 and no reduction is reported, so the bill takes the cell mean; + - `observed_gross` where CTREB is 1 and a positive CTREBAMT is added back to the netted CTANNUAL; + - `unknown_reduction` where CTREB is 1 without a positive CTREBAMT, whose bill is the larger of the netted CTANNUAL and the cell mean; + - otherwise `observed_gross`, the netted CTANNUAL, which stays zero where CTANNUAL is zero and CTPAID is not 1. + + The four values are `FRS_COUNCIL_TAX_BILL_PROVENANCE_VALUES`. One branch function, `_council_tax_branches`, chooses both the bill and its provenance from the same masks, and `derive_council_tax` returns its bill, bit for bit as before. `frs_council_tax_provenance_operation_parameters()` is the `derive` declaration (`output` and `formula`, the precedence above in raw codes) that the stage will declare. `council_tax_provenance_evidence(frame, provenance)` is the stage's receipt form: `{"stage": "frs_council_tax", "bill_provenance_sources": {value: rounded_count}}` for all four values, zeros included, counting distinct source households before the copies through `record_source_households`. It refuses an input that is not one-dimensional, has the wrong length or holds a value outside the four, by texts that name the column and the four values, never a value or count read. +- **The check** (`stage_health`, check `council_tax_reduction_within_bill`). It reads the phase's frame and no receipt key beyond the stage match every stage-health check makes. The households whose `region` is one of `excluded_regions` leave first, with their persons. Then each remaining household's `household_reduction_columns`, and each of its `person_reduction_columns` summed over its persons through `person_household_id`, must be at most its `bill_column` plus `absolute_tolerance`, through the shared `microcosm.build.bounded_amounts.amounts_within_bound`. Every value read of the bill and of those columns must also be finite and non-negative. The household ids must name each household once over the whole table before any leave. + - Its details are booleans: `households_checked`, one per reduction column under `columns`, and `finite_nonnegative`. A frame with no household left to check passes, with `households_checked` false. + - Its failure texts name the stage, the check and columns or parameters, never an id, a value or a count. A missing frame, a malformed declaration, a missing or repeated column, a non-numeric column, a repeated household id and a person whose household is in no table each fail by name. +- **Bindings** (`battery_bindings`). The stage-health binding hands the phase's frame to the new check, as to the band donor and copy area checks, and routes its four keys: `bill_column`, `household_reduction_columns`, `person_reduction_columns` and `excluded_regions`. Its tolerance is the routed `absolute_tolerance`. `UK_GATE_REGISTRY_MODULES` gains `microcosm.build.bounded_amounts`, which the whole registry now reaches. +- **Counting stage.** `frs_council_tax` joins the counting stages in `graph_kernels`, since its module now counts through `receipt_counts`. The counting test's control moves to `frs_employment`. +- **Keys.** UK only. `uk.stage.frs_council_tax@1`, every spine kernel through `graph_kernels`, the spine gates (`stage_health`, `battery_bindings`), the full battery's preflight and calibrated gates and the national gates (whose registry modules now include `bounded_amounts`) change hash, and the nodes after them re-key. No stage contract, phase code, country or solve fingerprint, declaration, generated file, `gates.json` or H2 file changes. No NZ, BE, AM or US key moves: `microcosm.build.gates`, `country_spec` and `source_manifest` are untouched, and only the UK stage-health check calls `bounded_amounts`. +- **Tests**, on invented rows and tables only. + - `tests/engine_free/uk/test_uk_frs_council_tax.py`: each provenance value and the precedence on hand-worked raw rows, with each bill equal to a literal worked by hand; a seeded property that re-derives the branch and the bill one row at a time; alignment by household id; the declaration's value order; the two GVTREGNO constants against `frs_spine.REGION_MAP`; the receipt's rounded counts, with copies counted once; and the refusals. + - `tests/engine_free/uk/test_uk_stage_health.py`: reductions at the bill and within the tolerance pass, in float and integer columns; a rebate or a reported reduction above the bill fails its column alone, as does a two-person sum above it and a reduction on a zero bill; NaN, infinite, negative and missing values fail `finite_nonnegative`, a NaN or negative bill failing every column; a Northern Ireland household above its zero bill fails nothing when its region is excluded and every column when it is not, and its persons leave with it; the declaration and table refusals; no digit in any text; details that are booleans. + - `tests/engine_free/uk/test_uk_battery_bindings.py`: the binding hands the check the phase's frame (evidence absent without it), routes its four keys, each of which changes the verdict, and refuses a misspelt key through `validate_gate_parameters`. diff --git a/changelog.d/931-council-tax-reduction-gate.changed.md b/changelog.d/931-council-tax-reduction-gate.changed.md new file mode 100644 index 0000000000..a7fddec89a --- /dev/null +++ b/changelog.d/931-council-tax-reduction-gate.changed.md @@ -0,0 +1,26 @@ +Gate each household's council-tax reductions within its bill on the UK spine, and hold the copies made after the council-tax localisation to their parent's council tax (#931). In a second gates digest break for #931's new spine gates (the plan allowed one; this extends it), the spine battery gains `uk_council_tax_reduction_within_bill` at the transferred boundary, and the copy area agreement holds `council_tax` and `council_tax_rebate`. No value moves. Every spine built before this change no longer binds, those built since `council_tax_localise` was declared included: the strict loader holds a stored report's gate digests to the current declarations. + +- **The gate** (`gates.json`, `uk_council_tax_reduction_within_bill`, right after `uk_copy_area_agreement`). It declares the stage-health check `council_tax_reduction_within_bill` on `council_tax_localise` at the transferred boundary. It is release-blocking: a spine without the `council_tax_localise` receipt fails it closed, and absent evidence (no frame, or no stage evidence) blocks it in every posture (`evidence_absent_blocks`). + - The households whose `region` is in `excluded_regions` (`NORTHERN_IRELAND`) leave first, with their persons. Then each household's `council_tax_rebate` (`household_reduction_columns`), and its persons' `council_tax_benefit_reported` summed (`person_reduction_columns`), must be at most its `council_tax` (`bill_column`) plus `absolute_tolerance`, and every value read must be finite and non-negative. + - The check reads the transferred frame, and no receipt key beyond the stage match every stage-health check makes. Its details are booleans, and its failure texts name the stage, the check and columns. + - It sits at the transferred boundary because `council_tax_localise` is the last spine stage to write the bill or a reduction, and the copies made after it inherit both. The localisation caps every Great Britain reduction and rebate at the new bill and leaves Northern Ireland's rows as they are, uncapped, so the gate leaves Northern Ireland out. + - No gate kind is added. The gate is a stage-health entry whose check reads the frame, as the copy area agreement is, so `country_spec` and `gates`, which NZ transport hashes, are untouched. +- **The copy area agreement** (`uk_copy_area_agreement`). Its later layers (`high_value_support`, `cgt_support_split`, `cgt_incidence_clone` and `cgt_residential_split`), whose copies are made after `council_tax_localise`, also hold each copy to its immediate parent on `council_tax` and `council_tax_rebate`, the household columns the localisation rewrites. The support channel's layer stays on region and the clone index alone, since the localisation prices those copies at their own cell. The kept bill (`council_tax_frs_bill`) is not held, and neither is the person reduction, since the copy check reads households. +- **The WAS support gate's notes reworded to name the clipped and the exempt columns (María, 14 Nov).** Text only: `uk_stage_was_wealth_support`'s parameters are unchanged. +- **Scopes and phase codes.** `UK_SPINE_GATE_SCOPE` gains the gate, so the closed-world partition gives it to the spine's battery, and the calibration seam and the local battery leave it to the spine. The spine's transferred gate code also hashes `microcosm.build.bounded_amounts`, which the check computes through, and its docstring's count of the modules that no stage up to `area_brma` hashes is recounted from the walk. +- **`microcosm.data.contract`** follows, re-pinned from the live producer: the entry's gate and phase, the evidence ids (the stage-health binding records an evidence digest for every entry), the spine part's scope, the battery's policy, manifest and fingerprint digests, and the spine part's digests. The calibration seam's and the release cut's digests do not move. +- **Keys.** UK only. `gates.json` is in the UK country fingerprint and in the solve fingerprint, so both move, and so do the gate kernels and the kernels keyed on the solve fingerprint. `gate_scopes`, and for certification readiness `microcosm.data.contract`, move the kernels that hash them. Of the gate phase codes only the spine's transferred code moves. Both spine gate phases re-key, and with them every node after `area_brma`: the rest of the spine, and every dense and national node. No stage kernel or stage contract moves, and no H2 or generated file changes. Outside the UK no key moves: no transport or US kernel, no NZ node with its donors held fixed, no NZ battery source, no US graph node, and no AM, BE, NZ or US fingerprint, spec-engine wire or bundle lock. +- **Tests**, on invented frames, the toy supports and the packaged spec. + - `tests/engine_free/uk/test_uk_stage_health.py`: + - the copy area gate's later layers hold the localisation's household rewrites, beside the SPI-copy area stage's; + - the packaged gate holds the bill and the reductions the localisation rewrites, with its excluded regions, at the transferred boundary, release-blocking, and the stage-health binding routes each of its keys and refuses each one misspelt; + - `council_tax_localise` is the last packaged stage that writes the bill or a reduction, with the support channel before it and the later copy stages after it; + - on the frame and the receipt the localisation's packaged stage writes, at one and three clones, the registered gate passes through the battery's registry. An invented Northern Ireland household's reduction above its zero bill, which the stage's receipt records, is left out, and held in it fails both columns; + - a Great Britain household's rebate, or its first person's reported reduction, set above its bill fails the gate on that column, and a Northern Ireland household's does not; + - stage evidence without the localisation's receipt fails the registered gate closed and blocks the build, and absent evidence (no stage evidence, or no frame) blocks it in a development build too; + - through the battery's registry, the packaged copy area gate fails a copy of each later layer moved on `council_tax` or `council_tax_rebate`, on that layer and column alone, and passes a support channel copy moved on either. + - `tests/engine_free/shared/test_gate_battery_contract_pins.py`: the mirrored evidence ids are the entries whose binding attests evidence, every stage-health entry among them. + - `tests/engine_free/uk/test_uk_battery_bindings.py`: the stage-health binding reads the frame for three packaged gates, all at the transferred boundary. + - `tests/engine_free/shared/test_country_spec.py`: the battery's entries and the evidence-absent entries in order, the new gate right after the copy area agreement. + - microcosm-data's `tests/engine_free/shared/test_contract.py`: the mirrored entry, its stage and the battery's digests. + - `tests/integration/uk/test_uk_staging_integration.py`: the smoke spine's battery passes the new gate. diff --git a/changelog.d/931-dense-k-pin.changed.md b/changelog.d/931-dense-k-pin.changed.md new file mode 100644 index 0000000000..e8df3efeca --- /dev/null +++ b/changelog.d/931-dense-k-pin.changed.md @@ -0,0 +1,38 @@ +Hold dense engine blocks, release candidates and size evaluation to the spine's clone count (#931). The dense line takes its geographic clone count K from the spine it binds; now every reader of K holds to it. The dense line still refuses every spine whose roster is not geography-first, so no dense build runs yet; what changes is which spines and runs are refused, and how size evaluation reads a dataset. + +- **Engine blocks.** `full_measure`'s engine blocks take the clone count their caller binds (`clones`, through `resolve_uk_full_measures` and `resolve_uk_full_national_problem`) and refuse a frame whose geographic clone count is not K, at every block count, one included: a one-block call on some of the pool's clones (one of them, say) used to pass. The check reads the clone count alone, so a part of the pool that keeps every clone index is not refused there. Blocks other than one or K are refused too. The refusal names the two clone counts and nothing else. The dense measures node carries the spine's K as its `geographic_clones` parameter, which its kernel hands to the engine blocks beside `engine_blocks`, and `append_uk_target_nodes` takes it, refusing engine blocks other than one or K and a K that is not a positive integer. The national rows (`materialize_uk_national_rows`) resolve at one block of one clone. Without `clones` (callers outside the build graph) nothing changes. +- **`--engine-blocks`.** Preparation refuses a count other than one or the spine's K once it has bound the spine, naming K. Validation still compares it with an asserted `--n-clones` only. +- **Release candidates.** On top of the sampled-spine refusal, preparation refuses a `--release-candidate` whose spine fails any of three checks, naming each failure and K: + - its clone count is not the doctrine's 15; + - it was not built as a release candidate (its sidecar's `release_posture`, or the one a spine request's flags give); + - its geography binding is not a release's: the new `country_adapter.uk_spine_geography_binding_failures` wants the atomic law (`assignment` `"atomic"`), the geography key as `identity`, a SHA-256 `definition_sha256`, support pins equal to the conditioned supports `sources.yaml` registers (`uk_atomic_support_register(conditioned=True)`) and no system the register does not list, and, where it is asked for one, that K; sizes and K must be integers, so a recorded `15.0` fails. + + The in-graph spine of a `--spine-request` records no geography block, so its binding carries K alone: a release candidate on one is refused as recording no geography binding until the request route composes a block. (Later in #931 it composes one with the sidecar writer's helper, and the check also holds the block's stream and register: `931-spine-assigns-areas`.) The `uk_atomic_support_register` docstring now says a release builds on the conditioned supports, and that the base ones are what `tools/build_uk_conditioned_area_supports.py` builds them from. +- **The spine's own `--release-candidate`** still takes one clone. It now also takes the dense release's 15, but only where the packaged UK spec's roster is geography-first (`spine_posture.roster_failures`); otherwise the refusal names what the roster lacks. Every other clone count is refused, in the parser and in the preparation the full build hands a spine request, in a sentence that says 15 needs a geography-first roster. Once later commits of #931 declare the area stages and the WAS chain's localiser, the check passes without a code change. +- **The release pre-flight** (`tools/preflight_uk_local_release_candidate.py`) holds the manifest's `geography.assignment` to the same helper, so to the conditioned register rather than the base one, and requires its `geographic_clone_count` to be 15, as `parameters.n_clones` must be. Its failures name the field and what it must be, never the value: `geography.assignment.assignment is not 'atomic'.` replaces the message that printed the law it found. +- **Size evaluation** (`size_evaluation.weight_tables`) reads a dense dataset as its clone-first spine's rows: + - Every row's ordinal at the copy-id table's `geographic_support` field must equal its `clone_index`. Each row's spine household is then itself, and its design weight is that spine row's own weight, with no division by K. + - Where a file keeps no `source_household_id`, distinct sources fold the geographic clones back to clone 0's id (`copy_id_table.parent`), copies apart. + - The old dense layout's multiplier decode (`_source_multiplier`, `_spine_ids` and their `id_multiplier_for_values` import) is removed, as are `weight_tables`' `n_clones` and `id_multiplier` arguments. A dataset in another layout is refused in one fixed sentence, which names no count, id or value and points at the tools of the commit that built it. + - The result's `source_id_multiplier` and `source_id_multiplier_basis` give way to `source_household_basis` (`source_household_id` or `geographic_support_parent`), the spine-coverage refusal no longer prints a count, and spine weights that list a household twice are refused. + - The copy-id guards now list `size_evaluation` among the table's readers, not among the users of the retired rule. +- **What moves.** Keys and records only; no dataset value, and no spine node. No spine kernel or gate phase code hashes an edited module, and no spine stage calls edited code, so every spine node keeps its key and H2 is not regenerated. + - 12 of the 86 UK kernels change hash, none of the spine registry's 60: + - the dense and gate kernels that hash `full_measure` or `graph_targets` (`uk.full.target_compilation@1`, `uk.full.target_selection@1`, `uk.full.measures@1`, `uk.full.problem@1`, `uk.full-gates.preflight@1`, `uk.full-gates@1` and `uk.full.rotated-holdout@1`); + - the national kernels that hash `graph_national` (`uk.full.national_targets@1`, `uk.full.national_problem@1`, `uk.full.national-gates@1` and `uk.full.national-readback@1`); + - `uk.full.bound_spine@1`, which hashes `graph_build`. + - So every node of the dense graph re-keys, on a composed spine (after its 86 spine nodes, whose keys hold) and on a bound one, and so does every node of the national graph. The measures node's key also takes its new `geographic_clones` parameter. + - `full_build_cli`, `rowwise_cli`, `spine_build`, `country_adapter`, `size_evaluation` and the pre-flight tool are hashed by no kernel, and the gate phase codes do not move. + - The NZ transport kernels' hashes, the US kernels and post-transfer graph keys, the spec engine's compiled bundles and the packaged specs are unchanged. + - No declaration, generated file, `gates.json` or schema changes. +- **Tests** (invented data): + - The engine blocks on the clone-first stand-in: the whole pool resolves in one block or K, while a frame of some of its clones, or of more clones, is refused at either count, and before any engine loads in both resolvers. Blocks other than one or K are refused. + - The measures' `geographic_clones` parameter, the measures kernel handing it to the engine blocks beside `engine_blocks`, and the target nodes' refusals. + - `--engine-blocks` held to the spine's K on both routes. + - A release candidate prepared on a stand-in spine at 15 clones, built as a release candidate, with the stand-in's own binding. + - A release candidate on a bound spine at another K, in another posture, under another law or off the register, refused naming each failure; the same spines build candidates. The request route's refusal, naming no geography binding. + - The spine CLI refusing 2, 7 and 16, and refusing 15 on a roster before the area stages while accepting it on a geography-first one. + - The binding helper field by field, a float K and float sizes included. + - The pre-flight refusing base-register pins, another K and each binding field. + - Size evaluation decoding a table-minted clone-first dataset by the identity above 2^62 without dividing by K, and refusing the old layout and rows off the layout without a figure. + - The stand-in sidecar's geography block is now the stand-in spine's own: the toy definition's digest and stream, and the toy supports' pins (`uk_full_population_graph.toy_geography_binding`). `patch_support_register` registers those pins as the conditioned supports and refuses a reader that asks for the base register. diff --git a/changelog.d/931-dense-localisation-nodes-retired.removed.md b/changelog.d/931-dense-localisation-nodes-retired.removed.md new file mode 100644 index 0000000000..d241d8b1f7 --- /dev/null +++ b/changelog.d/931-dense-localisation-nodes-retired.removed.md @@ -0,0 +1,8 @@ +Retire the dense line's own property, BRMA, private-rent and fuel-relief nodes, with their flags, configuration fields and release-candidate refusals (#931). The dense line takes home values, BRMAs, private rents and Rural Fuel Duty Relief flags from the spine, whose own stages set them in later commits of #931 group (c), and keeps the spine's council-tax bands. It already refuses, before it pins or reads any other input, a spine whose roster lacks those stages (`spine_posture`), so no dense build runs until they land. + +- **Nodes and kernels.** `uk.full.property.value@1`, `uk.full.property.band@1`, `uk.full.geography.brma@1`, `uk.full.geography.rfdr@1` and `uk.full.private_rent@1` leave `microcosm.build.uk_runtime.graph_population`, with the helpers that composed them, the property quantile artifact type (`microcosm.uk.property-quantile-draw`) and the pool checkpoint's typed edge to it. `append_uk_population_nodes` no longer takes `property_localisation_mode`, `brma_localisation_mode`, `private_rent_localisation_mode`, `rfdr_localisation_mode` or `full_scale`, and `uk_pool_validation_inputs` no longer takes a property mode. On the atomic assignment the dense graph's geography is now the identity, the shared support imports, assignment and derivation, the local-authority resolve, the shared gate and the UK distribution gate; the next change of #931 retires those too, when the dense line takes its areas from the spine. +- **Configuration.** `UKFullBuildConfig` loses `property_localisation`, `brma_localisation`, `private_rent_localisation` and `rfdr_localisation`, and with them its refusal of BRMA target rows without area BRMAs. The dense line no longer leaves its BRMA-grain rows out on either assignment: they bind on the spine's `brma` column, which a spine the dense line accepts reads off its areas. So `append_uk_target_nodes` loses its `brma_rows` switch and the target selection's payload its `brma_rows_left_out` field, which nothing could set once the configuration field went. +- **Flags.** `microcosm-build-uk` (`tools/build_uk_full.py`) no longer takes `--property-localisation`, `--price-paid-quantiles`, `--voa-band-mix`, `--scotgov-band-mix`, `--brma-localisation`, `--brma-area-layer`, `--private-rent-localisation`, `--brma-rent-quantiles`, `--rfdr-localisation` or `--rfdr-area-layer`, nor the six resource pins `--price-paid-quantiles-sha256`, `--voa-band-mix-sha256`, `--scotgov-band-mix-sha256`, `--brma-area-layer-sha256`, `--brma-rent-quantiles-sha256` and `--rfdr-area-layer-sha256`. A script that still passes one is refused as an unrecognized argument. The release-candidate refusals of the four `none` modes go with them: the spine-roster check holds every dense build, release candidates included, to a spine with the stages that set those columns. The build request's bindings lose their four localisation blocks, and the size-checkpoint identity loses the four blocks that bound those resources' pins. +- **Kept.** Every function the nodes called stays, with its tests: `owner_uniforms`, `localise_values`, `localise_bands` and `spine_household_keys` in `property_localisation`, `area_brmas` in `brma_area_layer`, `area_flags` in `rfdr_area_layer` and `localise_rents` in `private_rent_localisation`. The spine's geography and private-rent transforms (`spine_geography`, `spine_private_rent`), which no stage declares yet, call `area_brmas`, `area_flags` and `localise_rents`, and the `regional_home_values` stage calls `owner_uniforms`. (Later in #931 that stage retires, and the WAS chain's area home values rank owners with `owner_slice_uniforms`, which replaces `owner_uniforms`: `931-spine-localises-home-values`.) (Later in #931 the packaged spine declares their stages: `931-spine-assigns-areas`.) The committed resources the nodes read and the terminal `uk_local_brma_enum_domain` gate stay too, though no dataset build reads the VOA or Scottish band mix now. (Later in #931 that gate retires, and the spine's `uk_brma_enum_domain` checks the column at its transferred boundary: `931-spine-localises-home-values`.) The unread mode tuples `BRMA_LOCALISATION_MODES`, `RFDR_LOCALISATION_MODES` and `PRIVATE_RENT_LOCALISATION_MODES` go; `PROPERTY_LOCALISATION_MODES` stays for now, since spine stages hash `property_localisation`. `private_rent_localisation`'s docstring now names the spine's private-rent stage as the caller that supplies the row keys and tie-break uniforms. `tools/uk_private_rent_pool.py` and `tools/uk_private_rent_receipt.py` now say they read only dense runs built before this change. +- **What moves.** Keys only, no value: the dense line already refuses every spine, the national line every clone-first one, no spine module changes, and a national build on a spine without clone indices computes what it did before. Of the 98 kernels the UK registries register (103 before), 30 change hash, all `uk.full`: the nine `graph_population` defines (sample, normalisation, expand, identity, locations, mapping, local authority, pool and the distribution gate); the fifteen that hash it (the dense measures and problem, the dense solve, the calibration install and the five size kernels, the rotated holdout, both export preparations, and the national problem, gates and read-back); the bound spine's checkpoint kernel (`uk.full.bound_spine@1`), which hashes `graph_build`; and the five that hash `graph_targets` but not `graph_population` (the target compilation and selection, the national targets, and the full battery's preflight and calibrated gate kernels). Each kernel that hashes `size_checkpoint` also hashes `graph_population`, and no kernel hashes `full_build_cli`, `rowwise_cli`, `orrery_contract`, `brma_area_layer`, `rfdr_area_layer` or `private_rent_localisation`. Of the gate phase codes only the full battery's terminal code moves, since it lists `graph_population`, so the calibrated gates' `terminal_code` parameter changes too. On a spine the dense build composes, every spine stage and both spine gates keep their keys and every dense node re-keys; on a bound spine the checkpoint re-keys, and every dense and national node after it. A dense run's input pins no longer carry the seven resources, so its input-pins digest, candidate identity digest and size-checkpoint identity change. No declaration, generated file, `gates.json` or schema changes. +- **Tests.** The node and configuration tests go: `test_uk_brma_area_graph.py` and `test_uk_rfdr_area_graph.py` are removed, as are the graph sections of `test_uk_private_rent_localisation.py`, `test_uk_property_localisation.py` and `test_uk_regional_home_values.py` and the CLI's localisation flag tests. Their function tests stay. New tests check that each retired flag is refused as an unrecognized argument, and that the atomic dense graph composes none of the five nodes, neither declares nor reads their resources, and the Orrery roster names none of them. The toy resource writers that only the nodes read leave `test_support/microcosm_build/uk_atomic_support_fixtures.py`. diff --git a/changelog.d/931-dense-needs-a-geography-first-spine.changed.md b/changelog.d/931-dense-needs-a-geography-first-spine.changed.md new file mode 100644 index 0000000000..ae7c19c683 --- /dev/null +++ b/changelog.d/931-dense-needs-a-geography-first-spine.changed.md @@ -0,0 +1,14 @@ +The dense line refuses a spine that does not assign areas, before it pins or reads any other input (#931; María's ruling of 10 Nov, decision 4). Later commits of #931 group (c) move the dense line onto the spine's own areas; refusing first means none of them can build a dense dataset on a half-moved line. `full_build_cli.prepare_full_build` now checks the spine's roster first: after the engine freeze, and before it pins an input, reads the spine, authenticates the checkpoint or composes a graph. It checks again the roster the build then binds. No spine built from this code passes yet. The check passes once the spine declares its area stages and the main-residence localiser, and a bound spine's sidecar records the geography block. (Later in #931 the packaged spine declares both: `931-spine-localises-home-values`.) + +- **The geography-first names** (`microcosm.build.uk_runtime.geography_first_roster`, new). A names-only leaf that imports nothing first-party: `GEOGRAPHY_FIRST_STAGES` (`geographic_expand`, `geographic_identity`, `atomic_area_assign`, `local_authority`, `rfdr`, `area_brma`, `spi_copy_areas` and `private_rent`), `GEOGRAPHY_FIRST_OPERATIONS` (`was_wealth`'s `localise_main_residence_value`) and `SIDECAR_GEOGRAPHY_KEYS`, the keys of the build sidecar's `geography` block (`assignment`, `identity`, `definition_sha256`, `support_pins`, `stream` and `register`). Its stage names are the ones the stages' transforms declare, and a test holds them together. (Later in #931 the transforms read their names from the leaf.) +- **The check** (`microcosm.build.uk_runtime.spine_posture`, new). `roster_failures(stages, operations, geography=None, *, from_sidecar=True)` names, in the leaf's order, every stage, operation and block key a roster lacks. A roster that is not names fails as a whole (`stage roster`, `operation roster`), an operation counts only in a stage the roster ran, and extra names never fail. Only the block's keys are read, never their values. `require_geography_first_spine` refuses a roster that lacks anything, in one sentence that names what it lacks and nothing else: no count, id or value. `stage_roster` reads declared stages' names and operation kinds, and `spec_roster` a spec's. +- **Both routes.** + - With `--input-h5` the check reads the build sidecar's `stages`, `operations` and `geography`, from `--input-sidecar` where it is named, before the ladder or the spine is pinned. An absent or unreadable sidecar is refused in `load_bound_spine_checkpoint`'s own words. The checkpoint is still authenticated after the check, and the sidecar it authenticates, the one the build binds, is checked again, so one changed since the first read is refused too. + - With `--spine-request` it reads the stage names and operation kinds of the packaged UK spec, whose whole roster every request runs, before the request is parsed or its spine composed. Its spine runs inside the dense build's own graph, so it has no block to read. The spine the request composes is checked again, on its own stages, before the build reads it. + - A dry run, with or without `--candidate-clone-counts`, is refused alike. The national line and the row-wise dataset tool (`tools/build_uk_rowwise_dataset.py`) are unchanged. +- **What moves.** No line builds differently: the dense expansion already refused, at any clone count, a spine that carries the geographic clone indices, as every spine built since #931 group (b) does. The check also refuses a spine without them, one built before group (b), which the dense line could still bind until now. The expansion refused only once the graph reached it, so a dense dry run could still plan on a clone-first spine; dry runs and builds now both stop at preparation. A refused build records its attempt as failed, with the refusal as its message. `tools/measure_uk_atomic_assignment.py`'s graph route runs the dense preparation, so it is refused the same way; later in #931 the tool measures the spine's own draw with no graph. No node hashes `full_build_cli` or the two new modules, so no node key moves. No declaration, generated file, `gates.json` or schema changes. +- **Tests** (invented rosters, rosters read off the packaged spec, and the spine build's own sidecar writer over a synthetic frame; no built spine's sidecar). + - The packaged roster, and the sidecar the spine build's writer records for it, are refused naming the six area stages and the localiser, and the sidecar also the block. (Later in #931 the localiser alone, and then nothing: `931-spine-localises-home-values`.) + - Each missing name fails alone, in the leaf's order; unreadable rosters fail by name; a geography-first stand-in passes, with extra names too; no refusal carries a figure. + - Through `prepare_full_build` on both routes, recording stand-ins, under which the real request-roster reader runs, show the refusal comes before any input is pinned or read and before any graph is composed, and that a geography-first stand-in goes on to pin its first input. A sidecar block that lacks any one key is refused naming that key; an unreadable sidecar is refused word for word as the bound loader refuses it. A roster that passes the first check but not on the authenticated sidecar or the composed spine is refused before the spine is used. Through `main`, a refused build records a failed attempt without running a graph. + - The stand-in sidecars of the preparation tests and of the dense dry-run test carry a geography-first roster (`geography_first_sidecar_fields` in `test_support/microcosm_build/uk_full_build_cli.py`). diff --git a/changelog.d/931-dense-on-the-clone-first-spine.changed.md b/changelog.d/931-dense-on-the-clone-first-spine.changed.md new file mode 100644 index 0000000000..60553dc758 --- /dev/null +++ b/changelog.d/931-dense-on-the-clone-first-spine.changed.md @@ -0,0 +1,18 @@ +Build the dense line on the bound spine's clones, areas and sampling (#931). The dense line no longer samples, expands, keys or places anything of its own: its targets, measures and problem run on the spine's version as it stands, its pool is that version whole, and its clone count K, its sampling rung and its geography binding are the spine's. It still refuses every spine whose roster is not geography-first (`spine_posture`), so no dense build runs until the spine declares its area stages. (Later in #931 it declares them, and the dense line waits on the WAS chain's home-value localiser alone: `931-spine-assigns-areas`; then the chain declares it, and the posture check passes on the packaged spine: `931-spine-localises-home-values`.) + +- **Graph.** `uk.full.sample`, `uk.full.normalize`, `uk.full.expand` (with `uk.full.expand.owned`), `uk.full.identity`, `uk.full.locations`, `uk.full.geography_mapping`, the shared support imports, assignment, derivation and gate (`uk.full.geography.*`), `uk.full.geography.local_authority` and the UK distribution gate `uk.full.geography_gate` leave the dense graph, with their eight kernels and the population receipt, location draw and geography gate artifact types. `microcosm.build.uk_runtime.graph_population` keeps `context_frame`, `population_columns`, `population_slices` and the pool checkpoint, `uk.full.pool@1`, now a keep-all FILTER on `uk.full.spine_checkpoint` (`--input-h5`) or the spine's endpoint (`--spine-request`) with no typed edge, declared bitwise and hashing its own module and `national_frame`. `append_uk_population_nodes`, `uk_pool_validation_inputs`, `GEOGRAPHY_ASSIGNMENTS` and `UK_GEOGRAPHY_IDENTITY_INPUTS` go. The UK registry no longer registers the shared atomic-geography kernels; NZ's transport registers its own. The dense geography gate's ladder and installed-engine local-authority checks (#953) and the pool's refusal of a failed shared geography validation leave with their nodes; the spine's own geography gates take them over when they are registered later in #931, and until then the roster refusal holds every dense build. +- **Targets.** `append_uk_target_nodes` takes `population` with no default, and the full build passes the spine's version. The measures lose their edge to the dense geography gate and their check of it, and take the spine's transferred-gate admission the sample node held, where the graph declares the spine's gates: they refuse to read the version unless that stored report admits it, before they read anything else. +- **Configuration.** `UKFullBuildConfig` loses `sample_fraction`, `sample_seed`, `geography_assignment`, `source_vintage`, `constituency_vintage` and `source_lineage_modulus`. `n_clones` (default 1, the declared spine's) is the bound spine's K and `effective_sample_fraction` is `source_sample_fraction`, the spine's rung. `uk_full_graph` no longer takes `spine_weight_kind` or `atomic_geography_definition`, and refuses a composed spine whose `geographic_expand` node declares another K than the configuration's, naming both. `build_uk_country_graph` no longer takes `atomic_geography_definition`. +- **K, sampling and geography from the spine.** `prepare_full_build` reads them from the authenticated sidecar (`geographic_clone_count`, one where a sidecar predates the record; `sampling`; `release_posture`; the `geography` block) or from the spine request's `--n-clones`, `--sample-fraction` and `--sample-seed`, and sets the run's `n_clones`, `sample_fraction` and, where the spine was sampled, `sample_seed` to them before the run's parameters, its candidate identity digest, its size-checkpoint identity, its staging rung and both Logbook rungs record them. A spine whose sampling fraction is not a scale-ladder rung is refused there, naming the rungs. The attempt's build id, minted before preparation reads the spine, takes the spine's rung read ahead off the bound spine's sidecar or the spine request's `--sample-fraction` (f100 where that read fails, and preparation then reports the real error); preparation refuses an attempt whose build id carries another rung than the spine it binds, naming both rung tokens, and a refusal before the spine is bound records the build id's rung on its Logbook row. The request bindings gain a `spine` block (clone count, sampling and release posture), and their `geography` block is the spine's binding with its clone count beside it. The rowwise manifest reads its `sampling`, `identity.sampling`, rung and release verdict's full-rung leg from that spine block and its `geography.ladder_gate` from the export descriptor's geography check on the calibrated frame; its weight-kind chain names `geographic_expand` for the clones. +- **Bound-spine checks.** `_assert_spine_sidecar_binds_frame` also holds the sidecar's `geographic_clone_count` to the frame's clone count, naming both, and the bound spine's checkpoint kernel hashes `geographic_clones` for it. `spine_provenance_from_sidecar` adds the spine's clone count, `geography`, `sampling` and `release_posture`. The national build record, the national calibration diagnostics' build block and the dense manifest's `identity.spine.spine_provenance` carry that provenance, so they gain the four fields; a national build on a spine without clone indices records K = 1 and computes the same dataset. +- **Flags.** `microcosm-build-uk` no longer takes `--geography-assignment`, `--atomic-support-ew`, `--atomic-support-scotland`, `--atomic-support-ni`, `--atomic-support-sha256-ew`, `--atomic-support-sha256-scotland`, `--atomic-support-sha256-ni` or `--source-lineage-modulus`; a script that still passes one is refused as an unrecognized argument, on either role. The dense role refuses a `--sample-fraction` other than 1.0, any `--sample-seed`, `--candidate-clone-counts` with `--input-h5`, and `--n-clones` with `--candidate-clone-counts`, by name, before any input is read. `--n-clones` is an assertion of the spine's K: the dense role no longer fills it from the doctrine, and preparation refuses one that differs from the spine's, naming both, and on a spine request pointing at the request's own `--n-clones`. `--candidate-clone-counts` plans the spine request once per count, each as the request's own `--n-clones`. The engine blocks are held to one or the spine's K by the configuration; on validation only an asserted `--n-clones` is compared. `--expected-constituency-vintage` is still taken and recorded in the run's parameters, but its one reader, the legacy location draw, is gone, so no dense node checks the ladder against it; its help says so. (Later in #931 the flag retires, as María ruled on 13 Nov: `931-spine-localises-home-values`.) +- **Release-candidate refusals.** A sampled spine is refused as a release candidate at preparation, where its rung is read, on either route. The release-candidate refusal of `--n-clones` other than the doctrine's leaves validation, as do the support pins' requirement and the legacy assignment's refusal; `--sample-fraction` other than 1.0 is refused on every dense build (above). The spine's clone count is held to the doctrine's, and its geography binding to the conditioned register, by later commits of #931. The ladder, Ledger and input pins, the target rule, the epochs, the measure exclusions, the local target levels and the signing key are refused as before. +- **The dense sampler.** `national_sampling` keeps the rung tokens, the default seed and the spine root's sampler; `sample_uk_spine_frame` and `uk_spine_source_family_units`, which drew whole source families for the dense line, go, with their re-exports. +- **Texts.** The row-wise lane's clone refusals (`rowwise_dataset`) point at the dense graph on a geography-first spine and promise no later group; `tools/build_uk_rowwise_dataset.py` says it serves spines without clone indices. `geographic_identity`, `household_lineage`, `geographic_clones` and `diagnostics` no longer describe the dense identity node as a key's writer or a column's reader: `household_lineage`'s three lineage refusals no longer open "Geography identity", its `UK_OPTIONAL_LINEAGE_COLUMNS`, which nothing reads now, goes, and `geographic_clones`' docstring names the national gates among the kernels that hash it. `tools/measure_uk_atomic_assignment.py`'s graph route, which ran the dense line's geography nodes, refuses with a pointer to the spine's own draw, its command before it reads any input, and the helpers that composed its requests go; later in #931 the tool measures the spine's own draw in process. The Orrery roster loses its geography group and the retired population nodes. +- **What moves.** Keys and records only; no dataset value. No spine stage's code changes: `household_lineage`, `geographic_clones` and `geographic_identity` change in docstrings, comments and refusal texts (and `household_lineage` loses a constant nothing reads), and `national_sampling` loses only the dense sampler, which no spine stage calls; the dense line still builds on no spine. On the synthetic H2 fixture the legacy oracle's final frame, stage records and stage evidence are identical before and after. + - Of the kernels the UK registries register, 86 remain (98 before: the eight dense population kernels and the four shared atomic-geography ones go), and 68 change hash: 43 of the spine registry's 60 (the root, `uk.create@1`; the 39 stages that hash `household_lineage`, `geographic_identity` among them; and `cgt_support_split`, `was_wealth` and `was_lisa`, which hash `geographic_clones` alone), and the 25 `uk.full` kernels that hash an edited module. `uk.spine-gates@1`, `uk.claim@1`, `uk.identity@1` and 15 stages keep theirs. A spine build's root also hashes `national_sampling` through its sampler. So every spine node re-keys, and every dense and national node after it. + - The pool was the last platform-bitwise UK kernel, so no dense node key carries the platform now (on the declared spine 16 of the dense graph's 23 nodes did); a shared graph store can serve them across platforms on their own bitwise declarations. + - Of the gate phase codes only the full battery's terminal code moves. + - A dense run's input pins no longer carry the three atomic-area supports, its recorded parameters drop `source_lineage_modulus`, and its size-checkpoint identity drops `source_lineage_modulus` and the `geography` block, so its input-pins digest, candidate identity digest and size-checkpoint identity change, and a size checkpoint cut before this change does not resume. The bound spine's provenance gains four fields (above). + - The coverage manifest's `--check` passes; no declaration, generated file, `gates.json` or schema changes. +- **Tests.** `test_uk_full_population_graph.py` and `test_uk_atomic_identity_graph.py` are removed with the nodes they ran, and `test_uk_national_sampling.py` now tests the root's sampler. Their tests of live code move: the lineage reader's branch paths, residential arms and refusals to the new `test_uk_household_lineage.py`, which runs `uk_household_clone_paths` itself, and the row-wise lane's clone and source-lineage refusals to `test_uk_rowwise_dataset.py`. The full-graph stand-in (`test_support/microcosm_build/uk_full_population_graph.py`) is a clone-first, geography-first bound spine: the toy households at K clones in the copy-id table's geographic field, keyed as `geographic_identity` keys them and placed on the toy supports with the shared operators, with a BRMA and a fuel-relief flag; a bound checkpoint of it takes a stand-in sidecar whose geography block is under the leaf's keys. New tests cover each retired flag, the dense role's spine-bound refusals on both routes, K, sampling and seed taken from the spine on both routes (a seven-clone spine without `--n-clones` records seven, in the parameters, the identity digest and a written manifest), a disagreeing `--n-clones`, a sidecar whose K is not its frame's, the engine blocks held to the spine's K, `--candidate-clone-counts` planning a spine request once per count, a release candidate on a sampled spine on both routes, a spine off the scale ladder, the build id's rung read ahead and held to the spine's, the measures' admission, the pool on the spine's version and its keep-all mask, the manifest's spine-bound sampling and ladder gate, the dense allow-list pin (every column a geography-first spine adds to the export surface is in `UK_ALLOWED_EXTRA_EXPORT_COLUMNS`), the local area support gate's row, effective-sample-size and source floors in the K-sensitive constants table, and the measurement tool's refusal. The `geographic_identity` stage's keys are held to `household_draw_key` itself. diff --git a/changelog.d/931-dense-spine-memory-floor.added.md b/changelog.d/931-dense-spine-memory-floor.added.md new file mode 100644 index 0000000000..1ceee2007b --- /dev/null +++ b/changelog.d/931-dense-spine-memory-floor.added.md @@ -0,0 +1 @@ +`tools/run_uk_cut.py dense-spine`'s preflight checks the host's physical memory (#931). It read the disk but no memory figure, so a host too small for the dense spine's measured peak, 68.4 GiB in `hmrc_spi_income_spine`, passed it and stopped in that stage. A blocking `physical memory` check now refuses, before the spine's inputs are fetched and again in the preflight, a host with less than 72 GiB, or one whose memory cannot be read; `--min-memory-gib` sets another floor, or none. The national cut's preflight is unchanged, and no key, dataset or receipt moves. diff --git a/changelog.d/931-dense-weight-kind-chain-order.fixed.md b/changelog.d/931-dense-weight-kind-chain-order.fixed.md new file mode 100644 index 0000000000..efb428b86d --- /dev/null +++ b/changelog.d/931-dense-weight-kind-chain-order.fixed.md @@ -0,0 +1 @@ +The UK dense candidate manifest's `weights.household_weight_kind_chain` now lists the household weights' kinds in the graph's order (#931): the spine's sample of its FRS root (below f100) and `geographic_expand`, both on the survey's design weights, then `staging`, the bound spine's importance weights, then `rowwise_calibration`. It listed the sample and the clones after `staging`, as importance weights, the order of the dense line that sampled and cloned the staged spine itself; on the clone-first spine both run at the spine's start, before its SPI support channel makes the weights importance weights, and the dense line samples and clones nothing of its own. The kinds are written from `WeightKind` and the clone stage's name from `GEOGRAPHIC_EXPAND_STAGE_NAME`. The manifest's other fields do not change. Keys: `graph_terminal` is hashed by the spine's stage kernels, the dense population and export kernels and the certification readiness, so they re-key; no declaration, generated file or `gates.json` changes. Tests: the synthetic dense build at f100 and at f010, whose chain is held to the order and kinds the spine declares (its roster, `geographic_expand`'s declared weight kinds and the SPI support channel gate's). diff --git a/changelog.d/931-engine-batches-read-year-window.changed.md b/changelog.d/931-engine-batches-read-year-window.changed.md new file mode 100644 index 0000000000..1f56f84362 --- /dev/null +++ b/changelog.d/931-engine-batches-read-year-window.changed.md @@ -0,0 +1 @@ +The UK spine's per-clone engine batches go through the read-year window of microcosm#1615 (#931). Each clone's simulation is built by the same construction as a call's one simulation: `PolicyEngineUKEngine._read_year_simulation` projects the clone's dataset to the call's year on the adapter's own parameters, stops the Universal Credit rebalancing loop at that year, and constructs the simulation through `_simulation`, which filters policyengine-uk's `EntityIdWarning`. An engine block's annual-income and counterfactual simulations are built by the block's wrapped factory inside the measure resolver's cut. An engine block computes at no dated measure's year after the resolver's: its scratch engine holds no later year and the resolver refuses such a measure, so the block neither checks the engine's growth nor sets the pool's shares there. Every dated target in the contract is a 2024 one, so a block at 2024 or later keeps its periods. policyengine-uk builds each year only from earlier ones, so no value at the call's year moves. Tests (engine-free, made-up data): both adapter routes project, open the cut and construct in that order, with `_simulation` constructing while the cut is open, an engine block's later simulation is built inside the resolver's cut, and a contract target dated after the resolver's year is none of its block's periods. diff --git a/changelog.d/931-engine-simulation-rank-ids.fixed.md b/changelog.d/931-engine-simulation-rank-ids.fixed.md new file mode 100644 index 0000000000..16835502b7 --- /dev/null +++ b/changelog.d/931-engine-simulation-rank-ids.fixed.md @@ -0,0 +1,13 @@ +Each policyengine-uk simulation the UK adapter builds now holds ids that policyengine-core's 32-bit store keeps apart (#931; decision 12, María's rulings of 11 Nov). policyengine-core stores policyengine-uk's five id variables (`person_id`, `benunit_id`, `household_id`, `person_benunit_id` and `person_household_id`) as int32, converting them with numpy's `astype`, which wraps an id outside the type without an error. It builds the entities and memberships from the int64 columns it is given, so two ids that wrap to one value merge no entity: they become one stored key for every formula that reads the id. policyengine-uk hashes its Warm Home Discount draw on `household_id`, its two Universal Credit deduction draws on `benunit_id` and its birth-month spread on `person_id`. Anything rebuilt from the stored values would see one entity. Within one clone's batch every id carries the same clone offset, so a repeat there needs a copy-layer ordinal on at least one of the two ids. + +- **The rule** (`microcosm.frame.adapters.engine_identifiers`, shared, for Max's review). `EngineIdentifiers(stored_dtype)` declares the integer type an engine stores a schema's id and membership columns as. `engine_identifier_tables(schema, tables, identifiers)` hands a simulation the tables it is given when no entity's ids repeat once converted as the engine converts them (`stored_identifier_repeats`). An entity whose stored ids would repeat takes 1 plus each id's rank among that simulation's ids, in id order, and each person's membership of it takes the new id of the group it names, never the 0-based rank (`rank_identifier_tables`, the step that ranks and maps and decides nothing). Ranks are distinct, fit the type and keep id order, so the engine holds every entity's rows in the frame's order, and results still return by position or by the frame's own ids. The frame is never changed. The module also names the entities whose ids the conversion changes (`inexact_identifier_entities`), refuses a request for such an entity's id or membership variable (`refuse_inexact_identifier_requests`, which reads no table unless an id or membership variable is requested), and holds a declaration to an installed engine's types (`require_stored_dtypes`). It reads a schema and entity tables, never a Frame, and names no country. It refuses to renumber an entity that a declared link's table among the tables names, since it maps only the person table's memberships. Its refusals name entities, links, columns, variables and types, never an id or a count. national_frame's release rule keeps its own ranker for now; moving it onto `rank_identifier_tables`, and deriving `UK_ENGINE_IDENTIFIER_MAX` from the declaration, are owed (decision 7). +- **The UK adapter.** `UK_ENGINE_IDENTIFIERS` declares int32, and `_require_identifier_dtypes` checks it against the installed engine's five id variables once per adapter; a test holds national_frame's release range (`UK_ENGINE_IDENTIFIER_MAX`) to the same width. `_dataset_tables` applies the rule to `engine_tables`' tables, and both construction sites build through it, so a call run clone by clone ranks each batch within its own rows. `materialize` refuses, before any engine is built, a request for an id or membership variable whose entity holds an id the engine cannot store exactly, since the engine would return wrapped ids or ranks for it. Each simulation is built with policyengine-uk's `EntityIdWarning` filtered, since the adapter now checks the stored ids itself, and the adapter refuses to build one if policyengine-uk no longer defines that class at `utils.entity_ids`. Building a dataset now builds the adapter's `CountryTaxBenefitSystem` first, which is inert. The stages that call the engine bind the new module beside `microcosm.frame.materialize` (`_ENGINE_COMPUTE_MODULES`), as the walk from the engine the builds inject reaches it. +- **What moves.** + - Nothing on a frame whose stored ids do not repeat: `UKSingleYearDataset` is built from the same tables, byte for byte, so every engine output is the same. + - Elsewhere, only that simulation's values keyed on the renumbered entity's ids. For households that is the Warm Home Discount draw, which runs for 2025 to 2030 and adds only to HBAI income, which spine stages request only at 2024. A batched call's id-keyed values can differ from one simulation's over the whole frame wherever either renumbers, since each batch ranks its own rows. + - The adapter's simulations no longer write `EntityIdWarning` to stderr, and an id request for an entity the engine cannot store exactly is refused; no stage makes one. + - Every UK graph node re-keys: the kernels that hash the adapter directly, and every other node through its population's version. No other country's keys move. The US annual static-aging manifest's `source_sha256`, which hashes every module under `microcosm.frame`, gains the new file and changes the adapter's entry; it is provenance, not a node key. No declaration, generated file, `gates.json`, schema, receipt or sidecar field changes. +- **Tests** (invented data only). + - The shared module (`tests/engine_free/shared/test_engine_identifiers.py`): pass-through, the same table objects, on ids inside int32 and on copy-layout ids past 2**31 that convert out of int64 order; a stored repeat renumbered by rank, with 1-based memberships; a seeded sweep of a few hundred frames under int8 and int16 declarations, over NumPy and nullable, signed and unsigned id dtypes, against the tests' own reading of the conversion; inexact entities and request refusals; the rank step's refusals, a link table naming an entity to renumber among them; and refusals checked by exact string to quote no id, wrapped value or row count. + - The adapter, engine-free: the declaration, its once-per-adapter check, and the dataset builder holding it before it builds anything; on ids past 2**31 that stay apart, `_dataset_tables` hands on the very tables `engine_tables` made; each batch ranks its own rows, through `materialize`'s batched site and the dataset builder too; the request refusals; and the warning filter fails closed at both construction sites. The binding walk gains the module, and the two widths agree. + - Through the engine (`tests/engine/uk/test_policyengine_uk_identifiers.py`): the declaration is the installed engine's. On copy-layout ids every value, the id-keyed draws included, is a direct Microsimulation's over the frame's engine tables at 2024, at 2025 and at 2025 projected from 2024, with each household's member count and an echoed household input in row order. Households 7 and 7 + 2**32 take different Warm Home Discount draws, and every value is the same call's over the frame renumbered by hand: at the dataset's year, projected through policyengine-uk's council-tax and student-loan joins on the raw memberships, and clone by clone at two clones. These three fail where the adapter passes the frame's ids through unchanged, and a 0-based membership map fails the first two. The warning is filtered at both construction sites, while a direct Microsimulation over the same tables still records it. diff --git a/changelog.d/931-engine-uk-after-merge-ci.added.md b/changelog.d/931-engine-uk-after-merge-ci.added.md new file mode 100644 index 0000000000..6a378fc288 --- /dev/null +++ b/changelog.d/931-engine-uk-after-merge-ci.added.md @@ -0,0 +1 @@ +A new CI job, `engine-uk-after-merge`, runs on pushes to main only, after merge (#931). It runs the new `engine_after_merge/uk/` test category, UK engine tests too slow for every pull request. Its first module is the clone-first H2 test, which runs the whole UK spine at one and at four geographic clones through the engine, about 27 minutes per leg. `tools/run_engine_uk_tests.sh` takes the job whose files it runs, `engine-uk` by default. `tools/ci_test_plan.py` marks the category's group `after_merge`, so the plan gives the job the push condition as its `if` and no selection need; the `ci` aggregate needs it, so a push must run it and pass, and `require-results` passes its skip on a pull request (`GITHUB_EVENT_NAME`). `verify-workflow` refuses a job that needs it unless that job runs after merge too. diff --git a/changelog.d/931-fold-lowest-id-sorted-keys.changed.md b/changelog.d/931-fold-lowest-id-sorted-keys.changed.md new file mode 100644 index 0000000000..0b2adc20e5 --- /dev/null +++ b/changelog.d/931-fold-lowest-id-sorted-keys.changed.md @@ -0,0 +1,21 @@ +The UK fits now train each variant of a survey record on its lowest-id clone instead of its first row, through a shared fold that takes the order from its caller and reports what the clone receipts will need; `integer_record_keys` finds repeated ids by sorting (#931; the sort as María ruled on 10 Nov). No output moves: every spine is one clone today, so every fit keeps its rows and weights value for value, and every id check on integer ids gives the verdict it gave. + +- **`fold_replicas`** (`microcosm.build.source_lineage`) returns a `ReplicaFold` with one value per record in each field: + - `kept`: the rows the fit trains on; + - `weights`: on each kept row, its variant's selected weights summed exactly (`math.fsum`); every other weight unchanged; + - `representative`: the row each selected record's variant trains on, -1 off the selection; + - `varied`: whether a selected record's key holds more than one variant; + - `key_group`: a code of each selected record's replica key, -1 off the selection. + + A variant's representative is its selected record with the least `order`, ties going to the earlier row. `order` is one numpy integer per record, and a malformed one, a timedelta included, is refused with counts only. Without `order` the representative is the variant's first selected record in row order, as before. A selected record with a null key, which `replica_keys` never gives, is now refused rather than folded with other records. +- **Early returns decided on the key.** When no two selected records share a key, the selection and weights come back value for value and nothing varies. When keys repeat but no two selected records share a variant, the selection and weights still come back value for value, and the records of every key with more than one variant vary. Deciding on the key and the inputs together would report no variety exactly when every clone differs. +- **`collapse_replicas`** is a wrapper that returns `fold_replicas`'s kept rows and weights. It takes the same keywords as `fold_replicas`, `order` included. Without `order` a variant keeps its first selected row, as before, so every caller and fixture keeps its values. +- **The UK entry.** `household_lineage.collapse_geographic_clones` keeps its signature and return, and orders the fold by the entity's id column. The new `fold_geographic_clones` returns the whole `ReplicaFold`. A key's clones differ in id only by their clone's offset, so each variant trains on its lowest clone among the selected rows: clone 0 whenever clone 0 is selected and agrees with it, whatever the row order. Before, it trained on whichever of its clones came first. +- **`integer_record_keys`** (`microcosm.build.stochastic_assignment`) compares neighbours in a sorted copy of the ids instead of building `np.unique`'s array. On integer ids its verdicts, errors and return are unchanged. Timedelta ids, which numpy types as integers and the check used to accept, are now refused as ids that are not integers. +- **What moves.** No output, at one clone or on any spine. On frames whose clones are out of clone order, which only tests build today, a variant now trains on its lowest-id record. Node keys move: + - every UK spine node, since the spine's root binds `stochastic_assignment`, `source_lineage` and `household_lineage` and keys chain; with them the spine gate phases (the transferred phase's own code also hashes `stochastic_assignment`) and, in the in-graph build, every node after the spine; + - on a bound spine, whose root hashes none of the three, the full build's `uk.full.identity`, `uk.full.property.value` and `uk.full.private_rent`, which hash `source_lineage` and `household_lineage`, and every node keyed on them; + - the national line's gates, whose registry modules include `stochastic_assignment`. + + The spine checkpoint's gate digests do not move. The derived binding tables are unchanged, since the new names live in modules already bound wherever they are reached. No generated file or `gates.json` changes: `uk_spine.json` and the H2 fixture hold stage contract hashes, not code hashes. Of the transport kernels only the gate battery (`gates.battery@1`) re-keys: its key binds the sources its gate bindings compute through, US keyed draws among them, and since microcosm#1585 those import `stochastic_assignment`. So NZ's terminal gate node re-keys, and so do the export, readback and package nodes that chain on it. No other NZ node and no US or BE node hashes an edited module or chains on one, so their node keys stay. The US seed protocol attests `stochastic_assignment` (microcosm#1585), so its and the seed map's digests move, with the US bundle's spec hash (later in #931 these pins are re-derived), and the US PUF-support builder's whole-tree resume fingerprint moves, as it does on any edit to packaged source. +- **Tests.** The fold is checked against a record-by-record statement of its contract on random frames; under every row order of a three-clone frame; per variant; on a frame without replicas; and on a two-clone frame whose clones all differ, which folds nothing and varies everywhere. Without `order` it keeps the earlier tests' rows and weights. The UK entry keeps clone 0 when every table lists its clones in reverse, and the id check gives `np.unique`'s verdict on random integer arrays of several dtypes and refuses timedeltas. The test that holds every folding stage to a live lineage now finds a stage through either UK entry. diff --git a/changelog.d/931-high-value-copies-own-areas.changed.md b/changelog.d/931-high-value-copies-own-areas.changed.md new file mode 100644 index 0000000000..5c44758f43 --- /dev/null +++ b/changelog.d/931-high-value-copies-own-areas.changed.md @@ -0,0 +1,6 @@ +High-value home support copies now take a place of their own, as another clone of their household would (#931; María's ruling of 25 Nov). After `high_value_home_support` splits the top value stratum, each copy gets its own `geography_household_key` over its copy path, read on the support channel's, its own and the geographic branches. Its area is drawn with `atomic_area_assign`'s definition from its own draw inputs, which are its parent's, so at its parent's level. Then it gets its local authority, its BRMA (Northern Ireland's copies draw theirs on their own benefit units after one engine call over their households alone) and its fuel-relief flag. On each Great Britain copy whose local authority changed, the bill, the rebate and the person council tax reduction `council_tax_localise` wrote at the parent's authority are multiplied by the new authority's 2024-25 Band D over the former one's, one correctly rounded product of exact rationals; the copy keeps its parent's draw cell, so this is the amount `council_tax_localise` gives it there. Northern Ireland's bills stay as they are. A copy's home value and every other column stay its parent's. Before, every copy kept its parent's key, area and council tax, so all copies of a high-value home sat in its clone's area, and in the K = 15 comparison the high-value areas that `uk_high_value_homes_support` assesses rested on fewer distinct source households than the copies could give them. + +- `uk_copy_area_agreement` now holds the high-value support copies to their parent's region and clone index alone, as it holds the support channel's copies. The CGT layers still hold their copies to their parent's key, area and council tax. The notes of `uk_stage_high_value_home_support_mass` and `uk_council_tax_reduction_within_bill` say what the stage now does, so the gates digest moves. +- The stage declares what it now reads: the FRS release, the local authority names, the BRMA layer and counts, the RFDR layer and both Band D resources; the Scottish Band D feed check; the engine predictor `LHA_category`; the operation `assign_high_value_copy_areas`, new in the sources schema and the manifest vocabulary; and its twenty rewrites. The split's `values` text says the copies are placed. Its evidence adds `copy_areas` and `council_tax`: among clone-0 rows, the distinct source households copied, by system, and those whose copies changed authority, rounded by the shared disclosure rules, with every system withheld where one rests on one or two. +- `uk_high_value_copy_area_mapping_integrity`, a new release-blocking stage-health gate at the transferred boundary, holds the stage's placement record (`copy_areas`) to the spine's geography block and re-derives the frame's areas on the pinned supports, as the area draw's and the SPI-copy stage's mapping gates do; it accepts `pass`, or `not_run` on a frame without a high-value copy. The mapping check reads a stage's record under the receipt key its new `evidence_record` parameter names, which the stage-health binding routes. `UK_SPINE_GATE_SCOPE` and `microcosm.data.contract` add the gate, and the battery's policy, manifest and fingerprint digests and the spine part's are re-pinned from the live producer. +- `spine_geography.place_uk_copies` is the copy placement the SPI-copy area stage and this stage share, and `spine_council_tax.relocalise_uk_council_tax` the rescale. diff --git a/changelog.d/931-inspection-export-solve-year.fixed.md b/changelog.d/931-inspection-export-solve-year.fixed.md new file mode 100644 index 0000000000..be87562287 --- /dev/null +++ b/changelog.d/931-inspection-export-solve-year.fixed.md @@ -0,0 +1 @@ +`--inspection-export` describes its export again (#931). The inspection kernel (`inspection_export.UKInspectionExportPrepareKernel`) called `graph_terminal.describe_uk_export` without the solve year that function requires, so a dense build with `--inspection-export` failed with a `TypeError` at the export description. The kernel now passes the export node's `solve_year`, as the export kernel does. The kernel's test stands in for the description with an autospec of the real function, so a call that leaves out an argument it requires fails there as well. Only the inspection kernel's hash moves; no other node key, declaration or generated file changes. diff --git a/changelog.d/931-isa-tied-balance-rank.fixed.md b/changelog.d/931-isa-tied-balance-rank.fixed.md new file mode 100644 index 0000000000..88c90cc62a --- /dev/null +++ b/changelog.d/931-isa-tied-balance-rank.fixed.md @@ -0,0 +1,9 @@ +The UK ISA subscriptions stage (`isa_subscriptions`) gives every holder tied on a balance one weighted mid-rank (#931; María's ruling 7 of 7 Nov). Half of each subscriber's ISA amount key, and of each Lifetime ISA payer's payment key, is the person's balance rank, blended with a keyed uniform. The rank sorted balances stably and gave each row its own mid-rank, so tied balances ranked by row position, although its docstring said ties share a rank. Ties are common: the copies and clone halves made after the WAS wealth draw carry their root's ISA totals, so a single-adult one ties its root, and QRF draws repeat a few atoms. A root sits before its copies in the table, so it ranked below them, as clone 0 would below its clones once the spine clones households at its start. The stage was also not invariant to row order where balances tie: on a synthetic walk of 400 holders with balances on five atoms, permuting the rows moved 372 amounts, and none with distinct balances. + +- **The rank.** `_weighted_rank(values, weights, ids)` orders the rows by (value, id). Every member of a tie group takes the group's mid-rank, `(F(x-) + F(x)) / 2` over the total weight. A value held by one row keeps its own, `(c - w / 2) / total`, computed as before. Both callers pass the person ids, so the keyed uniform alone orders tied holders, exchangeably, and each rank is the same bit for bit whatever the row order. +- **No seed; the notes say it.** The rank draws nothing, so no seed, salt or operation key changes. The stage's notes now say that tied balances share one weighted mid-rank, so the keyed uniform alone orders them, and that the Lifetime ISA payments, whose operation declares no rank weight, reuse the amounts operation's `balance_rank_weight` (María's ruling of 10 Nov: in the notes, not a declared field). The notes change in `sources.yaml`, `source_stages.json` and the H2 fixture's declarations; notes enter no stage contract, so the stage's contract hash does not move. The band walk and the Lifetime ISA strata stay pooled. +- **What moves.** Nothing where no balance ties: on three synthetic frames of distinct balances every output is unchanged, bit for bit. Elsewhere: + - Tied holders' ranks move. A singleton's rank is unchanged bit for bit wherever the rows arrive in id order, as the spine's tables do, but its amount can still move, since the band walk and the within-band order are pooled over the holders a tie moves past. + - On three synthetic frames with balances on five atoms, every tied holder's rank moved; 248 to 260 of the 363 to 376 tied subscribers and 329 to 344 of the 420 to 430 other subscribers moved amount; and 46 to 56 of the 52 to 68 Lifetime ISA payers, all of them tied, moved payment. No balance moved. + - With three geographic clones per holder on five atoms, clone 0 now gets the least of its three in about a third of the holders, against about 43 per cent (ISA amounts) and 40 per cent (Lifetime ISA payments) before. + - Of the 101 UK kernel hashes only `isa_subscriptions`' moves. Node keys move from `isa_subscriptions` on: 4 of the gated spine's 83 nodes and 36 of the in-graph build's 115. The national line on a bound spine keeps its keys. diff --git a/changelog.d/931-k15-spine-cell-deferrals.changed.md b/changelog.d/931-k15-spine-cell-deferrals.changed.md new file mode 100644 index 0000000000..6fbb638194 --- /dev/null +++ b/changelog.d/931-k15-spine-cell-deferrals.changed.md @@ -0,0 +1,5 @@ +The local line defers four more cells that the geography-first K=15 spine of #1538, built after the second review's fixes, leaves without a household (#931): the three-or-more-children Universal Credit cells (`dwp.uc.households_by_area_children_3plus`) of Bromsgrove (E14001138) and Stone, Great Wyrley and Penkridge (E14001523), under `uc_children_constituency_spine_support_absent`; Sandwell's band-G cell (`mhclg.council_tax_stock.by_area.band_g`, E08000028), under the new signed reason `council_tax_band_g_spine_support_absent`; and Rhondda Cynon Taf's band-I cell (`welshgov.council_tax_stock.by_area.band_i`, W06000016), under `council_tax_band_i_spine_support_absent`. The dense pool on that spine has no household in any of the four cells, so the rowwise driver's support check refused them, while the dense pool on main's route carried all four. The spine's SPI copies now draw their area by their band's weight, as FRS rows do, so none lands in Sandwell's band G. The deferral lets the spine be calibrated and compared with main's route, and the assignment's support for the four cells stays open under #931 (María's ruling of 28 November 2026). + +- **What moves.** The four cells leave the active local surface (27,155 to 27,151 references; 2,944 to 2,948 signed deferrals), and Sandwell's band-G uprating hold leaves with its cell (20,248 to 20,247 holds). In the local compile-parity receipt the three cells the incumbent carries turn from drift rows into fixture-only rows (19,272 to 19,269 drift rows, 4,269 to 4,272 fixture-only), Rhondda Cynon Taf's band-I row, which the incumbent never carried, leaves the receipt (7,879 to 7,878 ledger-only rows), and the UC child-bucket drift rationale now quotes 2,523 rows rather than 2,525; its spread holds. `tools/build_uk_ledger_compile_parity_signed_differences.py` reads the band-G reason beside the small-cell rules, so Sandwell's fixture-only row carries the rationale its deferral was signed with, as the UC seats' rows do. +- **What holds.** No other reference, membership record or parity row changes. No kernel hashes either tool. The regenerated resources feed the dense target nodes, not the spine, and the spine gate declarations do not move, so the spine built at f366de76f still binds. +- **Tests.** The local default surface's counts follow: 27,151 candidate targets and 4,196 reviewed exclusions; the 31,347 references hold. The council-tax band cells bind 2,508 references less the small cells, and the band-G and band-I support deferrals pin their cells. diff --git a/changelog.d/931-keyed-tie-breaks.changed.md b/changelog.d/931-keyed-tie-breaks.changed.md new file mode 100644 index 0000000000..a78b16cdd5 --- /dev/null +++ b/changelog.d/931-keyed-tie-breaks.changed.md @@ -0,0 +1,19 @@ +Six walks on the UK spine that ordered exactly tied rows by id now order them by an identity-keyed uniform, then by id (#931; accepted as designed on 7 Nov). Ties broken by id alone put the lowest id first every time, and the copies and geographic clones of one household differ only in their copy ordinal, so one copy ordinal won every tie: the first copy or clone at `property_components`, `cgt_support_split` and `hmrc_cgt_gains_spine`, and the last at `high_value_home_support`, which takes the top of an ascending order. On synthetic clone pairs the lower clone index ranked first in every tied pair, and in about half of them once ties are keyed. Values move only where an exact tie touches a cut or a position schedule. + +- **Shared helper.** `microcosm.build.stochastic_assignment.keyed_tie_order(primary, ids, *, seed, salt)` returns `np.lexsort((ids, u, primary))`, with `u` the records' `keyed_tie_uniforms(ids, *, seed, salt)`: `stable_identity_uniforms` of `integer_record_keys(ids, label=salt)`. It is a secondary sort key, the form `regional_home_values` already uses, so on distinct values the order is the id order's bit for bit; it draws the uniforms of tied records only. Each record is keyed on its own id, never on `spine_household_keys`, which strips the geographic branch and would tie the clones again, and the rank-inside-a-tie form is not used, since it moves records that have no tie off their cut. +- **`cgt_support_split`**: households tied on investable wealth, seed 0, salt `cgt_support_split:wealth_tie`. High-value families tie exactly on the four wealth columns, since no stage from 26 to 42 writes them. +- **`high_value_home_support`**: owners tied on home value before the weighted mid-rank, which is unchanged; seed 0, salt `high_value_home_support:value_tie`. +- **`property_components`**: landlords tied on profit in the receipts walk, under the walk seed and a new `tie_salt`, `allocate_property_rental_income:tie`. The stage refuses an empty tie salt and one equal to a salt its finance-cost draws key the same person ids on. The walk's one offset stays as it is (ruling 6). +- **`hmrc_cgt_gains_spine`**: one uniform per person under the stage's seed (552), salted `hmrc_cgt_gains_spine:rank_tie:`, drawn once per stage call and read by every cell walk, pooled walk, plan and the sub-AEA remainder, which take it as `_ranked`'s keyword-only `tie` (without it, person_id alone breaks ties, as before). The plans and the remainder walk the rank ascending, so a tie's member with the higher uniform takes the lower stratum. +- **`hmrc_cgt_asset_type_spine`**: the BADR walk and the main asset type walk, under the BADR seed (555), salted `assign_badr_qualifying_gains:tie:` and `assign_main_asset_type:tie:`. +- **Declarations.** The two support splits declare their tie-break as new `seed` and `salt` keys and the receipts walk its `tie_salt`, in the code dictionaries, the strict schema (three operations), `sources.yaml` and `source_stages.json`; the selection, stratum rule, order, ordering, mapping, realization and values texts, the stage notes and the receipts walk's and asset types' receipt order texts say the above, and "no draw, no seed, no salt" and "deterministic, no seed" are gone. The build sidecar's declared seeds register the splits under their salts and the receipts walk's seed under its tie salt. +- **`cgt_support_split`'s rule B.** The split's walk, `keeps_the_split`'s rerun of it and the identity tool's recompute all pass the declared pair (`cgt_support_tie_break()`); the selection takes no default, so neither the rerun nor the tool can walk ties in another order. The exact-total correction's candidate order (the heaviest households left whole first, tied weights in row order) is unchanged: it picks the row of a rounding-sized correction rather than drawing anything. `copy_rule` names the cap of 64 candidates and their order, heaviest first, tied weights in row order, so of a whole household's geographic clones, which weigh the same, the one in the earliest row is tried first. +- **No nesting promised.** All six walks are pooled. The uniform is a function of each row's own id, so clone 0's equals the `K = 1` row's and every clone draws its own. +- **What moves.** Nothing where no exact tie touches a cut or a position schedule. Elsewhere, counted on synthetic frames: + - At `cgt_support_split`, a band's crossing household when it sits in a tie group: with three clones per household, 2 to 8 of about 850 households per frame changed copy count, and clone 0, which carried the most families in all six frames, carries the most in one. At one clone none moved on those frames, whose synthetic tied families are light, most members at or under 60, the weight above which a selected household takes a second copy. Where a band's crossing falls in a tie group whose members weigh more, as a high-value family's can, the keyed order changes which members are copied at one clone too. + - At `high_value_home_support`, the tie group across a region's cut: 0 to 5 of 3,000 owners per frame. + - At `property_components`, no untied landlord changes band, since the same landlords sit above it in either order. Where a tie group shares one weight, as the copies of one household do, only its own landlords move: on three frames of six-row families, about two thirds of the tied landlords' receipts moved, none outside the tie groups, and the band counts held. Where a tie group of unequal weights straddles a band boundary, as different households reporting one profit do, the keyed order puts another tied landlord at the boundary. Tied landlords then cross it, the bands' record counts and masses change, and the receipts of the other landlords in the bands on either side move with them; inside a band whose members hold, a reordered tie group can still move later landlords' receipts by rounding. On three frames of 2,400 landlords, half of them on 60 round profits at weights that differ, 24 to 49 tied landlords changed band and the record counts of 4 to 7 of the 11 bands changed; no untied landlord changed band, and the receipts of 398 to 941 of the about 1,200 untied landlords moved, by at most about 0.3 per cent. + - At `hmrc_cgt_gains_spine`, often, since the blended rank key ties gainers even on distinct inputs: 43 to 99 of about 1,800 gainers moved amount where wealth varies, and none where it does not. + - At `hmrc_cgt_asset_type_spine`, nothing, since plan amounts do not tie (three frames bit for bit). + - Node keys: every spine node re-keys, since `stochastic_assignment` changed and the spine's root binds it; values move from `high_value_home_support` on. On a bound spine the national line re-keys 5 of its 6 nodes, all but the bound checkpoint, since the national target, problem and gate kernels hash the country spec, which this change edits. + - Regenerated: `source_stages.json`, the coverage manifest's 25 source digests, the H2 fixture's declarations and the five stages' contract hashes in `uk_spine.json`, and the 39 values of the synthetic facts its tool sizes to the frames `property_components`, `property_purchases` and `cgt_residential_split` read. diff --git a/changelog.d/931-national-one-clone-areas.changed.md b/changelog.d/931-national-one-clone-areas.changed.md new file mode 100644 index 0000000000..cb0a694dee --- /dev/null +++ b/changelog.d/931-national-one-clone-areas.changed.md @@ -0,0 +1,28 @@ +The national line builds on a geography-first spine of one geographic clone (#931). Every spine since #931 group (b) carries the geographic clone index, and the national line refused all of them; it now takes the spine #931 group (c) builds, one that assigns every household its area, at one clone, and refuses any other. It also refuses every build until the degenerate-surface register's `household.atomic_area_basis` exclusion is signed for the national line and in force on the build's review date. That entry lists the local line alone at this change, so no national build runs; the register decides, and signing the entry for the national line, with the contract re-pin, lifts the refusal with no code change. The #931 commit that follows signs that entry for the national line. A national build writes its release without the spine's geographic clone indices, which are constant at one clone, and with the area columns the spine assigns, the three area codes under the consumers' names; the gates that read what the release ships read that export. The release certifier holds the spine's geography binding to a release's, as the dense release pre-flight does, before any gate runs, and refuses a candidate that carries a clone index. + +- **The national problem** (`graph_national`). `refuse_clone_first_national_spine`, which refused every spine carrying the geographic clone index, retires. The national problem, the first national node that reads the bound frame, now reads the bound spine's build sidecar (`uk_spine_evidence`, which the bound checkpoint authenticates against its frame, and which the problem node now declares as a source), and before it reads its frame or resolves anything it refuses (`require_national_bound_spine`) a spine whose sidecar records a geographic clone count other than the int one, or whose roster lacks a geography-first name: a clone or area stage, the WAS chain's main-residence localiser, the geography block or one of its keys (`spine_posture.roster_failures`, the dense line's check). A sidecar that records no clone count describes one clone, as the checkpoint authentication reads it. The refusal is one sentence naming K and what the roster lacks, with no row count, id or value; a sidecar that is not a JSON object, unparseable bytes among them, is refused in one fixed sentence. `uk_national_graph` refuses a spine population that does not read its build sidecar. +- **The checks** (`spine_posture`). + - `require_national_spine(sidecar)` holds a bound spine's build sidecar to one clone and the geography-first roster, as above. `NATIONAL_LINE`, `NATIONAL_CLONE_COUNT` and `NATIONAL_AREA_EXCLUSION` name the line, its clone count and the entry it needs signed. + - `require_national_exclusion_signed(review_date, *, source=None)` loads the degenerate-surface register (the committed one, or `source`) through `load_uk_reviewed_exclusion_register` and requires `household.atomic_area_basis` to apply on the national line (`UKReviewedExclusion.applies_on`: an entry that names no line applies on every one) and to be in force on the review date, neither expired (after its `expires_on`) nor premature (before its `approved_on`), as the gates read the register. It takes the review date as a `datetime.date` and reads no clock of its own. Its refusals name the exclusion, the national line and the entry's window, and nothing else: a missing entry, an entry not signed for the national line, an expired one and one not yet in force each have their own sentence. +- **The national preparation** (`full_build_cli.prepare_national_build`). After the engine freeze it refuses, on `--review-date`, the build's own review date (the date the national graph's target and gate nodes evaluate their registers on), an entry that is not signed for the national line or not in force, before any input is read. No gate of the national build reads this register; the release cut reads it again, on the day it certifies, and fails there on an entry that has lapsed since. The preparation then reads the bound spine's build sidecar, before the input is pinned, and refuses a spine of any clone count but one, naming K, or one whose roster is not geography-first; it checks the sidecar the checkpoint authentication returns again, so one changed since the first read is refused too. Every refusal comes before any engine work. A dry run, which takes its graph inventory from the same preparation, is refused there too, after its own reads of the input and the targets. A refused build records its attempt as failed, with the refusal as its message. +- **The national export** (`national_frame`). `UK_NATIONAL_EXPORT_DROPPED_COLUMNS` names each entity's geographic clone index (`person_clone_index`, `benunit_clone_index`, `household_clone_index`), and `uk_release_export_dropped_columns(line)` gives what the release boundary drops on a line: the reviewed export exclusions on every line and, on the national line, the clone indices after them. `uk_release_export_frame` takes that line as a keyword, a gate context's `release_line` (`"national"`, `"local"`, or none); without a line, or on the local line, it drops what it did before, and it refuses a line the gates do not know. The three area codes leave under the consumers' names on the national line as on the dense one. A frame that already left on a line now passes that line's boundary again unchanged when it carries the consumer names, as a national release with areas does (it raised before, as a table carrying a stale consumer name); a household table carrying both a ladder and a consumer name is still refused. The national writer (`full_build_cli`) and the graph's readback of the written H5 (`graph_national`) write and expect the national line's export. The comment on the release boundary's drop of `main_residence_value_rank_basis` now describes the WAS chain's kept draw. +- **The gates** (`battery_bindings`). The degenerate-surface gate skips what the context's line drops at export, so a national frame fed to it before export does not fail on its constant clone indices; the national line runs that gate only at the release cut, on the exported candidate, which carries none. A gate that checks a declared stage output reads the columns the context's line drops off the certifier's spine frame (`_export_dropped_columns_from_spine`), so the release cut's nonnegative gate checks the national candidate's clone indices there. The release input coverage and input-mass parity gates read the export of the context's line; the coverage gate, which also runs the preflight's manifest check, reads the line as declared and leaves its check to the export. +- **The certifier** (`release_certification`, `tools/certify_uk_release_cut.py`). The certification composer refuses a spine whose build sidecar does not record one geographic clone (a sidecar that records none describes one) or whose geography block is not a release's, by the helper the dense release pre-flight uses (`country_adapter.uk_spine_geography_binding_failures`, here at K = 1): the atomic law, the geography key, a SHA-256 definition digest, exactly the conditioned supports `sources.yaml` registers, the spine's area stream and the register's name. A sidecar without a geography block is refused as recording none. The certifier tool refuses a spine build sidecar whose bytes are not the ones the build record's `spine_provenance.sidecar.sha256` names, then runs the composer's geography check on it, both before any gate reads it, so a spine the check refuses costs no release-cut battery and leaves no signed release-cut report; the composer checks it again. The tool also refuses a candidate that carries any entity's geographic clone index, which the national line's export drops and which the release cut's degenerate-surface gate, skipping what the national line drops, would not report. The refusals name fields, columns and K only. +- **Texts.** `rfdr_area_layer`'s module docstring no longer says the national line keeps the engine's fuel-relief default, and `geography_first_roster`'s names the national line beside the dense one. Three test texts that described the national line as it was before this change follow: the K-sensitive table's zero-weight strata reason, a rules-engine provenance comment and a terminal-graph comment. +- **What moves.** Until the entry is signed for the national line, no national build runs. Before this change none ran on a spine from #931 group (b) on; a spine from before group (b), which carries no clone index and which the national line still built on, is now refused as not geography-first. Once the entry is signed, values move in a national build only: its release carries the spine's area columns and no clone index, so its council tax reduction, LHA, private rents, home values and fuel duty for households in a relief area follow the spine's areas, as ruled (decision 4 of 4 Nov; item 4 of 6 Nov), and the fuel-relief flag replaces the engine default of false the national line kept while it had no areas (María's ruling of 28 Oct). No national build has measured them. No value moves on the dense line: the release export without a line gives the frame it gave before on every invented frame checked, and the dense line's gates read the local line's export, which is the same. Keys, measured engine-free on code and invented data against a snapshot of the parent commit: + - UK kernels: 84 of 88 move, and none hashes a module it did not hash before. `national_frame`, which all 62 kernels of the spine registry and 21 other UK kernels hash, moves those 83: the spine registry's 62, `uk.spine-gates@1`, `uk.full-gates.preflight@1`, `uk.full-gates@1`, `uk.full.bound_spine@1`, `uk.full.calibrated@1`, `uk.full.dense@1`, `uk.full.measures@1`, `uk.full.pool@1`, `uk.full.problem@1`, `uk.full.rotated-holdout@1`, `uk.full.selected@1`, the four size kernels, `uk.full-export.prepare@1`, `uk.full-export.prepare-inspection@1`, `uk.full-export.readback@1`, `uk.full.national_problem@1`, `uk.full.national-gates@1` and `uk.full.national-readback@1`. Among them, `battery_bindings` moves the four gate kernels as well, `release_certification` the bound spine checkpoint, `geography_first_roster` the eight geography-first stage kernels and `rfdr_area_layer` two of those (`uk.stage.rfdr@1`, `uk.stage.spi_copy_areas@1`). `graph_national` moves the four national kernels, `uk.full.national_targets@1`, which hashes no other module this change edits, among them. `uk.full-export.package@1`, `uk.full.certification-readiness@1`, `uk.full.target_compilation@1` and `uk.full.target_selection@1` do not move. + - Graphs: every node re-keys, in the spine (90 of 90; split at four clones, 90 of 90; the bundle, 88 of 88), dense on the in-graph spine (100 of 100), dense on a bound spine (11 of 11; 15 of 15 through the export, package and certification-readiness nodes, the last two by chain alone) and national on a bound spine (7 of 7 with its readback; the national problem also by the sidecar source it now declares). Each spine node re-keys by its own kernel's hash, since every spine stage kernel hashes `national_frame`. With `national_frame` held at the parent's bytes, 75 of the spine's 90 nodes and 85 of the dense composed graph's 100 would still re-key, from `geographic_expand` on (`geography_first_roster`, and `battery_bindings` at the spine gates); `national_frame` alone re-keys the 15 nodes before it, `create_uk_frs` through `frs_annual_income_spells`. `release_certification` re-keys the bound checkpoint and so every node on a bound spine, and the calibrated gate node moves by its `terminal_code` parameter too. No value moves, and the gate declarations, which the strict loader holds a stored gate report to, do not move. Gate phase codes: the full battery's terminal code moves (it hashes `release_certification`); the preflight code and the spine's assembled and transferred codes do not. + - Not moving: the stage contracts, the UK country and solve fingerprints, the UK spec-engine wire and bundle lock, and every generated file and contract pin (the H2 fixture tool's `--check` regenerates byte for byte, and the coverage manifest and `source_stages.json` read current). Outside the UK no key moves: the 48 transport kernels and the shared transport registry, NZ's 27- and 31-node graphs (with the toy donor digests held fixed, since freshly written toy donors move them between two runs on the same parent) and the NZ battery's sources, the six US kernels and the eight-node US post-transfer graph, the F0 registry, and the AM, BE, NZ and US fingerprints, resource hashes, spec-engine wires and bundle locks. +- **Tests** (invented data, the seam suite's stand-in frame, its clone-first copies at one and three clones, the stand-in geography-first sidecar, and test registers with invented dates; one test reads the committed register as it stands, on a fixed date inside its entry's window). + - The national problem refuses a bound spine of three clones naming K, and a one-clone spine whose roster is group (b)'s naming the six area stages it lacks, the localiser and the geography block; it encodes its problem on a one-clone geography-first spine that carries the clone index; its node declares the sidecar it reads, and a spine population that reads none is refused. Its helper refuses a sidecar that is not a JSON object, unparseable bytes among them, in one fixed sentence, with no position from the parser's message and no figure but the issue's number. + - `require_national_spine` passes a geography-first one-clone sidecar, with or without a recorded clone count, and refuses another K, a K that is not an int, a roster from before the area stages and a sidecar that is not a JSON object, naming K and missing names only. + - `require_national_exclusion_signed` passes an entry signed for the national line, or naming no line, on its window's first and last days and inside it; refuses an entry on the local line alone, an expired and a premature entry and a register without the entry; refuses a review date that is a `datetime`, a string or None; and its refusals name the entry, the line and the window only. The committed register as it stands is refused on a fixed date inside its entry's window; the commit that signs the entry for the national line flips that test. + - Through `prepare_national_build`: an unsigned entry refused before the input exists; an expired and a premature entry refused; a spine of three clones and a spine from before the area stages refused before the input is pinned; the authenticated sidecar checked again; and a signed entry, on its window's first and last days and inside it, preparing a one-clone geography-first spine, the check evaluated on `--review-date` and the problem node reading the sidecar. No national preparation test reads the wall clock. + - The national role end to end: on a one-clone clone-first spine whose every entity carries its clone index, the build solves, its H5 carries none of the three, and the graph's readback passes; on a test register whose entry lists the local line alone, a build is refused with the refusal as its failure message, a failed row and a failed run and no build record, and a dry run is refused with no plan printed. The national role's suite now runs on a fixed review date, the latest approval across the committed registers (`committed_registers_review_date`, moved to `test_support/microcosm_build/uk_full_build_cli.py` from the national graph's tests), never the wall clock. + - The national graph's and the national role's stand-in sidecars record the stand-in geography-first roster and block at the frame's clone count, and the national role's end-to-end tests stand the exclusion check in as signed (`stand_in_signed_national_exclusion`) except where they test its refusal; `write_national_exclusion_register` and `use_national_exclusion_register` in `test_support/microcosm_build/uk_full_build_cli.py` write a test register and hold the preparation's check to it. + - The derived binding rule lists `require_national_bound_spine` as refusal-only in place of the retired helper. + - The national export (the stand-in geography-first spine at one and three clones): the drop list names each entity's clone index and the export takes the gate contexts' lines, refusing any other; the national release of a one-clone spine carries no clone index and keeps every lineage and area column value for value, the three area codes under the consumers' names; without a line and on the local line the export is one frame that keeps the clone indices, and the national one differs from it by the three indices alone; a released frame with areas passes the boundary again on any line, before and after the H5 round trip, and a household carrying both a ladder and a consumer name is refused; the graph's readback passes a calibrated one-clone spine's H5 written as the national line's export, and fails one written with the clone indices kept. + - The national allow-list pin: every lineage and area column the national release of a one-clone spine keeps, and every column it adds to the export surface, is in `UK_ALLOWED_EXTRA_EXPORT_COLUMNS`, with no list change; the clone indices stay listed for the dense line. + - The battery, on an invented one-clone frame before export: the degenerate-surface gate passes with the line-aware drop on the national line, and fails all three clone indices on the local line, with no line, and with the shared list alone on the national line; the spine frame answers the clone indices on the national line only, so the nonnegative gate checks a national release's indices there and fails them as missing without the national line or the spine; the coverage and input-mass gates read the export of the context's line; the coverage gate refuses a line the gates do not know. + - The certifier: one refusal per failure class of the binding check on the sidecar's block (the law, the identity, the definition digest, a support pin's digest and its size's type, a missing and an extra system, the stream's seed and its type, the register), a clone count that is not the int one, a block that is absent, null, empty or not a mapping (with K named where it is not one), and a binding held to a register whose supports are not the spine's; a sidecar without a clone count reads as one clone; no refused certification is written. The green certification fixture's sidecar carries the stand-in spine's one-clone binding under the register `patch_support_register` puts in place. + - The certifier tool refuses a sidecar rewritten since the calibration recorded it, and one the build record records none for; refuses a spine of three clones, and one that records no geography binding, by the composer's sentence; does all of this before the Ledger read, so no release-cut report is written; goes on to the Ledger read with the recorded sidecar and its stand-in binding; and refuses a candidate that carries any one entity's clone index, naming the column, and takes one that carries none. diff --git a/changelog.d/931-receipts-count-source-households.changed.md b/changelog.d/931-receipts-count-source-households.changed.md new file mode 100644 index 0000000000..d2eb05fcfc --- /dev/null +++ b/changelog.d/931-receipts-count-source-households.changed.md @@ -0,0 +1,15 @@ +The UK stage receipts that counted rows after `geographic_expand` now count distinct true source households, a household's copies and geographic clones once, through `receipt_counts` (#931). A count of a drawn or copied group reads geographic clone 0's rows, through the new `receipt_counts.record_clone_zero_rows`, so it is the count a one-clone spine gives. A count of rows that break a check counts source households over every clone, so a break in any clone still fails it. + +- **Trading allowance.** `traders`, `claimants` and the full-relief group's `records`. +- **Company cars.** The holders by channel and without EPB, the fuels drawn, the list-price routes, the SPI carve-out's counts, the carved rows' UC gainful self-employment and the FRS holders without pay; `draw_list_prices` and `carve_spi_benefits` take `sources` and `counted`. The checks' violations count source households over every clone (`_violations` takes `sources`), and the stage check's failure text names them. +- **UC take-up.** The drawn, Northern Ireland, moved, legacy-kept and changed units read clone 0's units, and `reporters_not_claiming` and `changed_outside_draw` every clone's; `assign_award_band_take_up` takes `counted`. +- **ISA subscriptions.** The balance split's households, the selected, limit, taper and Lifetime ISA records and the subscribers above their balance. The recipient table carries each person's source household and whether its row is clone 0's, and `scale_to_build_year_amounts` takes `sources` and `counted`. +- **SPI employment shell.** The training's `people`, which repeated its `source_households`, is gone. The drawn rows' counts (`source_households`, in place of `people`, `twin_had_an_occupation`, `newly_coded` and `kept_no_occupation`) and the industry copy's restricted draws and donors of another status group read clone 0's rows, and the held-out industry copy counts its adults without a donor in source households. +- **APS occupation.** The drawn `people`, which repeated `source_households`, is gone, and the SPI income recipients count source households. +- **SPI income stage.** The pay floor's eligible rows left below their floor count source households over every clone. The rank transport's uniformity receipt measures clone 0's recipients, counts their positive rows in source households and gives a group only where clone 0's rows meet the statistical floor and three or more source households carry them; `cross_fit_transport` and `transport_uniforms` take `sources` and `counted`. The SPI channel's carer link counts each route's carers in source households among clone 0's rows (`frs_disability.derive_carer_link` takes `counted`); on `frs_disability`, before any copy, it counts people as before, with each person's household read through `receipt_counts.own_source_households`. +- **CGT gains spine.** A band's gains-wealth correlation is given only where three or more source households carry its persons, else `<3`, and stays out of the mean. `cgt_imputation` reads `receipt_counts`, so the six CGT stages that bind it join the counting stages. +- **Other stages.** `frs_take_up`'s units claiming the extended hours without the universal hours, the LCFS excise shares the clip held (`clip_excise_shares` takes `sources`) and the gambling households added without a stake count source households over every clone. UC capital's sentinel units beside recorded property, UC limited capability's claims, branches and changed people, and PIP's recipients, countries, awards and fallbacks read clone 0's rows; `draw_pip_points` returns which people fell back. The take-up and gambling stage checks' failure texts name source households. +- **Declarations.** `trading_allowance_receipts`, `pip_points`, `isa_subscriptions` and `hmrc_cgt_gains_spine` declare `source_household_id` and `household_clone_index`, which their receipts now read. +- **Checks on the code.** The static scan of distinct counts follows a `households` field and either branch of a conditional. The constants table counts the SPI transport's group minimum in clone 0. +- **What moves.** No frame value and no gate verdict. A receipt count can fall where one household holds several of the people or units it counts, at one clone too. The edited modules' stages re-key, and so does every stage that binds `receipt_counts`. +- **Tests** (invented data). Each changed receipt at one and three clones, where three clones give the one-clone counts, and the scan's new forms. diff --git a/changelog.d/931-refusals-name-no-counts.changed.md b/changelog.d/931-refusals-name-no-counts.changed.md new file mode 100644 index 0000000000..711a315e28 --- /dev/null +++ b/changelog.d/931-refusals-name-no-counts.changed.md @@ -0,0 +1 @@ +The refusals the clone-first move added or reworded name their condition and its columns, with no count of rows, households or ids (#931): `geographic_identity`'s unpinned source year and repeated geography keys; the executor's new rows without an incumbent parent (`graph_kernels`); the row-wise cloning's repeated and overflowing ids (`rowwise_geography`); the SPI support channel's donor, link, uniqueness, selection, source and clone-index checks (`spi_support`) and the row-wise dataset's matching table checks (`rowwise_dataset`); and the CGT redraw's persons without a household weight (`cgt_imputation`). Every refusal keeps its condition. diff --git a/changelog.d/931-release-spine-package-pins.changed.md b/changelog.d/931-release-spine-package-pins.changed.md new file mode 100644 index 0000000000..60c7b06b91 --- /dev/null +++ b/changelog.d/931-release-spine-package-pins.changed.md @@ -0,0 +1,9 @@ +A release candidate on a bound spine, and the national certifier, hold the spine to the package they run from (#931). Before the move, a dense release candidate refused any localisation resource other than the committed package file (the knots, the band mixes, the BRMA and RFDR layers, the rent resources). The spine reads those now, and its build sidecar records each one's pin, but nothing held the recorded pins to the package: a spine built at one commit bound as a release candidate at a later commit that changed only a resource, with values from the old files. The binding's `definition_sha256` was held to its format only. + +- **Package pins** (`spine_build.uk_spine_package_pin_failures`, with `uk_spine_package_pins`, which reads the package through the sidecar writer's own helpers). The sidecar's `resource_pins` and `stage_artifact_pins` must be, entry for entry, the package's for the stages it records, and each of those stages one the package declares. A failure names the field, the stage, the resource or the artifact, and never a digest, a size or a locator. +- **The area definition** (`country_adapter.uk_spine_definition_failures`). The definition the spine's area draw builds on the conditioned supports at its declared seed is composed again, with the helper the sidecar writer calls, and the block's `definition_sha256` must be its digest. A zero or invented digest fails, and so does one of a definition that another commit's code composed. The digest is a function of the supports' bytes, so the check takes them; `uk_spine_geography_binding_failures` still holds the digest to its format only, as the dense release pre-flight reads it. +- **The supports' flags** (`spine_build.SPINE_SUPPORT_FLAGS`): `--spine-support-ew`, `--spine-support-scotland` and `--spine-support-ni`, the files the spine took as `--atomic-support-*`. They bind nothing, so they are not those retired dense flags. Each file is held to `sources.yaml`'s conditioned register (`spine_build.registered_atomic_support_payloads`, which the spine build now reads its own supports through, under its own flags). +- **The dense build.** `--release-candidate` with `--input-h5` now requires the three flags, read before any input is pinned, and `_require_release_candidate_spine` adds both checks to its refusal on a bound spine. A spine request composes its block and its pins from the package and its own supports, so it takes neither. Any other dense build refuses the flags, and so does the national role. +- **The national certifier** (`tools/certify_uk_release_cut.py`) takes the same three flags, holds them to the register and refuses, before any gate runs and after the geography binding check, a sidecar that fails either check (`_verify_spine_package`). `tools/run_uk_cut.py` passes it the supports the spine read, from `inputs/atomic_area_supports/`. +- **What moves.** Refusals only, under `--release-candidate` and in the certifier: no network request, no change to staging or publishing. `full_build_cli`, `rowwise_cli`, `spine_build`, `country_adapter` and the two tools are hashed by no kernel, so no node key moves. No declaration, generated file or `gates.json` changes. The dense and national assembly runbooks and `docs/uk-cut-anyone.md` name the new flags. +- **Tests** (invented data and the toy supports): on the dense preparation's stand-in spine and on the certifier's stand-in inputs, a zero digest and a resource pin or a stage artifact pin overwritten as another commit's are refused, naming the field and the resource or artifact; so is a missing resource pin in the certifier. Missing supports, a support off the register and support flags on a build that reads none are refused by flag before the spine is read, and the national role refuses them by name. The recompute passes the toys' own block and refuses a zero digest and the digest at another seed. diff --git a/changelog.d/931-retire-legacy-national-sampler.removed.md b/changelog.d/931-retire-legacy-national-sampler.removed.md new file mode 100644 index 0000000000..32b98f2083 --- /dev/null +++ b/changelog.d/931-retire-legacy-national-sampler.removed.md @@ -0,0 +1 @@ +Retire the UK national compact sampler, `sample_uk_national_frame`, and its source-family decoder, `uk_source_family_units`, from `microcosm.build.uk_runtime.national_sampling` (#931). The sampler drew rungs from the certified national compact. The decoder recovered each derivative row's source from retired id arithmetic: a clone multiplier of ten to the digit count of the largest canonical id, and SPI and capital-gains offsets of the largest raw and pre-capital-gains household ids plus one. No build or tool has called either since 8adc836b9 (#762) moved the row-wise candidate onto the spine sampler. Their private helpers go with them: the post-sample SPI replacement quota check, the required-column list and the clone-index column name. The module also leaves the copy-id tests' inline-rule allowlist, which now admits only `rowwise_geography` (the dense line's multiplier) and `copy_id_table` (its field spans). The spine sampler (`sample_uk_spine_frame`, `uk_spine_source_family_units`), the rung tokens and the default sampling seed are unchanged here; that sampler, which drew the dense line's source families, retires later in #931, when the dense line takes its sampling from the spine it binds. The tests of the retired functions are removed, and the numeric-region refusal they covered is now tested on the spine sampler. No value moves. The full build's population nodes that hash the module (`uk.full.sample`, `uk.full.normalize`, `uk.full.expand`, `uk.full.locations`, `uk.full.geography_mapping`, `uk.full.pool` and `uk.full.geography_gate`) re-key, and with them every node downstream of `uk.full.sample`. No spine node re-keys, and no generated file moves. diff --git a/changelog.d/931-shared-cell-expectations-and-bounds.added.md b/changelog.d/931-shared-cell-expectations-and-bounds.added.md new file mode 100644 index 0000000000..0153c27160 --- /dev/null +++ b/changelog.d/931-shared-cell-expectations-and-bounds.added.md @@ -0,0 +1,30 @@ +Two country-neutral helpers, shared for Max's review and imported by nothing yet (#931): the exact expectation of an area code's value under a conditioned draw cell, in `microcosm.build.atomic_support_expectations`, and amounts held within a bound each record carries, in `microcosm.build.bounded_amounts`. The UK's council-tax localisation will call both: the first for each household's reference over the cell its area was drawn from, the second for the check that a reduction stays within its bill. + +- **`draw_cell_expectations(support, households, *, constraint_columns, weight_by, default_weight, value_column, values)`** takes `choose_fallback_levels`' arguments but the ladder, with each household's inputs already at the level it is drawn at, and returns one exact `Fraction` per household, in row order: the mean of `values` over the household's cell, weighted by the column it samples by. `values` are ints or Fractions keyed by the codes of `value_column`, a support code column. + - It reads the inputs as the shared draw does. A present constraint input is an exact-match constraint on its support code column, and a missing one is skipped, as the draw skips an input declared `required: false`. The household samples by the weight column the rule maps its code to where the code is present, and by `default_weight` where it is missing or no rule is given. + - The integer weights are summed by cell and `value_column` code, each sum is multiplied by its code's value, and the total is divided by the cell's mass once. A code without mass in the cell is not read. It is vectorised, with one grouped mass table per set of constraints present and one expectation per distinct cell and weight column. + - Refusals name declared columns only, never a count, a household, a code or a value. It refuses `constraint_columns`, `weight_by` and `default_weight` as the chooser does; a `value_column` that is not a support code column; values that are not ints or Fractions, a float or a bool among them; a frame that lacks or repeats an input column; a present input that is not a nonempty string without surrounding whitespace; a present code the rule does not map, which the draw also refuses; a household whose cell has no support row, or no mass in the weight it samples by; and a code with mass in a household's cell but no value. +- **`amounts_within_bound(tables, *, entity, id_column, bound_column, same_entity_columns, member_columns, membership_columns, absolute_tolerance)`** returns one boolean per named amount column and `finite_nonnegative`. + - Each column's boolean says whether every record's amount is at most its bound plus the tolerance. The amount sits on the record itself, or on its members, summed to the record through their membership column. + - `finite_nonnegative` says whether every value read of the bound and of the amounts, member rows included, is finite and nonnegative, so any NaN, infinite or negative value fails it. A missing value reads as NaN: a NaN amount fails its column, and a NaN bound fails every column. An amount of plus infinity fails its column unless its bound is plus infinity too; minus infinity, like any amount at most its bound, passes it. + - Exclusions are the caller's: a check drops the records it leaves out, with their members, before calling. Refusals name tables and columns only, never an id, a value or a count. +- **Nothing calls them yet, and no key moves.** Neither module is imported by a stage, kernel, gate, tool or other module, so no node binds either. +- **Tests**, on invented supports and tables only. + - `tests/engine_free/shared/test_atomic_support_expectations.py`: + - expectations worked by hand, which the region's mean, the cell's unweighted mean or the mean by another weight column would miss; + - a missing input skipped and the default weight used, whether the frame holds it as None, NaN or pd.NA, in object, StringDtype (either storage), pandas' `str` or category columns; a missing input never matches a code spelled like a missing value; + - inputs follow `constraint_columns`, the default weight is the declared column, two codes sharing a weight column both read it, and a code without mass in the cell needs no value; + - at the decoder's whole weight range the expectation stays exact, equal to no float and to no fraction with a smaller denominator recovered from one; + - two Hypothesis properties: the expectation equals a loop over the support's areas, and it equals the expectation built from the shared draw's own integer cumulative table for the household's cell and weight column, over which the drawn area's value divided by a nonzero expectation averages exactly one. Where the loop or the draw refuses a household, the helper refuses it; + - a draw that takes the value code first, by the same weight column, has the same expectation, read from the shared draw's own table at the code's level; + - the vectorised result equals one household at a time, and shuffling the households or the support's areas changes no household's expectation; + - each refusal, with no digit in its text. + - `tests/engine_free/shared/test_bounded_amounts.py`: + - amounts at the bound pass, and just above it fail; + - the tolerance is honoured, and a two-member sum above the bound fails; + - members count toward their own record only; + - NaN, infinite and negative values fail `finite_nonnegative` wherever they are read; a NaN or plus-infinite amount fails its own column, and a negative one, minus infinity included, does not; a missing value reads as NaN; + - integer columns and tables without rows are read, and exclusions are the caller's; + - the verdicts do not depend on row order, and several member tables report in the order named; + - each refusal, with no digit in its text. + - The expectation test reads the shared draw's private cumulative table, so a change to `atomic_geography`'s draw can fail it. diff --git a/changelog.d/931-shared-clone-expansion-core.added.md b/changelog.d/931-shared-clone-expansion-core.added.md new file mode 100644 index 0000000000..22cd6e0456 --- /dev/null +++ b/changelog.d/931-shared-clone-expansion-core.added.md @@ -0,0 +1,28 @@ +A country-neutral clone expansion core, `microcosm.build.clone_expansion` (#931; shared now, as María ruled on 10 Nov). `expand_clones(frame, clones=K, declaration=...)` turns a frame into K clones of every record, clone-major. Clone 0 is the frame's own rows with their ids, and clone `k` repeats them with every id minted by the country's rule. The module names no country's columns, tables or constants: it reads each entity, id column, membership column and weighted entity from the frame, and the country passes the rest in a `CloneDeclaration`. + +- **Declarations.** + - A `CloneIdRule`: the most clones the rule numbers (`bound`), `mint(ids, k)` for clone `k`'s ids in the ids' own dtype, and `require_below(ids, what)`, which refuses incoming ids the mint has no room for. + - A clone-index column for every entity. + - The weight kinds the expansion accepts. + - The mass records' reason, declared once, so it is the same at every K. + - Optionally, a column per entity for each row's id before the expansion. + + A declaration compares and hashes by identity. +- **What the clones carry.** + - Each entity's ids are minted for clones 1 to K - 1, and a person's membership in clone `k` is its unit's clone-`k` id. Every other column is copied unchanged. Ids and memberships keep their dtype at every K. + - Each row carries its clone ordinal, with exactly K values on every entity, and, where declared, its clone-0 id. + - Every weighted entity's weights become `numpy.tile(w / K, K)`: one float per row of the frame, the same in each of its clones, of the entity's kind. Strata repeat once per clone and metadata is kept. + - The mass log gains one record per weighted entity, in the frame's entity order, with factor 1.0 and the declared reason. Each entity's clones' total must equal the frame's within a relative 1e-9. + - At K = 1 the rows, ids and weights are the frame's own; only the declared columns and the records are added. +- **Refusals.** Each names entities, columns, dtypes, weight kinds and declared constants only, never an id or a weight. The core refuses: + - a clone count that is not an integer in `[1, bound]`; + - a declaration that names an entity the frame lacks, or gives one of its entities no clone-index column; + - a frame that already carries a declared column, or carries a link table; + - weights, on any entity, of a kind the declaration does not accept; + - ids or memberships that are not numpy integers, memberships in another dtype than their unit's ids, and ids the rule's `require_below` refuses; + - a mint that does not return one integer per id in the ids' own dtype, does not keep the ids' order, or does not put every clone's ids above the clone before's. +- **Not covered yet.** Link tables and a different number of clones per record. These wait for a caller that needs them. +- **Tests.** + - `tests/engine_free/shared/test_clone_expansion.py` runs the core under neutral and US-shaped declarations on invented frames. The US-shaped frame weights households and people, each split with a record of its own, and its clones, labelled from their clone index, pass the shared two-channel invariant `outer_stage_runtime.assert_clone_expansion`. Narrow ids keep their dtype at every K, and each refusal, the dtype ones included, is checked to print no id or weight. + - `tests/engine_free/uk/test_uk_clone_expansion_core.py` runs it under the UK's declarations: the copy-id table's `geographic_support` mint and `require_below`, the ladder's clone-index columns, `source_household_id`, and design weights on households. At K = 1, 2, 3, 7 and 15 it reproduces the clone-first stand-in `clone_first_frame`, which is written without the core, bit for bit on the ids, the household clone index, the source household id and the weights. +- **First caller.** The UK's geographic expansion step (`microcosm.build.uk_runtime.geographic_expand`, G1 of the clone-first spine) calls the core with the UK's declaration, `UK_GEOGRAPHIC_CLONES`. Its mint and its `require_below` are named functions in that module that call the copy-id table, so the derived binding rule binds the table to the key of the stage that runs the step. The UK test above now takes that declaration from the step instead of keeping a copy of its own. The spine's `geographic_expand` stage runs the step, at one clone until the spine build takes a clone count, and binds the core into its key (`931-uk-spine-geographic-expand`). diff --git a/changelog.d/931-shared-fallback-level-chooser.added.md b/changelog.d/931-shared-fallback-level-chooser.added.md new file mode 100644 index 0000000000..054a0106ae --- /dev/null +++ b/changelog.d/931-shared-fallback-level-chooser.added.md @@ -0,0 +1,16 @@ +A country-neutral fallback-level chooser for conditioned area draws: `FallbackLevel` and `choose_fallback_levels` in `microcosm.build.atomic_support_conditioning` (#931; shared, for Max's review). The shared draw (`assign_atomic`) refuses a household whose constraint cell has no sampling mass in the weight it samples by. A country that conditions its draw, as the UK geography-first draw will on the deprivation decile and the council-tax band, declares a fallback ladder instead, and the chooser picks each household's level before the draw. + +- **Declarations.** `FallbackLevel(name, constraints, weight_by)` names the household inputs a level keeps as exact-match constraints, and says whether the level samples by the weight chosen for each household (`weight_by=True`) or by the default weight. `choose_fallback_levels(support, households, *, constraint_columns, weight_by, default_weight, levels)` takes the decoded support, a frame of household inputs, the support code column each input must match, the per-household rule `{"input": ..., "map": {code: weight column}}` (the draw's `weight_by` without its default) or `None`, the default weight column, and the ladder in order. +- **The rule.** Each household takes the first level whose inputs are present (every constraint the level keeps and, where it samples by the household's own weight, a code the rule maps) and whose cell, the support's areas matching the household on every kept constraint, has positive summed mass in the weight the household samples by there. It returns each household's level name, in row order. A draw that keeps a household's level's inputs, reads every other input as missing and samples each stage by the same rule then meets no empty cell. The chooser is vectorised, with one grouped mass table per level, read for the households no earlier level took. +- **Refusals.** + - A household no level takes is refused with one fixed text that names no count, household or value. + - A present input that is not a nonempty string without surrounding whitespace is refused, as the draw refuses it. A households frame that repeats an input column is refused with a fixed text. + - A declaration is refused where a level keeps an input `constraint_columns` does not map, a level samples by the household's own weight but no rule is given, an input maps to the area or to a column that is not a support code column, two inputs map to one column, a weight is not a support weight column, two levels share a name, or the rule's input is also a key of `constraint_columns`. The draw samples by a present code's weight at every level, so a level could not keep such an input and sample by the default weight, nor drop it and keep the household's own weight. +- **No caller yet, and nothing moves.** The chooser names no country, and nothing calls it until the UK geography-first draw. (Later in #931 the spine's `atomic_area_assign` calls it: `931-spine-assigns-areas`.) No node binds the module: no transport kernel (the shared kernels New Zealand's graph runs on, the atomic geography and rules kernels among them), no UK graph kernel or gate battery phase, and no transport binding's source closure hashes it, and no US module imports it. So no node key moves. +- **Tests.** `tests/engine_free/shared/test_atomic_support_conditioning.py`, on invented supports only: + - a household whose band has mass in its cell takes the first level, one whose cell has households but no banded mass takes the second, and a missing decile falls to the region-only levels, whether the frame holds it as None, NaN or pd.NA, in object, StringDtype, pandas' `str` or category columns; + - two codes that share one weight column both read it, and of two identical levels the first is taken; + - the default weight is the declared column, each input matches the support column `constraint_columns` names for it rather than a column of its own name, and a missing input never matches a support code spelled like a missing value; + - a household no level takes, and a frame that repeats an input column, are refused with count-free texts; + - on 3,000 invented households the vectorised choice equals a per-row loop over the support's arrays, and again under a shuffled row order; + - two Hypothesis properties on small invented supports and ladders, whose rules may share a weight column between codes and whose ladders may repeat a level: the chooser equals the per-row loop, and the shared draw itself finds mass at the chosen level and is refused at every earlier level whose inputs are present (and at every level, for a household the chooser refuses). diff --git a/changelog.d/931-spi-copy-areas-by-drawn-band.changed.md b/changelog.d/931-spi-copy-areas-by-drawn-band.changed.md new file mode 100644 index 0000000000..86f9f225de --- /dev/null +++ b/changelog.d/931-spi-copy-areas-by-drawn-band.changed.md @@ -0,0 +1 @@ +SPI support-channel copies and income band donors now draw their area by the FRS rows' rule (#931; María's ruling of 25 Nov). `spi_copy_areas` runs after `spi_housing_shell` and reads the council-tax band the shell drew for each copy: a copy draws within its region by the households of that band (L2), or by all households where the region holds none of it (L3), and its parent's decile is still not read. Before, a copy drew at L3 by all households and the shell drew its band from region, composition and incomes alone, so band and local authority were nearly independent: in the K = 15 comparison, upper bands sat in authorities with few such homes, and one authority's Band G stock row started past the solver's cap. The shell now prices each Great Britain copy's bill at the expected Band D of that same cell, one exact reference per region and band taken before the band draw, at the level the draw's chooser gives the cell (L3 where the region holds none of the band), and `council_tax_localise` localises it from there as before. The copy stage's declared area draw names the levels L2 and L3 (the sources schema's `area_draw.levels`), as do its evidence and the shell's council-tax evidence. diff --git a/changelog.d/931-spi-employed-income-floor.fixed.md b/changelog.d/931-spi-employed-income-floor.fixed.md new file mode 100644 index 0000000000..449423c036 --- /dev/null +++ b/changelog.d/931-spi-employed-income-floor.fixed.md @@ -0,0 +1 @@ +The SPI stage's `hmrc_spi_employed_income` is floored at zero (#931). The HMRC employed-income identity adds the miscellaneous employment leaf, which the SPI tape's MOTHINC carries below zero on a few records, so a drawn row could hold a negative employed income, which the stage declares non-negative; the K = 15 spine's per-clone draws gave <3 such values, and `uk_nonnegative_columns` blocked the build. The identity is now floored at zero, and the earned and assessable totals add the floored value, so TI still equals TEI plus TII exactly. The stage's receipt gains `employed_income_floor`, the distinct source households the floor lifts among geographic clone 0's rows, rounded as every receipt count is ("<3" for one or two). diff --git a/changelog.d/931-spi-housing-council-tax-code.added.md b/changelog.d/931-spi-housing-council-tax-code.added.md new file mode 100644 index 0000000000..4fc323dd54 --- /dev/null +++ b/changelog.d/931-spi-housing-council-tax-code.added.md @@ -0,0 +1,20 @@ +The housing shell's council tax on the rows the SPI support channel copied, at each copy's reference Band D, in `microcosm.build.uk_runtime.spi_housing_council_tax` (#931), unwired: no stage uses it yet and nothing imports the module, so no key or value moves. Later in #931 group (e), the housing shell (`spi_housing_shell`) prices its bills with it after its chained draws and declares what the module states. + +- **The reference.** A copy's decile is missing by rule and its band is the one the shell draws, so the SPI-copy area stage (`spi_copy_areas`), which runs after the shell, draws its area at L2, its region by the households of that band, where the region holds the band, else at L3, its region by households (María's ruling of 25 Nov). `uk_spi_housing_council_tax_inputs` takes the reference Band D of each Great Britain (region, band) cell, before the band draw, as the exact expected 2024-25 Band D of the cell at the level the draw's chooser gives it, under the draw's own weights, from `atomic_area_conditioning.uk_draw_cell_expectations`, the call the council-tax localisation (`council_tax_localise`) makes for the same rows; each copy is priced at its drawn band's cell. + - It reads each row's region, support channel and copy lineage, on a narrow frame of the region alone whose two draw inputs are present and missing (`uk_spi_copy_draw_frame`). It reads no area column, geography key, IMD decile or band flag. + - Its rows are those whose `household_support_channel` is `spi`, the housing shell's rule, and they must be exactly the rows the support channel's lineage marks as its copies, SPI copies and income band donors. The supports' digests are keyed by the supports given. +- **The bill.** `uk_spi_statutory_council_tax` prices a Great Britain row by the 2024-25 statute (`council_tax_band_d.uk_statutory_council_tax`) at its reference, for its nation and drawn band, less the single-adult discount where `council_tax_single_adult_raw` is 1: one correctly rounded conversion of the exact bill. `uk_spi_council_tax_bills` returns that on Great Britain rows and the chained draw, bit for bit, on Northern Ireland rows, by María's ruling of 14 November. The branch is the nation of the row's region, never a value of the draw. + - The bill reads neither the drawn area nor its local authority. The localisation multiplies a copy's bill by its drawn authority's Band D over the same reference, so it stays the one step that localises the bill, and the paid bill it keeps for the WAS chain carries no drawn area. +- **Checks and evidence.** `uk_spi_housing_council_tax_checks` returns booleans: every Great Britain bill at the statute of its reference, every Northern Ireland bill as chained, every reduction within its bill, and every rebate equal to its reduction. `uk_spi_housing_council_tax_evidence` returns the block the housing shell's receipt is to carry under `council_tax`: the method, the reference, the copy level, the England-and-Wales and Scottish Band D resources with their digests and the Scottish feed's source commit, the supports' digests and the checks. It has no number leaf, never copies the feed, and its keys are the same whatever systems, nations or clones a frame holds. +- **The declaration pieces** the housing shell's stage is to declare: the localisation's Band D artifacts and its Scottish `verify_vendored_fact_resource` parameters, and a `derive` of `council_tax` whose formula states the bill. +- **Refusals** name columns, dtypes and declared constants only, never a household's id, area code, authority code, band, value or count. A Northern Ireland row sent to the statute, and a band its nation does not price, are refused by the module's own messages before the statute is called. +- **Tests**, `tests/engine_free/uk/test_uk_spi_housing_council_tax.py`, on test_support's invented council-tax cases on the toy conditioned supports, at one clone and at three, and on the housing shell's invented tables, with an invented Band D: + - each copy's reference equals the localisation's own reference for the row, worked again from the toy supports, one for each system and region, and the rows are the lineage's copies in table order; + - the references and bills are the same with every area column, the geography key, the IMD decile and the band flag dropped, on the household columns the housing shell consumes, and for a copy moved to another authority of its region; + - the narrow frame is the area draw's frame of a copy at its level, and the shared expectation refuses one without either draw input; + - each Great Britain bill is the statute at its reference bit for bit, over every band of every Great Britain nation, with the single-adult flag given as `council_tax_single_adult_raw` or as the housing shell's zero-or-one flag; Northern Ireland's rows keep the chained draw bit for bit, zero or positive, whatever their band; the bills do not depend on row order; + - the checks hold where the bills are written, each reduction capped at its written bill and the rebate set equal to it, and each check fails on its own breach: the statute check on a Great Britain row, the Northern Ireland check on a Northern Ireland row, a zero of the other sign included, and the reduction and rebate checks on a row of each; + - with the localisation after the bills, each Great Britain copy's bill is the statute at its own authority within four units in the last place, its kept bill is the statute at its reference less its rebate, the localisation's cap never binds on a copy, the FRS rows are as the localisation leaves them without the bills, and Northern Ireland's rows are left as written; + - the bills of each wrong design are caught: the reference at the drawn authority, the region's unweighted mean, Northern Ireland priced by the statute, the chained bill kept in Great Britain, and the reduction capped at the localised bill; + - the evidence has no number leaf on the invented Band D, on one whose Scottish feed carries an integer, and on the committed one, and it is the same across frames and clone counts; + - the declaration pieces equal the localisation's, and every refusal names no key, code or count of a household. diff --git a/changelog.d/931-spi-housing-council-tax.changed.md b/changelog.d/931-spi-housing-council-tax.changed.md new file mode 100644 index 0000000000..ac3d5e260e --- /dev/null +++ b/changelog.d/931-spi-housing-council-tax.changed.md @@ -0,0 +1,41 @@ +Price Great Britain SPI copies' council tax by the statute after the housing shell's chained draws, and bind the shell to the conditioned supports (#931). The housing shell (`spi_housing_shell`) now prices its bills with `uk_runtime.spi_housing_council_tax`, which #931 group (e) added unwired, and declares what that module states. + +- **The shell** (`uk_runtime.spi_housing_shell`): + - `council_tax` stays a target of the chained QRF on every row, so the fit, the band draw and every other chained amount are as before. After the learned zeros and the tenure rules (`apply_support_rules`), each Great Britain row the SPI support channel copied, SPI copies and income band donors, takes the 2024-25 statute at its reference Band D (`uk_spi_council_tax_bills`): the expected 2024-25 Band D of the cell `spi_copy_areas` draws its area from, its region by households, for its nation and drawn band, less the single-adult discount where `council_tax_single_adult_raw` is 1. The bill reads neither the drawn area nor its local authority, so `council_tax_localise` stays the one step that localises it. + - By María's ruling of 14 November, Northern Ireland's rows keep the chained draw. The branch is the nation of the row's region. + - The drawn council tax benefit is then capped at the bill written (`cap_council_tax_benefit`); the reference person's `council_tax_benefit_reported` carries it and the household's `council_tax_rebate` equals it, as before. `apply_structural_rules` is now the composition of the two steps, with the same rule firings in the same order, so `tools/validate_uk_housing_imputation.py` is unchanged. + - By María's ruling of 14 November, the band is drawn from the income classifier alone, as before, and the band tilt moves to SPI seating. The shell reads no household area column, so the pin that holds its consumes free of the area stands. + - `impute_spi_housing_shell` takes the required keyword `council_tax_inputs` (`uk_spi_housing_council_tax_inputs` on its household table) and refuses inputs that do not hold its SPI-channel rows, with their regions, in table order. The bill's four checks are asserted on what the stage writes, each failing with a fixed message that names no household. + - The receipt keeps its keys and their forms, and gains the `council_tax` block: the method, the reference, the copy level, the Band D resources with their digests and the Scottish feed's source commit, the supports' digests and the checks, with no number leaf. The cap's firing count now counts the reductions above the bill written. + - `UKSPIHousingShellStageTransform` takes the conditioned supports' bytes (`supports`) and an optional Band D, the committed one by default, as the council-tax localisation's transform does. Loading the committed Band D holds Scotland's vendored resource to the pinned feed. The transform checks its stage when it is built and when it runs, and before it reads a row checks that its Scottish declaration maps the facts to the frame's period. +- **Stages** (`sources.yaml`, then `source_stages.json` by the by-name merge). The shell declares, in order, Scotland's Band D `verify_vendored_fact_resource` as `council_tax_localise` declares it, its imputation with its parameters unchanged, and a `derive` of `council_tax` whose formula states the bill. Its artifacts are the localisation's two Band D artifacts (roles `council_tax_band_d` and `scotland_band_d_facts`), each with `runtime_sha256_required`. Its source and notes describe this behaviour. Its outputs and rewrites are unchanged, and so is the stage order. +- **The graph and the spine build.** + - The shell reads the three conditioned supports as graph sources, as the area stages and the localisation do (`_SPLIT_STAGE_SOURCES`). Its household consumes are unchanged. + - In `graph_kernels`, the shell binds the helpers its transform now computes through, among them `spi_housing_council_tax`, `atomic_support_expectations`, `atomic_area_conditioning` and `council_tax_band_d`. The H2 fixture's registry builds it on the toy supports at the committed Band D. + - `spine_build` builds the shell on the supports the area stages read, holding them to the spine's support pins first, so a support replaced after the spine was prepared is refused with the area stages' message before the shell builds anything. The support flags' help names the shell. + - `tools/graph_uk_spine_fixture.py`'s oracle builds the shell on the toy supports. +- **The geography-first roster.** `GEOGRAPHY_FIRST_OPERATIONS` names the shell's `derive`, before the WAS chain's main-residence localiser. So the dense line's posture check, the spine CLI's release candidate and the national line refuse every spine built before this change, naming `operation derive in spi_housing_shell`. +- **Generated files.** `source_stages.json` regenerates by the by-name merge, and the shell's imputation keeps its committed key order. The H2 fixture regenerates through the engine slot: `uk_spine.json` carries the shell's new stage contract and `sources/fixture.json` its new descriptor, and `sources/cgt_asset_type_facts.json` and `sources/property_purchase_targets.json`, which the fixture tool sizes to its oracle's frames before `cgt_residential_split` and `property_purchases`, move with the values from `was_wealth` on. `release_input_coverage_manifest.json`, which pins `source_stages.json`'s digest, regenerates, and only that digest moves. +- **What moves.** + - Values, at one clone. Every column through `aps_occupation` is as before, and so are the shell's FRS rows, every band and other category it draws, and every chained amount but the bill and the reduction capped at it. + - Great Britain SPI copies and income band donors take the statute bill at their reference. Their reduction is the drawn reduction capped at that bill, and their rebate equals it, which differs from before only where a cap binds. + - After `council_tax_localise`, their bill is the statute at their drawn authority within four units in the last place. The paid bill the localisation keeps for the WAS chain's bill predictor is, on those rows, the statute at the reference less the rebate, still free of the drawn area. FRS rows through the localisation, and its evidence, are as before. + - From `was_wealth` on, SPI rows move directly, and FRS rows through the WAS chain's pooled ranks. + - The shell's receipt gains its block, and its cap's firing count can move. + - Keys. UK only. Every spine node re-keys, and so does every dense and national node after the spine. Of the stage contracts only the shell's moves. The UK country and solve fingerprints move, and so do the UK spec-engine bundle lock and wire. No gate phase code moves. Outside the UK no key moves: no transport or US kernel, no NZ node with its donors held fixed, no NZ battery source, no US graph node, and no AM, BE, NZ or US fingerprint, spec-engine wire or bundle lock. No gates entry, contract pin, operation kind or schema changes. +- **Tests**, on test_support's invented tables, the toy supports, an invented Band D, the packaged spec and H2. + - `tests/engine_free/uk/test_uk_spi_housing_shell.py`: + - every imputation takes the council-tax inputs of its own table, a permuted table and the clone pools included; + - only the Great Britain copies' bill path moves, on the invented tables and on a variant whose invented Northern Ireland training households carry positive bills and reductions: every band, category, other chained amount and Housing Benefit is the fit, draw and rules' own bit for bit, Northern Ireland's bill, reduction and rebate are the chained draw's, and each Great Britain bill is the statute at its reference, worked again from the toys; + - the fitted chain's targets, written out in the test, keep `council_tax` first; + - the bill is written after the learned zeros, the capped reduction is the reference person's and the rebate, and `apply_structural_rules` is the support rules then the cap, bit for bit; + - the receipt's block has no number leaf and is the same at one clone and at three, each check's fixed message names no household, and a chained Great Britain bill fails the statute check; + - the inputs are required and must be the SPI rows, with their regions, in table order, the transform checks Scotland's Band D period before it reads a row and checks the housing invariants once, a drifted stage is refused when the transform is built and when it runs, and the shell imports neither the localisation's module nor `frs_council_tax`'s; + - the committed smoke fixture's descriptor passes the stage's check; + - the H2 fixture's registry and `tools/graph_uk_spine_fixture.py`'s oracle both build the shell on the toy supports. + - `tests/engine_free/uk/test_uk_source_stages.py`: the shell's operations, in order, and its artifacts, the localisation's. + - `tests/engine_free/uk/test_uk_graph.py`: the support readers gain the shell, and the binding rules hold. + - `tests/engine_free/uk/test_uk_frs_spine.py`: the shell is built on the supports' graph sources and refuses a support replaced after the spine was prepared, and the release-candidate roster refusal names its `derive`. + - `tests/engine_free/uk/test_uk_spine_posture.py`, `test_uk_full_build_cli.py`, `test_uk_national_graph.py` and `test_uk_area_home_values.py`: the roster's operations, in the spine's order and held to the stages' own names, and the dense and national refusals naming the shell's `derive`. + - Engine tier: the adapter's support readers gain the shell. + - After merge, H2's clone-first run at one clone and at four: every SPI-channel row's bill after the localisation is the statute at its own authority within four units in the last place. diff --git a/changelog.d/931-spi-support-keyed-share.changed.md b/changelog.d/931-spi-support-keyed-share.changed.md new file mode 100644 index 0000000000..4d5a16cd10 --- /dev/null +++ b/changelog.d/931-spi-support-keyed-share.changed.md @@ -0,0 +1,7 @@ +The SPI support channel (`spi_support_channel`) copies its zero-weight SPI households as a keyed Bernoulli share instead of a fixed count drawn by row position (#931). A household is copied when its uniform, keyed on its own `household_id` under the stage's seed (42) and the new salt `spi_support_channel:inclusion`, falls below π = min(1, 10,000 × the sample fraction / the distinct `source_household_id` values entering the stage); at π = 1 every household is copied without reading a uniform. The manifest's 10,000 is now the share's numerator, so a one-clone spine's copy count is binomial, with mean min(10,000 × the sample fraction, the source households), instead of exact: about 1,000 at f010, by design arithmetic (10,000 × 0.1). Each household's draw reads only its own id, the seed, the salt and π, so row order does not matter. π counts true sources, so it is the same at every geographic clone count, and clone 0 of a cloned spine, whose ids are the one-clone ids, draws exactly the one-clone copies, while the other clones draw on their own ids (María's rulings of 7 Nov). + +- **Gate.** `e7_spi_synthetic_preclone` is renamed `e7_spi_synthetic_share`. Its declaration carries `maximum_zero_weight_rows_rule: {rule: binomial_share_band, sigma: 4}` instead of the integer 10,000. After the draw the stage resolves it to min(n, ceil(n × (π + band(π, n)))) over the n household rows entering the stage, and runs the unchanged zero-weight gate. The band is the repo's binomial band, moved unchanged from `stage_health.latent_attribute_tolerance` into `stochastic_assignment.binomial_share_tolerance(*, target, rows, sigma)`; `latent_attribute_tolerance` stays, as the same band at four sigma. In `sources.schema.json`, `stack_zero_weight_donors` requires `salt`, a zero-weight declaration takes either the integer maximum or the rule, and `allocate_zero_weight_prior_mass` accepts `geographic_clone_stratum`. The stage's source sentence, draw text and notes describe the share. +- **Per-clone strata.** Where the household table carries `household_clone_index`, the prior allocation's strata also split by geographic clone, so each clone keeps its own mass and its SPI weights depend on its own households and copies only. The manifest declares this as `geographic_clone_stratum: household_clone_index`. A positive-mass stratum without an SPI copy is refused with a count of strata, not their names. Without the column the strata are as before: a frame without it, or with a one-clone index, allocates bit for bit as the region and pension-age strata did, given the same copies. The small-clone-stratum fallback comes later in #931. +- **Receipt.** The stage evidence gains `expected_spi_households` (10,000 × the sample fraction), `inclusion_probability` floored to two decimals, `source_households` rounded by the receipts' rule, and the gate's name, rule and sigma, not the maximum it resolved to. `spi_households` stays exact, because the stage gate reads it. +- **Bindings.** spi_spine, the module of `frs_hmrc_spine_leaves`, `spi_support_channel` and `hmrc_spi_income_spine`, rounds the receipt, so `frs_hmrc_spine_leaves` joins the counting stages. spi_support now draws through the keyed-draw helpers, so `high_value_home_support` and `cgt_residential_split`, which bind it, bind them too. The spine gate kernel's hash names `stochastic_assignment` beside `stage_health`, since the latent-attribute checks' band now lives there. +- **What moves.** At K = 1 the SPI copy set is redrawn, with a binomial count around 10,000 × the sample fraction where that is below the source households. Per-stratum SPI weights move with it, and so does every SPI-channel value from `hmrc_spi_income_spine` on, the high-value and CGT selections that rank SPI rows, and calibration. Base FRS rows keep their weights after `spi_support_channel`, which are their incoming weights times stratum shares that do not depend on the draw, except the row the exact-total correction lands on. On synthetic frames, `spi_income_band_donors` seats the same households, carriers and bands under the old and new draws, at the same seating scale; its funding factors and mass scale, and with them its donors' and base rows' weights, move only by rounding, since its stratum masses sum the redrawn copies' weights. The empty-stratum refusal reads the new draw, so a small frame that built before can refuse, and one that refused can build. The H2 fixture's 135 households at a sample fraction of 135 / 10,000 give π = 1 (10,000 × 0.0135 is 135.0 in float), so its copies are unchanged; its declarations and the stage's contract hash are regenerated, with the coverage manifest's source digests and `source_stages.json`. Every node re-keys. diff --git a/changelog.d/931-spine-assigns-areas.changed.md b/changelog.d/931-spine-assigns-areas.changed.md new file mode 100644 index 0000000000..1e61328c20 --- /dev/null +++ b/changelog.d/931-spine-assigns-areas.changed.md @@ -0,0 +1,31 @@ +Assign each geographic clone's area in the UK spine, fold `frs_brma` into `area_brma`, give SPI copies their own areas, and localise private rents (#931). The area and private-rent transforms #931 group (c) added unwired are now declared and wired: the packaged spine has 63 stages. The dense line still refuses every spine, since the roster lacks only the WAS chain's home-value localiser, and the national line still refuses every clone-first spine. (Later in #931 the WAS chain declares the localiser, so the dense line's posture check passes on the packaged spine: `931-spine-localises-home-values`; and the national line builds on a geography-first spine of one clone once the area-basis exclusion is signed for it: `931-national-one-clone-areas`.) + +- **Stages** (`sources.yaml`, then `source_stages.json` by the by-name merge): + - `atomic_area_assign`, `local_authority` and `rfdr` run after `geographic_identity` and before `frs_take_up`: each clone's area and ladder, drawn on the three conditioned supports, its engine local authority and its fuel-relief flag. + - `area_brma` takes `frs_brma`'s place after `frs_household_draws`, and the assembled boundary moves with it (`UK_SPINE_ASSEMBLED_FINAL_STAGE`). Great Britain reads `brma` off the drawn area through the area-to-BRMA layer; Northern Ireland draws from the census counts with `frs_brma`'s keys, seed and salts. `frs_brma`'s stage block retires; its module and helpers stay. + - `spi_copy_areas` runs after `spi_housing_shell`: every SPI copy and income band donor gets a key over its own path, an area drawn at L2, its region by the households of the band the shell drew, where the region holds that band, else at L3 (María's ruling of 25 Nov), and its own local authority, BRMA and flag. Northern Ireland's copies draw their BRMA on their own benefit units after one engine call, one simulation, over their households alone (C-9, as ruled on 11 Nov). Its evidence withholds every system of a kind where one system rests on one or two source households: at one clone the support channel's and the band donors' own copy counts are the kind's total, so the other systems' counts would give it back by difference. + - `private_rent` runs after `spi_housing_shell`: Great Britain private renters' rents are read off their BRMA's list, keyed per row on the stage's own stream at seed 0, with its own mass-conservation receipt. + - `frs_take_up`'s notes and `frs_person_draws`' `rate_derivation` say the targets are counted within each geographic clone, as does the take-up contract's policy line for `frs_take_up`'s anchors, which also says `spi_benefit_coherence`'s SPI-channel Universal Credit redraw still counts over every clone; `spi_support_channel`'s notes say a clone's stratum without a copy is refused; `geographic_identity`'s notes no longer name the retired dense identity node. +- **Shared vocabulary.** The source-stage schema gains six strict operation kinds (`assign_atomic_area`, `resolve_local_authority`, `assign_area_brma`, `assign_rfdr_flags`, `assign_spi_copy_areas`, `localise_private_rents`), and `ALLOWED_SOURCE_OPERATION_KINDS` the same six. Both are additive. +- **The spine build.** + - `--atomic-support-ew`, `--atomic-support-scotland` and `--atomic-support-ni` are required when `atomic_area_assign` is scheduled, refused beside `--synthetic-fixture-dir`, and each file is held to the conditioned register (`uk_atomic_support_register(conditioned=True)`) before the engine is built. A refusal names the flag and the system only. + - The three supports are raw-byte graph sources of `atomic_area_assign`, `rfdr` and `spi_copy_areas`, named by `sources.yaml`'s conditioned ids. Each of those stages holds the files it reads to the pins of the spine's geography block, which the preparation composes before any stage runs, so a support replaced after the spine was prepared is refused, naming its system and graph source alone. + - The sidecar records a `geography` block under the roster leaf's keys: `assignment` (`"atomic"`), `identity` (`"geography_household_key"`), `definition_sha256`, `support_pins` (SHA-256 and integer size per system), `stream` (the seed at index 3) and `register` (`"sources.yaml"`, or `"synthetic"` for a fixture's toys). `country_adapter.uk_spine_geography_binding` composes it, for the sidecar and for the full build's `--spine-request` route alike, and `uk_spine_geography_binding_failures` now also holds `stream` and `register`. + - The declared seeds gain `atomic_area_assign` (`uk-spine-atomic-area-v1`: 0), `spi_copy_areas` (`uk-spine-atomic-area-v1`: 0, `brma`: 0), `private_rent` (`uk-spine-private-rent-v1`: 0) and `area_brma` (`brma`: 0). +- **The graph.** The six stages' consumes and cells; `area_brma` and `spi_copy_areas` are open engine surfaces; `hmrc_spi_income_spine` joins the reader-isolation boundaries, so the graph gains `hmrc_spi_income_spine.boundary`, and `private_rent` its own boundary. The geography-first transforms read their stage names from the roster leaf, and `private_rent_localisation.STREAM_EXPERIMENT` retires. The six stages run on the bitwise stage kernel (C-2; F10 is open with Max). +- **What moves.** + - Keys: every spine node, since `graph_kernels`, which defines every UK spine kernel, changed (the geography-first transforms' kernels now also hash the roster leaf), and `frs_person_draws`' stage contract moves through its `rate_derivation` and the take-up contract it pins; notes enter no stage contract. Stage contracts are added for the six stages and retire with `frs_brma`'s. Every dense and national node re-keys but a bound spine's checkpoint import, through the country fingerprint (`sources.yaml`, `source_stages.json`, the take-up contract and the coverage manifest). Outside the UK one kernel re-keys, the shared transport gate battery (`gates.battery@1`): the source closure of its bindings reaches `source_manifest`, where `ALLOWED_SOURCE_OPERATION_KINDS` lives, so NZ's terminal gate and the export, readback and package nodes after it re-key (`nz.gates.terminal`, `nz.export.prepare`, `nz.export.readback`, `nz.package`; the NZ spec is inactive), as #931 group (b)'s two kinds did. María accepted this on 12 Nov, with the allowed list kept in `source_manifest`. A key probe on code and toy data finds no AM, BE or US key, no AM, BE, NZ or US spec fingerprint, no gate phase code and no other country's spec-engine wire moving; in the AM, BE, NZ and US bundles the six kinds move only the spec engine's grammar receipt, which each country's emitted, uncommitted bundle lock carries. + - Values, at one clone: the new columns (3 assignment, 10 ladder, `local_authority` and `in_rural_fuel_duty_relief_area`); `frs_take_up`, `frs_person_draws` and `frs_household_draws` unchanged, since they read no area column; Great Britain BRMAs read off the drawn area, while Northern Ireland's households keep the BRMA `frs_brma` drew and its SPI copies draw their own; every SPI copy's and income band donor's own key, area, local authority, BRMA and flag; Great Britain private renters' rents, households' and copies'. In policyengine-uk's reads, council tax reduction moves only in the households of English working-age claimants placed in a council whose working-age scheme it models (its default local authority, Maidstone, is not one), LHA for Great Britain renters on Housing Benefit or Universal Credit through the BRMA, with both awards following the new rents, and fuel duty for flagged households; through council tax reduction and those awards the engine's HBAI income moves for those households, and with it `was_wealth`'s income predictor and the later stages that read the engine. At more than one clone, clone 0 nests exactly on the area stages, `area_brma` and the copies' areas, and the private rents approximately; the clones differ by area. + - `geography_household_key` is unique per row up to `spi_support_channel`, whose copies, like the income band donors, repeat their parent's key until `spi_copy_areas` gives each its own. The copies later stages make (high-value home support and the CGT copies) carry their parent's key, so the exported key is no longer unique per row. +- **Defaults taken** (the #931 group (c) design): + - C-1: `area_brma` sits after the draws, in `frs_brma`'s place, since policyengine-uk's `LHA_category`, which Northern Ireland's draw reads, reads `frs_take_up`'s `would_claim_uc`. + - C-2: the six stages are bitwise; C-3 and C-43: the area draw and the private rents take seed 0 on streams of their own, and the copies' areas reuse the area draw's and the BRMA's seeds. + - C-8: the SPI copies' areas are a stage of their own after both copying stages, whose contracts do not change. C-10: copies keep their parent's IMD decile and band flag, and the draw gives every SPI-channel row missing inputs, so copies draw at the region-and-households level (L3). + - C-11: copies made after `spi_copy_areas` inherit its key. C-14: the private rents rank each row on its own key, strictly on a full-scale spine and with the thin-region rule on a sampled rung. + - C-22: the three support flags are held to the conditioned register, and refused beside a synthetic fixture, which carries its own toys. C-26: the stage names. C-37: the three-system check is an engine-tier stand-in, not Northern Ireland households in H2's root. C-41: the BRMA distribution tool's output is private. +- **Generated files.** The H2 fixture regenerates with the 63 stages and three toy conditioned supports, written from test support's invented table through the canonical support adapter as fixture inputs under the conditioned ids, in files named `toy_.npz`. `.gitignore` admits exactly those three past its licensed-output `*.npz` rule, so a real-derived support, which keeps its own name, stays ignored. `release_input_coverage_manifest.json` gains a `private_rent` family. +- **Tools.** + - `tools/verify_uk_identity_stability.py`: E4 recomputes `area_brma`'s BRMA through the stage's own derivation (Great Britain's off the stored areas, Northern Ireland's from the count table on `LHA_category` as `area_brma` read it) and compares it bitwise. `spi_copy_areas`, the one later stage that declares writing `brma`, rewrites only rows the SPI support channel copied, every one of which E4's scope drops, so its rewrite counts as taken back; E4 refuses a scoped frame that keeps such a row, naming the column only. + - `tools/emit_uk_brma_distribution.py` compares Northern Ireland's draws only and counts `cell_n` and `built_count` in rounded distinct source households. A BRMA one or two source households carry withholds every figure of its cell. Each benefit-unit share is floored to the hundredth and z rounded to one decimal, both withheld in a cell of fewer than ten source households. An `--output` inside a git work tree is refused. + - `tools/graph_uk_spine_fixture.py` builds the six transforms in its oracle, as the fixture registry builds them. +- **Tests.** The pins above, the support flags, the binding's composer and checks, the leaf's drift tests and the K-sensitive constants (engine-free). The spine CLI, parsing and preparing the packaged roster: it holds each of the three supports to the register before it builds its engine, composes the geography block from them under `sources.yaml`'s register, hands the area stages the three files, which they hold to the block's pins, and gives a full-scale spine's private rents the strict rule. The shared operator's draw keys, each held to every term: identity, system, level and both digests. Every row's area at three clones the operator's draw on its own key, with some household's area moving at each clone after the first. The packaged area and private-rent stages running as their reviewed declarations; the copy stage withholding a kind's systems; the per-clone count texts; the assembled gates reading up to `area_brma`; the `private_rent` coverage family. E4 on invented frames through the area stages, `area_brma` and the copy stage, comparing `brma` and refusing an unscoped frame. The BRMA distribution tool's rounding, suppression, precision and private output. The integration run's sidecar block, equal to the one composed from the fixture's toys. H2 parity; `required_build_stages` with `private_rent`; the full country graph's only support sources, the spine's three conditioned ones, read by `atomic_area_assign`, `rfdr` and `spi_copy_areas` alone. The clone-first H2 test at 63 stages, with the copies' areas and every area-stage receipt field but K nesting in clone 0, and, at one clone and at four, every household's area from `area_brma` on, every SPI-channel row's own key, the later copies' inherited keys and `private_rent` keeping every rent it does not re-draw (H2's root households all own their homes, so it re-draws none). A new engine-tier test (`test_uk_spine_three_systems.py`) runs England-and-Wales, Scottish and Northern Ireland households on the toy supports through the area stages, `area_brma` and `spi_copy_areas` on the installed engine, at one clone and two. It holds every local authority to the engine's enum and Northern Ireland's BRMAs, base rows' and copies', to `frs_brma`'s draw, and then, on invented housing, `private_rent` re-drawing every Great Britain private renter's rent off its BRMA's list and leaving Northern Ireland's. diff --git a/changelog.d/931-spine-geography-transforms.added.md b/changelog.d/931-spine-geography-transforms.added.md new file mode 100644 index 0000000000..a53fa4115e --- /dev/null +++ b/changelog.d/931-spine-geography-transforms.added.md @@ -0,0 +1,32 @@ +The clone-first UK spine's area, local-authority, BRMA, fuel-relief, SPI-copy area and private-rent transforms (#931), unwired: no stage declares them and no node binds the three new modules, so no output moves. (Later in #931 the packaged spine declares and runs all six, in place of `frs_brma`'s stage: `931-spine-assigns-areas`.) Each transform checks the stage it runs as against the reviewed declaration its module states (name, household grain, outputs and rewrites, the reviewed operations verbatim and its artifacts, each with `runtime_sha256_required`), which the geography declarations will carry. + +- **The conditioned area draw** (`microcosm.build.uk_runtime.atomic_area_conditioning`). + - The definition over the three conditioned supports, held to canonical bytes, keeps the FRS region as a required constraint and the IMD decile as an optional one. England and Wales and Scotland sample each household by the area's households in its observed council-tax band, or by all the area's households where it has none; Northern Ireland, which has domestic rates, samples by households. The layers are the ten ladder columns, and the stream is `uk-spine-atomic-area-v1` with seed 0. + - The fallback ladder runs from L0 (decile and band) to L3 (region and households); Northern Ireland takes L1 and L3. + - The draw reads the decile as "1" to "10" (missing for 0) and the band only where `council_tax_band_observed` is true. A row the SPI support channel copied reads no decile and the band the housing shell drew, so it draws at L2 where its region holds that band, else at L3 (María's ruling of 25 Nov). + - The shared chooser picks each household's level with the definition's own rule and default. +- **The area stages** (`microcosm.build.uk_runtime.spine_geography`). + - G2, `UKAtomicAreaAssignStageTransform` (`atomic_area_assign`), draws, derives and validates every household's area on one narrow frame and writes the three assignment and ten ladder columns as `StringDtype("python")`. A validation that fails refuses the stage. + - G3, `UKLocalAuthorityStageTransform` (`local_authority`), resolves `local_authority` from `local_authority_code` through the committed names roster, never defaulted, as `StringDtype("python")`. + - G4, `UKAreaBRMAStageTransform` (`area_brma`, to take `frs_brma`'s slot), makes one engine call over the whole frame for `LHA_category`. Great Britain reads `brma` off the drawn LSOA (England and Wales) or output area (Scotland) through the committed area-to-BRMA layer. Northern Ireland draws from the census counts with `frs_brma`'s keys, seed and salts, so its values are `frs_brma`'s. `brma` stays an object column, and a frame G4 cannot place is refused before the engine call. + - G5, `UKRFDRStageTransform` (`rfdr`), sets `in_rural_fuel_duty_relief_area` from the drawn output area through the committed RFDR layer. It refuses a layer that flags an output area its system's support does not hold, and reports a system with no flagged household instead of refusing. + - `UKSPICopyAreasStageTransform` (`spi_copy_areas`, to run after `spi_housing_shell`) gives every SPI copy and income band donor a geography key over its own copy path, an area drawn with G2's definition at L2, its region by the households of its drawn band, where the region holds the band, else at L3 (María's ruling of 25 Nov), and then its own local authority, BRMA and flag. As María ruled on 11 Nov (C-9), Northern Ireland's copies draw their BRMA from the census counts on their own benefit units, with G4's seed and salts, after one engine call over their households alone. That call carries no clone index, so it is one simulation over every clone's copies, as at one clone: the UK adapter refuses a call over part of its pool, which a clone without a Northern Ireland copy would otherwise make it. Great Britain copies' areas are checked against the layer before the call. Each rewrite keeps its column's dtype, and every other row is left as it was. +- **Private rents** (`microcosm.build.uk_runtime.spine_private_rent`). G7, `UKPrivateRentStageTransform` (`private_rent`, to run after `spi_housing_shell`), re-draws each Great Britain private renter's rent with `private_rent_localisation.localise_rents`, every row its own spine household keyed on its `geography_household_key`. Tie-breaks are keyed on `(key, "rent_rank")` on the stream `("sha256-u53-v1", "uk-spine-private-rent-v1", 0, 0)`, so tied renters and the clones of one renter take ranks of their own and clone 0's tie-breaks are the same at every K. The sampled rung's thin-region rule counts true source households, and the stage is strict unless the spine is sampled. Only `rent` is rewritten: reported Housing Benefit, Universal Credit and mortgages, the weights and every other column are unchanged, and the stage records its household mass receipt. +- **Evidence.** Every count is distinct true source households through `rounded_count`, never per area or per cell, and no key or code of a household is printed. G2 (by system, level and fallback reason), G3 and G4 (by grain, and Northern Ireland's sources drawn) count over every clone. G5's flagged sources, the copy stage's copies, donors and flagged copies, and G7's re-drawn sources count among clone-0 rows; G7 also gives the cells ranked against their region or against Great Britain. The copy stage's evidence says its validation and roster check did not run on a frame without a copy. +- **Changed modules.** + - `frs_brma.draw_household_brmas` draws the BRMAs of any subset of households with today's keys; `add_frs_brma` calls it and its values are unchanged. Its refusals no longer print household or benefit-unit ids. + - `rfdr_area_layer.area_flags` gains `roster`. Its malformed-code refusal no longer prints a count or a code, and its unknown-system refusal names the accepted systems instead of the frame's values. + - The BRMA and RFDR layer docstrings describe the spine's stages. +- **Keys.** The stage kernels that bind `frs_brma` (`frs_brma`, `was_wealth`, `was_lisa`, `uc_take_up`, `uc_deduction_attributes` and `childcare_copy_take_up`) re-key with it, and so do the dense line's geography BRMA and RFDR nodes (`uk.full.geography.brma@1` and `uk.full.geography.rfdr@1`, after the layer modules' edits), with every node downstream of them. No transport key (NZ, BE, AM), US key or battery phase moves, and no node hashes the three new modules. No declaration, generated file or `gates.json` changes. +- **Values.** None moves. On the synthetic H2 fixture, the legacy oracle's final frame (every table, column and dtype, the weights, the strata and the mass log), its stage records and every stage's evidence digest are identical before and after this change, and the fixture regenerates byte-identically. +- **Tests**, on toy conditioned supports whose public area codes resolve against the committed resources (`test_support/microcosm_build/uk_conditioned_support_fixtures.py`), invented households, a recording stand-in for the rules engine and a stand-in for the support channel's two stages: + - each household's level and region, the decile read as "1" to "10", and the chooser called with the definition's own rule, default and ladder; + - clone 0's areas at K = 1, 2 and 3, and its copy keys, areas and BRMAs at K = 2 and 3, equal to K = 1's, and row-order independence; + - G2's and the copy stage's validation refusing a ladder the mapping does not give, and the written dtypes; + - Great Britain's BRMAs against the layer, Northern Ireland's against `frs_brma`, and `frs_brma`'s household pick written out; + - the copy stage's own keys and Northern Ireland draws, and its engine call as one simulation under the UK adapter's clone rule at K = 2 and 3 with Northern Ireland copies in clone 0 alone; + - G7 against `localise_rents` on a copy-free frame; + - count-free refusals, the frame's before any engine call; + - every evidence count byte-equal at K = 1 and K = 3. + + A mounted test, skipped without the supports, holds the chooser to the committed zero-mass tables. diff --git a/changelog.d/931-spine-home-values-and-geography-checks.added.md b/changelog.d/931-spine-home-values-and-geography-checks.added.md new file mode 100644 index 0000000000..ee546b7150 --- /dev/null +++ b/changelog.d/931-spine-home-values-and-geography-checks.added.md @@ -0,0 +1,13 @@ +The clone-first UK spine's WAS home-value localiser (G8), the regional property uprating's factor helper and the spine geography gate checks (#931), unwired: no stage declares the localiser or a denominator and no gate declares the new checks, so no value moves. (Later in #931 `was_wealth` declares the localiser, `regional_property_uprating` the denominator, and the spine battery's gates the three checks: `931-spine-localises-home-values`.) A later commit of #931 group (c) declares them, retires `regional_home_values` and registers the gates. + +- **The area home values** (`microcosm.build.uk_runtime.area_home_values`, G8, form F). Called with the WAS chain's segment-2 draw of `main_residence_value`, each owner household with a positive draw takes a point inside its weighted slice of the owner households of its assigned constituency and geographic clone with a positive draw, both support channels, at the stage's household weights: in order of the draw, ties broken on a draw keyed on the household id, each row's slice as wide as its weight and its point drawn keyed on the household id (`property_localisation.owner_slice_uniforms`; María's ruling of 17 Nov). Its stream is fixed, `("sha256-u53-v1", "uk-spine-area-home-values-v1", 0, 0)`, with seed source NONE, as ruled for `regional_home_values` on 9 Nov (C-43). An England and Wales owner's value is its assigned constituency's knots at that point (`uk/high_value_home_value_knots.json`), divided by its FRS region's regional uprating factor on geographic clone 0's draws, so the uprating, dividing by the kept draw, returns it to the knot value to one rounding. Scotland, Northern Ireland, renters and owners without a positive draw keep the draw bit for bit, and the draw is kept on every row as `main_residence_value_rank_basis`. It refuses, by texts that name columns and declared constants only, an England and Wales owner whose `constituency_code` is outside England and Wales or another owner's inside it, a constituency without knots and a localised value that is not positive. `area_home_values_declared` holds a WAS stage's declaration of `localise_main_residence_value` to the reviewed operation the module states, its two artifacts (each with `runtime_sha256_required`), the `main_residence_value_rank_basis` output and a support clip exempting exactly `main_residence_value` and `property_wealth`, and refuses a half declaration. The knots' region map `FRS_REGION_TO_KNOTS_REGION`, now read-only, and the knots' file name `KNOTS_RESOURCE` move here from `regional_home_values`, which imports them. `clone_zero_rows` says which household rows are geographic clone 0's; the WAS stage's cap counts by it too. +- **Its evidence** (C-16, C-44): among geographic clone 0's rows of positive weight, the distinct true source households rewritten in each region (`rounded_count`) and those whose knot value is at the knots' cap (`support_band`); the knots' digest, basis year and level, the regional reference's digest, the rank basis and its column, the stream and the method. No value, sum or factor. +- **The WAS stage** (`was_wealth`). `impute_was_wealth` takes `main_residence_localiser=None`; where given it runs after segment 2, segments 3 to 11 condition on its values, the draw is kept as the rank basis and the result carries what it returned. Segment seeds are prefix-stable, so segments 1 and 2 draw bit for bit as without it. The transform builds the localiser only when its stage declares the area home values, writes the rank basis and adds an `area_home_values` block to its evidence. The support clip reads the stage's declared exemptions (`area_home_values.support_clip_exemptions`), none today. `cap_derived_totals_to_donor_range` takes `localised`, the rows whose main residence the localiser rewrote (none by default), and raises each such row's largest property total by its main residence's excess over the donor's largest, so that excess never takes other property away (other property past the donor's room still is); every other row's largest total is the donor's, so without the localiser the cap is as before. Its `*_capped_rows` fields now count the distinct true source households it adjusted among clone-0 rows, rows of zero weight included, in `extreme_count` bands (C-40), and the stage reads its frame's sources with `record_source_households`. +- **Property and uprating helpers.** `property_localisation.localise_main_residence_values` is the value half of `localise_values`, which now calls it; its refusal of a constituency without knots names no constituency. `regional_uprating.regional_reference_factors` is the stage's factor, factored out of `uprate_household_property_by_region`, which gains `denominator_column` (default `main_residence_value`): the owners stay the rows with a positive main residence, and the mean is taken over the declared column. The stage transform reads its operation's optional `denominator` (`main_residence_value` or `main_residence_value_rank_basis`, refusing any other), and the packaged stage declares none. It refuses households carrying `main_residence_value_rank_basis` while it divides by `main_residence_value`, since form F's localised homes land on their knots only where the stage divides by the kept draw (C-15). +- **Gate checks** (`stage_health`), registered by no gate yet: `atomic_mapping_integrity` holds an area stage's recorded validation to an accepted outcome (`pass` by default), the declared scope and SHA-256 digests of the definition and one per declared support system; `area_home_values` is the regional home values ranking check for the WAS stage's block (every declared region rewritten, the sources at the knots' cap within the declared maximum, flagged where a band straddles it, the declared basis year, knots level and rank basis, and clone-0 counting), with no value or sum to check; `copy_area_agreement` reads the phase's frame and holds every household a declared copy layer minted equal to its immediate parent, the id with that layer's copy-id field cleared (`copy_id_table.parent`), on the layer's declared columns. A declared list given as one string, a sources-at-cap entry that is neither a count nor a band, and household ids the copy-id table cannot decode fail by name. Every failure text names the check and the field, never a count or a value. `wealth_coherence`'s `capped_rows` detail carries the WAS cap's bands as printed, beside its counts. +- **Shared** (`microcosm.build.copy_agreement`, names no country): `rows_agree_with_parents(table, *, id_column, parent_ids, rows, columns)` compares each flagged row with its parent column by column, missing on both counting as equal, and returns per-column booleans and count-free texts. +- **Bindings** (`battery_bindings`). The stage-health binding hands the phase's frame to `copy_area_agreement` as well as to the band donor check, and routes the new checks' parameter keys (`knots_level`, `accepted_outcomes`, `validation_scope`, `support_systems`, `columns_by_copy_layer`). The UK enum-domain evaluator rebuilds the shared gate's result without counts or examples (C-32): a failure names the column and its domain, and the details keep `columns_checked`, `allowed_values` (and each nation's) and `columns_outside_domain`. Its refusal of a region with no nation names no region. `microcosm.build.gates` is untouched. +- **Count-free texts** (C-32). The geography ladder gate's and `local_authority_consistency_failures`' failure texts name the check and the column, without a row count, an example or the observed weighted share; the shares stay in the details. The ladder gate fails, naming the column, on a region it cannot read where it raised a text listing the values before, and the assignment summary's weight-length refusal carries no lengths. +- **Keys.** Every kernel the spine registry holds changes hash, since `graph_kernels`, which defines their classes, binds the WAS stage's new helpers (`area_home_values`, `property_localisation`, `regional_uprating`, `rowwise_geography`, `microcosm.graph`'s randomness and canonical encoding), adds `was_wealth` and `was_lisa` to the counting stages and has `regional_home_values` bind `area_home_values`. So do the spine gates (`stage_health`, `battery_bindings`), the full battery's preflight and calibrated gates (`battery_bindings`, `geography_ladder`), the national gates (also `copy_agreement`, now among the registry's modules), and every dense, national and export kernel that hashes `geography_ladder` or `local_authority_input`. Of the gate phase codes only the full battery's terminal code moves, as it lists `local_authority_input`, so the calibrated gates' `terminal_code` parameter changes too. No transport kernel (NZ, BE, AM) moves, and no US module imports an edited one: `microcosm.build.gates` and `country_spec` are untouched, and only the UK stage-health checks import `copy_agreement`. No declaration, generated file, `gates.json` or schema changes. +- **Forms.** A failing enum-domain, ladder or local-authority result carries no row count or example, and a passing enum result's details lose the empty `invalid_counts` and `invalid_examples` and gain an empty `columns_outside_domain`. The WAS stage's capped-row fields print bands, which `wealth_coherence`'s details carry. +- **Tests.** On invented households, toy knots and a toy regional reference: form F against the public helpers and by hand, the uprating landing localised homes on the knots within one ulp, row-order independence on non-integer draws and weights, ties broken on the declared stream, a copy keeping its parent's source ranked on its own key, clone-0 evidence at K = 1, 2 and 3, the evidence counted in distinct sources among clone 0's rows of positive weight, the count-free refusals, the declaration's whole-or-nothing form, the dense roster's operation name and the packaged spec declaring the localiser and the uprating's denominator together (`test_uk_area_home_values.py`). In the WAS chain: segments 1 and 2 bit for bit with and without a localiser, every segment from 3 on reading the localised value, rows the localiser keeps bit for bit through all eleven segments, the clip leaving the exempt columns, the cap's room beside a localised home and only there, the banded capped counts in distinct sources among clone 0's rows, at the function and through the stage, the stage handing the cap its localised rows, and an end-to-end run of a declared stage on the committed knots followed by the uprating with the declared denominator, which refuses the localised households without it. The value half against `localise_values`, the factor helper and the default keyword against the stage's former loop bit for bit, each new check passing and failing on hand-built evidence (the mapping-integrity check also on the area-draw transform's own evidence over toy supports, the copy check on an SPI copy and a band donor of a later clone), `rows_agree_with_parents` on invented tables (`test_copy_agreement.py`), and the enum, ladder and local-authority texts' pass and fail forms with no digit of data. diff --git a/changelog.d/931-spine-localises-council-tax.changed.md b/changelog.d/931-spine-localises-council-tax.changed.md new file mode 100644 index 0000000000..1c6867cbda --- /dev/null +++ b/changelog.d/931-spine-localises-council-tax.changed.md @@ -0,0 +1,69 @@ +Localise Great Britain council tax by each clone's local authority just before the UK spine's WAS chain, and carry each bill's provenance from `frs_council_tax` (#931). The council-tax localisation #931 group (d) added unwired is now declared: `council_tax_localise` runs after `private_rent` and before `was_wealth`, in a graph version of its own, so the packaged spine has 63 stages. `frs_council_tax` writes `council_tax_bill_provenance` beside the bill, and the localisation reads it. The localisation keeps the paid bill from before it as `council_tax_frs_bill`, which the WAS chain's bill predictor reads. The release boundary drops both columns. + +- **Stages** (`sources.yaml`, then `source_stages.json` by the by-name merge): + - `frs_council_tax` declares `derive` after `impute_cell_means`, as `frs_council_tax_provenance_operation_parameters()` returns it, and outputs `council_tax_bill_provenance` after `council_tax`. Its imputation and nonnegative outputs are unchanged, and its notes gain one sentence on the flag. The transform writes the flag (`StringDtype("python")`) from the same branches that choose the bill, which stays bit for bit as before. `checkpoint_metadata()` returns the provenance receipt, `council_tax_provenance_evidence`: distinct source households before the copies, through `rounded_count`. The stage's declaration check expects `read_tables`, `impute_cell_means` and `derive`, with both reviewed parameter sets. + - `council_tax_localise` declares `council_tax_localise_operation_parameters()` verbatim and in order: + - `verify_vendored_fact_resource` for Scotland's Band D at build period 2024; + - `derive` for the kept bill; + - `localise_council_tax`; + - `record_mass_conservation_receipt`, coupled to the terminal family gate as `private_rent`'s is. + + Its two Band D resources are artifacts with `runtime_sha256_required`: `council_tax_band_d` (`council_tax_band_d_england_wales_2024_25.json`) and `scotland_band_d_facts` (`scotgov_band_d_council_tax_2024_25.json`). Its one output and nonnegative output is `council_tax_frs_bill`. It rewrites `council_tax`, `council_tax_rebate` and `council_tax_benefit_reported`. Its notes describe this behaviour. `was_wealth`'s and `was_lisa`'s declarations are unchanged. +- **Shared vocabulary**, for Max's review. The source-stage schema gains the strict `localise_council_tax` kind: every key is required and no other key is allowed. `ALLOWED_SOURCE_OPERATION_KINDS` gains the kind. +- **The WAS read.** `was_wealth.recipient_predictors`, which `was_lisa` calls, now takes its council-tax predictor from `council_tax_frs_bill`. That is the paid bill the localisation keeps from before it localises: `max(council_tax - council_tax_rebate, 0)` on the FRS bill, the expression the predictor computed before. The predictor frame keeps its columns and their order. A frame without the kept bill is refused, naming the column. So the bill predictor is bit for bit as before, and the drawn area does not enter it. The HBAI net income both stages read from the engine sees the localised bill and reduction. +- **The graph and the spine build.** + - `council_tax_localise` opens its own graph version (`_READER_ISOLATION_BOUNDARIES`). It rewrites the housing shell's person council tax reduction, which `private_rent`'s finite reader anchors on, so without a version of its own the compile would close a cycle between the two. `private_rent` reads the shell's cells, and `was_wealth` and `was_lisa` read the localisation's. The spine graph gains the stage and `council_tax_localise.boundary`. + - The stage consumes each household's draw inputs (geography key, region, IMD decile, council-tax band and band flag), its drawn area, system and local authority, the bill's provenance and the single-adult flag. It also consumes the support channel's branch of the copy lineage and its true source and clone index. Like the area draw, it reads the three conditioned supports as graph sources. Its cells are the kept bill and the three rewrites, all float64; `frs_council_tax`'s cells gain the flag, a string cell. + - In `graph_kernels`, the stage's module is `spine_council_tax`. It is bound with the helpers its transform computes through, among them `atomic_support_expectations`, `bounded_amounts` and `council_tax_band_d`, and counts as a counting stage. It runs on the bitwise stage kernel every spine stage runs on (F10 is open with Max). The H2 fixture's registry builds it on the toy supports at the committed Band D. + - `spine_build` builds the stage on the supports the area stages read, holding them to the spine's support pins first. So a support replaced after the spine was prepared is refused with the area stages' message before the stage builds anything. The support flags' help names the stage. The sidecar's stage records report no nonzero share of the flag or of the kept bill (`_UNREPORTED_SHARE_COLUMNS`), as for the root's area carriers. + - The geography-first roster gains `COUNCIL_TAX_LOCALISE_STAGE`, and `spine_council_tax` reads its stage name from there. So the dense line's posture check, the spine CLI's release candidate and the national line refuse every spine built before this change, naming the stage alone. +- **The release boundary.** `UK_RELEASE_EXPORT_DROPPED_COLUMNS["household"]` gains `council_tax_bill_provenance` and `council_tax_frs_bill`, which no engine variable reads. Neither is a reviewed extra of the export surface (`UK_ALLOWED_EXTRA_EXPORT_COLUMNS`), so the dense and national exports carry neither. +- **Tools.** + - `tools/graph_uk_spine_fixture.py` runs the localisation in its oracle (`UK_FIXTURE_STAGE_COUNT` 63). + - `tools/build_uk_release_input_coverage_manifest.py` gains the stage's family, in `private_rent`'s form. + - `tools/verify_uk_identity_stability.py`'s scope docstring now names the stage's in-place rewrites, which no receipted recompute reads. +- **Generated files.** + - `source_stages.json` regenerates by the by-name merge. `frs_council_tax`'s unchanged operations keep their committed key order. + - The H2 fixture regenerates through the engine slot, and `--check` passes. Three files change: + - `uk_spine.json` gains the stage and its boundary; + - `sources/fixture.json` gains `frs_council_tax`'s new operation, output and notes sentence and the new stage; + - `sources/cgt_asset_type_facts.json` changes, because the tool sizes it to the oracle's frame before `cgt_residential_split`, which reads the stages the localised bill reaches. + + `property_rental_facts.json`, `property_purchase_targets.json`, `NORMALIZATION.md` and `PRODUCED_BY.txt` are unchanged. + - `release_input_coverage_manifest.json` regenerates without an H5, and `--check` passes. It gains the new family, and every family's source-manifest digest moves. +- **What moves.** + - Values, at one clone. Before `council_tax_localise` every existing column keeps its values: `frs_council_tax`'s bill is as before, and the flag is a new column. + - Great Britain's council tax, the reported council tax reduction and the rebate move by each household's ratio: its authority's 2024-25 Band D over the expected Band D of its own draw cell. On a statute row the reduction and the rebate move by the bill's own change instead. + - Missing bills, and bills netted of a reduction of unknown size, take the 2024-25 statute where the band was observed. + - A reduction or rebate above the new bill is capped at it. + - SPI copies and income band donors move at their region-level cell. + - Northern Ireland's rows are unchanged. + + The WAS bill predictor is unchanged bit for bit. The HBAI income WAS and LISA read moves with the localised bill and reduction. So can their draws, the home values the WAS chain localises, and every later stage that reads wealth, council tax or the reduction. Above one clone, clone 0's FRS rows take one clone's council tax exactly, and the SPI-channel rows nest to the share class. + - Keys. + - Every spine node re-keys, and so does every dense and national node after the spine. Of the stage contracts only `frs_council_tax`'s moves, and `council_tax_localise`'s is new. The UK country and solve fingerprints move. No gate phase code moves. + - Outside the UK one kernel re-keys: the shared transport gate battery (`gates.battery@1`). Its bindings' source closure reaches `source_manifest`, where `ALLOWED_SOURCE_OPERATION_KINDS` lives. So NZ's terminal gate and the export, readback and package nodes after it re-key (`nz.gates.terminal`, `nz.export.prepare`, `nz.export.readback`, `nz.package`), the cause María accepted on 12 Nov. + - No other NZ, AM, BE or US key moves. In those four countries' bundles, the schema edit moves only the spec engine's grammar receipt. +- **Tests**, on invented data, the toy supports and H2. + - Engine-free: + - the 63 stages and their order, the localisation right after `private_rent` and right before `was_wealth`; + - no stage from the area draw to the localisation writing a draw input but the housing shell's band, and no stage after it writing its columns; + - `frs_council_tax`'s operations, which now end with the derive, and its two outputs, the localisation's outputs, rewrites and mass receipt; + - the packaged stages equal to the reviewed declarations, and `frs_council_tax`'s transform writing the flag and its receipt from a pinned invented tab; + - the reader isolation and the cells each reader binds, the support readers, the consumes, and the counting stages; + - a pin that the housing shell's consumes hold no household area column; + - the roster refusing a spine without the stage, on the dense and the national lines; + - the support re-pin refusal for the stage; + - the release boundary dropping both columns on every line, and the sidecar reporting no share of either; + - the WAS predictor reading the kept bill and refusing a frame without it; + - the coverage family. + - Engine tier, through the slot: + - H2 parity; + - the driver's stage records leaving out both columns' shares; + - `required_build_stages` and the adapter's support readers gaining the stage; + - the localisation on all three systems at one clone and at two, after the real-engine BRMA and copy stages. Northern Ireland, an SPI copy among its rows, is left bit for bit. Great Britain's ratio rows take their cell's ratio. Reductions stay within the bill, and the kept bill is the paid bill from before the stage. + - After merge, H2's clone-first run at 63 stages: + - each ratio row's bill is its cell's ratio times its bill, with one where the cell holds one toy authority and other than one for some London and Scotland region-level rows, SPI-channel rows among them in each; + - household 12 and the households whose ids are multiples of 21 take the statute, and no other row does; + - every reduction lies within its bill, and the kept bill is the paid bill, which the WAS bill predictor reads, bit for bit, on the stage's output; + - clone 0's FRS rows at four clones are one clone's, bit for bit, and the stage's receipt is the same at every K but for the clone count. diff --git a/changelog.d/931-spine-localises-home-values.changed.md b/changelog.d/931-spine-localises-home-values.changed.md new file mode 100644 index 0000000000..6dbbb7c5fe --- /dev/null +++ b/changelog.d/931-spine-localises-home-values.changed.md @@ -0,0 +1,37 @@ +Localise England and Wales home values inside the UK spine's WAS chain, retire `regional_home_values`, and register the spine geography gates (#931). The WAS home-value localiser #931 group (c) added unwired is now declared: `was_wealth` reads each England and Wales owner's main residence off its assigned constituency's knots after the chain's second segment, its later segments condition on that value, and `regional_property_uprating`, dividing by the draw the localiser keeps, returns each of those homes to its knot value. `regional_home_values`, which wrote the regions' Land Registry values after the support copies, retires, so the packaged spine has 62 stages. Its roster is now geography-first, so the dense line's posture check passes on a packaged spine whose sidecar records its geography block, while the national line still refuses every clone-first spine. (Later in #931 the national line builds on a geography-first spine of one clone once the area-basis exclusion is signed for it: `931-national-one-clone-areas`.) The spine battery checks the areas the spine now assigns, in one gates digest break: the area draws' mapping integrity, each later copy's agreement with its parent, the BRMA and local-authority domains and the geography ladder, and the area home values' ranking in place of the retired stage's; the local battery's BRMA recheck retires, so the local contract has six gates. + +- **Stages** (`sources.yaml`, then `source_stages.json` by the by-name merge): + - `was_wealth` declares `localise_main_residence_value` after the chain's fit, with `area_home_values.area_home_values_operation_parameters()` as returned: the segment-2 draw it reads, the rows it rewrites, a keyed point inside each owner's weighted slice of its constituency and geographic clone, with the tie-breaks and the points on its own fixed stream (`sha256-u53-v1`, `uk-spine-area-home-values-v1`, 0, 0; seed source NONE, C-43), so a cell with few owners still reaches the top of its knots and geographic clone 0 takes the one-clone values (María's ruling of 17 Nov; method `uk-spine-area-home-values-v2`), the constituency knots, the region map, the factor it divides by and the rows it leaves. The two resources it reads are artifacts with `runtime_sha256_required` (`value_knots`, `high_value_home_value_knots.json`; `regional_reference`, `regional_land_values.json`). The kept draw, `main_residence_value_rank_basis`, is an output and a nonnegative output after `main_residence_value`; the release boundary drops it, as before. The support clip exempts `main_residence_value` and `property_wealth`, which a localised home can lift past the donor's range (C-18). A home read at the knots' cap takes the largest quotient the factor multiplies back to the cap or below, so the uprating never returns it one rounding above `uk_support`'s price-paid bound, which is the cap; the declared value says so. The stage's source now also cites the HM Land Registry knots and the public regional reference it reads, the provenance the retired stage's survey and source carried. The stage's notes are unchanged. + - `regional_property_uprating`'s operation declares `denominator: main_residence_value_rank_basis`, and its factor text and notes say the factor's mean is that draw's, over each region's FRS-base owners in geographic clone 0 (C-15), so a frame of K clones keeps the one-clone factor. + - `high_value_home_support`'s notes and its module's docstring no longer describe the retired dense value node: the stage selects on the localised values, and every copy keeps its parent's value, area and geography key. + - `regional_home_values` retires with its module (`uk_runtime/regional_home_values.py`) and its tests. The knots' constants it read stay in `area_home_values`, and `property_localisation.main_residence_rank_basis`, the reader of the column it stored, goes too. +- **Shared vocabulary**, for Max's review. The source-stage schema gains the strict `localise_main_residence_value` kind and an optional `denominator` (a string) on `uprate_to_regional_reference`; `assign_regional_home_values` leaves the schema and `ALLOWED_SOURCE_OPERATION_KINDS`, which gains `localise_main_residence_value` (C-42). +- **The graph and the spine build.** The localiser runs inside `was_wealth`, on the bitwise stage kernel every spine stage runs on (C-2; F10 is open with Max). `was_wealth` owns the kept draw's cell and `regional_property_uprating` consumes it, since the graph projects the stage's frame to what it consumes. `regional_home_values`' consumes, cells, module, helper bindings and counting-stage entry go, and neither the spine build, the H2 fixture's implementations nor the fixture tool's oracle (`UK_FIXTURE_STAGE_COUNT` 62) installs it. `UKWASWealthStageTransform.output_columns()` gives the kept draw where its stage declares the localiser (`UK_WAS_WEALTH_LOCALISED_OUTPUT_COLUMNS`, and `UK_WAS_WEALTH_LOCALISED_NONNEGATIVE_OUTPUT_COLUMNS` for the nonnegative ones), and the transform writes it beside the main residence, in the order the stage declares its outputs and the graph writes its cells, so the legacy plan and the graph give one column order (H2 parity holds the two to it). +- **The dense line's posture.** The packaged roster now has every geography-first name (`spine_posture.roster_failures` finds none missing), so `prepare_full_build` goes on past the posture check on a spine request and on a bound spine whose sidecar records its geography block, and the spine CLI's `--release-candidate` takes the dense release's 15 clones (C-38). A bound spine whose sidecar records no geography block is still refused, naming the block alone. +- **`--expected-constituency-vintage` retires**, as María ruled on 13 Nov. The dense line takes its areas from the spine, and no dense node read the ladder's vintage against the flag. `microcosm-build-uk` no longer takes it on either role, so a script that still passes it is refused as an unrecognized argument; the dense posture loses `expected_constituency_vintage`, its invariant and `UK_DENSE_CONSTITUENCY_VINTAGE`; and the run's recorded parameters no longer carry it. Records only: no kernel hashes `full_build_cli`, `rowwise_cli` or `rowwise_posture`, so no node or kernel key moves from it. The row-wise dataset tool's own flag and the geography ladder loader's keyword are unchanged. +- **Gates** (`uk/gates.json` and `uk_runtime.gate_scopes`, one digest break; no gate kind is added, so `country_spec`'s closed list, which NZ transport hashes, is untouched). + - At the assembled boundary, which closes after `area_brma`: `uk_atomic_area_mapping_integrity`, the `stage_health` check `atomic_mapping_integrity` on `atomic_area_assign`, whose recorded validation must have passed at the declared scope with SHA-256 digests of its definition and of the three conditioned supports. + - At the transferred boundary, after `spi_copy_areas`, the last spine stage that writes the area columns: + - `uk_spi_copy_area_mapping_integrity`, the same check on `spi_copy_areas`, which also accepts the `not_run` the stage records on a frame without a copy; + - `uk_copy_area_agreement`, the check `copy_area_agreement`, declared on `cgt_residential_split`, the last copy layer: every high-value support, CGT support split, CGT incidence clone and CGT residential split copy equals its immediate parent on the columns `spi_copy_areas` rewrites and on `region` and `household_clone_index`, and every SPI copy and income band donor on those two alone (C-11, C-20); + - `uk_local_authority_enum_domain`: every `local_authority` is a member of the installed engine's `LocalAuthority` enum, whose domain the spine battery's rules engine supplies (microcosm#953); + - `uk_geography_ladder`, the ladder gate (`spine_agreement`) on the transferred frame, the SPI copies' own ladders and the national line's among them (C-31); its London share is a population fact, so a synthetic smoke build records a failure without blocking on it; + - `uk_brma_enum_domain`, moved from the assembled boundary, since `spi_copy_areas` gives the SPI copies and income band donors BRMAs of their own. + - `uk_stage_regional_home_values_ranking` becomes `uk_stage_area_home_values_ranking`: the `area_home_values` check on `was_wealth`'s block, at `knots_level: constituency` and `rank_basis: weighted_slice_within_constituency_and_clone`. Its `maximum_sources_at_cap` is re-derived for the constituency knots rather than kept at the retired stage's zero: a slice point stays below 1, so a source reads the knots' cap only where its constituency's knots reach the cap below the top grid point, which the committed knots do in a few constituencies and only in the top thousandths of the distribution. The maximum is 9, the top of the receipt's 3-9 band, so the gate fails once the receipt prints 10-29 or more; the count is clone 0's, so it holds at any clone count. `stage_health`'s `regional_home_values` check retires with the stage. + - `uk_stage_was_wealth_support` declares the WAS support clip's exemption, `exempt_columns: [main_residence_value, property_wealth]`, and drops those two columns' row allowances. + - `uk_local_brma_enum_domain` retires: the dense line takes its BRMAs from the spine, and the transferred `uk_brma_enum_domain`, which its notes name as the replacement, checks them. The local contract has six gates (`UK_LOCAL_GATE_SCOPE`, the local scope's exclusion reasons), and `full_gates.classify_full_gate_outcomes`'s one structural local stop is the ladder gate. + - Stale notes are reworded without figures: `uk_support`'s, `uk_brma_enum_domain`'s and the terminal band check's, which named the dense line's retired nodes or `frs_brma`, and the high-value support gate's, which now says what its stratum ranks and what its copies keep. `uk_support`'s also says that the price-paid bounds give `main_residence_value` the knots' cap and `property_wealth` the cap plus the WAS donor bound's headroom over the main residence. `uk_local_area_support`'s notes are unchanged; `uk_stage_was_wealth_support`'s still describe the clip before the exemption and are left for a later spine digest break. + - The data shard's mirrors follow (`microcosm.data.contract`): the entries' gates and phases, the evidence entries, the spine certification part's scope, the dense line's six local entries and the certification's excluded ids, and the digests below; its test fixture's enum details follow the UK binding's count-free form (C-32). +- **Tools.** + - `tools/verify_uk_identity_stability.py`: E5 follows the denominator the packaged `regional_property_uprating` declares, read as the stage reads it. Dividing by the kept draw, the stage leaves no fixed point to re-apply, so E5 recomputes the main residence from that draw through both steps, the area home values (each owner's weighted mid-rank within its FRS region at the scoped frame's household weights, ties on the declared stream, its constituency's knots, divided by the region's factor) and the uprating, and holds the stored values to it at one rounding generation. The property total is named under the receipt's new `not_recomputed`, since the WAS chain drew it on the localised value; on a frame without the kept draw, a release, both property columns are, and the receipt records `uprating_denominator`. A `denominator` keyword runs the fixed-point form for a stage that divides by the main residence. The scope (`_frame_as_stage_saw`) no longer takes `regional_home_values`' rewrite back: `_SCOPE_REVERSALS` holds the salary-sacrifice conversion alone, and the reversal of `regional_home_values`' rewrite and its last-writer guard retire, since no stage after the uprating writes either property column. + - `tools/build_uk_release_input_coverage_manifest.py`: `regional_home_values`' family goes, and `was_wealth`'s carries the kept draw. + - `tools/graph_uk_spine_fixture.py`: the oracle runs the localiser through `was_wealth`'s declaration, on the committed knots and regional reference, without `regional_home_values` (62 stages). +- **Generated files.** `source_stages.json` regenerates by the by-name merge, which also aligns a stage's artifacts by role and its operations by kind, so `was_wealth`'s unchanged entries keep their committed key order and number spelling where its artifact and operation lists grew. The H2 fixture regenerates through the engine slot and `--check` passes: `uk_spine.json`, `sources/fixture.json`'s stage payloads, and the purchase targets and CGT asset-type facts the tool sizes to the oracle's frames, which move with the localised home values; `NORMALIZATION.md` and `PRODUCED_BY.txt` are unchanged. `release_input_coverage_manifest.json` regenerates without an H5 and `--check` passes: `regional_home_values`' family goes, `was_wealth`'s outputs gain the kept draw, and every family's source-manifest digest moves. +- **Defaults taken.** + - From the #931 group (c) design: C-2 (bitwise; F10 is open with Max), C-15 (form F), C-16 and C-44 (the localiser's evidence in rounded and banded clone-0 sources), C-17 (the rank within the FRS region, as ruled on 6 Nov), C-18 (the clip's exemptions and the cap's room), C-19 (support copies keep value and area), C-20 and C-31 (the gate design, the ladder at the transferred boundary), C-32 (count-free gate texts), C-38 (the spine's 15-clone release candidate on the geography-first roster), C-42 (the retired kind) and C-43 (seed source NONE on the localiser's own stream). + - Beyond it, each listed for María with its options in the commit message: the operation's place right after the chain's fit and the kept draw's right after `main_residence_value`, declared nonnegative; a plain-string `denominator` in the shared schema; `output_columns()` reading the declaration; the sources-at-cap maximum of 9; the new gates' places in `gates.json`; the WAS support gate dropping the exempt columns' allowances; no `evidence_absent_blocks` on the two domain gates; the ladder gate on its evaluator's defaults; the copy agreement holding later copies on `region` and `household_clone_index` too; the zero-weight strata row kept; E5's recompute through both steps, its `not_recomputed` field and its `denominator` keyword; the smoke run reading the new gates as not blocking rather than passed, with the ladder's and the ranking's failures held to their population facts; a home read at the knots' cap stepped down to the largest quotient the factor multiplies back to the cap or below, and the declared value saying so; `was_wealth`'s source citing the knots and the regional reference now; and the merge aligning artifacts by role and operations by kind. +- **What moves.** + - Values, at one clone: England and Wales owners' main residences come from their constituency's knots at their rank within their FRS region, in place of their region's knots after the support copies, and for those owners the chain's segments 3 to 11 (other property, pensions, financial wealth, mortgages and the rest) condition on them; the regional uprating leaves them at the knot value, to one rounding, and a home at the knots' cap at the cap or below; Scotland's and Northern Ireland's main residences are as before. High-value home support selects on the localised values, and its copies keep their parent's value (C-19), where `regional_home_values` gave each copy its own rank in its region's top stratum; on María's ruling of 25 Nov each copy draws its own area, as another clone of its household would, and takes its new authority's council tax. The stages that read home values or property wealth after it move with them: property components and purchases, Universal Credit capital, CGT selection and redraw, ISA subscriptions and private school attendance. Above one clone, the rank and the factor pool over the clones, so the values nest approximately. + - Keys: every spine node, and every dense and national node through the country fingerprint, a bound spine's checkpoint import too, since the spine gate digests it holds a stored report to move (below). Of the stage contracts only `was_wealth`'s and `regional_property_uprating`'s move, and `regional_home_values`' goes. Outside the UK one kernel re-keys, the shared transport gate battery (`gates.battery@1`), whose bindings' source closure reaches `source_manifest`, where `ALLOWED_SOURCE_OPERATION_KINDS` lives: so NZ's terminal gate and the export, readback and package nodes after it re-key (`nz.gates.terminal`, `nz.export.prepare`, `nz.export.readback`, `nz.package`), the cause María accepted on 12 Nov. No other NZ, AM, BE or US key moves; in those four countries' bundles the schema edit moves only the spec engine's grammar receipt. + - Gates: spine gate reports gain the five new gates and carry the ranking gate under its new id, and a failure of one blocks the spine at its boundary as every release-blocking spine gate does (the ladder and ranking gates' not on a synthetic smoke build); local gate reports lose the BRMA recheck. The gate battery's manifest, policy and fingerprint digests move, and with them the data shard's pins of the full battery, of the spine and release-cut certification parts and of the dense line's local battery; the calibration seam's part does not move. So a spine built before this change no longer binds: the strict loader holds its stored gate report's digests to the current declarations. The transferred spine gate's own code (`gate_phase_codes`) now also hashes what its new gates compute through, `copy_agreement`, `geography_ladder`, `local_authority_input`, `rowwise_geography`, `terminal_gates` and `microcosm.frame.materialize`; the assembled gate's own code is unchanged. The full build's calibrated gates' own code moves too, since it hashes `calibration_run`, `local_authority_input` and `terminal_gates`, whose texts this change rewords (keys only); the preflight's does not. Outside the UK no key moves beyond the four NZ nodes above. +- **Tests** (invented data and the packaged spec): the 62 stages; the declared operation verbatim, its artifacts, output and exemptions; the denominator; the kept draw's cell and the uprating's read of it; the packaged roster passing the posture check, its sidecar with a block passing and one without failing on the block alone; the dense preparation going on past the check on both routes; the spine CLI taking 15 clones on the packaged roster; the retired flag refused on either role and absent from the posture and the recorded parameters; the acceptance receipt's pending roster without `regional_home_values`; the knots' region map and the release's drop of the kept draw, moved from the retired tests; the K-sensitive table's sources-at-cap row read off the area home values gate, and rows for the knots' cap, the high-value support stratum and its copies; the zero-weight strata row, now kept, since its every maximum is zero rows; the declared battery's entries, phases and strict-evidence entries; the two area domains at the transferred boundary and the local BRMA recheck gone; each packaged geography gate's parameters held to the code's constants (the scope and support systems the area stages record, the copy-id layers and the copy stage's rewritten columns, the localiser's regions, knots basis year and level and rank basis); the cap maximum resting on the committed knots, passing through the receipt's 3-9 band and failing from 10-29 at any clone count; the WAS support gate passing a receipt that marks the two columns exempt; an off-domain BRMA blocking the transferred spine gate in every posture; the six-gate local scope, its one structural stop, and the stage-health frame readers; each gate battery phase keying on its own reach. E5 on frames the area home values, the uprating and the high-value support built (with and without the CGT layers): green with the copies folded back, red when they stay in scope or a stored main residence moves off the two steps, the property total named as not recomputed, both property columns named on a release, and the fixed-point form where the stage divides by the main residence; the scope taking nothing back for the home values and no later writer of either column; the SPI rows in E5's scope, red without them; at two geographic clones, green over both and red on clone 0 alone, since the rank pools over the clones. The coverage manifest's `was_wealth` family with the kept draw, and no `regional_home_values` family. The WAS stage writing its outputs, and the graph its cells, in the stage's declared order. A home read at the knots' cap coming back from the uprating at the cap or below, within the price-paid bound, which the plain quotient fails; the release export dropping the kept draw from a frame that carries it; every high-value support copy keeping its parent's localised value, kept draw, property total, seat and geography key, and the stratum selected on the localised value rather than the kept draw; and the stage kernel the localiser runs in pinned BITWISE (C-2), so a ruling on F10 changes the pin on purpose. On the engine tier: H2 parity; `required_build_stages` without `regional_home_values`; the clone-first H2 test at 62 stages, with every England and Wales owner localised after `was_wealth`, Scotland's draws kept bit for bit, the kept draw reaching the last population and dropped at the release boundary, the localiser's block carrying its clone count at every K, and its values in the share class above one clone; `was_wealth`'s values equal to the area home values on the stage's input frame bit for bit, the uprating returning each localised home to its knot within one rounding (and a home at the cap to the cap or below), and every high-value support copy equal to its parent on every column but its ids, at one clone and at four; the integration smoke run's spine battery, in which each new or moved spine gate passes or, a population fact the fixture is not, fails recorded and not blocking (on H2 the ladder gate's London share, since its root cycles four regions, and the ranking gate's declared regions, since it holds three of England and Wales's), and those two fail on their population facts alone. diff --git a/changelog.d/931-spine-mapping-gates-read-the-frame.changed.md b/changelog.d/931-spine-mapping-gates-read-the-frame.changed.md new file mode 100644 index 0000000000..8a33571491 --- /dev/null +++ b/changelog.d/931-spine-mapping-gates-read-the-frame.changed.md @@ -0,0 +1,15 @@ +The spine's two area mapping gates, `uk_atomic_area_mapping_integrity` at the assembled boundary and `uk_spi_copy_area_mapping_integrity` at the transferred boundary, now fail on content (#931). They held the area stages' records to their own form alone. They now also hold each record's digests to the spine's geography block, and re-derive every household's area and ladder from the phase's frame on the conditioned supports that block pins. Their names, phases, parameters and scope are unchanged, and no value moves. + +- **The check** (`stage_health`, `atomic_mapping_integrity`). Beside the record's outcome and scope, it holds the record's `definition_sha256` and `support_sha256` to the `definition_sha256` and `support_pins` of the spine's geography block, the block the spine build's sidecar records (`country_adapter.uk_spine_geography_binding`). + - It holds the conditioned supports it is handed to the block's pins (SHA-256 and size), builds the area draw's definition on them at the spine's seed, and holds that definition to the block's. + - On that definition it re-derives each household's fallback level from its stored draw inputs (`uk_draw_inputs`, `uk_draw_levels`, `uk_draw_frame`) and runs the shared validation (`atomic_geography.validate_geography`) on the stored assignment and ladder columns, as the area draw checks the rows it places. Each ladder column must be the one the support maps the stored area to, and each area must lie in its household's region, and in its IMD decile where the household's level keeps the decile. No draw is repeated. + - At the assembled boundary that is every row the area draw placed. At the transferred boundary it is every row: the FRS households', the SPI copies' and band donors', and the later copies'. + - So a record with invented digests fails, and so do a ladder column overwritten after the draw and a draw that took households at a coarser level than their stored inputs give. + - Its details add two booleans, `agrees_with_binding` and `frame_holds`. Its texts name the field, or give the draw inputs' or the shared operator's own refusal, which names columns and declared constants only. +- **Bindings** (`battery_bindings`). The stage-health binding hands the mapping check the phase's frame and two evidence artifacts, `spine_geography` and `atomic_area_supports`, which it declares for that check alone. A battery without either, or without the frame, reports the gate evidence_absent, which blocks it in every posture (`evidence_absent_blocks`). +- **Gate nodes** (`graph_evidence`). `add_uk_spine_gate_nodes` takes the spine's `geography` block. Given it, each phase whose stages include `atomic_area_assign` carries the block as its `spine_geography` parameter and reads the three conditioned supports as graph sources, which the graph must declare. The gate kernel hands the block and the supports' bytes to the battery (`uk_spine_geography_artifacts`). The spine build's preparation passes the block it composes, so the spine build and the in-graph full build bind it. `build_uk_country_graph`, which composes no block, binds none, so its mapping gates would be evidence_absent. +- **Keys.** UK only. The spine gate kernel's hash adds what the check computes through in both phases: `atomic_geography`, `atomic_support_conditioning`, `atomic_area_conditioning`, `atomic_area_support`, `source_lineage`, `household_lineage`, `microcosm.graph`'s canonical encoding and randomness, and `rowwise_geography`. `rowwise_geography` leaves the transferred phase's own code for the kernel's hash, since both phases now compute through it. `UK_GATE_REGISTRY_MODULES` adds six of them, so the national gates re-key. Both spine gate phases re-key, and with them every node after `area_brma`: the rest of the spine, and every dense and national node. No stage kernel, stage contract, declaration or generated file changes, and no transport or US key moves. In `gates.json` only the two gates' notes change, to say what they now check, so the gate battery's pins move. +- **Tests**, on invented households and the toy conditioned supports. + - `tests/engine_free/uk/test_uk_stage_health.py`: the area draw's and the SPI-copy area stage's receipts and frames pass on the block over the toys, at one clone and at two; a receipt with an invented definition digest, or invented support digests, fails; a frame whose `lsoa_code`, `msoa_code` or `constituency_code` is overwritten on one row fails, on the copy stage's frame on an FRS row and on an SPI copy's alike; a draw that took every household at L3, whose own validation passes, fails; the check fails without the block, with a block a pin short, with a support changed or absent, without the frame, and with a block whose definition the supports do not give; and through the battery's registry each packaged gate passes, and is evidence_absent, blocking, without the block, the supports or the frame. + - `tests/engine_free/uk/test_uk_graph_evidence.py`: given the block, both gate phases carry it and read the three supports, and a graph that does not declare them is refused; the kernel hands the block and the supports' bytes to the gates of a node that carries it, and nothing otherwise. + - `tests/engine_free/uk/test_uk_battery_bindings.py`: the stage-health binding reads the frame for five packaged gates, the area draw's mapping gate at the assembled boundary and the others at the transferred boundary, and declares the block and the supports for the mapping check alone. diff --git a/changelog.d/931-spine-shared-names.changed.md b/changelog.d/931-spine-shared-names.changed.md new file mode 100644 index 0000000000..702196db7a --- /dev/null +++ b/changelog.d/931-spine-shared-names.changed.md @@ -0,0 +1,8 @@ +The spine's stages import the shared names they used to spell for themselves, as `docs/shared-constants.md` asks, and the tests that held each copy equal to its owner go (#931). + +- **The household clone index.** `cgt_support` drops its unread copy, and `spi_support`, `spi_band_donors` and `spi_spine` read `geographic_clones.ladder_clone_index_column("household")`; `spi_support.SPI_GEOGRAPHIC_CLONE_INDEX_COLUMN` goes. +- **The area draw's inputs.** The draw reads the root's decile column, its unobserved code and its band flag from `frs_area_draw_columns` (`FRS_IMD_DECILE_COLUMN`, `FRS_IMD_DECILE_UNOBSERVED`, `FRS_COUNCIL_TAX_BAND_OBSERVED_COLUMN`), a module that holds those names alone and that `frs_spine` imports them from, as do its declared operation, the council-tax localisation's inputs and `tools/measure_uk_atomic_assignment.py`; `atomic_area_conditioning.COUNCIL_TAX_BAND_OBSERVED_COLUMN` and `UNOBSERVED_IMD_DECILE` go. The conditioned supports keep their own decile code column, `atomic_area_support.IMD_DECILE_COLUMN`. +- **Release lines.** `national_frame.UK_RELEASE_LINES` is the one definition of the UK release lines; `weighted_integrity` and `battery_bindings` import it, and `weighted_integrity` no longer exports it. The national line's clone index drops are built with `ladder_clone_index_column`. +- **The mapping-integrity scope.** `atomic_geography.ATOMIC_GEOGRAPHY_VALIDATION_SCOPE` names the scope `validate_geography` records, and the spine's area stages hold the receipt to it. `spine_geography` takes Northern Ireland's region from `atomic_area_support`'s profile. +- **Bindings.** `frs_spine`, `atomic_area_assign`, `spi_copy_areas` and `council_tax_localise` bind `frs_area_draw_columns`, whose names their draw inputs read, and so do the spine gate kernel's hash and `UK_GATE_REGISTRY_MODULES`, since the area mapping gates re-derive the draw inputs: the gates and the national line key on the names without keying on `frs_spine`; `area_brma` binds `rowwise_geography`, the FRS region map the support profile reads. +- **What moves.** Keys only, no value: every name keeps its spelling, so no declaration, generated file or value changes; the nodes whose kernels hash an edited module, or whose bindings grew, re-key. diff --git a/changelog.d/931-stage-profile-dir-outside-work-trees.fixed.md b/changelog.d/931-stage-profile-dir-outside-work-trees.fixed.md new file mode 100644 index 0000000000..653bc554ad --- /dev/null +++ b/changelog.d/931-stage-profile-dir-outside-work-trees.fixed.md @@ -0,0 +1 @@ +The spine build refuses a `--stage-profile-dir` inside any git work tree (#931). It compared the resolved path with this checkout's own, so it refused the checkout only as spelled: another checkout or worktree passed, and so did this one spelled in another case on a case-insensitive volume. It now holds the directory with `receipt_counts.outside_work_trees`, the check the tools hold their licensed outputs with, which refuses a path below any directory holding a `.git` entry. The refusal stays one fixed sentence: `--stage-profile-dir must lie outside every git work tree: ...`. No stage, node key or generated file moves. diff --git a/changelog.d/931-take-up-counts-per-clone.changed.md b/changelog.d/931-take-up-counts-per-clone.changed.md new file mode 100644 index 0000000000..95bf6cd60a --- /dev/null +++ b/changelog.d/931-take-up-counts-per-clone.changed.md @@ -0,0 +1,9 @@ +`frs_take_up`'s Child Benefit, Pension Credit and Universal Credit draws and `frs_person_draws`' apprentice walk now count within each geographic clone, so clone 0 of a clone-first spine takes a one-clone spine's flags (#931; María's rulings of 6 and 10 Nov). Before, the anchored residual took `int(rate × n)` once over every clone's benefit units, and the walk interleaved every clone's employees and stopped once, so clone 0's flags were not one clone's. The stages' other draws were already keyed on each row's own id. + +- **Shared `strata`** (for Max's review). `stochastic_assignment.assign_binary_with_anchored_residual` takes a keyword-only `strata`, one integer per row. Each stratum's rows take the flags they take alone: their own `int(rate × n)` target, the need their own anchors leave and the threshold their own non-anchored rows fill. Without `strata` the function runs as before; with every row in one stratum it gives the same flags bit for bit, and without an anchor strata change nothing. Strata that do not align with the draws, and strata without an integer dtype, every column with a missing label among them, are refused in fixed sentences that name no count, label or row. The module names no country, and only UK modules and UK tools import it. +- **frs_take_up.** `derive_frs_take_up` takes `clone_index` and passes it as `strata` to the three anchored draws. The stage reads each benefit unit's clone from `household_clone_index` through the person memberships with the new `geographic_clone_indices`, which shares its mapping with `geographic_clone_zero_rows`, so its consumes do not change. A frame without the column passes None. +- **frs_person_draws.** `derive_is_apprentice` takes `person_clone_index`, as do `derive_frs_person_draws` and `derive_frs_person_draws_with_receipt`, and each clone walks its own employees to the rate times its own weight aged 21 to 24, with the unchanged nearest-target walk. The stage reads the index through `geographic_clone_indices`. The receipt keeps its keys and their formulas: the masses and the realized weight are sums over every clone, `target` is the rate times the weight aged 21 to 24 over every clone, and `cap_bound` compares the eligible weight over every clone with that target, as the `apprentice_draw` stage-health check recomputes them. The supports are still counted among clone 0's people in true source households, and withheld below the floor of three as before. A misaligned or non-integer index, or a `person_clone_zero` that disagrees with it, is refused in a fixed sentence that names no count or row. +- **E4** (`tools/verify_uk_identity_stability.py`) gives both recomputes each row's clone, read once from the scoped frame and carried by id onto the permuted tables, and holds stored `is_apprentice` flags to the walk within each clone. Its `tolerance_policy` text says so. +- **What moves.** At one clone, no value: both stages' outputs and receipts are as before, bit for bit, with or without a one-clone index, and E4's receipt differs only in its `tolerance_policy` text. On the synthetic H2 fixture the legacy oracle's final frame, its stage records and every stage's evidence digest are identical before and after, and the fixture regenerates byte-identically. Above one clone, which no build has yet run on this code, the three anchored flags and `is_apprentice` move, each clone meeting its own target. Clone 0's anchored flags are one clone's exactly. Its `is_apprentice` flags are one clone's at any power-of-two clone count, and elsewhere except at a near-tie of the walk. Whatever reads these flags follows: `frs_brma` reads `would_claim_uc` through `LHA_category`. (Later in #931 `area_brma`, in its place, does.) `spi_benefit_coherence`'s Universal Credit redraw and `uc_take_up` still count over every clone. +- **Keys.** The frs_spine root and 49 of the 57 stages after it hash `stochastic_assignment`, so every spine node re-keys, and both spine gate nodes with them. Of the gate phases' own codes, the transferred spine phase's hashes `stochastic_assignment` and moves; the assembled phase's does not. On a bound spine the national gates re-key, and so do the full build's calibrated gates and the nodes after them, through the terminal phase's code, which hashes `frs_take_up`; they do so without a re-solve, since the preflight's code and the solve's key leave that code out. No node hashes the identity tool. Of the 48 kernels the transport registry registers, from which NZ's graph is composed, all but the gate battery keep their hashes. The battery's key (`gates.battery@1`) binds the sources its gate bindings compute through, US keyed draws among them, and since microcosm#1585 those import `stochastic_assignment`, so NZ's terminal gate node re-keys, and so do the export, readback and package nodes that chain on it. No NZ, BE or AM module imports an edited file. The US keyed draws take only `stable_identity_uniforms` from `stochastic_assignment`, which this change leaves as it was, so no US draw moves; but the US seed protocol attests the module, so the seed protocol's and the seed map's digests move, and with them the US bundle's spec hash (later in #931 these pins are re-derived). No declaration, generated file, `gates.json` or schema changes: `frs_take_up`'s notes, `frs_person_draws`' `rate_derivation` and the take-up contract's policy line follow with the geography declarations. (Later in #931 they do: `931-spine-assigns-areas`.) +- **Tests** (invented data). The shared keyword against its arithmetic before strata, without strata and with one stratum in three integer dtypes; two hand-built strata, under relabelling and row permutation; strata without an anchor; and the refusals. `frs_take_up` on the clone-first stand-in at three clones over a grid of rates, and bit for bit at one clone. The walk at two and four clones, its supports and cap bound at three, an exact tie of the walk that clone 0 keeps at every power-of-two clone count up to 16 and breaks by at most one person elsewhere, the stage at four clones, and bit for bit at one clone. Both stages through `geographic_expand` at 2, 3, 7 and 15 clones, where counting over every clone instead moves clone 0 for each of the four draws. E4 at three clones at two Universal Credit rates, and the walk check within each clone. The engine-tier test at four clones, where clone 0 through `frs_brma` is now the one-clone frame on every column. diff --git a/changelog.d/931-transport-helper-bindings.changed.md b/changelog.d/931-transport-helper-bindings.changed.md new file mode 100644 index 0000000000..fa420cbc47 --- /dev/null +++ b/changelog.d/931-transport-helper-bindings.changed.md @@ -0,0 +1,11 @@ +Every transport kernel now hashes each first-party module that its own code, or an object the transport registry hands it, computes through, as far as the derived binding rule the UK stages and kernels are held to can see, apart from the core modules every node runs through and two checks that only refuse (#931). `source_hash` hashes only the files it is given, so a transport node that called a function in a module its hash did not name replayed a stale cached output when that module changed. Only node keys move. + +- **The rule, shared.** The rule's walk moved from `test_uk_graph` to `test_support/microcosm_build/derived_binding_rule.py`. Each country passes its tables as a declaration there, and the UK's walks are unchanged. The rule's refusal check now counts a store into a container the function itself creates as local. +- **The transport's tables.** `test_transport_binding_rule` holds 45 of the 48 kernels `build_transport_registry` registers to the rule: 37 of the transport package's 40, the shared atomic geography's four, the ordered solve and the three rules kernels. The other three, main's income-evidence kernels, are held to it later in #931. The transport has its own tables, each entry with a reason a test checks: the eight core modules, 19 core definitions, two refusal-only checks (`graph_inputs.require_outputs` and `reference_profiles._validate_interval_resolution`) and one stop, `target_kernels._COMPILE_MODULES`, which only implementation hashes read. The rule also walks what the registry hands the kernels: the `AxiomEngine` behind the rules kernels and the input closure, and the gate registry behind the battery, whose key also binds its bindings' source closure. +- **What is bound.** 79 bindings in 36 kernels: + - the canonical JSON encoder in 32 kernels. It joins the compile list (`transport/compile_modules.py`) for the seven kernels that hash it, and `_GRAPH_RUNTIME` now excludes only the kernel protocol and the declarations; + - the target surface's factor evidence and its Chronicle feed identity (`reference_factors`, `ledger_artifact`, `chronicle_epoch`), in the kernels that decode or check a surface; + - `artifact_types`, `calibrate.target`, `graph_atomic_geography` and the Axiom input surface where kernels name them; the gate report records (`country_spec`, `gate_battery`, `gates`) in the export and package kernels; `build.trace` in the export readback; `takeup_kernels` in the battery; `frame.rules` and `frame.materialize` in the input closure; `calibrate.hierarchy` and `monetary_binding` where targets or matrices are rebuilt; `frame.exact_money` in the counterfactual bridge, as in the zero solve; + - the ordered solve's internals (exact-k, the L0 gates and their initialization record, the hierarchy, the monetary binding and the encoder) in `calibrate.ordered_adam@1`'s own half, so `calibrate.adam@1`'s hash, which UK kernels and the parity pins embed, does not move. +- **The import record.** `test_transport_compile_modules` drops microcosm#1497's record of unclassified imports, its kernel groups and the record check. It keeps the compile list's closure checks and the geography-label re-key test, and now checks that no transport kernel hashes the compile list. The import scan's record helpers, which nothing else used, go. +- **What moves.** Node keys only. 43 of the 48 transport kernel hashes move, main's three income-evidence kernels among them; the four atomic geography kernels and the person location keep theirs. All 369 nodes of New Zealand's packaged graph re-key: 365 directly, and the atomic geography and person location nodes by chaining. Belgium composes no graph. No UK kernel hash moves (0 of 101), nor do `calibrate.adam@1`'s or `simulate.rules@1`'s, and nothing of the US's. No value, declaration or generated file moves. diff --git a/changelog.d/931-uc-children-seat-deferrals.changed.md b/changelog.d/931-uc-children-seat-deferrals.changed.md new file mode 100644 index 0000000000..4a0b525936 --- /dev/null +++ b/changelog.d/931-uc-children-seat-deferrals.changed.md @@ -0,0 +1,6 @@ +The local line defers two Universal Credit child-bucket constituency cells under the new signed reason `uc_children_constituency_spine_support_absent` (#931): Wokingham's (E14001593) two-children cell (`dwp.uc.households_by_area_children_2`) and Stratford-on-Avon's (E14001526) three-or-more-children cell (`dwp.uc.households_by_area_children_3plus`). On the geography-first K=15 spine of #1538 the dense pool has no household in either cell, so the rowwise driver's support check refused them, while every other Great Britain constituency cell of both buckets binds; the dense pool on main's route carried both. The deferral lets the spine be calibrated and compared with main's route, and the assignment's support for the two cells stays open under #931 (María's ruling of 24 November 2026). + +- **What moves.** The two cells leave the active local surface (27,157 to 27,155 references; 2,942 to 2,944 signed deferrals). In the local compile-parity receipt the two cells turn from drift rows into fixture-only rows (19,274 to 19,272 drift rows, 4,267 to 4,269 fixture-only), and the UC child-bucket drift rationale now quotes 2,525 rows rather than 2,527; its spread holds. `tools/build_uk_ledger_compile_parity_signed_differences.py` reads the new reason beside the small-cell rules, so the incumbent's two cells carry the rationale their deferral was signed with. +- **Partition step.** The two deferred cells stay off the reconciliation frame, since no control moves their leg, so the target compilation met each seat's UC children partition with one bucket absent and refused it. The partition is `share_of_parent`: each bucket moves by its parent's own reconciliation factor, which no other bucket enters, so the buckets present move as they would beside the absent one. `apply_cross_grain_partitions` now lets a `share_of_parent` partition miss a member only where a signed deferral leaves that member's cell off the frame, and names it under `members_absent` in the partition receipt. The target compilation hands it the membership's signed cells off the surface (target id and area), so any other missing member, a feed gap among them, still refuses, naming the partition, the area and the member. An `exhaustive` partition still refuses a partial set, since it rescales its members jointly onto the parent. +- **What holds.** No other reference, membership record or parity row changes. No kernel hashes either tool. The regenerated resources feed the dense target nodes, not the spine, and the spine gate declarations do not move, so a spine built at 6fff0bccf still binds. +- **Tests.** The local default surface's counts follow: 27,155 candidate targets and 4,192 reviewed exclusions; the 31,347 references hold. A cross-grain test moves a `share_of_parent` partition with one signed member absent as the whole partition would move, and receipts the absent member; another refuses the partition where no signed deferral covers the missing member, or where one covers another member or another area. diff --git a/changelog.d/931-uk-annual-income-other-spells-growth.changed.md b/changelog.d/931-uk-annual-income-other-spells-growth.changed.md new file mode 100644 index 0000000000..d051137ef9 --- /dev/null +++ b/changelog.d/931-uk-annual-income-other-spells-growth.changed.md @@ -0,0 +1 @@ +The annual-income simulation carries each input's other spells by policyengine-uk's own growth parameters (#931). The factor is the product, over each year after the dataset's up to the measurement year, of one plus the engine's rate in the series its dataset projection uses for the input: `gov.economic_assumptions.yoy_growth.obr.average_earnings` for pay and `gov.economic_assumptions.yoy_growth.obr.per_capita.mixed_income` for profit. It replaces the median of the engine's year-on-year ratios over the rows a simulation held, a statistic of whichever engine block ran, so every per-clone block and one engine over the pool now use the same factor. The engine's rows must still agree with it within 1e-5, or the resolver refuses. This moves data on the national and dense lines: an annual input with other spells can move by one float32 step, and with it the `*_annual` matrix entries, calibrated weights and H5 bytes. `other_spells_engine_factors` changes in every resolver receipt that carries it. diff --git a/changelog.d/931-uk-atomic-geography-wiring.changed.md b/changelog.d/931-uk-atomic-geography-wiring.changed.md index 42edfd16e6..dbd45e16d1 100644 --- a/changelog.d/931-uk-atomic-geography-wiring.changed.md +++ b/changelog.d/931-uk-atomic-geography-wiring.changed.md @@ -1 +1 @@ -The UK full build assigns geography on the shared atomic-geography operators: households are keyed by their explicit spine lineage (`uk.full.identity`), one atomic area is drawn per household by census household count within FRS region under a keyed stream, larger geographies derive from the support mappings, and the shared gate must pass before the pool checkpoint. `--geography-assignment legacy` keeps the sequential ladder draw for measurement builds; release candidates refuse it and pin the three supports (#931). +The UK full build assigns geography on the shared atomic-geography operators: households are keyed by their explicit spine lineage (`uk.full.identity`), one atomic area is drawn per household by census household count within FRS region under a keyed stream, larger geographies derive from the support mappings, and the shared gate must pass before the pool checkpoint. `--geography-assignment legacy` keeps the sequential ladder draw for measurement builds; release candidates refuse it and pin the three supports (#931). Later in #931 the dense line retires these nodes and flags and takes its geographic clones, areas and sampling from the spine it binds, whose own stages assign them. diff --git a/changelog.d/931-uk-child-benefit-age-noise-tolerance.changed.md b/changelog.d/931-uk-child-benefit-age-noise-tolerance.changed.md new file mode 100644 index 0000000000..4f76667a67 --- /dev/null +++ b/changelog.d/931-uk-child-benefit-age-noise-tolerance.changed.md @@ -0,0 +1,6 @@ +The UK Child Benefit take-up stage gate (`uk_stage_child_benefit_take_up`) now holds each measured age within the larger of 0.05 and three standard errors of a share drawn at its published rate over its child rows (#931; María's ruling of 10 Nov). A measured age, one with at least `minimum_age_child_rows` child rows whose solved rate was not clipped, was held within a fixed `maximum_age_claim_rate_deviation`, 0.05, of HMRC's published rate for it. The band is `maximum_age_claim_rate_standard_errors` × sqrt(p (1 − p) / n), with the new parameter declared as 3, and p and n the receipt's `published_rate` and `eligible_child_rows` for the age. It treats the age's child rows as independent draws at p, an approximation as ruled: in the stage, siblings share their family's draw, reporters always claim and the realised rate is weighted. + +- **Why.** #931's keyed redraws move each age's realised claim rate by sampling noise. At an age with few child rows that noise can exceed a fixed 0.05, and because the draws are keyed, such a failure would repeat on every rebuild, including the national build. +- **Floor.** Three standard errors exceed 0.05 only below 3,600 p (1 − p) child rows, so an age with more rows keeps 0.05 and only thin ages loosen. At a published rate of 0 or 1 the term is 0, so the floor holds. The overall claim-rate check and the opt-out check are unchanged. +- **Report.** A failing age's line names the tolerance used at that age, "(tolerance t: the larger of 0.05 and 3 standard errors of a share at the published rate over that age's child rows)", and the gate's details count the measured ages held to more than the floor (`ages_tolerance_above_floor`). The gate refuses a missing, non-finite or non-positive `maximum_age_claim_rate_standard_errors`. The stage-health binding now routes the parameter, since the battery refuses a declared parameter its binding does not route. +- **What moves.** The gate's verdicts at thin ages: an age whose realised rate is more than 0.05 from its published rate but within its three standard errors now passes. No stage output or generated file moves: the gate reads the receipt and draws nothing. Of the 99 UK kernel hashes 14 move, and no phase code: the spine gates' (`stage_health`, `battery_bindings` and the solve fingerprint, which `gates.json` is part of); `uc_deduction_attributes`' and `uc_take_up`'s (`stage_health`); the full build's target compilation, selection, measures, problem and rotated holdout (the solve fingerprint), its preflight and calibrated gates (`battery_bindings` and the solve or country fingerprint) and its certification readiness (`microcosm.data.contract`, which the re-pin edits); and the national targets, problem and gates (the country fingerprint; the gates also hash the gate registry's modules). Node keys move from the assembled spine gate on: 66 of the gated spine's 83 nodes. On a bound spine the full build re-keys from its target compilation on, so it re-solves, and the national line re-keys all but the bound checkpoint. The contract re-pins the gate battery's policy, gates-manifest and spec-fingerprint digests and the release certification's spine part; the calibration seam, release cut and dense line digests do not move. diff --git a/changelog.d/931-uk-child-benefit-gate-clone-zero-rows.changed.md b/changelog.d/931-uk-child-benefit-gate-clone-zero-rows.changed.md new file mode 100644 index 0000000000..37200dee11 --- /dev/null +++ b/changelog.d/931-uk-child-benefit-gate-clone-zero-rows.changed.md @@ -0,0 +1,7 @@ +The UK Child Benefit take-up stage now counts its receipt's eligible child rows, overall and at each single year of age, among geographic clone 0's rows (#931), so its stage gate (`uk_stage_child_benefit_take_up`) measures the same ages, each against the same sampling band, at every clone count. Before, `eligible_child_rows` counted every clone's rows: an age below the gate's `minimum_age_child_rows` of 200 at one clone held K times its rows on a spine of K clones, so it was measured there, against a band narrower by the square root of K. + +- **Receipt.** `child_benefit_take_up` reads each eligible child's clone from its household's `household_clone_index` through `frs_take_up.geographic_clone_zero_rows`. `assign_child_benefit_claims` and `solve_child_benefit_claim_rates` take a keyword-only `child_clone_zero`, one flag per eligible child; without it every child counts, as on a one-clone frame, and a misaligned array is refused in a fixed sentence that names no count. The weighted figures and the realised rates are still taken over every clone, and the receipt's other unit counts, `eligible_family_units` among them, still count every clone's units. +- **Gate.** The check and its parameters do not change. The floor and the band's n both read the receipt's `eligible_child_rows`, so both are one clone's. The realised rate is taken over every clone, each on its own keys, so a band read on one clone's rows is no narrower than the noise of a rate realised over several. The check's docstring and the gate's notes in `gates.json` say what the rows count. +- **Constants table.** `test_uk_k_sensitive_constants.py` classifies `minimum_age_child_rows` as rows counted in clone 0. Its guard now reads a packaged gate's minima (names that start with `min`) as well as its maxima, and counts of units, and the table classifies what that finds: the band donor gate's `minimum_donors_per_band` (per clone, with the stage's constant), the local area support gate's `minimum_rows` and `minimum_distinct_sources` (kept, as before), the HMRC leaves' `minimum_signal_rows` (survey records, counted before the clones), five floors of one row over every clone (kept: more clones can only meet them more easily), two floors on the cells of a published table (invariant, a new count class) and the high-value homes support gate's `minimum_distinct_sources` (kept). +- **What moves.** At one clone, no value and no verdict: every row is clone 0's. On a spine of more than one clone the receipt's row counts are one clone's, and the gate measures the ages a one-clone spine measures. The `child_benefit_take_up` node now hashes `frs_take_up`, through which it reads the clone index, so it re-keys, with every node after it. `gates.json` changes in this gate's notes only; the gates manifest digest moves with them, and so do the pins that mirror it. +- **Tests** (invented data). The receipt at two clones against one; the stage at four clones against one, and at one clone with and without the clone index; and an invented receipt of 900 source families with a child aged 5 and 150 with a child aged 19, at published rates of 0.9 and 0.5 and realised rates of 0.91 and 0.42, which gets the gate's one-clone verdict at fifteen clones, where counting every clone's rows measures the age of 19 and fails it. diff --git a/changelog.d/931-uk-clone-receipts.changed.md b/changelog.d/931-uk-clone-receipts.changed.md new file mode 100644 index 0000000000..55c2a3ddde --- /dev/null +++ b/changelog.d/931-uk-clone-receipts.changed.md @@ -0,0 +1,18 @@ +The UK stage receipts and stage checks now read a spine of more than one geographic clone (#931; María's rulings of 10 Nov). Every new count is of distinct true source households, rounded through `receipt_counts`. The spine still builds one clone by default, so no value and no gate verdict moves. At one clone only the `spi_support_channel` and `spi_income_band_donors` receipts change, with the band donor check's details and failure texts and the clone count's refusal texts. + +- **Fold receipts.** Every FRS-trained fit folds its training rows through `household_lineage.fold_geographic_clones`: the SPI income stage's reference and stage-2 forests, the SPI employment and housing shells, the UC reporter redraw, UC capital and salary sacrifice. On more than one clone, each of these stages' evidence gains `geographic_fold` (`household_lineage.geographic_fold_receipt`). It gives the clone count; the source households the fit selected, and those whose clones differ on what the fit reads, both rounded as every receipt count is; and the share that differ, given only where ten or more of the selected households differ and none or ten or more do not, and otherwise the count of those that differ again. A one-clone spine's evidence is unchanged. +- **Twin check.** `cross_fit_transport` takes `twin_identities`, read only to find each recipient's twin among the training rows. The SPI income stage passes each copy's twin through its forests' fold, so the check reaches the copies of every clone. Each copy's uniforms stay keyed on its own identity; on one clone the two keys are the same. +- **`spi_support_channel`.** Its receipt gives the frame's clone count. Its two pension-age counts are rounded distinct source households carrying the mass beside them, on rows of positive weight: the pension-age base households', and those of clone 0's pension-age SPI copies. Both are the same at every clone count, and the masses are unchanged. +- **`spi_income_band_donors`.** + - At every seating, each funding row keeps its stratum and its rounded donor households and reads `<3` for its masses and factor. The receipt gains two booleans: `funding_within_share`, every factor at least one less the declared reallocation share, to the stage check's relative tolerance; and `funding_matches_bands`, the bands and the funding strata each carrying the reallocated mass. + - On a capped seating, each band's donors and carriers, and the donor count, are rounded distinct source households. Each band's weighted taxpayers and carriers' mean age, and the reallocated mass, read `<3`, and each band's carrier regions are left out. A full seating keeps the plan's exact band counts. + - The result keeps the exact figures, and its frame, out of its repr. + - A band short of candidates or seats is refused naming the band and, on a cloned spine, that a clone fell short, without a count. +- **The band donor check.** It reads the funding from the two booleans and requires one less the receipt's reallocation share to reach its minimum funding factor; its details drop the smallest funding factor. On a capped seating it recomputes the seats from the transferred phase's frame. A seat is a band donor row whose id holds no ordinal in a copy-id field minted after the band donors, since every later layer keeps the row it copies at its own id. Every declared band must seat a donor, every seat must hold one carrier, and each band's seats must split evenly across the clones; the bands' mass there is the stage's `funding_matches_bands`, since later layers reweight the seats. The details then carry the clone count, the seating, the mass scale, the booleans and the count of bands. No failure text gives a count. The stage-health binding hands the frame to this check alone, `copy_id_table` joins the gate registry's modules, and the transferred phase's own code hashes it. +- **Clone count.** `geographic_clones.geographic_clone_count` takes the calling stage and refuses a malformed clone index in fixed sentences naming it, with no count. The six support-clip stages, property components, the CGT support split and the fold receipts read the count through it, and the WAS wealth and Lifetime ISA stages bind the leaf for it. The copy-id field the clones' ids are minted in, `GEOGRAPHIC_COPY_ID_FIELD`, is named in the leaf, and `geographic_expand` re-exports it. +- **Clone-aware thresholds.** + - The six support-clip stages (WAS wealth, WAS Lifetime ISA, NTS bus travel, LCFS consumption, ETB VAT and ETB services) and property components give `clone_count` from two clones up. The support-clip check multiplies each declared row allowance by it, and the property components check its two row maxima. + - `regional_home_values` counts the source households at the value cap in clone 0's rows, reading each row's clone from its id through the copy-id table, so its check's one maximum holds at any clone count. (Later in #931 the stage retires, and the WAS chain's area home values count their sources at the knots' cap in clone 0's rows: `931-spine-localises-home-values`.) It refuses a frame whose clone index disagrees with its ids. + - The take-up signal receipt counts each flag's population support and distinct values in clone 0's rows, and the apprentice draw its supports. A figure measured over every clone is withheld where clone 0's count or the count over every clone is one or two. +- **Constants table.** `test_uk_k_sensitive_constants.py` classifies each count-like constant of the UK spine, and each count-like maximum in the packaged gates, by what it counts and how it meets the clone count, and pins it to the code. +- **What moves.** Node keys only. Every UK spine node re-keys. On a bound spine, so do the full build's identity, property value and private rent kernels, the dense population kernels, the export preparation kernels, the national problem, measures and gates, and the full gates with their terminal phase code. No generated file, declaration or `gates.json` changes. No transport kernel and no US, NZ or BE node hashes an edited module; only the US PUF-support builder's whole-tree resume fingerprint moves, as on any edit to packaged source. diff --git a/changelog.d/931-uk-copy-id-table.changed.md b/changelog.d/931-uk-copy-id-table.changed.md new file mode 100644 index 0000000000..5e09131ed5 --- /dev/null +++ b/changelog.d/931-uk-copy-id-table.changed.md @@ -0,0 +1,6 @@ +The UK spine mints every copy row's ids from fixed decimal fields declared in `microcosm.build.uk_runtime.copy_id_table`, not from a power of ten above the largest id each copy layer sees (#931). Once the spine clones households at its start, that largest id would grow with the clone count K, so every layer's offset would move with K and the K=1 spine would stop being the clone-0 slice of the K=15 spine. Copy `k` in a field takes `id + k × radix` on all five id columns, so every copy id is a function of its source id and its copy path alone. The fields, least significant first: `vintage` (10 ordinals at 10^8, reserved for pooled FRS vintages, minted by nothing yet), `geographic_support` (100 at 10^9, for the clone-first spine), `spi_support_channel` (3 at 10^11: the SPI copy at 1, the income band donor at 2), `high_value_support` (6 at 10^12), `cgt_support_split` (10,000 at 10^13), `cgt_incidence_clone` (2 at 10^17) and `cgt_residential_split` (8 at 10^18, the top field). The largest mintable id is about 7.2e18, below int64's limit, which the module checks when it loads. + +- **Where.** `frs_spine` refuses raw ids at or above 10^8. The SPI support channel, the income band donors (whose sources are now read from their `{entity}_source_id` columns), the high-value split, the CGT support split, the incidence twin and the residential arms mint through the table, which refuses an ordinal outside its field, a row that already carries one and an int64 overflow. The CGT split refuses a household that would need more than 10,000 copies with a fixed message. The incidence anchor pairs each twin with the id less the twin field's radix, whatever the frame's largest id. The executor recovers each id-offset stage's parents at the stage's declared radix, refuses an incumbent id at or above it, and reads ids as exact int64 on any frame; the row-by-row walk it replaces read a row holding only integer and float columns as float64, inexact above 2^53. The UK modules' refusals on the copy path print counts, never ids: the new ones, and the older checks that listed up to five ids or printed the largest (uniqueness, links, sources, carriers and weights in the clone helpers, the SPI support and spine stages, the row-wise dataset and its tool's dry-run plans, the CGT stages and the spine sampler); the shared graph executor's own EXPAND checks, which every copy stage also passes through, are unchanged, and some of them still name ids. `create_uk_spi_support_tables` no longer takes an `id_multiplier`. The identity tool (`tools/verify_uk_identity_stability.py`) decodes the CGT support copies and the residential arms at their fields' declared radices and records the declared radix as each receipt's `id_multiplier`; it refuses, by count, a spine whose copy ids do not follow the table, as every pre-table spine with copy rows does, and such a spine is receipted with the tool at the commit that built it. +- **What moves.** Base FRS rows keep their ids. Every copy row's five id columns now sit at its parent row's ids plus its layer's offset: SPI copies 10^11, band donors 2×10^11, high-value copy k k×10^12, CGT copy k k×10^13, twins 10^17 and arm j j×10^18. Each used to be a power of ten above the largest id its layer saw. Relative id order is unchanged at K=1, so sorts, ties, ranks and folds are unchanged. Values move on copy rows through every draw keyed on the copy's own id: the SPI income stage's second stage; `company_cars`, `spi_employment_shell`, `aps_occupation`, `spi_housing_shell`, `was_wealth` and `was_lisa`; `regional_home_values` (retired later in #931), `property_components`, `property_purchases`, `nts_bus_travel`, `lcfs_consumption`, `etb_vat`, `etb_services`, `uc_reporter_redraw`, `spi_benefit_coherence`, `uc_capital_coherence`, `uc_take_up`, `uc_legacy_closure_take_up`, `pension_credit_take_up`, `child_benefit_take_up` and `uc_deduction_attributes`; every twin's Advani-Summers prior (so the CGT gains layer is re-realised); `salary_sacrifice`, `carers_allowance_take_up`, `student_loans`, `childcare_copy_take_up`, `private_school_attendance`, `isa_subscriptions`, `pip_points` and `trading_allowance_receipts`; and policyengine-uk's Warm Home Discount draw on copy households in spine engine calls. Base rows move second-order through pooled steps: the high-value selection, the regional value ranks, the landlord walk, the residential solve, the anchor, the CGT walks and calibration. Draws keyed on `person_source_id` do not move. National ids pass 2^53 from the incidence twin on, and at the CGT support split for any copy at ordinal 901 or more. The released file's identifiers, ranks of the build ids, do not move at K=1, while its `*_build_id` columns carry the new copy ids, so joining copy rows across versions goes through lineage (source id and copy path), not build ids. +- **Dense line.** The dense expand keeps its multiplier above the spine's largest id. A spine carrying residential arms (multiples of 10^18), as a production national spine does, leaves no int64 room for a second dense clone, so every dense entry point (the graph's `uk.full.expand`, the ladder and crosswalk clone routes and the row-wise tool's plans) refuses wherever the dense offset would overflow int64, in one message naming #931 and the clone-first spine. Dense builds with K > 1 of such a spine wait for #931's clone-first spine; K = 1, and a spine whose ids leave room (one without copy rows, say), expand as before. The dataset-size evaluation decodes dense ids back to spine ids on exact integers, 10^19 included. A caller can pass the multiplier the expansion recorded (`weight_tables(id_multiplier=)`); `tools/evaluate_uk_dataset_size.py` infers it from the spine's household ids or the clone-0 household ids, and a dataset the inferred multiplier does not fit is refused by count. A dense file that keeps its true sources decodes its spine stretch again instead of failing. Later in #931 the graph's `uk.full.expand` retires, as the dense line builds on the clone-first spine's own clones (`931-dense-on-the-clone-first-spine`), and the dense K pin (`931-dense-k-pin`) retires the size evaluation's decode: `weight_tables` loses its `id_multiplier` and `n_clones` arguments and reads a dense dataset's ids as its clone-first spine's, through the copy-id table's `geographic_support` field, refusing any other layout. +- **Declarations.** The `id_remapping` texts of the copy stages in `sources.yaml`, `source_stages.json` and the code dictionaries name the table field; the SPI support and band-donor operations gain the key, which the source schema now requires. The stages that read the table bind it into their hashes. The SPI support and band-donor stages also bind `spi_support`, whose clone helper mints their copies; the high-value split binds `cgt_support`, whose exact-total correction weighs its copies; and the CGT clone and anchor stages, which share `cgt_structure`, bind `rowwise_geography`, whose clone helper mints the twins. Every stage whose module or bound helpers import `microcosm.build.stochastic_assignment`, or import another module's function that draws through it, now binds it, so an edit to the keyed draws re-keys each stage they move. Every spine node re-keys; the coverage manifest's source digests and the H2 fixture are regenerated. diff --git a/changelog.d/931-uk-council-tax-check-copies-read-columns.changed.md b/changelog.d/931-uk-council-tax-check-copies-read-columns.changed.md new file mode 100644 index 0000000000..dd0d9f0ef8 --- /dev/null +++ b/changelog.d/931-uk-council-tax-check-copies-read-columns.changed.md @@ -0,0 +1 @@ +The UK council-tax reduction check (`council_tax_reduction_within_bill`, which `uk_council_tax_reduction_within_bill` declares at the spine's transferred boundary) now copies only the columns it reads when it leaves out the excluded regions' households and their persons (#931): each household's id, bill and reduction columns, and each person's household and reduction columns. It copied every column of the household and person tables before, a whole copy of the final frame at the boundary. `_without_excluded_regions` takes the columns its caller reads; a column named there that a table lacks is left out, and a repeated one keeps every column of its name, so the shared bounded-amounts check refuses either as before. Its verdicts, failures and details do not change. Keys: the gate phases and kernels that hash `stage_health` re-key; no declaration, generated file or `gates.json` changes. Tests (invented tables with columns the check does not read): the check against a copy of every column on frames it passes, fails and refuses, and the step's rows and columns against that copy. diff --git a/changelog.d/931-uk-cut-dense-spine.added.md b/changelog.d/931-uk-cut-dense-spine.added.md new file mode 100644 index 0000000000..0db722b3d5 --- /dev/null +++ b/changelog.d/931-uk-cut-dense-spine.added.md @@ -0,0 +1,6 @@ +`tools/run_uk_cut.py dense-spine` builds only the dense line's spine, so a machine larger than the dense calibration's can build it (#931). It fetches every input but the Chronicle artifact. Its preflight checks the checkout, the environment, a signing key registered to sign (a release-candidate spine is shippable only once signed), the registers' expiries and the host, with a 400 GB free-disk floor by default; it reads no reference and starts no emitter. It builds the spine as a release candidate at the local doctrine's 15 geographic clones, with `--stage-profile-dir`, into `/dense-spine/`, apart from the national cut's spine, and keeps the per-node memory profile in `/dense-spine-profile/`. Like every step it is resumable, and `--retry-spine` moves an unfinished attempt and its profile aside. Once the spine is done it hard-links the H5, its `.sha256`, `.build.json`, `.spine_gates.json` and `.hmrc_replay.json` and the profile into `/dense-spine-handoff/`, and prints their upload to `policyengine/microcosm-uk-build-inputs` under `spines/