Skip to content

Count state child care subsidies in the SPM once - #10569

Open
MaxGhenis wants to merge 49 commits into
mainfrom
spm-child-care-subsidies
Open

MaxGhenis wants to merge 49 commits into
mainfrom
spm-child-care-subsidies

Conversation

@MaxGhenis

@MaxGhenis MaxGhenis commented Nov 1, 2026 •

Copy link
Copy Markdown
Contributor

Problem

For a Manhattan parent earning $30,000 with a child in full-time care at $14,000 a year, ny_ccap pays $13,916.40. On main at 469ad12cb9 (2.90.2), turning that subsidy on raises household_net_income by $8,321.86 and lowers spm_unit_net_income by $5,594.54.

On main, SPM resources count only the Colorado, Washington and West Virginia subsidies, and the SPM deduction uses pre-subsidy expenses. So in the other 48 states a subsidy cuts SNAP and tax credits, and nothing in the SPM offsets the cut.

Fix

Census subtracts what parents paid for child care (SPM technical documentation, PDF page 17), and its list of noncash benefits (section 4.3.1) has no child care benefit. So from 2024 the model counts a subsidy in the SPM once, as a lower expense.

In a household calculation, the user enters the price of care before any subsidy as spm_unit_pre_subsidy_childcare_expenses, while both dataset builds fill that input with what parents reported spending. So spm_unit_capped_work_childcare_expenses has two rules. In them, W stands for work expenses, C for the earnings cap, E for the input, S1 for the subsidy the simulated policy pays and S0 for the subsidy baseline policy pays.

Where What E holds Expense
Household calculation The price of care before any subsidy min(W + max(E - S1, 0), C), or min(W + X, C) for a unit with a child given childcare_expenses X
Over a dataset, or rebuilt from a snapshot, extracted situation or dump of one What parents reported spending, which the rule reads as after any subsidy min(W + max(E - (S1 - S0), 0), C)

Over a dataset, the model grosses the reported amount up by the baseline subsidy at run time and then nets the simulated subsidy from the result. Under baseline policy the formula reads no subsidy and keeps min(W + E, C), the amount Census subtracts. holds_dataset_inputs picks the rule, and simulation.baseline supplies S0, as it does for medicaid_slcsp_state_denominator. The predicate holds over a dataset (simulation.is_over_dataset), in a simulation built from a marked snapshot or situation of one, and in one restored from a marked dump of one.

export_source_inputs marks a snapshot of a dataset simulation with "_dataset_inputs": true, and extract_person marks a situation extracted from one the same way. This package's builders turn the mark into an attribute on the simulation they build, before core clones it into a reform's baseline arm, so the arm and later branches keep the dataset rule too. At a92315ef96 the Manhattan family's reload read as a household, and its expense fell from $14,000 to $83.60; now it keeps $14,000. Main's other readers of is_over_dataset, such as county, still read a reload as a household. A snapshot without the mark, as main's export_source_inputs writes, reloads as a household, and so does one marked false. Any other value raises ValueError. Main's reload_source_inputs reads only a snapshot's version, period keys, provenance envelope, sources and overrides. So it ignores the mark and the key below, and snapshots stay at version 1 (read from main's code, not run). Main's builders would reject the mark in an extract_person situation, as they reject any unknown key (read from core's code).

Over a dataset, core gives a reform's baseline arm each value the dataset gives, formula variables among them. export_source_inputs lists the formula variables' values as overrides, and at 439c863eea reload_source_inputs set them after construction on the reform side only, so the reload's arm calculated them. A probe at that head gave a New York family $40,000 of ny_ccap_countable_income through a dataset. Under the repeal, the source's arm paid a subsidy of $13,816.40 and the reload's arm $13,916.40, so the reload's expense came out $100 above the source's. A reload of a marked snapshot now sets each override on its arm too. A caller who sets a value on a reform simulation after construction sets it on the reform side alone, so export compares each override with the input the source's arm records. Where they differ, it lists the arm's value under "_baseline_arm_overrides", or null where the arm records none. A marked reload gives its arm each listed value in place of the override and skips a null one. A pure input or a Social Security component that a caller sets on a reform simulation after construction still reaches the reload's arm ("Snapshots, situations and dumps" under "Costs and limits of this rule"). A marked snapshot of a simulation with no arm carries no "_baseline_arm_overrides", so a reload with reform= gives its arm every override. The reload skips a variable that baseline policy doesn't define, since the source's arm has none. When the arm would get a value the reform stores in another entity or with other ETERNITY storage, the reload raises a ValueError that names the variable, before it sets anything on the arm. Its own check raises with the guard's message, though a value whose length doesn't fit the reform's entity can raise core's length error on the reform side first (read from code, not run). A reform built over the dataset raises the same way. A reload of an unmarked snapshot sets its overrides on the reform side only, as main's does (read from main's code).

  • In a household calculation, the formula reads childcare_expenses, the model's out-of-pocket variable, for a unit with a child. That variable allocates expenses to children, so for a unit with no child the formula nets child_care_subsidies from the unit's own input. A caller can give a unit with a child its out-of-pocket amount as childcare_expenses, which then replaces max(E - S1, 0). Main reads only E, so for a unit with a child given only $6,000 of childcare_expenses, the expense moves from $0 on main to $6,000. A unit with no child ignores that input. Members' pre_subsidy_childcare_expenses, given directly, also replace E for a unit with a child, since childcare_expenses sums them. Once a caller gives one member's amount, every member holds an input, so a child given none counts zero rather than a share of E. For example, with E of $10,000, $6,000 given for one child, no subsidy, W of $1,000 and C of $20,000, the expense moves from $11,000 on main to $7,000, whether the unit has one child or two. YAML cases pin each of these.
  • From 2024, this PR drops co_ccap_subsidy, wa_child_care_subsidies and wv_child_care_subsidies from spm_unit_benefits and from the four reform copies of that list. The expense has no formula before 2024, so SPM resources keep those subsidies in those years wherever main counts them, and every year before 2024 matches main. The Tlaib copies hold only Colorado's. A YAML case in each reform's file pins 2023 and 2024.
  • From 2024, the child_care_subsidies list holds all 51 state programs. The DC, Tennessee and Texas programs pay in 2024, but main's list leaves them out until 2025. Adding them lowers childcare_expenses for those three states in 2024. Its readers see the lower amount that year: the SNAP dependent care deduction, HUD adjusted income, dependent-care credits, and the DC, Tennessee and Texas TANF deductions. Over Populace 2024 the three programs pay nothing, so the default file's 2024 results don't move.

At 1b9dec8316, the Manhattan family's expense falls from $14,000 to $83.60, its SPM net income rises by $8,321.86, as its household net income does, and it leaves SPM poverty.

Over a dataset, a unit reporting $14,000 keeps a $14,000 expense under baseline policy. Repealing New York's subsidy raises that expense to $27,916.40 and lowers SPM net income by the same $8,321.86. test_repeal_moves_dataset_and_household_income_by_the_same_amount pins this in New York and Texas.

Adding subsidies to resources instead would depart from the Census definition and fail in two places. It would add income at the earnings cap, where the expense doesn't fall. It would also overcount wherever a program pays more than the family spends. Vermont pays its state rate regardless of the provider's charge, and in the audit it paid $22,828 against a $1,200 bill.

Why the dataset needs its own rule

Both dataset builds fill the input from the ASEC's reported spending, SPM_CHILDCAREXPNS: Populace in microcosm/build/us_runtime/childcare.py and policyengine-us-data in datasets/cps/cps.py. The ASEC asks parents how much they spent on child care, and Census subtracts that amount as it stands. This rule reads the amount as what parents paid after any subsidy, so netting a modeled subsidy from it would count the subsidy twice. Over the default file in 2026, netting cut the SPM expense by $1.135B at 606699d640, and by $7.280B with schedules set at 640753a617. So the builds keep the reported amount, and the model moves it only by the change in subsidy a reform makes.

The baseline arm

The dataset rule reads S0 from the reform's baseline arm. Core builds that arm inside its __init__. Simulation.__init__ and Microsimulation.__init__ then move employment_income, self_employment_income, sstb_self_employment_income, weekly_hours_worked and long_term_capital_gains to their pre-response variables, and fill state_code from state_code_str. At d4d391788d, the arm kept the raw inputs and read 0 from the pre-response variables. In a household situation it paid the Manhattan family $3,498 in New York TANF and no child care subsidy, where a plain run paid no TANF and a $13,916.40 subsidy. Over a dataset that stores raw hours, as policyengine-us-data's CPS build does (cps.py:481), the dataset rule would have carried that gap into the SPM.

#9698, which this branch merges from main, branches the arm again after the moves (_rebuild_baseline_branch). That rebuild bound the copied holders to baseline variables but kept each holder the reform had built in another entity or with other ETERNITY storage. The SPM mixin's constructor, subsample and _baseline_measurement_branch all drop such holders. Under a reform that stores child_care_subsidies for all time, the arm read a New York family's $500 input for all time as S0, where baseline policy pays the family $13,916.40. The family's reform expense came out $14,000.00, where the rule gives $27,416.40. This PR makes the rebuild drop those holders too. A dropped holder takes its inputs with it, though, so dropping alone would have the arm calculate S0 in place of a subsidy the caller gave, even a yearly one that baseline policy can hold.

