Repository navigation
Add the US block -> congressional-district plan registry (117th-120th) - #1041
Merged
Merged
Conversation
Record, for every populated 2020 census block, its district under each registered plan, so a block draw can derive every plan's district from the chosen block and SOI's 117th-plan district tables become exact block sums. - 117th_congress: 2020 BAF CD layer; North Carolina carried from its 2019 plan onto 2020 blocks through the Census 2010-2020 block relationship file (method reproduces Census's 2016 plan for 99.992% of NC population; districts within 0.09% of NCGA's official 2020 figures). - 118th/119th_congress: Census block equivalency files. - 120th_congress: Census's 120th file (2026-08-31), with Missouri on its 2022 map per the 2026-09-25 Supreme Court order in 26A388. The builder cross-checks apportionment, Census state vs national files, Census's redrawn-state lists and split blocks, and agrees exactly with the block ladder; the loader re-checks every invariant; the artifact is byte-reproducible and pinned in us_cd_plan_registry.provenance.json. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- Loader and ladder differential refuse arrays that are not 1-D and aligned (a (n, 1) population or trailing ladder values used to pass). - The builder pins the reviewed Census block-split notes by SHA-256 and refuses a changed note, since CENSUS_BLOCK_SPLITS transcribes them. - Docs and docstrings: the loader's checks are structural; national completeness comes from the build, the ladder agreement and the pin. "Exact block sums" is qualified for North Carolina's carried plan. - The 120th note says "the 2026 elections" (Louisiana's Nov 3 is a primary). District data unchanged; artifact sha256 6b16fc21... - Tests: tamper cases for shapes, misaligned ladder arrays, a lazy-parse test that fails if the stream is materialized, split-note pin tests, and a fill property over several counties, tracts and block groups checked against a reference implementation. - Classify cd_plan_registry.py as a reviewed non-registry runtime module. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Contributor
Author
|
Merging on behalf of the Route A session that spawned this work (the authoring session is gone). Gates: 🤖 Generated with Claude Code |
juaristi22
added a commit
that referenced
this pull request
Sep 28, 2026
…rminal tests Rebase onto main 4b57d15 (#1007 unified calibration diagnostics, #1041, #1046). The calibrated gate battery now hands a typed rotated-holdout report to the diagnostics, so the kernel test's holdout fixture is a complete UKMeasuredRotatedHoldout; the synthetic graph driver's fake diagnostics declare the legacy schema, like the rowwise-tool candidate fixture in the assembler tests, because the assembler validates only the current schema, which the real gate kernel emits. The lock pin is re-recorded on the merged lock (696ea49c...), inside the graph-registration commit. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What this adds
A versioned, SHA-pinned registry of every populated 2020 census block's congressional district under each registered plan. A household's location is one block and every other geography is a lookup from it. This file supplies the district lookup for every map, so the block draw (the separate location v1 PR, owned by another session) can derive each plan's district from the chosen block. It also makes SOI's 117th-plan district tables exact sums of blocks under the registry's assignments, so consumers need no crosswalk. The assignments follow Census's whole-block tabulation, and North Carolina's 117th rows are carried from 2010 blocks, so they approximate the official boundaries.
No household assignment code is touched.
congressional_district_geography.py,geography_ladder.pyandpuma_ladder.pyare unchanged, and the new module is outside the spec engine's hashed kernel list. The PUMA × county × district atom table is deliberately out of scope (it is a later optimization under the version 1 location design).117th_congress(SOI CD tables, TY2020–2022)CDlayer; North Carolina carried from its 2019 plan (below)118th_congress119th_congress(primary; the block ladder's plan)120th_congress(the 2026 elections)Files:
us_runtime/cd_plan_registry.py: parsers, assembly, the validating loaderload_us_cd_plan_registryand the pinned loaderload_pinned_us_cd_plan_registry, the ladder differential, and the 2010→2020 crosswalk.tools/build_us_cd_plan_registry_artifact.py: the builder.us_cd_plan_registry.provenance.json: the receipt, holding the artifact SHA-2566b16fc21…, every source's URL and SHA-256, per-plan totals and every check's result.US_CD_PLAN_REGISTRY.md: the documentation.The built artifact (17.8 MB) is at
_buildf-runtime/inputs/us_cd_plan_registry_2020.npz, next to the Route A block ladder.Two places the registry departs from a single Census file
CDlayer is NC's 2016 plan, which puts only 55% of NC's population in the same district as the 2019 plan the 117th used. So NC's rows carry the General Assembly's 2019 block file (HB 1029, S.L. 2019-249; 2010 blocks) onto 2020 blocks through the Census 2010→2020 relationship file, by largest intersecting land area.Both are recorded in
plan_sources[plan]["known_deviations"].Invariants
Structural invariants hold for every registry the loader accepts. They are checked at build time and again on every load:
00(at-large or DC) or01..n, where n is its House seats for that plan's census. So every district holds a populated block.These checks are structural, so a
--statessubset also passes them. National completeness comes from three things: the build covers every 2020 P.L. 94-171 block with positive population in the 50 states and DC (5,769,942 blocks, 331,449,281 people); the registry agrees exactly with the block ladder; andload_pinned_us_cd_plan_registryenforces the SHA-256 pin.Differential checks (run by the builder, fail closed)
7ba39b95…): exact agreement on all 5,769,942 blocks, their populations and their 119th districts.Tests
test_us_cd_plan_registry_properties.py: Hypothesis properties on random multi-state geographies.test_us_cd_plan_registry.py: parser formats (BAF, all three BEF layouts, legislature CSV) and refusals, round-trip and tamper tests, the pinned SHA, the ladder differential, and the packaged receipt's contents. An opt-in test (MICROCOSM_US_CD_PLAN_REGISTRY/MICROCOSM_US_BLOCK_LADDER) re-checks a real artifact; it passed locally against the built file.test_us_cd_plan_registry_crosswalk.py: crosswalk examples, including a minimized counterexample the property tests missed and the fix now covers (a state whose 2010 counterparts are all outside the plan).Review
Astra (GPT-6, hard tier) reviewed the first head and requested changes. All eight findings are addressed in fd9a022:
The CI classification failure is fixed:
cd_plan_registry.pyis registered as a reviewed non-registry runtime module.Local results on fd9a022:
test_us_spine_blindness.pypasses (498 tests).ruff check .,tools/ci_test_groups.py --verifyandtools/build_and_inspect_wheels.shpass.axiom: n/a: geography data infrastructure, no policy rules
🤖 Generated with Claude Code