Skip to content

Fix UT fully refundable EITC reform crash and zero-refund bug#8645

Open
PavelMakarchuk wants to merge 2 commits into
mainfrom
fix-ut-fully-refundable-eitc-reform-crash
Open

Fix UT fully refundable EITC reform crash and zero-refund bug#8645
PavelMakarchuk wants to merge 2 commits into
mainfrom
fix-ut-fully-refundable-eitc-reform-crash

Conversation

@PavelMakarchuk

Copy link
Copy Markdown
Collaborator

Fixes #8644

Problem

Triggering the bundled Utah fully-refundable-EITC contrib reform (gov.contrib.states.ut.child_poverty_impact_dashboard.eitc.in_effect) crashed the simulation. After working around the crash, the reform also failed to actually pay the EITC as refundable for the low-liability filers refundability is meant to help — same dual-bug profile as the Missouri reform fixed in #8642.

Three bugs fixed in ut_fully_refundable_eitc_reform.py

1. add() received a parameter path string (crash). ut_non_refundable_credits.formula passed the literal string "gov.states.ut.tax.income.credits.non_refundable" to add(), which iterates it character by character — get_variable("g") returns NoneAttributeError: 'NoneType' object has no attribute 'entity'. Now resolves the parameter to its list of variable names first.

2. Mixed computation modes (crash on core ≥3.26.8). ut_refundable_credits redeclared a formula but inherited adds from the baseline variable, tripping the engine's strict mode check (ValueError: ... mixes computation modes). Now sets adds = None and subtracts = None explicitly.

3. Refundable credit capped at tax liability (silent zero-refund). ut_fully_refundable_eitc returned ut_eitc — the applied credit capped at UT tax liability — so a zero-liability filer received $0 even though refundability should pay the full amount. Now uses ut_eitc_potential (uncapped at liability; the W-2 wages cap mandated by Utah Code § 59-10-1044 still applies as designed). Same functional fix the MO PR applied via mo_wftc_potential.

Verification

Reproduced the issue's exact script — runs without raising. Verified the reform's effect against baseline using the YAML regression test below: a Utah filer with eitc = 5_000, employment_income = 30_000, and ut_income_tax_before_non_refundable_credits = 0 (i.e. zero state liability) now receives the full ut_eitc_potential = 1_000 as ut_refundable_credits, where the buggy reform returned $0.

