Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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/922-us-county-facts-pin.added.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Pin the US county facts (IRS SOI county, Census PEP county and seven ACS 5-year county tables) as their own Chronicle file beside the main US feed, and make the ACS-local county rung read them through `--county-facts` and `--county-facts-sha256` instead of `--feed`; a county run also needs `--feed-sha256`, the operator's digest of the `--feed` file. The US country package declares the two new pin files, which moves the US bundle's `spec_sha256`.
7 changes: 5 additions & 2 deletions docs/agent-guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -581,8 +581,11 @@ The ACS local-area release can build its fresh staging H5 on Modal with
`us-acs-multispine-staging`, then consume its verified H5 and summary through
`us-acs-local-release`; see [the Modal stage runbook](us-modal-stage-runbook.md#acs-multispine-staging).
Its optional [county calibration rung](us-acs-local-county-rung.md) uses
`--geographies state,cd,county --soi-mode state_county`, a county-inclusive
Ledger feed, and matching county boundaries. Full runs require all 3,144
`--geographies state,cd,county --soi-mode state_county`, the separately
pinned county facts (`--county-facts` and `--county-facts-sha256`;
`us/chronicle_county_facts.json`, microcosm#922) beside the main feed, and
matching county boundaries. County materialize runs are local: the Modal stage
runner cannot pass `--county-facts`. Full runs require all 3,144
county-equivalents and write `county_reliability.json`; the base year is 2024.
County solves use a run-level loss cap of 10 and a per-record weight cap of 5,
configurable with `--county-target-loss-cap` and `--county-max-weight-ratio`
Expand Down
20 changes: 10 additions & 10 deletions docs/evidence/spec-engine/us-f0-coverage.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"country": "us",
"documentation_sha256": "fda6ec0dd925077f4d84d30a1c206dd81d82c5e16bd94506e81fe1b9f7e2f466",
"field_usage": {
"authored_normative_field_count": 32609,
"authored_normative_field_count": 32615,
"claim_count": 48,
"claims": [
{
Expand All @@ -16,8 +16,8 @@
"legacy_sinks": [],
"mode": "front_end_validation",
"pointer_class": "all",
"pointer_count": 104,
"pointer_sha256": "8a186065f5b8ffc59bc3f62fe927975e6f36bc1e913aa61761652c9a8aa67988",
"pointer_count": 110,
"pointer_sha256": "368fe74c5a1ac00cc51079ffc1e13add27471d6daeaf2bf362cb321be9535619",
"rationale": null,
"relative_sink_prefix": null,
"source_prefix": "/authored/country_package.json",
Expand Down Expand Up @@ -758,20 +758,20 @@
"verifier": "vintages"
}
],
"configuration_field_count": 42395,
"consumed_field_count": 42395,
"configuration_field_count": 42401,
"consumed_field_count": 42401,
"generation0_effect_counts": {
"legacy_behavior": 38780,
"no_generation0_effect": 3615
"no_generation0_effect": 3621
},
"mode_counts": {
"compiler_semantic": 27674,
"front_end_validation": 349,
"front_end_validation": 355,
"identity_only": 103,
"legacy_behavior": 14269
},
"multiple_primary_use_field_count": 0,
"pointer_inventory_sha256": "81bc649e653b467b0da8fa7442a895fe45f24a263c725d764ca9ed8f4441325c",
"pointer_inventory_sha256": "7765ab26649d67e3ae69a8b10af462fc7e7921ed88f681503aa766640f6cf821",
"resolved_binding_field_count": 9786,
"unused_field_count": 0
},
Expand Down Expand Up @@ -2585,7 +2585,7 @@
"country": "us",
"schema_id": "country_spec",
"schema_version": 1,
"spec_sha256": "2171077615ae07dd8d079fbf3a110aa67b561a5d58048defdb09c4051659d6f0"
"spec_sha256": "3fd1a3840bd8769b5fa674ab51d3db9a92450e40bf09d5cf9894add726c4c4b8"
}
},
"report_schema_version": 3,
Expand All @@ -2595,7 +2595,7 @@
"country": "us",
"schema_id": "country_spec",
"schema_version": 1,
"spec_sha256": "2171077615ae07dd8d079fbf3a110aa67b561a5d58048defdb09c4051659d6f0"
"spec_sha256": "3fd1a3840bd8769b5fa674ab51d3db9a92450e40bf09d5cf9894add726c4c4b8"
},
"status": "pass"
}
138 changes: 75 additions & 63 deletions docs/us-acs-local-county-rung.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,8 @@ every state, even when an entire concept or parent block is absent:
| `return_count` | `irs_soi.individual_income_tax_returns` | count |
| `adjusted_gross_income` | `us:statutes/26/62#adjusted_gross_income`, source concept `irs_soi.adjusted_gross_income` | USD |

