Skip to content

Remove SSTB/QBI compat shim, require policyengine-us 1.637.0#770

Merged
MaxGhenis merged 3 commits into
mainfrom
slim-sstb-compat
Apr 17, 2026
Merged

Remove SSTB/QBI compat shim, require policyengine-us 1.637.0#770
MaxGhenis merged 3 commits into
mainfrom
slim-sstb-compat

Conversation

@MaxGhenis

Copy link
Copy Markdown
Contributor

Summary

Collapse the two-sided SSTB/QBI implementation that landed across #701 (data) and policyengine-us#7944 (model). With policyengine-us 1.637.0 shipping the SSTB inputs and formulas natively, the compat shim in policyengine_us_data/utils/policyengine.py no longer has a job to do.

  • Bumps the policyengine-us floor from >=1.572.5 to >=1.637.0 and regenerates uv.lock.
  • Deletes the 357-line ensure_policyengine_us_compat_variables function that monkey-patched CountryTaxBenefitSystem.__init__ to backfill sstb_self_employment_income, sstb_w2_wages_from_qualified_business, sstb_unadjusted_basis_qualified_property, sstb_self_employment_income_would_be_qualified, sstb_qualified_business_income, total_self_employment_income, and the SSTB-aware QBI/QBID formulas.
  • Removes the three import-time and validate_database call sites that triggered the shim.
  • Drops the three compat-specific unit tests in tests/unit/test_package_imports.py — they exercised the shim's QBID arithmetic, which is now covered by policyengine-us's own test suite.
  • Renames test_validate_database_accepts_compat_variablestest_validate_database_accepts_total_self_employment_income since the variable is no longer compat.

Net diff: +14 / −578 lines across 7 files (plus the lockfile).

Why

The original shim was a pragmatic bridge while policyengine-us and policyengine-us-data shipped the split on independent release cadences. Keeping it indefinitely has two costs:

  • Policy formula logic (QBI split, QBID caps) living in a data package duplicates what policyengine-us owns and risks drift on future tweaks.
  • A global CountryTaxBenefitSystem.__init__ monkey-patch is a side effect that's hard to reason about for downstream consumers.

The shim was self-disabling (needs_sstb_qbi_compat = "sstb_qualified_business_income" not in tbs.variables), so removing it is purely a dead-code cleanup for any consumer on policyengine-us 1.637.0+.

Test plan

  • ruff format --check . — clean
  • uv lock — resolves cleanly with 1.637.0
  • PR CI: unit tests, smoke test, changelog fragment, docs build
  • PR CI: integration tests (triggered by the policyengine-us-data/ changes)

Note: changelog fragment is named +slim-sstb-compat.changed.md as a placeholder; will rename to <PR_NUMBER>.changed.md after this PR lands its number.

🤖 Generated with Claude Code

MaxGhenis and others added 3 commits April 16, 2026 23:46
policyengine-us 1.637.0 adds `sstb_self_employment_income`,
`sstb_w2_wages_from_qualified_business`,
`sstb_unadjusted_basis_qualified_property`,
`sstb_self_employment_income_would_be_qualified`,
`sstb_qualified_business_income`, `total_self_employment_income`, and
the SSTB-aware QBI formulas as first-class variables (PR #7944). The
data package no longer needs to backfill them.

Bump the `policyengine-us` floor to `>=1.637.0`, delete the
`ensure_policyengine_us_compat_variables` monkey-patch and its three
call sites, and drop the compat-specific unit tests that validated the
shim's SSTB variable registration and QBID arithmetic — those
behaviors are now covered by policyengine-us's own test suite.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@MaxGhenis MaxGhenis merged commit 60278a1 into main Apr 17, 2026
8 of 9 checks passed
@MaxGhenis MaxGhenis deleted the slim-sstb-compat branch April 17, 2026 12:07
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.

1 participant