Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
8047380
Add a SHA-pinned registry for US local-jurisdiction flags
MaxGhenis Nov 2, 2026
dd68d86
Derive local-jurisdiction flags in the block, PUMA and pooled lines
MaxGhenis Nov 2, 2026
b7b3e21
Repin US spec contracts and test the local-jurisdiction flags
MaxGhenis Nov 2, 2026
84ab874
Re-derive flags for existing artifacts, require flags in ladder gates…
MaxGhenis Nov 2, 2026
51022c0
Regenerate the H3 US post-transfer parity fixture for the new pool ma…
MaxGhenis Nov 2, 2026
792f3a7
Derive local-jurisdiction flags again after every support reduction
MaxGhenis Nov 3, 2026
4a57518
Require a flag-complete parent in the annual static-aging lane
MaxGhenis Nov 3, 2026
22cf88f
Name the live PUMA-ladder gate failures when a stored receipt drifts
MaxGhenis Nov 3, 2026
1da07e2
Merge origin/main into us-local-jurisdiction-flags
MaxGhenis Nov 3, 2026
1818486
Name who acts in the builder's local-jurisdiction comments
MaxGhenis Nov 3, 2026
1c65d4d
Merge main (1e8831901) into us-local-jurisdiction-flags
MaxGhenis Nov 13, 2026
3a6d247
Move the local-jurisdiction flags out of us_runtime (lead's condition 1)
MaxGhenis Nov 13, 2026
96a3c92
List the flags modules in the binding identity and recount (B1)
MaxGhenis Nov 13, 2026
234a302
Recompute the US spec-engine pins on the merged tree
MaxGhenis Nov 13, 2026
cda6f08
Give main's receipt-anchor pool test a frame-shaped pool fake
MaxGhenis Nov 13, 2026
bcb0194
Read the registry at its new path in the engine contract test
MaxGhenis Nov 13, 2026
8a5b3ae
Merge main (68bbff774) into us-local-jurisdiction-flags
MaxGhenis Nov 13, 2026
56b63eb
Derive the local-jurisdiction flags after the block_v1 draw
MaxGhenis Nov 13, 2026
e504a6d
Scan the moved flags implementation with the runtime it serves (revie…
MaxGhenis Nov 13, 2026
fb7f9ef
Pin what the gate-import test is cited for (review G-B1)
MaxGhenis Nov 14, 2026
3774d64
Pin the base and frozen flag assignments; say the third refusal (D2, …
MaxGhenis Nov 14, 2026
724b6eb
Give the export-statement test the names the export derivation reads
MaxGhenis Nov 14, 2026
d8e1490
Recompute the spec-engine pins on main 68bbff774 with the block_v1 flags
MaxGhenis Nov 14, 2026
21ec4d9
Read no place rung beside a block outside its county (review round 1)
MaxGhenis Nov 14, 2026
6ed3ccd
Recompute the spec-engine pins after the round-1 fix
MaxGhenis Nov 14, 2026
4030c01
Pin the reviewer's redraw sequence as examples of the line property
MaxGhenis Nov 14, 2026
42c021b
Keep the ACS block-gate test on the tool's gate and test the pool ref…
MaxGhenis Nov 14, 2026
d7a90ec
Recompute the spec-engine pins after the round-1 repair
MaxGhenis Nov 14, 2026
59d539e
Merge main (085672fa9) into us-local-jurisdiction-flags
MaxGhenis Nov 14, 2026
77984c9
Keep the calibrated support's flags on the release export (review rou…
MaxGhenis Nov 15, 2026
db83dde
Test that a block-only L0 export keeps the income tax its weights wer…
MaxGhenis Nov 15, 2026
4a9859d
Keep the fitted base's flags on the L0/refit export (review round 3)
MaxGhenis Nov 15, 2026
46ea7d7
Draw supports with no rung in the held-selection property (review rou…
MaxGhenis Nov 15, 2026
68effae
Say what the release export does with the flags in its telemetry (rev…
MaxGhenis Nov 15, 2026
e4f52d9
Merge main (e555b4d8b) into us-local-jurisdiction-flags
MaxGhenis Nov 15, 2026
87a03db
Scope the exports' flag promise to the rows their weights keep (revie…
MaxGhenis Nov 15, 2026
59e1483
Say what the L0/refit export checks of its saved weights (review roun…
MaxGhenis Nov 15, 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/us-local-jurisdiction-flags.added.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Derive the policyengine-us input-only local flags `in_denver`, `in_yonkers`, `in_wilmington` and `pa_philadelphia_wage_tax_resident` from household geography through a SHA-pinned registry checked against the 2020 Gazetteer, P.L. 94-171 counts and the block ladder. The block-ladder line writes all four; the PUMA line, and the pooled ACS line with its PUMA ladder, write the county-rule flags and record the place-rule flags (Yonkers, Wilmington) as unavailable instead of writing `False`. Under the opt-in `--location-rule block_v1`, every line that draws a block derives all four from that block's county and place, after the draw. The L0/refit export and the fiscal refresh release builder re-derive the flags from an existing base's own geography, and the builder derives them again after frozen-support selection, before it computes its targets, so a base built before this change, or a frozen support that keeps only block-anchored rows, no longer exports without them. On export, the builder keeps the flags it computed its targets with, and the L0/refit export writes those its whole base's geography decides. Neither export writes a flag that only the rows its weights keep decide, and each records such a flag as unavailable. Both ladder gates now fail a table that lacks a flag its geography decides. The annual static-aging lane, which keeps its parent's columns and base-year bytes, now refuses a parent that lacks or contradicts a flag its geography decides, before any model work, and records the parent's flag receipt in the candidate manifest. The registry and its module live in `microcosm.build.us_local_jurisdictions`, outside `us_runtime` (which re-exports them), so that check never imports `us_runtime`, whose package import asserts the engine ABI lock wherever policyengine-us is installed.
22 changes: 11 additions & 11 deletions docs/evidence/spec-engine/us-f0-coverage.json
Original file line number Diff line number Diff line change
Expand Up @@ -1642,13 +1642,13 @@
"compiler_ir.node_slices"
],
"expected": {
"map_sha256": "8d0542f7b83f030772e6e53b5742d0f13bcad82325a4e9b66d5d999a3fbb5276",
"protocol_sha256": "3ab23e82779263dabe8da210de55ce7f12fdc0464e8145ca2c18649426b7f976"
"map_sha256": "5230ab2f01d1ffbc841eb58b5eb8e452e470bcc3c6ea077b9678f432fc4dd8e4",
"protocol_sha256": "4ac422f9c40e6bb61b27f31a22bdd31e001e0ce9062fcb62c5906b571ef9f19d"
},
"failures": [],
"observed": {
"map_sha256": "8d0542f7b83f030772e6e53b5742d0f13bcad82325a4e9b66d5d999a3fbb5276",
"protocol_sha256": "3ab23e82779263dabe8da210de55ce7f12fdc0464e8145ca2c18649426b7f976"
"map_sha256": "5230ab2f01d1ffbc841eb58b5eb8e452e470bcc3c6ea077b9678f432fc4dd8e4",
"protocol_sha256": "4ac422f9c40e6bb61b27f31a22bdd31e001e0ce9062fcb62c5906b571ef9f19d"
},
"status": "covered"
},
Expand All @@ -1663,7 +1663,7 @@
"compiler_ir.seed_stream_map"
],
"expected": {
"implementation_sha256": "3ab23e82779263dabe8da210de55ce7f12fdc0464e8145ca2c18649426b7f976",
"implementation_sha256": "4ac422f9c40e6bb61b27f31a22bdd31e001e0ce9062fcb62c5906b571ef9f19d",
"protocol": "legacy-v1",
"streams": [
"build_model",
Expand All @@ -1684,7 +1684,7 @@
},
"failures": [],
"observed": {
"implementation_sha256": "3ab23e82779263dabe8da210de55ce7f12fdc0464e8145ca2c18649426b7f976",
"implementation_sha256": "4ac422f9c40e6bb61b27f31a22bdd31e001e0ce9062fcb62c5906b571ef9f19d",
"protocol": "legacy-v1",
"streams": [
"build_model",
Expand Down Expand Up @@ -1873,7 +1873,7 @@
"alpha",
"zeta"
],
"sha256": "ecf64f2bfbb59ffaaa717d8a09d38e56a38d6d43c1aa0a209d57492b038fb19a"
"sha256": "47d4474df59d47ad5e2fd9a4663002c1c34761862c679e3059bbb83687f17fba"
},
"failures": [],
"observed": {
Expand All @@ -1897,7 +1897,7 @@
"alpha",
"zeta"
],
"sha256": "ecf64f2bfbb59ffaaa717d8a09d38e56a38d6d43c1aa0a209d57492b038fb19a"
"sha256": "47d4474df59d47ad5e2fd9a4663002c1c34761862c679e3059bbb83687f17fba"
},
"status": "covered"
},
Expand Down Expand Up @@ -1961,7 +1961,7 @@
"take_up_contract",
"us_qbi_reconciliation_contract"
],
"sha256": "731c8c33dc511dfc35bc4b37bed9864ee75446e45555b999a01ec9b6ad1289cf"
"sha256": "3c5e14bef2c3dfecee5c1dd8b7d9b28eb3b0ba9e72e0765b6c2576a48f3175d8"
},
"status": "covered"
},
Expand Down Expand Up @@ -2585,7 +2585,7 @@
"country": "us",
"schema_id": "country_spec",
"schema_version": 1,
"spec_sha256": "fa75bd68f579fd7fb0dd0eed955c867415c251f11fc34087bbc24ae3a77a2a49"
"spec_sha256": "97f2b9384e8190183829870da17e6160527d2964d980f0f6ea1d0d4495fa66d4"
}
},
"report_schema_version": 3,
Expand All @@ -2595,7 +2595,7 @@
"country": "us",
"schema_id": "country_spec",
"schema_version": 1,
"spec_sha256": "fa75bd68f579fd7fb0dd0eed955c867415c251f11fc34087bbc24ae3a77a2a49"
"spec_sha256": "97f2b9384e8190183829870da17e6160527d2964d980f0f6ea1d0d4495fa66d4"
},
"status": "pass"
}
21 changes: 19 additions & 2 deletions docs/us-annual-static-aging.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,13 +50,30 @@ fields. Fixed-format inputs, including missing nullable booleans that require
that storage format, are rejected before building and need a separate certified
layout contract.