The feed has already converted the AGI publisher values from thousands of USD
to USD; the county rung does not apply another scale factor. It refuses
Chronicle has already converted the AGI publisher values from thousands of USD
to USD in the county facts file; the county rung does not apply another scale factor. It refuses
duplicate facts, negative or nonfinite shares, zero share denominators,
incomplete county inventories, incompatible boundaries, and missing or
ambiguous state parents. No unsupported concept receives a new engine measure.
Expand Down Expand Up @@ -127,60 +127,61 @@ two concepts are available. At fixed error, raising ESS cannot worsen a grade.
These are report-only evidence grades;
Kish ESS is not a county standard error or a guarantee of unbiased estimates.

## Audited feed and remaining input work

The release's packaged pin is
`packages/microcosm-build/src/microcosm/build/us/chronicle_feed.json`, pointing
to Chronicle commit `51aa40fd28e2ca81937752515e773d123fecfb71`. The corresponding
local feed is
`/Users/maxghenis/PolicyEngine/_buildh-runtime/inputs/consumer_facts_us_51aa40f.jsonl`.
The audit streamed its actual bytes: 40,178 facts, 169,038,757 bytes, SHA256
`965a29ac9458edb58a05184917ee4a19772fd3dc7b4588db6eb6da5803641aac`.
It contains **zero county facts**: 23,968 congressional-district, 12,251 state,
and 3,959 country facts. The historical release recipe uses a `--feed`
placeholder; that recipe does not prove county facts were exported.

Both county source packages already exist at the pinned Chronicle commit.
They are omitted by the explicit `chronicle_feed_scope.json` selection. A
reviewed feed extension needs the following additional pairs:

```json
[
{
"record_set_id": "irs_soi.ty2022.county_totals",
"period_type": "tax_year",
"period_value": "2022",
"package_id": "soi-county-2022",
"package": "packages/irs_soi/county_2022",
"build_year": 2022
},
{
"record_set_id": "census_pep.vintage2024.county_population",
"period_type": "calendar_year",
"period_value": "2024",
"package_id": "census-pep-county-population-2024",
"package": "packages/census/pep_county_2024",
"build_year": 2024
}
]
```

Add the packages to their build-year `runs` entries, update the scope pair
count, rebuild with `tools/build_us_chronicle_feed.py`, and review/update the
feed and scope hashes and fact-to-target parity/fencing evidence. The current
fiscal compiler excludes county SOI geography; this rung consumes the raw
county facts and splits existing state measures. Population defaults still
use the ladder. Future ACS county packages require an additional scoped feed
extension. This implementation performs **no feed or scope mutation** and
does not claim an available county feed hash.
## County facts input (microcosm#922)

