Skip to content

Fix code-health regressions in AR SRA and WA WCCC#8537

Merged
hua7450 merged 1 commit into
PolicyEngine:mainfrom
DTrim99:fix-codehealth-ar-sra-wa-wccc
May 28, 2026
Merged

Fix code-health regressions in AR SRA and WA WCCC#8537
hua7450 merged 1 commit into
PolicyEngine:mainfrom
DTrim99:fix-codehealth-ar-sra-wa-wccc

Conversation

@DTrim99
Copy link
Copy Markdown
Collaborator

@DTrim99 DTrim99 commented May 28, 2026

Summary

Two code-health tests started failing on main after recent merges. Both fixes are localized — total diff is 4 changed lines plus a changelog fragment.

Failures fixed

  1. test_no_builtin_sum_over_entity_calls — flagged policyengine_us/variables/gov/states/ar/ade/oec/sra/income/ar_sra_countable_income.py:21:

    per_person_income = sum(person(source, period) for source in p.income.sources)

    Built-in `sum()` walking a generator with direct `person(...)` calls can break vectorization. Precompute the per-person arrays into a list first, then `sum()` the list — the AST under the `sum()` call no longer contains entity-variable calls.

  2. test_input_variable_definitions::test_input_variables_do_not_use_non_geographic_defined_for — flagged `policyengine_us/variables/gov/states/wa/dcyf/wccc/payment/wa_wccc_provider_type.py` where the input variable had `defined_for = "wa_wccc_eligible_child"`. Non-geographic `defined_for` on an input variable silently zeros user-provided inputs. Replace with the standard `defined_for = StateCode.WA`, matching every other `wa_wccc_*` variable. Downstream consumers (e.g., `wa_wccc_max_monthly_reimbursement`) retain their own eligible-child gates, so output behavior is unchanged.

Context

Test plan

  • `make format` passes
  • CI runs both flagged tests
  • AR SRA YAML test suite continues to pass (precompute is mathematically identical to the generator form)
  • WA WCCC YAML test suite continues to pass (the `defined_for` change only affects what happens to provider-type inputs for non-eligible-children in WA; downstream consumers still gate)

🤖 Generated with Claude Code

Two code-health tests started failing on main after PRs PolicyEngine#8324 (AR SRA)
and PolicyEngine#8208 (WA WCCC) merged. Neither was caught by the originating PRs'
CI because the tests were added later. Both fixes are localized.

1. ar_sra_countable_income.py — `test_no_builtin_sum_over_entity_calls`
   flagged line 21:

       per_person_income = sum(person(source, period) for source in p.income.sources)

   The built-in `sum()` walks an AST containing direct `person(...)`
   calls, which can break vectorization. Precompute the per-person
   arrays into a list, then sum the list (the AST under the `sum()`
   call no longer contains entity-variable calls).

2. wa_wccc_provider_type.py — `test_input_variable_definitions
   ::test_input_variables_do_not_use_non_geographic_defined_for`
   flagged this input variable's `defined_for = "wa_wccc_eligible_child"`.
   Non-geographic `defined_for` on an input variable silently zeros
   user-provided inputs in surprising ways. Replace with the standard
   geographic `defined_for = StateCode.WA`, matching every other
   wa_wccc_* variable. Downstream consumers (e.g.,
   wa_wccc_max_monthly_reimbursement, which retains its own
   eligible-child gate) continue to filter by eligibility, so output
   behavior is unchanged.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@codecov
Copy link
Copy Markdown

codecov Bot commented May 28, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 100.00%. Comparing base (b3356cd) to head (7f028e9).
⚠️ Report is 40 commits behind head on main.

Additional details and impacted files
@@             Coverage Diff             @@
##             main     #8537      +/-   ##
===========================================
+ Coverage   97.20%   100.00%   +2.79%     
===========================================
  Files          22         2      -20     
  Lines         358        30     -328     
  Branches        4         0       -4     
===========================================
- Hits          348        30     -318     
+ Misses          8         0       -8     
+ Partials        2         0       -2     
Flag Coverage Δ
unittests 100.00% <100.00%> (+2.79%) ⬆️

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

☔ View full report in Codecov by Sentry.
📢 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.

@DTrim99 DTrim99 requested review from PavelMakarchuk and hua7450 May 28, 2026 14:55
@hua7450 hua7450 merged commit 1c0c602 into PolicyEngine:main May 28, 2026
26 checks passed
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.

2 participants