Because the lane adds no column, the parent must already carry every
local-jurisdiction flag its own geography decides (see
`packages/microcosm-build/src/microcosm/build/us_runtime/US_LOCAL_JURISDICTIONS.md`):
`in_denver` and `pa_philadelphia_wage_tax_resident` when every household has a
county, and also `in_yonkers` and `in_wilmington` when every household has a
place and a block. The builder reads the parent first and refuses one that lacks
such a flag, carries one that disagrees with its geography, or carries one its
geography cannot decide (`in_yonkers` where some household has no block, say),
before any model or output work. It also refuses a parent in which a
household's `block_geoid` does not begin with that household's `county_fips`:
the block was kept from before the county was redrawn, so the place beside it
cannot be trusted. A parent that predates the flags, in which every household
has a county, therefore needs a rebuild before it seeds annual files. A parent
with no `county_fips` column, or with a null county on some household, decides
no flag: the builder accepts it when it carries none, and its receipt records
no rung and no carried flag.

The output directory must be new. A failed attempt retains its partial files and
`build_status.json`; rerunning requires another directory. `annual_manifest.json`
is written last, after all years finish and source/input hashes are rechecked.
It contains:

- `base`: source dataset, year, base build ID (`parent_release`), path, and
SHA256.
- `base`: source dataset, year, base build ID (`parent_release`), path, SHA256,
and the parent's local-jurisdiction flag receipt (`local_jurisdiction_flags`).
- `inputs`, `model`, and `runtime`: SSA pin, model commit and source hashes, actual
implementation hashes, and dependency versions.
- `metadata.dataset_years`: a map from the source dataset to year-keyed annual
Expand Down
2 changes: 2 additions & 0 deletions docs/us-location-v1.md
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,8 @@ What each line does:
- ACS households draw within their observed PUMA. Donors keep the block their base drew. That base must record `block_v1`, so each donor's block lies in its CPS source geography; staging refuses a legacy base before the ACS fetch, and refuses any donor without a block.
- Finalize runs `us_block_location_gate` on the staged ladder. The targets' `--ladder` must be the PUMA ladder staging recorded.

