Skip to content

Fix exact-limit asset tests and resource eligibility rules - #10639

Open
MaxGhenis wants to merge 22 commits into
mainfrom
round-summed-limits
Open

MaxGhenis wants to merge 22 commits into
mainfrom
round-summed-limits

Conversation

@MaxGhenis

@MaxGhenis MaxGhenis commented Nov 2, 2026 •

Copy link
Copy Markdown
Contributor

What and why

Before this PR, bank, stock and bond balances were stored as float32, and the float32 sum of $178.57, $1,547.79 and $273.64 was $2,000.000122, so the SSI resource test rejected an applicant who holds exactly $2,000. These three inputs now store float64 values. Some aggregates still store float32 and can drift when the model adds or stores the totals.

The drift occurs in float32 addition and in float64 sums stored back as float32. A sum that drifts below the limit can also pass a strict comparison. This PR covers asset and resource tests. Income-limit tests belong to a separate sweep.

Merge with main

The branch merges main at 6fa4eaf6d3, 89a15b72f5, c44636b2b7, 59d6806230 and ab596b0733. The merge at c44636b2b7 resolved nine conflicts, and the merge at ab596b0733 resolved two Idaho conflicts. The Idaho BBCE cutoff and the June and July boundary cases are present.

  • SSI keeps main’s spouse lookup and couple test. It compares the parental share with the limit remaining after whole-cent own and spousal resources.
  • Iowa SSA rounds the community and entry-month couple sums before adding the parental share, stored in float32 at or below the allocation.
  • Minnesota Supplemental Aid rounds the spouse total. Virginia Auxiliary Grant rounds the amount selected for the joint initial-month or individual budget.
  • Optional senior or disabled Medicaid rounds Missouri’s whole parental resources together with the marital-unit assets.
  • The medically needy, Connecticut SSP, Minnesota MSA and SNAP BBCE YAML files keep the cases from both branches. The medically needy parental cases have distinct names.

SSA divides parental excess equally among eligible children and divides it again when a child becomes ineligible. The regulation limits deeming to resources above the parental allowance. POMS SI 01330.200 B · 20 CFR 416.1202(b)(1)

The allocation loop uses integer cents for whole-cent allowances and limits. For example, $1,966.67 plus one third of $100 exceeds $2,000 by one third of a cent. Fractional-cent reforms use decimal subtraction and division before conversion to float64. SSI and medically needy Medicaid use the float64 share in their final tests. Iowa SSA uses its float32 share.

Change

  • round_to_cents returns dollar amounts rounded to cents as float64. Whole-cent asset tests use it to recover the represented total before comparing with a limit.
  • meets_limit_with_share accepts a positive infinite limit. Negative infinity and NaN fail the comparison.
  • Contra Costa, Marin, San Mateo and Santa Clara preserve fractions of a cent from average vehicle values. They round the sum when the stored vehicle amount represents whole cents. San Mateo recovers cents before it divides and applies the existing vehicle deduction.

Sites fixed

The PR changes 85 Python files. Of those, 82 are under policyengine_us/variables: seven federal, 55 state, 15 county and five household files. San Bernardino has three resource comparisons in one formula.

Federal sites cover SSI eligibility and parental deeming, SNAP and BBCE, Medicare Savings Programs, medically needy Medicaid and optional senior or disabled Medicaid. California’s Medicare Savings Program test sums the component balances in cents. Idaho’s non-cash SNAP categorical eligibility ends July 1, 2026.

State TANF and other cash assistance sites cover AK, AR, AZ, CA, CT, DC, DE, FL, GA, IA, ID, IN, KS, KY, ME, MI, MN, MO, MS, MT and ND. They also cover NE, NH, NJ, NM, NV, NY, OK, OR, PA, RI, SC, SD, TN, TX, UT, VT, WA, WI, WV and WY.

Other state sites cover CA CAPI, CO OAP, CT SSP, IA SSA and parental deeming, IL AABD, MD PAA, MN MSA, MS HMW, NC Special Assistance, NH SSP and VA Auxiliary Grant. Colorado OAP pools intact spouses’ resources under the strict married cap. A legal separation decree reported by either spouse excludes the separated spouse’s resources and income and applies the strict unmarried resource cap.

County sites cover Alameda, Contra Costa and Santa Clara personal property. They also cover Los Angeles cash and assessed home value, Marin liquid assets and personal property, Orange County resources, Riverside property, San Bernardino resources, San Francisco CAAP personal property and San Mateo property. Orange County exempts one qualifying vehicle’s net equity and honors explicitly reported zero total equity. When the qualifying vehicle’s equity is unavailable, the model uses the total net equity as a proxy for one vehicle. A single vehicle over the exemption threshold counts in full. San Mateo’s tests state the assumed deduction from additional-vehicle equity.

Sites outside this change

  • Los Angeles General Relief personal property uses a strict comparison. Both county sources include $2,000 in the limit. The comparator needs review. County eligibility page · County property manual
  • Los Angeles compares a single vehicle-value input and an ownership count. San Francisco compares a vehicle count and an average.
  • is_ccdf_asset_eligible, ia_cca_asset_eligible, il_hbi_resource_eligible, in_ccdf_asset_eligible, ma_ccfa_asset_eligible and tx_ccs_asset_eligible compare one stored spm_unit_assets input.
  • oh_ccap_eligible sums accounts against $1 million. Float32 cannot hold every cent at that size.
  • The state sweep still needs cases for ca_wdp_asset_eligible, dc_ccsp_asset_eligible, il_hbwd_asset_eligible, ma_eaedc_assets_limit_eligible, ms_wd_resource_eligible and wi_shares_asset_eligible.
  • It also needs cases for mo_ssp_resource_eligible, mo_liheap_eligible, mt_liheap_eligible, nc_lieap_eligible, oh_rss, sd_ssp_care, _wi_cts and the Iowa LIHEAP savings threshold.
  • Michigan’s home heating and homestead credits use income for their household resource tests.

Below $32,768, the error from three float32 inputs and two float32 additions stays below half a cent. Some California and New York Medicaid and MSP limits exceed that bound.

Overlapping PRs

Tests

The branch adds 206 net named YAML cases relative to main. They cover totals at the limit and one cent away, cases with fractional vehicle amounts, and Orange County, San Mateo, SSI, medically needy Medicaid, Colorado OAP, Idaho BBCE and California MSP regressions.

The Idaho SNAP and joint SSI files include the earlier float32 totals as direct regression inputs. SSI tests cover fractional-cent equality for one child and for three children, as well as the existing just-over-limit cases. The deeming cases cover children who stay in or leave the division, an SSI child at $2,000.0001, and a New York Medicaid share fractionally above $33,038.

The rounding property checks 2,000 three-part splits. Two direct helper cases cover the infinite individual limit and mixed limits.

Validation

At 317618787b and on its merge with main at 8e81d66, 57 YAML files pass 770 cases. Two Python helper files pass three tests, Ruff passes, and eight mutants fail their intended regression cases.

An earlier run at 676bf30 and on a merge with main at e530416 passed 869 cases in 54 YAML files and 263 tests in four Python files. In that run, named cases rejected 30 behavior-changing mutants, and restoring each of six original behaviors failed a regression. Riverside’s old inline rounding and the shared helper pass the same 12 cases. The two county partner files that read the changed variables pass with their existing expectations.

Household results change at the tested asset limits, Idaho’s July cutoff, Orange County’s vehicle-input cases, and Colorado’s legal-separation resource and income cases. California MSP changes in both directions at the January 2026 boundary. Population impact is not measured.

axiom: TheAxiomFoundation/rulespec-us#1626 queued for SSI deeming
axiom: needed for Colorado spouse resources and legal-separation income deeming, the Idaho cutoff and Orange County’s vehicle rule


🤖 Generated with Claude Code

Balances are stored as float32, so three accounts that add to exactly a
limit in cents can sum a fraction of a cent above it (178.57 + 1,547.79 +
273.64 = 2,000.0001) and fail an "at or below" test, or below it and pass
a "below" test. Add a shared round_to_cents helper and apply it where SSI,
SNAP, Medicaid, the Medicare Savings Programs, BBCE and 47 state programs
compare summed resources with a dollar limit. Each site has a YAML witness
at the limit that fails on main, and a cent-over (or cent-under) case.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01LwQq6HXUrFaqEeR9DeqWcq
…ically needy witness to Hawaii

The Arkansas case counted the unit as an SSI recipient, which bars the
medically needy pathway, so it couldn't show the asset boundary. Hawaii
has the same 2,000 limit and reaches it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01LwQq6HXUrFaqEeR9DeqWcq
snap_assets sums person inputs to the SPM unit in float64 before storing
float32, so the Idaho witness needs a split that drifts on that path too.
Hypothesis favours edge splits that never drift; pinned examples make the
model property fail without the rounding.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01LwQq6HXUrFaqEeR9DeqWcq
@MaxGhenis

Copy link
Copy Markdown
Contributor Author

Ready for hub review

Head: 56f56d1c657a6f45f29fe98c99be88c286b89ab1

