Skip to content

Read Schedule A line 14 at Historic Table 2's US rows (TY2022 and TY2023) - #461

Draft
juaristi22 wants to merge 2 commits into
mainfrom
ht2-us-charitable-1760
Draft

juaristi22 wants to merge 2 commits into
mainfrom
ht2-us-charitable-1760

Conversation

@juaristi22

Copy link
Copy Markdown
Collaborator

Summary

soi-historic-table-2 (TY2022, 22in55cmcsv.csv) and soi-historic-table-2-2023 (TY2023, 23in55cmcsv.csv) now read the contributions deduction, N19700/A19700, at the US row of all 11 AGI classes: 22 facts per package (605 -> 627). The IRS documentation guides of both years define the pair as "Total charitable contributions", Schedule A line 14. Every value is a publisher cell.

Since #350 the state broad packages read this pair for each state, and Table 2.1 reads the same line for the nation. The US row of Historic Table 2, the file's total for all returns, had no fact for it. That row includes the file's other-areas and Puerto Rico rows as well as the 50 states and DC.

Measure id Column Concept Label Unit
charitable_returns N19700 (CP) irs_soi.returns_with_contributions_deduction Returns with contributions deduction count
charitable_amount A19700 (CQ) irs_soi.contributions_deduction Contributions deduction amount usd, value_scale: 1000
  • The ids, concepts and labels are the ones that Table 2.1 and the state broad packages use. test_schedule_a_lines_shared_across_grains_carry_table_2_1_ids checks every package that reads these columns.
  • The TY2023 twin gets the same two measures, as test_packages_mirror_their_2022_twins requires. Both files have the pair at columns CP and CQ, and each measure guards its header.
  • The new measures come after the 55 existing ones (ordinals 55 and 56). The existing facts keep their values, keys, cells and lineage; only layout.record_set_spec_hash moves, because it hashes the whole record set, and it enters no key. The packages already parse every cell of the US rows, so the source cell counts (1,956 and 1,980) do not move.

Values

The US row for all returns. Amounts are in thousands of dollars, as the IRS publishes them.

TY2022 TY2023
N19700 12,095,980 11,562,200
A19700 220,984,505 210,916,402

Ratios, computed from the repo's publisher files:

Ratio TY2022 (returns, amount) TY2023 (returns, amount)
Historic Table 2 US row / Table 2.1 "Contributions deduction: Total", same tax year 0.9931, 0.9937 0.9842, 0.9950
District file's US row / Historic Table 2 US row 0.9873, 0.9328 0.9981, 0.9756

On the US row, the neighbouring pairs N19570/A19570 and N20950/A20950 are 7% to 25% of these totals, so a read one column over would fail the Table 2.1 check.

The 51 state rows hold 0.9987 of the TY2022 US row's returns and 0.9950 of its amount (TY2023: 0.9988 and 0.9966). The file's other-areas and Puerto Rico rows hold the rest.

The district files' United States totals (chronicle#449's rule)

The district files' United States totals of line 14 were already not facts: chronicle#449's third rule paired them with Table 2.1. They now share a semantic key with the new Historic Table 2 facts, so the first rule removes them and the declared pair is no longer needed. PUBLICATION_1304_LINES in tests/test_chronicle_soi_district_agi_classes.py drops the two charitable pairs (17 -> 15; eight Schedule A items in Table 2.1, not ten), and the district packages' comments say so. Counted with that test's rules on this branch:

Rule TY2022 TY2023
Same semantic key 3,571 (was 3,569) 3,468 (was 3,466)
Same Historic Table 2 column only 1,030 979
Declared Publication 1304 pair only 15 (was 17) 15 (was 17)
Removed totals 4,616 4,462

No district fact changes. The changelog fragment gives the new counts next to chronicle#449's fragment.