So where the rebuild would drop a holder that holds an input the caller gave, it raises ValueError naming the variable (_refuse_inputs_baseline_policy_drops). Under the reform that stores child_care_subsidies for all time, a $500 subsidy given for all time or for 2026, through a dataset or a situation, raises. The guard has three limits:

  • It fires only at the end of construction (system.py:543), because at the arm's other two drop sites, in the constructor and in subsample, core has already dropped the holder and its record of the input.
  • An input set after construction and then subsampled raises nothing: the subsample's arm drops it and calculates the variable, as on main.
  • It matches a recorded input by variable name alone, ignoring branch and period, because the records the arm copies from the reform keep the reform's branch name.

The behavioural-response measurement branch drops the same holders and calculates those variables without the guard, as on main. Main's test_baseline_measurement_drops_incompatible_holders sets such an input after construction and expects the branch to calculate the variable as simulation.baseline does. The branch has no baseline of its own, so its SPM expense keeps E and reads no subsidy.

The household rule reads no S0, so the arm doesn't move a household calculation's SPM expense. No reform in policyengine_us/reforms redefines a variable in another entity or with other all-time storage, so none reaches the drop or the guard, and a static test below keeps it so.

A subsample of a branch with any name but "baseline" gets its own arm (see "A branch named "baseline"" under the limits). A branch shares its parent's arm, and core rebuilds only the arm a simulation holds in branches["baseline"]. So subsample hands core a copy of the inherited arm, which core rebuilds on the branch's sample, while the parent keeps its own. Without that copy, the branch kept its parent's arm on the full sample, and the dataset rule raised an error reading S0 from it, where main returns the expense. If core's subsample raises before it rebuilds the arm, the branch gets back what it held under that name.

Tests and a docstring that #10975 added on main assumed a subsampled branch keeps its parent's unsampled baseline and matched people by ID. Here the branch's own baseline holds the same people in the same order, so values align by position, and the ID lookup stays as a fallback. A subsample that raises after core has resampled the simulation still sends a later calculation to the lookup, because a branch then keeps its parent's unsampled arm and a reform simulation keeps its own. A value calculated before that subsample skips it (see "Subsampling after new person IDs"). After new person IDs, the lookup raises NotImplementedError naming the IDs the arm lacks. Where the people keep their IDs, it matches them by ID; I reached that case only by forcing the rebuild to raise. New person IDs alone don't reach the lookup, since the simulation and its arm keep the IDs they loaded until a subsample. #10975's variable documentation now says the same.

