Repository navigation
Conversation
ca_riv_general_relief_countable_property_value was a Person variable whose adds listed the SPM-unit cash assets and countable vehicle value. Core projects a group value onto every member, and the property test then summed the members, so cash and vehicle value counted once per member. It is now an SPMUnit stock: unit amounts are added once and personal property is summed. ca_riv_general_relief_earned_income_deductions added the tax unit's state_withheld_income_tax and additional_medicare_tax, so every member deducted the whole unit's withholding from their own wages. It now adds each person's own ca_withheld_income_tax and the new person-level additional_medicare_tax_withheld (26 U.S.C. 3102(f)(1): 0.9% of the employee's wages above $200,000, regardless of filing status). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
PR Review: Stop projecting group amounts onto every Riverside General Relief memberPR #9901 (author: MaxGhenis, head SummaryThe PR fixes two places where Riverside County General Relief (GR) gave every member of a unit the whole unit's amount.
The law and the code agree:
One blocker and three documentation-level items remain:
Critical (must fix)1. Merged with current
Should address1. The Riverside half of the axiom line uses an
2. The PR body says every new case fails on
3. The new parameter's description doesn't follow the house template.
Suggestions
Verified correct
Axiom line assessmentThe line has two halves.
CI statusAll green at the head: 35/35 checks pass ( That run predates #9897. CI on the merged result would fail Branch status
Verdict: REQUEST_CHANGES |
DTrim99
left a comment
There was a problem hiding this comment.
The unit-level property test and per-earner deductions match the sources, and the federal 3102(f)(1) withholding examples hold. Details in the comment above. C1: merged with current main, the code-health ratchet fails. #9897 lists all four Riverside edges in KNOWN_VIOLATIONS, and this PR fixes them, so test_known_violations_only_shrink errors. Rebase and delete the four ca_riv tuples. Should items: S1, the Riverside half of the axiom line uses an n/a reason the guide doesn't allow, so file a queued pe-parity issue as #9916 did; S2, three cases the PR body says fail on main actually pass, and property-value Case 2 can't catch multi-counting; S3, the withholding_threshold description.
The bug
Two Riverside County General Relief (GR) variables are Person variables whose
addslists include group-level variables. policyengine-core evaluates eachaddsentry withcalculate(added_variable, period, map_to=variable.entity.key), andmap_resultturns a group value into a person value withentity_pop.project(values)when nohowis given (policyengine_core/simulations/simulation.py,_run_formulaandmap_result; same code in 3.32.8, the locked version, and 3.32.20). So every member of the group gets the whole group amount.Property.
ca_riv_general_relief_countable_property_value(Person) addsspm_unit_cash_assets(SPMUnit),ca_riv_general_relief_countable_vehicle_value(SPMUnit) andpersonal_property(Person).ca_riv_general_relief_property_eligiblethen sums it over the SPM unit, so cash and countable vehicle value count once per member. Run onmain, 2024:Any adult unit of n ≥ 2 whose cash plus countable vehicle value is between $500/n and $500 is wrongly denied.
Deductions.
ca_riv_general_relief_earned_income_deductions(Person) addsstate_withheld_income_tax(TaxUnit) andadditional_medicare_tax(TaxUnit), so every member deducts the whole tax unit's CA withholding and Additional Medicare Tax from their own wages. Run onmain, 2024-01: a couple where person1 has a $30,000 pension and person2 has $4,800 of wages.ca_withheld_income_taxis [31.80, 0], but the deductions are [31.80, 62.40]: person2 deducts person1's withholding. Countable income falls from $369.40 to $337.60, and the grant rises from $69.10 to $100.90 a month.The rule
The parameter files cite the Riverside DPSS manual "General Assistance Eligibility" (DP 90-001), pp. 20, 22 and 25, which is not public. The public sources agree with unit-level property and per-earner deductions:
additional_medicare_taxis the Form 8959 liability, which uses the filing-status threshold and adds self-employment income, so it is the wrong concept for a wage deduction even for one earner.The fix
ca_riv_general_relief_countable_property_valuebecomes an SPMUnit variable withquantity_type = STOCK, as in the San Bernardino and Orange County GR property variables. Core then adds the SPM-unit cash and vehicle amounts once and sumspersonal_propertyover members.ca_riv_general_relief_property_eligibleis unchanged.state_withheld_income_taxwith each person's ownca_withheld_income_tax, andadditional_medicare_taxwith a new Person variable,additional_medicare_tax_withheld= 0.9% × max(payroll_tax_gross_wages− $200,000, 0). Its threshold is a new parameter,gov.irs.payroll.medicare.additional.withholding_threshold(3102(f)(1)), kept separate from the 3101(b)(2) liabilityexclusionit happens to equal for single filers.Why keep Additional Medicare rather than drop it. It is a mandatory wage deduction, and it can co-occur with GR eligibility in the model: a self-employment loss offsets wages in GR earned income, but not the Additional Medicare base. Integration Case 10 is such a household: $300,000 of wages, a $280,800 business loss, eligible for $50.90 a month only because the $75 of withholding is deducted. In practice the leg almost never binds.
Tests
Every new case fails on
mainand passes here (I ran each file againstmain's Riverside code):ca_riv_general_relief_countable_property_value.yaml(new): cash, vehicles and personal property each counted once.ca_riv_general_relief_property_eligible.yaml: Cases 3–5. A $300 account in a two-person unit passes; $300 in each of two accounts fails; three adults with $4,850 of vehicles pass.ca_riv_general_relief_earned_income_deductions.yaml(new): the pension/wages couple above; two earners where only one has CA withholding; a $300,000 earner whose Additional Medicare withholding ($75 a month) and CA withholding stay with them.integration.yaml: Case 8 (the $300 account, $438.50 grant), Case 9 (the pension/wages couple, $69.10) and Case 10 (above). Case 2 changes from [38.63, 0.38] to [38.63, 0]: person2 has no wages or withholding of their own. Its other outputs are unchanged.additional_medicare_tax_withheld.yaml(new): the threshold boundary ($200,000 → $0), $250,000 → $450, both examples in 26 CFR 31.3102-4 (spouses with $100,000 and $300,000: [0, 900] withheld against $1,350 of joint liability; spouses with $190,000 and $150,000: nothing withheld against $810 of liability), self-employment income alone, and a 401(k) deferral.Invariants
tests/core/test_riverside_general_relief_attribution_invariants.pychecks these with Hypothesis batches of one- to four-adult Riverside units plus a seeded population of 120. Each batch is run once, then again with the first member's assets and wages raised.additional_medicare_tax_withheld= 0.9% × (wages − $200,000)⁺ ≤ 0.9% × wages. The constants are typed from the statute, not read from parameters. For a one-person single filer it equalsadditional_medicare_tax.state_withheld_income_tax, counted once.On
main's Riverside code the seeded test fails on (1), and with only the property fix applied, on (4): 138 of 263 people.Impact
ca_riv_general_relieffeeds no household benefit, net income or poverty aggregate; it is listed only inprograms.yaml. Only GR and its intermediates move.partners/analytics_coverage/signatures/ca.yaml(29 cases) andedge_cases/state/ca/riv_general_relief.yaml(3 cases) pass unchanged, and no file underpartners/is edited.ca_riv_general_relief_countable_property_valueis now an SPM-unit variable, so a caller that set it as a person input must set it on the SPM unit. No repo file or partner test does.Caveats
ca_withheld_income_taxis an estimate from the person's whole AGI, so withholding attributable to a pension or interest is still deducted from that same person's wages. This PR only stops it moving to other members.axiom: us:statutes/26/3102/f/1#additional_medicare_withholding_wages_subject_to_subsection_a encoded-correct (companion tests
additional_medicare_withholding_applies_only_to_employer_wages_above_threshold, $250,000 from one employer → $50,000 subject to withholding, the base of this PR's $450 case, andadditional_medicare_withholding_zero_at_threshold; rate us:statutes/26/3101/b/2#additional_medicare_tax_rate; rulespec-usf468c8da) | Riverside GR n/a: rulespec-us has no Riverside County (or any California county) General Relief module, and the only source, Riverside DPSS manual DP 90-001, is not public and not in axiom-corpus, so a queued issue could not quote the rule🤖 Generated with Claude Code