Skip to content

Fix circular dependency in NY A06774 Enhanced CDCC reform#7428

Open
DTrim99 wants to merge 2 commits intoPolicyEngine:mainfrom
DTrim99:fix-ny-a06774-circular-dependency
Open

Fix circular dependency in NY A06774 Enhanced CDCC reform#7428
DTrim99 wants to merge 2 commits intoPolicyEngine:mainfrom
DTrim99:fix-ny-a06774-circular-dependency

Conversation

@DTrim99
Copy link
Collaborator

@DTrim99 DTrim99 commented Feb 18, 2026

Summary

Fixes #7427

The NY A06774 Enhanced Child and Dependent Care Credit reform had a circular dependency that caused simulation crashes. The reform's ny_cdcc formula was calling cdcc, which depends on cdcc_credit_limit, which in turn depends on income_tax_before_credits. Since ny_cdcc is a refundable credit that affects state income tax (which feeds into SALT deduction), this created a cycle.

Changes

  • Replace cdcc with cdcc_potential in the reform formula
  • cdcc_potential calculates the credit value (expenses × rate) without the credit limit, avoiding the dependency cycle

Test plan

  • Existing tests pass (expected values are based on cdcc_potential calculation)
  • Manual verification: reform produces correct values ($726 for $40k AGI with $3k expenses)
  • Microsimulation runs without circular dependency error

Related

Use cdcc_potential instead of cdcc in the NY A06774 reform formula to avoid
circular dependency through income_tax_before_credits.

The cdcc variable depends on cdcc_credit_limit which depends on
income_tax_before_credits, creating a cycle when ny_cdcc (a refundable credit)
affects state income tax through SALT deduction.

Fixes PolicyEngine#7427

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@codecov
Copy link

codecov bot commented Feb 18, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 70.80%. Comparing base (aa81546) to head (b7276cf).
⚠️ Report is 48 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #7428   +/-   ##
=======================================
  Coverage   70.80%   70.80%           
=======================================
  Files        3871     3871           
  Lines       55779    55779           
  Branches      276      276           
=======================================
  Hits        39492    39492           
  Misses      16286    16286           
  Partials        1        1           
Flag Coverage Δ
unittests 70.80% <ø> (ø)

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.

# Calculate the enhanced credit (110% of federal CDCC potential)
# Use cdcc_potential instead of cdcc to avoid circular dependency
# (cdcc depends on cdcc_credit_limit which depends on income_tax_before_credits)
federal_cdcc_potential = tax_unit("cdcc_potential", period)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you add tests to make sure this works

Add 5 new tests to verify the circular dependency fix works:
- Married filing jointly with two earners
- Explicit cdcc_potential calculation verification
- Maximum expenses stress test
- Income just above threshold boundary case
- Low income with maximum CDCC rate

All 10 tests pass.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@DTrim99
Copy link
Collaborator Author

DTrim99 commented Feb 19, 2026

Fixes Applied

Tests Added for cdcc_potential Fix

Added 5 new tests to verify the circular dependency fix works correctly:

  1. Married filing jointly with two earners - Tests reform works across filing statuses
  2. Explicit cdcc_potential calculation verification - Validates the intermediate cdcc_potential value
  3. Maximum expenses stress test - Tests with expenses exceeding the cap (scenario that would trigger circular dependency with cdcc)
  4. Income just above threshold boundary case - Tests fallback to standard NY CDCC at $50,001
  5. Low income with maximum CDCC rate - Tests at AGI $15k where federal rate is 35%

Verification

  • ✅ All 10 tests pass (5 existing + 5 new)
  • ✅ Tests explicitly verify cdcc_potential intermediate values
  • ✅ Tests cover edge cases that would expose circular dependency issues

Ready for re-review.

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.

Fix circular dependency in NY A06774 Enhanced CDCC reform

2 participants

Comments