Repository navigation
Conversation
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>
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>
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>
…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>
_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>
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>
Handing this PR to the US + core hub (review round cap reached)Head: 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: Open findingsThe severity is Sol's. Each finding was reproduced independently at this head; the scripts, outputs and notes are in
Notes on each finding:
What passedLocal runs at this head used policyengine-core 3.37.1. Results are in
Pending and owed
🤖 Generated with Claude Code |
… 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>
…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>
Problem
For a Manhattan parent earning $30,000 with a child in full-time care at $14,000 a year,
ny_ccappays $13,916.40. On main at469ad12cb9(2.90.2), turning that subsidy on raiseshousehold_net_incomeby $8,321.86 and lowersspm_unit_net_incomeby $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. Sospm_unit_capped_work_childcare_expenseshas 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.min(W + max(E - S1, 0), C), ormin(W + X, C)for a unit with a child givenchildcare_expensesXmin(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_inputspicks the rule, andsimulation.baselinesupplies S0, as it does formedicaid_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_inputsmarks a snapshot of a dataset simulation with"_dataset_inputs": true, andextract_personmarks 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. Ata92315ef96the 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 ofis_over_dataset, such ascounty, still read a reload as a household. A snapshot without the mark, as main'sexport_source_inputswrites, reloads as a household, and so does one markedfalse. Any other value raisesValueError. Main'sreload_source_inputsreads 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 anextract_personsituation, 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_inputslists the formula variables' values as overrides, and at439c863eeareload_source_inputsset 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 ofny_ccap_countable_incomethrough 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", ornullwhere the arm records none. A marked reload gives its arm each listed value in place of the override and skips anullone. 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 withreform=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 otherETERNITYstorage, the reload raises aValueErrorthat 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).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 netschild_care_subsidiesfrom the unit's own input. A caller can give a unit with a child its out-of-pocket amount aschildcare_expenses, which then replacesmax(E - S1, 0). Main reads only E, so for a unit with a child given only $6,000 ofchildcare_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, sincechildcare_expensessums 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.co_ccap_subsidy,wa_child_care_subsidiesandwv_child_care_subsidiesfromspm_unit_benefitsand 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.child_care_subsidieslist 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 lowerschildcare_expensesfor 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_amountpins 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 inmicrocosm/build/us_runtime/childcare.pyandpolicyengine-us-dataindatasets/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 at606699d640, and by $7.280B with schedules set at640753a617. 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__andMicrosimulation.__init__then moveemployment_income,self_employment_income,sstb_self_employment_income,weekly_hours_workedandlong_term_capital_gainsto their pre-response variables, and fillstate_codefromstate_code_str. Atd4d391788d, 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, aspolicyengine-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 otherETERNITYstorage. The SPM mixin's constructor,subsampleand_baseline_measurement_branchall drop such holders. Under a reform that storeschild_care_subsidiesfor 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
ValueErrornaming the variable (_refuse_inputs_baseline_policy_drops). Under the reform that storeschild_care_subsidiesfor all time, a $500 subsidy given for all time or for 2026, through a dataset or a situation, raises. The guard has three limits:system.py:543), because at the arm's other two drop sites, in the constructor and insubsample, core has already dropped the holder and its record of the input.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_holderssets such an input after construction and expects the branch to calculate the variable assimulation.baselinedoes. 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/reformsredefines 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 inbranches["baseline"]. Sosubsamplehands 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'ssubsampleraises 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
NotImplementedErrornaming 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 givesfica_pre_tax_contributionsreaches 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_changeread $0 on the source and on the marked reload, where the marked reload read $71.06 at439c863eea. An unmarked reload still reads $71.06, as main's reload would (read from main's code).tests/core/test_employer_payroll_tax_incidence.pypasses whole ata7c00425d3, 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:
childcare_expensesand 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 achildcare_expensesinput, which replacesmax(E - S1, 0)for a unit with a child and which a unit with no child ignores.0 <= expense(0) - expense(S) <= S, and a larger subsidy never raises the expense.spm_unit_benefitsunchanged and raisesspm_unit_net_incomeby the fall in the expense, so the SPM counts it once.childcare_expensesand its members' pre-subsidy expenses to their formulas. A unit with a child given onlychildcare_expensesX getsmin(W + X, C), where main reads no X and givesmin(W, C).*_child_care_subsidiesvariable, and no program one of them adds, appears inspm_unit_benefitsor a reform's copy of it, and all 51 appear in every program block. Everyhousehold_state_benefitsblock from 2024 counts them only throughhousehold_child_care_subsidies, which Count all child care subsidies in household benefits #9503 added.household_child_care_subsidiescounts in the household measure, plus the fall in the expense.Over a dataset:
min(W + E, C), whatever subsidy the model pays, in a plain simulation and in a reform's baseline arm.In
tests/microsimulation/test_spm_child_care_reported_expense.py,Microsimulationloads 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.pychecks 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 throughstate_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:child_care_subsidiesfor all time, a $500 subsidy for all time or for 2026, from a dataset or in a situation, raisesValueErrornaming the variable from_rebuild_baseline_branch.sstb_self_employment_incomewhile 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."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 neithernnorfracraises and leaves each branch as it found it, and a retry gets the same S0 and expense.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.export_source_inputsandreload_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 fromextract_personwith 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. Markedfalse, a snapshot and a situation read $83.60 for the first family, and a mark of"true"or1raises in the builder and in the reload.ny_ccap_countable_incomeand $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 storeschild_care_subsidiesfor 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.dump_simulationbefore 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 with1in it the restore raises. A household simulation's dump holds no mark.tests/core/test_shipped_reforms_store_no_variable_apart.pyreads the source of every reform inpolicyengine_us/reformswithout 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 passesupdate_variable,add_variableorreplace_variableanything 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 thanVariableor a baseline variable. A second test checks that the scan flags the reforms that the arm tests andtests/core/test_spm_system.pybuild to store a variable apart, and a third that it flagsdefinition_period: str = ETERNITY.test_subsampling_never_changes_which_policy_a_holder_belongs_tointests/core/test_spm_system.pynow 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). At5a6557a92a, with_rebuild_baseline_branchdisabled, 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:"baseline"entry fails the test of a branch named"baseline", whose new arm then repeals the subsidy as the reform does."baseline".test_baseline_measurement_drops_incompatible_holders, which then raise onis_household_head.system.py:544), with the constructor's own drop in place, fails the rebuild's-drop test. The guard's-limit test andtest_subsampling_never_changes_which_policy_a_holder_belongs_tostill pass without it.test_subsampling_never_changes_which_policy_a_holder_belongs_to, which then raises on the reform's ownis_household_head.test_policy_over_a_dataset_moves_the_expense_by_the_subsidy_changeon an explicit example.childcare_expensescases and the two that give a member's pre-subsidy amount.test_the_scan_reads_an_annotated_assignment, which then misses a reform that storeschild_care_subsidiesfor all time that way.a92315ef96adds documentation text and one test to1b9dec8316. 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 raisesKeyErrorin place of core'sValueError.The head,
d367d8c1ba, changes only comments and docstrings intools/social_security_inputs.py, and the three commits below it,688fc8d7af,d10cddb410andcf7a43e027, change only the docs page's paragraph on snapshots.a7c00425d3updates the docs, the changelog and the capped-expense variable's documentation, and202b79eb80below it gives a marked reload's arm the snapshot's overrides, marks dumps and checks the mark's value.e9fc366e76added the subsample refusal toa92315ef96, and439c863eeathe snapshot mark. Ata7c00425d3I ran the arm test file,tests/core/test_spm_system.py, the invariant tests, the reach scan, the derivation tests andtests/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:"true"without raising, and the dump test, which accepts1.is_over_datasetalone in the formula fails it at the same branch.extract_person, fails theextract_persontest at $83.60."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. Listingco_ccap_subsidybesidehousehold_child_care_subsidiesin the 2026 household block fails the household list test, and listinghousehold_child_care_subsidiesinspm_unit_benefitsfails 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_incomepins one case.Audit of all 51 subsidies
I ran these audits on household calculations at
606699d640against main at469ad12cb9, 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.child_care_subsidiesleft 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.meets_ccdf_activity_testset. Every state pays somewhere on the grid, and the identity in invariant 6 holds in every cell.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.employment_income_before_lsr, which a household simulation fills fromemployment_incomebut the YAML runner leaves at zero. With a bareemployment_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_state_benefitslisted 23 of the 51 subsidies. Since Count all child care subsidies in household benefits #9503, the list counts all 51 throughhousehold_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 at469ad12cb9, and this PR's taxes and benefits at606699d640. Over a dataset this head's baseline expense equalsmin(W + E, C), and among variables onlyspm_unit_spm_expensesreads 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 at363e9fc5e4. 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 atmin(W + E, C)with or without an arm (invariant 7).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_expensesand 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
469ad12cb9and this PR's taxes and benefits at640753a617.child_care_subsidiesFive 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
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_subsidiesrises $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.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_expensesplus 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.spm_unit_net_incometook 29.6 s in a plain run and 37.4 s in the reform arm of a no-change reform.social_security_retirementfor all time, a dataset that gives the component raises at construction, naming it.tools/social_security_inputs.pyrecords such an input on a source branch of its own, and the guard matches that record by name.Microsimulation(dataset=..., reform=..., tax_benefit_system=...)loads the dataset under the system given, then applies the reform.apply_reformdrops 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.set_inputon a reform simulation reaches only that arm. A caller who sets schedule columns on a reform simulation has to set them onsimulation.baselinetoo, or the model computes S0 without them.reform=, andapply_reformbuilds none. A simulation built withreform=keeps its arm, under baseline policy, through any reform applied later.Microsimulation(tax_benefit_system=...)withoutreform=, orapply_reformon a simulation built withoutreform=, leaves no arm, so the expense keeps E, and subsidy changes don't move it. Inpolicyengine_us, only tests call the first form.subsamplereplaces a calculation branch the caller named"baseline"with the arm, as core'ssubsamplealready drops every other calculation branch. The same copy runs wherever a simulation has abaselinethat isn't itsbranches["baseline"]. So if a caller sets a top-level reform simulation'sbaselineby 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 setsbaselineonly to the arm orNone. At the local clone'sdd82d0e596(2026-10-11), policyengine.py sets no simulation'sbaselineand calls neithersubsamplenorget_branch(read from a clone that may be stale). NowsubsampleraisesValueErroron 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 fromget_branch("baseline")on a branch, from a clone of one, or from a rename by hand. It also comes fromget_branch("baseline")on a reform simulation after a caller deletes itsbranches["baseline"](read from code, not run). Core rebuilds the arm withget_branch("baseline"), which returns that simulation itself. On main,get_branch("baseline")taken on a branch gave a simulation with nobranches["baseline"], and main'ssubsampleadds 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 inbranches["baseline"], so on main too its subsample gave it baseline policy and cleared its arm (read from code, not run). Ata92315ef96the subsample gave each such simulation baseline policy and cleared its arm (run for a branch'sget_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(andget_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).countyand main's other readers ofis_over_datasetread a reload as a household. A marked reload's arm gets the snapshot's overrides, butsourcesand 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 ata7c00425d3. A dataset gave one person $1,200 ofsocial_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_personcallsextract_person, so its situation carries the mark (a probe ran this atd10cddb410). A reform rebuilt from a situation thatextract_personorsample_persontook 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 atd10cddb410set the first of two New York families'ny_ccap_countable_incometo $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 fromextract_persongave its arm $40,000 and an expense of $27,816.40. A reload has no dataset, and core'ssubsamplereads 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'ssubsampleraises aTypeErroron the reload's string person ids, marked or not (probes ran both atd10cddb410). Core'srestore_simulationbuilds 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: aSimulation(populations=...)built from another simulation's populations, and a situation built by hand from a snapshot'ssources(both read from code, not run). At the local clone'sdd82d0e596(2026-10-11), policyengine.py calls none ofextract_person,sample_person,export_source_inputs,reload_source_inputs,dump_simulationandrestore_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).policyengine-us-data's CPS build also storesspm_unit_capped_work_childcare_expensesitself, fromSPM_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.scripts/microsim.pyraises 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.pystays inREST_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 at6946cd74a4. Alone on a loaded Mac ata7c00425d3, its 12 tests took 109 s, and the process group peaked at 4.4 GiB.test_spm_child_care_reported_expense.pyadds two tests: one reads only the expense and its inputs from aMicrosimulation()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.pynow holds 26 tests, against 23 at165fd41b3d. Alone on a Mac ata7c00425d3they took 221 s and peaked at 3.8 GiB. This PR changes three of the 47 tests intests/core/test_employer_payroll_tax_incidence.py, which #10975 added; alone ata7c00425d3the file took 126 s and peaked at 2.9 GiB. Theretests/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.pyparses the reforms' source rather than importing them. Ata7c00425d3its 3 tests took 2.9 s, and the process peaked at 1.2 GiB.tests/core/test_behavioral_response_measurement_copies.pyneeds more than 6 GiB alone, the local limit, so only CI runs it whole; locally, ata7c00425d3, main'stest_baseline_measurement_drops_incompatible_holderspasses 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
subsampleraisesKeyErrorwhen a caller setsperson_idafter loading a dataset that carries a Social Security component input, such associal_security_retirement. The error comes from_select_subsample_sourcesintools/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).axiom: n/a: Census publishes the SPM as a statistical measure, and rulespec-us encodes no SPM provision.
🤖 Generated with Claude Code