Skip to content

Fix federal disability gates disconnected from their legal definitions - #9345

Open
hua7450 wants to merge 6 commits into
mainfrom
fix/disability-input-disconnects
Open

Fix federal disability gates disconnected from their legal definitions#9345
hua7450 wants to merge 6 commits into
mainfrom
fix/disability-input-disconnects

Conversation

@hua7450

@hua7450 hua7450 commented Aug 25, 2026

Copy link
Copy Markdown
Collaborator

Summary

Part of the disconnected-disability-inputs audit (#9330). Fixes the six federal findings: gates whose statutes define disability by SSI/SSDI receipt or by cross-reference to the Social Security Act, but which read only the generic is_disabled flag (or, inversely, an SSI-criteria flag where the law requires receipt).

Fixes #9329
Fixes #9331
Fixes #9332
Fixes #9333
Fixes #9334
Fixes #9337

Changes

Issue Gate Legal basis Fix
#9332 disabled_programs.yamlis_usda_disabled 7 CFR 271.2 item (2): "Receives supplemental security income benefits … or disability or blindness payments" Replace is_ssi_disabled (criteria flag, no receipt test, drops blind SSI recipients) with receives_ssi + ssi (reported or modeled receipt). is_usda_disabled stays an annual status, like is_usda_elderly, using Core's default period resolution for the monthly inputs.
#9331 SNAP ABAWD exemption, work registration, general work requirements, student rule 7 CFR 273.7(b)(1)(ii): receipt of temporary or permanent disability benefits establishes unfitness for employment; 7 CFR 273.24(c)(2) OR is_usda_disabled into each disability leg
#9333 SSI student earned income exclusion 20 CFR 416.1112(c)(3): applies to a blind or disabled claimant under SSA's own definition is_disabledmeets_ssi_disability_criteria. The SGA screen in is_ssi_disabled is deliberately left out: it is an initial-entitlement test, section 1619(a) recipients keep SSI status above SGA, and the exclusion also feeds MSP, Medicaid, and state supplement income methodologies that have no SGA test.
#9334 Medicaid home equity family exception 42 U.S.C. 1396p(f)(2)(A)(ii)(II): child "blind or permanently and totally disabled as defined in section 1614" Add is_ssi_disabled to the resident-child disability legs
#9329 Medicaid work requirement (community engagement) HR1 §71119: exemption for individuals "blind or disabled (as such terms are defined in section 1614)" Add is_ssi_disabled to eligible_disabled
#9337 HUD elderly/disabled family + HUD dependent 42 U.S.C. 1437a(b)(3)(E): person with disabilities includes the SSA §223 (SSDI) definition Add is_ssi_disabled and SSDI receipt paths; drop stray unit = USD on the boolean

Also clarifies the disabled_programs description and is_usda_disabled documentation: per 271.2 item (2) any SSI receipt qualifies (including aged-category recipients, who are 65+ and always also qualify under the elderly test, so no consumer's outcome changes through the aged path).

Not in this PR

Tests

  • is_usda_disabled.yaml rewritten to exercise the receipt list directly: receives_ssi, an ssi input, modeled SSI receipt, blind and aged SSI recipients, SSDI receipt, and the negative case where is_ssi_disabled is true but income is too high for SSI (ssi: 0, is_usda_disabled: false). The student exclusion test gains a case where a student earning above SGA keeps the exclusion.
  • Review follow-ups: an SSI-receipt case on each of the four SNAP gates (receives_ssi on ABAWD, work registration, and the student rule; an ssi amount on general work requirements), zero-SSDI negative controls on both HUD variables, a home equity case where the resident child does not meet the SSI disability test, and a non-disabled above-SGA mirror for the student exclusion. The previous "SSI disabled" case only passed because a zero-income person becomes modeled-SSI-positive under default takeup.
  • One benefit-receipt case appended to each formula that gained an SSI or SSDI leg, with is_disabled: false so the new path is what carries the result: SNAP ABAWD exemption, work registration exemption, general work requirements (with the noncompliance flag set), student rule, Medicaid work requirement, Medicaid home equity family exception, HUD elderly/disabled family, and HUD dependent.

Review follow-ups (@DTrim99)

  • Citations: 42 U.S.C. 1382c(a)(3) added for the blind-or-disabled precondition of the student exclusion, with an inline note that 20 CFR 416.1112(c)(3) sets only the age and student conditions. The "receipt establishes unfitness" rule is now pinned to 7 CFR 273.24(c)(2)(i), applied by analogy to the 273.7(b)(1)(ii) exemption, in the work registration, general work requirement, and student rules.
  • Reference attributes: the new authorities are on the variables, not only in comments: 1382c(a)(3) on the Medicaid work requirement, 42 U.S.C. 1437a(b)(3)(E) on both HUD variables, 273.24(c)(2) on the SNAP student rule and the two SNAP work rules, and 7 CFR 271.2 on is_usda_disabled.
  • Idiom: is_usda_disabled uses add(person, period, [program]) > 0 per entry, as in is_ssi_recipient_for_medicaid. Results are unchanged in household and microsimulation runs.
  • HUD SSDI path: noted inline as a modeling proxy for the section 223 definition.
  • Parameter description: SNAP spelled out; a comment notes that amount entries are truthiness-tested. No fragment anchor on the 271.2 link, since Cornell exposes no stable per-definition anchor on that page.
  • Not taken: the optional month-input aggregation test for is_usda_disabled; the variable keeps Core's default period resolution.

Impact channels

Checklist

  • Code formatted (make format)
  • Changelog fragment (changelog.d/fix-disability-input-disconnects.fixed.md)
  • Rebased on main
  • CI passes

🤖 Generated with Claude Code

@codecov

codecov Bot commented Aug 25, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 30.00000% with 7 lines in your changes missing coverage. Please review.
✅ Project coverage is 42.20%. Comparing base (a68c725) to head (6621f87).
⚠️ Report is 7 commits behind head on main.

Files with missing lines Patch % Lines
.../eligibility/medicaid_work_requirement_eligible.py 0.00% 2 Missing ⚠️
...ariables/gov/hud/is_hud_elderly_disabled_family.py 0.00% 1 Missing ⚠️
.../eligibility/student/is_snap_ineligible_student.py 0.00% 1 Missing ⚠️
...gibility/work_requirements/is_snap_abawd_exempt.py 0.00% 1 Missing ⚠️
...ements/is_snap_work_registration_exempt_non_age.py 0.00% 1 Missing ⚠️
...quirements/meets_snap_general_work_requirements.py 0.00% 1 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##              main    #9345       +/-   ##
============================================
- Coverage   100.00%   42.20%   -57.80%     
============================================
  Files            1       10        +9     
  Lines           37      218      +181     
  Branches         2        0        -2     
============================================
+ Hits            37       92       +55     
- Misses           0      126      +126     
Flag Coverage Δ
unittests 42.20% <30.00%> (-57.80%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@hua7450
hua7450 marked this pull request as ready for review August 25, 2026 05:15
@hua7450
hua7450 marked this pull request as draft August 25, 2026 15:07
@hua7450
hua7450 force-pushed the fix/disability-input-disconnects branch from 6621f87 to 54f61be Compare September 3, 2026 05:18
@hua7450
hua7450 marked this pull request as ready for review September 3, 2026 16:35
@hua7450
hua7450 requested a review from DTrim99 September 3, 2026 17:42
@DTrim99

DTrim99 commented Sep 3, 2026

Copy link
Copy Markdown
Collaborator

Program Review — PR #9345 (reconnect federal disability gates to legal definitions)

Scope

  • Federal multi-program: USDA "elderly or disabled member" (7 CFR 271.2) receipt-based redefinition; SNAP work/ABAWD/registration/student gates gain the is_usda_disabled path; Medicaid work-requirement + home-equity family exception gain the Section 1614 SSI test; HUD disability gains is_ssi_disabled/social_security_disability paths (and drops a stray unit=USD on boolean vars); SSI student exclusion drops the SGA screen (uses meets_ssi_disability_criteria).
  • Source: CFR/USC HTML citations (no dollar-table PDF).

All four sub-reviews (regulatory, references, code patterns, test coverage) independently confirm the PR's core thesis is sound and that every disability variable is a REUSED existing variable — no reinvented/duplicate variables, no hard-coded policy magnitudes, all changes monotonic OR-ins that preserve pre-existing paths (except the intentional, documented SGA-screen drop in the SSI student exclusion).

Critical (Must Fix)

None.

(The references reviewer initially flagged the SSI student-exclusion citation as critical. On merge it is reclassified SHOULD ADDRESS: 20 CFR 416.1112(c)(3) is the correct governing provision for the student earned-income exclusion itself — this is a too-narrow/incomplete corroboration of the retained blind/disabled precondition, not a wrong-section pointer. See Should Address #1.)

Should Address

  1. SSI student exclusion — cited paragraph does not source the retained "blind or disabled" precondition. variables/gov/ssa/ssi/eligibility/income/is_ssi_blind_or_disabled_working_student_exclusion_eligible.py:10 (class reference = 20 CFR 416.1112(c)(3)). 416.1112(c)(3) is the student earned-income exclusion and is conditioned only on age (<22) and student status; it does not itself impose the is_blind | meets_ssi_disability_criteria screen the variable retains. The §1619(a) rationale for dropping the SGA screen is sound and correct. Add a supporting cite for the blind/disabled precondition (Section 1614 / 42 USC 1382c — the SSI-status context in which this exclusion sits), or note inline that (c)(3) is age/student-only and the blind-or-disabled framing derives from the enclosing SSI branch.

  2. Imprecise CFR pin-cite: "receipt establishes unfitness" attributed to 7 CFR 273.7(b)(1)(ii). is_snap_work_registration_exempt_non_age.py and meets_snap_general_work_requirements.py (comments above the is_usda_disabled/is_disabled line). The text enumerating "receiving temporary or permanent disability benefits ... establishes unfitness" actually lives in 7 CFR 273.24(c)(2)(i) (ABAWD medical-unfitness), not in 273.7(b)(1)(ii) — which only says "physically or mentally unfit for employment" and delegates the definition to the State agency. The modeling choice (treat benefit receipt as unfitness across SNAP work provisions) is defensible and consistent; repoint the pin-cite in these two files to 273.24(c)(2)(i) as the source of the "receipt establishes unfitness" rule, or state it is applied by analogy. (The ABAWD file is_snap_abawd_exempt.py is correctly grounded in 273.24(c)(2).)

  3. New disability paths documented only inline, not in the machine-readable reference attribute. The added statutory authorities are accurate but sit only in comments on:

    • medicaid_work_requirement_eligible.py — add Section 1614 / 42 USC 1382c (or the HR1 subsection defining "blind or disabled").
    • is_hud_dependent.py (class reference = 24 CFR 5.603) and is_hud_elderly_disabled_family.py (24 CFR 5.611) — add 42 USC 1437a(b)(3)(E) (the §223/42 USC 423 disability definition; the inline "section 223 SSA" wording is verified correct).
    • is_snap_ineligible_student.py (class reference = 7 USC 2015#e) — add anchored 7 CFR 273.7(b)(1)(ii) (or 273.24(c)(2)(i)), the source of the newly-added receipt path.
      (The three SNAP work-requirement gates already carry adequate #b_1 / 273.24 anchors.)
  4. is_usda_disabled mixes MONTH-defined inputs into a YEAR np.logical_or.reduce without the codebase's add(...) > 0 idiom. variables/gov/usda/is_usda_disabled.py + parameters/gov/usda/disabled_programs.yaml. The YEAR variable now lists receives_ssi (MONTH bool) and ssi (MONTH float); reading each at a YEAR period auto-sums 12 months then coerces to bool. Functionally correct (any nonzero month → True; the HEAD commit removed the old month-summing special case that crashed calculate_add), but every other year-period SSI-receipt test in the codebase uses (person("ssi", period) > 0) | (add(person, period, ["receives_ssi"]) > 0) (e.g. is_ssi_recipient_for_medicaid.py). Align to that idiom for robustness/readability; relying on implicit MONTH→YEAR summation inside a logical_or.reduce over mixed bool/USD names is fragile.

  5. Missing SSI-receipt-leg edge tests on the SNAP gates. For is_snap_ineligible_student, is_snap_abawd_exempt, is_snap_work_registration_exempt_non_age, and meets_snap_general_work_requirements, the new exemption is is_disabled | is_usda_disabled but each is tested only via the SSDI (social_security_disability) sub-path. is_usda_disabled also routes SSI receipt (receives_ssi/ssi); add at least one SSI-receipt case per gate to confirm that leg flows through. (SSI receipt is separately proven in is_usda_disabled.yaml, so this is a completeness gap, not a coverage hole for the underlying variable.)

  6. Missing negative controls on two new > 0 / SSI-disabled branches.

    • is_hud_dependent / is_hud_elderly_disabled_family: the social_security_disability > 0 branch is tested only at 12_000; add a social_security_disability: 0 (no other disability) case to harden the 0-boundary.
    • medicaid_home_equity_limit_family_exception: Case 19 shows an is_ssi_disabled child firing the exception, but there is no paired is_ssi_disabled: false case confirming it does NOT fire — add one to guard against silent over-triggering.

Suggestions

  1. HUD SSDI path is a receipt proxy for the §223 definition. is_hud_elderly_disabled_family.py, is_hud_dependent.py. 42 USC 1437a(b)(3)(E) is definition-based (nature of impairment); social_security_disability > 0 is SSDI receipt, an under-inclusive proxy for §223 claimants. Added as an alternative via |, so it only broadens — not a defect. Note inline that it is a modeling approximation rather than the literal statutory test.

  2. disabled_programs.yaml — spell out SNAP and tighten anchors. Description uses the bare acronym SNAP and omits the standard ... under the [Full Program Name] program closing; consider spelling out Supplemental Nutrition Assistance Program. Separately, add a fragment anchor to the long 7 CFR 271.2 definitions section (and optionally a self-documenting bare-string reference on is_usda_disabled.py, currently absent). A one-line comment noting that the amount entries (ssi, social_security_disability) are truthiness-tested would aid future readers.

  3. Optional documentation tests. A MONTH-input microsim-style test for the YEAR aggregation of monthly SSI receipt in is_usda_disabled; and an above-SGA meets_ssi_disability_criteria: false mirror case in the SSI student exclusion documenting that non-disabled students never qualify regardless of income. The changelog fragment (fix-disability-input-disconnects.fixed.md, type fixed) accurately enumerates all six behavioral changes.

Validation Summary

Check Result
Regulatory PASS — 7 CFR 271.2 / 273.24 / 42 USC 1396p(f) / 20 CFR 416.1112 / §1614 direction of change confirmed; 1 imprecise pin-cite (SHOULD)
References PASS with gaps — parameter reference exemplary; new paths documented inline but partly absent from reference attribute (SHOULD)
Code patterns PASS — 0 hard-coded values, all vectorized, all monotonic, periods/entities correct, no duplicate variables; 1 idiom robustness note (SHOULD)
Test coverage PASS — every changed formula has a positive branch test incl. the SGA-drop regression guard (is_usda_disabled Case 5); missing SSI-leg + negative-control edges (SHOULD)
CI status passing

Branch Status

⚠ PR branch is 24 commits behind main. Consider rebasing before merging. Review was scoped to the PR's actual changes — staleness did not affect findings.

Review Severity: APPROVE

No CRITICAL findings survive the merge. The PR is regulatorily sound, reuses all disability variables (no reinvention), is well-tested on its core paths, and passes CI. Remaining items are traceability/precision improvements to references, one idiom-alignment note, and edge-test completeness — all non-blocking.

🤖 /review-program

@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.

No critical issues — the disability-gate reconnections are regulatorily sound (7 CFR 271.2/273.24, 42 USC 1396p(f), 20 CFR 416.1112) and all disability variables are reused, not reinvented. Requesting changes for 6 should-address follow-ups: three are citation-precision (SSI student-exclusion §1614 precondition; the 273.24(c)(2)(i) vs 273.7(b)(1)(ii) pin-cite; add the new authorities to the reference attributes rather than inline comments), one code-idiom (add(...) > 0 in is_usda_disabled), and two test-leg gaps (SSI-receipt leg into the SNAP gates; HUD 0-boundary + Medicaid home-equity negative controls). Full findings above. 🤖 /review-program

hua7450 and others added 6 commits September 4, 2026 21:30
Aligns six federal disability gates with the definitions their statutes
actually reference (part of the #9330 disconnected-disability-inputs
audit):

- SNAP disabled_programs (7 CFR 271.2): qualify by SSI receipt
  (receives_ssi | ssi) instead of the is_ssi_disabled criteria flag,
  which has no receipt test and drops blind SSI recipients.
- SNAP ABAWD, work registration, general work requirements, and student
  rules (7 CFR 273.7(b)(1)(ii), 273.24(c)(2)): disability benefit
  receipt (is_usda_disabled) establishes unfitness for employment.
- SSI student earned income exclusion (20 CFR 416.1112(c)(3)): gate on
  is_ssi_disabled rather than the generic is_disabled flag.
- Medicaid work requirement and home equity family exception
  (42 U.S.C. 1396p(f)(2)): recognize the Section 1614 SSI definition.
- HUD person with disabilities (42 U.S.C. 1437a(b)(3)(E)): recognize
  the SSA Section 223 path via is_ssi_disabled and SSDI receipt; drop
  the stray unit = USD on the boolean.

Fixes #9329
Fixes #9331
Fixes #9332
Fixes #9333
Fixes #9334
Fixes #9337

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
The gate now computes is_ssi_disabled, whose SGA parameter
(gov.ssa.sga.non_blind) has no values before 1975-01-01, so the
1974-period cases crashed on an undefined parameter.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
- Rewrite is_usda_disabled tests to exercise receives_ssi, an ssi input,
  modeled SSI receipt, blind and aged SSI recipients, and the negative case
  where the SSI disability test is met but no SSI is received.
- Add one benefit-receipt case to each formula that gained an SSI or SSDI
  leg: SNAP ABAWD, work registration, general work requirements, student
  rule, Medicaid work requirement, Medicaid home equity family exception,
  HUD elderly/disabled family, and HUD dependent.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
…h SSI receipt for SNAP

- The student earned income exclusion now gates on meets_ssi_disability_criteria
  rather than is_ssi_disabled. The SGA screen is an initial-entitlement test,
  and section 1619(a) recipients keep SSI status above SGA; the exclusion also
  feeds MSP, Medicaid, and state supplement income methodologies that have no
  SGA test, so it must not vanish above the threshold.
- is_usda_disabled reads monthly booleans with the ADD option so reported SSI
  receipt in any month qualifies for the year, matching how monthly amounts
  are annualized. SSI receipt reflects an SSA aged/blind/disabled
  determination that does not lapse month to month.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Drop the month-summing special case for monthly booleans. Core's default
resolution applies: monthly amounts are summed over the year and monthly
booleans are read as stocks. This also removes the ADD-option path that
crashed Microsimulation.calculate_add.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
- Cite 42 U.S.C. 1382c(a)(3) for the blind-or-disabled precondition of the
  SSI student exclusion; 20 CFR 416.1112(c)(3) sets only age and student.
- Repoint the receipt-establishes-unfitness rule to 7 CFR 273.24(c)(2)(i),
  applied by analogy to the 273.7(b)(1)(ii) exemption, in the SNAP work
  registration, general work requirement, and student rules.
- Add the new authorities to reference attributes (Medicaid work
  requirement, HUD dependent, HUD elderly/disabled family, SNAP student).
- Use the add(...) > 0 idiom in is_usda_disabled and add its reference.
- Note that SSDI receipt is a modeling proxy for the HUD section 223 test.
- Spell out SNAP in the disabled_programs description.
- Tests: SSI-receipt leg on the four SNAP gates, zero-SSDI negative controls
  on both HUD variables, a non-triggering home equity case, and a
  non-disabled above-SGA mirror for the student exclusion.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
@hua7450
hua7450 force-pushed the fix/disability-input-disconnects branch from 32291b9 to 857d7c7 Compare September 5, 2026 01:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment