Repository navigation
Stage more ACS inputs and draw ACA take-up on ACS tax units (#1720) - #1754
juaristi22 wants to merge 26 commits into
Conversation
acs_local_aca_take_up_targets reads the fiscal lane's ACA state tables (_aca_source_target_tables) from the registry that the SSI and Medicaid targets already compile: CMS APTC recipients, the SOI premium tax credit returns and amounts, and the bronze table where the feed has one. Both targets functions now take that compile as compiled=, so materialize can compile the feed once for both stages. Like the fiscal lane, the stage needs the APTC-recipient table. On the pinned feed (41b2fb2) the SOI tables are exactly the 102 premium tax credit rows of R2's state surface, and there is no bronze table, so the ACS stage stops after the ratio's clip as the national stage does. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…1720) is_separated and is_surviving_spouse follow the donor's relationship_inputs rule on the ACS rows' A_MARITL (loader-mapped from MAR); is_military is ACS MIL == 1; the four POCCU2 occupation flags follow the donor's org_wages rule on the native detailed_occupation_recode. Both donor rules become shared functions that the donor stages call too. The stage runs on the ACS-only frame before any transfer, fills only missing cells and records a receipt (with the agreement of is_military against POCCU2 52 and ESR 4 or 5); it grades nothing. The seven columns leave the reviewed-fill register (63 -> 56 entries) and join R2's NEVER_DEFAULT_FILLED. R2 gains a reviewed limitation for the staged inputs. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…le (#1720) Staging runs attribute_us_se_health_premiums, unchanged, on the ACS-only frame after the shared transfer (whose post-transfer structure settles the self-employment components it reads) and before pooling, so ACS rows carry is_self_employed and health_insurance_premiums instead of False and 0. The flag is positive Schedule C income, the donor's rule; the receipt records its agreement with ACS COW 6 or 7 and the premiums the Medicare proxy and employer coverage withheld. SEMP's blank under 15 reads as 0. Only missing cells are filled, and nothing is graded. The two columns leave the reviewed-fill register (56 -> 54) and join R2's NEVER_DEFAULT_FILLED; R2's staged-inputs limitation describes them. With this stage the ACS rows' MAGI is final before R2 assigns Medicaid take-up (the national order is microcosm#1689). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
#1720) A lane-own QRF pass (acs_local_weeks_deferrals) on the donor's ASEC observation role, the pattern of the local income pass: weeks_unemployed (measured LKWEEKS) and the traditional and Roth 401(k) and Roth IRA deferrals (RETCB_VAL split by the archived shares). It runs right after the shared transfer, because the weeks family reads the transferred unemployment_compensation through a predictor extension of this call alone; every earlier fit has drawn by then and each family seeds from its own name. A test proves every other column, the earlier provenance and the earlier fits are identical with and without the pass. The donor's own post-processing becomes two shared functions that its PUF-half stages call too: weeks clipped, rounded and 0 without UC; deferrals clipped at 0 and the 401(k) deferrals 0 without wages. The pass refuses any column the shared plan or the income pass draws, fills only missing cells and grades nothing. The four columns leave the register (54 -> 50) and join R2's NEVER_DEFAULT_FILLED; the staged-inputs limitation describes them. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
ACS tax units now carry would_file_taxes_voluntarily from the donor release's own model (voluntary_filing: the weighted QRF on the pinned full SIPP 2023 file's December filing answers), instead of False. The donor function gets a table-level entry point, impute_us_voluntary_filing_from_tables, which impute_us_voluntary_filing now calls; donor values are unchanged. The stage (acs_local_voluntary_filing) builds the receiver from a view of the ACS tax units (unit wages with WAGP's blank under 15 read as none, the head's age and sex, JOINT filing status, the household's persons under 18), runs after the SSI disability stage on the pooled frame and fills only missing ACS cells. It reads the SIPP file staging already resolves for the SSI model, so nothing is downloaded twice. It records a receipt and grades nothing; only its stage function reads origin tags (pinned in the spine-blindness test). The column leaves the register (50 -> 49), with its EITC and PTC notes, and joins R2's NEVER_DEFAULT_FILLED. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The shared transfer draws takes_up_housing_assistance_if_eligible for every ACS SPM unit, group quarters included (TYPEHUGQ 2/3), which have no housing unit. A lane-own step (acs_local_group_quarters_housing) sets the flag False there on the ACS-only frame after the shared transfer and before pooling; housing units keep their draw. This differs from #975's proposed design (a structural policy inside acs_transfer), which would move the shared execution contract, the attested imputation.yaml entry and the pool lane's pins; the shared plan is unchanged. The step refuses nothing beyond a frame without the columns it reads, and records a receipt. The spm_unit_tenure_type register entry stays (the RENTER fill stays); its housing-assistance note becomes harmless, because the engine pays hud_hap times the take-up flag, False there. R2's texts (acs_engine_free_default_fills and the staged-inputs limitation, whose treatment now names the receipts and the override) and the take-up module's docstring describe the step. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ls (#1720) New us_runtime/acs_local_aca_take_up.py. It runs the fiscal lane's own aca_marketplace_inputs manifest stage on the ACS tax units, through run_source_stage and the US handlers, against what the donor rows leave of each state count: - an engine pre-pass (a callable the release tool supplies) on the donor households with their stored flags, then on the ACS households, where a missing take-up cell reads True and a missing ratio 1.0. On policyengine-us 2.145.3 aca_ptc is gated on filing and a unit taking up a positive credit counts as filing, so with the flag True it is the credit before take-up, as the fiscal lane reads it; - residual tables: each state count minus the donor rows' contribution, summed on the weight column of the stage operation that reads the table, floored at zero; shortfalls and donor excesses are recorded; - no anchor: the ACS asks no subsidized Marketplace coverage item, the fiscal lane's rule when that anchor is absent; a stored ACS cell is kept; - draws on the donor stage's stream, keyed on acs_2024_1yr:SERIALNO and the unit's lowest SPORDER; - only missing ACS cells are filled; a receipt (per table and state: count, donor, residual, ACS capacity and delivery, pooled, people per return), an assignment table with a digest, and a function that applies a recorded assignment; - acs_local_aca_take_up_signal_gate grades the flags and the receipt. The lane will only report it. Where both SOI tables exist, the stage's joint step decides the takers: it fills each state's residual return count with the units whose credit per return is closest to the residual average, the draw only breaking ties, as on the donor. The CMS people are reported, not met (#168). The module joins the spine-blindness allowlists; only _acs_masks and the gate read origin tags. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
do_materialize compiles the feed once for the SSI/Medicaid and the ACA counts, then runs the ACA stage right after the SSI and Medicaid assignment (Medicaid eligibility bars the credit and reads SSI receipt) and before the county AGI pass and the engine pass. The pre-pass is _acs_engine_aca_tax_units: the same in-place view contract as the SSI and Medicaid pre-pass (now _prepass_view_contract), then the fiscal lane's batched _aca_source_tax_unit_table at --hh-chunk, one chunk's simulation at a time. The stage writes acs_local_aca_take_up.npz (tax unit, flag, ratio) to the checkpoint and its receipt to run_identity.json under acs_local_aca_take_up. Calibrate requires the recorded assignment, and the consumer export applies it and refuses a mismatch, the lane's convention for every drawn column. The grade is report-only (María's rule): acs_local_aca_take_up_signal is recorded in the receipt and as the diagnostic shadow entry us_local_aca_take_up_materialize; a failed or broken grade is logged and materialize goes on, and the recorded-assignment check does not need it to pass. The us_local scope's pinned digests move with the new entry. Texts: acs_take_up_engine_defaults no longer lists ACA and points to #1720; a new reviewed limitation acs_local_aca_take_up describes the method and its limits; the take-up module's docstring follows. Tests: the wiring with stubbed stages, the recorded assignment's refusals and round trip, a grade that fails or breaks without stopping the stage, and an engine-contract test that runs the stage with policyengine-us on a small staged lane frame (two batch sizes, same donor contributions). test_no_county_materialization_matches_pre_county_surface fails on the base too: its staging summary records no engine, so _require_staging_engine stops materialize before this stage. It passes with that check stubbed; the fix is left to its own change. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…1720) Both tax-unit columns join _NEVER_DEFAULT_FILLED_REASONS (the engine defaults are universal premium tax credit take-up and the benchmark plan for every taker; run the ACS local ACA take-up stage first) and the pre-check's stage_filled_never_default, and their two entries leave the reviewed-fill register (63 -> 61). The register refuses an entry for a never-default column, so these land together, in this commit rather than in the wiring commit. The SSI and Medicaid pre-pass runs before the ACA stage, so its ACS view still carries null ACA cells, which the never-default rule would refuse. _prepass_view_contract now reads a null cell of a column a later materialize stage assigns at its engine default (True and 1.0, what the reviewed fill gave it before), so that assignment does not change. Register notes: the would_file_taxes_voluntarily -> PTC note said there was no direct effect because ACA take-up was True on every ACS unit. With take-up drawn, a non-taker's aca_ptc reads tax_unit_is_filer, so the note now names the direct path too; the verdict stays known_bias, mixed. No other note assumed universal ACA take-up. Tests: both columns are refused by the reviewed-null fill, the pre-pass reads pending cells at the engine defaults and keeps donor cells, and the release tests that used ACA take-up as their example of a reviewed known-bias fill now use the owned vehicle count. The engine-tier walk of the register and the county AGI workflow test (no stage-filled column is an AGI input) pass. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
) One line in the County Files build guide (step 3): materialize draws the ACS tax units' ACA take-up and plan ratio after the SSI and Medicaid take-up, writes acs_local_aca_take_up.npz to the checkpoint, and its grade is report-only. The pre-pass's time is not measured yet. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
#1720) A6 of PR A, approved by María on 25 Nov. The loader reads two more optional person items, HINS1 (employer or union coverage) and HINS2 (direct purchase). A lane-own step (acs_local_coverage_anchors) writes has_esi = HINS1 == 1 (the donor's NOW_GRP counterpart) over the shared transfer's draw. HINS2 == 2 sets both direct-purchase flags False; where HINS2 == 1 the draws stand unless both are False, and then one draw keyed on SERIALNO:SPORDER picks the type at the donor ASEC role's shares among direct purchasers, by age band. HIMRKS (Subsidized Marketplace Coverage) is not loaded pending a ruling. The step runs after every transfer, because a native value before the transfer would take has_esi out of its chained batch and move every other draw; a test with a real transfer proves nothing else moves. In the stage it runs before A2's premium attribution, which now reads the native has_esi (A2's docstring says so; its tests are unchanged). It records the agreement of each native value with the draw it replaces and grades nothing. No register entry changes. R2's staged-inputs limitation and the ESI premium doc describe it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
PR B stacks on PR A: the ACA pre-pass reads the inputs PR A writes on ACS rows at staging (filing status, the self-employed deduction's inputs, the deferrals in MAGI, voluntary filing). Merged at PR A's committed head; its A6 (HINS1/HINS2) was not committed yet. Conflicts, all expected: - the register: PR A removes would_file_taxes_voluntarily and PR B the two ACA entries, so all three adjacent tax-unit blocks go (63 -> 47); - the pre-check's docstring: both sentences kept; - the register-coverage test: 37 columns of release 767312d are now filled natively, 1 is retired and 41 are registered; - the spine-blindness allowlist: both new modules kept. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The Marketplace-versus-other choice among ACS direct purchasers (HINS2 == 1) moves into choose_acs_direct_purchase_types: the transfer's draws stand where either flag is True, else one keyed draw at the donor ASEC role's type shares by age band. Its results are unchanged. A ruling on HIMRKS (Subsidized Marketplace Coverage, not loaded) would change this function and its tests, plus one loader name, and nothing else in the stage. The receipt's direct-purchase part now nests the choice's own record under "choice", with its source named (ACS_DIRECT_PURCHASE_CHOICE_SOURCE). A test drives the function alone. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A6 writes the ACS rows' has_esi from HINS1 and bounds the two direct-purchase flags with HINS2, so the ACA stage's eligible pool rests on measured employer coverage. One conflict: the two neighbouring imports in R2 (acs_local_aca_take_up, acs_local_coverage_anchors); both stay. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The texts said the ACS asks no subsidized Marketplace coverage item. It does: the 2024 PUMS has HIMRKS (direct purchase with or without a premium subsidy), which staging does not load; loading it is an open ruling. So the anchor rule stands, for that reason: no ACS unit is anchored, the fiscal lane's rule when the item is absent. And since PR A's A6 the eligible pool reads employer coverage from ACS HINS1 and direct-purchase flags bounded by HINS2, not only transferred draws. Module docstring and receipt text, R2's acs_local_aca_take_up limitation and its test, and the changelog fragment (which no longer counts the register's entries, since PR A also removes entries). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The anchor is now an input of the stage call, not a constant: the stage reads reported_has_subsidized_marketplace_health_coverage_at_interview, the anchor the aca_marketplace_inputs stage declares, on the ACS persons where staging writes it, and reads False where the column is absent, as the fiscal lane's _aca_source_person_table does. Staging writes none today (it does not load the PUMS subsidy item HIMRKS; that ruling is open), so nothing moves. If staging writes the column, this stage needs no new rule. A stored ACS take-up True is still an anchor, and a unit stored False still stays out. With an anchor, a state's anchored mass can exceed its residual. The stage then keeps every eligible anchor (preserve_true_anchors) and takes no other ACS unit there. The receipt records acs_anchored and anchor_excess per table and state, and the grade gives such a state the status anchor_excess: reported, not failed. The engine-contract fixture now pins has_esi False, so the test never rests on a drawn has_esi. Texts follow: the module docstring and receipt rule, R2's acs_local_aca_take_up limitation and its test, the changelog fragment. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
María ruled on 25 Nov 2026 that R1 loads HIMRKS (Subsidized Marketplace
Coverage) and uses it to split the two direct-purchase flags ("HIMRKS use
sounds good in pr A").
- The loader reads HIMRKS and its allocation flag FHIMRKSP (both in the
2024 PUMS dictionary; FHIMRKSP is in the person allocation flags) as
optional items. They stay on the ACS person rows as raw source items,
renamed at the read boundary to ACS_HIMRKS and ACS_FHIMRKSP, as ACS_MIL.
- choose_acs_direct_purchase_types: among HINS2 = 1 rows, HIMRKS code 1
(direct purchase with a premium subsidy) sets the Marketplace flag True
and keeps the drawn non-Marketplace flag. Codes 0 and 2 and a blank keep
the earlier rule. No rule reads code 0 (universe not documented) or
code 2 (on or off the Marketplace).
- HINS2 = 2 still sets both flags False, whatever HIMRKS says; the stage
counts HIMRKS 1 or 2 on such rows, and on rows with a blank HINS2.
- The receipt adds the HIMRKS codes among HINS2 = 1 rows (row counts and
weighted shares), the allocated count, the agreement of code 1 with the
drawn Marketplace flag and the conflicts. Row counts and shares only.
- No ACA anchor is written; R2's staged-inputs limitation says how code 1
is used.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
María ruled on 25 Nov 2026 that HIMRKS code 1 is the fixed point of the
ACA take-up draw on ACS rows ("Yes, with thinning"): R1 writes the anchor
column, and the release's ACA stage thins anchors above a state's
residual.
- The coverage stage writes the ACA manifest stage's own anchor column,
reported_has_subsidized_marketplace_health_coverage_at_interview, on
the ACS rows: True where HINS2 == 1 and HIMRKS == 1, Census-allocated
values included; False on every other ACS row. Its name is read from
the manifest's reported_true_anchor, so the stage and the release read
one name.
- Donor rows get no value: the donor reads no subsidized-coverage item
(NOW_MRKS is unread) and the national tool reads the absent column as
False.
- The column is not a transfer target, so no draw moves; a real-transfer
test shows every other column unchanged.
- The receipt's aca_anchor gives the anchored rows, their weighted share,
the allocated anchored rows and the code 1 rows left out (HINS2 2 or
blank). R2's staged-inputs limitation names the column.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The starting session resent the brief for the ACA anchor column (first sent at 21:25Z on 25 Nov and lost in a restart). Its rule matches the previous commit; this commit adds what the brief asks beyond it. - The aca_anchor receipt adds whether FHIMRKSP is loaded, the weighted share of the anchor that Census allocated, and the conflicts (HIMRKS 1 with HINS2 2: rows and weighted share; with HINS2 blank: rows). - The real-transfer test writes the pooled person table through the staging H5 boundary (put_frame_table, read_frame_table): ACS rows keep their values and donor rows stay missing, never False. - The changelog and R2's staged-inputs limitation say that donor rows carry the column missing and that it is a source column, not an engine input (the input-null audit, the register, the pre-check and R2's reviewed-null fill read only engine variables). Nothing is thinned, drawn or graded here. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The ACS local Medicaid stage thinned its HINS4 anchors inline: where a state's anchored eligible weight exceeds its residual, each anchor stays with probability (residual - stored weight) / anchored weight on a keyed draw. The ACA stage needs the same rule for its subsidized-coverage anchors (María's ruling, 25 Nov: HIMRKS as the anchor, with thinning), so the rule moves to a new country-agnostic module, microcosm.build.anchor_thinning, that both stages call. The caller passes the groups, the counted mass, the fixed rows, the anchors and the stream. The module is new rather than part of stochastic_assignment, which is an attested seed-kernel module and a helper module of many UK stages: an edit there moves the seed-protocol pins and UK stage digests. The Medicaid stage's results are unchanged: same sums, clip and draw strings on the same stream. Its receipts and flags on 36 fixture cases (27 of them thinned) are byte-identical before and after. The one-key draw helper the stage no longer uses is gone; the keyed-draw equivalence test now pins the shared keep draw on the HINS4 stream instead. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
María ruled on 25 Nov that the PUMS subsidy item HIMRKS is the ACA take-up anchor on ACS rows, with thinning. Staging writes the manifest's anchor column; this stage reads it and now thins it with the shared rule the Medicaid stage uses for HINS4: per state of the binding table (the SOI return count where the feed has it), each reported anchor stays with probability (residual - stored-True mass) / anchored mass on its own keyed draw (stream acs_local_aca_subsidized_anchor_keep, keyed on SERIALNO and the unit's lowest SPORDER). The mass counts as the binding operation counts it, over its domain, where the credit is positive. A stored ACS take-up True is never thinned, and donor rows are untouched. A unit not kept is an ordinary non-anchor, so the joint step can still fill with it where the kept anchors fall short of the residual, as the Medicaid stage's rule allows. The keep draw meets the residual in expectation only, so a thinned state gets its own grade status, anchors_thinned: reported, not failed. The receipt records, per state, the residual, the stored-True and anchored mass, the keep probability, the anchor and thinned rows and the thinned rows that take up anyway; the thinned states; and the share of ACS takers that are anchors, by rows and weighted. The grade's details list the thinned states and, per table, the states where the kept anchors exceed the residual. R2 logs one line for it; the limitation, the docs line and the changelog fragment describe the rule. Two tests that assumed anchors are kept above a residual now test the thinning. New engine-free tests: no thinning below the residual, the keep probability and the joint fill above it, delivery within the tolerance with many anchors, the keyed property, and donor rows and a stored ACS True left alone. One assertion line from PR A's merge is joined as the pinned ruff formats it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
PR A's last two commits: HIMRKS splits the ACS direct-purchase flags (code 1 sets the Marketplace flag), and staging writes the ACA stage's anchor column on ACS rows (True where HINS2 == 1 and HIMRKS == 1), which the ACA stage now thins above a state's residual. This merge carries both lanes into one PR (María, 25 Nov: one PR). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
PR A's final head per its hand-over (22:36Z): the aca_anchor receipt gains the allocated share and the HIMRKS/HINS2 conflicts, a test pins the anchor column through the staging H5 boundary (donor rows stay missing), and the staged-inputs limitation says the column is a source column, not an engine input. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
PR A's weeks and deferrals pass (A3, 9dff7c5) moves the donor's weeks-unemployed and retirement-contribution post-processing into two shared functions. Both modules are attested seed-kernel modules, so the seed protocol's content digest and the compiled seed map's digest moved and the pinned-digest tests failed from A3 on. The functions keep the same clip, rounding and zero rules, so no draw changes; this commit records the new digests with a note in the pin file's own form. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
vahid-ahmadi
left a comment
There was a problem hiding this comment.
Reviewed at e6f1c0d56. Moving these 16 inputs from engine defaults to ACS items or donor methods is the right direction, and the "What a build must measure" list is very useful. I read the stage design and the rulings list, spot-checked acs_local_status_inputs.py and the thinning helper, and ran test_anchor_thinning.py, test_us_acs_local_status_inputs.py and test_us_acs_local_group_quarters_housing.py locally (30 passed). I didn't read the ACA stage module line by line.
1. CI doesn't run on this PR. As the body says, CI runs only on PRs to main, and this one is stacked on #1719. So the 16 local failures, the engine tiers and the full suite are unchecked until #1719 lands. With about 9,500 lines touching R1, R2 and the seed pins, I'd retarget it at main for one CI run, as a draft, before merging into #1719. Or wait to merge it until #1719 is on main and CI has run here.
2. is_surviving_spouse = "widowed" gives the surviving-spouse filing status to too many people (item 2). In policyengine-us, surviving_spouse_eligible is is_surviving_spouse & has child dependents & not married. It doesn't check that the spouse died in one of the two prior tax years (IRC §2(a)). So every widowed head with a dependent child gets joint-return brackets and the joint standard deduction instead of head of household, on both spines. The ACS has the item to narrow it: MARHW, widowed in the past 12 months. MARHW = 1 is a reasonable proxy for "died within the window" (it under-covers the second year). That would be closer to the law than the donor's rule. If you keep the donor's rule for consistency, the limitation should name the filing-status effect.
3. The ACA target years (item 18) will make thinning act widely. The anchors are 2024 HIMRKS, when enhanced subsidies had grown subsidized Marketplace enrollment well past 2022. The state PTC rows are SOI TY2022. So in many states the anchored mass exceeds the residual, and thinning throws much of the 2024 anchor signal away to fit 2022 counts. Until #1728 moves the targets, I'd treat the thinned share as the first number to read in a build (receipt anchor.thinning). If it's large, binding the CMS 2024 table for this stage (item 15's alternative) may fit the anchors' year better.
4. Choosing takers by closeness to the residual average (item 16) concentrates take-up on units with a typical credit, which narrows the distribution of credits among takers. The donor does the same, so the lanes agree. But it biases distributional reads of the PTC: too few very large and very small credits. Worth a line in the limitation, and a check of the credit-per-return spread on ACS takers against the SOI amount and return ratio by state.
5. Independent keep draws (item 19). Agreed that moving to weight_balanced_uniforms is its own change. Since the thinning is now one shared helper, that change would be one edit for both stages, so I'd open the issue now.
6. Smaller points
- Item 1: MIL == 1 (on active duty) is a better reading of
is_militarythan a military occupation code, so I'd keep it. - Item 9: turning a "non-Marketplace only" draw into "both" on HIMRKS 1 seems right, since the source says they have subsidized Marketplace cover. Counting the cases is good.
- The known failing test (
test_no_county_materialization_matches_pre_county_surface) also fails on #1719. A one-line fixture fix in #1719 would let this PR's local runs be clean.
Review drafted with AI assistance and checked against the code at e6f1c0d56.
…ons (#1720) The review of microcosm#1754 asked for two limitation lines. - acs_local_staged_inputs: policyengine-us's surviving_spouse_eligible does not check that the spouse died in one of the two prior tax years (IRC section 2(a)), so on both spines every widowed, unmarried tax unit head with a child dependent files as a surviving spouse, with the joint brackets and standard deduction, not as a head of household. The rule itself is unchanged. - acs_local_aca_take_up: beyond the kept anchors, the joint step's selection puts the ACS takers' credits near each state's average credit per return, with too few very large and very small credits, so distributional reads of the credit on ACS rows are biased; the donor's stage selects the same way. Text only: no draw, receipt or pinned digest changes. R2's tool tests (engine-free): 372 passed, 2 skipped. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Thanks, Vahid.
🤖 Generated with Claude Code |
Part of #1720, under #1730. Stacked on #1719. Touches #975.
What this PR does
The ACS local lane left many inputs on ACS rows to the engine defaults or to draws that ignore the ACS's own items. This PR fixes the most urgent of them in two lanes. Donor rows keep their values in both lanes. No new check can refuse a release: staging writes receipts only, and materialize's new grade is report-only.
Lane A: staging (R1,
tools/_legacy/build_us_acs_multispine_base.py)ACS rows get 14 inputs that R2 used to fill with the engine default, 3 coverage flags from ACS items instead of transfer draws, and the ACA stage's anchor:
is_separated,is_surviving_spouse,is_military(MIL == 1),has_never_worked,is_computer_scientist,is_farmer_fisher,is_executive_administrative_professional(the donor's own rules where they exist).is_self_employed,health_insurance_premiums, with the donor'sattribute_us_se_health_premiums.weeks_unemployedand three deferrals (traditional_401k_contributions_desired,roth_401k_contributions_desired,roth_ira_contributions_desired): a lane-own QRF pass on the donor's ASEC role, after the shared transfer.would_file_taxes_voluntarily: the donor's SIPP model on ACS tax units.has_esifrom HINS1; the two direct-purchase flags bounded by HINS2.reported_has_subsidized_marketplace_health_coverage_at_interviewon ACS rows, True where HINS2 == 1 and HIMRKS == 1 (allocated values included); donor rows carry it missing. It is a source column, not an engine input.Lane B: materialize (R2,
tools/build_us_acs_local_release.py)ACS tax units get
takes_up_aca_if_eligibleandselected_marketplace_plan_benchmark_ratiofrom the donor's own method instead of universal take-up at the benchmark plan:aca_marketplace_inputsmanifest stage runs on the ACS tax units against what the donor rows leave of each state count (CMS APTC recipients, SOI PTC returns and amounts), floored at zero;microcosm.build.anchor_thinning) that both stages call, with the Medicaid stage's results unchanged;acs_local_aca_take_up.npz), calibrate requires it, and the consumer export must reproduce its digest;acs_local_aca_take_up_signalis report-only: recorded inrun_identity.jsonand as the diagnostic shadow entryus_local_aca_take_up_materialize.Reading order
The commit order mixes the lanes, so read by file group.
tools/_legacy/build_us_acs_multispine_base.py(stage order), then the six new stage modules inus_runtime/:acs_local_status_inputs.py,acs_local_se_health_premiums.py,acs_local_weeks_deferrals.py,acs_local_voluntary_filing.py,acs_local_group_quarters_housing.py,acs_local_coverage_anchors.py. Then the loaderacs_pums.pyandacs_multispine.py, and the donor helpers changed in place with donor values unchanged:relationship_inputs.py,org_wages.py,weeks_unemployed.py,retirement_contributions.py,voluntary_filing.py.us_runtime/acs_local_aca_take_up.py(the stage),anchor_thinning.py(the shared thinning rule) and its callerus_runtime/acs_local_ssi_medicaid_take_up.py, then the wiring intools/build_us_acs_local_release.py(targets, pre-pass, stage, checkpoint, identity, calibrate, export), the shadow entry inus/gates.jsonandus_runtime/battery_bindings.py, and a docstring inus_runtime/acs_local_take_up.py.us_runtime/acs_local_reviewed_fill_consumers.yaml; in R2_NEVER_DEFAULT_FILLED_REASONSand the limitationsacs_local_staged_inputs(lane A),acs_local_aca_take_up(lane B) andacs_take_up_engine_defaults; the pre-checktools/check_us_acs_local_reviewed_fills.py; the seed pins inspec_engine/inventory_coverage.py;docs/us-county-files-final-build.md,docs/us-esi-employer-premiums.md; seven fragments inchangelog.d/.Commits by lane (in history order):
499bdc6a66f7d34ab8d7fb41eaa9dff7c55121f14af175305c104358edfbb4d58acd125360f41a4ccNEVER_DEFAULT_FILLED, pre-check, register (2 entries)07b3e1e3d01b029b01bc745c3175305c1043(A1-A5)e0f1a20cfaf2b57b0b01b029b01(A6)657d4e6f3efd5ae803e0f1a20cfcf65a13dff862decd240fcf36fb7726a08511b11e0206b0fedaf42b78f1d98a40fcf36fb99355b3a1b0fedaf42(final)e6f1c0d561e76cf81eThe history is kept as built: no rebase, squash or reorder, because the merged tree is the tested one.
Register: 63 entries at the base, 47 after
16 entries removed, none added:
has_never_worked,health_insurance_premiums,is_computer_scientist,is_executive_administrative_professional,is_farmer_fisher,is_military,is_self_employed,is_separated,is_surviving_spouse,roth_401k_contributions_desired,roth_ira_contributions_desired,traditional_401k_contributions_desired,weeks_unemployed; tax unitwould_file_taxes_voluntarily.takes_up_aca_if_eligible,selected_marketplace_plan_benchmark_ratio.Each removed column is now in R2's
_NEVER_DEFAULT_FILLED_REASONS, so a staging run or checkpoint from before this PR is refused at materialize, as for earlier staged columns. A5, A6 and the HIMRKS commits override transferred columns, which are never null, so they add none.What a build must measure
No build exists for this PR yet, so every number below is unmeasured. Read receipts as shares and row counts.
acs_local_aca_take_up:anchor.thinning.thinned_tax_units / anchor_tax_units, and the weighted share, the sum ofanchor_mass × (1 − keep_probability)over the sum ofanchor_massacross its state rows. The SOI rows are TY2022 and the anchors 2024 (item 18), so a large share means the thinning discards much of the anchor signal; then item 15's alternative, binding the CMS 2024 table for this stage, may fit the anchors' year better. Also: the thinned states, each state's keep probability, anchor rows, thinned rows and thinned rows that take up anyway;take_up.anchor_share_of_takersand its weighted twin; R1 receiptacs_local_coverage_anchors.aca_anchor(anchor rows, weighted share, allocated share, HIMRKS/HINS2 conflicts).calibration_diagnostics.json,initial_estimate / targetfor each statepremium_tax_credit_returnsandpremium_tax_credit_amountrow, against Build 0 (Ready the US ACS local-area lane for the next national build on policyengine-us 2.145.3 (#1661, #1675, #1154) #1719 as it is), and the final values. In the county proof of concept of 17 Nov the pooled file started at 1.85 times the SOI return count and 1.42 times the amount.tables.<name>.statesfor the three tables: the donor share of each target, the residual, the ACS capacity and delivery, shortfalls, donor excess, and the kept anchors' excess over each table.take_up.weighted_take_up_share_of_eligibleagainst the donor's share on its own eligible units;plan_ratioshares below 1.0 and at each clip. The spread of the credit per return among ACS takers, by state, against the SOI amount per return: the receipt's per-state delivered amount and count give the average; the spread (for example the weighted 10th and 90th percentiles, against the donor's takers) needs an engine pass over the built file. The joint step favours credits near the average (item 16).compositionfor the target, the donor, the ACS rows and the pool (Jointly calibrate ACA take-up to CMS APTC people and SOI PTC returns #168).acs_local_status_inputs(weighted shares;is_militaryagreement with POCCU2 52 and ESR 4/5),acs_local_se_health_premiums(flagged share, withheld rows, COW 6/7 agreement),acs_local_weeks_deferrals(ACS and donor positive shares; UC recipients with positive weeks; post-processing counts),acs_local_voluntary_filing(ACS and donor weighted true share),acs_local_group_quarters_housing(units turned False by TYPEHUGQ),acs_local_coverage_anchors(HINS1 against the drawnhas_esi; direct-purchase rows set False, kept and type-drawn; HIMRKS codes and weighted shares among HINS2 = 1 rows, allocated rows, code 1's agreement with the drawn Marketplace flag and the rows that became "both"; HINS2 = 2 conflicts with HIMRKS).has_esithe ACS units eligible for the PTC and the children eligible for CHIP change; the self-employed premium deduction and the deferrals move MAGI before R2's Medicaid pre-pass, so the CMS residual and the Medicaid assignment can move.engine_prepasswall time and peak RSS, against the SSI and Medicaid pre-pass and materialize's peak.run_identity.jsonacs_local_aca_take_up.gateand the shadow comparison forus_local_aca_take_up_materialize.Items for María to confirm
Rulings already given (context, not open): A6 (HINS1/HINS2, 25 Nov 17:08Z); HIMRKS for the direct-purchase split (21:20Z); HIMRKS as the ACA anchor, with thinning (21:25Z); one PR (22:02Z).
is_militaryis ACS MIL == 1 (on active duty), not the donor's rule (POCCU2 52, a military occupation on the longest job).is_surviving_spouseis "widowed" on both spines (the donor's rule), wider than the tax status. The engine'ssurviving_spouse_eligiblehas no two-year window (IRC section 2(a)), so every widowed, unmarried head with a child dependent gets the surviving-spouse filing status on both spines; the limitation now says so. ACS MARHW (widowed in the past 12 months) could narrow it on ACS rows, but 14 state rules also readis_surviving_spouse, and they have no such window.has_never_workedon ACS rows is POCCU2 53 (blank OCCP from age 16, no job in five years).acs_transfer. ACS group-quarters records draw a housing take-up flag in the local-area transfer #975 stays open until a build confirms it.has_esi, not on HINS1.NOW_MRKSis unread), so anchors exist on ACS rows only.weight_balanced_uniforms(systematic sampling with a keyed start, from the Budget 2026 slower data fixes, PR C of #1418: electricity at the ONS level, pension income by area #1420 review) would hold the kept mass within one unit of the residual; moving both stages to it changes the Medicaid stage's draws, so it would be its own change.Deviations from the two plans
Each lane had a written plan before the code. The code differs from it here:
stage_filled_never_defaultis unchanged for lane A's columns: that list is for columns R2's own stages fill. Lane B's two ACA columns are on it.ACS_HIMRKS, counts conflicts, passes weights for the receipt).b0fedaf42completes it after the brief was resent.NEVER_DEFAULT_FILLEDentries moved from B3 to B4, with the register removal: the register refuses an entry for a never-default column. B4 also makes the SSI and Medicaid pre-pass read the pending ACA cells at the engine defaults.microcosm.build.anchor_thinning, which both stages call; its receipts and flags on 36 fixture cases (27 thinned) are byte-identical before and after. The helper is a new module, not part ofstochastic_assignment, which is an attested seed-kernel module that UK stage digests read.aca_ptcdoes not depend on the take-up flag. On 2.145.3 it does (filing gate), so the pre-pass reads a missing flag as True.weeks_unemployed,retirement_contributions) without a re-pin, so the seed-protocol tests failed from A3 on.e6f1c0d56re-pins both digests; no draw changes.Tests
Environment:
uv sync --all-packages --locked --extra us(policyengine-us 2.145.3), Python 3.13. Touched files only (María's rule). CI runs only on PRs tomain, so it does not run on this PR; the local runs below are the only check.On the final merged tree (
99355b3a1plus the re-pin):engine_free/shared/test_spec_engine_seeds.py,engine_free/shared/test_spec_engine_inventory_coverage.py,engine_contract/us/test_spec_engine_inventory_coverage.py: 28 passed (after the re-pin; before it, the pinned-digest test failed as A3 left it).-n 4(21 files, both tiers): the ACA stage (engine-free and engine-contract), the thinning helper, the keyed draws, the Medicaid stage, R2's tool (engine-free and engine-contract), the gate shadow and bindings, spine blindness, the coverage anchors, the loader, the multispine seam and both builders, the register (engine-free and the engine-tier walk), the pre-check, the county surface, the take-up module and the no-county regression: 1875 passed, 3 skipped, 16 failed. All 16 failures aretest_no_county_materialization_matches_pre_county_surface, stopped at_require_staging_engine, the known failure below.ruff check .: passes.tools/ci_test_plan.py verify: ok.Before the last merges (lane B's thinning on the merged A6 tree): the ACA, helper, keyed-draw, Medicaid, R2 tool, gate shadow, bindings, spine blindness and inventory tests: 1358 passed, 2 skipped. The Medicaid stage's receipts on 36 fixture cases: byte-identical before and after the helper.
Earlier runs per lane: each commit's touched tests passed before it was committed. Lane A ran its touched files at each state, A1 to the anchor receipt, and every run passed (one A3 run had 3 failures that came only from the then-uncommitted A4 module). Lane B on the merged A6 tree: 1460 passed and 3 skipped engine-free, 153 passed in the engine tier.
After the review (
1e76cf81e, text only): R2's tool tests (engine-free): 372 passed, 2 skipped.ruff checkandruff format --diffon the two changed files: clean.Known failure, not caused by this PR:
engine_free/us/test_us_acs_local_no_county_regression.py::test_no_county_materialization_matches_pre_county_surfacefails on #1719's head too: its staging summary records no engine, so_require_staging_enginestops materialize. It passes with that check stubbed. A one-line fixture fix, for its own change.Not run: the full suite; any build, staging run or R2 run on real data; the engine over a full file; each commit in isolation from a clean checkout.
🤖 Generated with Claude Code