Each line also derives the four input-only local-jurisdiction flags (`in_denver`, `in_yonkers`, `in_wilmington` and `pa_philadelphia_wage_tax_resident`) from the county and place of the block it drew or kept, after the draw, and records that the block rungs decided them. `packages/microcosm-build/src/microcosm/build/us_runtime/US_LOCAL_JURISDICTIONS.md` says where each line records it.

## Invariants

Each of these is a property test in `tests/engine_free/us/test_us_block_location.py` (Hypothesis over nested synthetic ladders) or `test_us_cps_source_geography.py`:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -350,7 +350,7 @@
"acs_person_predictors": "878c788a6f037d7aca12b3586ea034eff04f3034ffa11935a736493042551f25",
"authority": "bf681aedc859fd6398ef72da68f584069b7d25b3085c549bf99f82e8324c4eef",
"early_families": "4aa9f736fd76e83955477ad1667e58f48f264783f05bdc7f0102cd32d61323bd",
"full_checkpoint": "ecf64f2bfbb59ffaaa717d8a09d38e56a38d6d43c1aa0a209d57492b038fb19a",
"full_checkpoint": "47d4474df59d47ad5e2fd9a4663002c1c34761862c679e3059bbb83687f17fba",
"gap_fill_schedule": "1c31f9868f7884347cc19cf1ff65da43f950b9114941a715bab168246db414a7",
"graph_nodes": "1b208fff4f6d878c522147fee617177544bda8963c940f98a4bfc37507cb955f",
"geography_assignment": "44e7f5f6cd7ceeef85d532c3d46306d03de4f4ee811376e6d29920742746b65c",
Expand Down Expand Up @@ -392,8 +392,11 @@
# microcosm#1096 moves both again: solve's opt-in softmax mass
# parametrization projects exactly onto the capped simplex; the default
# projection parametrization is unchanged.
"seed_map": "8d0542f7b83f030772e6e53b5742d0f13bcad82325a4e9b66d5d999a3fbb5276",
"seed_protocol": "3ab23e82779263dabe8da210de55ce7f12fdc0464e8145ca2c18649426b7f976",
# microcosm#1444 moves both: housing_inputs puts each ACS rent draw on its
# own household's head. microcosm#1453 moves both again: geography_ladder
# and puma_ladder write the local-jurisdiction flags.
"seed_map": "5230ab2f01d1ffbc841eb58b5eb8e452e470bcc3c6ea077b9678f432fc4dd8e4",
"seed_protocol": "4ac422f9c40e6bb61b27f31a22bdd31e001e0ce9062fcb62c5906b571ef9f19d",
"source_manifest": "dc3879886d2a69f20fb982a675d7fb322c0e4017afef6471be54b0ee3cbd2af6",
"take_up": "9522ce40f7dea569312dd7a7beb474e5a5afadd2f1e10cb5876534c3ef623d35",
"tail": "565f0ceeadab69d3e96a886a00dd0305f7425fa3acde24d12ba48db2b37d5fc0",
Expand Down

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@
Each projection starts from the same base frame. Only one projected year is
held in memory at a time. The original H5 is copied byte for byte, and all later
files retain its entity/column/row layout with an explicit ``_time_period``.
No file adds a column, so the parent must already carry every local-jurisdiction
flag its own geography decides; the lane refuses a parent that lacks one,
carries one that disagrees with its geography, or carries one its geography
cannot decide, before any model work.
Each projected year's H5 is ``microcosm_us_<year>`` (key and file name); the
base year, and the family, take the key of the base build's dataset
(``base_dataset``, ``microcosm_us_<base year>`` unless given), so the
Expand Down Expand Up @@ -90,6 +94,36 @@ def _check_pin(path: Path, expected: str) -> None:
raise ValueError(f"SHA256 mismatch for {path}")


