Skip to content

Harden state nonrefundable credit guardrails#7992

Merged
PavelMakarchuk merged 3 commits intoPolicyEngine:mainfrom
MaxGhenis:issue7991-credit-hardening
Apr 14, 2026
Merged

Harden state nonrefundable credit guardrails#7992
PavelMakarchuk merged 3 commits intoPolicyEngine:mainfrom
MaxGhenis:issue7991-credit-hardening

Conversation

@MaxGhenis
Copy link
Copy Markdown
Contributor

Summary

  • document the shared *_potential vs applied-credit convention for ordered state nonrefundable credits
  • add helper-level invariant tests for remaining-liability calculation and ordered capping
  • add a code-health guard that flags new downstream consumers of applied credit variables unless they have been reviewed intentionally

Why

PR #7984 split several state credits into potential and applied forms. The Maryland refundable CDCC regression showed that downstream formulas can silently read the applied amount when a form or worksheet really refers to the pre-ordering amount. This PR makes that distinction explicit and adds tests around the specific bug class.

Impact

This does not change any state credit amounts directly. It hardens the shared helper semantics and adds regression coverage so future split-credit refactors are less likely to reintroduce Maryland-style downstream-consumer bugs.

Validation

  • pytest policyengine_us/tests/core/test_non_refundable_credit_cap.py policyengine_us/tests/code_health/test_non_refundable_credit_downstream_consumers.py -q
  • python -m policyengine_core.scripts.policyengine_command test -c policyengine_us policyengine_us/tests/policy/baseline/gov/states/md/tax/income/credits/md_refundable_cdcc.yaml policyengine_us/tests/policy/baseline/gov/states/de/tax/income/credits/eitc/de_eitc.yaml policyengine_us/tests/policy/baseline/gov/states/de/tax/income/credits/eitc/refundability_calculation/de_income_tax_if_claiming_non_refundable_eitc.yaml policyengine_us/tests/policy/baseline/gov/states/ky/tax/income/credits/family_size_tax_credit/ky_family_size_tax_credit.yaml policyengine_us/tests/policy/baseline/gov/states/la/tax/income/credits/child_care_expense_credit/la_school_readiness_tax_credit.yaml policyengine_us/tests/policy/baseline/gov/states/ny/tax/income/credits/ny_eitc.yaml policyengine_us/tests/policy/baseline/gov/states/va/tax/income/credits/eitc/va_eitc.yaml policyengine_us/tests/policy/baseline/gov/states/va/tax/income/credits/eitc/va_eitc_person.yaml policyengine_us/tests/policy/baseline/gov/states/va/tax/income/credits/eitc/refundability_calculation/va_income_tax_if_claiming_non-refundable_eitc.yaml

Closes #7991.

@codecov
Copy link
Copy Markdown

codecov bot commented Apr 14, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 96.00%. Comparing base (0671338) to head (29d1ea6).
⚠️ Report is 21 commits behind head on main.

Additional details and impacted files
@@             Coverage Diff             @@
##              main    #7992      +/-   ##
===========================================
- Coverage   100.00%   96.00%   -4.00%     
===========================================
  Files            4        1       -3     
  Lines           72       25      -47     
  Branches         0        3       +3     
===========================================
- Hits            72       24      -48     
- Partials         0        1       +1     
Flag Coverage Δ
unittests 96.00% <ø> (-4.00%) ⬇️

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.

@MaxGhenis MaxGhenis marked this pull request as ready for review April 14, 2026 01:53
@PavelMakarchuk PavelMakarchuk merged commit beafb9f into PolicyEngine:main Apr 14, 2026
8 of 9 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.

Harden state nonrefundable credit potential/applied patterns

2 participants