Tests

  • New tests/policy/reform/ut_fully_refundable_eitc.yaml: verifies the full potential UT EITC is paid as refundable at zero liability, the nonrefundable portion is zeroed, and there's no double-counting when liability already absorbs the credit.
  • Existing contrib tests at tests/policy/contrib/states/ut/child_poverty_impact_dashboard/eitc/ut_fully_refundable_eitc.yaml updated to drive from federal eitc (rather than injecting the capped ut_eitc), in line with the new uncapped behaviour.
  • All 180 Utah baseline tests still pass.
  • The test_non_refundable_credit_downstream_consumers.py invariant still passes (the reform's reference to ut_eitc in ut_non_refundable_credits is unchanged).

🤖 Generated with Claude Code

PavelMakarchuk and others added 2 commits June 15, 2026 22:07
Mirrors the MO fix in #8642 for Utah's analogous bundled reform.

- ut_refundable_credits: clear inherited adds/subtracts so the reform's
  formula doesn't trip the core engine's strict computation-mode check.
- ut_non_refundable_credits: resolve the non_refundable parameter to a
  list of variable names before passing it to add() — the previous
  literal string was iterated character-by-character at calc time.
- ut_fully_refundable_eitc: pay the uncapped potential credit
  (ut_eitc_potential) instead of the tax-liability-capped ut_eitc so the
  reform delivers a refund to zero-liability filers.

Fixes #8644

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
…erage

- ut_non_refundable_credits: switch from `add() then subtract ut_eitc` to
  `ordered_capped_state_non_refundable_credits` with ut_eitc filtered out
  of the ordered list. The previous form overstated the non-refundable
  total whenever the bucket binds at liability — the ordered cap must
  walk the credit list to free each later credit's slot correctly. This
  matches the baseline ut_non_refundable_credits computation exactly,
  except EITC is removed because it is paid as refundable here.

- Add three regression tests: W-2 wages cap (Utah Code § 59-10-1044)
  binding under the reform, a self-employment-only filer receiving no
  refundable credit (no W-2 wages → zero potential), and confirmation
  that the reformed credit is paid without double-counting at partial
  liability.

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

DTrim99 commented Jun 18, 2026

Copy link
Copy Markdown
Collaborator

PR Review — #8645: Fix UT fully refundable EITC reform crash and zero-refund bug

The Utah member of a three-PR family of state refundable-EITC reform fixes (alongside #8642 MO and #8657 OH). Reviewed read-only for correctness, code patterns, test coverage, and the one red CI check. All three claimed fixes verified correct.

🔴 Critical (Must Fix)

None. The fixes are correct. (The red CI check is an unrelated runner timeout — see CI diagnosis.)

🟡 Should Address

  1. Re-run the failed Full Suite - Contrib (states-shard-2) — it is not a real failure. The shard died with exit code 143 (SIGTERM / runner shutdown) during unrelated Rhode Island tests (ri/ctc_reform_test.yaml, ri/exemption_reform_test.yaml) in Batch 15 — a job timeout, not a UT failure. The UT reform tests themselves passed earlier in the same job (ut_fully_refundable_eitc.yaml …, batch reported 35 passed). It's on the latest commit (a7b5961), so a maintainer re-run is warranted before merge; expect green.
  2. Add absolute_error_margin: 0.01 to the currency assertions in both tests/policy/reform/ut_fully_refundable_eitc.yaml and the contrib test. Expected values are exact integers (0/300/400/500/1000) so tests pass without it, but the one-cent margin is convention and guards float brittleness.

🟢 Suggestions

  1. Consider asserting ut_non_refundable_credits directly in one zero-liability case to lock the "EITC removed from the bucket, counted once" behavior at the aggregator level (currently inferred via ut_income_tax: 0).

Findings detail

  • Bug (a) — string→add() crash: old ut_non_refundable_credits.formula passed the bare param path to add(), which iterates it char-by-char → get_variable("g")AttributeError. Fix resolves the non_refundable parameter to its list first, then feeds the ordered-cap helper. Correct.
  • Bug (b) — adds = None/subtracts = None: baseline ut_refundable_credits uses adds = "…credits.refundable"; the reform replaces it with a formula, so clearing both is the right defensive pattern. (The "mixes computation modes" ValueError guard is core ≥3.26.8; still correct and forward-compatible.)
  • Bug (c) — capped→uncapped, no double-count: ut_eitc is liability-capped → $0 at zero liability; fix returns ut_eitc_potential (uncapped, still applies the §59-10-1044 W-2-wages cap). The reform's new ut_non_refundable_credits walks the same ordered list as baseline minus ut_eitc, so EITC is counted exactly once — refundable side only. The switch from a naive sum − ut_eitc to the ordered walk (2nd commit) is correct and necessary so the ordered cap frees EITC's slot for later credits. "Fully refundable for all filers incl. childless" semantics match intent.
  • Code patterns: period usage correct; valid import of ordered_capped_state_non_refundable_credits; no hard-coding (rate 0.2 from params; 5000×0.2=1000, 2500×0.2=500 verified). No code-health allowlist change in the diff.

CI diagnosis

Check Full Suite - Contrib (states-shard-2) (run 27589687418, job 81568058302, head a7b5961)
Root cause Job timeout / runner shutdown (exit 143, SIGTERM) during unrelated RI tests in Batch 15; make: *** Terminated, "runner received a shutdown signal"
UT tests in that job PASSED (ut_fully_refundable_eitc.yaml, 35 passed); shards 1 / other-1/2 / congress all green
Verdict Infrastructure timeout, not caused by this PR — re-run to clear

Validation Summary

Check Result
Bug (a) add()-string crash fix PASS
Bug (b) adds/subtracts cleared PASS
Bug (c) uncapped ut_eitc_potential, counted once PASS — no double-count
§59-10-1044 W-2 wages cap preserved PASS
"Fully refundable" semantics PASS — matches intent
Period / naming / no hard-coding PASS
Test coverage of all 3 bugs PASS (boundary cap, partial-liability, SE-only)
absolute_error_margin: 0.01 on currency MISSING (cosmetic)
Changelog fragment (.fixed.md, top-level) PASS
CI shard-2 failure Infra timeout (exit 143), not UT-related — re-run

Review Severity: APPROVE

The three fixes are correct, no double-counting, and well-tested. The red check is a runner timeout on unrelated RI tests, not a defect in this PR — re-run to clear. Adding the currency margin is minor optional polish.

hua7450 pushed a commit to hua7450/policyengine-us that referenced this pull request Jun 18, 2026
Mirrors the UT fix in PolicyEngine#8645 for Ohio's analogous bundled reform.

- oh_refundable_eitc: pay the uncapped potential credit
  (oh_eitc_potential) instead of the tax-liability-capped oh_eitc so the
  reform delivers a refund to zero-liability filers (the case
  refundability is meant to help).
- oh_non_refundable_credits: replace the formula that returned only
  oh_non_refundable_eitc (= 0) — which silently discarded Ohio's other
  six non-refundable credits — with ordered_capped_state_non_refundable_credits
  on the same ordered list, filtering out oh_eitc since it is paid as
  refundable here.

Updates the contrib tests to drive from federal eitc and pin
oh_income_tax_before_non_refundable_credits, mirroring the UT pattern,
and adds a new regression test verifying that other OH non-refundable
credits (e.g. oh_joint_filing_credit) still apply under the reform.

Fixes PolicyEngine#8656

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
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.

UT fully refundable EITC reform (create_ut_fully_refundable_eitc) crashes when triggered

2 participants