County facts do not come from `--feed`. They have their own pin,
`packages/microcosm-build/src/microcosm/build/us/chronicle_county_facts.json`,
with scope `chronicle_county_facts_scope.json` (scope name `us_county_facts`),
built at Chronicle commit `3e9d3a0694e8ca7e31ed5319c3ceb1bde92b12e0` on the
`chronicle.consumer_fact.v5` row contract. The file holds 180,326 rows
(922 MB, SHA256
`67b0998aa2ee1aeed6637dab6a846f405246706508074b1c1b5bab7bd98c8bea`): IRS SOI
county TY2022, Census PEP county vintage 2024, and the ACS 2020-2024 5-year county tables B01003, B11001, B19001,
B19013, B19025, B19051 and B19061. The main feed, its scope and the target
parity resources are unchanged; [the re-pin notes](us-chronicle-feed-repin.md#the-county-facts-pin-microcosm922)
say why the county facts are a separate file.

A `--soi-mode state_county` materialize must pass
`--county-facts <file> --county-facts-sha256 <the county pin's facts_sha256>`
and `--feed-sha256`. `--feed-sha256` is the operator's digest of the `--feed`
file: materialize refuses a `--feed` file that does not match it, but nothing
binds it to the main pin, because local runs also use other feeds. The parser refuses a county facts digest
other than the pin's, county facts without county geography or
`--soi-mode state_county`, and a county facts path that is the `--feed` file.
`prepare_run` loads the file with
`microcosm.build.us_runtime.county_facts.load_us_county_facts`. The loader
first hashes the file and refuses it unless its digest and row count are the
pin's. A second pass hashes it again and parses it. That pass refuses a row
that is not a JSON object, is on another row contract, is not a county row or
is outside the scope, and refuses a file whose bytes changed between the
passes; it reads to the end before refusing, so a file swapped between the
passes is named as changed whatever its rows hold. It drops the 78 Puerto Rico municipios (4,136 ACS rows) with a count
and keeps only the fields county targets read. A refusal, or a file that
cannot be read, is recorded in `county_surface.json` before the staging frame
is loaded or any target row is materialized (the state administrative targets
are compiled from `--feed` earlier). On the build machine the loader reads the pinned file in about 5 s and
holds about 0.9 GB of rows, measured apart from importing the US runtime. The
rows stay on the surface for the rest of the materialize stage; today only the
SOI county split reads them, in `prepare_run`. No county step reads `--feed`,
and nothing reopens the county facts file after `prepare_run`. The
run identity and `materialize_rss.json` record the county facts receipt under
`county_facts`. The refresh recipe carries both flags. It names placeholder files
(`<county-facts.jsonl>`, like `--feed`'s) and never the build machine's path;
the county digest it carries is the pinned one, while `--feed-sha256` stays a
`<sha>` placeholder. A run without county
facts records nothing new, so its run identity keeps its pre-county bytes.

The inspected Chronicle publisher inputs have two concrete blockers:

- **Kalawao:** the SOI CSV has 3,143 counties and omits `15005` Kalawao County;
the PEP CSV has all 3,144. A complete county SOI block currently fails with
that county named. A source correction or an explicitly reviewed county
treatment is needed before a full SOI run; this implementation introduces
no fallback and does not silently borrow Maui's facts.
- **Kalawao:** the SOI CSV has 3,143 counties and omits `15005` Kalawao County.
PEP and five ACS tables carry all 3,144. B19013 has 3,143 (it has no De Baca
County, `35011`), and B01003 reaches 3,144 only across its two record sets.
The IRS 2022 county users guide (`22incydocguide.docx`) says items with fewer
than 20 returns for a county were excluded, so Kalawao's SOI value is
missing, not zero. The guide does not say whether Kalawao's returns are
counted in another county's row. Until the rung declares a reviewed treatment (a
combined SOI cell {15005, 15009}, planned in the production county rung's own change),
a complete county SOI block still fails with that county named.
- **Connecticut:** both packages use the nine planning-region codes `09110`
through `09190`. The household county column and ladder must use those same
boundaries. Select `--county-column county_fips_2023` when the parallel
Expand All @@ -190,7 +191,7 @@ The inspected Chronicle publisher inputs have two concrete blockers:
SOI facts carry `geography.level = "county"` and Census-style IDs such as
`0500000US01001`; the row geography is authoritative even though the record
set itself groups all counties. SOI geography metadata says vintage `2022`,
PEP says `2024`; actual county-code inventories must agree across feed,
PEP says `2024`; actual county-code inventories must agree across the county facts,
ladder, and households. The audited raw publisher artifact hashes are
`2c04ff235bcbacb990b316bf79c7c628089a9a4c1dd9593ac51f74a109b13343`
for `22incyallnoagi.csv` and
Expand All @@ -199,7 +200,8 @@ for `co-est2024-alldata.csv`.

## Full-run requirements and command

A full run needs a reviewed county-inclusive Ledger feed and its actual SHA256,
A full run needs the pinned main feed and its SHA256, the pinned county facts
file and its SHA256,
a staging H5 and summary with household support in every county, a matching
county-boundary PUMA ladder, and resolution of the Kalawao SOI gap. The
historical staging file was approximately 10.7 GB. The historical ladder was
Expand All @@ -211,7 +213,7 @@ At 3,144 counties and the current two SOI concepts, the county increment is
`3,144 × (population + returns + AGI) = 9,432` rows. With the pinned 4,380 state
administrative rows, 51 state population rows and 436 district population
rows, this is approximately **14,299 rows** including holdouts. The exact
count depends on the reviewed feed and ladder; an incomplete SOI county block
count depends on the pinned county facts and the ladder; an incomplete SOI county block
is refused rather than reducing that count silently.

For the historical 1,588,854-household staging population, each household can
Expand All @@ -225,9 +227,15 @@ engine/frame dominate the total. Historical full materialization peaked at
not a county-build benchmark. The implementation does not allocate a dense
households-by-county-target matrix.

Once the input blockers are resolved, set these paths and the new reviewed
feed hash in the execution environment. This example uses the planning-region
column; use `county_fips` only with a feed and ladder matching that column.
County materialize runs are local. The Modal stage plan
(`tools/modal_us_stage_plan.py`) has no way to pass `--county-facts`, so its
check (`check_stage`) refuses a `state_county` materialize before any compute.
A `--run` that skips that check stages its inputs first and is then refused by
the release tool's own argument check.

Once the input blockers are resolved, set these paths and the two pinned
digests in the execution environment. This example uses the planning-region
column; use `county_fips` only with a ladder matching that column.
The following is documentation only and has not been executed:

County rows activate a separate solver profile: `--county-target-loss-cap 10`
Expand All @@ -251,8 +259,10 @@ The **tax-target cost is unmeasured until the joint solve runs**; these are
starting settings, not evidence that the production tradeoff is acceptable.

```bash
export COUNTY_FEED=/path/to/consumer_facts_county.jsonl
export COUNTY_FEED_SHA256='<new-reviewed-64-hex-feed-sha256>'
export COUNTY_FEED=/path/to/pinned/consumer_facts_us.jsonl
export COUNTY_FEED_SHA256='<the main pin facts_sha256>'
export COUNTY_FACTS=/path/to/consumer_facts_us_county_3e9d3a0.jsonl
export COUNTY_FACTS_SHA256='67b0998aa2ee1aeed6637dab6a846f405246706508074b1c1b5bab7bd98c8bea'
export COUNTY_STAGING_H5=/path/to/acs_multispine_staging.h5
export COUNTY_STAGING_SUMMARY=/path/to/acs_multispine_staging.summary.json
export COUNTY_LADDER=/path/to/matching_us_puma_ladder.npz
Expand All @@ -264,6 +274,7 @@ uv run python tools/build_us_acs_local_release.py \
--staging-h5 "$COUNTY_STAGING_H5" \
--staging-summary "$COUNTY_STAGING_SUMMARY" \
--feed "$COUNTY_FEED" --feed-sha256 "$COUNTY_FEED_SHA256" \
--county-facts "$COUNTY_FACTS" --county-facts-sha256 "$COUNTY_FACTS_SHA256" \
--ladder "$COUNTY_LADDER" \
--families snap,medicaid,soi --geographies state,cd,county \
--soi-mode state_county --county-column "$COUNTY_COLUMN" \
Expand Down Expand Up @@ -294,7 +305,7 @@ tests with at most two workers, the related release/district tests, the test
layout verifier, `uv run ruff check .`, and `uv run ruff format --check` on
touched Python files; report actual results in the PR.
No release build, full materialization, annual projection, publication, or
county-inclusive feed regeneration is part of this implementation's validation.
county facts rebuild is part of this implementation's validation.

## Validation record

Expand All @@ -307,7 +318,8 @@ installed, after the requested US setup completed:
- Existing release, sparse district, district property, geography-label, and
loss-weight suites: **125 passed, 2 skipped**, using `-n 2 --dist loadfile`.
The skips are optional checks requiring an explicitly configured pinned
Chronicle feed; the actual feed inventory was audited separately above.
Chronicle feed. This record predates the county facts pin; the county
inventory is in the county facts section above.
- `uv run ruff check .`: clean.
- `uv run --no-sync python tools/ci_test_plan.py verify`: clean, 772 test files
in registered directories.
Expand Down
Loading
Loading