An input that a caller sets on a branch to fica_pre_tax_contributions, or to a contribution it sums, counts as a change to payroll wages until the branch's own subsample. After it, the input counts as no change, because the branch's new baseline holds the input too, as a reform simulation's baseline does after its own subsample. On main (read from its code, not run), the branch keeps its parent's arm, so the input still counts after the subsample. A value a dataset gives fica_pre_tax_contributions reaches the arm too, so it counts as no change. A marked reload now gives its arm the snapshot's overrides, so after a snapshot the value still counts as no change. In a probe of $1,000 given for a parent earning $30,000, employer_payroll_tax_fixed_employer_cost_change read $0 on the source and on the marked reload, where the marked reload read $71.06 at 439c863eea. An unmarked reload still reads $71.06, as main's reload would (read from main's code). tests/core/test_employer_payroll_tax_incidence.py passes whole at a7c00425d3, 47 tests.

This PR also adds tests/core/test_reform_baseline_arm_inputs.py, which pins the rebuilt arm on the dataset path this rule reads, and updates the docstring of _baseline_measurement_branch, which still said the arm keeps the raw inputs.

Invariants

I test these with Hypothesis in policyengine_us/tests/test_spm_child_care_subsidy_invariants.py.

For a household calculation:

  1. For a unit that leaves childcare_expenses and its members' pre-subsidy expenses to their formulas, the model's expense equals the formula above, written from the documentation rather than from the code. YAML cases pin a childcare_expenses input, which replaces max(E - S1, 0) for a unit with a child and which a unit with no child ignores.
  2. 0 <= expense(0) - expense(S) <= S, and a larger subsidy never raises the expense.
  3. With taxes and other benefits fixed, a subsidy leaves spm_unit_benefits unchanged and raises spm_unit_net_income by the fall in the expense, so the SPM counts it once.
  4. With a subsidy of zero, the expense matches main's formula in every state for a unit that leaves childcare_expenses and its members' pre-subsidy expenses to their formulas. A unit with a child given only childcare_expenses X gets min(W + X, C), where main reads no X and gives min(W, C).
  5. From 2024, no *_child_care_subsidies variable, and no program one of them adds, appears in spm_unit_benefits or a reform's copy of it, and all 51 appear in every program block. Every household_state_benefits block from 2024 counts them only through household_child_care_subsidies, which Count all child care subsidies in household benefits #9503 added.
  6. A differential test turns real programs on and off. The expense falls by the amount the test's reference gives. The change in SPM net income equals the change in household net income, less the subsidy household_child_care_subsidies counts in the household measure, plus the fall in the expense.

Over a dataset:

  1. Baseline policy leaves the expense at min(W + E, C), whatever subsidy the model pays, in a plain simulation and in a reform's baseline arm.
  2. Under any policy the expense follows the dataset rule, at the floor and the cap and with or without a child in the unit, with W and C from the policy simulated. A policy that pays the same subsidy and keeps W and C leaves the expense where baseline policy put it.
  3. Where the subsidy baseline policy pays doesn't exceed the price, a second differential gives a dataset the amount the household rule says a unit pays at baseline policy. The two rules then give the same expense under any policy. A larger subsidy leaves the unit paying nothing, which hides the price from the dataset rule. With real programs and $14,000 as both rules' input, repealing the subsidy moves SPM net income by the same amount under both wherever neither cap binds. The parent's earnings and hours enter as raw inputs, so this case runs the arm rebuild too.

In tests/microsimulation/test_spm_child_care_reported_expense.py, Microsimulation loads the shipped population, so the dataset flag and the baseline arm come from the path a user's run takes. One test checks property 7 on every record of the default dataset. The other runs a real reform on a 500-household slice that holds units with both a modeled subsidy and reported spending. It checks that the baseline arm matches a plain run and that the reform arm follows the rule.

tests/core/test_reform_baseline_arm_inputs.py checks the arm itself. Under a reform that changes nothing, the reform and its baseline arm compute what a simulation with no reform computes, on four pre-response variables and seven outputs from the subsidy to household net income. It runs a dataset of raw columns with two families in every state, and a situation that names New York only through state_code_str. It also checks that the arm owns its policy and holds no value the reform's policy produced, and that every holder in either arm suits that arm's definition of its variable. Its other tests:

  • The guard. Under the reform that stores child_care_subsidies for all time, a $500 subsidy for all time or for 2026, from a dataset or in a situation, raises ValueError naming the variable from _rebuild_baseline_branch.
  • The guard's limit. Under that reform, a $500 subsidy set after construction and then subsampled raises nothing. The arm pays the subsidy a plain run pays, and the reform keeps the $500.
  • The rebuild's drop. Construction asks a reform for the holder of sstb_self_employment_income while it moves that input, even where the caller gave none. Under a reform that stores the variable for all time, the reform then holds an empty holder for all time, which the guard leaves alone, and the arm holds none.
  • A subsampled branch. Two New York earners each paid $500 for care, with subsidies of $100 and $200 and weights of 0 and 1, under a reform that raises the standard deduction. A branch of the reform simulation that subsamples reads an arm on its own sample, which pays $200, and gets the $500 expense that a subsample of the reform itself gets. The parent keeps its arm on both households.
  • A branch named "baseline", and a failed subsample. Under a reform that repeals the subsidy, the caller names one of a branch's calculation branches "baseline". The branch's subsample still gets S0 of $6,000 and an expense of $12,000, as a subsample of the reform itself does. A subsample given neither n nor frac raises and leaves each branch as it found it, and a retry gets the same S0 and expense.
  • A simulation named "baseline". Under the repeal, get_branch("baseline") on a branch, a clone of it, a deeper branch of that name and a reform simulation renamed "baseline" each raise when they subsample. Each keeps its policy, arm, branches and name, and the first still reads S1 of $0 and an expense of $27,916.40.
  • Snapshots. Both New York families, over a dataset, go through export_source_inputs and reload_source_inputs: with no reform, under the repeal, and from a source built under the repeal and from its arm. Each reload keeps the dataset's expense, $14,000 and $6,000 with no reform and $27,916.40 and $12,000 under the repeal. So do a branch, taken before the reload calculates anything, and a second snapshot of the plain reload. Under the repeal the arm reads S0 of $13,916.40 and $6,000 and keeps the reported amounts. A situation from extract_person with no value set by hand, with and without the repeal, does the same. A snapshot with the mark removed reloads as a household, at $83.60 and $0. Marked false, a snapshot and a situation read $83.60 for the first family, and a mark of "true" or 1 raises in the builder and in the reload.
  • The arm's overrides. A dataset gives the first New York family $40,000 of ny_ccap_countable_income and $2,000 of work expenses. Under the repeal, a marked reload's arm reads what the source's arm reads: S0 of $13,816.40 and $6,000 and an expense of $16,000 and $6,000. The reform side reads $29,816.40 and $12,000. An unmarked reload's arm calculates both values instead, as main's does. A caller then sets $3,000 of work expenses and an earnings cap of $20,000 on the source's reform side. The reload's reform side and arm each read what the source's do, and a snapshot of the reload lists the same arm values. Under the reform that stores child_care_subsidies for all time, a marked reload of a dataset's $500 subsidy raises, naming the variable. An unmarked one builds, and its arm calculates the subsidy. A variable only a reform defines reaches the reload's reform side alone, and nothing raises.
  • Dumps. A dataset simulation with no reform, dumped through core's dump_simulation before any calculation, restores with the reported expense, $14,000 and $6,000, and the $1,200 Social Security benefit its source reads. With the mark file removed, it restores as a household, at $83.60 and $0, and with 1 in it the restore raises. A household simulation's dump holds no mark.

tests/core/test_shipped_reforms_store_no_variable_apart.py reads the source of every reform in policyengine_us/reforms without importing it. It fails on a reform that redefines a variable in another entity or with other all-time storage. It also fails on one that passes update_variable, add_variable or replace_variable anything but a class defined in its own file or a loop over such classes. It reads an attribute that a class body sets by plain assignment or by annotated assignment with a value. It doesn't read one set through a tuple target, an augmented assignment, a nested block, a later assignment on the class or a base other than Variable or a baseline variable. A second test checks that the scan flags the reforms that the arm tests and tests/core/test_spm_system.py build to store a variable apart, and a third that it flags definition_period: str = ETERNITY. test_subsampling_never_changes_which_policy_a_holder_belongs_to in tests/core/test_spm_system.py now checks every holder before it subsamples as well.

The five new invariant cases and the slice test all fail against the formula that nets the subsidy from a reported payment (513aa0bb66). At 5a6557a92a, with _rebuild_baseline_branch disabled, all three arm tests then in the file and the New York repeal case failed. A no-change reform then got the expense wrong for 32 of the arm test's 102 households, by up to $13,916.40.

At 1b9dec8316, I made each change below in turn and ran the tests named. Each fails at least one:

  • Leaving a subsampled branch on its parent's arm fails the subsampled-branch test, which finds the parent's arm in the branch.
  • Copying the arm only where a branch has no "baseline" entry fails the test of a branch named "baseline", whose new arm then repeals the subsidy as the reform does.
  • Removing the restore fails the failed-subsample test, which then finds the arm's copy in a branch that held nothing under "baseline".
  • Removing the guard's three calls fails the four guard cases, which then build without raising.
  • Calling the guard in the measurement branch instead fails both cases of main's test_baseline_measurement_drops_incompatible_holders, which then raise on is_household_head.
  • Removing the rebuild's drop (system.py:544), with the constructor's own drop in place, fails the rebuild's-drop test. The guard's-limit test and test_subsampling_never_changes_which_policy_a_holder_belongs_to still pass without it.
  • Having the guard read the reform's records and holders rather than the arm's fails test_subsampling_never_changes_which_policy_a_holder_belongs_to, which then raises on the reform's own is_household_head.
  • Matching only records on the arm's own branch fails the four guard cases.
  • Removing the dataset rule's floor fails test_policy_over_a_dataset_moves_the_expense_by_the_subsidy_change on an explicit example.
  • Reading S0 from the reform rather than its arm fails the same test on two explicit examples.
  • Removing the household rule's floor for a unit with no child fails the two YAML cases where a subsidy exceeds such a unit's expense.
  • Swapping what the household rule reads for a unit with and without a child fails 13 of the 19 YAML cases, among them the three childcare_expenses cases and the two that give a member's pre-subsidy amount.
  • Dropping the reach scan's read of annotated assignments fails test_the_scan_reads_an_annotated_assignment, which then misses a reform that stores child_care_subsidies for all time that way.

a92315ef96 adds documentation text and one test to 1b9dec8316. At it, I reran the arm test file, #10975's tests and YAML cases and the documentation checks, all of which pass. Removing the restore's check that it made a copy there fails the new test, whose subsample, with no arm, then raises KeyError in place of core's ValueError.

The head, d367d8c1ba, changes only comments and docstrings in tools/social_security_inputs.py, and the three commits below it, 688fc8d7af, d10cddb410 and cf7a43e027, change only the docs page's paragraph on snapshots. a7c00425d3 updates the docs, the changelog and the capped-expense variable's documentation, and 202b79eb80 below it gives a marked reload's arm the snapshot's overrides, marks dumps and checks the mark's value. e9fc366e76 added the subsample refusal to a92315ef96, and 439c863eea the snapshot mark. At a7c00425d3 I ran the arm test file, tests/core/test_spm_system.py, the invariant tests, the reach scan, the derivation tests and tests/core/test_employer_payroll_tax_incidence.py. I also ran one measurement test, test_baseline_measurement_drops_incompatible_holders, three Social Security input files, one marital-unit snapshot test, tests/unit/test_ss_history_engine.py, the documentation checks and the integration and capped-expense YAML files. Each passes. There I made each change below in turn and ran the whole arm test file. Each fails at least the test named:

  • Setting a marked reload's overrides on the reform side only fails the overrides test on its first check: the reload's expense comes out $29,916.40, against the source's $29,816.40. The work-expense, reform-side and refusal tests fail too.
  • Listing nothing the source's arm holds apart fails the reform-side test: the reload's arm reads the $3,000 of work expenses set on the reform side, where the source's arm reads $2,000.
  • Setting an override the reform stores for all time on the arm, in place of raising, fails the refusal test, which then builds without raising.
  • Reading any mark for its truth fails the mark test, which then accepts "true" without raising, and the dump test, which accepts 1.
  • Writing no mark file on dump fails the dump test: the restored expense falls to $83.60 and $0.
  • Reading the mark file without marking the restored simulation fails the dump test the same way.
  • Dropping the mark from every new branch but the arm fails the round-trip test at its branch, taken before the reload calculates anything: the branch's expense falls to $83.60 and $0.
  • Writing no mark on export, or leaving it out of the reloaded situation, fails the round-trip test at the reload's branch, taken before the reload calculates anything: its expense falls to $83.60 and $0.
  • Marking only a simulation over a dataset on export fails the same test at the second snapshot's reload.
  • Reading is_over_dataset alone in the formula fails it at the same branch.
  • Having the builders strip the mark without marking the simulation, or writing no mark in extract_person, fails the extract_person test at $83.60.
  • Marking a reloaded simulation only after construction fails the reform reload test at the arm's expense, $83.60 and $0, after the reform side's checks pass.
  • Removing the check on a simulation named "baseline" fails its test, whose subsample then doesn't raise.

Dropping Texas from the 2024 program block, or every block from 2024 on, fails test_latest_blocks_list_every_state_program. Listing co_ccap_subsidy beside household_child_care_subsidies in the 2026 household block fails the household list test, and listing household_child_care_subsidies in spm_unit_benefits fails the SPM resource test.

Intended violation

A subsidy can lower SPM resources at the whole-model level. SNAP, TANF and tax credits read out-of-pocket expenses, so a subsidy can cut them by more than the SPM expense falls. At the earnings cap the expense can't fall at all, and below the cap a benefit cliff can cut more than the expense falls. Household income loses the same benefits but also counts the subsidy, so it can rise while SPM income falls. SPM net income fell in 22 of the 1,395 subsidized cells in the grid below, and test_subsidy_at_the_cap_can_lower_spm_income pins one case.

Audit of all 51 subsidies

I ran these audits on household calculations at 606699d640 against main at 469ad12cb9, and this head keeps that commit's household rule. Main has since changed the Vermont, New Hampshire, Nevada, Texas, New York and Colorado subsidies (#10584, #10575, #10598, #10622, #10623, #10636, #10817, #10821, #10827, #10721), so those states' counts can differ at the merged head.

  • Each state against the aggregate, 2021 to 2026. I ran one working family in every state for 306 state-years, and no run errored. Before this PR, child_care_subsidies left out paying state programs in DC, Tennessee and Texas in 2024, and in DC, North Carolina, Oregon and Texas in 2021 to 2023. From 2024 they agree. This PR leaves 2021 to 2023 unchanged, because the SPM expense formula starts in 2024.
  • Deduction, 2024 to 2026. In 306 runs across 153 state-years at two expense levels, the deduction matched the formula. That audit compared against the aggregate, so it missed DC, Tennessee and Texas in 2024.
  • Grid. 51 states by 6 earnings levels by 6 expense levels gives 1,836 cells, with meets_ccdf_activity_test set. Every state pays somewhere on the grid, and the identity in invariant 6 holds in every cell.
  • Nevada. At the audit's base, Nevada paid the audit family nothing. Its activity test read meets_ccdf_activity_test, TANF enrollment, homelessness and protective care, and the family had none of them set. Stop requiring an activity input from Nevada's working parents #10575 has since stopped requiring the activity input from working parents.
  • Main's New York and Colorado changes. Since Fix New York child care categorical routes and family shares #10817 and Count public assistance and SSI supplements in New York CCAP income #10827, New York's CCAP counts the Family Assistance grant a family takes up and waives the family share for it. TANF reads employment_income_before_lsr, which a household simulation fills from employment_income but the YAML runner leaves at zero. With a bare employment_income, Family Assistance saw no earnings, paid the Manhattan family $3,498 and waived its $83.60 family share. So every case in this PR's integration YAML now gives pre-response earnings, as a household run stores them, and the New York subsidy stays $13,916.40. With bare earnings, the Alaska, Washington, West Virginia and Tennessee cases also paid TANF grants that a household run doesn't, though their asserted outputs matched. Since Charge Colorado families one child care parent fee under section 3.124 #10721, the Colorado case's single parent pays a $1,518 fee, and the model pays a $12,482 subsidy.
  • Household list. At the audit's base, household_state_benefits listed 23 of the 51 subsidies. Since Count all child care subsidies in household benefits #9503, the list counts all 51 through household_child_care_subsidies, up to the family's pre-subsidy bill for child care and after-school care.

Population impact

I computed these tables from saved full-file arrays for 2026 (populace_us_2024.h5@populace-us-2024-spm-20260909): main at 469ad12cb9, and this PR's taxes and benefits at 606699d640. Over a dataset this head's baseline expense equals min(W + E, C), and among variables only spm_unit_spm_expenses reads the expense, so the arrays give what this head's rule produces at that base. Main has since changed the Vermont, New Hampshire, Nevada and Texas subsidies, among others, and added cash programs to SPM resources. The branch has merged main seven times since those runs, most recently at 363e9fc5e4. Full-file runs at this head and its merge base wait until the host's disk can take them. They will confirm or replace these tables after the merge. The changes to the baseline arm since those runs don't move these tables, which show baseline policy: over a dataset, baseline policy leaves the expense at min(W + E, C) with or without an arm (invariant 7).

Measure Main This PR
SPM poverty, all people 14.540% 14.574%
SPM poverty, children 18.825% 18.908%
SPM poverty, adults 18 to 64 13.906% 13.932%
SPM poverty, 65 and over 11.264% 11.264%
Deep SPM poverty, all people 3.355% 3.355%
Deep SPM poverty, children 2.536% 2.536%
SPM net income $0.527B below main

All of the change comes from the three subsidies leaving resources. Main adds modeled Colorado and Washington subsidies ($270.7M and $255.9M) on top of what those families reported paying, and this PR stops that. From 2025 the two program lists match, so child_care_subsidies, childcare_expenses and SNAP equal main's on every record in 2026, with or without schedules. The deduction differs from main on 0 records, and SPM net income differs on 35. Five records (116,936 people, 64,207 children) enter poverty and none leave. Washington's rate moves from 12.00% to 13.44% on 4 records, and no other state's rate moves by 0.01 point.

With schedules set

The default dataset has no schedule columns, so most programs pay nothing. As a sensitivity, I gave every child under 13 in a unit with child care expenses a full-time schedule on both sides: 8 hours a day, 5 days a week, 21 days a month. I ran main at 469ad12cb9 and this PR's taxes and benefits at 640753a617.

Measure Main This PR
SPM poverty, all people 14.612% 14.648%
SPM poverty, children 19.060% 19.148%
Deep SPM poverty, children 2.676% 2.676%
child_care_subsidies $9.735B $9.735B
SPM net income $0.483B below main

Five records (126,465 people) enter poverty and none leave. Washington moves as above, and West Virginia's rate moves from 14.03% to 14.56% on 1 record.

Costs and limits of this rule

  • Other programs still net. SNAP, HUD adjusted income, state TANF and LIHEAP income tests, and dependent-care credits read childcare_expenses, which nets the modeled subsidy from the input over a dataset, as on main. This rule reads that input as what parents paid after any subsidy, so these programs net it twice wherever a program pays. Schedule data would widen the gap: with schedules set, child_care_subsidies rises $7.475B, SNAP falls $1.231B and taxes rise $0.462B. Add NSECE childcare attendance candidate and validation tools microcosm#916, a draft, fills those schedule columns, so these programs need the same treatment before any schedule release. That fix gets its own PR.
  • The household cap reads E too. household_child_care_subsidies (Count all child care subsidies in household benefits #9503) caps the subsidy household net income counts at the family's bill: its members' pre_subsidy_childcare_expenses plus after-school expenses. By default that person-level variable spreads E evenly across the unit's children, so the bill holds all of E for a unit with a child and none of it for a unit without one. Over a dataset, where E holds the reported amount, household net income counts the subsidy only up to that bill, or in full where the bill comes to zero.
  • Subsidies priced at the payment. Over a dataset the subsidy formulas take E, the reported payment, as the price of care, so S0, S1 and their difference all come from what parents paid. Where a program pays more than the bill, as Vermont's did in the audit, a reform that cuts the subsidy raises the expense by the whole cut, which can exceed what the family paid.
  • Full enrollment. The subsidy formulas pay every eligible family, with no take-up rate or waiting list of their own. So the dataset rule subtracts the full change in subsidy from every eligible family's reported amount, before the floor and the cap apply. A family that reported $100 and gains $1,000 in subsidy sees its expense fall by $100.
  • Run time. A reform run over a dataset now also computes subsidies in its baseline arm, and a plain run pays nothing extra. Over 5,000 households on a loaded Mac, spm_unit_net_income took 29.6 s in a plain run and 37.4 s in the reform arm of a no-change reform.
  • A variable a reform stores apart. Under a reform that redefines a variable in another entity or with other all-time storage, the arm calculates that variable, and construction raises where the caller gave it an input. "The baseline arm" above gives the guard's limits. No shipped reform does this.
  • A Social Security component stored apart. Under a constructed reform that stores social_security_retirement for all time, a dataset that gives the component raises at construction, naming it. tools/social_security_inputs.py records such an input on a source branch of its own, and the guard matches that record by name.
  • A reform given its own system. Microsimulation(dataset=..., reform=..., tax_benefit_system=...) loads the dataset under the system given, then applies the reform. apply_reform drops the holder of a variable the reform stores apart, with its record of the input, before construction rebuilds the arm. So under a reform that stores the subsidy for all time, nothing raises, and the reform and its arm both calculate the subsidy, where a plain run reads the dataset's subsidies.
  • Inputs set after construction. set_input on a reform simulation reaches only that arm. A caller who sets schedule columns on a reform simulation has to set them on simulation.baseline too, or the model computes S0 without them.
  • Entry points without an arm. Core builds the baseline arm only for a reform passed as reform=, and apply_reform builds none. A simulation built with reform= keeps its arm, under baseline policy, through any reform applied later. Microsimulation(tax_benefit_system=...) without reform=, or apply_reform on a simulation built without reform=, leaves no arm, so the expense keeps E, and subsidy changes don't move it. In policyengine_us, only tests call the first form.
  • A branch named "baseline". A branch's subsample replaces a calculation branch the caller named "baseline" with the arm, as core's subsample already drops every other calculation branch. The same copy runs wherever a simulation has a baseline that isn't its branches["baseline"]. So if a caller sets a top-level reform simulation's baseline by hand, its subsample rebuilds the arm under the policy of the baseline the caller set (read from code, not run). Outside its tests, this package sets baseline only to the arm or None. At the local clone's dd82d0e596 (2026-10-11), policyengine.py sets no simulation's baseline and calls neither subsample nor get_branch (read from a clone that may be stale). Now subsample raises ValueError on a simulation named "baseline" that has an arm, before it changes anything, and the message says to name the branch something else. Such a simulation comes from get_branch("baseline") on a branch, from a clone of one, or from a rename by hand. It also comes from get_branch("baseline") on a reform simulation after a caller deletes its branches["baseline"] (read from code, not run). Core rebuilds the arm with get_branch("baseline"), which returns that simulation itself. On main, get_branch("baseline") taken on a branch gave a simulation with no branches["baseline"], and main's subsample adds no copy. So its subsample returned with the reform and its parent's unsampled arm (read from main's code; a probe ran main's method in this head's runtime, not main's package). This head raises on that path, where main returned. A reform simulation renamed "baseline" keeps its arm in branches["baseline"], so on main too its subsample gave it baseline policy and cleared its arm (read from code, not run). At a92315ef96 the subsample gave each such simulation baseline policy and cleared its arm (run for a branch's get_branch("baseline") and a clone of it; read from code for the rename and the deleted entry). No shipped code subsamples such a simulation (read: subsample( and get_branch("baseline") outside the tests). If core raises after it builds the new arm, that arm keeps the old one as its own baseline, as on main (read from code).
  • Snapshots, situations and dumps. A snapshot keeps the dataset rule for this expense alone: county and main's other readers of is_over_dataset read a reload as a household. A marked reload's arm gets the snapshot's overrides, but sources and the provenance envelope reach both sides at construction. So a pure input or a Social Security component that a caller sets on a reform simulation after construction reaches the reload's arm, though the source's arm lacks it. A probe ran this at a7c00425d3. A dataset gave one person $1,200 of social_security_retirement, and a caller set $2,400 on the reform side. The marked reload's arm then read $2,400, where the source's arm read $1,200 (pure inputs read from code, not run). sample_person calls extract_person, so its situation carries the mark (a probe ran this at d10cddb410). A reform rebuilt from a situation that extract_person or sample_person took from a reform simulation gives its arm the reform side's values, so its arm also takes a formula value a caller set after construction. A probe at d10cddb410 set the first of two New York families' ny_ccap_countable_income to $40,000 on the reform side, where the source's arm calculated $30,000. A snapshot's reload matched the source's expense of $27,916.40, while a reform rebuilt from extract_person gave its arm $40,000 and an expense of $27,816.40. A reload has no dataset, and core's subsample reads the dataset's time period, and its name when the caller gives no seed. So a reload can subsample only where a caller attaches a dataset by hand. Even then, core's subsample raises a TypeError on the reload's string person ids, marked or not (probes ran both at d10cddb410). Core's restore_simulation builds no arm, so a restored dump of a reform simulation keeps the reported expense wherever it calculates it (read from core's code; the dump test restores a simulation with no reform). Two copies carry no mark and so read as a household: a Simulation(populations=...) built from another simulation's populations, and a situation built by hand from a snapshot's sources (both read from code, not run). At the local clone's dd82d0e596 (2026-10-11), policyengine.py calls none of extract_person, sample_person, export_source_inputs, reload_source_inputs, dump_simulation and restore_simulation. Its US household path builds its own situation from the six entity groups, so it never meets the mark (read, not run, from a clone that may be stale).
  • A stored expense. policyengine-us-data's CPS build also stores spm_unit_capped_work_childcare_expenses itself, from SPM_CAPWKCCXPNS (cps.py:786), and the model accepts it as an input. Over that file neither rule runs in the stored year, as on main.
  • Dataset inputs. The model reads any dataset input as a payment. PolicyEngine/ccdf-calculator's scripts/microsim.py raises this input to an assumed price over a dataset, but it reads subsidies and not the SPM, so this rule doesn't reach it.

Test cost

test_spm_child_care_subsidy_invariants.py stays in REST_REMAINING_HEAVY_TESTS, and it retains one reformed system and builds two more for the real-reform cases. Its tests ran for 206 s in CI at 6946cd74a4. Alone on a loaded Mac at a7c00425d3, its 12 tests took 109 s, and the process group peaked at 4.4 GiB. test_spm_child_care_reported_expense.py adds two tests: one reads only the expense and its inputs from a Microsimulation() over the whole file, and the other runs on a slice. In CI they took 7 s and 31 s. tests/core/test_reform_baseline_arm_inputs.py now holds 26 tests, against 23 at 165fd41b3d. Alone on a Mac at a7c00425d3 they took 221 s and peaked at 3.8 GiB. This PR changes three of the 47 tests in tests/core/test_employer_payroll_tax_incidence.py, which #10975 added; alone at a7c00425d3 the file took 126 s and peaked at 2.9 GiB. There tests/core/test_spm_system.py's 77 tests took 191 s and peaked at 3.5 GiB. tests/core/test_shipped_reforms_store_no_variable_apart.py parses the reforms' source rather than importing them. At a7c00425d3 its 3 tests took 2.9 s, and the process peaked at 1.2 GiB. tests/core/test_behavioral_response_measurement_copies.py needs more than 6 GiB alone, the local limit, so only CI runs it whole; locally, at a7c00425d3, main's test_baseline_measurement_drops_incompatible_holders passes its 2 cases in 9.8 s. Local runs used policyengine-core 3.37.1; main now requires 3.37.2.

What this PR does not change

  • Schedules on microdata. New York's subsidy now counts in household calculations, but in a default population run the model still pays it $0, because the default dataset has no schedule columns. With them unset in 2026, one audited family gets nothing from 31 state programs that pay it once it has a schedule, New York's among them. Of the other 20, 6 pay it less without a schedule, 2 pay more and 12 pay the same. So in a default run the baseline subtracts what parents reported, and a reform that changes New York's subsidy moves nothing until the data carries schedules.
  • Years before 2024. The SPM expense has no formula before 2024, so in those years a subsidy reaches the SPM only in Colorado, Washington and West Virginia. The Tlaib reform copies carry only Colorado in those years, as on main.
  • Subsampling after new person IDs. With or without a reform, subsample raises KeyError when a caller sets person_id after loading a dataset that carries a Social Security component input, such as social_security_retirement. The error comes from _select_subsample_sources in tools/social_security_inputs.py, a function this PR doesn't change. This PR no longer looks people up by ID itself. The error stops core's rebuild before core clears its caches, so a later read of a value calculated before the subsample fails core's size check. When I forced a raise at the same point, a later read returned the old value instead. Main behaves the same (read from core's code).
  • Texas copays before January 2025. Each Texas workforce board set its own parent share of cost until January 13, 2025, when the Texas Workforce Commission began phasing in a statewide scale. Since Apply Texas Workforce Board parent share of cost scales before TX3C #10623, the model applies six boards' scales from October 2023: Alamo, Borderplex, Brazos Valley, Dallas County, Panhandle and South Texas. It uses the statewide scale for all other boards and months, backdating it from January 2025 to 2015. I kept Texas in the 2024 list, because leaving it out drops the whole subsidy. This PR's 2024 Texas case uses the model's default county, Anderson, in the East Texas board, which has no board scale. The model applies the statewide scale there, and the case expects $5,793.01.

axiom: n/a: Census publishes the SPM as a statistical measure, and rulespec-us encodes no SPM provision.

🤖 Generated with Claude Code

MaxGhenis and others added 3 commits November 1, 2026 12:00
The SPM subtracts what parents paid for child care and lists no child care
benefit among its noncash resources. PolicyEngine subtracted pre-subsidy
expenses and added only the Colorado, Washington and West Virginia subsidies
to resources, so a subsidy in the other 48 states lowered SPM resources.

Net child_care_subsidies from the expense instead, and take the three states
out of spm_unit_benefits and the four reform copies of that list.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Add YAML cases for the formula's edges and for New York, Texas, Alaska,
Washington, West Virginia and Colorado through their real programs, and
property tests for the invariants. The whole-model form of "a subsidy never
lowers SPM resources" fails where SNAP, TANF and credits fall by more than the
expense, so the property holds those fixed and one test pins the intended case.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The differential passed on the old code because its identity holds when the
expense does not move. It now also requires the fall the Census definition
gives, with explicit examples in states that left the subsidy out and states
that counted it as a resource.

Income comparisons get a tolerance above float32 rounding, which tripped the
exact comparison at the fixture's $400,000 of earnings.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@MaxGhenis
MaxGhenis marked this pull request as ready for review November 1, 2026 18:15
MaxGhenis and others added 2 commits November 1, 2026 14:36
Reviews by GPT-6.1 Sol and Opus 5.5 found three problems at 343f8fe.

- Before 2024 the SPM expense has no formula, so removing the Colorado,
  Washington and West Virginia subsidies from resources made them reach no
  SPM path. A 2023 Washington subsidy lowered SPM income. Those three now stay
  resources until 2024, and years before 2024 match main.
- The 2024 program block left out the DC, Tennessee and Texas subsidies, which
  pay in 2024. All 51 now start at 2024, the first year the SPM expense reads
  the list, and the test checks every block from then on.
- The formula read the pre-subsidy input and ignored a direct out-of-pocket
  amount. It now reads childcare_expenses, the model's out-of-pocket variable,
  for a unit with a child.

Also add paying-subsidy cases for 2024 and 2025, correct the intended
violation's wording, record that datasets fill the pre-subsidy input from
reported spending, and route the property tests to the group for retained
full systems.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The baseline keeps Colorado, Washington and West Virginia subsidies as
resources before 2024, because the SPM expense has no formula then. The four
reform copies of spm_unit_benefits dropped them in every year, so each override
now restores what main carried: all three in the Texas rebate, Colorado in the
Tlaib copies.

Qualify the docstring's identity for a direct childcare_expenses input, and
correct the integration YAML header.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
MaxGhenis and others added 4 commits November 2, 2026 09:36
The list test reads list literals only, so it could not see the pre-2024
clause in the four reform copies. A 2024 case in each reform's YAML file now
fails if the clause loosens and a subsidy counts as a resource on top of the
lower expense.

Also qualify the docstring for person-level pre-subsidy inputs and for the
Tlaib copies, which carry only Colorado's subsidy before 2024, and note in the
integration header that one case sets no care hours.

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

# Conflicts:
#	policyengine_us/tests/policy/baseline/household/income/spm_unit/spm_unit_benefits.yaml
…idies

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Datasets fill spm_unit_pre_subsidy_childcare_expenses from the ASEC's
SPM_CHILDCAREXPNS, which already holds what parents paid after any subsidy, so
netting a modeled subsidy from it counted the subsidy twice. Over a dataset the
expense now keeps the reported amount under baseline policy, and a reform moves
it by the change in subsidy: min(W + max(E - (S1 - S0), 0), C). Household
calculations keep the input as a price and net the subsidy, as before.

Add properties for both rules and a differential between them, and a
microsimulation test over the shipped population.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@MaxGhenis MaxGhenis changed the title Count every state child care subsidy in the SPM Count state child care subsidies in the SPM once Nov 2, 2026
MaxGhenis and others added 3 commits November 2, 2026 23:51
…olicy side

Main's #9698 now branches a reform's baseline arm again after the
constructors move the pre-response inputs. Over a dataset, the SPM expense
reads its baseline subsidy from that arm, so pin it there:

- Add tests/core/test_reform_baseline_arm_inputs.py. Under a reform that
  changes nothing, the reform and its arm match a plain run on 102
  households of raw columns, two families in every state, and on a
  situation that names New York only through state_code_str. With
  _rebuild_baseline_branch disabled, both cases fail.
- Keep the parent's raw earnings and hours in the repeal test, which then
  fails in New York without the rebuild.
- Set work expenses and the earnings cap on the policy side only in
  property 8, with an example that fails if the rule reads either from the
  arm.
- Drop the dead branch_name guard, document the entry points that build no
  arm, and word the reported-spending reading as an inference from the ASEC
  question.
- Update _baseline_measurement_branch's docstring, which still said the
  arm keeps the raw inputs.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The docstring still named _rebuild_baseline_arm, which this branch dropped
when it merged main. Main's #9698 calls it
_rebuild_baseline_branch. Name the moved inputs through PRE_RESPONSE_INPUTS,
which also lists sstb_self_employment_income.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
MaxGhenis and others added 5 commits November 3, 2026 04:29
_rebuild_baseline_branch cloned the reform simulation and rebound the
clone's holders to baseline variables, but it kept each holder the reform
had built in another entity or with other ETERNITY storage. Construction,
subsample and _baseline_measurement_branch all drop those. Under a reform
that stores child_care_subsidies for all time, a New York family with a
$500 input got S0 = $500 from the arm, where baseline policy pays it
$13,916.40, so its reform expense came out $14,000.00 where the dataset
rule gives $27,416.40.

- Call _drop_holders_built_for_another_policy before _rebind_holders.
- Add test_the_arm_calculates_what_the_reform_stores_for_all_time, and
  check in every arm test that each holder suits its arm's variable.
- Check holder binding before subsampling as well. Under the redefining
  reform, the arm copied an empty yearly holder for the baseline's
  ETERNITY is_household_head.
- Document that apply_reform builds no arm while a simulation built with
  reform= keeps its arm, and word the input's after-subsidy reading as the
  model's.

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

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
#9503 lists household_child_care_subsidies in
every household_state_benefits block in place of the per-state entries. It
counts each subsidy up to the family's pre-subsidy bill. The differential
test's helper looked only for child_care_subsidies or the state's own
variable, so after the merge it returned 0 while household_net_income
counted the subsidy, and test_spm_and_household_measures_agree would miss
by that amount.

- subsidy_counted_by_household_measure now reads whichever child care
  variable the list names: household_child_care_subsidies, the aggregate,
  the state's variable or a program that variable adds. It fails if the
  list names two.
- test_no_subsidy_is_a_spm_resource also checks that no SPM benefit list
  names household_child_care_subsidies.
- test_household_measure_counts_each_subsidy_once checks that every
  household_state_benefits block from 2024 names
  household_child_care_subsidies once and no other subsidy variable or
  program.

Adding co_ccap_subsidy to the 2026 household block fails the new test, and
adding household_child_care_subsidies to spm_unit_benefits fails the SPM
check.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Sol's r7 review found that dropping a holder the reform built with other
ETERNITY storage also drops inputs that baseline policy can hold. With a
yearly $500 subsidy for 2026 in the dataset both runs read, under a reform
that stores child_care_subsidies for all time, the arm calculated $13,916.40
as S0 and the reform's expense came out $27,416.40 instead of $14,000.00.

A reform simulation now keeps each input whose variable baseline policy
defines in the same entity but with other ETERNITY storage. Every place that
drops such holders (the constructor's arm, the rebuilt arm, a subsample's arm
and the baseline measurement branch) then sets those inputs again, skipping
any the baseline's definition can't hold. subsample carries them over to the
sample by person ID, and keeps them when it fails before core rebuilds.

Also: #9503's program-list test checked no block on this branch and now
checks every block from 2024; invariant 9 states its price condition; the
changelog names the replay.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
MaxGhenis and others added 6 commits November 24, 2026 00:32
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The record of inputs a reform stores apart from baseline policy now keeps
what core stored, drops inputs core deleted or replaced, and reaches a
subsample through core's own export, so core samples and reweights them.
The behavioural-response measurement branch no longer sets them, as on
main, which fixes main's test_baseline_measurement_drops_incompatible_holders.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Main's New York CCAP changes (#10817, #10827) count the Family Assistance
grant a family takes up and waive the family share for it. TANF reads
employment_income_before_lsr, which a household simulation fills from
employment_income but the YAML runner leaves at zero, so the New York cases
now give pre-response earnings, as a household run stores them. Colorado's
single parent fee (#10721) sets that family's fee at $1,518. The
microsimulation test imports the fixture under its Microcosm name (#10687).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Core's apply_reform binds holders through _bind_to_tax_benefit_system,
which drops a holder the new definition cannot use, with its recorded
inputs. The docstring said apply_reform keeps a simulation's own inputs.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The in-session review of 5b05e30 found three ways the baseline arm's
record of stored-apart inputs went wrong, each reached only by a
constructed harness:

- An input core skipped, for a neutralized variable or a period after
  the variable's end, was kept with the value the holder stored for all
  time. set_input now keeps an input only when core's count of stored
  inputs rises.
- A write the record didn't see, such as one on the holder itself, came
  back into play once a later input passed the current-value check.
  Before keeping an input, the record now checks that its last input
  under the key is what the holder stores there, and starts the key's
  record again if not.
- Under a yearly reform of a variable baseline policy stores for all
  time, a holder write under another year was exported after the kept
  columns, so a subsample's arm ended with it. A variable whose holder
  holds an input the record doesn't account for is now calculated in
  the arm, and a subsample drops it from the record it rebuilds.

_input_key now uses core's storage period. Four arm tests pin these and
the removal of a failed subsample's export. Every case in the
integration YAML now gives pre-response earnings, since TANF reads them
and the YAML runner leaves them at zero; the asserted outputs don't
change. Docstrings now say which callers drop holders, that a flat
situation's inputs go through set_input, and why clone copies the list.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The in-session review of 3ba8fc7 found that the record keyed an
input by the period it was set for. A yearly holder can store one input
under several years, or under fewer than the period spans: given 24
months from January 2025 while 2026 already held an input, core stored
2025 alone. The record then held no input under 2025 and marked the
variable missed, so the arm calculated a role the plain run reads.
Core's count of stored inputs also rose for an input whose years the
holder's handler skipped.

Core stamps every value it stores with a sequence number. set_input now
draws the next number before the input and keeps it under each key
stamped since, for its year on a yearly holder and with the period set
for on a holder for all time. The value checks between calls stay as
they were, since core's apply_reform stores preserved inputs again with
new stamps. A write the record misses that stores the very array it kept
last still goes unnoticed; the docstrings now say so.

The role-order test now covers 12 and 24 months from January, and the
holder-write test covers an edit to the stored array in place. The
review's dispatch harnesses (one month, two years, 12 and 24 months, a
month before 2026, and dataset month columns) now give the arm the
plain run's role.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Core reweights a subsample's weight columns by parsing each period back
from its column name. Twelve months from January parse back as the year,
and from February as a year from February, so neither equalled the period
kept, and a reform storing weights for all time raised TypeError from
subsample. Match the period's name instead.

Core selects a subsample's households by the first household ID column of
its export, and the arm's kept columns come first, so a reform storing an
ID apart from baseline policy sampled by the IDs kept for the arm. The arm
now sets again no entity ID, membership ID or role; it shares the
reform's populations.

State as a limit that core's handlers divide or dispatch an input over
several periods around the inputs a holder already has, so overlapping
inputs can leave the arm reading other values than a plain run.

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

Copy link
Copy Markdown
Contributor Author

Handing this PR to the US + core hub (review round cap reached)

Head: 165fd41b3dda7b24aaff9885afe09af3b61b9b24. CI passes at this head (40 pass, 1 skipping), and the PR is MERGEABLE. The only block is review. Nobody should merge while a P1 is open.

Why it's moving. Max ruled on d2293 and d2288: "hold this head, keep the data as it is, and have the model gross up at run time; then I merge on the normal gates." Four review rounds have run since: r6, r7c, r8 and r9c. r6 to r8 raised only P2 findings, and each was fixed. r9c raised six P1s and one P2. The PR guide allows no round 5, so the hub now picks between a rework and a call for Max. Sol found the route intact in each of the four rounds, so this isn't a "route broken" return to Max.

Latest review. GPT-6.1 Sol r9c at this head: REQUEST_CHANGES, ROUTE: INTACT. The review is at ~/reviews/axiom-vision-2026-10/rework-1031/verify/ny-ccap/spm-fix/review-r9-sol.md. Earlier reviews are in the same folder: review-r8-sol.md, review-r7c-sol.md, review-r6-sol.md, review-r5-sol.md, review-r5-opus.md, review-r3.md, review-r2.md, review-r1.md and review-r1-opus.md. Round r4 was queued but cancelled on Max's instruction before it ran.

Open findings

The severity is Sol's. Each finding was reproduced independently at this head; the scripts, outputs and notes are in .../spm-fix/r12/verify/f1 through f7/progress.md. Each verifier also gave its own severity view, shown below, but a finding stays open until a reviewer closes it. The "New vs main" column says whether the verifier ran main's code (run) or only read it (read).

# Sol Who reaches it Reproduced New vs main Verifier's view
1 P1 Ordinary call Yes Yes (run) P2
2 P1 Constructed reform Yes Yes (read) P2
3 P1 Constructed reform Yes Yes (run) P3
4 P1 Constructed reform Yes Yes (read) P3
5 P1 Constructed reform Yes Yes (read); see note P3
6 P1 Ordinary call Yes Yes (read, plus main's formula swapped in on head) P2
7 P2 Constructed reform Yes Yes (read) P3

Notes on each finding:

  1. get_branch(...).subsample() raises ValueError. A branch made by get_branch shares its parent's baseline arm. Core's subsample rebuilds only branches["baseline"], so after sampling, the arm keeps the parent's population. The expense formula subtracts the arm's subsidy and gets two values for one SPM unit. Main carries the same stale arm but returns [500], because its formula never reads the baseline.
    • Reach: no shipped code subsamples a branch. When the populations differ the call fails loudly; it doesn't return wrong numbers silently.
    • Fix sketch (probed in process for an ordinary reform; the parent stayed unchanged): in SPMSimulationMixin.subsample, give a branch its own copy of the inherited arm under branches["baseline"]. _kept_record and _recorded_keys must then accept keys stamped with ancestor branch names. Without that second part, a reform that stores the subsidy apart moves from a crash to a silently wrong arm subsidy.
  2. Two spellings of one year corrupt the sampled baseline weight. The export takes the last array for household_weight__2025, and the weight lookup takes the first. Fix: collapse by str(period) in one place, and test with unequal values.
  3. A same-valued explicit ETERNITY write leaves a stale yearly receipt. The arm replays the old yearly input instead of calculating, and a different value makes it calculate, so the reform's expense moves by $13,416.40 on whether the two arrays are equal. On main the arm calculates in every variant after a subsample.
  4. Core restamps surviving inputs inside a handler that calls apply_reform. The record counts the restamped inputs as new. The outcome depends on the hash seed: wrong under seeds 0 and 1, right under seed 2. Fix sketch: if caches were reset during super().set_input, mark that variable missed.
  5. A handler stores an input, then raises. The input goes unrecorded.
    • Sol's exact case: the arm calculates the variable. Read, not run: main's arm calculates it too.
    • A variant (case CR in f5/progress.md) gives a silently wrong replay, which main can't produce. When the raising handler stores the array already kept for that year, the record looks consistent and keeps a stale order: the arm reads [True, False], while the control and a plain run read [False, True].
    • Fix: record the input in a finally. A probe of that fix was written but not run.
  6. The PR body's household formula omits a precedence rule. The code is intended, and the YAML expects $6,000. For a unit with a child, a supplied childcare_expenses replaces max(E − S1, 0), and a unit with no child ignores it. Invariants 1 and 4 in the body don't hold for that input.
    • This is also an unstated change from main. A caller that supplies only childcare_expenses (the partner signature shape) gets an expense of $6,000 at this head, where main's formula gives $0.
    • A child-level pre_subsidy_childcare_expenses input also departs from the body's table (case D in f6/progress.md).
    • Fix: edit the PR body and add YAML cases for the input shape that supplies only childcare_expenses. No code change is needed.
  7. No test covers the clone cleanup guard (spm.py:1356). Removing the line changes no test outcome. Fix: one small test.

What passed

Local runs at this head used policyengine-core 3.37.1. Results are in .../spm-fix/r11/summary.out, and logs are in r11/runs/.

  • Tests. The arm tests passed 23 of 23, test_spm_system.py passed 77, and the integration YAML passed 10 of 10. Main's test_baseline_measurement_drops_incompatible_holders passed 2 of 2.
  • Replay mutants. Of the 17 in-process replay mutants in r11/mutate_r11.py, 16 fail at least one test. native_first fails the three role-order cases, as the PR body records. old_input_key passes all 23: it keys inputs by the period set rather than by core's storage period, and the two keys agree because the record already keeps each yearly period as its own key.
  • Manhattan family. New York subsidy of $13,916.40. SPM expense of $83.60, against $14,000 without the subsidy. SPM and household net income each rise $8,321.86, and the family leaves SPM poverty.

Pending and owed

  • Population impact. The tables in the PR body come from runs at an earlier base, as the body says. Rerunning them at this head waits on disk space. Backlog brief: ~/chief-of-staff/state/chips/2026-11-24/rerun-spm-child-care-population-tables-for-10569.md.
  • Social Security inputs. Carrying Social Security inputs into a reform's baseline arm is a known limit listed in the PR body. Backlog brief: ~/chief-of-staff/state/chips/2026-11-24/carry-social-security-inputs-into-a-reforms-baseline-arm.md. Its harness, which the brief says sat in a scratchpad, has a durable copy at .../spm-fix/r10/scratch-r10-inline/verify-review-1/ss_min.py.
  • Dependencies. None. No hold applies to policyengine-us.

🤖 Generated with Claude Code

MaxGhenis and others added 25 commits November 25, 2026 21:37
… name

Remove the record and replay of inputs that baseline policy stores apart
from a reform: the constants, the record and replay methods, the
build_from_dataset and _to_person_dataframe overrides, the kept-input
lines in clone, the record steps in subsample, the keep wrapper around
set_input, and the replay call in system.py. set_input is main's again.

Keep the drop at its three arm sites (the constructor, subsample and the
country rebuild) and in the behavioural-response measurement branch. At
the three arm sites, call a guard first that raises a ValueError naming
each variable whose recorded input the arm would drop. The measurement
branch keeps main's drop-and-calculate.

A branch that shares its parent's baseline arm now hands core a copy of
that arm under branches["baseline"] before it subsamples, so core's own
rebuild gives the branch an arm on its sample. Before, the expense rule
read the parent's arm and raised on the size mismatch.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The guard read the reform simulation's holders and recorded inputs. That
refused an input main's subsampling test gives the reform's own yearly
is_household_head, which the arm drops and calculates on main. Read the
arm's own holders and _user_input_keys instead, so the guard refuses
only an input the arm itself holds and would drop.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The guard reads only the arm it is called on, so its source parameter
went unused: drop it from the guard and its three call sites. Its
docstring now says what it reads, that keys match by variable name
alone (the arm's copied keys keep the reform's branch name), and where
it fires: only the rebuild at the end of construction still holds the
holder and its keys, since core's _bind_to_tax_benefit_system drops both
wherever core builds the arm.

The changelog fragment described the input replay; it now describes the
guard and the subsampled branch's own arm.

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

The arm file's replay tests tested code this branch removed. It keeps
the two tests that a no-change reform's arms match a simulation with no
reform, and adds:

- four cases, a dataset or a situation giving a $500 subsidy for all
  time or for 2026 under a reform that stores the subsidy for all time,
  each refused at construction with a ValueError naming
  child_care_subsidies, raised from _rebuild_baseline_branch;
- the stated limit: an input set after construction and then subsampled
  raises nothing, and the new arm calculates the subsidy as a plain run
  does. Its first assertion, that construction leaves the arm no holder
  stored for all time, reaches the rebuild's drop in system.py;
- F1: a branch of a reform simulation that subsamples reads an arm on
  its own sample and gets the $500 expense a subsample of the reform
  gets, where before the expense raised on a size mismatch.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The arm's drop, and the guard that refuses an input it drops, matter only
under a reform that redefines a variable in another entity or with other
ETERNITY storage. A static scan of policyengine_us/reforms, which
imports nothing, finds no such reform, and fails on any variable change
it can't resolve to a class in the same file. A second test checks that
the scan flags the reforms the tests build for that purpose.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
For a unit with a child the household rule reads childcare_expenses, so
a caller who gives only that amount, $6,000, gets it as the expense;
main's formula read only the pre-subsidy amount and gave $0. A unit with
no child ignores childcare_expenses and nets its subsidy from its own
pre-subsidy amount.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A unit with no child nets its subsidy from its own pre-subsidy amount,
and no case had a subsidy above that amount. Add one: $1,500 against
$1,000 leaves only the $500 of work expenses.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
With the guard in place, the rebuild's drop matters only for a holder the
reform built for its own definition of a variable that holds no recorded
input. No test reached it: with the drop removed, the guard's-limit test
and main's subsampling test stayed green. The guard's-limit test's docstring, and
the message of the commit that added it, said its first assertion
reached the drop; under that reform construction leaves no subsidy
holder at all, so it doesn't.

Construction's input move asks the reform for the holder of
sstb_self_employment_income even where the caller gave none. Under a
reform that stores that variable for all time, the reform then holds an
empty holder for all time, which the arm copies when it branches after
the moves. The new test checks that the rebuild's drop keeps that holder
out of the arm. The guard's-limit docstring loses its wrong sentence.

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

For a unit with a child, the household rule reads childcare_expenses, which
sums the members' pre_subsidy_childcare_expenses less the subsidy. A caller
who gives a member's amount directly therefore replaces the unit's
spm_unit_pre_subsidy_childcare_expenses with the members' sum. The new case
gives the unit $10,000, the child $6,000, no subsidy, $1,000 of work expenses
and a $20,000 cap, and expects $7,000. Main's formula read only the unit's
amount and gave $11,000. No code change.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The scan read only plain assignments, so a reform class that declared
`definition_period: str = ETERNITY` escaped it. It now also reads an
annotated assignment with a value and a plain name target. The module
docstring lists the forms it still doesn't read. A new positive control
writes such a class to a temporary file and checks the scan flags it; the
path label now falls back to the full path for a file outside the package.
No class under policyengine_us/variables, reforms or tests uses the
annotated form, so the shipped-reform result doesn't change.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The comment said the redefining reform gets an empty yearly
is_household_head holder that the rebuilt arm must drop. On this test's own
path, after construction neither the reform nor its arm holds a holder for
is_household_head, with or without the rebuild's drop, so the check before
subsampling passes either way. The comment now says so and names the arm
test that pins the rebuild's drop. No assertion changes.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Brings in main through 363e9fc, including the subsample tests from #10975
and reform-system derivation, so this branch can move those tests to
its own subsample behaviour.

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

Core rebuilds a subsample's baseline arm from branches["baseline"]. A branch
shares its parent's arm and usually holds nothing under that name, so
subsample put a copy of the arm there. Where the caller had named one of the
branch's calculation branches "baseline", subsample skipped the copy, and
core rebuilt the arm from that branch under the reform's policy.

subsample now puts the copy in place wherever self.baseline is set and
branches["baseline"] is anything other than that arm. If core's subsample
raises while the copy is still in place, subsample puts back what the branch
held before (nothing, or the same calculation branch) and re-raises.

Tests: under a repeal of child care subsidies, a branch that named a
calculation branch "baseline" reads S0 of $6,000 and an expense of $12,000
after a subsample, as a subsample of the reform itself does, and the parent
keeps its arm on both households. A subsample given neither n nor frac
leaves each branch as it found it, sharing the parent's arm, and a retry
reads the same S0 and expense.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A subsampled branch now gets a baseline of its own on the same sample. So
test_a_subsampled_branch_matches_its_baseline_by_person and
test_a_subsampled_branch_finds_its_person_among_repeated_axis_ids check that
the branch's baseline holds the same people as the branch, by count and by
ID, in place of the parent's unsampled count. Their value assertions are
unchanged. The axes test drops its NotImplementedError arm for a kept ID the
parent repeats: identical ID lists align by position, so that arm no longer
describes the code, and the test's seed keeps an ID the parent has once.

for_each_person's docstring now says a subsampled branch aligns by position,
and that the ID lookup serves a baseline that lists other people, as after a
branch subsample that raised once core had resampled the branch. Its code is
unchanged.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
In a household situation, a person variable given for one member is an
input for every member, and the members given none hold 0. So with the
unit's $10,000, $6,000 given for one of two children, no subsidy, W of
$1,000 and C of $20,000, the second child's pre-subsidy amount is 0,
childcare_expenses is $6,000 and the expense $7,000, where main's formula
gives $11,000. No code change.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The variable's documentation and fica_pre_tax_totals' docstring said a
branch keeps its ancestor's baseline, and that a subsampled branch raises
for a person whose ID the baseline lacks or repeats. A branch now shares
its ancestor's baseline until its own subsample rebuilds one on the same
people from the inputs the branch then holds, as a reform simulation's
subsample does. So an input set on the branch counts as a change to
payroll wages until that subsample, and the ID lookup serves a baseline
that lists other people, as after a subsample that raised once core had
resampled the simulation.

Text only: no code, label, unit or reference changes.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A simulation with no reform has no arm and no "baseline" entry, so
subsample makes no copy and must put nothing back when core raises. The
test checks that core's ValueError for a call with neither n nor frac
reaches the caller and that the simulation still has no arm. Without the
restore's arm_copy check, the restore deletes a missing "baseline" key
and raises KeyError while handling core's ValueError.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Core rebuilds a subsample's arm with get_branch("baseline"), which returns
the simulation itself when that is its own name. A branch named "baseline"
under another branch shares its parent's arm, so its subsample gave it
baseline policy and dropped its arm. subsample now raises before it changes
anything and says to name the branch something else.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Over a dataset, spm_unit_pre_subsidy_childcare_expenses reads as what
parents paid after any subsidy; in a household, as the price before it.
export_source_inputs and extract_person turn a dataset simulation into a
situation, so its reload read the same inputs as a household's, and the
Manhattan family's expense fell from $14,000 to $83.60.

Both now write "_dataset_inputs": true for a simulation whose inputs came
from a dataset. This package's builders strip the key and mark the
simulation they build, inside core's __init__ and so before core clones it
into a reform's baseline arm. The expense reads one predicate,
holds_dataset_inputs; no other reader of is_over_dataset uses it. Snapshots
stay at version 1, and one without the key reloads as a household.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Over a dataset, core gives a reform's baseline arm each value the dataset
gives. export_source_inputs lists a value given for a formula variable among
the overrides, and reload_source_inputs set those on the reform side only, so
the reload's arm calculated them and the reform side read S0 from that arm.
A marked reload now sets each override on its arm too. Export lists, under
_baseline_arm_overrides, what the source's arm held for each override it
doesn't share (null for nothing), so a value a caller set on the reform after
construction stays off the reload's arm. A marked reload skips a variable
baseline policy doesn't define, and refuses one the reform stores in another
entity or with other ETERNITY storage, as construction over a dataset does.
An unmarked snapshot reloads as before.

The dump wrapper writes the dataset mark to __entities__/dataset_inputs.json,
and the restore wrapper sets it, so a restored dump of a dataset simulation
keeps the dataset rule. A mark other than true or false raises ValueError in
the builder, the reload and the restore.

The round-trip test now takes its branch before the reload calculates
anything.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Reorder the SPM child care expense's documentation so "that arm" follows the
arm it names, and say that export_source_inputs marks a snapshot,
extract_person a situation and dump_simulation a dump. A simulation restored
from a marked dump has no arm, as core's restore_simulation builds none, so
the documentation no longer gives it one. The Social Security levers page now
says what a marked reload gives a reform's baseline arm and where a dump holds
the mark, and the changelog fragment names the snapshot mark and the refusal
to subsample a simulation named "baseline".

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A Social Security component or pure input that a caller sets on a reform
after construction reaches both sides of a reload through the snapshot's
sources and provenance envelope, so the arm-override list doesn't cover it.
Say so, name the `_dataset_inputs` key, limit the refusal to values the arm
would get, and state what a reload with `reform=` gives the arm of a
snapshot taken without one.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A Social Security component that a caller sets on a reform after construction
gets a null in the arm-override list, yet reaches the reload's arm through the
provenance envelope, as a pure input does through the sources. Describe the
comparison, the listing and the skip in their own sentences, then the two
paths that bypass them, and say when a reload raises on the mark's value.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A reform rebuilt from an extract_person or sample_person situation of a
reform simulation gives its arm the reform side's values, so its arm takes
a formula value set on the reform after construction, where a marked
snapshot's arm keeps the source arm's value. A restored dump returns an
expense it already holds as dumped. Other dataset-only rules read the
reload, not the expense, as a household.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The comments on _baseline_arm_overrides, export_source_inputs and
_set_overrides_on_the_arm now say the snapshot lists each formula
override whose recorded input the arm lacks or records differently, with
the arm's recorded input or null, and that a pure input or Social Security
component set after construction reaches both sides of a reload.
Comments and docstrings only.

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.

1 participant