Checks

  • New tests/test_chronicle_soi_ht2_us_charitable.py, for both tax years, with each package built at its tax year:
    • each of the 22 new facts against its cell, read with the csv module;
    • the ten AGI classes against the all-returns fact (amounts exactly, counts within 5 x 11);
    • the 51 state facts plus the OA and PR cells against the new US fact (amounts exactly, counts within 5 x 54);
    • the ratio to Table 2.1's line 14 for the same tax year, pinned to four decimal places.
  • Existing tests now cover the pair too: the TY2023 per-cell, documented-variable, mirror, AGI-class and state-total tests; the guide-column and one-identity tests; and the district US-row subset test (both new ratios are in its stated ranges).
  • Mutation check: six mutants, each with one change, and the tests kill all six:
    • the TY2022 amount moved to A19570;
    • the TY2022 amount without value_scale;
    • the TY2023 returns with the old district concept;
    • the TY2023 amount with the old district label;
    • the TY2022 ordinals 55 and 56 swapped;
    • the TY2023 returns moved to N20950.
  • build-suite for both packages at year 2023: valid, 627 facts each, agent acceptance clean, lineage coverage 1.0.
  • Local test files, all passing at the head: test_chronicle_soi_ht2_us_charitable.py, test_chronicle_soi_ht2_2023.py, test_chronicle_soi_ht2_state_schedule_a.py, test_chronicle_soi_doc_guide_columns.py, test_chronicle_soi_district_agi_classes.py, test_chronicle_soi_capital_gain_concepts.py, test_issue_376_one_label_per_value.py, test_chronicle_boundaries.py; and in test_chronicle_source_package.py and test_chronicle_bundle.py, the tests that pin these packages' counts and values.
  • Not run locally: the full default-bundle test (test_build_bundle_writes_merged_consumer_contract, about an hour). CI runs it.

Bundle (default, year 2023)

I built the 34 IRS SOI packages at bundle year 2023 with and without this change (base 13294b93). Only these counts moved, each by the new facts:

Count Change
fact_count +44
tax_year:2022, tax_year:2023 +22 each
country:0100000US +44
tax_unit +44
irs_soi +44

There is no new geography, period or entity key, no new semantic duplicate key (95 IRS keys before and after) and no new warning. The full-bundle pins in tests/test_chronicle_bundle.py move by the same amounts: fact count 2,416,365 -> 2,416,409, irs_soi 146,622 -> 146,666, country:0100000US 10,840 -> 10,884 and tax_unit 147,927 -> 147,971.

Consumer note (Microcosm)

Chronicle stores the 44 values as publisher facts and activates none of them. Microcosm's US feed selects (record set, period) pairs (us/chronicle_feed_scope.json). Its scope holds irs_soi.ty2022.historic_table_2.us for tax year 2022 and not the TY2023 US record set. So a Microcosm re-pin to a Chronicle commit with this change adds the 22 TY2022 facts to its feed and none of the TY2023 facts, and the 605 existing TY2022 US rows change only their layout.record_set_spec_hash. PolicyEngine/microcosm#1760 needs the TY2022 US total.

Chronicle Governance

  • Approved Chronicle agent role: ledger-source-ingestor. Paths outside its allowed paths: docs/us-legacy-etl-cleanup.md (the national sources of line 14, and a clause that they differ) and changelog.d/irs-soi-ht2-us-charitable.added.md.
  • Deterministic checks: source-package validation (build-suite, the validate_source_package counts), source-cell preservation (the per-cell tests; lineage coverage 1.0), consumer-contract validation (build-suite consumer facts; the IRS SOI bundle build), raw-facts boundary validation (tests/test_chronicle_boundaries.py).
  • LLM judge verdicts, at e2817442. Two Opus 5.5 agents that wrote none of the commits judged the change. Each had the code and the criteria in .github/chronicle-agents.yml, not the author's conclusions.
Judge Verdict Items
ledger-source-fidelity PASS with notes 0 must-fix, 0 should-fix, 2 nits
ledger-contract not applicable no schema, identity or consumer-contract code change
ledger-boundary PASS with notes 1 must-fix outside its criterion, 1 should-fix, 4 nits

What the judges checked:

  • Fidelity: 44 of 44 new facts equal their cell times the declared scale, read with the csv module; the files' sha256 and sizes equal the manifest; both guides define N19700/A19700 as Schedule A line 14; every other package that reads the pair declares the same id, concept, label and unit; the 605 existing facts of each package keep their values, keys, cells and lineage; every publisher value and relation the diff states is true.
  • Boundary: every new value is a publisher cell with assertion: observation and the publisher's tax year; the YAML adds only measure declarations; no consumer selection, activation, binding, alignment or solver construction moves into Chronicle; the tests compare publisher tables and store or select nothing.

