-
Notifications
You must be signed in to change notification settings - Fork 1
Add negative income edge cases and bracket threshold patterns #27
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
Adds critical edge case pattern discovered from WV homestead credit bug: - Negative household income combined with zero deductible expenses - This combination often reveals incorrect eligibility calculations - Tax credits need to handle this case explicitly Real-world example: WV homestead excess property tax credit incorrectly calculated $120 credit when income was negative and property tax was $0. The bug was in eligibility logic that didn't properly handle negative income thresholds. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
Add critical guidance for bracket-based parameters where negative input values are possible (e.g., AGI can be negative). The first bracket threshold must be -.inf rather than 0 to correctly handle all cases. Based on learning from PolicyEngine/policyengine-us#6953 (Hawaii Food/Excise Tax Credit), where using 0 as the first threshold incorrectly excluded taxpayers with negative AGI. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
Documents critical pattern: state income taxes should reference federal income sources (like adjusted_gross_income) rather than redefining income sources at the state level. This prevents bugs like PolicyEngine/policyengine-us#6964 where Mississippi incorrectly allowed unlimited capital losses because it bypassed federal capital loss limits. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
Additional learning: State income tax conformityAdded new guidance on state income tax conformity to federal rules. Key pattern documented: Context: Changes:
This will help prevent similar bugs in future state income tax implementations. |
Discovered from MT income tax bug fix: when subtracting values and flooring at zero, must wrap entire subtraction in max_(), not just one operand. Pattern prevents "phantom income" bugs where max_(income, 0) - loss can produce negative results when loss > income. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
Captures learning from Montana income tax bug fix (PolicyEngine/policyengine-us#6947): - Phantom non-zero tax despite zero taxable income - Root causes: type conversion issues and missing zero-income short-circuits - Debugging steps for tracing calculation chains This pattern will help future sessions diagnose similar state tax calculation bugs more quickly. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
When implementing state tax credits and income-based programs, statutes often specify modified income definitions (e.g., "AGI plus exemptions") rather than standard measures. This is a common source of bugs. Added warnings and examples to: - implementation-validator: validation checklist for income measures - document-collector: guidance on capturing exact income definitions Real-world example: Arizona Family Tax Credit uses "AGI plus exemptions" per ARS 43-1073, not just AGI alone. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
Summary
Adds three critical patterns learned from recent PolicyEngine-US bug fixes:
Changes
Testing Patterns (from #6948)
>instead of>=Parameter Patterns (from #6953)
-.inf(not0) when negative values are valid-.infvs when0is appropriateVectorization Patterns (from #6965)
max_()when subtracting and flooring at zeromax_(A - B, 0)NOTmax_(A, 0) - BContext
Testing edge case (#6948): WV homestead excess property tax credit incorrectly calculated $120 refund when household income was negative AND property tax paid was $0. TaxAct correctly showed $0, highlighting the importance of this edge case.
Bracket threshold pattern (#6953): Hawaii Food/Excise Tax Credit used
0as first bracket threshold, incorrectly excluding taxpayers with negative AGI. Using-.infcorrectly handles all cases including business losses.Subtraction flooring pattern (#6965): Montana income tax used
max_(income, 0) - capital_gainswhich created phantom taxable income when capital losses occurred. The correct patternmax_(income - capital_gains, 0)properly floors the entire subtraction result at zero.All three are subtle but important patterns that will help prevent similar bugs in future implementations.
🤖 Generated with Claude Code