Skip to content

Ready the US ACS local-area lane for the next national build on policyengine-us 2.145.3 (#1661, #1675, #1154) - #1719

Draft
juaristi22 wants to merge 46 commits into
mainfrom
us-local-area-ready-2145
Draft

juaristi22 wants to merge 46 commits into
mainfrom
us-local-area-ready-2145

Conversation

@juaristi22

@juaristi22 juaristi22 commented Nov 24, 2026 •

Copy link
Copy Markdown
Collaborator

Part of #922. Now targets main: #1676 merged as 0ba5e85ee, and main is merged in (5dd6cb92a).

Purpose

This PR unlocks the US ACS local-area build on policyengine-us 2.145.3 against the published national build populace-us-2024-3b3de63-12693b9db03d-20261127T193416Z (built at 12693b9db). The build has three parts:

  1. R1, the ACS staging;
  2. R2, the 2024 local release, with its state, district and county surfaces;
  3. the publisher's preflight.

Most of what it fixes comes from the new donor and engine, so it holds for every surface; the county-specific part is AGI support. The lane last ran as the County Files proof of concept (#1660, #1647), on policyengine-us 2.2.1 with a patched donor and temporary flags. The final build runs from this PR's head (runbook: docs/us-county-files-final-build.md; #1661).

What changes

#1660's pre-checks and its strike_benefits entry. This PR picked them early with authorship. #1660 has since merged into main with its proof-of-concept flags (--allow-default-donor-column in R1, --county-drop-empty-soi-rows in R2). The runbook passes neither.

The AGI pre-check reads AGI's inputs for its year, from the engine. On 2.145.3, AGI's static closure reaches take-up flags R2's stages fill, through formulas the engine runs without reading anything in R2's year:

  • the 2020-only charitable deduction for non-itemizers;
  • the behavioral responses, which return 0 in a pass without a reform.

The check builds on #1676's probe, which runs each formula of the closure as the engine does, on the engine's parameters, with a population that refuses reads. Here the probe's simulation is also that of a pass without a reform (no baseline, as policyengine-core sets it), and the closure follows reads inside the engine's helper functions (follow_helpers). No year or variable is named. On 2.145.3 the 2024 AGI reads 218 inputs, none of them a stage-filled column; in 2020 the deduction still reads them. Engine tests check:

  • the deduction is 300 for a 2020 filer giving 1,000 in cash, and 0 in 2024;
  • the responses compute 0 and the elasticity effects are never computed;
  • an AGI traced in 2024 computes no stage-filled column.

Engine and donor location in the staging summary, c0b792ae5.

  • Staging records the engine it ran on (engine_versions) and the donor base's location rule.
  • R2's materialize refuses a staging made on another engine before it loads the staging file.

SOI support in minimum support, ac3d4cabc and 1f833383a (#1661 item 1). A county whose households all store an AGI of 0 gets an empty county AGI row, which R2 refuses after its engine pass. On a county SOI surface, materialize computes each household's AGI before minimum support, one chunk at a time. Minimum support then:

  • takes the K eligible households first in rank order for a county with none, and swaps the K-th for the next household in rank order with a positive AGI only when none of the K has one ("reason": "positive_agi"), so the rest keep their PUMA's AGI mix;
  • moves K same-PUMA households with a positive AGI into each county still without one;
  • never leaves a donor county without a household whose AGI is nonzero.

The receipt reports the first-pass movers' share with a positive AGI beside their PUMAs' share. A county it cannot fill is refused before the engine pass. The AGI check applies the same moves.

Donor lineage, 26c36d50d, 3daa52019 and c9de1722d. R2's five inherited donor limitations describe the Build O lineage. A staging from a national build outside it is refused at calibrate, and again at finalize, until REVIEWED_DONOR_LINEAGES has the build. The published national's review, from its own evidence:

An entry maps each limitation that holds to the reason the donor's evidence gives, and finalize writes it in place of the Build O text.

Helper reads in the static index, 134afc6a6 (#1675). PolicyEngineUSVariableMetadataIndex(follow_helpers=True) records each read inside one of policyengine-us's module-level helpers under every variable whose formula reaches that call. It is opt-in, and the default view is unchanged. The register walk and the AGI check use it.

WIC and EITC take-up on ACS rows, 68cf15a11 (#1154, #1675). Both flags reached R2's engine pass at the engine default, True, on every ACS row.

  • WIC: R1 draws the ACS rows' decisions with the national wic_claim_input generator before pooling.
  • EITC: R2's take-up stage draws the ACS tax units' claims with the take-up contract's seeded draw by number of qualifying children.
  • The take-up gate grades both flags.

The ESI employer premium on ACS rows: #1670, merged at fde23835c. It carries the premium from staging through package, with the ESI gates at staging, finalize and package.

The reviewed-fill register on 2.145.3, 38524a2b3 (#1675). reviewed_against is 2.145.3. Each entry lists every program the walk reaches through the engine's helpers, and the engine-tier test checks every list against the walk.

Merging #1676 and main. One merge of #1676's head (8457fe1a5) and one of main (5dd6cb92a). Fixes they needed:

  • the no-county regression test now stubs the staging engine check, as the other tests do (9625aa781);
  • R2's AGI pass calls the shared household-nesting check that main moved to household_batches (aa1534c53). Without it, every county run would stop at that pass. The engine test and an adversarial review of the merge both found it.

Runbook, docs/us-county-files-final-build.md. It covers inputs and pins, one command per step, what to send and when to stop. It is now sized for the dense donor (8ef3da2a0): the proof of concept's figures don't bound R1, and it asks for about 100 GB of free disk. After a second review (51969a367):

Before the final build

Nothing is owed in code. Both data entries are in: the register on 2.145.3, and the published national's lineage entry. The build runs from this PR's head, on a 128 GiB host.

Tests

Local runs on policyengine-us 2.145.3, counted with JUnit. The engine-free runs hide the engines as CI's job does.

  • Engine-free: the 139 files touched by this PR, or naming a module both sides changed: 10,342 tests, 10,313 passed, 29 skipped.
    • That is after the two fixes the merge needed: the regression test's 16 cases, and the staging builder test's duplicate parameter, which had stopped one chunk from collecting.
  • Engine tier:
    • the register walk and the release tool's contract tests: 253 passed;
    • the AGI, take-up, annual local and multispine pool workflow tests: 51 passed after the AGI-pass fix.
  • At 5dd6cb92a (after main):
    • the 32 files touched since that pass, plus main's changed tests and the local-area contract tests: 2,210 tests, 2,207 passed, 3 skipped;
    • the AGI engine tests, the release tool's contract tests and the register walk: 203 passed.
  • At 51969a367:
    • the release tool and lineage-order tests: 360 tests, 359 passed, 1 skipped;
    • the runbook's R2 block, run in bash and in zsh with stub commands, passes identical arguments to the five stages, and each stage's arguments parse with R2's parser.
  • Pins and lint: the seed and spec pins (--legacy-only --check and --check) and the coverage manifest (50842/50842) pass; tools/ci_test_plan.py verify and verify-workflow are ok; ruff check . is clean.

Not in this PR

🤖 Generated with Claude Code

MaxGhenis and others added 30 commits November 17, 2026 14:47
Takes the ESI premium slice of #1199 (e730a95) into
us_runtime/esi_premiums.py: the row-kind mask, the pool-anchor kernel
with_us_esi_premium_pool_anchor, and the summary and gate checks for
frames where some rows carry the raw ASEC fields and others were filled
by a transfer.

Left out: anchor_share (US_ESI_PREMIUMS_ANCHOR_SHARE_KEY,
_validated_anchor_share, the stage keyword and its config read),
us_esi_premiums_household_mass_share, and all of #1199's stacked-pool
wiring (multispine_pool, stacked_spine, graph, spec YAMLs and the
re-pinned counts and digests).

_raw_evidence_mask, us_esi_premiums_summary and both gates take a
keyword-only allow_transferred_rows, default False. With False every
row must carry every raw ASEC field or the stage raises
SourceRuntimeError, and PERIDNUM is never read: main's rule. With True
the mask applies #1199's row-kind rule verbatim; the kernel uses True.
On frames where every row is a CPS row the summary keeps main's
arithmetic, so its statistics match main bit for bit.

Route A's callers (the base builder and the release tool) pass nothing
new and keep main's rule. derive_us_employer_esi_premiums_from_manifest
and with_us_esi_premium_inputs are byte-identical to main, including
the idempotent branch that calls the signal gate on the default.

Tests:
- test_us_esi_premiums_pool_anchor.py: #1199's kernel and row-kind
  tests, plus the mixed-frame gate tests, on a hand-built mixed frame;
  the default refuses transferred and partial rows and never reads
  PERIDNUM; the kernel refuses a CPS row without a record id.
- test_us_esi_premiums_route_a_differential.py: Route A-shaped frames
  (no id column, id on every row, red frames, blank PERIDNUM, a row
  with neither fields nor id) in the base builder's and the release's
  call orders. Premiums are byte-equal to main's stage expression, and
  every gate's verdict and details match an oracle of main's summary
  and gates (test_support/microcosm_build/us_esi_premiums_main_oracle.py).
  A hypothesis test compares verdicts over random row edits.
- test_us_spine_blindness.py: comment on esi_premiums.py's entry
  only; the classification is unchanged.
- test_us_esi_premiums.py (main's) passes unchanged.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Fixes the four P2 findings the lead kept from the commit 1 reviews.

A1: with the default allow_transferred_rows=False, _raw_evidence_mask's
refusal now names each incomplete raw ASEC column with its row count and
keeps main's remediation ("the Census column was not restored for every
vintage (asec_census_person_columns) and is never defaulted", plural when
several columns are named). The keyword hint now says only a frame that
holds transferred ACS rows is graded with allow_transferred_rows=True.
Route A's base builder prints this text in its SystemExit and the release
writes it to esi_premiums.json. The verdict, the exception class and the
substrings the pool-anchor tests assert are unchanged.
test_a_null_raw_field_is_refused_with_mains_diagnosis checks one null
NOW_HIPAID row on Route A frames (pre-clone, base, export) and fails on
a602ccd.

A2: the vendored oracle's header names the live helpers it imports and
says the differential test (T2) cannot detect a change to them.

B1: a comment at the summary's all-CPS guard, and the differential
module docstring, say its no-subsetting part holds by construction: an
all-True subset holds identical values, so no in-process test sees it.

B3: the property test's docstring says the bit-equal statistics are
pinned by the named F1/F2 tests, not by the property test.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The verify of 8770b90 raised three P3s:
- The hint said a frame of CPS rows is never graded with
  allow_transferred_rows=True, but the lane's donor qualifier grades its
  CPS donor release with True. It now says only a frame that holds
  transferred ACS rows needs the keyword, and any other frame should
  restore the fields.
- The oracle header now also lists the functions and constants the six
  shared helpers call, which T2 cannot see either.
- The two-column refusal case now nulls both fields on one row, so the
  lead count (rows) differs from the cell count.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Add U/acs_local_esi_premiums.py from #1201 (e7e85cf): the lane's donor
qualifier, its one-family ASEC-only transfer plan, the anchor wrapper around
with_us_esi_premium_pool_anchor, and both ESI gates on narrow views. Text
that described #1199's stacked-pool wiring, which main lacks, is reworded.
The qualifier's signal gate and both lane gates pass
allow_transferred_rows=True (Q13); Route A's callers keep the default.

build_optional_acs_multispine takes esi_premium_donor_factory. When it is
set, the ESI pass runs after main's hours and income passes and immediately
before the shared transfer (Q4), and its fit records and imputed inputs sit
between theirs in the same order. The pooled frame is anchored after
with_optional_acs_spine, and provenance gains
fit_configuration.esi_premium_donor_channel and local_esi_premiums. With the
default None the orchestration is unchanged.

Engine-free tests: #1201's lane tests run on main, with the shared pool plan
assertion inverted (main's pool plan has no ESI family) and the whole-frame
gate calls passing the lane keyword, plus a check that the lane frame is red
under the default keyword. T5 is a pass-order differential with a two-family
shared plan: every non-premium column of every table, the weights, strata and
the shared transfer's receipts are byte-equal with and without the factory.
T6 records every transfer call with main's hours and income passes on. The
spine-blindness inventory classifies the new module.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The ACS local lane now carries the employer premium (microcosm#454) from
staging through package, and each stage holds it to the lane's two gates.

- Staging (tools/_legacy/build_us_acs_multispine_base.py) qualifies the
  premium's donor before the SIPP donor load and the ACS fetch, passes the
  donor factory to the transfer, adds the premium's family to the
  transfer-coverage plan, and grades both ESI gates on the final frame after
  the hours gate and before export. A red gate stops the build. The summary
  records the verdicts and the transfer provenance (local_esi_premiums), and
  the orchestration record carries the flag.
- The local release tool (tools/build_us_acs_local_release.py) grades both
  gates at finalize on the calibrated bytes and binds them to that artifact.
  input_coverage.passed now comes from those gates rather than a hard-coded
  pass, and a red gate is a hard failure. Package refuses a report whose
  verdict is missing, red or bound to other bytes, with the refusal text the
  other bound finalize gates use. fill_reviewed_nulls keeps main's refusal of
  a null premium; only its comment changes.
- --allow-esi-premium-gaps is the recorded waiver for diagnostic builds. On
  the release tool it records red gates (enforced: false) without failing
  finalize or package. It still refuses a report that has no boolean verdict
  or is bound to other bytes. On staging it records a refused donor and red
  gates in the summary.
- Modal: allow_esi_premium_gaps is an option of US_ACS_LOCAL_RELEASE only.
  On US_ACS_MULTISPINE_STAGING the flag is owned, so a staging plan cannot
  forward it. No committed plan digest moves: ToolSpec options are code, not
  plan data.
- Tests: the legacy builder's wiring, order and evidence; the release tool's
  finalize grading and package binding, on a real lane frame; Modal
  forwarding; and an engine-contract test of the engine pass on a lane frame
  (CI runs it). Both tool loaders now come from one test_support module. The
  block-location and telemetry tests pass the new staging stage through.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…2283)

docs/us-esi-employer-premiums.md gains an "ACS local releases" section:
the lane's own ASEC-only pass, its donor qualification, the anchor kernel
and its wage-universe rule, the narrow view, and what staging, finalize
and package record. The section says how allow_transferred_rows splits
the callers: the lane passes True; the base build, the fiscal-refresh
release tool and the stage's re-check keep the default and its rule
(every row carries the raw ASEC fields, PERIDNUM unread). The gates table
and a new gates bullet describe grading a mixed frame by row kind, and
"What this does not do" drops the bullet that said the ACS local lineage
does not build. README.md and docs/agent-guide.md point to the section,
and one changelog fragment covers PR 0, including the
--allow-esi-premium-gaps waiver. No text describes stacked-pool wiring.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Brings in #1559 (Route A default ASEC pool) and #1635 (US gates in
us/gates.json, run in shadow beside today's gates). No textual conflicts;
git auto-merged the four files both sides touched
(tools/build_us_acs_local_release.py, tools/modal_us_stage_plan.py,
test_us_acs_local_release_tool.py, test_us_spine_blindness.py).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Declare the two finalize ESI gates as us_local entries of us/gates.json
(us_local_esi_premiums_signal, us_local_esi_premiums_anchor), bound to the
lane's own row-kind gates (allow_transferred_rows=True), so the battery's
shadow (microcosm#1585 item 11) compares them beside today's calls.
Finalize calls the two gates one by one inside their shadow sites, and
--allow-esi-premium-gaps is recorded as their waiver. Re-pins
SCOPE_PINS['us_local']; spec_sha256 and the other scopes' pins do not move.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Tests for what the lane review found unpinned, plus the docs and
docstrings it found stale. No production behaviour changes.

- Staging wiring test: a red ESI gate stops the build before the H5 or
  its summary is written ("write" is now in the recorded order), and a
  waived build (--allow-esi-premium-gaps) whose donor the qualifier
  refuses transfers nothing, owes nothing in the coverage plan and
  records the refusal, its red verdicts and the waiver.
- Local release: finalize runs with the gate battery's shadow armed and
  the us_local ESI entries match finalize's verdicts at 1.0, 0.0 and
  1.4; the ESI finalize tests serve the frame only as the calibrated
  artifact.
- Lane pass-order test: the shared plan adds tax-unit and SPM-unit
  families, as the declared plan has.
- Route A: a static import-closure test shows BASE and REL reach
  neither acs_multispine nor acs_local_esi_premiums.
- acs_local_esi_premium_gates hands the frame to the two single gates,
  which each narrow it once; docstring, the ESI doc's finalize sentence
  and status line, and refuse_unassigned_us_esi_premiums' docstring
  updated.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Brings in #1672 (build-then-certify) and #1677 (hand-off copy). Clean merge; the only files both sides touched are README.md and docs/agent-guide.md.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Fix the five findings of the independent review of 4e882d3 and two
nits that a check of those fixes raised.

- Blocking: on a mixed frame whose CPS rows hold no household mass,
  give their policyholders or employed policyholders no weighted
  MEPS-IC share, or give the employed a part of it that rounds to zero,
  the summary could divide by zero and stop both gates with
  ZeroDivisionError before a verdict. A CPS premium per unit of
  household mass that rounds to zero could do the same in
  _transferred_row_summary, and a CPS share of household mass that
  rounds to zero could stop the anchor gate in its private-sector
  cross-check. The new _refuse_unusable_source_anchor_evidence refuses
  the first three kinds of frame with a SourceRuntimeError naming each
  gap, and both gates record it as a red verdict. When the CPS premium
  per unit of household mass rounds to zero, _transferred_row_summary
  leaves the per-mass ratio NaN, and the anchor gate fails it whenever
  the transferred rows hold household mass. The cross-check divides by
  the share only when the share exceeds zero.
- Nit from the check: when the cross-check has no finite value, it
  records NaN and an unavailable reason that names each term at fault:
  the sector total, the share, or their quotient.
- Should-fix: the donor qualifier refuses a donor with any row that
  lacks a raw ASEC field or a CPS record id, before the signal gate,
  which would grade a row that lost both as a transferred row.
- Should-fix: under --allow-esi-premium-gaps, package refuses a red ESI
  gate unless finalize recorded the waiver (enforced: false).
- Should-fix: each stage of the ACS local release tool saves the
  waivers it applied to its own entries (<stage>.waivers.json), and the
  rebuilt comparison takes the ESI entries' waivers from finalize's
  record, so package's flags no longer rewrite them.
- Nit from the check: when finalize's observations have no waiver
  record, as in a checkpoint from 4e882d3, the shadow records the
  ESI entries' waiver as unknown and still rebuilds the comparison.
- Nit: _clone_disagreements selects rows only on a mixed frame.

The refusal, the per-mass guard and the cross-check's scaling run only
on a mixed frame. Tests: five mixed-frame refusal and rounding tests
and a three-case cross-check test (pool anchor), a donor that lost both
kinds of evidence (lane), a red gate finalize enforced (release tool),
and two shadow waiver tests (gate shadow). The ESI doc and the
changelog fragment describe the new refusals and waiver rules.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Since d5aa4e2 the local income pass's OIP predictor uses
strike_benefits as a component, so R1 requires every donor to carry
it. Neither the shared plan nor the local income pass transfers it, so
every ACS person reaches R2 with a null strike_benefits, R2 fills the
engine default 0, and finalize's reviewed-fill consumer gate refuses
the fill as unregistered (package refuses it too). This blocks the
County Files proof of concept's R2 (#922) and any staging built from a
current national donor.

The register entry names the 13 means-tested consumers that the
engine-tier test recomputes from policyengine-us 2.2.1, with the
verdict harmless: no pinned ASEC respondent reports other-income
code 12, so every donor value is 0, and a transfer would draw 0 too.
The engine-free test that pins the register's column set now lists
fills added since release 767312d.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
(cherry picked from commit 77f5fa1)
R2's attach_surface builds each county's IRS SOI rows from the state
rows' stored entries, and the state AGI row stores no zero. A county
whose households all have AGI of exactly 0 therefore gets an empty AGI
row, and attach_surface refuses the run after the materialize engine
pass (#1630 review, finding 1). Minimum support fills only counties
with no household.

tools/check_us_acs_county_agi_support.py runs on the staging H5 before
R2, in minutes and with no engine pass:
- It reads the household table and only the AGI income columns of the
  person and tax-unit tables (fixed-format blocks are streamed in row
  chunks).
- The AGI income columns are the money inputs of policyengine-us's
  irs_gross_income closure, read from the installed engine's source
  without importing it, less Social Security (taxable share only) and
  deductions, expenses and contributions. A null cell counts as 0, the
  default R2 fills. The check errs towards listing a county.
- With --puma-ladder it takes the county list from the ladder and
  applies R2's own minimum-support moves first.
- It writes a JSON report and exits 2 when a county is at risk.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
(cherry picked from commit 06b53f6)
R2's finalize stage grades every reviewed default fill against
acs_local_reviewed_fill_consumers.yaml and refuses an unregistered fill,
a different fill value or spine, or another policyengine-us. That
refusal comes after materialize and calibrate, hours into the run.

tools/check_us_acs_local_reviewed_fills.py runs in seconds after R1:
- it reads the staging summary's reviewed_engine_input_nulls (names and
  counts by spine);
- it refuses what materialize refuses: a NEVER_DEFAULT_FILLED null off
  the ACS spine, and a null ESI employer premium;
- it builds the fill records R2 writes, with the fill values R2's
  _resolve_engine_default gives, and runs R2's own finalize gate on
  them. A null that an R2 stage fills first counts as a fill, so it
  errs towards a refusal.
It exits 2 when R2 would refuse.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
(cherry picked from commit 46674e0)
The check counted a household when any person held a nonzero gross-income
input. policyengine-us 2.2.1 adds only the positive sources of a tax
unit's head and spouse to irs_gross_income, and only an adult can be
either, so a household whose income sits on a dependent, or on a tax unit
without an adult, has an AGI of 0. A county of such households passed the
check, and R2 would refuse its empty AGI row after the engine pass (#1660
review).

The check now loads the staging frame and summary as R2's materialize
stage does, holds back the formula-owned columns, fills the reviewed
nulls with R2's own fill step, and runs the engine for the household sum
of adjusted_gross_income in household chunks. An engine-tier test checks
that sum against the production SOI materializer's AGI measure on six
households, the dependent and no-adult cases included. Null take-up flags
that R2's own stages fill are held back, as the AGI does not read them; a
null never-default column that the AGI reads is refused, as R2 refuses it.

Part of #922.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
(cherry picked from commit 3b28e31)
…check

The zero-AGI pre-check set its exit status from at_risk alone. R2's
check_support refuses a county outside the ladder and a ladder county
without a household-universe record, with or without
--county-drop-empty-soi-rows, in materialize after the staging load and
the SSI/Medicaid pre-pass. With --puma-ladder the check now lists both
(counties_outside_ladder, unsupported_counties) with R2's set rules,
moves no household when a county is outside the ladder (as R2 does), and
exits 3, which takes precedence over 2. The report records its exit
status.

Part of #922; review of #1660 (comment 6955224433).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
(cherry picked from commit a5ca4df)
The reviewed-fill pre-check filed any ACS-only null in a never-default
column under natively_filled. R2's stages fill only the take-up stage's
SPM-unit take-up flags and engine-free fills and the SSI and Medicaid
take-up flags; R2's reasons for the immigration, disability, income
transfer and SSI disability-criteria columns say to re-run staging, so
such a null passed the pre-check and then stopped materialize. The check
now takes the stage-filled set from R2's own constants
(stage_filled_never_default), refuses every other never-default null on
any spine with a re-run-staging message, and records the set in its
report. A test ties the set to R2's own reasons.

Part of #922; review of #1660 (comment 6955224433).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
(cherry picked from commit 28e7b7c)
The zero-AGI check held back every null NEVER_DEFAULT_FILLED column that
the AGI does not read, on either spine. Run alone, it passed a file that
R2's first fill refuses. It now takes the stage-filled set from the
reviewed-fill pre-check (stage_filled_never_default) and holds back a
null column only when an R2 stage fills it, every null is on an ACS row
(the <entity>_spine tag) and the AGI does not read it. It refuses every
other never-default null, as R2's fill step does: a null on a donor row,
in a column no R2 stage fills, in one the AGI reads, or without a spine
tag to place it. An engine-tier test checks that no stage-filled column
is an input of the AGI closure, so an engine release that changes that
fails in CI.

Part of #922; review of #1660 (comment 6956136956).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
(cherry picked from commit f8b1039)
This branch carries the two pre-R2 checks from #1660 but not the
proof-of-concept flag --county-drop-empty-soi-rows (#1661), so the AGI
check's docstrings, two test names and its changelog line now say when R2
refuses (before or after its engine pass) instead of naming the flag. The
county rung doc gets a short section on running both checks between the
staging and R2, with their exit statuses.

No logic changes.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
On policyengine-us 2.145.3 the static dependency closure of
adjusted_gross_income reaches four take-up flags R2's stages fill
(takes_up_ssi_if_eligible, takes_up_medicare_if_eligible,
takes_up_tanf_if_eligible, receives_housing_assistance). Each path runs
through charitable_contributions_ald, the 2020-only charitable deduction
for non-itemizers, which reads the itemization choice. Its formula returns
0 without reading anything in a year whose gov.irs.ald.deductions does not
list it, and 2024 does not. So the AGI check would have refused every
staging file R2 accepts, though no such null can change the AGI R2 stores.

The check now walks the closure's edges from AGI and stops at a deduction
in YEAR_LISTED_DEDUCTIONS that the check's year does not list. The
engine-workflow test checks the year rule on the engine (2020 lists the
deduction and it is 300 for a filer giving 1,000 in cash; in R2's year it
is not listed and is 0) and that no stage-filled column is an AGI input
then. Its AGI expectations, computed on 2.2.1, hold on 2.145.3.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…'s staging

ACS staging audits the nulls of every input the installed policyengine-us
defines, so its summary holds only for that engine. It now records the
policyengine-us and policyengine-core it ran on (engine_versions), and,
under either location rule, the donor base's recorded location rule
(base.location). The ACS local release refuses, at the start of
materialize and before it hashes or loads the staging H5, a summary that
records another policyengine-us or none: on 2.145.3 a staging made on
2.2.1 would otherwise fail in the fill step hours in, or at package for
the retired mortgage legs. The reviewed-fill pre-check reports the same
refusal through R2's function.

The County Files staging may run the legacy rule on the block_v1 national
donor, whose tract, district and county are the assigned triple the legacy
pool keeps. A new pool test checks that such a donor also keeps its block
and the geography derived from it, and that ACS rows get none.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Certification writes a US national build's manifests in the tagged shape
and rewrites them into its tier's build folder (microcosm#1570, #1585 item
11). The new test writes such a release manifest, rewrites it with
rewrite_release_dir into microcosm-us-2024-national and into
microcosm-us-2024-evidence, and checks that staging's
--donor-release-manifest accepts it, that the reference it records reads
from the build's folder at main, and that the local-area release
contract's donor check accepts that reference. Test only: the County
Files staging needs no code change to name the certified donor.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A county whose households all store an AGI of 0 gets an empty county AGI
row, which attach_surface refuses after the materialize engine pass, about
three hours into a county build. The proof of concept dropped such rows
with --county-drop-empty-soi-rows (#1660), which #1661 says the final
County Files build must not do: every county needs real support instead.

On a county SOI surface (state_county, county geography, minimum support
on), materialize now computes each household's AGI before the support
step, with the engine pass's own input projection and reviewed-null fill,
one 100,000-household chunk at a time (fill_reviewed_nulls gains quiet=,
since a chunk's null counts never match the register's). In 2024 the AGI
reads no county column, so the moves leave it unchanged.
plan_minimum_support takes the AGI:

- the first pass ranks households with a positive AGI first;
- a second pass moves K same-PUMA households with a positive AGI into each
  county that has supporting households but none with a nonzero AGI, with
  the first pass's eligibility and ranking (moves carry
  "reason": "soi_support");
- no move leaves a donor county without a household whose AGI is nonzero.

check_support refuses a county still without one before the engine pass.
Without the AGI, nothing differs from before. The AGI pre-check applies
the same moves, and an engine-workflow test checks that R2's AGI pass gives
the value the state SOI AGI row stores.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
finalize_reviewed_limitations writes five inherited limitations about the
donor: the SSI aged-band collapse (#507), the miscellaneous income loss
side (#393), the Build O tip-return count deficit, the 57,240-household
certified selection and the Social Security erasure (#1178, for every
donor, since DONORS_WITHOUT_SOCIAL_SECURITY_ERASURE is empty). Each
describes the Build O lineage. The final County Files build stages from
the next US national build, a dense build published into a build folder of
microcosm-us-2024-national, so its release would have published those five
as its own.

REVIEWED_DONOR_LINEAGES (empty) maps a donor build outside that lineage to
the inherited limitations a review of its own evidence found to hold; the
others leave its releases' register. Materialize, before it hashes or loads
the staging H5, and finalize refuse a staging whose donor is a build of
microcosm-us-2024-national or microcosm-us-2024-evidence with no entry.
Older donors keep all five, unchanged.

The national build's entry is data: its build ID, and the rulings on the
five from that build's evidence.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
docs/us-county-files-final-build.md gives the operator the final County
Files build on the next US national build: host and inputs with their pins,
the two entries the checkout must hold first (the re-reviewed register and
the donor's REVIEWED_DONOR_LINEAGES entry), then one command per step: R1
with --donor-release-manifest and the legacy rule on the block_v1 donor,
the two pre-R2 checks, R2 stage by stage with the county rung's flags and
no drop flag, the publisher's --preflight-only, and the projection. It also
gives the files-only rehearsal on the built national H5 before
certification ends, what to send and when to stop. The county rung doc
points to it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
R2 binds its commit at calibrate and package refuses another, so a files-
only rehearsal at a commit without the re-reviewed register ends at
finalize's engine-version refusal, after gate_summary.json is written.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
#1676 moved from d596fcb to its final head, ba41043: the five
review fixes, the export reference, the shellcheck fix, and main's
#1666 and #1682. The County Files build runs on the national build's
code, so this line carries it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…1675)

The static consumer index interprets a module-level helper function in
policyengine-us's variables/ once per call context, under the helper's
own name, so variable_dependency_closure stopped where a formula called
one: 127 helper names on policyengine-us 2.145.3. Free and reduced-price
school meals, for one, read their tiers through school_meal_daily_rate.

The index now also records each such read under every variable whose
formula reaches that call context, directly or through other helpers
(helper_consumers), and PolicyEngineUSVariableMetadataIndex(
follow_helpers=True) walks them.

The default view is unchanged: on 2.145.3 its receipts and definitions
equal the previous module's, value for value. As the default, the new
view would move the pool's pinned SSI dependency contract (689 input
leaves would become 1,057) and the US engine ABI lock built from it, both
on #1676's line. So it is opt-in.

The reviewed-fill register's engine-tier walk uses it. Its walk tests
still skip until the register is re-reviewed on 2.145.3.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The AGI check decides which null stage-filled columns it may hold back
from the AGI with AGI's static closure. Through helpers the closure finds
two inputs the gap hid: the self-employed health insurance deduction's
Form 7206 inputs, read only in form_7206_line_13.

It also reaches household_net_income, and through it every benefit and
the take-up flags R2's stages fill. The path runs through the behavioral
responses' get_behavioral_response_measurements helper. An engine pass
without a reform never reads through those responses, so the walk stops
at the four behavioral-response variables too (NO_REFORM_UNREAD). An
engine test checks that the simulation then has no baseline, that the
responses are 0, and that the elasticity effects are never computed.

On 2.145.3 the check reads 219 inputs: the 217 it read before plus the
two. No stage-filled column is among them.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Fix the two should-fix findings and the three code and docs nits of
the independent review of 24a417c, reword the PR body for the
fourth, and add tests for the three faults it said the tests could
miss.

- Should-fix: a package run could show another finalize run's waiver,
  since the shadow read the checkpoint's latest finalize record
  whichever gate report package selected. Finalize's waiver record now
  holds the waivers and the SHA-256 of the gate report that run wrote,
  or null when the report at that path did not change during the run
  or the shadow could not read it. The shadow attaches the record only
  when that digest matches the selected report's; otherwise it records
  each ESI entry's waiver as "unknown: " with both digests. A record
  without the digest, as 24a417c wrote, counts as unknown too.
  The comparison still reads the latest finalize run's observations,
  whichever report package selects.
- Should-fix: a waiver record the shadow could not read or parse
  stopped the rebuild, and the comparison that stage entry had deleted
  never came back. Now, when a record is not valid JSON or not a
  mapping, or holds waivers that are not lists of strings, a digest
  that is not SHA-256 hex or an entry its stage does not waive, the
  shadow gives that stage's entries an "unknown: " waiver naming the
  file and the error, logs a warning and rebuilds the comparison.
- Nit: on a mixed frame, finite weights could sum past the largest
  float, and positive infinity passed the "not x > 0" checks. The new
  _refuse_overflowing_mixed_aggregates refuses the frame and names
  each weighted sum that overflows, and both gates record the refusal
  as red. It checks the household mass of either kind of row and of
  both together, the employer premium of either kind, and the CPS
  rows' MEPS-IC shares and the weight of their employed policyholders
  with a positive share. Only _transferred_row_summary and
  _refuse_unusable_source_anchor_evidence call it; the masses keep
  their scale and the all-CPS expressions do not change.
- Nits: the ESI doc's L0/refit note points to the gates table for the
  call sites; the doc makes the per-mass refusal conditional on
  transferred household mass; the doc and the changelog fragment state
  package's default refusal beside its waiver exception.
- Faults the tests could miss: package cases for a red verdict that
  lacks enforced or sets it to null or 0; static tests that Route A's
  tools and the stage's own gate call pass no allow_transferred_rows
  and the shadow bindings never name it; and assertions of the
  diagnostic for a zero CPS all-policyholder share.

Add four shadow tests (ten cases), a record assertion in the
shadow-armed finalize test, three package cases, four pool-anchor
tests (three overflow, one zero policyholder share) and an assertion
in a fifth, and three static call-site cases in the Route A
differential.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>

@vahid-ahmadi vahid-ahmadi left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, María. This is a big PR (+13.4k lines), so I kept to the parts that change what R2 computes: the EITC and WIC take-up draws, the AGI pre-check's year closure, the SOI support moves, and the staging engine refusal. I didn't review the ESI premium carry (#1670 has its own review), the helper index beyond its use in the AGI check, or the runbook line by line. Nothing I found blocks. There's one design point on the first support pass, and two notes.

Checked at 3daa520 (stacked on #1676's final head ba41043, 34 commits)

  • EITC on ACS tax units. It reuses the national contract unchanged: _eitc_child_count_by_tax_unit, _seed_program and the contract's rates by number of children. It fills only missing ACS cells, keeps donor values, and adds the EITC cells to the assignment digest. The gate grades the ACS weighted share against the contract's (0.60, 0.92) band and requires the flag complete and varying on both spines.
  • WIC. It runs the national with_us_wic_claim_input on the ACS-only frame after the transfer, keyed by source identity. It refuses an already-filled column or a row from another source_year, and require_complete_us_wic_take_up refuses a null or non-boolean cell at each later step. Donor decisions are never redrawn.
  • AGI year closure. In policyengine-us, charitable_contributions_ald returns 0 at the Python level before reading anything, in any year whose gov.irs.ald.deductions doesn't list it. The parameter lists it in 2020 only. So stopping the walk there in 2024 is exact. Missing other year-gated deductions (e.g. domestic_production_ald before 2018) only makes the check stricter. Stopping at the four behavioural-response variables is right for a pass with no reform, and the engine test covers it.
  • Staging engine refusal. _require_staging_engine compares the recorded and installed policyengine-us, and refuses a summary that records none. That's the right check for its purpose, since the null audit depends on the variables the engine defines.
  • Tests. Four engine-free files give 228 passed locally: county AGI support, WIC take-up, take-up and county production. I didn't run the engine tiers. CI hasn't run because the PR targets #1676's branch.

1. The first support pass now prefers positive-AGI households for every unsupported county, not just the ones that need AGI support. plan_minimum_support sorts first-pass candidates by (not positive, rank, position) whenever household_agi is given (tools/us_acs_local_county_surface.py; test_first_pass_ranks_households_with_agi_first).

  • With the default K = 3, an unsupported county's whole support becomes three filers with positive AGI, as long as its PUMAs have them. Households with zero or negative AGI, such as non-filers, people living only on Social Security or SSI, or losses, are pushed to the back.

  • County calibration then reweights only those three households. So in those counties every zero-income measure the county targets touch (SNAP and Medicaid among them, through income) rests on filers.

  • The second pass already guarantees AGI support where it's missing. Two cheaper alternatives:

    • require a positive AGI for one of the K first-pass households and leave the other K − 1 to the random rank;
    • drop the preference from the first pass and let the second pass add households only where needed.

    Either keeps support representative of the PUMA. If the preference stays, it would help if the receipt reported the share of first-pass movers with positive AGI against their PUMAs' share, so the skew is visible in the final build's evidence.

2. Four tests fail with policyengine-us 2.145.3 installed. test_us_pool_input_consumers.py encodes 2.2.1's dependency expectations (the two retired mortgage items, taxable_pension_income, domestic_production_ald). It passes in CI only because CI runs it without an engine. The lane now runs on 2.145.3, so those expectations describe an engine nothing uses. Worth updating here or on #1676's line, or listing in #1720 so the file can't silently pin the old graph.

3. Before the final build, as you list.

  • The reviewed-fill register's engine-contract walk skips 182 tests until reviewed_against is 2.145.3. The re-review commit is what turns that coverage on.
  • The donor's REVIEWED_DONOR_LINEAGES entry now gates calibrate rather than materialize, and finalize checks again. That order makes sense.

Review drafted with AI assistance and checked against the code at 3daa5201920a269d2fef83689285b0aef09d059c.

juaristi22 and others added 2 commits November 24, 2026 16:19
…45.3 (#1675)

reviewed_against is 2.145.3. Each entry's consumers are every means-tested
program the engine's dependency walk reaches, through module-level helpers too
(PolicyEngineUSVariableMetadataIndex(follow_helpers=True)), with one note per
program; the engine-tier test checks every list against the walk. Pairs that a
release pass never moves (the 2020-only charitable deduction, the contributed
COLA means test, the no-reform behavioral responses) are listed as harmless.

- second_home_mortgage_interest leaves the register (PolicyEngine/policyengine-us#9605),
  and so does takes_up_eitc: R2's take-up stage draws it, and it joins
  NEVER_DEFAULT_FILLED and the pre-check's stage-filled list.
- Five entries for the next national donor's columns: the four SCF student-debt
  inputs (no consumers) and weeks_worked (blank under 16; harmless).
- California CARE, FERA, EZ-SAVE and CVRP and Missouri SSP pay nothing on these
  files. educational_assistance and is_military -> state benefits, which rested
  on them alone, are harmless in their own notes; other notes drop those names.
  The PTC's Medicaid bar is named where it sits on 2.145.3
  (is_aca_marketplace_enrollee). pre_subsidy_rent -> the PTC is mixed, like the
  other forced, nil PTC verdict.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Review of #1719: the first support pass ranked households with a positive
AGI first, so an unsupported county's K movers all had a positive AGI
wherever its PUMAs had such households, and county calibration reweighted
only those.

The first pass now takes the K eligible households first in rank order, as
it does without the AGI. Only when none of them has a positive AGI does the
K-th give way to the next eligible household in rank order that has one (its
move carries "reason": "positive_agi"). The county's AGI row then has
support, and the other picks keep their PUMA's AGI mix. The second pass is
unchanged.

minimum_support.soi_support.first_pass reports the first-pass movers' share
with a positive AGI beside the share among their PUMAs' eligible households,
and names the counties where the swap happened.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@juaristi22

Copy link
Copy Markdown
Collaborator Author

Thanks, Vahid.

1. First support pass: changed in 1f833383a, along the lines of your first alternative.

  • The first pass now takes the K eligible households first in rank order, as it does without the AGI.
  • Only when none of them has a positive AGI does the K-th give way to the next eligible household in rank order that has one. That move carries "reason": "positive_agi".
  • So an unsupported county gets its AGI support without extra households, and the other picks keep their PUMA's mix. The second pass is unchanged.
  • The receipt now has minimum_support.soi_support.first_pass. It gives the first-pass movers' share with a positive AGI, the share among their PUMAs' eligible households (averaged over the movers), and the counties where the swap happened.
  • Three engine-free tests replace test_first_pass_ranks_households_with_agi_first:
    • the rank's picks stand when one of them has an AGI;
    • the last pick is swapped when none has one;
    • nothing is swapped when no household with an AGI can move, and the second pass then names the county.
  • The three county support test files give 215 passed and 1 skipped.

2. test_us_pool_input_consumers.py on 2.145.3. It's listed in #1720, under "Adjacent follow-ups". The file tests #1676's pool code, and CI runs it without an engine, so I've left it out of this PR.

3. Before the final build. The register re-review on 2.145.3 is in 38524a2b3, and the engine-contract walk now runs: 193 tests pass. The donor's lineage entry goes in before calibrate, once the new national file is published.

🤖 Generated with Claude Code

@MaxGhenis

Copy link
Copy Markdown
Contributor

A heads-up on the SIPP 2023 donor downloads: #1753 moves them on main to the data repository's 1.115.5 tag, which serves the same pu2023.csv and pu2023_slim.csv bytes. This branch still downloads at 21280dca until it takes main.

That PR edits the attested SIPP readers, so it moves the seed map, seed protocol, US spec_sha256, minimal-spec loader golden and us-f0-coverage.json. The next re-pin here picks those up. The recorded revision constants and the source records stay the same.

juaristi22 added a commit that referenced this pull request Nov 26, 2026
C1 of the shared-code work in microcosm#1728. No target changes.

- The ledger filter rules move verbatim from
  tools/build_us_fiscal_refresh_release.py to
  microcosm.build.us_runtime.ledger_filter_rules: 25 names, 446 lines. They
  say how the national irs_soi slice reads a spec's AGI band, filing status
  and EITC child count, and which restated ledger_filter_* keys a spec may
  carry. Each definition is byte-identical. The tool imports all 25 names
  back (its materializer and filter guard call them, and tests and
  tools/bakeoff_us_support_mix.py read them there). It drops the two FSA
  balance-bound imports that only the moved code used, and keeps the two
  age-stamp keys, which a test reads through the tool.
- tools/us_acs_local_cd_surface.py reads the rules from the package, so it
  no longer imports the national tool.
- tools/build_us_acs_local_release.py compiles the registry in one function:
  _compiled_fiscal_registry takes the district crosswalk that
  state_admin_surface also gives the state_cd rule.
- test_us_spine_blindness.py classifies the new module.
- Two tests in test_us_fiscal_refresh_builder.py changed a rule on a freshly
  loaded tool and relied on that copy being thrown away. The rules now live in
  one package module that every load shares, so both use monkeypatch: one
  removes the age rule for its own run only, and one empties the refused EITC
  child-count sides where the comparison reads them.

Proof: test_us_acs_local_surface_bytes.py (the C0 pins) passes unchanged on
the pinned feed and ladder for state, totals, full and state_cd, and the
pinned surfaces of test_us_target_sets.py pass. In all, 3,714 tests
in the 47 files that load the changed tools or hold the module and binding
registers pass locally (8 skipped), with the pinned feed and ladder set.

Left for later commits, as planned: the import cycle between the district
and county modules goes when C3 moves the population rows, and the county
code's use of the argparse namespace moves with the county rung (C5),
because #1719 changes check_support.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
juaristi22 and others added 6 commits November 30, 2026 16:57
Takes #1676 at dc7917f: the child-support channel floor (12693b9,
the national build's commit), main through 0278db1 (#1660 merged,
#1696's thread settings, #1737's final-export carry and the rest), the
policyengine-us 2.145.3 CI fixes and the AGI pre-check's year cut read
from the engine.

Resolutions:
- AGI pre-check: #1676's probe decides which formulas read nothing in
  the check's year. Its population now also stands in for an engine pass
  without a reform, whose simulation has no baseline, so the behavioral
  responses read nothing there; and the closure follows the engine's
  helper functions (#1719's index view). #1719's named lists
  (YEAR_LISTED_DEDUCTIONS, NO_REFORM_UNREAD) go. On policyengine-us
  2.145.3 the 2024 inputs are 218, none of them a column an R2 stage
  fills; in 2020 the charitable deduction still reads them. The report
  records the input count (agi_engine_inputs) in place of
  agi_closure_stops_at. Tests: #1676's probe tests, #1719's engine
  evidence restated for the probe, and an engine-free test of the
  no-reform stand-in. #1719's year-closure fragment goes: #1676's covers
  the same fix.
- Reviewed-fill register and the release-tool test that tracks it:
  #1719's re-review on 2.145.3, which carries #1660's strike_benefits
  entry re-reviewed.
- #1660's files that #1719 had cherry-picked (the two pre-checks, their
  tests and changelog fragment): merged three-way against the picked
  commit f8b1039, so both sides' later changes stay.
- R1, its Modal plan and their tests: both sides' options, #1719's ESI
  waiver and #1660's proof-of-concept default-donor allowance, each
  documented and owned by the Modal runner.
- Release tool: Path is imported at the top for the thread setting;
  MappingProxyType stays for REVIEWED_DONOR_LINEAGES.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
c0b792a made materialize refuse a staging summary that records no
engine, and stubbed the check in the county-surface test, but not here.
This fixture's summary records no engine, as it records none of the
other staging stages the test already stubs, so its 16 cases stopped at
the refusal. The refusal has its own tests in the release-tool file.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
populace-us-2024-3b3de63-12693b9db03d-20261127T193416Z, the national
built at 12693b9, is the first donor outside the Build O lineage. On
its own evidence (30 Nov 2026):
- aged SSI: 2,384,997 recipients aged 65 and over against SSA's
  2,382,142, so the #507 collapse drops;
- miscellaneous income: 1.60M weighted tax units carry a net loss, 5.0
  times SOI's 318,839 loss returns, so #393's distortion holds;
- tip returns: 1.38M weighted tax units against SOI's 6.04M (-77.2%),
  with the amount calibrated, so the deficit holds;
- sparse selection: a dense donor of 345,942 households, so it drops;
- Social Security: 83.2% of people aged 65 and over receive it, by
  #1186's own measure (77.9% CPS-reported, 55.9% on the erasing
  default), and #1186 is in the build commit, so the erasure drops and
  the build joins DONORS_WITHOUT_SOCIAL_SECURITY_ERASURE.

The Build O texts describe that lineage with its own figures. An entry
now maps each limitation that holds to the reason the donor's evidence
gives, and finalize writes that reason in place of the Build O text.
The runbook says both data entries are in for this donor.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Main moved build_us_fiscal_refresh_release's private
_assert_group_entities_nest_in_households to
household_batches.assert_group_entities_nest_in_households. The merge of
#1676 switched materialize_chunked to the shared check but kept
_household_agi's old call, so every county SOI run with more households
than one AGI chunk would stop with an AttributeError at R2's AGI pass,
after the staging load and the SSI/Medicaid pre-pass. The engine-tier
test test_r2s_own_agi_pass_stores_the_soi_rows_agi and the adversarial
review of the merge both found it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The runbook's figures came from the 17 Nov proof of concept, whose donor
had 57,240 households. The published national built at 12693b9 is
dense, with 345,942, so the pooled staging has about 18% more households
and R1's QRF fits train on about six times as many donor households.
The runbook now says the proof of concept's figures do not bound R1,
gives the steps' times as lower bounds, and asks for about 100 GB of
free disk (staging, calibrated file and package copy) instead of 60.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
#1676 merged into main as 0ba5e85, so this PR now targets main. The
merge brings main's commits since #1676's last merge of it (0278db1):
the build-folder switch and release publication changes, microcosm-data's
registry, the spec-engine and transport tests, and README. No conflicts.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@juaristi22
juaristi22 changed the base branch from us-engine-refresh-route-a to main November 30, 2026 17:49
juaristi22 and others added 2 commits November 30, 2026 17:50
The test workflow runs on pull requests into main only, and #1719 was
pushed while it still targeted #1676's branch, so no run started when it
was retargeted after #1676 merged.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…#1661)

From the second review of #1719:
- The runbook's R2 block kept the command and its flags in shell
  variables and relied on bash splitting them into words. zsh, the macOS
  default shell, does not, so the pasted block failed at once there. It
  now uses shell functions and runs the same in both shells: with stub
  commands, bash and zsh pass identical arguments, and each stage's
  arguments parse with R2's parser.
- R1's ACS archive cache (--inputs-dir) had no place. Anywhere in the
  checkout but its git-ignored inputs/ folder makes the tree dirty, which
  R2's clean-tree checks and package refuse. The runbook now names
  $ACS_INPUTS and keeps it outside the checkout.
- Every release's refresh note gave the microcosm#508 SSI fix as its
  example of the next donor, which no longer fits the reviewed national.
  It now names the next certified national release.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@juaristi22

Copy link
Copy Markdown
Collaborator Author

Hi @PavelMakarchuk, could you run the US County Files build (the ACS local-area release) on the national build you just published? Please run it from a checkout of 51969a367c2de84cd94f9940883612e2771fb2f6, this PR's head, following docs/us-county-files-final-build.md at that commit, sections 1 to 4. It needs a 128 GiB host with nothing heavy beside it, and about 100 GB of free disk.

Inputs.

  • The donor: the national you published. Take microcosm_us_2024.h5 and release_manifest.json from releases/microcosm-us-2024-national/populace-us-2024-3b3de63-12693b9db03d-20261127T193416Z/ in policyengine/populace-us.
  • The PUMA ladder and the county facts: under inputs/ in policyengine/populace-us-staging.
  • The feed: the national build's own (41b2fb2).
  • The ACS archive cache: any folder outside the checkout ($ACS_INPUTS).
  • Section 2 has every path and pin.

Steps.

  1. R1, the staging (4 hours or more): the command in step 1. It checks the donor in its first minutes. If it refuses, stop and send the log. This is the stage with the least certain run time and memory: its QRF fits train on six times as many donor households as the proof of concept's, so expect it to go past the proof of concept's 4 hours and 48 GiB.
  2. The two checks (minutes): both must exit 0. If either doesn't, stop and send both reports.
  3. R2, the county release (about 5 to 5.5 hours; materialize peaks around 70 GiB): the five stages in step 3, one per process, from the clean checkout.
  4. The publisher's preflight (seconds): it must print a valid result. It publishes nothing.

Then: send us the evidence with section 6's command. It packs logs and JSON records only, never the H5s. If anything on section 6's stop list happens, stop, keep every file, and send the evidence.

The times are estimates: the 17 Nov proof of concept's figures, scaled to this donor's six times as many households. Thank you!

juaristi22 added a commit that referenced this pull request Dec 1, 2026
#1719's branch moved 870 commits (main with #1676, and the County Files
changes). Three files conflicted:

- spec_engine/inventory_coverage.py: both comment lists kept. The seed map
  and seed protocol digests are re-pinned for the merged tree with
  tools/repin_us_spec_engine_contracts.py and tools/spec_engine_coverage.py
  (two passes each, then --check), which also move the US spec digest in two
  tests and the F0 coverage report. No draw changes.
- us_runtime/voluntary_filing.py: __all__ keeps this lane's
  impute_us_voluntary_filing_from_tables and drops
  load_sipp_2023_voluntary_filing_donor, which the base replaced with the
  shared SIPP December read (#1686).
- tools/build_us_acs_local_release.py: the SSI and Medicaid pre-pass keeps
  this lane's _prepass_view_contract and takes the base's
  refuse_population_aggregates=True on every view.

Two breaks that git did not flag are fixed here:

- The base removed the release tool's
  _assert_group_entities_nest_in_households and
  _assert_medicaid_claiming_tax_units_local; with the refusal on, the engine
  pass refuses those cases itself. _prepass_view_contract drops its own
  nesting check and its hh_chunk argument, and the ACA pre-pass calls
  _aca_source_tax_unit_table_batched with the same refusal.
- acs_local_voluntary_filing read its donor through the removed
  load_sipp_2023_voluntary_filing_donor. It now reads the file with
  read_sipp_december_person_rows and builds the donor with
  build_sipp_2023_voluntary_filing_donor, the base's route to the same
  bytes.

Tests on this tree: engine-free (32 files, no engine installed) 2017 passed,
6 skipped, 2 failed; engine tier (7 files) 183 passed. The 2 failures are
older than this merge: the pre-pass contract imports policyengine-us when
no cell needs it. The next commit fixes that.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
juaristi22 and others added 2 commits December 2, 2026 10:55
Main has moved on R2's target selection (declared target sets,
microcosm#1728) and reads only part of the calibrated H5 in qa, finalize
and package (606c442).

Resolutions:
- test_us_acs_local_release_tool.py: both sides' new tests, this PR's
  ESI premium verdicts and main's partial-read tests.
- R2's finalize columns: main's list (_finalize_columns) has only what
  main's checks read, and a stored column missing from it raises
  KeyError, or reads as absent, at finalize, hours into a build. This
  PR's checks read more: the ESI employer-premium gates (microcosm#454)
  and the EITC and WIC take-up flags (microcosm#1675, #1154), one of them
  on tax units, which the list did not name at all. It now lists the
  tax-unit origin tag and EITC flag, the WIC flag, and the ESI gates'
  columns, exported from acs_local_esi_premiums as
  ACS_LOCAL_ESI_PREMIUM_GATE_PERSON_COLUMNS and _HOUSEHOLD_COLUMNS.
- Tests: main's comparison fixture gains those flags and the tax-unit
  tag, and a new test runs both ESI gates on the columns finalize loads
  and compares their verdicts with the whole file's; dropping any of 18
  of the 19 stored ESI columns changes or refuses it, and the nineteenth
  is an id column that is always loaded.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Main streams the calibrated H5's write in R2 (#1822): the person table is
no longer held whole, and calibrate loads a listed set of staging
columns.

Resolutions:
- R2's calibrate write: main's streamed call, with this PR's note that on
  policyengine-us 2.145.3 weeks_worked is an input, so the projection
  keeps it.
- fill_reviewed_nulls: main moved its end into
  _finish_reviewed_null_fills; this PR's quiet= (the AGI pass fills one
  chunk at a time, whose null counts never match the register's) now
  passes through it.
- The staged take-up step reads only listed person columns at calibrate:
  main's test of the real step, on this PR's take-up fixtures with the
  EITC and WIC columns, gives the same result on the narrow load.
- No removed or renamed function is referenced on the merged build path
  (static cross-reference check).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants