Skip to content

Prefer capital gains components in PUF top-tail guard#168

Merged
MaxGhenis merged 1 commit into
mainfrom
codex/puf-top-tail-component-guard-20260602
Jun 2, 2026
Merged

Prefer capital gains components in PUF top-tail guard#168
MaxGhenis merged 1 commit into
mainfrom
codex/puf-top-tail-component-guard-20260602

Conversation

@MaxGhenis
Copy link
Copy Markdown
Contributor

Summary

  • make the PUF support-clone top-tail guard prefer PE-used capital-gains components (long_term_capital_gains_before_response / long_term_capital_gains plus short_term_capital_gains)
  • fall back to stored capital_gains only when component variables are absent
  • add a regression test for the current failing shape: low stored capital_gains with high LTCG still entering the open-ended AGI bin

Why

The post-#167 rebuild still regressed on the same target:

  • MP latest-local loss: 1.2450774476685147
  • eCPS latest-local loss: 0.7685371816961414
  • top target: state/MD/adjusted_gross_income/amount/1000000_inf

The guard had affected_rows=0 because it used stored capital_gains ~= $14.3M for the bad MD row. PolicyEngine-US does not treat stored capital_gains as authoritative here: during simulation setup it copies long_term_capital_gains into long_term_capital_gains_before_response and removes capital_gains from input variables, so formulas use LTCG/STCG components. The same row had long_term_capital_gains ~= $95.0M, which should have triggered the guard.

Validation

  • uv run ruff check src/microplex_us/pipelines/us.py tests/pipelines/test_us.py
  • uv run ruff format --check src/microplex_us/pipelines/us.py tests/pipelines/test_us.py
  • uv run --extra dev python -m pytest tests/pipelines/test_us.py -k 'puf_support_clone_top_tail_guard' (5 passed)
  • uv run --python 3.13 --extra dev --extra policyengine python -m pytest tests/pipelines/test_us.py (179 passed, 6 expected warnings)

@MaxGhenis
Copy link
Copy Markdown
Contributor Author

Local proof against the completed #167 artifact seed data:

  • input: /Users/maxghenis/CosilicoAI/microplex-us/artifacts/ecps_shaped_cps_puf_support_clone_export_top_tail_guard_no_acs_efc1fd8_20260602/.../seed_data.parquet
  • patched rough AGI variables use LTCG/STCG components, not stored capital_gains
  • guard summary on that seed: affected_rows=1
  • max rough AGI before: 95,107,558.38
  • max rough AGI after: 78,999,999.0
  • rows above cap before: 1
  • rows above cap after: 0

So this patch catches the same artifact shape that #167 missed before we spend another rebuild.

@MaxGhenis MaxGhenis merged commit 0855fd3 into main Jun 2, 2026
5 checks passed
@MaxGhenis MaxGhenis deleted the codex/puf-top-tail-component-guard-20260602 branch June 2, 2026 07:13
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