def _parent_local_jurisdiction_flags(frame: Frame) -> dict:
"""Require the parent to carry its local-jurisdiction flags, with a receipt.

The lane copies the parent's base year byte for byte and keeps the
parent's columns in every projected year, so it cannot write a flag the
parent lacks: the engine would default it to ``False`` for every resident
in every year.
"""

# From microcosm.build.us_local_jurisdictions, never through us_runtime:
# importing any us_runtime module asserts the engine ABI lock wherever
# policyengine-us is installed, so this check would refuse every parent
# under another engine version (test_us_annual_static_aging_gate_imports).
from microcosm.build.us_local_jurisdictions import (
us_local_jurisdiction_artifact_receipt,
)

try:
return us_local_jurisdiction_artifact_receipt(frame)
except ValueError as error:
raise ValueError(
"The annual lane keeps its parent's columns and base-year bytes, so "
"it needs a parent that already carries every local-jurisdiction "
"flag its own geography decides; rebuild the parent through a "
"geography line, which writes those flags and keeps every block "
"inside its county. "
f"{error}"
) from error


def _model_provenance(*, source: Path, commit: str, version: str) -> dict:
import policyengine_us

Expand Down Expand Up @@ -278,13 +312,8 @@ def build_annual_static_aging(
ssa = Path(ssa_csv).expanduser().absolute()
_check_pin(base, base_sha256)
_check_pin(ssa, ssa_sha256)
model_kwargs = {
"source": Path(model_source),
"commit": model_commit,
"version": model_version,
}
model = _model_provenance(**model_kwargs)
runtime = _runtime_provenance()
# Read the parent before any model work, so a parent this lane cannot
# carry forward fails first.
with pd.HDFStore(base, "r") as store:
_period(store, base_year)
tables = {
Expand All @@ -301,6 +330,14 @@ def build_annual_static_aging(
frame = Frame(
tables, US_SCHEMA, {"household": Weights(weights, WeightKind.CALIBRATED)}
)
local_jurisdiction_flags = _parent_local_jurisdiction_flags(frame)
model_kwargs = {
"source": Path(model_source),
"commit": model_commit,
"version": model_version,
}
model = _model_provenance(**model_kwargs)
runtime = _runtime_provenance()
base_tables = {
entity: table.loc[:, columns[entity]]
for entity, table in engine_tables(
Expand Down Expand Up @@ -337,6 +374,7 @@ def build_annual_static_aging(
"parent_release": parent_release,
"path": str(base),
"sha256": base_sha256,
"local_jurisdiction_flags": local_jurisdiction_flags,
},
"inputs": {"ssa": {"path": str(ssa), "sha256": ssa_sha256}},
"model": model,
Expand Down
Loading
Loading