How the findings were answered in 39830e91:

  • Boundary must-fix (outside its criterion): test_a_total_stays_only_where_no_other_package_gives_it failed, because the line 14 pair of PUBLICATION_1304_LINES is no longer needed. The list now has 15 pairs (see above).
  • Boundary should-fix: the changelog fragment of chronicle#449 counts 17 pairs and ten Schedule A items. The new fragment gives the new counts.
  • Boundary nits: the changelog describes the US row as the file's all-returns total, which includes the other areas and Puerto Rico; the docs row says the two national series of line 14 differ; the test builds each package at its tax year; an unused constant is gone.
  • Fidelity nits: the count bounds allow for the rounded total (5 x 11 and 5 x 54). The first commit's message says the guide pin moves by 22; it moves by 2 (55 -> 57 measures).
  • Left as it is: chronicle#449's TY2023 fragment still says 55 measures and 605 facts for soi-historic-table-2-2023, as that PR added it; this fragment gives 57 and 627.

39830e91 changes test pins, comments and text only. Its test files pass.

Not in this PR

  • The US row's line 8a pair, N19300/A19300 (home mortgage interest paid to financial institutions), which the state package also reads.

🤖 Generated with Claude Code

juaristi22 and others added 2 commits December 1, 2026 18:58
soi-historic-table-2 (TY2022) and soi-historic-table-2-2023 (TY2023) now read
N19700/A19700, "Total charitable contributions" (Schedule A line 14) in the
IRS guides of both years, at the US row of all 11 AGI classes: 22 facts per
package, 605 -> 627. The measures take the ids, concepts and labels that
Table 2.1 and the state broad packages already use for the same line
(charitable_returns, charitable_amount), so the 51 state rows of each
edition have a US total from the same file. The TY2023 twin gets the same
two measures, as test_packages_mirror_their_2022_twins requires.

The new measures come after the 55 existing ones (ordinals 55 and 56), so the
existing facts keep their keys. The packages already parse every cell of
the US rows, so the source cell counts do not move.

New tests/test_chronicle_soi_ht2_us_charitable.py checks, for both years,
each new fact against its cell read with the csv module, the AGI classes
against the all-returns fact, the 51 states plus OA and PR against the new
US fact, and the ratio to Table 2.1's line 14 for the same tax year
(0.9931/0.9937 for TY2022, 0.9842/0.9950 for TY2023). The count pins of the
package, guide and single-source bundle tests move by 22.

Microcosm's US target nesting (PolicyEngine/microcosm#1760) needs the TY2022
US total to give the Historic Table 2 state rows of this line their shares.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Full-bundle pins (tests/test_chronicle_bundle.py), measured with the 34 IRS
SOI packages built at bundle year 2023 on 13294b9 and on this branch: fact
count, irs_soi, country:0100000US and tax_unit +44, tax_year:2022 and
tax_year:2023 +22 each. No new geography, period or entity key, semantic
duplicate key (95 IRS keys before and after) or warning.

chronicle#449's district totals rule: the district files' United States
totals of line 14 now share a semantic key with the new Historic Table 2
facts, so the first rule removes them and their Publication 1304 pair is no
longer needed. PUBLICATION_1304_LINES drops the two charitable pairs (17 ->
15, eight Schedule A items in Table 2.1), and the district packages' comments
say so. Counted with the test's rules: same key 3,571 and 3,468 (were 3,569
and 3,466), same column 1,030 and 979, declared pairs 15; the removed totals
stay 4,616 and 4,462, so no district fact changes.

Judge notes answered: the count bounds of the new test allow for the rounded
total (5 x 11 and 5 x 54), the test builds each package at its tax year and
drops an unused constant, the changelog fragment describes the US row as the
file's all-returns total and gives the new chronicle#449 counts, and the
legacy ETL doc says the two national series of line 14 differ. The first
commit's message says the guide pin moves by 22; it moves by 2 (55 -> 57
measures).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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