Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
a403050
Count every UK floor in true source households (#931)
juaristi22 Nov 5, 2026
78e7f24
Fold geographic clones into each survey record in the FRS-trained fit…
juaristi22 Nov 5, 2026
972f824
Let a shared area draw choose each household's weight column (#931)
juaristi22 Nov 5, 2026
945110f
Add conditioned UK area supports for the geography-first draw (#931)
juaristi22 Nov 5, 2026
d495d20
Re-pin the conditioned supports to chronicle#413's merge (#931)
juaristi22 Nov 5, 2026
8fe2d00
Fold geographic clones in the SPI employment fit (#931)
juaristi22 Nov 5, 2026
449ebb5
Catch every form of a household-row count in the static floor scan (#…
juaristi22 Nov 6, 2026
fc66d2c
Require the sources the person draws and annual income count by (#931)
juaristi22 Nov 6, 2026
233f7b9
Refuse the artifact's bare clone_index in the SPI income stage (#931)
juaristi22 Nov 6, 2026
a7c18ec
Note the UC capital donor floor, Scotland's band mix and #893's doc t…
juaristi22 Nov 6, 2026
94befd1
Fold only clones that agree on what each fit reads (#931)
juaristi22 Nov 6, 2026
5e1d2c7
Draw Scotland's band weights from each data zone's NRS mix
juaristi22 Nov 6, 2026
b19a6d3
Keep only the graph versions the caller reads (#931)
juaristi22 Nov 6, 2026
6745bed
Release each stage's result once its evidence is captured (#931)
juaristi22 Nov 6, 2026
2d67333
Write and reuse structural graph versions one column at a time (#931)
juaristi22 Nov 7, 2026
55ef324
Free what each graph node no longer needs, and record amendment 30 (#…
juaristi22 Nov 7, 2026
e2e5afd
Read Scotland's band weights from Chronicle's NRS facts
juaristi22 Nov 7, 2026
fe823f2
Count the floors of the stages main added since 6 Nov in true source …
juaristi22 Nov 15, 2026
690f0a2
Regenerate the supports' provenance, the coverage manifest and the H2…
juaristi22 Nov 15, 2026
70e5ac1
Give main's newer tests the true source this branch's floors count by…
juaristi22 Nov 15, 2026
bb0ccf3
Merge main (3b75cf151) into uk-931-geography-first-prep
juaristi22 Nov 17, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions changelog.d/931-atomic-geography-weight-by.added.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
A sampling stage of the shared atomic-geography declaration can declare `weight_by` (`input`, `map`, `default`) in place of its one `weight` column: each household then samples by the weight column `map` names for its `input` code, or by `default` where the code is missing, and a code the map does not name is refused (#931). The UK geography-first draw needs it to weight a household's output area by the dwellings in its own council-tax band. Declarations without `weight_by`, New Zealand's and today's UK one among them, keep their canonical bytes, definition digest and draws; only the geography kernels' implementation hashes, and with them their cache keys, move. The graph builder adds the `weight_by` input to the assignment's household slice.
20 changes: 20 additions & 0 deletions changelog.d/931-uk-conditioned-area-supports.added.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
The UK atomic-area supports gain conditioned forms for the geography-first draw (#931), which only that move binds; today's build binds the registered supports, so no output moves.

Each conditioned support extends its system's registered support byte for byte, and adds:

- **`imd_decile`:** the area's deprivation decile within its nation, at the 2019 vintage the FRS 2024-25 deciles follow (IoD 2019, WIMD 2019, SIMD 2020v2, NIMDM 2017). Each area takes the plurality of its live residential postcodes in the May 2026 NSPL; a tie goes to the parent area's plurality, and an area without such a postcode takes its parent's decile.
- **Households by council-tax band, times 10^6, as exact integers:**
- England and Wales take bands A to I from the area's LSOA mix in VOA CTSOP1.1; only Wales has band I.
- Scotland takes bands A to H from its 2022 data zone's dwellings by band in NRS's December 2024 estimates, rounded half to even; its output areas nest in those zones.
- Northern Ireland is unbanded.

`tools/build_uk_conditioned_area_supports.py` builds them from chronicle#412's raw-only registrations (PR chronicle#413), pinned by sha256, and from NRS's dwellings by band and 2022 data zone, which it reads from the pinned UK Chronicle feed (chronicle#421). `uk/uk_atomic_area_conditioned_supports.provenance.json` records every input, the fingerprint of the NRS facts, the decile rule counts, the rounding and a precomputed table of zero-mass draw cells. A feed-gated test checks that the pinned feed still carries the facts the supports were built from.

`sources.yaml` declares the supports under the new role `uk_atomic_area_conditioned_support`, with five new geography vintages. `spine.yaml` declares the FRS channel's `observed_constraints: [imd_decile]`, an optional field the shared spine schema now admits. `validate_uk_country_source_projection` refuses a spec in which the supports, their conditioned forms and that declaration disagree.

The country-neutral `microcosm.build.atomic_support_conditioning` provides the building blocks:

- `modal_area_codes`;
- `apportion_weights`;
- `extend_atomic_support`;
- `zero_mass_cells`.
18 changes: 18 additions & 0 deletions changelog.d/931-uk-fits-fold-geographic-clones.added.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
The UK fits trained on the frame's FRS rows now fold geographic clones into each survey record before they fit (#931). This covers the SPI stage-2 and reference forests, the housing shell, the UC reporter redraw, the UC capital donor cells, the salary-sacrifice forest and the SPI employment shell.

- **How the fold works.** Each fit passes what it reads: its predictors and targets, or the columns they derive from. A record's clones that agree on it keep the record's first training row, with the weight of those clones summed exactly. Clones that differ, through a draw keyed on their own ids or a stage run per area, stay rows of their own, each variant with its own clones' summed weight. SPI, high-value and CGT copies stay rows of their own, as now.
- **No change today.** Today's spine has no geographic clones, so every fit's rows and weights stay as they were, value for value.
- **What changes once the spine clones before enrichment:**
- the fits see each record once wherever its clones agree, and every clone's value at its share wherever they differ;
- the reference transport meets no duplicate twins from agreeing clones;
- the UC capital cells' donor minimum counts records, not identical clones.
- **The country-neutral pieces.** `microcosm.build.source_lineage` gains three functions:
- `copy_paths`: every household's ordered copy path from a declared lineage, never inferred from ids, weights or values;
- `replica_keys`: a key per record of any entity, shared only by its replicas in the named branches, with a member's rank in its household telling members apart;
- `collapse_replicas`: the fold itself, which takes the fit's `inputs` and folds only replicas that agree on them.
- **The UK entry.** `household_lineage.collapse_geographic_clones` is the UK's entry and requires those inputs. `uk_household_clone_paths` now reads the clone path through `copy_paths` on `UK_COPY_LINEAGE`, with identical paths and draw keys; three identity-test messages name the shared reader's branches.
- **Declarations and tests.**
- The collapsing stages declare the lineage live where they run, and a test refuses one whose surface would hide it.
- Replicated-fixture tests hold each fit to the rows and weights it fits without clones.
- A fixture with differing clones (a landlord's property income drawn apart) holds the UC reporter redraw to training on both variants at half the unit's weight each.
- **Hashing.** The SPI income stage also binds `spi_rank_transport` into its hash.
1 change: 1 addition & 0 deletions changelog.d/931-uk-floors-count-true-sources.changed.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Every UK floor now counts true source households, the survey household each copy and clone keeps in `source_household_id`, through one reader (#931). The reader is the new country-neutral `microcosm.build.source_lineage.record_sources`: a country declares its copy lineage once (the entity copies are made of, its source column and each copying step's marker and ordinal columns), and every record of any entity reads its source through household membership. `receipt_counts.record_source_households` is the UK's entry on `household_lineage.UK_COPY_LINEAGE`, and `receipt_counts.SOURCE_HOUSEHOLD_COLUMN` is the shared `source_household_id`, no longer `household_source_id`, the support channel's immediate parent. The reader refuses a frame without the source column, and a null source; a stage that runs before the SPI support channel says so (`before_copies`), and its households are then their own sources unless the frame already carries copy lineage. The take-up signal receipts, the apprentice receipt and the annual income receipts (stages 10 to 12 and 15), the SPI pay floor and pension coherence (which read `household_source_id` without the null refusal), company cars, the SPI benefit coherence, UC take-up's pools, the legacy closure, salary sacrifice's receipt and bonus donor floor, Carer's Allowance, the trading allowance, the support floor, the single-year age report, the dataset-size evaluation, the sampled-rung private-rent region floor, and the council-tax, BRMA-distribution, weighted-integrity, benefit-cap and UC-relationship tools count through it. The two columns agree on every household row of today's spine and pool, so no spine output moves. The single-year age report and the dataset-size evaluation now count a zero-weight row as carrying nothing and a household's copies once, so their support counts can fall; the weighted-integrity tool's carriers are now distinct sources, not rows. The five finite stages that declared `household_source_id` declare `source_household_id`, UC take-up's pooling text and the Carer's Allowance and support-floor notes name it, and a static test refuses any distinct count of `household_id`, `person_household_id` or `household_source_id` in the UK runtime and tools outside two named structural checks. The receipts' counting modules (`receipt_counts`, `household_lineage`, `source_lineage`) are bound into the implementation hash of every stage whose module or helpers import one of them; eight stages that counted through `receipt_counts` did not bind it, so an edit to it alone left their cache keys in place.
54 changes: 53 additions & 1 deletion docs/geography-assignment.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ area using identified, versioned mappings. Distinct clones may receive different
areas subject to their observed source constraints. The assigned location then
remains fixed through subsequent enrichment, calibration and analysis views.

> These US passages describe the work of PolicyEngine/microcosm#893, which
> closed unmerged on 9 October 2026. Its modules, graphs and receipts never
> reached main.

The earlier block-before-clone implementation and its passing controls remain
historical evidence. They do not demonstrate this corrected ordering. Geographic
assignment must use a stable post-clone identity, including a clone discriminator
Expand Down Expand Up @@ -142,7 +146,12 @@ cross-platform equivalence has not been established.
The version-1 declaration lists `identity`, `stream`, three assignment `outputs`
(`area`, `system`, `basis`), and `systems`. Each system supplies its atomic
identity and source, a selector, observed constraints, an optional observed-area
column, sampling stages and derived layers. Geographic codes use nullable
column, sampling stages and derived layers. A stage samples by one `weight`
column, or declares `weight_by` (`input`, `map`, `default`) instead: each
household samples by the weight column `map` names for its `input` code, or by
`default` where the code is missing, and a code `map` does not name is refused
(microcosm#931). A declaration without `weight_by` keeps its canonical bytes,
so its definition digest and draws are unchanged. Geographic codes use nullable
strings throughout, retaining leading zeroes. An engine that needs integer
storage must declare that conversion separately. A system without a particular
layer produces missing values for that layer, which the integrity gate checks.
Expand All @@ -159,6 +168,10 @@ checks mapping integrity, while the executor and build own structural lineage
and population-quality acceptance. The country's chosen identity still needs
verification across actual sampling rungs.

> These US passages describe the work of PolicyEngine/microcosm#893, which
> closed unmerged on 9 October 2026. Its modules, graphs and receipts never
> reached main.

The US development composed graph attaches geography after harmonization, but
`us_runtime/graph_geography.py` selects a joint tract/congressional-district cell
and emits PUMA, county and district. It does not assign a Census block. Its prior
Expand All @@ -182,12 +195,51 @@ on a shared seeded stream) remains available as `--geography-assignment
legacy` for measurement builds only, and still supplies the rosters and
dispersion checks used by target compilation.

Each support also has a conditioned form for the geography-first draw
(microcosm#931), which only that move binds. It is declared in
`uk/spec/sources.yaml` with role `uk_atomic_area_conditioned_support`, beside
the support it extends, and recorded in
`uk/uk_atomic_area_conditioned_supports.provenance.json`;
`tools/build_uk_conditioned_area_supports.py` builds it from the registered
support's bytes, chronicle#412's raw-only registrations and, from the pinned UK
Chronicle feed, NRS's dwellings by band and 2022 data zone (chronicle#421). It
adds two kinds of column:

- **`imd_decile`**, an exact-match constraint code. It is the area's
deprivation decile within its own nation, at the 2019 vintage the FRS
2024-25 deciles follow (IoD 2019, WIMD 2019, SIMD 2020v2 and NIMDM 2017). An
area takes the decile that most of its live residential postcodes carry in
the May 2026 NSPL. A tie goes to its parent area's plurality, and an area
without such a postcode takes its parent's decile. The relation is
`inferred_modal`.
- **`households_band_a`, `households_band_b` and so on**, weight columns. Each is
the area's households in that council-tax band times 10^6, which a `weight_by`
stage chooses per household:
- England and Wales take bands A to I from the area's LSOA mix in VOA
CTSOP1.1. Only Wales has band I.
- Scotland takes bands A to H from its 2022 data zone's dwellings by band in
NRS's December 2024 estimates, as Chronicle emits them; its output areas
nest in those zones.
- Northern Ireland has domestic rates, so its support carries no bands.

The provenance lists every zero-mass draw cell (FRS region by decile, and
region alone, for each weight column), so the move can choose a draw's fallback
ahead of time instead of meeting an empty cell. `spine.yaml` declares the FRS
channel's `observed_constraints: [imd_decile]`, and the UK country adapter
refuses a spec in which the supports, their conditioned forms and that
declaration disagree. The shared pieces (`atomic_support_conditioning`: modal
codes, exact apportionment and zero-mass cells) name no country's columns.

The Northern Ireland source builder currently infers Data Zone constituencies
using the modal active-postcode constituency. Review the official
[NISRA constituency aggregation and lookup resources](https://www.nisra.gov.uk/publications/census-2021-output-geography-information-papers)
before choosing or replacing that approximation. Source existence is not
acceptance of a particular lookup or its application to the population.

> These US passages describe the work of PolicyEngine/microcosm#893, which
> closed unmerged on 9 October 2026. Its modules, graphs and receipts never
> reached main.

The US block adapter in `us_runtime/atomic_block_support.py` now preserves each
supplied block, leading zeroes, population weight and the source-labeled
tract-to-PUMA and block-to-district mappings. Its declaration uses the shared
Expand Down
20 changes: 20 additions & 0 deletions docs/graph-acceptance.md
Original file line number Diff line number Diff line change
Expand Up @@ -748,6 +748,26 @@ lock unchanged:
independent review of #1125 (finding 1, Subfleet job 20261007-081708);
adopted with the fix in #1140.

30. **A caller may name the versions it retains.** `run_graph(...,
retain_populations=...)` names the population versions the caller will
read from the manifest. `None`, the default, keeps every version to the
end of the run and attaches all of them, as before. Given a collection,
the executor drops each version it does not name once its last reader
has applied its result, before that reader is observed or written. A
last reader that is not reached drops it at its turn in the run order.
Ordinary members read a version as their incumbent and structural nodes
as their base; nothing else does, so a version nothing reads goes with
the node that made it. Only the named versions and their mass ledgers
are attached, and `RunManifest.population` refuses any other with the
error it gives a manifest restored from JSON. An unknown name, an
ordinary member's id, a name that is not a string, a bare `str` or
`bytes`, and anything that is not a collection are refused before any
source is read. Each node reads the same population with or without the
keyword, and it enters no node key, receipt, cache record or portable
manifest field. Runtime-only, the interface lock is unchanged. Adopted
2026-11-06 for the 15-clone UK spine (#931), which cannot hold every
version it builds in 32 GiB.

Adding a normative field with a default changes the canonical projection
of every node that carries it, so node keys moved with amendments 11 and
13's sibling field `entrants`; no released artifact pins a graph key yet.
Expand Down
9 changes: 6 additions & 3 deletions docs/graph-explorer.md
Original file line number Diff line number Diff line change
Expand Up @@ -144,9 +144,12 @@ achieved value, residual, standard error, filter, or other field, the table says

The shared-bin histogram compares both incoming and outgoing weights divided by
the original design-weight anchor, aligned by entity id. For a just-executed run,
those arrays come from `manifest.populations`. For a saved run, the CLI reloads
the structural frames identified by `NodeReceipt.frame_key`. A receipt-provided
before/after ratio sample would take precedence if the runtime adds one later.
those arrays come from `manifest.populations`. A run that names the versions it
retains (`retain_populations`, charter amendment 30) attaches only those, so its
histogram for any other version says the samples are not recorded. For a saved
run, the CLI reloads the structural frames identified by `NodeReceipt.frame_key`.
A receipt-provided before/after ratio sample would take precedence if the
runtime adds one later.

Mass totals and strata come first from `receipt.mass`, then from the attached
executor `MassRecord`, and finally from the validated before/after structural
Expand Down
9 changes: 9 additions & 0 deletions docs/uk-atomic-household-lineage.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,15 @@ The host can extract the household pairs from its verified shared EXPAND receipt

The full-build graph now adopts this key: `uk.full.identity` (`UKGeographyIdentityKernel`) reads the spine's explicit lineage columns and the pool clone index and writes `geography_household_key` with exactly this encoding, and `test_uk_atomic_identity_graph.py` holds the kernel to this projector on the executor's actual EXPAND receipt. The existing source stage order still interleaves enrichment before later SPI/CGT cloning; moving atomic assignment before every enrichment stage remains a separate staged migration under the geography-first umbrella issue (PolicyEngine/microcosm#931). This helper does not claim that migration, native FRS qualification or a new UK release.

## Shared lineage readers

The UK's copy lineage is declared once, as data, in `uk_runtime.household_lineage.UK_COPY_LINEAGE`: every copy's true source is `source_household_id`, and each copying step (the SPI support channel, the CGT support split, high-value support, the CGT incidence clone, the CGT residential split and the geographic clone) names its marker and ordinal columns in path order. The country-neutral readers in `microcosm.build.source_lineage` take that declaration as a parameter, so another country can declare its own lineage and reuse them (microcosm#931):

- `record_sources` gives every record of any entity its true source through household membership. Every UK floor counts distinct sources through it (`receipt_counts.record_source_households`), so a household's copies and clones count once.
- `copy_paths` reads every household's ordered clone path; `uk_household_clone_paths` is the UK's strict entry for the identity kernel.
- `replica_keys` and `collapse_replicas` keep one training row per true source and path without the geographic branch, with the clones' weights summed. The FRS-trained fits fold their training rows through `household_lineage.collapse_geographic_clones`: the SPI stage-2 and reference forests, the housing shell, the UC reporter redraw, the UC capital donor cells, the salary-sacrifice forest and the SPI employment shell. Once geographic clones precede enrichment, each fit still sees each survey record once. A frame without geographic clones keeps its rows and weights value for value.
- Each fit passes what it reads (its predictors and targets, or the columns they derive from), and clones fold only where they agree on it. Clones that differ, through a draw keyed on their own ids or a stage run per area, stay rows of their own. Each variant carries the summed weight of the clones that share it, so the fit sees every clone's value at its share and nothing is dropped.

## Verification scope

Invented tests cover the full four-branch path, explicit selection, exact large IDs, source and ordinal changes, stable keys under row reordering and pool growth, unknown/colliding ancestry refusal and detached output. A real shared CREATE/EXPAND/FILTER graph supplies the household lineage receipt and replays from cache. Its projected keys then feed the existing seven-node atomic graph, including three system imports, assignment, derivation and its gate. That graph also completes required replay and preserves the supplied entity tables, weights, strata and metadata. No native source, private archive, country engine or external resource is used.
Loading
Loading