Repository navigation
Conversation
MaxGhenis
force-pushed
the
soi-ht2-state-schedule-a-columns
branch
from
October 12, 2026 18:33
9261668 to
d2d27d9
Compare
MaxGhenis
changed the base branch from
fix/irs-cd-ht2-column-mappings
to
main
October 12, 2026 23:16
soi-historic-table-2-state-broad-2022 now reads eight more columns of 22in55cmcsv.csv for every state, each pinned to the TY2022 documentation guide's definition: - N00700/A00700 (Schedule 1 line 1) as taxable_state_local_income_tax_refunds_* - N18300/A18300 (Schedule A line 7) as taxes_paid_deduction_* - N19300/A19300 (Schedule A line 8a) as Table 2.1's mortgage_interest_paid_* - N19700/A19700 (Schedule A line 14) as Table 2.1's charitable_* The congressional-district package's charitable_* move to Table 2.1's concept and label for the same line 14 columns, so state, district and national rows join on concept as well as measure id. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The 20 IRS SOI packages at bundle year 2023, built against the parent commit, gain 408 TY2022 tax-unit facts, eight per state, and 204 semantic duplicate keys: the district file's state-total rows publish Schedule A lines 8a and 14 under the same concepts as the new state rows. No new geography, period or entity keys and no new warnings. docs/concept-migrations.md records the district charitable_* move to Table 2.1's contributions concept and label. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Review nits on e3bd56e: the identity test promised measure id, concept and label but checked two; it also rejected a correctly mapped TY2023 twin. The bundle comment now says what the measurement compared. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
docs/us-legacy-etl-cleanup.md (chronicle#348) now names the Historic Table 2 state rows for four retired series: - salt_* names taxes_paid_deduction_* (Schedule A line 7) beside the line 5e and 5b measures; the legacy rows named no IRS line; - mortgage interest and charitable rows list Historic Table 2's state rows next to the district file's state totals, separate IRS tabulations of the same lines; - state_local_refunds_* is covered at state grain; HT2's US row and Table 1.4 still go unselected nationally. The QBI row's chronicle#345 note is now past tense. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
MaxGhenis
force-pushed
the
soi-ht2-state-schedule-a-columns
branch
from
October 13, 2026 01:16
d2d27d9 to
7d096e5
Compare
Confirmation-review nits at 7d096e5: STATE_ONLY_COLUMNS read as "only the state package may read these" while the test accepts matching district readers, so it is now SINGLE_IDENTITY_COLUMNS. The cleanup doc's national refunds gap also names the district file's US row, which publishes N00700/A00700 unselected. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
MaxGhenis
marked this pull request as ready for review
October 13, 2026 01:57
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.
Summary
soi-historic-table-2-state-broad-2022now reads four more column pairs of IRS Historic Table 2 (22in55cmcsv.csv) for each of the 51 states. That is 408 TY2022 facts. Each column is pinned to the definition in the TY2022 documentation guide (22incmdocguide.doc), not to the column-name pattern.N00700/A00700(AG/AH)taxable_state_local_income_tax_refunds_returns/_amount(new)irs_soi.returns_with_taxable_state_local_income_tax_refunds/irs_soi.taxable_state_local_income_tax_refunds(new)N18300/A18300(CD/CE)taxes_paid_deduction_returns/_amount(new)irs_soi.returns_with_taxes_paid_deduction/irs_soi.taxes_paid_deduction(new)N19300/A19300(CH/CI)mortgage_interest_paid_returns/_amountN19700/A19700(CP/CQ)charitable_returns/_amountirs_soi.returns_with_contributions_deduction/irs_soi.contributions_deductionWhat was there before. No package selected Schedule 1 line 1 or Schedule A line 7 at state grain; #348's
docs/us-legacy-etl-cleanup.mdlists both as gaps. For lines 8a and 14, the only state values were the district file's state-total rows. Those are a separate IRS tabulation, and they differ from Historic Table 2's state rows: WY line 14 is $572M in the district file and $1,204M in Historic Table 2. This PR adds Historic Table 2's own state rows for both lines.Labels for the line 8a and line 14 pairs are Table 2.1's. Amounts use
value_scale: 1000. Each measure guards its header withsource_column_idandexpected_column_header.District concept move. The district package and Table 2.1 used different concept ids for line 14.
irs_soi.(returns_with_)charitable_contributions_deduction.irs_soi.(returns_with_)contributions_deduction.Both read the same line. The district file's
N19700/A19700and Table 2.1's "Contributions deduction: Total" (DG/DH) are both Schedule A line 14. So the districtcharitable_*move to Table 2.1's concept and label, and state, district and national rows join on concept as well asmeasure_id.measure_id,source_record_id, values and lineage are unchanged.docs/concept-migrations.mdrecords the move.New ids. No package reads Schedule 1 line 1 or Schedule A line 7 at any grain, so these ids are new.
taxes_paid_deduction_*follows Table 2.1's naming for its line totals (interest_paid_deduction_*for line 10). Table 2.1 publishes line 7 as "Taxes paid deduction: Total" (CA/CB), which its package does not yet select.taxable_*convention. Schedule 1 line 1 reports only the taxable part of these refunds; the guide's wording drops that word.Evidence
Scripts, downloads, bundle measurements, mutation results and both review outputs are in
~/PolicyEngine/_reviews/chronicle-ht2-state-schedule-a/on the build Mac.Publisher files
22incmdocguide.doc(sha256d99db44b…) and23incmdocguide.doc(94279069…) were downloaded from irs.gov on 2026-10-12. The bytes match the extracts and hashes intests/data/irs_soi_doc_guides/from Read IRS SOI district and Historic Table 2 measures from the columns their guides define #345.irs.gov/pub/irs-prior.22in55cmcsv.csvmatches its manifest sha256 (f72f8333…).California, TY2022 (amounts in thousands of dollars, as published):
N00700A00700N18300A18300N19300A19300N19700A19700Do the columns mean what the guide says? I compared Historic Table 2 with the national publications (computed from the repo's publisher files):
Observations, kept as published. These are cells as published; no mechanism is claimed.
A18300is belowA18460(line 5e): DC, ME, MD, MT, OH and OR. The largest gap is MD, $20.8M or 0.4%. TY2023 has the same pattern in 8 states.A19700is $572M in the district file and $1,204M in Historic Table 2.Invariants (stated and tested)
csvparse of22in55cmcsv.csv. Each fact equals its cell × scale and names its source column. The check is exhaustive, not sampled, because the input is finite.N19300,A19300,N19700orA19700declares Table 2.1's measure id, concept and label.N00700,A00700,N18300andA18300each carry one measure id and concept in every package.test_every_measure_reads_the_column_its_guide_definition_namesandtest_every_definition_names_the_same_variable_in_every_guide.23in55cmcsv.csvhas the same eight variables at the same column letters, so a TY2023 twin generated from this package reads them unchanged.Mutation check. I ran seven mutants and the tests killed all seven:
A18460;value_scaledropped;N19500;The script and results are in the evidence folder.
Bundle counts
I built
build-bundle --year 2023over the 20 IRS SOI sources at the parent commit and at this head. The differences:fact_counttax_year:2022tax_unitsemantic_duplicate_key_countThe +204 comes from the district file's state-total rows, which publish lines 8a and 14 under the same concepts for the same 51 states: 51 × 4. This is how the two files' shared columns already behave.
Nothing else moved: no new geography, period or entity keys, no warnings and no errors. The full-bundle pins in
tests/test_chronicle_bundle.pymove by the same amounts: fact count 1,007,134 → 1,007,542 and semantic duplicate keys 2,324 → 2,528.Consumer effect
Chronicle stores these as raw publisher facts; it activates nothing. What microcosm does with them is microcosm's call on its next re-pin, tracked in PolicyEngine/microcosm#1245. As read at microcosm
7253402fb(analysis in the evidence folder; I grep-verified the mappings):us/chronicle_feed.jsonrows and digest move: 40,178 → 40,586 rows if nothing else changes.charitable_*. These are the only new ids microcosm maps, tocharitable_deductionover itemizers. They become state targets, and instate_cdthey replace the charitable sibling bridges with these Historic Table 2 state parents.mortgage_interest_paid_*is unmapped on purpose.taxes_paid_deduction_*andtaxable_state_local_income_tax_refunds_*map to nothing.measure_id, and none of its code names either charitable concept id.TY2023
On
main, no TY2023 state package carries the broad columns.soi-historic-table-2-state-agi-2023holds only return count and AGI, so this PR adds no TY2023 measures. #295 adds a TY2023 state broad twin derived from this TY2022 package, and I left a heads-up there. Its mirror test will expect these eight measures, and they sit at the same columns in23in55cmcsv.csv.Dependencies
8826247b). This PR extends Read IRS SOI district and Historic Table 2 measures from the columns their guides define #345's guide-pinning test and reuses its districtmortgage_interest_paid_*ids.130b95bd). Commit7d096e57updates five rows of Retire US legacy ETLs whose values don't trace to publisher bytes #348'sdocs/us-legacy-etl-cleanup.md:taxes_paid_deduction_*(line 7) beside the line 5e and 5b measures;state_local_refunds_*: covered at state grain; the national gap stays;N01700,N06500;N00900/N26270/N25870overlap IRS SOI Table 1.4: add business, rental, royalty, farm-rental, partnership and S-corp net income/loss legs; give HT2/district 'net income (less loss)' columns their own concept ids #346).Chronicle Governance
ledger-source-ingestorvalidate-package soi-historic-table-2-state-broad-2022 --year 2023: valid, 3,111 facts, no errors or warnings.build-suite: 3,111 facts, all lineaged, 8,476 source cells unchanged.test_every_new_fact_is_its_published_cellchecks every new fact exhaustively.build-suiteconsumer facts are valid, and so is the 20-source IRS SOI bundle. CI: CI pending ona838ee45(it passed on the pre-rebase headd2d27d9c: run 38291765431,Chronicle bundle,Chronicle surfaceandChronicle checks).build-suiteagent acceptance passes: 0 missing lineage or provenance, 0 row-semantic errors. The reviewer reran raw-fact validation for both changed packages: 3,111 state facts and 29,760 district facts.subfleet run --task review --tier hard, ate3bd56e9. Round 2 confirmed both verdicts at7d096e57, after the rebase ontomainand the cleanup-doc commit. The Sol lanes were closed until 04:00Z, so round 2 was an independent Opus 5.5 agent, the fallback in~/.claude/CLAUDE.md.ledger-source-fidelity: PASS ate3bd56e9(round 1) and7d096e57(round 2). The reviewer independently checked CA, NY, TX, DC and more states against the CSV, the guide hashes and wording, the 2022 form lines, the accounting identity, the Table 2.1 ratios and every bundle delta. "No values are invented or repaired." It raised three nits and no blockers or should-fix findings. All three are fixed in9261668e, rebased asd2d27d9c: the state-only identity test now checks labels, it accepts matching later readers such as a TY2023 twin, and the bundle comment says what the measurement compared.N19300/A19300/N19700/A19700; the national refunds gap across all four Table 1.4 vintages; Read IRS SOI district and Historic Table 2 measures from the columns their guides define #345's QBI repin; the bundle-pin lineage acrossa90ad379→8826247b→130b95bd; and 11 out-of-tree mutants against the rebased identity tests.a838ee45:SINGLE_IDENTITY_COLUMNS, testtest_line_7_and_refund_columns_keep_one_identity;ledger-target-profile: n/a (no target profile touched)ledger-contract: n/a (no schema or identity code touched; the concept-id move is a package declaration recorded indocs/concept-migrations.md)ledger-boundary: PASS ate3bd56e9(round 1) and7d096e57(round 2). The change makes source selections and one concept alignment, and adds no reconciliation, aging, imputation, activation, solver construction or PolicyEngine-computed facts. Cross-source comparisons happen only in tests.docs/concept-migrations.mdandchangelog.d/are outside the ingestor's literal allowed paths, but they "directly document the authorized source changes".Tests
tests/test_chronicle_soi_ht2_state_schedule_a.pycovers:tests/test_chronicle_soi_doc_guide_columns.py:test_schedule_a_lines_shared_across_grains_carry_table_2_1_ids;test_line_7_and_refund_columns_keep_one_identity.tests/test_chronicle_source_package.py: CA values for all eight measures and package counts 2,703 → 3,111.tests/test_chronicle_bundle.py: full-bundle pins moved by the measured deltas.tests/test_chronicle_source_package.pyplus the consumer-contract, boundary and catalog tests: 182 passed;ruff check: clean.mutation-results.txt). After the rebase onto Read IRS SOI district and Historic Table 2 measures from the columns their guides define #345'sd61c069a, which compiles selectors from source-record specs, I reran the seven package mutants and all were killed again (mutation-results-d61c069a.txt).🤖 Generated with Claude Code