What the item asked, and how it's resolved

  • Sweep exact-limit comparisons of summed asset inputs (SSI, Medicaid and SNAP first). I grepped 83 variables that compare asset or resource values with <= or <. For each, a script found the dollar limit for a single adult, built a three-way cent split that drifts on both summing paths, and checked whether the result flips on main. 55 sites flip and are fixed; the rest are listed below.
  • Witness, then round, using one shared helper. The helper is round_to_cents at policyengine_us/tools/general.py:17. It follows the existing form at is_optional_senior_or_disabled_asset_eligible.py:21-22, and that file now calls it (line 22). Fixed sites (file:line of the rounding):
    • meets_ssi_resource_test.py:29
    • ssi_resources_deemed_from_ineligible_parent.py:124 (also the child's own resources and own plus share in the reallocation loop)
    • meets_snap_asset_test.py:30
    • msp_asset_eligible.py:28
    • is_medically_needy_for_medicaid.py:61
    • meets_tanf_non_cash_asset_test.py:28
    • 49 state sites, each in its *_resources_eligible/*_asset_eligible file (CA CAPI and CalWORKs, CO OAP, CT SSP, IA SSA, IL AABD, MN MSA, MS HMW, NH SSP, plus 41 TANF-type tests). The full list is in the PR body.
  • Sites with no witness are left and listed. The list is in the PR body under "Sites left unchanged".
  • Hypothesis property. policyengine_us/tests/unit/test_round_to_cents_properties.py.
  • Make Riverside General Relief eligible at exactly $500 of property #10582's files. Not touched.

Witnesses (hand computation)

Site Split Total float32 sum on main
SSI $2,000 178.57 + 1,547.79 + 273.64 2,000.00 2,000.0001 → fails
SSI deemed parent child 575.52 + 570.57 + 353.91 = 1,500.00, plus excess 2,500 − 2,000 = 500 2,000.00 own 1,500.0001 → fails
SNAP FY2025 $3,000 2,607.87 + 29.87 + 362.26 3,000.00 3,000.0002 → fails
MSP 2025 $9,660 2,885.40 + 5,798.41 + 976.19 9,660.00 9,660.001 → fails
Medically needy, HI $2,000 178.57 + 1,547.79 + 273.64 2,000.00 fails
BBCE, ID $5,000 4,338.99 + 609.03 + 51.98 5,000.00 5,000.0005 → fails
NH FANF, < $1,000 719.22 + 208.18 + 72.60 1,000.00 just under 1,000 → wrongly passes
MS HMW, < $4,000 1,843.69 + 2,145.15 + 11.16 4,000.00 just under 4,000 → wrongly passes

Each state file has a comment above its case giving the split and the total.

Tests run

All YAML runs were one file per process; Python tests ran with pytest, one file per process.

  • On the branch:
    • 6 federal files: SSI 10, deemed parent 40, SNAP 8, MSP 27, BBCE 15 and medically needy 39 cases, all passing;
    • is_optional_senior_or_disabled_asset_eligible.yaml: 59 passing;
    • 49 state files: all passing, 411 cases across those files and the medically needy file.
  • On main (a detached worktree of origin/main, with the branch's test files):
    • each of the 6 federal files fails exactly its at-limit case and nothing else;
    • a combined file of the 49 state witness pairs fails exactly the 49 at-limit cases (47 inclusive, 2 strict), and all 49 cent-over/under cases pass.
  • Property file: 2 passed on the branch; 1 failed and 1 passed on main (the model property fails, assert False == True; the helper-only property can't fail on main).
  • Code-health: test_source_conflicts.py 103 passed, test_rest_python_groups.py 62, test_no_builtin_sum_over_entity_calls.py 1, test_selective_test_batches.py 18.
  • Format and lint: ruff format and ruff check are clean on the changed Python files.

Mutants

Each ran in its own process, and the code was restored afterwards.

  • The helper rounds to whole dollars (np.round(..., 0)): the cent-over case fails in meets_ssi_resource_test.yaml and in ca_tanf_resources_eligible.yaml, and the model property fails.
  • No rounding (main): every at-limit witness fails, as listed above.

Cost of the new Python test

Measured locally on this 4 vCPU VM (not Linux CI): 2 tests in 12-19 s; the whole process took 67 s with startup; peak RSS 1.2 GiB. It was measured before the pinned example was added, which adds one simulation. The file lands in the remaining rest-python group by path.

CI

The PR is a draft, so CI hasn't run.

Judgment calls

  1. Round at the comparison, not in the summing variables. Rounding spm_unit_cash_assets or ssi_countable_resources would store float32 again, and later sums (marital-unit totals in float64) drift too. Two-way float64 sums of float32 values can land off a cent total, so rounding the compared value is the robust place.
  2. The helper returns float64. The exactness guarantee holds for three parts below $16,384. Random checks found no failures below $32,768, but some at $65,536. The large California Medicaid limits ($130,000) are above that bound, so the rounding helps there but doesn't guarantee exactness.
  3. Operators are kept. No < was changed to <= or the reverse. NH FANF and MS HMW stay strict.
  4. The medically needy witness is in Hawaii, not Arkansas. The Arkansas unit came out as an SSI recipient, which bars the pathway.
  5. The model property pins a drifting example. Hypothesis favours edge splits (0, 0, total), which never drift, so without the pin it passed on main.
  6. Axiom line. The item gave no axiom: line. I wrote axiom: n/a: numeric representation only, since no provision's reading changes; please replace it if you file pe-parity.
  7. Partner contract tests. I didn't run or edit them. A partner case would move only if it held split balances totalling exactly a limit.

Proposed follow-ups

  • Round summed income before exact income-limit tests. Gross and net income tests compare float32 sums of several income sources with dollar limits, the same pattern as the asset tests. Sweep them with the same witness harness and helper.
  • Build witnesses for the remaining SSI-family resource sites. MD PAA, NC SA and VA AG read ssi_countable_resources against $2,000-type limits, but need fuller households to reach the test. Build witnesses for them and apply round_to_cents.

Generated by Claude Code

@MaxGhenis
MaxGhenis marked this pull request as ready for review November 3, 2026 00:28
@MaxGhenis

Copy link
Copy Markdown
Contributor Author

Hub review in progress

Head reviewed: 56f56d1c657a6f45f29fe98c99be88c286b89ab1 (matches the hand-off).

Findings so far (not final):

  • P2, non-boundary change in SSI parental deeming. ssi_resources_deemed_from_ineligible_parent.py:154 rounds own_resources + share, and meets_ssi_resource_test.py:29 rounds personal + deemed. share = excess / count is a real division, not float32 noise. A parent with $2,100 and three ABD children each holding $1,966.67 gives each child a $33.3333 share, $2,000.0033 in all. Main fails all three children on resources; this head passes them. The body's "numeric representation only" claim doesn't cover this.
  • P2, textual conflicts with open Apply 416.1163(e)(2) to deemed SSI and identify SSI couples by marriage, not tax roles #10141 in 6 files, including the same lines of meets_ssi_resource_test.py. Apply 416.1163(e)(2) to deemed SSI and identify SSI couples by marriage, not tax roles #10141 replaces the marital-unit sum with personal_resources + personal_resources[spouse], a float32 add, so whichever PR lands second has to keep round_to_cents around the new expression.
  • Exactness bound (checked). Three float32 parts with two float32 adds err by at most 5 half-ulps, so the guarantee holds below $32,768 (5 × 2^-10 = 0.00488 < 0.005), not only below $16,384. SPM-level sums go through float64 and cast once, so 6 or 12 parts drifted no more in my runs. Above $65,536, float32 can't hold cents. Fixed sites with limits above $32,768: MSP and medically needy in CA ($130k/$195k), and medically needy in NY ($33,038/$44,796). In 100,000 random three-way splits per case, rounding never put a result on the wrong side where main got it right.

Still running: the head and main YAML runs, mutants, and the property test.


Generated by Claude Code

@MaxGhenis

Copy link
Copy Markdown
Contributor Author

Ready for hub review
VERDICT: REQUEST_CHANGES
56f56d1
METHODOLOGY_CHOICE: yes

The head hasn't moved past 56f56d1c65. The core change is sound: one helper, rounding at the comparison, every operator kept, and each witness I sampled fails at main for the stated reason. I'm asking for changes for three reasons. Two SSI-family sites the brief put first still flip, and both have cheap witnesses. One rounding site changes results that aren't float noise. And two statements in the body are wrong.

METHODOLOGY_CHOICE is yes because of P2-1: rounding own_resources + share to cents settles how a fractional per-child share of parental excess counts, and no source I could read settles that.

Findings

P2-1. SSI parental deeming: rounding absorbs a real third-of-a-cent share, not float noise

policyengine_us/variables/gov/ssa/ssi/eligibility/resources/deemed/ssi_resources_deemed_from_ineligible_parent.py:154 and meets_ssi_resource_test.py:29.

share = excess / max_(1, count[pool]) is a real division. Rounding own_resources + share (and personal_resources + deemed_resources) to cents turns a true total of $2,000.0033 into $2,000.00. Main fails these children on resources; this head passes them. Nothing in the body or changelog says so, and the body's axiom: n/a: numeric representation only; no provision's reading changes doesn't hold for this path.

Witness: in 2026-01, a parent (not ABD) has a $2,100 bank account, giving $100 of excess. Three ABD children each hold $1,966.67 in a single account, so no float32 sum is involved. Each child's share is $33.3333.

head: ssi_resources_deemed_from_ineligible_parent = [0, 33.333332 ×3]; meets_ssi_resource_test = [F, T, T, T]  (1 passed)
main: meets_ssi_resource_test@2026-01: [0. 0. 0. 0.] differs from [0. 1. 1. 1.]

Counting the share to the cent may well be right, since SSA works in cents. But it is a rule about how a share is counted, not a float artefact. Either cite a source for counting the share to the cent, state the choice in the body, and pin it with a YAML case like the one above, or limit this site's rounding to the float32 sums it was meant for. Also replace the axiom line, for example: axiom: n/a: float32 representation only, except that a fractional per-child parental excess share now counts to the cent (416.1202(b)).

P2-2. MD PAA and VA AG still flip, and each witness takes three inputs

The body lists md_paa_eligible and va_ag_eligible under "Composite eligibility I couldn't satisfy with a single adult". Both are reachable with one adult. Each compares an unrounded ssi_countable_resources with the $2,000 SSI limit: md_paa_eligible.py:51 and va_ag_eligible.py:12-13. The brief put SSI-family resource tests first.

I held every other input fixed and compared $2,000 in one account with 178.57 + 1,547.79 + 273.64, using a Python Simulation, person aged 70, is_disabled, 2026-01, at this head:

md_paa_eligible  (MD, ssi=800 for 2026-01, md_paa_living_arrangement=CARE_HOME_LEVEL_B)        whole,split = [True, False]
va_ag_eligible   (VA, va_ag_certified=True, is_ssi_aged_blind_disabled=True, ssi=0, social_security=30000)  whole,split = [True, False]

Fix: ssi_resources = round_to_cents(person("ssi_countable_resources", period.this_year)) in MD, and resources = round_to_cents(where(joint, person.marital_unit.sum(resources), resources)) in VA. Add the at-limit and cent-over YAML pairs. I found no cheap witness for nc_sa_eligible: the adult-care-home SSI recipient passes both ways, and the over-income case failed for another reason. Leaving NC listed is fine.

P2-3. Income tests weren't swept, though the brief asked for them

The brief's item 1 asks to sweep "<= and < comparisons of summed asset or income inputs". The body says "Income tests weren't swept." The disclosure is honest, but this part of the brief is undone. Either sweep the income tests here or have the hub take the hand-off's proposed follow-up ("Round summed income before exact income-limit tests") as a tracked item before landing.

P3-1. The exactness bound is twice as wide as stated

The test comment (test_round_to_cents_properties.py:30-32) and hand-off judgment call 2 say the guarantee holds below $16,384. For three float32 parts and two float32 adds, the error is at most 5 half-ulps. Below 2^15 the half-ulp is at most 2^-10, so the error is at most 5 × 2^-10 = 0.00488 < 0.005. The guarantee therefore holds below $32,768.

Measured on the model at this head, with 3,000 random three-way cent splits per total in ssi_countable_resources: no misrounding at $2,000, $10,000, $16,383.99 or $32,767.99, and 64 of 3,000 at $65,535.99. SPM-level sums such as spm_unit_cash_assets add in float64 and cast once, so 6- or 12-account units drifted no more than 3-account ones (300 units each at every total up to $65,535.99, none misrounded). Four or more accounts don't break the claim on either path.

Fixed sites with limits above $32,768: MSP and medically needy in CA ($130,000 / $195,000) and medically needy in NY ($33,038 / $44,796). Above $65,536, float32 can't hold cents at all. In 100,000 three-way splits per case, rounding never put a result on the wrong side where main got it right, but at $130,000 about 5% of exact-limit splits stay wrong on both. The body's "rounding helps there but doesn't guarantee exactness" is accurate.

Suggested comment text: Below 2**15 dollars a half unit is at most 2**-10, so the sum stays within 5 / 2**10 < 0.005 of the total, with MAX_CENTS = 2**15 * 100 - 1.

P3-2. Open #10141 overlaps six files

#10141 touches meets_ssi_resource_test.py (the same countable_resources = where(...) lines), is_medically_needy_for_medicaid.py and its YAML, ct_ssp_resource_eligible.py, ia_ssa_eligible.py and mn_msa_resource_eligible.py. #10141 replaces the marital-unit sum with personal_resources + personal_resources[spouse], a float32 add that drifts the same way. Whichever PR lands second must keep round_to_cents(...) around the new expression. Other open PRs on changed files: #10146 and #10159 (ssi_resources_deemed_from_ineligible_parent.py), #10640 (is_medically_needy_for_medicaid.py), #10394 (its YAML), and #9939, #10038 and #10195-#10203 (tools/general.py; this PR only adds a function there).

P3-3. The model property mostly repeats the YAML witnesses

test_split_accounts_match_one_account builds a Simulation per example. The hand-off says its random draws don't drift, so only the pinned @example catches anything, and the YAML at-limit cases already cover that. CLAUDE.md says not to add a Python test when YAML exercises the same behaviour.

Local cost on this VM (not Linux CI): the file took 85 s wall including startup and uv run, with 2 passed in 23.4 s. It lands in remaining, whose shaped budget is 15 s per file. I'd drop the model property, or shrink it to the pinned example alone with max_examples=0. The helper-only property is cheap and worth keeping. If the model property stays, it belongs in remaining-heavy, like unit/test_medicaid_abd_ssi_rate_standard_properties.py.

P3-4. Small items

  • pa_tanf_resources_eligible.py:15-16 has a stray blank line between the comment and the code it describes.
  • The deemed-parent YAML adds only the at-limit case, with no cent-over companion, unlike the other 54 files.

Checked and sound

  • Defect at main. I copied the new cases from 16 sampled files (SSI, deemed parent, SNAP, MSP, medically needy HI, BBCE ID, CA CalWORKs, CO OAP, CT SSP, IA SSA, IL AABD, MN MSA, MS HMW, NH FANF, NH SSP, NM Works) and ran them at origin/main. Each at-limit case fails: inclusive sites return [0.] where 1.0 is expected, and NH FANF and MS HMW (strict <) return [1.] where 0.0 is expected. Each cent-over or cent-under companion passes.
  • Sampled sites at the head. The rounding sits at the comparison each witness reaches. Every comparison of the same sum in the file uses the rounded value: nm_works rounds the liquid side, and its non-liquid side returns 0. Sites behind a where or defined_for: nh_fanf (limit from where), mn_msa (receives_ssi | ...), co_oap/ia_ssa/nh_ssp (defined_for). Multi-comparison sites: is_medically_needy_for_medicaid (only the asset side changed; income isn't in scope), is_optional_senior_or_disabled_asset_eligible, and the deemed loop.
  • Limit side. Every fixed site compares against stored whole-dollar parameters or whole-dollar arithmetic on them: nd base + increment × n, il_aabd p1 + pn × size, ne .calc, msp max_ of parameters, and ca_tanf_resources_limit, whose stored values are 16,333-18,829. I found no uprated or fractional limit, so I have no limit-side witness.
  • Head tests. All 55 changed YAML files pass, one per process: 511 cases, 0 failures. The property file passes 2 of 2. At main, with only the helper added, it fails on the pinned example: AssertionError: ('meets_ssi_resource_test', (17857, 154779, 27364)). That is a real failure on Linux with the default float settings.
  • Mutants, each in its own worktree and process, restored afterwards:
    • Helper rounds to whole dollars (the hand-off's mutant): killed by meets_ssi_resource_test.yaml, msp_asset_eligible.yaml, nh_fanf_resources_eligible.yaml, meets_tanf_non_cash_asset_test.yaml and the property.
    • Mine, rounding to 3 decimals: survives SSI, NH FANF and BBCE, and is killed by msp_asset_eligible.yaml (9,660.001) and the property.
    • Mine, truncating to cents with np.floor(x*100)/100: killed by nh_fanf_resources_eligible.yaml (the strict site) and the property (2 failed).
  • Helper. round_to_cents returns float64 for float32 arrays, scalars and ints. It passes inf, -inf and nan through unchanged. Its result works with <=, <, where and max_. policyengine_us.model_api already star-imports tools/general.py, so the 55 files add no import, no cycle and no extra load step.
  • Amounts within half a cent. A single stored $2,000.004 (float32 2,000.00403) now rounds to $2,000.00 and passes. In practice that only moves a unit whose stored balance lies within $0.005 of a limit.
  • Unchanged list. spm_unit_assets is a pure input with no formula or adds, so the six CCDF-type sites sum nothing upstream.
  • Scope. Nothing changed under .github/ or policyengine_us/tests/policy/baseline/partners/. ruff format --check and ruff check are clean on the 58 changed Python files.
  • CI. The Pull request run at this head (41553122325) completed with every job successful, including Household API Partners and the Rest shards.
  • Impact. Baseline output can move only for a unit whose compared total lies within half a cent of a limit, or for the P2-1 deemed-share case. On imputed balances the pairs should read zero or nearly zero. Variables an impact run should read, all present at both main and this head: meets_ssi_resource_test, ssi, meets_snap_asset_test, snap, msp_asset_eligible, is_medically_needy_for_medicaid, is_optional_senior_or_disabled_asset_eligible, medicaid, tanf, and the state *_resources_eligible variables listed in the body. Both impact: and axiom: lines are present.

What I couldn't check

  • Primary sources. This session's network blocks ecfr.gov, secure.ssa.gov, gc.nh.gov, govinfo.gov, uscode.house.gov, law.cornell.edu, medicaid.ms.gov and web.archive.org. I couldn't verify the operators against law: NH's "shall be less than" and MS HMW's strict test rest on the code's own quotes. Nor could I check whether SSA rounds a per-child deemed share (P2-1).
  • Population data. No microsimulation or population file is available here, so the impact claim above is reasoning, not a measurement.
  • CI timing. I didn't see CI's timing and memory reports for the property file; the numbers in P3-3 are local.

Generated by Claude Code

@MaxGhenis

Copy link
Copy Markdown
Contributor Author

Picking this up for the US hub. I'll post a hand-off comment here when it's ready.


Generated by Claude Code

Bring the branch up to date with main before this review round. The merge
had no conflicts; main's nine commits touch none of this PR's files.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Rounding own resources plus the share to cents turned a child's true
2,000.0033 into 2,000.00 and passed them, though main fails them. That is a
rule about how a share counts, not float noise. POMS SI 01330.200 B says to
equally divide the deemed resources among the children, and 20 CFR
416.1202(b)(1) sets no rounding rule, so the share now stays unrounded.

The rounding stays on the sums of float32 balances the comparisons reach:
the deemors' total before the parental limit comes off, a child's own
balances, a couple's balances on a joint claim, and a person's own plus an
ineligible spouse's. New YAML pins the review's three-child witness (all
fail, as on main), a whole-cent share at the limit that main fails, a
cent-over companion for the deemed-parent case, and at-limit and cent-over
pairs for the spousal and joint paths.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Both compare ssi_countable_resources, a float32 sum of bank, stock and
bond balances, with the $2,000 SSI limit, so three balances that add to
exactly $2,000.00 failed as $2,000.0001. Each fix gets an at-limit case and
a cent-over companion.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Below 2**15 dollars a float32 half unit is at most 2**-10, so five half
units stay under half a cent: the helper's guarantee holds below $32,768,
not $16,384, and the property now draws totals up to $32,767.99.

The model property built a Simulation per example, and only its pinned
example caught anything; the YAML at-limit cases cover that, so it goes.
Also remove a stray blank line in the Pennsylvania TANF formula.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Rounding own resources plus the share inside the loop alone keeps the
review's three-child witness unchanged, since all three children stay or
leave together. This case lets one child leave the division on the exact
share, so the other two divide the excess as 50 each; rounding the loop's
total would keep all three at 33.33. Main gives the same result as this
branch.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Both add a parental share to a child's resources and then rounded the
total to cents, which absorbed a fraction-of-a-cent share the same way the
SSI test did. Medically needy adds SSI's own share; Iowa divides the excess
as SSI does. Round only the summed balances and add the share unrounded,
as the SSI resource test now does.

The medically needy witness is a disabled child whose own income is too
high for SSI, so they don't count in the division but are deemed the share
their SSI-eligible siblings divide: 1,966.67 plus 33.3333 fails, as on
main, and a whole-cent share at the limit passes, which main fails. Iowa's
computed share doesn't give that witness: a child whom the share takes
over the limit leaves the division and is deemed the remaining children's
larger share, or the whole excess if none remain. So its witness enters a
certified share.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Keeping the parental share unrounded left two float errors that decide
totals at the limit. Float64 addition put 1,983.90 + 48.30 / 3 at
2,000.0000000000002, which removed an at-limit child from the division and
raised the siblings' shares. And core stores the share as float32: a share
of 100.01 reads back as 100.010002, so a child with 1,899.99 failed a
$2,000 limit that main and the previous head passed.

The deeming loops now test divisor x own + excess <= divisor x limit in
whole cents, and store each share as the largest float32 at or below it, so
own resources plus the share read back stay within any limit the exact
total meets. The share is still never rounded to cents. Iowa's loop also
rounds the deemors' total and the child's own balances, which it summed in
float32 without rounding.

New cases: a whole-cent share at the limit (SSI, medically needy and Iowa),
16.10 shares that keep an at-limit child in the division (SSI and Iowa), a
parent's three-account split at the Iowa allowance, and an Iowa child whose
three accounts plus the share total the limit.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The whole-cent comparison converts own resources to cents itself, so no
test caught dropping the loop's own-resource rounding. The loop still
needs it to decide which children are deemed at all: a child whose
balances total exactly $2,000 would add to 2,000.0001, be left out of the
deeming, and pass on their own resources. This case expects the child to
be deemed the parent's 100 of excess and fail.

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

Copy link
Copy Markdown
Contributor Author

Picking this up for the US hub, continuing an earlier session's work on this fix round (its commits 85e2cb44e0 to cc8622208b). I'll post a hand-off comment here when it's ready.


Generated by Claude Code

Bring the branch up to date with main before this fix round.

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

Copy link
Copy Markdown
Contributor Author

Picking this up for the US hub, continuing an earlier session's work on this fix round (its commits through cc8622208b). I'll post a hand-off comment here when it's ready.


Generated by Claude Code

@MaxGhenis

MaxGhenis commented Nov 3, 2026 •

Copy link
Copy Markdown
Contributor Author

Ready for hub review
RESULT: FIXED
HEAD: a7289d7

This round continues an earlier session's work. Its nine commits (85e2cb44e0 to cc8622208b) carried the code and YAML for findings 1-7 but left the PR body unchanged. I checked each commit against its finding and kept all of them; one goes past the hub's literal instruction, explained under P2-1 below. This session's only commit is a merge of main (a7289d77dd), which had no conflicts. Before merging I had to unshallow the clone, because a shallow history gave a false merge base.

Findings

  • P2-1, deemed parent share: FIXED (kept from 220543dd31, b7773a86b4, 0e3f0a4683, 7a72caaa57, cc8622208b).
    • Sums rounded (each adds float32 parts):
      • ssi_resources_deemed_from_ineligible_parent.py:126 rounds parental_resources, which adds each deemor's float32 ssi_resources_for_deeming (itself built from ssi_countable_resources, an adds of float32 bank, stock and bond inputs).
      • :131 rounds the child's own ssi_countable_resources.
      • meets_ssi_resource_test.py:29-30 rounds the couple's marital-unit sum, and the person's own plus the ineligible spouse's resources (a float32 add of two float32 sums). It adds parent_resources unrounded.
    • Share left unrounded. share = excess / divisor (:164) is never rounded to cents. The code comment at :157-162 cites SI 01330.200 B and 416.1202(b)(1) with both links. My network blocked secure.ssa.gov, law.cornell.edu and web.archive.org (proxy 403), so the citation rests on the hub's quoted text.
    • Judgment call kept from 7a72caaa57, beyond the brief's literal text.
      • The loop tests own + share with meets_limit_with_share (tools/general.py:31), exactly in whole cents: divisor × own + excess ≤ divisor × limit. A plain float64 own + share puts 1,983.90 + 48.30/3 at 2,000.0000000000002.
      • The returned share is float32_at_most(deemed) (:173, tools/general.py:47), the largest float32 at or below the exact share. Without it, rounding own resources would add a regression against main: a share of 100.01 is stored as 100.010002, so 1,899.99 + 100.010002 fails a $2,000 limit that main passes. This moves the share by less than one float32 step, always downward, and never to cents.
      • The docstring's exactness claim (a cent ÷ divisor exceeds float32's step for shares below 2^11 and divisors below 80) checks out: 0.01/80 = 1.25e-4 > 2^-13 ≈ 1.22e-4.
    • Same pattern, kept from 0e3f0a4683 and 7a72caaa57: is_medically_needy_for_medicaid.py:61-65 and ia_ssa_eligible.py:46-52 / ia_ssa_resources_deemed_from_parents.py:59-80. At 56f56d1c65 both rounded own + share the same way SSI did.
    • YAML:
      • The review's witness (ssi_resources_deemed_from_ineligible_parent.yaml, "A share of parental excess counts to the fraction of a cent") expects false for all four. It passes at main and fails at 56f56d1c65 ([F,T,T,T]).
      • The companion ("Child accounts plus a share of parental excess that total exactly the limit pass": $100 over four children, 178.57 + 1,522.79 + 273.64) passes here and fails at main, which deems [0, 25, 33.33, 33.33, 33.33].
      • The axiom: line keeps "numeric representation only", reworded as "float32 representation only; the share stays an exact equal division".
  • P2-2, MD PAA and VA AG: FIXED (365613ef88).
    • md_paa_eligible.py:65 and va_ag_eligible.py:22 apply the review's two expressions.
    • At-limit / cent-over pairs: md_paa_eligible.yaml cases 19/20 and va_ag_eligible.yaml (new file, 2 cases). Both at-limit cases fail at main and at 56f56d1c65.
    • Both are off the body's "couldn't satisfy" list; NC stays.
  • P2-3, income tests: FIXED in the body. It now says the PR covers asset and resource tests and leaves income-limit tests to a follow-up.
  • P3-1, bound: FIXED (4d6efb0473). test_round_to_cents_properties.py:22-25 has the review's text and MAX_CENTS = 2**15 * 100 - 1.
    • Arithmetic: below 2^15 a float32 ulp is 2^-9, so a half-ulp is 2^-10. Three part roundings plus two add roundings give 5 × 2^-10 = 0.00488 < 0.005.
    • No "$16,384" or 2**14 is left in the tree, and the body now says $32,768.
  • P3-2, overlaps: FIXED in the body. I rechecked with git merge-tree --write-tree --name-only at each current head and counted conflicts that appear against this head but not against main:
  • P3-3, model property: FIXED (4d6efb0473). test_split_accounts_match_one_account is gone and the helper-only property stays.
  • P3-4: FIXED (4d6efb0473, 220543dd31). The stray blank line in pa_tanf_resources_eligible.py is gone. The deemed-parent YAML has the cent-over companion ("Child accounts plus parental excess a cent over the limit fail").
  • Body: FIXED. It covers what and why, this round's ruling with both sources, MD and VA, the bound, the overlaps, tests and validation. It keeps impact: the hub will measure.

Mutants

Each ran in its own worktree and process and was restored afterwards (git status clean).

Mutant Result Killed by
(a) helper rounds to whole dollars killed meets_ssi_resource_test.yaml (3 cent-over cases), msp_asset_eligible.yaml, nh_fanf_resources_eligible.yaml (cent-under), md_paa_eligible.yaml case 20, va_ag_eligible.yaml cent-over, and the property
(b) round own + share, as 56f56d1c65 did (loop and meets_ssi_resource_test) killed ssi_resources_deemed_from_ineligible_parent.yaml: the review's witness and "A child whom an unrounded share takes over the limit leaves the division" (2 failed). meets_ssi_resource_test.yaml alone doesn't kill it.
(c) drop the rounding in md_paa_eligible.py killed md_paa_eligible.yaml case 19 (at limit)
(d) drop the rounding in va_ag_eligible.py killed va_ag_eligible.yaml at-limit case

Tests

All runs at the final tree, one file per process:

File Cases
meets_ssi_resource_test.yaml 14
ssi_resources_deemed_from_ineligible_parent.yaml 47
is_medically_needy_for_medicaid.yaml 42
ia_ssa_eligible.yaml 4
ia_ssa_resources_deemed_from_parents.yaml 11
md_paa_eligible.yaml 20
va_ag_eligible.yaml 2
meets_snap_asset_test.yaml 8
msp_asset_eligible.yaml 27
nh_fanf_resources_eligible.yaml 14
  • YAML: 189 cases pass, 0 fail.
  • test_round_to_cents_properties.py: 1 passed (2,000 examples), 51 s wall locally including uv run. It needs the dev extra for Hypothesis; without it the module skips.
  • Lint: ruff format --check and ruff check are clean on all 61 changed Python files.

The same seven changed YAML files were also run against two other trees:

  • main: 16 failures, all the new at-limit or exact-share cases.
  • 56f56d1c65: 8 failures, among them the review's witness, the medically needy case 37 and the IA SSA fractional-share case.

No full suites or microsimulations were run.

CI

The Pull request run 41709965715 at a7289d77dd completed with conclusion success: all 36 jobs passed, including every baseline and contrib shard, Household API Partners, PR validation, Package and compatibility, the Python shards and Quick Feedback. https://github.com/PolicyEngine/policyengine-us/actions/runs/41709965715

Judgment calls

  1. I kept the earlier session's exact whole-cent test and float32 round-down of the stored share (P2-1 above) instead of the literal "leave the share unrounded and compare round(own) + share". I measured the literal variant (plain own_resources + share <= p.individual, no float32_at_most) in its own process: ssi_resources_deemed_from_ineligible_parent.yaml had 2 failures in 47.
    • "A whole-cent parental share that brings a child exactly to the limit passes" gives [F, F]. Main passes this case, so the literal variant is a regression.
    • "A child whom a share reaches exactly to the limit stays in the division" gives [16.10, 24.15, 48.30] where [16.10, 16.10, 16.10] is expected.
      The share is still never rounded to cents.
  2. Medically needy and Iowa SSA got the same treatment, because at 56f56d1c65 both rounded own + share as SSI did.
  3. Item 1 asked to show the companion fails at main or at 56f56d1c65. It fails at main, and the review's witness fails at 56f56d1c65.

Proposed follow-up

  • Round summed income before exact income-limit tests. Income tests compare float32 sums of several income inputs with dollar limits, and they drift the same way. Sweep <= and < income-limit comparisons with the same at-limit and cent-over YAML pairs.

Generated by Claude Code

@MaxGhenis

Copy link
Copy Markdown
Contributor Author

Hub review in progress

Head under review: a7289d77dda7aa8fc3c0cffdd15ac861c50876d6 (unchanged since the hand-off).

These findings may still change:

  • P2-1, the kept exact-share design holds on a brute-force grid. I compared three variants with exact rational arithmetic (own + excess/div <= 2000): main, this head, and the brief's literal variant (round(own) + share, share stored as the nearest float32). The grid covers divisors 1-12, excess $0.01-$4,000 (deemed through a float32 parental sum, allowance $2,000 or $3,000), and own balances at the boundary and one cent past it, 18.4M cases in all.
    • This head's loop and final test disagree with the exact rule in 0 cases.
    • The literal variant wrongly fails about 11% of at-limit cases (499,793 of 4.6M) in the final test. Main gets all of these right.
  • Hand-off claim. 1983.9 + 48.3/3 is 2000.0 in float64, not 2000.0000000000002 as the docstring of meets_limit_with_share and the body say. The exact whole-cent test is still the right design, since the literal loop errs in 69k-103k at-limit cases once excess comes from round_to_cents(parental) - allowance. The example is wrong, though.
  • Sources. This session's network refuses ecfr.gov, govinfo.gov, secure.ssa.gov, ssa.gov, law.cornell.edu, web.archive.org and uscode.house.gov (proxy 403 / DNS).

Still running: the head's YAML files, main comparisons, mutants and overlaps.


Generated by Claude Code

@MaxGhenis

Copy link
Copy Markdown
Contributor Author

Ready for hub review
VERDICT: APPROVE
a7289d7
METHODOLOGY_CHOICE: no

The head hasn't moved past a7289d77dd, the hand-off's head. Since round 1's head (56f56d1c65) the branch has gained nine fix commits (85e2cb44e0 to cc8622208b) and two merges of main. Main is 2 commits ahead and merges cleanly (git merge-tree).

All seven round 1 findings are fixed, and the run that covers each is below. The P2-1 design that goes past the brief's literal text is the right one. Each child's share stays an exact equal division, and against exact rational arithmetic the kept code never puts a child on the wrong side of the limit. The brief's literal variant would have regressed against main. METHODOLOGY_CHOICE is no: rounding now touches only sums of float32 balances, and the parental share isn't rounded to cents, so no reading of 416.1202(b) or SI 01330.200 B is chosen. The findings below are P3: one overlap the body misses, and one numeric example that is wrong as written.

Findings

P3-1. The overlap list misses #10629, which conflicts with this head and not with main

policyengine_us/variables/gov/hhs/medicaid/eligibility/categories/is_optional_senior_or_disabled_asset_eligible.py:22 and is_medically_needy_for_medicaid.yaml.

Open #10629 ("Let Missouri aged, blind and disabled people who don't receive SSI spend down", head as fetched today) rewrites the line this PR changes to round_to_cents(...). It replaces np.round(person.marital_unit.sum(personal_assets), 2) with np.round(marital sum + where(deems_parents, parental_resources, 0), 2).

git merge-tree --write-tree --name-only HEAD pr-10629      -> CONFLICT in is_optional_senior_or_disabled_asset_eligible.py, is_medically_needy_for_medicaid.yaml
git merge-tree --write-tree --name-only origin/main pr-10629 -> no conflict

The fix is in the body only. Add to "Overlapping open PRs": **#10629** conflicts in is_optional_senior_or_disabled_asset_eligible.py (the same assets = ... line) and is_medically_needy_for_medicaid.yaml. Its new sum adds whole parental resources, with no division, so whichever PR lands second keeps round_to_cents(...) around the whole expression.

The body's other overlap claims hold. Rechecked at each current head:

P3-2. The float64 example in the docstring and two YAML comments is false as written

  • policyengine_us/tools/general.py:36-37
  • policyengine_us/tests/policy/baseline/gov/ssa/ssi/eligibility/resources/deemed/ssi_resources_deemed_from_ineligible_parent.yaml:657
  • policyengine_us/tests/policy/baseline/gov/states/ia/hhs/ssa/ia_ssa_resources_deemed_from_parents.yaml:641
  • the body's first P2-1 sub-bullet

All four say 1,983.90 + 48.30 / 3 is 2,000.0000000000002 in float64. It isn't:

>>> 1983.9 + 48.3/3
2000.0
>>> x = np.round(np.float64(np.float32(2048.3)), 2); e = x - 2000; e, np.round(np.float64(np.float32(1983.9)), 2) + e/3
(48.30000000000018, 2000.0000000000002)

The drift is real, but it comes from forming the excess as 2,048.30 − 2,000 in float64, not from dividing 48.30. The mutant run below confirms it matters in the model: a float64 loop test drops the first child in the 2,048.30 case. Suggested docstring text: Float64 arithmetic can put a total at the limit a hair above it (an excess of 2,048.30 - 2,000 is 48.30000000000018 in float64, and 1,983.90 plus a third of it is 2,000.0000000000002), so compare whole cents instead:. Make the same change in the two YAML comments and the body. This also corrects my interim comment above, which called the example wrong without saying the mechanism is real.

Round 1 findings at this head

  • P2-1 (deemed share): fixed, by a better route than the brief's literal one.

    • ssi_resources_deemed_from_ineligible_parent.py:126 rounds the deemors' float32 total, and :131 rounds the child's own balances.
    • :165 tests own + share exactly in whole cents (meets_limit_with_share, tools/general.py:31).
    • :173 stores the share as the largest float32 at or below it (float32_at_most, tools/general.py:47).
    • meets_ssi_resource_test.py:29-30 rounds only the marital-unit sum and own + spouse, then adds the parental share unrounded.
    • Medically needy (is_medically_needy_for_medicaid.py:61-65) and Iowa SSA (ia_ssa_eligible.py:46-52, ia_ssa_resources_deemed_from_parents.py:59-80) follow the same pattern.
    • Round 1's witness (a $2,100 parent, three children at $1,966.67): meets_ssi_resource_test = [F, F, F, F] at this head, as at main. At 56f56d1c65 the result is [0. 1. 1. 1.].
  • P2-2 (MD PAA, VA AG): fixed at md_paa_eligible.py:65 and va_ag_eligible.py:22, with round 1's expressions. Results:

    Case main 56f56d1c65 this head
    MD case 19 (at limit) fails [0.] fails [0.] passes
    VA at-limit case fails [0.] fails [0.] passes
    MD case 20 and VA cent-over pass pass pass
  • P2-3 (income tests): resolved as a follow-up. The diff changes no income comparison: no added or removed line in variables/**.py mentions income. Main and this head therefore have the identical gap: main rounds no summed income before any income-limit test. The PR leaves that gap no worse, so it stays a follow-up. Most income limits I sampled are FPG multiples, not whole dollars, such as ms_hmw_income_eligible's p.rate * unit_fpg. Exact-limit income witnesses will be rarer than asset ones, and I didn't build one.

  • P3-1 (bound): fixed. test_round_to_cents_properties.py:22-25. Between 2^14 and 2^15, a float32 ulp is 2^-9 and a half-ulp is 2^-10. Three part roundings plus two add roundings give 5 × 2^-10 = 0.0048828 < 0.005, and MAX_CENTS = 2**15 * 100 - 1 = 3,276,799. No 16,384, 16384 or 2**14 remains in the changed files.

  • P3-2 (overlaps): fixed except Let Missouri aged, blind and disabled people who don't receive SSI spend down #10629 (finding P3-1 above).

  • P3-3 (model property): fixed. Only test_rounded_sum_of_float32_parts_is_the_total remains. Run: 1 passed in 8.93s.

  • P3-4: fixed. The stray blank line in pa_tanf_resources_eligible.py is gone. The deemed YAML has "Child accounts plus parental excess a cent over the limit fail".

The judgment call past the brief (P2-1)

The rule under 20 CFR 416.1202(b)(1) and SI 01330.200 B, as the hub quoted them, is: the child's own resources plus an exact equal share of the parental excess, against the $2,000 individual limit. I computed each variant against that rule with exact integer arithmetic (div × own + excess ≤ div × limit). The grid:

  • divisors 1-12;
  • excess $0.01 to $4,000, formed as the model forms it (round_to_cents(float32 parental) − allowance, with allowance $2,000 and $3,000);
  • own balances at the largest whole-cent value that meets the rule, and one cent above it;
  • 18.4 million cases in all.
Variant Loop wrong (at limit / cent over) Final test wrong (at limit / cent over)
This head (exact cents, round-down share) 0 / 0 0 / 0
Brief's literal (round(own) + share, nearest float32) 69,092-102,703 / 0 499,793 / 0
Main (single own balance) 499,802 / 0 0 / 0

So the kept version moves no child across the limit in either direction relative to the exact rule. Where it differs from main, main was wrong, and only in main's loop. The literal variant wrongly fails about 11% of at-limit children whom main passes.

The YAML cases agree. I reran both variants in their own processes:

  • Whole-cent share ("A whole-cent parental share that brings a child exactly to the limit passes": $2,100.01 parent, $1,899.99 child). This head passes. The literal variant gives meets_ssi_resource_test [0. 0.] where [0. 1.] is expected, which confirms the hand-off. Main passes.
  • Fractional share (round 1's witness and "A child whom an unrounded share takes over the limit leaves the division"). Both variants pass, and so does main.

The float32_at_most docstring's exactness bound checks out: 0.01 / 80 = 1.25e-4 > 2^-13 ≈ 1.22e-4. The grid stops at 12 children.

Mutants

Each ran on its own copy of the head, one YAML file per process, and was then deleted. git status is clean and HEAD is a7289d77dd.

Mutant Result Killed by
(a) helper rounds to whole dollars killed meets_ssi_resource_test.yaml (3 cent-over cases), msp_asset_eligible.yaml, nh_fanf_resources_eligible.yaml (cent-under), md_paa_eligible.yaml case 20, va_ag_eligible.yaml cent-over, ssi_resources_deemed_from_ineligible_parent.yaml (3), and the property (case=(1, (0, 0, 1)))
(b) round own + share, as 56f56d1c65 did (loop and final test) killed deemed YAML: round 1's witness [0. 1. 1. 1.] and "unrounded share takes over the limit". It survives meets_ssi_resource_test.yaml and the medically needy YAML.
(c) drop MD rounding killed md_paa_eligible.yaml case 19
(d) drop VA rounding killed va_ag_eligible.yaml at-limit case
Brief's literal variant (float64 loop, nearest-float32 share) killed deemed YAML: "whole-cent parental share" [0. 0.] and "share reaches exactly to the limit" [16.1, 24.15, 48.3]; medically needy case 39
Round-down dropped (return deemed) killed deemed YAML: "whole-cent parental share" and "share reaches exactly to the limit" (meets_ssi_resource_test [0. 0. 1. 1.]); medically needy case 39
Mine: float64 loop test, round-down kept killed deemed YAML: "share reaches exactly to the limit" [16.099998, 24.15, 48.3]
Mine: child's own balances unrounded in the loop killed deemed YAML: "own accounts total exactly the limit is still deemed" [0. 0.]

Checked and sound

  • Defect at main. I copied the seven YAML files changed this round into a main worktree: 16 failures, all at-limit or exact-share cases. At 56f56d1c65: 8 failures, including round 1's witness, medically needy case 37 and the IA fractional-share case. Both counts match the hand-off. At main, the 2,048.30 case returns excess 48.30005, which comes from the unrounded float32 parental sum.

  • Hand values. I computed these in float32 (sum shown, then rounded):

    Parts Total float32 sum
    178.57 + 1,547.79 + 273.64 2,000.00 2,000.0001220703
    178.57 + 1,522.79 + 273.64 1,975.00 1,975.0001220703
    2,607.87 + 29.87 + 362.26 3,000.00 3,000.0002441406
    2,885.40 + 5,798.41 + 976.19 9,660.00 9,660.0009765625
    4,338.99 + 609.03 + 51.98 5,000.00 5,000.0004882813
    719.22 + 208.18 + 72.60 1,000.00 999.9999389648
    1,843.69 + 2,145.15 + 11.16 4,000.00 3,999.9997558594

    Each rounds to the total. A share of 100.01 stores as 100.01000213623, as the YAML comment says.

  • Head tests. All 58 changed YAML files pass, one per process: 560 cases, 0 failures. The property file passes (1 test).

  • Readers.

    • ssi_resources_deemed_from_ineligible_parent is read by meets_ssi_resource_test and is_medically_needy_for_medicaid.
    • ia_ssa_resources_deemed_from_parents is read by ia_ssa_eligible.
    • nh_ssp_resources_deemed_from_parents and ia_ssa_income_deemed_from_parents import only _ssi_parental_resource_pool, which this PR leaves unchanged.
    • The new helpers are read only at the PR's own sites.
    • float32_at_most lowers a stored share by less than one float32 step, and no reader scales it.
    • I found no reader this PR makes worse.
  • NH SSP. nh_ssp_eligible.py rounds the total, including the NH parental excess. NH doesn't divide that excess (He-W 652.03, per the code comment), so rounding there is representation only.

  • Lint. ruff format --check and ruff check are clean on the 61 changed Python files.

  • Body. These claims hold:

    • 61 changed Python files;
    • 52 state files: 51 sites plus Iowa's deeming variable;
    • 189 cases across the 10 named files (my per-file counts: 14 + 47 + 42 + 4 + 11 + 20 + 2 + 8 + 27 + 14);
    • main fails every new at-limit case;
    • the bound text.

    Both the impact: and axiom: lines are present. The axiom line's "float32 representation only; the share stays an exact equal division" now holds.

  • Baseline impact. Output can move only for a unit whose summed balances lie within half a cent of a limit, or a deeming child whose exact own + share lands at the limit where main's float32 path missed. On imputed balances both should be rare. An impact run should read meets_ssi_resource_test, ssi, meets_snap_asset_test, snap, msp_asset_eligible, is_medically_needy_for_medicaid, medicaid, md_paa/va_ag eligibility and the state *_resources_eligible variables.

  • Scope. Nothing changed under .github/ or policyengine_us/tests/policy/baseline/partners/.

  • CI. The Pull request run 41709965715 at this head completed success, with 36 of 36 jobs successful and none cancelled or skipped.

What I couldn't check

  • Primary sources. This session's network refuses ecfr.gov, govinfo.gov, secure.ssa.gov, ssa.gov, law.cornell.edu, web.archive.org and uscode.house.gov (proxy 403 or DNS failure). I couldn't read SI 01330.200 B or 20 CFR 416.1202(b)(1). The rule I computed against rests on the hub's quoted text: an exact equal division, with no rounding rule.
  • Population data. I ran no microsimulation, so the impact statement is reasoning, not a measurement.
  • Children beyond 12. The brute-force grid covers divisors 1-12. Above that, I checked only the docstring's arithmetic bound (divisors below 80).
  • Memory. Three medically needy runs were OOM-killed after printing their results while four test processes shared the VM. I reran each alone and the results matched.

Generated by Claude Code

1,983.90 + 48.30 / 3 is exactly 2,000.0 in float64. The drift comes from
forming the excess as 2,048.30 - 2,000, which gives 48.30000000000018;
1,983.90 plus a third of that gives 2,000.0000000000002. Comments only.

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

DTrim99 commented Nov 5, 2026

Copy link
Copy Markdown
Collaborator

PR Review: Round summed resources to whole cents before exact-limit asset tests

Summary

The model stores balances as float32, so three cent amounts that add to exactly a whole-dollar limit can sum a fraction of a cent above it (failing a <= test) or below it (passing a strict < test). The PR adds one vectorized helper, round_to_cents, and applies it immediately before 57 resource-limit comparisons: 6 federal and 51 state. It also adds two helpers for the SSI and Iowa SSA parental-deeming loops. meets_limit_with_share tests own + share exactly in integer cents, and float32_at_most stores the share as the largest float32 at or below its exact value. Every changed site has an at-limit YAML case and a cent-over (or, for a strict <, cent-under) companion.

The core design is sound. Rounding touches only sums of whole-cent inputs, and the child's share of parental excess is never rounded to cents. I confirmed the at-limit witnesses with float32 arithmetic on the summing path each site uses. CI is 36/36 green at the head.

One should-address item remains. The PR body's site inventory, which says why each unchanged site was left alone, omits the California county general relief and general assistance asset tests. These have the same drift, with witnesses at their limits, and stay unrounded. The other notes are suggestions.

Critical (must fix)

None.

Should address

1. The body's site inventory omits the California county general relief and general assistance asset tests, which drift the same way and stay unrounded.

The body sorts every site into "Sites fixed" and "Sites left unchanged (no witness)". The only local programs it names are San Bernardino and San Francisco, under "Not probed". These county tests compare a float32 sum of whole-cent balances with a whole-dollar limit and are neither rounded nor listed:

  • policyengine_us/variables/gov/local/ca/la/general_relief/eligibility/cash/la_general_relief_cash_asset_eligible.py: spm_unit_cash_assets <= limit ($100 single applicant, $200 married, $1,500 recipient).
  • policyengine_us/variables/gov/local/ca/marin/general_relief/eligibility/liquid_assets/ca_marin_general_relief_liquid_asset_eligible.py: spm_unit_cash_assets <= limit.
  • policyengine_us/variables/gov/local/ca/scc/ga/eligibility/ca_scc_general_assistance_personal_property_eligible.py: cash + personal property + vehicle <= $500.
  • policyengine_us/variables/gov/local/ca/cc/ga/eligibility/ca_cc_general_assistance_personal_property_eligible.py: cash + personal property + vehicle <= limit.
  • policyengine_us/variables/gov/local/ca/oc/general_relief/resources/ca_oc_general_relief_resources_eligible.py: ca_oc_general_relief_countable_property (an adds of spm_unit_cash_assets and a vehicle value) <= $1,000.

Witnesses use the float64-sum-stored-as-float32 path that spm_unit_cash_assets follows. I checked them numerically:

  • 29.54 + 5.73 + 64.73 = 100.00 is stored as 100.0000076, so an LA single applicant at exactly the $100 limit fails.
  • 202.47 + 11.89 + 285.64 = 500.00 is stored as 500.0000305, so a Santa Clara applicant at exactly $500 fails.
  • At $200 and $1,500, splits that store as 200.0000153 and 1,500.0001221 also exist.

Several sum-based tests in the same family have multi-person witnesses (two people's float32 balances summed): Alameda and Los Angeles personal property, Marin personal property, and San Mateo property (strict <). Riverside already rounds inline (ca_riv_general_relief_property_eligible.py:20).

Fix: either apply round_to_cents at these sites with an at-limit / cent-over YAML pair in each variable-named file, or add them to the body's "Sites left unchanged" list with the reason (for example, "California county programs deferred to a follow-up"). As written, the body implies they were classified.

Suggestions

  1. Drop the axiom line's parenthetical. "(the hub may file pe-parity before landing)" implies pending parity work, but the n/a reason stands on its own (see the axiom assessment). The body's impact: the hub will measure is also a placeholder. Replace it with a measured figure or drop it.
  2. Use the helper at the one remaining inline cent-rounding of a summed resource test. ca_riv_general_relief_property_eligible.py:20 still uses np.round(total_property_value, 2). That is the same pattern the PR moved to round_to_cents in is_optional_senior_or_disabled_asset_eligible.py.
  3. Guard meets_limit_with_share against a non-finite limit (policyengine_us/tools/general.py). The helper casts limit * 100 to int64. A reform that sets gov.ssa.ssi.eligibility.resources.limit.individual to infinity would give an undefined cast (INT64_MIN with a RuntimeWarning), and that can wrap the product. If only the individual limit is infinite, a child could then be dropped from the division and change siblings' shares. Medically needy reads those shares against state limits. One remedy is np.where(np.isfinite(limit), <integer test>, True). No reform in the repo does this today.
  4. Track the unfixed sites the body names. One follow-up issue could cover nc_sa_eligible (which the body says "likely drifts"), the unprobed sites and the income-limit sweep, so they aren't lost after merge.

Verified correct

Rounding never changes a legal result.

  • Each site rounds only a sum of whole-cent quantities: bank, stock and bond balances; property values; and vehicle values less whole-dollar exemptions.
  • ssi_countable_resources is an adds of the three balance inputs. ssi_resources_for_deeming subtracts only a whole-cent military exclusion.
  • No non-dollar quantity is rounded, and no sub-cent legal quantity is rounded.
  • The MT and WA TANF vehicle proxy, (value / count) × (count − 1), can carry sub-cent fractions. The legal countable value (total less the highest-equity vehicle) is whole cents and never exceeds the proxy. So when the rounded proxy is within the limit, so is the legal value: rounding cannot pass a unit the law fails.
  • Each comparison operator (<= or <) is unchanged.
  • Rounding happens once per comparison. round_to_cents is idempotent on cent values, so stacked rounding is harmless anyway.

Exactness bound.

  • Below 2^15 dollars, a float32 half-ulp is at most 2^-10. Three part roundings plus two adds give at most 5 × 2^-10 = 0.00488 < 0.005.
  • The float64-to-float32 path has four half-ulps plus negligible float64 error.
  • The property test covers both paths up to MAX_CENTS = 2**15 * 100 − 1.

The share stays an exact equal division (POMS SI 01330.200 B; 20 CFR 416.1202(b)(1)).

  • The eCFR text of 416.1202(b)(1) deems parental resources "only to the extent that those resources exceed the resource limits described in § 416.1205" and has no division or rounding rule.
  • SI 01330.200 B: "equally divide the value of the deemed resources among those children", and when a child becomes ineligible, "divide the value of the deemed resources among the remaining eligible children".
  • In ssi_resources_deemed_from_ineligible_parent.py, only the deemors' float32 total (before the allowance comes off) and the child's own balances are rounded. share = excess / divisor is not.
  • meets_limit_with_share computes excess_cents <= divisor × (limit_cents − own_cents) in int64. This is the exact rational test own + excess/divisor <= limit for whole-cent own, excess and limit.
  • float32_at_most lowers the stored share by less than one float32 step and never moves it to cents. Its bound holds. A total over a whole-cent limit exceeds it by at least 0.01 / divisor, and for shares below 2^11 the float32 step is at most 2^-13 ≈ 1.22e-4 < 0.01 / 80 = 1.25e-4. Any share that can pass the $2,000 SSI limit is below 2^11.
  • meets_ssi_resource_test, is_medically_needy_for_medicaid and ia_ssa_eligible round only own (plus spouse, or the marital-unit sum), then add the share unrounded.
  • nh_ssp_eligible rounds a total that includes NH's parental excess. NH adds the whole excess and does not divide it (He-W 652.03(i)-(j), cited in nh_ssp_resources_deemed_from_parents.py), so this is representation only.

Helper placement and vectorization.

  • round_to_cents, meets_limit_with_share and float32_at_most live once in policyengine_us/tools/general.py. All three are array operations (np.round, np.rint(...).astype(np.int64), np.where with np.nextafter).
  • Every site applies the helper at one consistent layer, the last step before its limit comparison.
  • Rounding inside the shared aggregates instead would not hold: their float32 storage would reintroduce drift for later sums (vehicle add-ons, marital-unit sums).
  • int64 headroom is ample: divisor × cents stays far below 9.2e18 for any realistic balance.

Boundary pinning. Each of the 59 changed variable files except the pure refactor has a variable-named YAML file with an at-limit case and a cent-over or cent-under companion (58 files; is_optional_senior_or_disabled_asset_eligible.py only swaps np.round(..., 2) for the identical helper).

  • The companion failing at the head shows the resource test binds in that household and pins the limit to the cent. CI passes both cases.
  • I recomputed every at-limit split on the path its site uses. Same-entity adds (ssi_countable_resources) uses float32 addition. Person-to-SPM-unit adds (spm_unit_cash_assets, snap_assets) uses a float64 bincount sum stored as float32.
  • Every split lands on the wrong side unrounded, so each at-limit case fails without its site's rounding and each site is pinned. The three SSI-only splits (178.57/1,547.79/273.64, 575.52/570.57/353.91 and 178.57/1,522.79/273.64) drift only on the float32-add path, and they are used only at person-level ssi_countable_resources sites.

Hand-checked expectations.

# Case Arithmetic Expected
1 AK ATAP at limit 1,157.81 + 285.17 + 557.02 = 2,000.00; stored 2,000.0001221 (fails at main); rounded 2,000.00 <= 2,000 true; 2,000.01 companion false
2 NH FANF, strict < 719.22 + 208.18 + 72.60 = 1,000.00; stored 999.9999390 (passes at main); rounded 1,000.00 < 1,000 is false false; 999.99 companion true
3 MS HMW, strict < 1,843.69 + 2,145.15 + 11.16 = 4,000.00; float32 3,999.9997559; rounded 4,000.00 < 4,000 is false false; 3,999.99 true
4 MSP 2025 2,885.40 + 5,798.41 + 976.19 = 9,660.00; float32 add 9,660.0009766; rounded <= 9,660 true; 9,660.01 false
5 SNAP FY2025 2,607.87 + 29.87 + 362.26 = 3,000.00; stored 3,000.0002441; limit.yaml standard 2024-10-01 = 3,000 true; 3,000.01 false
6 SSI ineligible spouse 1,500.0001221 + 1,500.0001221 = 3,000.0002441 (fails at main); rounded 3,000.00 <= couple 3,000. Spouse alone 1,500.00 <= 2,000 [true, true]; spouse at 1,500.01 gives [false, true]
7 SSI deeming, 2,048.30 parent round(2,048.30) − 2,000 = 48.30000000000018, which is 4,830 cents; 3 × 198,390 + 4,830 = 600,000 <= 600,000, so child 1 stays; share 16.10 is stored as 16.0999985; 1,983.90 + 16.0999985 = 1,999.9999985 <= 2,000 deemed [0, 16.10 ×3]; test [F, T, T, T]
8 SSI deeming, three children at 1,966.67 excess 10,000 cents; 3 × 196,667 + 10,000 = 600,001 > 600,000, so all leave and keep the share 33.3333; 1,966.67 + 33.3333 = 2,000.0033 > 2,000 [0, 33.3333 ×3]; all false
9 SSI deeming, one child at 1,966.67 and two empty Round 1: child 1 out (600,001 > 600,000). Round 2: two children divide 100 = 50 each, stable [0, 33.3333, 50, 50]; [F, F, T, T]
10 SSI deeming, 2,100.01 parent excess 100.01000000000022, which is 10,001 cents; 189,999 + 10,001 = 200,000 <= 200,000; share stored 100.0099945; 1,899.99 + 100.0099945 = 1,999.9999945 <= 2,000 (nearest float32 100.0100021 would fail) [0, 100.01]; [F, T]
11 SSI deeming, child's own exactly 2,000 float32 2,000.0001221 rounds to 2,000.00 <= 2,000, so the child is active; 200,000 + 10,000 > 200,000, so the child leaves with share 100; 2,000 + 100 > 2,000 [0, 100]; [F, F]
12 IA SSA deeming Case 10 / medically needy Case 38 178.57 + 1,522.79 + 273.64 = 1,975.00 (float32 1,975.0001221); 4 × 197,500 + 10,000 = 800,000 <= 800,000, so the share is 25 each; 1,975 + 25 = 2,000 IA [0, 25 ×4], eligible [F, T, T, T, T]; MN child 1 true
13 Medically needy Case 37 Child 1 is income-ineligible for SSI (21,358 / 12 above the SSI amount), so the three siblings divide 100 = 33.3333 and child 1 is deemed that share; 1,966.67 + 33.3333 = 2,000.0033 > 2,000 (MA) all false

Other checks.

  • Callers: ssi_resources_deemed_from_ineligible_parent is read by meets_ssi_resource_test and is_medically_needy_for_medicaid, and ia_ssa_resources_deemed_from_parents by ia_ssa_eligible. nh_ssp_resources_deemed_from_parents imports only the unchanged pool helper. No reader scales the round-down share.
  • The corrected float64 example in the docstring and the two YAML comments is now true: 1983.9 + (round(float32(2048.3), 2) − 2000) / 3 = 2,000.0000000000002, and 1983.9 + 48.3/3 = 2,000.0.
  • Changelog: changelog.d/round-summed-limits.fixed.md is a top-level fragment of a sensible type.
  • Tests sit in variable-named YAML files. The new va_ag_eligible.yaml is named for its variable.
  • The Python test (policyengine_us/tests/unit/test_round_to_cents_properties.py) exercises only the helper, with no model or dataset. Hypothesis is in the dev extra, and the file runs in the Rest Python shards. It is cheap and covers a property YAML can't (2,000 random three-way splits on both summing paths).
  • Source-conflict ratchet (Tie source-conflict markers to the register shared with Axiom #10287): no added or removed line matches CONFLICT_COMMENT_RE. Other main-side guards (Integrate modeled state unemployment insurance into income flows #9558, Count military SBP annuities in state benefit income lists #10317, Count each Social Security benefit once in Pennsylvania CCW countable income #10408) don't touch these files.
  • Partner tests: nothing under policyengine_us/tests/policy/baseline/partners/** or .github/ changed. All 120 files are variables, YAML tests, the helper, the unit test or the changelog. The YAML churn is one at-limit / companion pair per changed site (about 25 lines each), plus multi-person deeming cases in the four deeming and medically needy files. Each pair is that site's only pin.

Axiom line assessment

axiom: n/a: float32 representation only; a child's share of parental excess stays an exact equal division (SI 01330.200 B, 416.1202(b)(1)), so no provision's reading changes (the hub may file pe-parity before landing)

The n/a is valid. The PR fixes numeric representation: every comparison keeps its operator and limit, and the deeming loop now computes exactly the rule it already intended (own + excess / divisor <= limit). No provision's reading changes, and an exact-decimal RuleSpec encoding is unaffected. The parenthetical implies possible pending parity work, which contradicts n/a; drop it (Suggestion 1).

CI status

All 36 checks pass on run 41733711974 at head 122d8fd961: every baseline and contrib shard, Household API Partners, PR validation, Package and compatibility, Microsimulation, Rest Python shards 1-9 and Quick Feedback. None is pending, failed or cancelled.

Branch status

Verdict: REQUEST_CHANGES

@DTrim99 DTrim99 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Requesting changes per the review above: 0 critical, 1 should (California county GR/GA asset tests drift the same way but are neither rounded nor listed in the body's inventory), 4 suggestions.

This was referenced Dec 1, 2026
MaxGhenis and others added 2 commits December 1, 2026 11:43
Restore Orange County's aggregate vehicle exemption and honor reported zero equity. Apply Colorado's strict resource cap and stop income deeming after legal separation. Preserve fractional SSI limits and cover float32 drift in SNAP and SSI totals.

Co-Authored-By: GPT-6.2 Sol <noreply@openai.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

@DTrim99 DTrim99 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Program review

Base repository: PolicyEngine/policyengine-us
PR number: 10639
Reviewed head SHA: 20d68c2
Merge base SHA: 094934a
Mode: incremental from 122d8fd
Scope: changed behavior and affected dependencies
Source manifest: /private/tmp/policyengine-command-runs/ea33c0bb2b64/pr-10639-review-sources.json
Review status: COMPLETE

Source Documents

Critical

C1 — Colorado OAP applies "below the resource limit" only to married and legally separated clients (OPEN)

  • Location: policyengine_us/variables/gov/states/co/ssa/oap/co_oap_eligible.py:32-33 (where(married | couple_separated, assets < asset_limit, assets <= asset_limit)). Tests at policyengine_us/tests/policy/baseline/gov/states/co/ssa/oap/co_oap_eligible.yaml:52 ("Three accounts that total exactly the resource limit pass", 2025) and :31 ("Eligible single", 2023, from main).
  • Trigger: a Colorado client who has never married, is widowed or is divorced, age 60 or older, with countable resources of exactly $2,000. For example, 1,157.81 + 285.17 + 557.02 in 2025.
  • Observed: co_oap_eligible is true. CI runs this as a passing assertion. A legally separated client at the same $2,000 unmarried limit is false (:216, "Legally separated applicant at the strict unmarried limit fails"). A married couple at $3,000 is false (:41).
  • Expected: false. 9 CCR 2503-5 3.520.71(A)(1) (physical PDF p. 32) says the client shall "Have countable resources below the resource limit as outlined in Section 3.520.72". The definitions (p. 3) say: "'Eligible client' means a client whose countable resources are below the resource limit". Neither text distinguishes marital status. 3.520.72(A)(1)(a) (p. 35) sets one $2,000 limit for "an unmarried client", and 3.520.63(D) (p. 27) treats legally separated clients as unmarried. So never-married and legally separated clients share the same limit and the same strict test. The head's own comment at line 31 cites 3.520.71(A)(1) for the strict test, then applies it only to the married and separated branch.
  • Why this diff: commits 8ef4272 and 871d058 rewrote this comparison and made the strict rule depend on marital status. The PR's rounding also flips the three-account $2,000 split from ineligible at main (float32 total 2,000.0001221) to eligible, and the new at-limit case pins that result. The same <= for a clean $2,000 single input ("Eligible single") already exists on main.
  • Impact: an unmarried Colorado OAP applicant at exactly $2,000 gets eligibility and the full OAP grant that the rule denies. The population is small but the household effect is all-or-nothing.
  • Fix: use assets < asset_limit for every client. Flip the expectations at :31 and :52 to false. The one-cent-below case at :110 already pins the passing side. Update the changelog's "strict resource limit for married and legally separated applicants" wording.
  • Source: /tmp/policyengine-command-runs/ea33c0bb2b64/sources-10639/co-9ccr2503-5.pdf (ruleVersionId=10694, the version the parameters cite, last amended 03/02/2023 per its history notes). A later rule version was not checked. The cited version governs the parameter.
  • Proposed severity: This is an executed wrong eligibility result in a claimed year (2025 and 2026), and this diff introduces and pins it at the PR's at-limit witness.

Coordinator assessment: I've kept this critical. It is an executed wrong eligibility result in 2025 and 2026: an unmarried applicant at exactly $2,000 gets the full OAP grant that 9 CCR 2503-5 3.520.71(A)(1) denies ("countable resources below the resource limit"). The new at-limit case pins it, after this round's rounding flips the three-account $2,000 split from ineligible on main to eligible. The code review raised the same comparison for the policy role. The fix is one operator, assets < asset_limit for every client, plus flipping the expectations at lines 31 and 52.

Should Address

A1 — PR-caused red CI: the new Orange County input breaks the pre-first-modeled-year uprating test (OPEN)

  • Location: policyengine_us/variables/gov/local/ca/oc/general_relief/resources/ca_oc_general_relief_exempt_vehicle_equity.py (added in 8ef4272). It meets policyengine_us/tests/core/test_pre_first_modeled_year_uprated_inputs.py:62-70 (_situation).
  • Trigger: add_default_uprating (tools/default_uprating.py:125) gives any float USD input the AGI-per-capita uprating. The new input has defined_for = "in_oc", so the test makes an in_oc group. _situation treats any defined_for other than None or in_nyc as a state code and writes state_code: "in_oc".
  • Observed: CI run 46640203294, job 142618004042, failed with test_early_input_behaves_like_first_modeled_year_input[in_oc]: SituationParsingError: 'in_oc' is not a known value for 'state_code'. Reproduced locally against the snapshot: 1 failed, 52 passed (pr-10639-code-pytest.log). The failure is in the shard, which is why the "Check Rest Python shards" gate also fails.
  • Not main: the test dates from main #9650 (2026-09-28). Main's push run 46770751730 at base 50af7fb is green. No in_oc variable on main is an input; this PR adds the first uprated input whose defined_for is a county.
  • Fix, either of:
    • Add the variable to NO_DEFAULT_UPRATING_VARIABLES. It selects a vehicle against a fixed $4,650 exclusion and uses a -1 sentinel, so indexing it is questionable anyway: a 2025 input of 4,600 read in 2027 would uprate above 4,650 and lose its exemption.
    • Or extend the test's _situation to map in_oc to CA plus county: ORANGE_COUNTY_CA.
  • Severity: should-address. This is a PR-caused red check. Branch protection on main lists no required status contexts, so the coordinator can escalate if it treats the shard gate as required.

A2 — The household_vehicles_equity default of -inf is the model's first non-finite variable default and is not JSON-safe in the API metadata (OPEN)

  • Location: policyengine_us/variables/household/assets/household_vehicles_equity.py:15 (default_value = -np.inf, 871d058).
  • Trigger: any consumer that serializes variable metadata or the default output. policyengine-api country.py build_variables copies a float default_value into "defaultValue". _json_safe passes floats through, and metadata_routes.py calls json.dumps, whose default allow_nan=True writes bare -Infinity. Parameter values go through get_safe_json and are converted; variable defaults are not.
  • Executed (pr-10639-code-diag/deem2_*.json):
    • Serializing the default with the API's expression gives {"defaultValue": 0} on main and {"defaultValue": -Infinity} at the head.
    • Node's JSON.parse of the head string throws No number after minus sign in JSON.
    • A scan of all variables finds household_vehicles_equity as the only non-finite default.
    • A household that does not report equity now gets household_vehicles_equity = -inf (main: 0).
  • Downstream readers:
    • in_tanf_countable_resources is unchanged: 500 with equity unset and 5,500 with equity 25,000, the same on both trees.
    • ca_oc_general_relief_countable_vehicle_value is the intended reader of the sentinel.
    • No adds list or parameter references the variable.
  • Impact: once the API picks up this version, the US metadata response can contain invalid JSON for browsers. Any table that sums the variable over households without data would show -inf.
  • Fix: use a finite sentinel (the OC input already uses -1) or an explicit "equity reported" input, or ship a coordinated API serializer change first.
  • Severity: should-address. This is a cross-repo hazard; no benefit amount is wrong.

A3 — The axiom: needed line does not satisfy the Axiom Parity rule for a maintainer's PR (OPEN)

  • Location: PR body, second axiom line: "axiom: needed for Colorado spouse resources and legal-separation income deeming, the Idaho cutoff and Orange County's vehicle rule".
  • Expected: the repository CLAUDE.md "Axiom Parity" section allows axiom: needed only for "an external contributor [who] cannot complete the Axiom work". Otherwise the line must be encoded-correct, encoded, or queued. A queued line needs a dispatch-ready rulespec-us issue labelled pe-parity. This PR's author is a maintainer. The commits add substantive provisions: the Colorado 3.520.72(A) couple total and 3.520.72(C) / 3.520.63(D) legal-separation exclusion of resources and deemed income, and the Orange County Section 60.4.c one-vehicle net-equity exclusion. No rulespec-us issue exists for them. A read-only gh issue list -R TheAxiomFoundation/rulespec-us search found Colorado AND-CS issues and OC §70 issues, but none for OAP spouse resources or OC §60.4.c.
  • Also: the Idaho cutoff is already on main, so it doesn't belong in this PR's parity line.
  • The first line is fine. TheAxiomFoundation/rulespec-us#1626 is open, labelled pe-parity and covers 416.1202 / 416.1205 SSI deeming.
  • Proposed severity: SHOULD ADDRESS (axiom-line problem).

Suggestions

S1 — The changelog and body claim the Idaho BBCE cutoff, which main already carries (OPEN)

  • Location: changelog.d/round-summed-limits.fixed.md:1 ("End Idaho's non-cash SNAP categorical eligibility in July 2026") and the body's "Sites fixed" paragraph.
  • Observed: git diff 50af7fba69 20d68c22c9 -- policyengine_us/parameters/gov/hhs/tanf/non_cash/asset_limit.yaml shows only the added IDAPA 16.03.04.305 reference. The 2026-07-01: -.inf entry with the H730 comment is already on main. The release note would announce a change this PR doesn't make.
  • IDAPA 16.03.04.305 (physical p. 37) does state the $5,000 BBCE resource limit, so the new reference supports the 2015 value.
  • Fix: drop the Idaho sentence from the fragment and say in the body that the cutoff came in through the merge.
  • Proposed severity: SUGGESTION.

Evidence Gaps

No material gaps reported.

Notes

  • This round covers the four author commits since the 11-05 review and four merges of main.
  • The round-1 should-address item (California county GR/GA asset tests) is RESOLVED.
    • All five named county sites now call round_to_cents, and so do Alameda, Marin personal property, LA home value, San Bernardino, SF CAAP, San Mateo, Riverside and NC SA.
    • Each site has an at-limit / one-cent-over YAML pair.
    • Executed: an LA single applicant with 29.54 + 5.73 + 64.73 = $100.00 is ineligible on main and eligible at the head, and $99 and $101 match main.
  • Suggestions 1–3 are resolved, including the np.isfinite handling of non-finite limits.
  • Suggestion 4 is still open: the body lists about 14 unprobed state sites, the income-limit sweep and LA GR personal property's strict < under "Sites outside this change", but no follow-up issue tracks them.
  • New behavior verified against sources:
    • SSI resource deeming. It matches 20 CFR 416.1205(a)–(c) and POMS SI 01330.200 B: <= against the couple limit, and an exact equal parental share.
    • Orange County vehicles. These follow Section 60.4.c and 60.2: one vehicle's net equity is fully exempt up to $4,650, and a vehicle above that counts in full.
    • Colorado spouse resources. A married client counts the spouse's resources against $3,000 (3.520.72(A)). A legally separated spouse's resources and income are excluded (3.520.72(C), 3.520.63(D), 3.534).
    • Medically needy Medicaid and California MSP. Representation changes only.
  • Noted, not findings: the Orange County fallback treats unsplit aggregate equity as one vehicle, which the body discloses. Indiana TANF's result is unchanged by the -inf default.
  • Both shard-4 failures trace to code-1. Main's push run at 50af7fb is green.

Validation Summary

Local tests at the reviewed head (review venv, policyengine-core 3.37.2, matching uv.lock; imports resolved to the snapshot): every touched program folder passed with 0 failures across two bounded runs (3,088 cases in the second run, in 6 shards). The Python run gave 1 failed and 52 passed; the failure is test_early_input_behaves_like_first_modeled_year_input[in_oc], reproducing code-1. Diagnostics executed the LA, Santa Clara, Colorado and SSI boundary households and serialized the variable metadata. Sources: 9 CCR 2503-5, 20 CFR 416.1205, POMS SI 01330.200, the Orange County GR resource rules, IDAPA 16.03.04.305 and the California county GR manuals; manifest check passed. CI at 20d68c2: 34 checks pass, 2 fail (Python Rest shard 4 and its gate; see code-1).

Timing

setup seconds: 18.00s; scope seconds: 60.00s; parallel review seconds: 1142.00s; policy role seconds: 351.20s; code role seconds: 1142.00s; adjudication seconds: 150.00s; consolidation cleanup seconds: 35.70s; elapsed seconds: 1722.00s

Review Severity

REQUEST_CHANGES. Open findings: 1 critical, 3 should address, 1 suggestions.

This branch has not been deployed

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants