Repository navigation
Conversation
…ed order Historic Table 2 and congressional-district N01000 count Form 1040 line 7 returns (gain, loss-limited loss or distributions only); Table 1.4 col 37, the population capital_gains_gross measures, counts Schedule D gain returns only. The rebase control is now the latest Table 1.4 fact not after the build period, CD and HT2 rows never qualify, a tie between matched records refuses the compile, and a line-7 row without a usable control is dropped instead of shipping as a level. Rebased rows declare the bridge in soi_source_concept / soi_control_concept. On the pinned feed the 51 national_state HT2 state return counts go from 29,599,604 (2.39x the national 12,392,020 target) back to Build P's 12,289,836; amounts keep their values. national_state registry d315c75804ef -> 65e4dde11c83 (microcosm#1035). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…review) The chooser now treats one record id carrying two values or period labels at the winning period as ambiguous too, so no feed order can pick the value. Tests cover that, an equivalent period label, and a tie at a superseded period. The model-concept comment scopes "no loss returns" to the Build P release data, and the doc's AGI-mix median is the median absolute change. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #1035.
Summary
On the pinned feed, the route-A
national_statesurface calibrates 51 Historic Table 2 (HT2) state capital-gains return counts that sum to 29,599,604. The same surface calibrates the national Table 1.4 target of the same model quantity at 12,392,020, so the states sum to 2.39x the nation. This PR fixes the two causes:The 51 targets return to 12,289,836, which is exactly the Build P release's value. This moves published target values, so it waits on Max's ruling before merge.
What each IRS count measures
The four feed-backed files (
22in14ar.xls,23in14ar.xls,22in55cmcsv.csv,22incd.csv) are sha256-identical to the feed'ssource.source_sha256. The supplementary workbooks (Tables 1.3 and 1.4A, TY2020/21 Table 1.4, TY2023 HT2) are not in the feed and were fetched from irs.gov. Evidence is in~/PolicyEngine/_reviews/cg-returns-control-20260925/(irs-concepts.md).Which one
capital_gains_gross/indicator_sumshould targetTable 1.4 col 37.
capital_gains_grossmaps to PE-UScapital_gains, which is short-term plus long-term, i.e. Schedule D before the loss limit (capital_gains.pyadds).> 0(tools/build_us_fiscal_refresh_release.py_signed_component/_soi_component_row).non_sch_d_capital_gains, which has its own col-35 target.How the control drifted
aggregate_fact_key, a content hash. The congressional-district US row, which is TY2022 data stamped ty2023 (CD record sets stamp 22incd.csv as ty2023 — a tax-year vintage error; add Table 1.4 taxable-interest facts (populace#489) chronicle#117), now sorts first and won (factor 0.97964).What changes (
fiscal_targets.py)_SOI_CAPITAL_GAINS_FAMILY_CONCEPTS: a reviewed register that maps each SOI record-set family to what itsnet_capital_gains_*columns count.table_1_4→schedule_d_taxable_net_gainhistoric_table_2andcongressional_district(any vintage) →form_1040_line_7_net_gain_or_loss_SOI_CAPITAL_GAINS_MODEL_CONCEPTrecords whatcapital_gains_grossmeasures._soi_capital_gains_active_totals:AmbiguousSoiCapitalGainsControlError. There is no feed-order tie-break._rebase_stale_soi_capital_gains_distributions:soi_source_concept/soi_control_concept, so the bridge is declared._soi_record_set_family: strips the period token and the CD data vintage.Effect on the pinned feed
Release compile:
target_period=2024,age_targets=True, packaged CD crosswalk, Medicaid substitution.national_statetargetsnational_stateregistryd315c75804ef65e4dde11c830fc096598516e02123644d42national_staterows plus 9 CD-classified HT2 proxies onfull.experiments/replacement_scorecard/incumbent_48b9d479.json).The share assumption. HT2 shares of line-7 returns stand in for shares of Schedule D gain returns, because IRS publishes no state gain-only count. AGI composition is the one measurable source of difference. Weighting each state's HT2 N01000 by AGI class with Table 1.4's per-class gain share would move TY2022 state targets by −2.9% (WV) to +4.3% (DC), with a median absolute change of 1.6%. That refinement is not applied here.
Invariants
national_state, no SOI state family sums past the largest national target of the same quantity and filters (63 families compared, pinned feed). Before this PR the capital-gains returns family violated this at 2.39x, and it was the only one.Tests
_soi_record_set_familyshapes, including a futurecongressional_district_2024.65e4dde11c83.test_us_fiscal_targets.py: 192 passed, 0 skipped.test_release_target_parity.py,test_us_chronicle_feed.py,test_us_acs_local_release_tool.py(withMICROCOSM_US_CHRONICLE_FACTSset),test_us_spine_blindness.pyandtest_us_source_coverage.py: 622 passed.ruff check .is clean;ruff format --checkis clean on the touched files (59 untouched files on main would be reformatted by the locked ruff, unrelated to this PR).Review
Independent adversarial review (Subfleet
review/standard, served by GPT-6 Astra, report at~/PolicyEngine/_reviews/cg-returns-control-20260925/review-1036.md): APPROVE. It re-read the IRS headers and doc guides, reproduced the identities, a fresh compile (65e4dde11c83/e02123644d42, 60 value moves by 0.415202720927, 0 added or removed, 51-state sum 12,289,835.97, all 51 equal to Build P's diagnostic targets), 189 fiscal-target tests, and the three mutation failures. Its P3 notes are addressed in 6ebfcf7: the chooser now also refuses one record id with two values at the winning period (the public compile already rejected duplicate ids earlier, inledger_targets.py), tests cover superseded ties and equivalent period labels, and the no-loss-returns and AGI-mix median wording is qualified.Interaction with #1030
#1030 (open) adds
test_pinned_feed_capital_gains_returns_control_reads_its_data_year. That test pins the CD US row as the control of 51 specs, and its doc bullet predicts a 58.5% fall once the stamp is truthful. With this PR the CD row is never a control, so:PolicyEngine/chronicle#292, which restamps the CD package to ty2022, would also have flipped the control by period alone. With this PR the control does not depend on that stamp.
Not changed here (chips filed)
irs_soi.returns_with_taxable_net_capital_gains) is Table 1.4's. The TY2023 HT2 package generator in progress will clone it.full. 488 return counts at the line-7 level on the Schedule D indicator; the US row is 2.41x the Table 1.4 row on that surface._is_soi_congressional_district_record_setmatches onlycongressional_district_2022.national_state, 0.3% to 12.2% apart. Taxable Social Security is the largest gap.🤖 Generated with Claude Code