Skip to content

Nest the US target rows on the shared cross-grain operator, and re-pin the US feed (#1760: Stage A, steps 1 to 3 and decision 2) - #1791

Draft
juaristi22 wants to merge 39 commits into
mainfrom
claude/us-target-nesting-1760-4cb538
Draft

juaristi22 wants to merge 39 commits into
mainfrom
claude/us-target-nesting-1760-4cb538

Conversation

@juaristi22

@juaristi22 juaristi22 commented Nov 27, 2026 •

Copy link
Copy Markdown
Collaborator

Part of #1760. Draft. Step 3 is here: the US feed re-pin to Chronicle 13294b93 and the target changes ruled for it, with decision 2 (the national level of the state SOI rows). Target values change.

Where this stands

Step What State
Stage A The four US share mechanisms run on the cross-grain operator that the UK uses, with the bytes they had Here
Rulings docs/us-target-nesting-rule-design.md: the rule, nine decisions (accepted 27 Nov 2026), and one general model to declare them Here (a page)
Step 1 The general model in the shared operator. The UK declares none of the new options Here
Step 2 The US on the model: one declaration in the UK's key names, the operator's metadata keys, one receipt format. Same target values; the keys and the receipts change Here
Step 3 The feed re-pin after PolicyEngine/chronicle#451, and the ruled target changes. The allocators and the level bridges go Here
Decision 2 The state rows of the 14 quantities of #1243 take the level of the newer national row, on a derived control of the kind scaled Here (1 Dec 2026). Its two build choices were ruled to stand on 1 Dec 2026
Joint surface The passes on one surface, in one operator call Not here: a follow-up PR (ruled 1 Dec 2026)
Second review An adversarial review of the head 30b22eea2 (1 Dec 2026): seven findings Six repaired here. For the seventh, 102 targets are held out of the production national mode until the follow-up (ruled 1 Dec 2026; see "The second review")
Review of 2 Dec 2026 A light review of the target changes: two requests and a view on the mortgage interest decision The account of the compile change is in the re-pin page (d6ce5d6c1). The build comparison needs a build, so it is María's call (see "The review of 2 Dec 2026")

The rulings are in this comment on #1760. The page for the code is docs/us-target-nesting.md. The re-pin is in docs/us-chronicle-feed-repin.md.

What step 3 changes

The feed

  • US feed: Chronicle 13294b93 (Add later editions of the US feed's sources (chronicle#449) chronicle#451, merged 28 Nov 2026, with the vintage review of chronicle#449). Built offline from a clean checkout: 62,268 rows on chronicle.consumer_fact.v5, facts_sha256 2e880fd3…. The scope keeps today's record sets and tax years: 705 pairs (706 before).
  • County facts: moved to the same commit. The build at 13294b93 has the bytes of the 3e9d3a0 build (67b0998a…), so only the commit and the scope digest move.
  • chronicle#451 removes the district file's own state and US rows, keeps the at-large areas as district rows, and reads the district file's SALT and premium tax credit from the right IRS columns. The district file now carries its true tax year, 2022.

The compile

Surface Before (41b2fb2) After (13294b93)
Release compile (full) 31,748 28,116
national_state 6,102 6,316
  • national_state gains 204 Historic Table 2 state rows (charitable contributions and the QBI deduction, returns and amounts, 51 states; the 102 charitable rows are held out since the second review, see below), 2 national QBI rows of Historic Table 2 and 8 Table 1.4 partnership and S corporation rows. Historic Table 2 names the QBI deduction qbi_amount/qbi_claims, and the two SOI measure maps now take those ids.
  • The 810 TY2022 state taxable-interest band rows stay. The TY2023 state AGI-band package now carries taxable interest too, and the scope holds no TY2023 national Historic Table 2 row, so those slices would have displaced the TY2022 rows and then been dropped by the stale-interest rebase. A slice that the rebase would drop no longer takes part in the newest-vintage selection.
  • The state SSI targets take SSA's own workbook: the old pinned file's 51 state payment totals summed to more than its own US row. SNAP, BEA and Z.1 values move with chronicle#449's source revisions.
  • The District of Columbia's district is seat 98 (1198) at Chronicle, as at the Census Bureau. The district translation and the household district distribution read seat 98 as seat 00, Microcosm's at-large convention.
  • Row 4 retires (hierarchy_reconciliations: []): the district file has no state row to scale its district rows to.
  • Row 1: the district file has no US row, so the capital-gains share denominator of its rows is the sum of its district rows. On the state_cd surface the district capital-gains rows then nest in the Historic Table 2 state row, like every district row.
  • The restamp register is empty: no fact of the feed is restamped.

Held out of the compile: deferred_district_measures

A new register in us/fiscal_target_registers.json holds the district rows of 14 measures out of the compile (6,104 rows), each with its reason:

  • 12 would be new district targets: CTC, real estate taxes, taxable income, wages (new in the district file), and SALT and the premium tax credit (read from the right column now). New district families are for US local build: district targets that exist but are not in the fit #1731.
  • 2 are the renamed mortgage interest: mortgage_interest_paid_*, IRS column A19300/N19300, home mortgage interest paid to financial institutions. That is one part of the home mortgage interest deduction, not the whole interest deduction. Under its new id it binds no variable, at any level: Table 2.1 (national), Historic Table 2 (51 states) and the district file all carry it. Which variable it binds is a decision of its own (deductible_mortgage_interest is the closest). Table 2.1 keeps its national interest_paid_deduction target.

The nesting

  • Every district row nests in its Historic Table 2 state row, on state_cd and now on full too (rule: state_cd_district_shares on both modes in us/spec/target_sets.yaml). So full and state_cd give the same rows. Charitable contributions and the QBI deduction take Historic Table 2 parents, so the level bridges go.
  • The QBI deduction is paired by measure id: Historic Table 2's qbi_amount/qbi_claims with the district file's qualified_business_income_deduction_*, declared as paired_values on the district bridge selector.
  • The allocators go. Every pass divides a control by the operator's own rule (row × control / sum of the rows). Before they went, I checked that no reader needs an exact sum: every closure check has a tolerance. On the same inputs, removing them moves values in the last bits only: county populations keep their bits, and county SOI and household rows stay within 1e-12 relative of the old code. CrossGrainRule is main's again.
  • The factor band (1.25 around the median factor across states, unbind) takes off five blocks, 44 district rows: Hawaii qualified and ordinary dividends, Washington charitable contributions, Utah tax-exempt interest, New York rental income. The largest kept gap is 1.22x; the smallest dropped gap is 1.32x.
  • Both files are tax year 2022 now, so the factors are the level gap between the two publications: median 1.017 for returns, 1.019 for AGI (about 1.05 for amounts before). Taxable interest keeps its Table 4.3 rebase (median 2.40).
state_cd Before After
Historic Table 2 state rows 4,227 4,431
District-file state rows (level bridges) 302 0
District rows 21,743 (51 measures) 20,879 (49 measures)
(state, concept) blocks 2,189 2,102
Admin specs (with SNAP and Medicaid) 26,425 25,463
With the 487 ladder population rows 26,912 25,950

The state default goes from 4,380 to 4,584 compiled targets (5,071 with the ladder rows); totals stays at 255.

Not built yet

  • One pass on one joint surface. It goes in a follow-up PR (ruled 1 Dec 2026). The operator can do it: it rescales a middle level to its control first, and that row then controls the levels below it. The obstacle is in the US tools: the national pass runs in the compile before aging, the district pass when the local tool selects its surface, and the county passes after the engine pass. The clean form moves the district pass into the compile, which changes the registry on which the national release runs its parity and coverage gates.
  • the mortgage interest decision (above).

Decisions 4 and 7 go in their own PRs, as ruled.

Decision 2: the national level of the state rows

The defect (#1243). 14 SOI quantities bound two national rows of two tax years: the Historic Table 2 US row (tax year 2022), which is the total of the state rows' own file, and a newer Publication 1304 row (tax year 2023). No weight vector meets both. For two of them the state rows summed to more than the smaller national row.

The rule (ruled 27 Nov 2026). The newer row is the national control. Each state row takes one factor, the newer national value over the Historic Table 2 US total, so it keeps its share of the total of its own file. The Historic Table 2 US row stops binding.

How. A derived control of the kind scaled in the shared code (cross_grain_controls.scaled_control: a value times the lower rows' share of their own source's total). The operator divides it among the state rows. The US declares one pass with an entry for each pair, and the compile runs it (_nest_soi_state_rows_in_newer_national_controls), after rows 1 and 2 and before the state AGI bands.

Quantity (Historic Table 2 measure) Control Factor Historic Table 2 US over the control's table, tax year 2022 States over the control, after
adjusted_gross_income Table 1.1 1.0341 0.9965 0.9928
return_count Table 1.1 1.0060 0.9896 0.9941
wages_salaries_amount Table 1.4 1.0510 0.9969 0.9921
wages_salaries_returns Table 1.4 1.0069 0.9947 0.9947
taxable_ira_distributions_amount Table 1.4 1.0080 0.9929 0.9967
taxable_ira_distributions_returns Table 1.4 1.0161 1.0091 0.9973
taxable_pension_income_amount Table 1.4 1.0373 0.9857 0.9950
taxable_pension_income_returns Table 1.4 0.9863 0.9977 0.9956
taxable_social_security_amount Table 1.4 1.1561 0.9943 0.9977
taxable_social_security_returns Table 1.4 1.0507 0.9922 0.9968
unemployment_compensation_amount Table 1.4 1.0334 0.9898 0.9966
unemployment_compensation_returns Table 1.4 1.0107 0.9829 0.9979
itemized_deductions_amount Table 1.2 1.0620 0.9738 0.9967
taxable_income_amount Table 1.2 1.0227 0.9970 0.9919

The factor is on the published values (tax year 2023 over tax year 2022). At the build year an amount moves by 0.978 to 1.122 (the old rows were aged one year more), and a count moves by its factor.

The concept check of each pair (the ruling asked for it before the build):

  • on the pinned feed the two national rows of each pair carry one publisher concept (source_concept) and one return universe, with no other filter;
  • in tax year 2022 the two tables agree within 2.7% for every pair (the fourth column). Twelve come from the feed. The two Table 1.2 pairs come from the IRS file 22in12ms.xls as Chronicle pins it at 13294b93, because the feed's scope does not hold that table for 2022;
  • the compile holds each pair to its declared concept from now on: it refuses a pair whose rows carry another one, or none.

On the pinned feed:

Before After
Release compile 28,116 28,101
national_state 6,316 6,301
State rows that take a factor 0 714 (14 quantities, 51 states)
National rows that stop binding 15: 14 Historic Table 2 US rows, and the state_2022 copy of the US return count
Local state, totals, full, state_cd 4,584 / 255 / 25,463 / 25,463 the same counts; the values of the 14 quantities move

The 408 state AGI band rows follow their state total. The district rows and the county rows are shares of their state row, so they follow too.

Two choices of the build, ruled to stand on 1 Dec 2026:

  1. The pass runs in the compile, before the state AGI bands and before aging. So every build has it, a band follows its state total, and a state row ages from its control's period with its control.
  2. A district-file row of a paired measure takes the same factor in the compile (11 measures, 4,796 rows). On the local surfaces this changes nothing: a district row is a share of its state row there. It keeps the district file a part of the national row on the national tool's full mode, where district rows are raw: without it, the district rows of taxable IRA distributions sum to 1.0056 of the one national row that is left. It also keeps the factors and the bound of the district bridge as measured at the re-pin.

What a reader must know: a state row of the 14 quantities now carries the operator's keys, and its cross_grain_parent is the national control. A reader that wants the rows under a state parent must also read the level. The readers in the tree do (the hold-out rules, the loss weights, the closure check).

The UK: no UK output changes. One UK node is keyed more widely. The implementation hash of the gate battery covers every module that its bindings reach by an import statement, and that closure already holds the US compile. The US compile now imports the operator, its row-level pass, the US declaration reader and the US adapter, so the closure grows by these four modules (243 to 247; test_transport_evidence_kernels.py lists them). The gate battery computes again on the next UK run, as it does after any edit of the US compile.

The second review (1 Dec 2026)

A second adversarial review read the head 30b22eea2 (decision 2, step 3, the repaired tests, the merges). It confirmed the arithmetic of the pass on the pinned feed, the aging, the readers of the parent key, the gates on the compiled registry, the UK path and the four repaired tests. It found seven items. I checked each one with my own run before I changed code.

# Finding State
1 The re-pin adds targets that cannot be met together on the production national mode (national_state). See below The 102 rows are held out in f50fedd25 (ruled 1 Dec 2026). The repair is in the follow-up
2 A state that one pair lacks made the compile refuse: all pairs ran in one operator call, where the country covered the states of every pair Repaired in 2c2df0547: each pair is a pass of its own
3 A district-file row of a paired measure took the factor with no check of its tax year or quantity Repaired: the compile refuses a follower of another tax year or quantity. A follower is matched by its measure id, and the declaration says so
4 The call of the pass in the compile, and the county pairing by the row's own tax year, had tests on the pinned feed only Repaired: a test of the whole compile on small inputs, with a band and aging (it fails when the pass is removed or runs after the bands), and a county test
5 The pass skipped in silence where a conflict would stay, and it left no record Repaired: it refuses when the newer row binds beside state rows and the US total of their file is missing or of another tax year. It records its own receipt where a stage keeps the nesting receipts. A national build has the row metadata only (each state row names the total that stopped binding)
6 Guards weaker than the page said Repaired: a row with no publisher concept is refused, a factor of zero or below is refused, and a derivation that cannot run names its quantity
7 Three places in the pages gave numbers of the old pin Repaired

No pinned value moved with these repairs.

Finding 1, measured on national_state at the build year 2024:

Quantity What binds States over the national row New here? Now
Charitable deduction 102 Historic Table 2 state rows (tax year 2022) and the Table 2.1 national row (tax year 2023) 1.069 (amount), 1.028 (returns) Yes: the re-pin adds the state rows The 102 state rows are held out of national_state
SALT, real estate taxes The Historic Table 2 US row (2022), the Table 2.1 row (2023) and the state rows 1.043 (SALT amount), 1.006 (real estate taxes) No: on main today Every row binds, as on main. A declared known gap

This is the defect of #1243 on quantities outside its list of 14. For the charitable deduction the rule of decision 2 cannot run yet: Chronicle's Historic Table 2 US package has no charitable column, so the state rows have no US total of their own file.

Ruled on 1 Dec 2026: the repair goes in the follow-up of #1760 that makes the levels consistent, and the rows are held out until then. Built in f50fedd25:

  • a known gap of us/cross_grain_declarations.json can hold its rows out of the national solve (held_out_of_national_solve), and spec/target_sets.yaml excludes them from national_state by the predicate held_out_known_gap;
  • on the pinned feed national_state goes from 6,301 to 6,199 targets (2d99e5fddc8a). The compiled registry (28,101), the full mode and every local surface are unchanged: the state rows stay the parents of the district rows there, and no national row binds on a local surface;
  • the selection receipt of the national tool counts the held-out rows apart (held_out_known_gap_targets, only when there are any). dropped_congressional_district_targets counts district rows only, as before;
  • a comment on US targets: one declared nesting rule across national, state, district and county levels #1760 records what the follow-up needs to retire the hold-out.

A correction. The text of this description from 16:33Z to this update also listed partnership and S corporation income as a third case (8 Table 1.4 component rows beside the Historic Table 2 combined row, which is 7.4% above their net). That was wrong, and those rows are not held out. A US SOI row binds the positive part of its variable on each return, so the combined row binds the positive part of each return's sum. The four parts hold that quantity between their net ($1,078bn) and the sum of the two income rows ($1,358bn), and the combined target ($1,158bn) is inside that range. docs/us-target-nesting.md says so.

For a later ruling (not a defect): the feed also holds the tax year 2023 state AGI-class package, so the published 2023 state totals exist. The state totals of decision 2 (2022 shares at the 2023 national level) are 0.956 to 1.054 of them for adjusted gross income, and 14 states are more than 2% off.

The review of 2 Dec 2026

A light review of the target changes, at f50fedd25.

1. The compile change, by source. Done in d6ce5d6c1: docs/us-chronicle-feed-repin.md ("The compile change, by source"). It compares two compiled registries at the build year 2024: the code before the re-pin on the old feed, and this branch on the new feed.

Source Level Before After Change Reason
District file district 22,672 21,800 -872 The two interest paid deduction measures left (52 measures to 50, the same 436 districts): the column is mortgage interest paid, which binds no variable until that is decided
District file state 2,601 0 -2,601 chronicle#451 removes the district file's own state rows (51 measures, 51 states)
District file country 49 0 -49 chronicle#451 removes the district file's own US rows
Historic Table 2 state rows that stood in for a district district 324 0 -324 36 measures for 9 areas that had no district row in the old file. The file now holds them as district rows
Historic Table 2 state 2,397 2,601 +204 The charitable and QBI deductions, new in the state package
Historic Table 2 country 65 67 +2 The US rows of the QBI deduction
Table 1.4 country 18 26 +8 Partnership and S corporation net income and net loss
Every other source and level (36 groups) 3,622 3,622 0 The same count in each group; 13 rows have a new id and the same value
Total 31,748 28,116 -3,632

The 6,104 deferred district rows are not a removal of 6,104 rows. 5,232 of them are of twelve measures that the old feed did not hold, so they were never compiled. The other 872 are the first line of the table. Decision 2 then takes 15 national rows off (28,116 to 28,101).

2. The effect on the build. Not done: it needs a national build, and no build ran for this PR. The page gives what the comparison needs. On the production national mode, 4,830 of the 6,102 targets of the old surface keep their value (4,817 with the same id, 13 with a new id), 1,257 move with a known cause for each group, 112 are new and 15 are gone.

The view on the mortgage interest decision. The rows stay held out, as the review advises. policyengine-us 2.145.3 has a variable before the limits (mortgage_interest: home mortgage interest and deductible points, before the federal acquisition-debt caps), so the binding that the review prefers is possible. The decision is still open.

What Stage A and steps 1 and 2 do

The US local tools made child target rows from parent rows in four places, each with its own arithmetic, its own checks, its own metadata keys and its own receipt. They now run on the cross-grain operator that the UK uses (microcosm.build.cross_grain), and the US declares its choices in the UK's key names.

The model has six things, and each is general (no construct is for one country only; the shared operator runs the first five, and the coverage check reads the sixth): a measurement, a bridge (by id, or by a selector that makes one bridge for each pair of targets), a derived control, a bound on the factor of a bridge, the members of a leg, and pairs that are not reconciled.

Up to step 2 no target value changed: on the feed pinned then, each of the 26,272 rows of the state_cd SOI surface had the bits of the value it had, and the other three surfaces had their bytes.

The parts

Part Where
The operator: a bound measured from the median factor, one-sided, that can unbind a leg; the declared members of a leg; bridge selectors (which can pair values); the metadata keys of a reconciled row microcosm/build/cross_grain.py
The row-level pass (reconcile_rows: the operator on target rows, with an answer for each row). No country in it microcosm/build/cross_grain_controls.py
The US declaration, in the UK's key names us/cross_grain_declarations.json
Its reader, and a coverage check that is a receipt and a test only us_runtime/cross_grain_declarations.py
The US adapter: the rows of each pass, the checks that are US rules, the specs made from the operator's answer us_runtime/target_nesting.py
The four tool functions, thin wrappers with the same names and signatures tools/us_acs_local_cd_surface.py, tools/us_acs_local_county_surface.py
The operator's receipt, in target_nesting.json tools/build_us_acs_local_release.py

What step 2 changes (by design)

On valid data the rows and their values were the same. These things differ.

  1. Metadata keys. District and county rows carry the operator's keys, as UK rows do.

    New key Old keys
    cross_grain_parent state_cd_parent_target_name, state_county_parent_target_name
    cross_grain_value_before state_cd_cd_file_value, state_county_source_value
    cross_grain_factor state_cd_rebase_factor, state_cd_level_bridge_factor
    cross_grain_control state_cd_parent_basis, state_cd_level_bridge_sibling
    cross_grain_members state_county_cell_members

    Six old keys have no new one, because another place holds the value (the parent row, the operator's receipt, the declaration).

  2. Receipts. The district receipt names the bridge and its bound under bridge, with the legs it unbound; factor_by_measure replaces rebase_factor_by_measure, and since step 3 paired_measure_ids replaces the level-bridge fields. internal_consistency is gone. County blocks lose share_sum.

  3. Pins of state_cd (the registry, the roles and the receipts) moved, and were measured again.

  4. Refusal texts. A refusal that the operator makes has the operator's text: a leg that does not hold its members, a sum of zero under a control, opposite signs, a county with no state.

  5. One check is gone: that the district file's own state row is the sum of its district rows. Since step 3 the district file has no state row.

  6. One refusal is new: a concept that takes its state parent from Historic Table 2 in some states and from the district file in others. It does not occur on the pinned feed.

  7. With the bound turned off (only tests do that), a concept whose Historic Table 2 level is zero in every state keeps district rows of zero. The old code dropped them.

  8. A band of 2.0 or more is refused. The old code accepted any band. No command-line flag sets it, so only a test or a direct caller can meet this.

The readers of the keys moved with them: the loss weights, the hold-outs and their pro-rata baselines, the county reports, and one field of the reviewed limitations. The dated runs under experiments/ read registries of their own date and are not changed.

Since Stage A, three inputs that the oldest code computed are refused by the operator (rows that sum to less than 1e-9 of their control, a county SOI block under a negative state row, a control of -0.0). None occurs on the pinned feed.

A run that is resumed across this change is stopped: a later stage refuses targets with the old keys, and a district receipt with the old fields, and says to run --stage materialize again.

Commits

# Commit Proof
A0 288b2e3ca Pins on the code as it is (the pin test of #1755, cherry-picked) It passes on main as it is
A1 e3e483dbd The allocator hook (removed again in step 3) 400 seeded surfaces through the operator and through a reference copy of the file
A2 bc8aa6ae1 cross_grain_controls Each allocator equals the arithmetic it replaces, bit for bit, on 200 seeded blocks
A3 d1f62f9dd The US declaration, its reader and the adapter base Each register equals the literal it replaces
A4 6da6e3b12 District SOI shares on the operator (row 5) 160 seeded surfaces against a verbatim copy of the old function
A5 55fa55c36 County population, county SOI shares, county households on the operator (rows 8, 6, 7) 120 seeded inputs for each
A6 c3dc13b4c The inventory, the docs page, the coverage test The pinned feed's compiled registry has no coverage gap
merge 3aac702e3 Merge of main (5589fae09), with the US F0 pins written again Both pin tools ran twice; --check passes
design 350cd9de2, 17ee67085, 035881105 The rule, the rulings, one general model (docs only) No code
step 1 947978c46 The bound, the members and the bridge selector, general in the operator The differential test holds the default path to the operator before any edit, bit for bit
fix 938c7faa6 Annotations that the spine-blindness check needs The whole file passes
step 2 d91ae5b37, 2264fb377, 011651554 The operator refuses a declared leg with no row; the US on the model; the pages See "Tests run here"
rulings 625c93702 The ten rulings of 27 Nov on the steps, in the design page Docs only
county 6e76eaee6, fa297a018 The county rows on the pinned county facts; the county SOI bridge declares the bound of the district bridge No leg is unbound on the pinned county facts
review f1c17c5e1, bb6776f87, ff0b9fa15, 672e82936 The eleven findings of the adversarial review See "Adversarial review"
merge a8b9d2c52 Merge of main (be6a1983d), with the US F0 pins written again Both pin tools ran; --check passes
fix ca5e864bc The property test of the district shares draws no block that the operator refuses All twelve CI checks passed on it
merge b138c5f20 Merge of main (dc77fa312, with the geography-first move of #931), with the US F0 pins written again Both pin tools ran; --check passes
merge b4c276c23 Merge of main (6b87a0c28, with #1755) The tests ran on the merged tree
step 3 87fabcde0 Re-pin the US feed to Chronicle 13294b93, and compile the feed there The pinned compile counts and digests, measured again
step 3 12677fb68 Nest the district rows in Historic Table 2; the allocators and the level bridges go See "Tests run here"
step 3 75cb18cba The pages and the changelog Docs only
merge a9d1dd414 Merge of main (88fadfa8f, the post-export scoring work) No conflict
CI c00e34ccf Four tests that the feed re-pin and the key change left behind See "CI"
review of #1755 df726b5d6 Seven items from the review of #1755 See "The seven items from the review of #1755"
decision 2 38f3e6cfa Give state rows the level of the newer national control See "Decision 2" and "Tests run here"
decision 2 30b22eea2 The pages and the changelog Docs only
second review 2c2df0547 Six items from the second review See "The second review" and "Tests run here"
merge 5cf1f85e3 Merge of main (fdd4a98fa) No conflict. It brings the renewal of the UK register expiries (#1834)
second review f50fedd25 Hold the state charitable rows out of the production national mode See "The second review". national_state 6,301 to 6,199; the US F0 pins move with the target-set file
review of 2 Dec d6ce5d6c1 Account for the compile change of the feed re-pin, by source Pages only

87fabcde0 also renamed the SOI measure maps from interest_paid_deduction_* to mortgage_interest_paid_*. That was wrong: it took Table 2.1's national interest paid deduction off its variable, and bound column A19300 to the variable of the whole deduction. 12677fb68 reverts the rename and holds the mortgage rows out (see above). Only the head runs in CI, and 87fabcde0 alone does not pass the state_cd tests.

The county rows on the real inputs

The pinned county facts file (922 MB, sha256 67b0998a…) is a test input on the build machine. Two tests in test_us_target_nesting_county.py read the pinned feed, the PUMA ladder and that file, when MICROCOSM_US_CHRONICLE_FACTS, MICROCOSM_US_PUMA_LADDER_ARTIFACT and MICROCOSM_US_CHRONICLE_COUNTY_FACTS name them. They skip in CI.

Pass Rows At step 3
County population, 2020 counties 3,143 Same codes, order and value bits
County population, 2023 county-equivalents 3,144 Same
County SOI (return count, adjusted gross income) 6,286 Same rows; values within 1e-12 relative of the old code (the allocator went); bytes pinned again
County households 51 state rows, 3,144 county rows Same rows; values within 1e-12 relative; bytes pinned again

The county SOI bridge declares the bound of the district bridge (1.25 around the median factor across states, unbind). No leg is outside it on the pinned county facts, so it unbinds nothing.

Adversarial review, 27 Nov 2026

A reviewer with no part in the work tried to prove the PR wrong, at head fa297a018. It changed no file. UK outputs and US values held; the eleven findings were fixed in f1c17c5e1 to 672e82936 (a lost refusal came back twice, a run resumed across the change of keys is stopped, the coverage check is tighter, two more bit-for-bit tests). Step 3 removed one of the two lost refusals again, with the level bridges it guarded: a district block that lacked a district while its level bridge was distrusted.

Pins

  • Feed pins: us/chronicle_feed.json, us/chronicle_feed_scope.json, us/chronicle_county_facts.json, us/chronicle_county_facts_scope.json, and the two parity resources (32 compiled families, 64 reviewed exclusions).
  • Compile pins in test_us_fiscal_targets.py, test_us_fiscal_target_registers.py and test_us_target_sets.py: measured again on the new feed.
  • state_cd bytes in test_us_acs_local_surface_bytes.py, the district contract in test_us_acs_local_sparse_cd.py, and the district and county pins in the two nesting test files: measured again.
  • Decision 2: the compile pins, the registry versions, the surface bytes and the county SOI rows are measured again. The district counts, drops and unbound blocks did not move. The US F0 pin tools ran and moved no pin.
  • US F0 pins: both pin tools ran (legacy, twice, coverage twice) and both --check pass. The seed protocol attests the bytes of congressional_district_geography, so the golden vector of the spec loader test moved.

The seven items from the review of #1755

#1755 merged on 30 Nov 2026 with seven review items open. They are in df726b5d6, at María's request (1 Dec 2026).

# Item What changed
1 (text) The pages said that a reworded rationale of the declared target sets re-keys no UK solve node The UK national line keys its targets, problem and gates on the bytes of every UK resource, so it computes again. docs/uk-target-sets.md, the #1759 changelog entry and test_uk_solve_scope.py now say so. The root cause is not changed here
2 docs/us-target-sets.md said that a reworded rationale moves no pin It moves documentation_sha256 in the US coverage evidence. The page names the tool to run
3 equals: [] (or {}) changed a selection and no hash The schema of the typed resource and the shared reader refuse a list or an object as a compared value
4 exclude and left_out_levels were hashed in order Both take the set order. The US spec_sha256 and documentation_sha256 move one time; the UK content hash does not
5 UK text described the BRMA row filter and the frs_brma stage that #931 retired Corrected in docs/uk-target-sets.md and in two prose fields of uk/spec/target_sets.yaml
6 The level check of the compile does not read the rows that the local tool builds us/local_target_construction.json is held to the level rule and to the declared built rows when it loads (require_declared_built_levels)
7 Four #1728 changelog entries gave old US field counts The counts are gone

The UK

  • The UK graph hashes cross_grain.py and microcosm.calibrate.target_sets. So the UK target nodes, and every node after them, compute again on the next UK run. The outputs are the same: the bit-for-bit test compares the operator with main's file on seeded surfaces, and it pins the list of definitions that this branch changed or added.
  • uk/spec/target_sets.yaml changes in two prose fields (item 5 above: one description and one rationale). Its content hash and the UK solve fingerprint are the same: test_uk_solve_scope.py and test_uk_graph.py pass with no change of a pinned value. The byte fingerprint moves, so the UK national line computes its targets, problem, solve and gates again one time.
  • No file in uk_runtime/ changes. One UK test file changes in its docstrings only (test_uk_solve_scope.py, item 1).
  • The UK graph does not hash cross_grain_controls.

Merges

Tests run here

On 1 Dec 2026, on the tree of f50fedd25 (the hold-out).

What Result
The US test files of the compile, the target sets, the declaration, the national tool and its post-export probe, the district and county passes, the surface bytes and the national-to-state pass, and the shared files of the operator, the gate bindings, the country spec and the spec engine, with the three pinned inputs and CI's fixed seed 2,254 tests: 2,248 passed, 6 skipped (they need the US engine), none failed
Nine UK files: the eight of the shared operator and target sets, and the file of the notice test 1,229 passed, none skipped
Engine tests in a second venv with policyengine-us 2.145.3: inventory coverage, the coverage tool, the multispine pool tool, the chunked materialize test 41 passed
ruff check ., tools/ci_test_plan.py verify, both pin tools with --check pass

On the tree of 5cf1f85e3 (the six repairs and the merge of main): 1,263 US and shared tests with the pinned inputs and 1,918 UK and data tests passed, none skipped. On the tree of 30b22eea2 (decision 2), every file of CI's engine-free list ran here in two parts: 21,914 tests with the pinned inputs (one failure, repaired) and 16,431 tests as CI runs them (the one failure was the UK notice test, which main now repairs).

No build ran here. The engine-us and engine-uk jobs did not run here, except the engine tests above.

CI

CI was red on 75cb18cba, and on the two heads before it. I had not read it since ca5e864bc.

Job Test Cause Now
engine-us (since the merge of main at dc77fa312) test_every_chunk_and_batch_size_gives_the_one_chunk_target_matrix The test came from main and names the state parent with the old key, state_cd_parent_target_name The fixture uses the operator's key. Passes in the US engine venv
engine-free test_the_committed_feed_pin_banks_the_anchor It follows committed re-pin reports to prove that the pinned feed holds the three BEA facts of the ESI premium anchor. This re-pin drops and changes rows, so it needs a report of its own experiments/us-feed-13294b93/anchor_rows.json: the three facts have the same period, value and source file before and after
engine-free (found locally: CI stops at the first failure) test_the_release_s_recorded_post_export_outputs_are_unchanged The JCT tax expenditures have fiscal-year ids since the re-pin (fy2024), and the test's stand-in reform takes its effect from its id The pin is measured again
not in CI (feed-gated) test__load_ledger_target_specs__compiles_the_pinned_feed It looked for the district file's wv_total row, which the feed no longer has It holds West Virginia's district rows to the two districts of the current plan

One failure was not from this branch: test_no_committed_local_adjudication_is_about_to_lapse (UK). Four DESNZ adjudications expire on 15 Dec 2026, and the test fails from 14 days before, which is 1 Dec. It fails on every branch until the adjudications are renewed on main. The engine-free job stops at the first failure, so it can hide a later one.

CI on df726b5d6 (read 1 Dec 2026, 13:52Z): engine-us, engine-uk, integration-uk, installed-emitter, lint and wheels pass, so the chunk test is repaired in CI too. The two engine-free jobs fail on that one UK test and stop there (23,820 tests passed before it).

CI on 30b22eea2 (read 1 Dec 2026, 16:18Z): engine-us, engine-uk and the other jobs pass. The two engine-free jobs fail on the UK notice test only. #1834 renewed those registers on main (merged 1 Dec 2026, 15:38Z), and 5cf1f85e3 merges that main, so the engine-free job can now run to its end.

CI on f50fedd25: all 12 checks pass (read 2 Dec 2026, 08:27Z). It is the first run on this branch since ca5e864bc in which the engine-free job ran to its end, on both Python versions. The engine-us and engine-uk jobs pass too.

CI on d6ce5d6c1 (pages only) was not read when this text was written.

Not verified

  • No build ran. Matrix rows on real households are not covered.
  • In CI: nothing on the pinned inputs. CI has no feed, no ladder and no county facts file. The pinned bytes, the pinned district and county comparisons and the pinned coverage skip there. A commit that breaks one keeps CI green: run those test files with the three variables set before a merge.
  • A whole state_county surface. The county rows are compared and pinned on the real inputs (above). The support moves and the matrix rows of the county mode need a household frame, and no test here has one.
  • The engine-us and engine-uk jobs did not run here, except 41 engine tests. CI runs them. After decision 2 every file of the engine-free job ran here, in two parts; after the second review's repairs only the touched files ran here (see "Tests run here").
  • The --exact-k arm waited on a feed with the chronicle#277 fix. 13294b93 contains it; the arm has not run on it.
  • A UK build. The proof for the UK is the bit-for-bit test and the UK tests.

Rulings and what is open

Ten calls on the steps were ruled on 27 Nov 2026, with the nine decisions (section 4 of the design page). Step 3 was started on 30 Nov 2026 and decision 2 on 1 Dec 2026, on the rulings of those days. On 1 Dec 2026 the joint surface was ruled into a follow-up PR.

Open:

  • For the follow-up of US targets: one declared nesting rule across national, state, district and county levels #1760: the joint surface, and the retirement of the hold-out with the two known gaps (the charitable deduction needs a Historic Table 2 US row from Chronicle and a feed re-pin; the SALT and real estate taxes pairs need their concept check).
  • Mortgage interest: which variable mortgage_interest_paid_* (column A19300) binds, at the three levels. The review of 2 Dec 2026 prefers a variable before the limits to deductible_mortgage_interest; the engine has one (mortgage_interest).

🤖 Generated with Claude Code

juaristi22 and others added 16 commits November 26, 2026 16:31
…ladder

microcosm#1728 moves the code that builds the local target surface out of
the tools. Each move must leave every target, role and receipt as it was.
TargetRegistry.version sorts metadata keys, so it does not see a change of
key order. Materialize writes target_registry.json and target_roles.json with
the keys in insertion order, and their sha256 is in the run identity.

test_us_acs_local_surface_bytes.py follows the target part of do_materialize
for each non-county --soi-mode: the admin surface, the ladder populations,
the role records, the district pro-rata populations, the ladder population
rows, and the district and county hold-outs. It pins the sha256 of
target_registry.json, of target_roles.json, of the target receipts, and of
the population rows' matrix on a household table that supports every ladder
cell (a release run refuses a cell with no household).

Measured at 3316038 and run twice: state 4,867 targets, totals 742, full
30,464, state_cd 26,912. The tests run only when MICROCOSM_US_CHRONICLE_FACTS
and MICROCOSM_US_PUMA_LADDER_ARTIFACT name the pinned inputs. state_county is
not pinned: it needs the pinned county facts, which are not on this machine,
and a household frame for its support moves.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
microcosm#1760 moves the US share mechanisms to the shared cross-grain
operator with the same bytes. The operator divides a control among its lower
rows as row x control / numpy sum. The US rows sum with math.fsum and, for the
county rows, use a residual rule. On the pinned US feed the numpy sum changes
the last bit of 5,533 of 21,743 district values.

CrossGrainRule gains one field, allocator, default None. With None the
operator runs the standing rule: no float operation is added or removed. With
an allocator, the operator calls it for each control and takes
(values, factor, raw_sum) from it; the refusals and the closure check apply
unchanged, and the leg receipt names the allocator. The file gains no import.

The UK declares no allocator. The UK graph hashes this file, so the UK target
nodes and the nodes after them compute again on the next UK run, with the
same outputs.

Proof:
- test_support/microcosm_build/cross_grain_reference.py is the file at
  e29843d, pinned by sha256. test_cross_grain_allocator.py runs 400 seeded
  surfaces (with and without factor bounds) through both modules and compares
  the value bytes, the receipts and the refusal texts. It also checks that
  only CrossGrainRule and the reconcile function differ from the reference,
  and that the imports are the same.
- The operator tests and the UK tests that use the operator pass unchanged.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
microcosm.build.cross_grain_controls holds what a country's sources can need
around the operator (microcosm#1760). It is plain arithmetic on values and
keys, with no country in it:

- allocators for CrossGrainRule.allocator: proportional_fsum (the standing
  rule with an exactly rounded sum), and share_residual_to_largest and
  scale_residual_to_largest, which reproduce rows first made outside the
  operator and are marked for replacement in Stage B;
- derived controls: sum_of_lower_rows and scaled_by_sibling_ratio;
- the factor band: control_ratio, level_ratio, median_by_group, band_verdict;
- completeness: leg_completeness, with declared combined cells;
- self-consistency: sum_gap.

The operator does not import the module, so the UK graph does not hash it.
No caller uses it yet.

Proof: test_cross_grain_controls.py holds each allocator, bit for bit, to
the arithmetic it replaces on 200 seeded blocks, runs each one through the
operator, and checks the helpers and that the module names no country.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
us/cross_grain_declarations.json is the US file of the shared cross-grain
operator (microcosm#1760). It names the geography levels and the levels that
hold controls with the key names of uk/cross_grain_declarations.json, and it
declares the four mechanisms that make lower-level rows from a higher-level
control in the local tools (rows 5 to 8 of the issue): the allocator, the
rule for the control, the bounds, the source of the member lists, the old
metadata keys, and the reviewed registers with their reasons.

The registers were Python literals in the tools: the defective, unparented
and excluded district measures, the six level bridges, the factor band, the
two tolerances, the reviewed crosswalk digest, the required county measures
and the combined cell with its basis. The tools now read them from the
declaration under their old names. No function uses the operator yet.

us_runtime/cross_grain_declarations.py reads the file.
us_runtime/target_nesting.py is the adapter: it builds one surface from
blocks (a control and its lower rows), runs the operator with the declared
allocator, and returns each block's rows. A stage can record the operator's
own receipts and write them to target_nesting.json.

The new resource row moves the US F0 pins, as each new legacy resource does:
42,407 configuration fields (32,621 authored), the country_manifest claim at
116 pointers, and the US bundle's semantic spec_sha256 (9141b9bf). No target
changes. Both pin tools ran twice and their --check modes pass.

Proof: test_us_cross_grain_declarations.py holds each register to the
literal it replaces (value, type and order), read from
test_support/microcosm_build/us_target_nesting_reference.py, which is the
tool code at e29843d. It also checks the declaration's shape and the
adapter's block interface.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
state_cd_soi_surface (row 5 of microcosm#1760) rebased each state's district
rows onto the Historic Table 2 state row with its own arithmetic. The shared
operator now divides each state control among its district rows, with the
proportional_fsum allocator the US declaration names. The adapter
(us_runtime.target_nesting.district_soi_surface) keeps the US side: the
choice of the control, the level bridge by a sibling ratio, the factor band,
the plan completeness check, the self-consistency check, the refusals with
their texts, and the old metadata keys and receipt.

The tool functions state_cd_soi_surface and state_parent_reconciliation keep
their names and signatures and call the adapter. About 450 lines leave
tools/us_acs_local_cd_surface.py.

No target changes. On the pinned feed and ladder the state_cd surface has the
bytes it had: 26,912 targets, and the same sha256 of target_registry.json,
target_roles.json and the receipts (test_us_acs_local_surface_bytes.py).

Proof:
- test_us_target_nesting_district.py holds the tool function to the verbatim
  copy of the code it replaces on 160 seeded surfaces: the same specs in the
  same order, value bits, metadata key order, receipt bytes and refusal
  texts. The draws include signed rows, all-zero blocks, blocks out of the
  band (with NaN in the receipt), bridged concepts, a state with one district
  and four kinds of refusal.
- The district property tests, the sparse tests and the feed contract tests
  pass unchanged.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Three county mechanisms of the ACS local release made rows from a state
control with their own arithmetic (rows 8, 6 and 7 of microcosm#1760). The
shared operator now divides each state control among its counties, with the
allocator the US declaration names:

- with_county_populations: the ladder's county overlaps, scaled to the state
  total (scale_residual_to_largest);
- state_county_soi_surface: county SOI facts as shares of the broad state
  row, with the declared combined cell (share_residual_to_largest);
- acs_household_surface: the state target is the sum of the county estimates
  (sum_of_lower_rows), and the counties divide it
  (share_residual_to_largest).

The adapter (us_runtime.target_nesting) keeps the US side of each one: the
fact checks, the completeness checks, the refusals with their texts and
their order, and the old metadata keys and receipts. The tool functions keep
their names and signatures. county_code_of, the county hierarchy,
cell_members and the broad-parent test moved with them and stay in the tool
under their old names. About 460 lines leave
tools/us_acs_local_county_surface.py.

The materialize stage records the operator's own receipt of each nesting
pass and writes it to a new file, target_nesting.json. No stage reads it and
it is not in the run identity. The old receipts keep their bytes.

No target changes.

Proof:
- test_us_target_nesting_county.py holds each tool function to the verbatim
  copy of the code it replaces on 120 seeded inputs: the same specs in the
  same order, value bits, metadata key order, receipt bytes, refusal texts
  and refusal order. The draws include equal largest rows, zero rows, the
  combined cell, optional measures and ten kinds of refusal.
- The three county test files, the tests that run the materialize stage and
  the pinned non-county surfaces pass unchanged.

Not covered: the county rows on the pinned county facts file. The file is
not a local test input, so these blocks are synthetic.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
us/cross_grain_declarations.json gains an inventory: each US family that two
geography levels measure, with the route that ties the levels today or the
reason none does (microcosm#1760). It records what the code does. It decides
no nesting rule: the decisions of the issue are open, and Stage B applies
them.

- Rows 1 to 4 of the issue (capital gains, taxable interest, state AGI bands,
  the district file's own state row) are compile rules. Each entry says why
  its arithmetic stays where it is in Stage A and names the metadata the rule
  writes.
- Rows 5 to 8 name their mechanism on the shared operator.
- The families that do not nest have a reason and an issue: the SOI families
  with two national rows, the state age rows, the program families whose
  state rows are not checked against their national row, the families with
  no national row, and the district ACS rows that are not in the fit.

us_cross_grain_coverage_violations checks a set of compiled specs against the
inventory. It is a receipt and a test of the declaration. No build calls it
and it refuses nothing.

docs/us-target-nesting.md describes the operator, the allocators, the four
mechanisms, the receipts, the inventory and what Stage A leaves open.

Proof: test_us_cross_grain_coverage.py checks each entry, that rows 1 to 8
each have one entry and each mechanism has one, and each kind of gap on
synthetic specs. With the pinned feed it compiles the registry: no
violation, and the families below the national level are exactly the ones
the compiled entries name. The inventory does not move the US pins (both
--check modes pass).

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
…tracts

main moved 93 commits (to 5589fae). None touches cross_grain.py, the three
local tool files or fiscal_targets.py. Two generated pin files conflicted:
the F0 coverage evidence and the pool tool's spec_sha256 pin. Both took main's
side and were written again by the pin tools on the merged tree
(tools/repin_us_spec_engine_contracts.py, tools/spec_engine_coverage.py: two
passes each, then --check). Coverage reads 42,407/42,407 fields and 41/41
inventory checks; the US bundle's semantic spec_sha256 is now 7ef87297.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
docs/us-target-nesting-rule-design.md is the design step of Stage B of
microcosm#1760. It is a proposal: no code reads it and no target changes.

It records the two rulings so far, the second from 27 Nov 2026 (the Historic
Table 2 state row is the state parent of a district row on every surface,
and a parent that it does not contain is not removed). It then proposes one
rule in nine statements, shows what each family does today with the sum of
its lower rows over its higher row on the pinned feed, and lists nine
decisions, each with a recommendation: the level holder, national to state
for the SOI families, the program families, the state population vintage,
the county households, bounds and members, the ACS district rows, the parent
in the loss, and one allocator, key set and receipt.

docs/us-target-nesting.md points to it and notes the 27 Nov ruling.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
… constructs

docs/us-target-nesting-rule-design.md: the nine decisions of the nesting rule
were accepted on 27 Nov 2026 (the recommended option of each). The page now
says so, and gains a section on how the rulings are declared.

The principle of that section: the US declares its nesting with the
constructs that the UK declares in uk/cross_grain_declarations.json, under
the same key names (exact signatures, bridges, bridges with a derived
control, partitions, relations, local routes, licensed empty legs, the
cross_grain_* metadata keys and the pass receipt). The section maps each
ruling to one of them, gives sketches, and lists the four additions that the
shared tooling needs, each optional and beside the operator: bridge
families, two kinds of derived control, a bound around a common factor, and
a US contract derived from declared metadata fields. It also says what the
US-only keys of Stage A (mechanisms, inventory) become at the re-pin.

Docs only. No code applies the rulings yet; the target changes wait for the
feed re-pin.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Ruled on 27 Nov 2026: clean country-agnostic code comes first, the simpler
and the more general the better, with no construct for one country only, and
a UK re-key is accepted for it.

So section 5 of docs/us-target-nesting-rule-design.md no longer adds US parts
beside the operator. It states one model for every country in the shared
operator, in six things: the measurement, the bridge (by id or by a
selector), the derived control (sum or scaled), the bound (limits around a
reference, and refuse or unbind), the members of a leg, and the pairs that
are not reconciled. It lists what goes: the allocator hook and the three
allocators at the re-pin, the US-only keys and checks, the sibling-ratio
bridge, the US metadata keys and receipts, and the four separate passes. It
maps each ruling to the model and gives three steps.

Docs only.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
…erator

Three things that each country did in its own code are now parts of the
shared cross-grain operator (microcosm#1760, design section 5), each off by
default:

- The bound of a bridge. CrossGrainBridge gains min_factor_shift (a
  one-sided bound), shift_around ("one", or "median" for the median factor
  across the legs of the bridge, which takes out a gap that every leg
  shares) and out_of_bound ("refuse", or "unbind": the leg's lower rows stay
  as given and the receipt names them, so the caller takes them off its
  surface). The US band of 1.25 around the median is a shift from -0.20 to
  +0.25 around "median" with "unbind".
- The members of a leg. apply_cross_grain_reconciliation takes
  expected_members (lower target -> leg -> geographies) and refuses a leg
  that holds other rows than those. A leg with no row stays with the
  empty-leg licences.
- The bridge selector. CrossGrainBridgeSelector and expand_bridge_selectors
  make one bridge for each pair of targets from one declared entry, and name
  the lower targets that no higher target pairs with.

The UK declares none of these. Its outputs are the same: the bit-for-bit
test still holds the default path to the operator at e29843d on 400 seeded
surfaces (values, receipts, refusal texts), and a receipt gains the
unbound_legs key only when a bridge of its rule unbinds. The UK graph hashes
this file, so the UK target nodes and the nodes after them compute again.

Proof: test_cross_grain_model.py (20 tests); the pinned list of changed
definitions in test_cross_grain_allocator.py; the operator tests and the 17
UK test files that use the operator pass unchanged (787 passed, 7 skipped).

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
…s as frames

CI's engine-free job failed on the Stage A head in
test_runtime_population_operators_are_source_spine_blind. The check treats a
function parameter with no annotation as a possible frame, and refuses a
subscript on it whose key it cannot resolve. us_runtime/target_nesting.py had
nine: two lambdas over a block key, and the county populations and county
values of the two county functions, which came from the tool with no
annotations.

The two county functions now annotate their parameters, and the block key is
read by a named function. No behavior changes. The whole test file passes.

I had run one test of that file locally, not the file.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
…row in the operator

Two general changes to the shared cross-grain operator, for step 2 of
microcosm#1760 (the US on the model). The UK declares neither.

- expected_members reads every declared leg, with or without rows. A leg
  whose members were all absent was left to the empty-leg licences. So a
  target with no row at all formed no group, and the pass left its totals
  as they were without a word. Such a leg is now refused like a leg that
  lacks one member. A leg that declares no member holds no row, and the
  licences still decide it.
- The metadata of a reconciled row is in the operator: the UK's key names
  (cross_grain_value_before, cross_grain_factor, cross_grain_control), two
  new general keys (cross_grain_parent, the name of the control row, and
  cross_grain_members, the geographies a row stands for), and
  cross_grain_metadata, which writes them in a fixed order. A country takes
  the names from one place. No UK code changes.

The default path is the operator before any edit, bit for bit
(test_cross_grain_allocator.py, 400 seeded surfaces; its pinned list of
added definitions gains cross_grain_metadata). The UK graph hashes this
file, so UK target nodes compute again on the next UK run, with the same
outputs.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
…'s keys and receipts

Step 2 of microcosm#1760 (docs/us-target-nesting-rule-design.md, section
5.5), on María's go of 27 Nov 2026. No target value changes: on the pinned
feed and ladder each of the 26,272 rows of the state_cd SOI surface has the
bits of the value it had, and the full, state and totals surfaces have the
bytes they had.

What is general now, and where:

- cross_grain_controls holds one row-level pass, reconcile_rows: it runs
  the operator on target rows and says, for each row, its value, what
  reconciled it, the factor, and the control row. The helpers that only the
  US used (factor band, completeness, self-consistency, sibling ratio) are
  gone: the operator's bound, members and selectors do that work.
- us/cross_grain_declarations.json is in the UK's key names:
  bridge_selectors (Historic Table 2 state rows over district-file rows,
  with the bound +0.25 / -0.20 around the median and unbind; state SOI rows
  over county-file rows), derived_controls (county households),
  same_measurement (the ladder population), relations (six subset pairs,
  Medicaid with max_excess), local_routes, members, registers. What goes at
  the feed re-pin is under until_the_feed_repin: the allocators, the level
  bridges of the six district-only concepts, the compile rules of rows 1
  to 4 and two known gaps. The keys mechanisms and inventory are gone.
- us_runtime/target_nesting.py runs each of the four passes through one
  function, run_pass.

What changes by design:

- Metadata keys: cross_grain_parent, cross_grain_value_before,
  cross_grain_factor, cross_grain_control and cross_grain_members replace
  the state_cd_* and state_county_* keys. Six old keys have no new one:
  the parent row, the operator's receipt or the declaration holds the value.
- Receipts: the district receipt has bridge (with the unbound legs),
  level_bridge_out_of_band and factor_by_measure. factor_band,
  rebase_factor_by_measure and internal_consistency are gone. County blocks
  lose share_sum. target_nesting.json entries are pass, allocator and the
  operator's receipt.
- So three pins of state_cd move (registry, roles, receipts). The target
  count and the population matrix are the same.
- A refusal that the operator makes has the operator's text.
- The check that the district file's own state row is the sum of its
  district rows is gone. Row 4 of the compile scales the district rows to
  that state row before this pass (22,236 district rows carry its marker on
  the pinned feed; the 436 that do not are never bound).
- A concept that takes its state parent from Historic Table 2 in some
  states and from the district file in others is refused. It does not occur
  on the pinned feed.
- With the bound turned off (tests only), a concept whose Historic Table 2
  level is zero in every state keeps district rows of zero.

The readers of the keys move with them: the loss weights, the hold-outs and
their pro-rata baselines, the county reports, and one field of the reviewed
limitations. The dated runs under experiments/ are not changed.

Proof: test_us_target_nesting_district.py and test_us_target_nesting_county.py
hold the tool functions to verbatim copies of the code they replace (160 and
120 seeded inputs, and the pinned feed): the same rows in the same order, the
same value bits, the same parent, factor, value before and members under the
new keys, the same counts, drops and summaries. Both US pin tools ran and
wrote no file; --check passes.

PR #1755 declares the old parent keys in us/local_target_construction.json
and pins the state_cd registry bytes. The PR that merges second takes the
other's change.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
docs/us-target-nesting.md is the page of the code as it is after step 2 of
microcosm#1760: the six things of the model, the four passes, what the
operator checks and what the adapter checks, what stays until the feed
re-pin, the metadata keys with the keys they replace, and each difference
from the code before. The SOI surface page and the county page name the new
keys and receipt fields. The design page records that steps 1 and 2 are on
the branch and which two parts of the model are not built yet (the scaled
derived control, and one pass on one joint surface).

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
@juaristi22 juaristi22 changed the title Run the US share mechanisms on the shared cross-grain operator (Stage A of #1760, no target change) Nest the US target rows on the shared cross-grain operator (#1760: Stage A and steps 1 and 2, no target change) Nov 27, 2026
juaristi22 and others added 3 commits November 27, 2026 15:39
Ruled on 27 Nov 2026, after steps 1 and 2 of microcosm#1760 were written:
no allocator after the re-pin; one parent source for a concept; the
district file's self-consistency check stays out; the county rows are
compared and pinned on the pinned county facts file now; the merge waits for
a gap between UK releases; PR #1755 merges first; the rulings go on the
issue after the text is approved; Medicaid stays a subset with a declared
excess; the full surface and district capital gains nest in the Historic
Table 2 state row at step 3; decisions 4 and 7 go in their own PRs.

Docs only.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
…pin them

Call 4 of the rulings of 27 Nov 2026 on microcosm#1760: the county rows are
compared and pinned on the real inputs now, not at the feed re-pin.

test_us_target_nesting_county.py gains two tests that read the pinned feed,
the pinned PUMA ladder and the pinned county facts file
(us/chronicle_county_facts.json, 922 MB, sha256 67b0998a...). They run when
MICROCOSM_US_CHRONICLE_FACTS, MICROCOSM_US_PUMA_LADDER_ARTIFACT and the new
MICROCOSM_US_CHRONICLE_COUNTY_FACTS name those files, and skip without them.

- The three county passes give the rows of the code before the move to the
  shared operator, in the same order, with the same value bits, parent,
  value before and members: 3,143 county populations on 2020 counties and
  3,144 on the 2023 county-equivalents, 6,286 county SOI rows (two measures
  for 3,143 cells; one cell stands for Kalawao and Maui), and 51 state and
  3,144 county household rows.
- The bytes of those rows and of their receipts are pinned.

Measured on the same inputs, for decision 6: the factor of each of the 51
county SOI legs is within 0.998 to 1.052 of the median for adjusted gross
income (median 1.1207) and within 0.9997 to 1.0005 for the return count
(median 1.0000). No leg is outside the band of 0.8 to 1.25 that the district
bridge declares. The pages record it. Whether the county bridge declares
the band is still to rule.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Ruled on 27 Nov 2026 (microcosm#1760, decision 6), after the county factors
were measured on the pinned county facts: the county bridge declares the
band of the district bridge. No county value changes.

- us/cross_grain_declarations.json: the selector state_soi_vs_county_file
  takes max_factor_shift 0.25, min_factor_shift -0.2, shift_around median
  and out_of_bound unbind.
- us_runtime/target_nesting.py: the county pass handles a leg that the
  operator unbinds. Its county rows of that measure leave the surface, the
  receipt names the leg under bridge.unbound, and its counties do not count
  as missing. One helper gives both passes their selector, and one gives
  each surface receipt the same bridge entry (the bridge, its bound, the
  legs it unbound), the households receipt too.
- tools/us_acs_local_county_surface.py: state_county_soi_surface takes
  factor_band, as state_cd_soi_surface does. The default is the declared
  band, and an infinite band turns the bound off (tests with random
  factors use that).

On the pinned county facts the factor of each of the 51 legs is within
0.998 to 1.052 of the median for adjusted gross income and 0.9997 to 1.0005
for the return count, so no leg is unbound: the 6,286 county SOI rows keep
their pinned bytes. The two receipt pins of the county rows move, because
the receipt names its bridge in the new shape. The state_cd pins do not
move.

Tests: a state that is off the median loses its county rows of that measure
and the receipt names it; a state off in both measures is not refused; the
old-against-new comparison on random blocks runs with the bound off,
because the old code had none.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
juaristi22 and others added 9 commits November 27, 2026 19:19
…with the old copy

From the adversarial review of PR #1791 (microcosm#1760), findings 2, 8
and 9.

- The members check of the operator counted each member once, so a row
  that appeared two times passed. The old US district code refused that.
  The rule is now one public function, assert_leg_members: a leg holds each
  declared member one time; a member that is absent, a row of another area,
  and a member that two rows hold are refused. A caller that takes a leg
  off its surface before a pass checks it with the same function. The UK
  passes no expected_members, so no UK call reaches this.
- reconcile_rows named a wrong factor, or no status, in two shapes that the
  operator accepts: a row under two controls (a bridge and a control of its
  own measurement), and a leg id that holds "+". It refuses both. No US
  pass reaches either.
- The bit-for-bit test had one shape of surface. Two tests add the others:
  seeded surfaces with a bridge that is valued for each geography (200
  seeds: 241 results and 159 refusals, all equal to the copy of the file
  at e29843d), and a replay of the operator's own tests
  (test_cross_grain.py) in which each call also runs that copy: 59
  reconciliation calls, 6 partition calls and 4 detection calls, with
  bounded bridges, rows that bind nothing, reviewed unbound targets,
  licensed empty legs and unchecked bounds.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
…its coverage check

From the adversarial review of PR #1791 (microcosm#1760), findings 1, 6,
10 and 11.

The district pass:
- A block whose level bridge is distrusted leaves the surface before the
  pass, so the operator never saw it, and a block that lacked a district
  was dropped in silence. The old code refused it. The adapter now checks
  such a block with the operator's rule (assert_leg_members). With the
  operator change before this commit, a district row that appears two
  times is refused again too.
- A district-file target that the selector pairs with no Historic Table 2
  target, and that no state row of its own measurement controls, is
  refused. The pass threw that list away.
- The trust band of a level bridge reads both limits of the declared bound.
  It read the upper one and took its inverse.

The declaration:
- An unknown top-level key, a bridge by id and a partition are refused when
  the file loads: no US pass would read them.
- The part of a subset relation must be at a lower level than its whole.
- The higher level of a compile rule or a known gap must be a declared
  level. The derivation of a derived control is read by the adapter, which
  hard-coded the sum.
- single_member_legs goes: nothing read it.

The coverage check:
- A role that the top level and a lower level both hold must be named: by a
  relation of its own, or by a compile rule or a known gap that lists it. A
  family was covered as a whole, so a new role in a covered family passed
  unseen. On the pinned feed ten roles are at two levels. Six had a
  relation. The two premium tax credit roles of Historic Table 2 get a
  subset relation (their 51 state rows sum to 0.9996 and 0.9997 of the US
  row). The general SOI role and the Census age rows are listed by the two
  known gaps that are about them.
- A subset whose whole is more than one row, or is not positive, is a
  violation. It was skipped in silence.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
…r code wrote

From the adversarial review of PR #1791 (microcosm#1760), finding 4, on
María's go of 27 Nov 2026 ("Fix all").

A run that is resumed across the change of the metadata keys reads files of
older code. The run identity holds no code hash, so nothing stopped it:
calibrate failed with a text about concept groups, finalize wrote an empty
value in one reviewed limitation, and a county report could lose the SOI
evidence of the county that a combined cell covers.

- The checkpoint loader refuses a target_registry.json or a
  target_roles.json that holds a key with the prefix state_cd_ or
  state_county_.
- The finalize stage refuses a district receipt in materialize_rss.json
  that holds rebase_factor_by_measure, factor_band or internal_consistency.

Each refusal says that the file was materialized by older code and to run
--stage materialize again. No key of this code has one of the two prefixes.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
From the adversarial review of PR #1791 (microcosm#1760), findings 3, 5, 7,
10 and 11.

- Two sentences from Stage A said that every metadata key and receipt, and
  the bytes of the surface, were as before. Step 2 made them untrue.
- docs/us-target-nesting.md: what the removed self-consistency check leaves
  open for the six concepts that only the district file has; the two
  refusals that were lost and are back; a band of 2.0 or more is refused;
  the guard for a run resumed across the change; which proofs run in CI and
  which only where the pinned inputs are; what the coverage check proves
  and what it does not; that the pairs that are not reconciled are read by
  the coverage check only.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
…tten again

main moved 114 commits past the last merge (5589fae), and the PR
conflicted, so no CI check ran on it. Two generated files conflicted, the
same two as at the first merge: docs/evidence/spec-engine/us-f0-coverage.json
and test_us_multispine_pool_tool.py. main's side was taken for both, and the
US pin tools then wrote them for the merged tree (legacy, twice, coverage
twice); both --check pass.

main touches none of the nesting files: not the operator, not
cross_grain_controls, not the US declaration, its reader or the adapter,
not the two local surface tools. Its change to
tools/build_us_acs_local_release.py (household batch helpers) merged with
no conflict. The merged tree holds no reader of the retired metadata keys.

The environment needs the lock file of main: microcosm-emitter-interface
0.18.0 (uv sync, from the local cache).

Not run on the merged tree here: the tests. A build of another session
filled the machine's memory, and the test run was stopped. ruff, the CI
test plan check and both pin checks pass. CI runs the suites; the tests on
the pinned inputs still need a run on this machine.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
… the refusal

CI runs the property tests with a fixed seed. On that seed, this test drew
a district block of 2.0 under a Historic Table 2 state row of 2,000,000,001,
with the bound turned off. The operator refuses a lower total that is below
1e-9 of its control, by design. So the two engine-free jobs failed on this
test on each run. A local run draws a random seed, and passed.

The test now draws values from 1 to 1e8, so no block is below the limit.
The case that CI drew is now a fixed case of the refusal test.

Only the test file changes.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
…tten again

main is 319 commits ahead, with the geography-first move of microcosm#931
(PR #1538). Six files conflicted, each a generated pin or a count of the
spec-engine ledger. Each takes main's side, plus the three declaration
fields that this branch adds (one resource row of the US manifest): 32,641
authored fields and 50,845 configuration fields. Both pin tools ran, and
both --check pass.

main changed the shared operator for #931: a share_of_parent partition may
miss a member that a signed deferral leaves off the frame. So the reference
copy of the bit-for-bit test is now main's file at dc77fa3 (it was the
file at e29843d). The sets of definitions that this branch changed or
added are the same, and the operator tests pass against the new copy.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
PR #1755 is on main now. It moves the US target selection, hold-outs, ladder
rows and compile registers into declared files. Ten files conflicted:

- six generated pins and counts of the spec-engine ledger. Each takes main's
  side, plus the three fields of the one manifest row that this branch adds:
  32,814 authored fields, 51,018 configuration fields, country manifest
  125 pointers. Both pin tools ran, and both --check pass.
- the hold-out and baseline code of the two local tools: main's side (the
  shared target_holdouts code). Its declaration
  us/local_target_construction.json and the frozen reference copy of the old
  tool code now name the parent key cross_grain_parent at both levels, as the
  tool code before #1755 read it on this branch. The hold-out equivalence
  test sets that key on its records.
- the module list of the spine blindness test: both lines.
- the surface-bytes test: one docstring for both changes, and this branch's
  three state_cd pins. The merged code gives those bytes again, so #1755's
  moves change no byte here. test_us_target_sets.py pins the state_cd
  registry version that main makes with the state_cd_* keys; it takes this
  branch's version (the count and every value are as before).

An import that the merge left unused goes. The shared cross-grain operator
is the same file on main, so the bit-for-bit reference stays.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
PolicyEngine/chronicle#451 merged as 13294b93 (28 Nov 2026). The US feed and
the county facts move there together (microcosm#1760, step 3).

The feed (tools/build_us_chronicle_feed.py, built offline from a clean
checkout; 62,268 rows on the chronicle.consumer_fact.v5 contract, sha256
2e880fd3...). The scope keeps today's record sets and tax years: nine
record sets now carry their true tax year (chronicle#117) and take it, the
JCT tax expenditures for 2024 are the fiscal-year record set, and the TY2023
copy of the W-2 tips table goes because its TY2020 pair is in the scope
(705 pairs). The county facts built at 13294b93 have the bytes of the
3e9d3a0 build, so only their commit and scope digest move. The parity
resources follow the feed: 32 compiled families, 64 reviewed exclusions.

What the compile needs on this feed:
- District of Columbia: Chronicle numbers its seat 98 (1198), as the Census
  Bureau does; the district translation reads a seat 98 at seat 00.
- Taxable interest by AGI band: the TY2023 state package carries it now,
  and no TY2023 national Historic Table 2 row is in the scope, so the stale
  interest rebase would drop those rows after they displaced the TY2022
  rows. Such a slice no longer takes part in the newest-vintage selection
  (eligibility is part of selection), so the TY2022 rows stay and the six
  reviewed Iowa/North Dakota/Vermont exclusions need no change.
- Measure ids: qbi_amount/qbi_claims (Historic Table 2's ids of the QBI
  deduction) map to the QBI variable; interest_paid_deduction_* is
  mortgage_interest_paid_* now (column A19300/N19300), with the same
  variable.
- A new register, deferred_district_measures: twelve district measures that
  would be new targets (CTC, real estate taxes, taxable income, wages, and
  SALT and PTC, which read the right IRS column now). They are bound in
  microcosm#1731, not here.
- The restamp register is empty: no fact of the feed is restamped.
- District capital gains: the district file has no US row now, so its share
  denominator is the sum of its district rows of the same key.
- The 44 JCT references take the fy2024 ids; the target names change, the
  values do not.

The national_state surface keeps its 810 state taxable-interest band rows
and gains the Historic Table 2 state rows of charitable contributions,
mortgage interest and the QBI deduction (306), the Historic Table 2 US QBI
rows and eight Table 1.4 partnership and S corporation rows. The state SSI
targets take SSA's own workbook values (the pinned file's states summed to
more than its own US row). The state_cd surface still refuses at this
commit: its pairing and parents change in the next commit.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
juaristi22 and others added 2 commits December 1, 2026 00:44
… bridges go

Step 3 of microcosm#1760, on the feed of 87fabcd (Chronicle 13294b93).

The nesting:
- Every district row of the congressional-district file nests in its
  Historic Table 2 state row, on state_cd and now on full too (rule
  state_cd_district_shares on both modes in us/spec/target_sets.yaml), so
  the two modes give the same rows. The district file has no state row now,
  and Historic Table 2 carries the state rows of charitable contributions
  and the QBI deduction, so the level bridges go (STATE_CD_LEVEL_BRIDGES,
  the defective-measure register and the level-bridge fields of the
  receipt).
- The district selector pairs by measure id: Historic Table 2's
  qbi_amount/qbi_claims with the district file's
  qualified_business_income_deduction_* (paired_values). Its closure
  tolerance (1e-9) is declared on it.
- The allocator hook of the shared operator (CrossGrainRule is main's
  again) and the three US allocators go: every pass divides a control by
  the operator's own rule. No reader needs an exact sum: every closure
  check has a tolerance. County populations keep their bits; county SOI and
  household rows move in the last bits.
- Row 4 of the compile retires (hierarchy_reconciliations is empty): the
  district file has no state row to scale its district rows to.
- The household district distribution reads the record set of the pinned
  district file (ty2022), and the District of Columbia's seat 98 as seat 00.
- Rows 1 to 3 are declared under compile_rules; until_the_feed_repin goes.

A correction to 87fabcd: it renamed the SOI measure maps from
interest_paid_deduction_* to mortgage_interest_paid_*. That took Table
2.1's national interest paid deduction off interest_deduction, and bound
column A19300 (home mortgage interest paid to financial institutions, one
part of the deduction) to the variable of the whole deduction. This commit
restores the interest_paid_deduction_* entries and the role key, and adds
the two mortgage_interest_paid_* measures to deferred_district_measures (14
measures now). Under that id the measure binds no variable at any level
(Table 2.1, Historic Table 2, the district file); which variable it binds
is a decision of its own.

On the pinned feed: release 28,116 targets; national_state 6,316 (+204
Historic Table 2 state rows, +2 national QBI rows, +8 Table 1.4 rows);
local state 4,584, totals 255, full and state_cd 25,463 (25,950 with the
ladder rows). state_cd has 4,431 Historic Table 2 state rows and 20,879
district rows (49 measures) in 2,102 blocks; the factor band unbinds five
blocks (44 rows). The pins moved with it, and the US F0 pins were written
again: the seed protocol attests the bytes of
congressional_district_geography, so the seed hashes and the golden vector
of the spec loader test moved.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- docs/us-acs-local-soi-target-surface.md: the state_cd section on the new
  feed (one Historic Table 2 vintage; factors near 1.02 now that both files
  are tax year 2022; the five blocks that the band drops; what stays off the
  surface; the counts), the surfaces measured again on 13294b93, and full.
- docs/us-chronicle-feed-repin.md: the 2026-11-30 re-pin.
- docs/us-target-nesting.md, docs/us-target-nesting-rule-design.md: what
  changed at the re-pin, the status, and what is not built yet.
- docs/us-target-sets.md: the counts and registry versions on the new feed.
- docs/us-national-build-runbook.md, docs/us-release-build-rule.md: the
  new feed commit and digest; the new pin contains Chronicle b571381f.
- changelog.d: an entry for the re-pin, and the Stage A entry without the
  allocator and the level-bridge fields.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@juaristi22 juaristi22 changed the title Nest the US target rows on the shared cross-grain operator (#1760: Stage A and steps 1 and 2, no target change) Nest the US target rows on the shared cross-grain operator, and re-pin the US feed (#1760: Stage A and steps 1 to 3) Dec 1, 2026
juaristi22 and others added 5 commits December 1, 2026 09:24
38 commits of main since 6b87a0c: the pooled post-export scoring work
(#1775 and the commits before it). No conflict. main touches no nesting
file, no pin of the spec engine and no feed pin.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
CI on 75cb18c was red, and a local run of the whole engine-free job found
the rest (CI stops at the first failure).

- test_the_committed_feed_pin_banks_the_anchor follows committed re-pin
  reports from the feed that added the three BEA facts of the ESI employer
  premium anchor (NIPA Table 7.8, series B4923C) to the pinned feed. The
  re-pin to Chronicle 13294b93 drops and changes rows, so it needs its own
  check: experiments/us-feed-13294b93/anchor_rows.json lists the three rows
  of the feed before and after it (list_anchor_rows.py), and
  _follow_row_changing_repin_report holds both sides to the banked rows:
  same period, value and source file. The three facts are unchanged.
- test_every_chunk_and_batch_size_gives_the_one_chunk_target_matrix (from
  main, engine-us) built its district rows with state_cd_parent_target_name.
  The tool reads the operator's key, cross_grain_parent, so the per-chunk
  parent check saw no block. The fixture names the parent with PARENT_KEY.
  It failed since the merge of main at dc77fa3.
- test_the_release_s_recorded_post_export_outputs_are_unchanged (from main)
  pins a hash of the reform validation output. The JCT tax expenditures
  have their fiscal-year ids since the re-pin (fy2024, cy2024 before), and
  the stand-in reform's effect is a function of its id, so the pin moves.
- test__load_ledger_target_specs__compiles_the_pinned_feed (feed-gated)
  looked for the district file's wv_total row, which the feed no longer
  has. It now holds West Virginia's district rows to the two districts of
  the current plan, and the state row to Historic Table 2's.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
The adversarial review of #1755 (30 Nov 2026) left one important finding
and six smaller ones. None was changed before its merge.

1 (text). The UK national line keys its targets, problem and gates on the
   bytes of every UK resource, so a reworded rationale of the declared
   target sets makes it compute again. docs/uk-target-sets.md, the #1759
   changelog entry and test_uk_solve_scope.py said that it re-keys no solve
   node. They now name the full line, and the national kernels as out of
   the test's scope. The root cause is not changed here.
2. docs/us-target-sets.md: a reworded rationale moves documentation_sha256
   in the US coverage evidence; the page said that it moves no pin.
3. A metadata test compares with one scalar. The schema of the typed
   resource and the shared reader refuse a list or an object as the value
   of equals or not_equals: one with no member is absent from the canonical
   content, so the test changed a selection and no hash.
4. exclude and left_out_levels take the set order: their order means
   nothing to a selection. The US spec_sha256 and documentation_sha256 move
   one time (pins written again); the UK content hash does not move. The
   same entry two times in left_out_levels is refused by the spec engine
   before the reader. The page names the five fields that are normative
   though no selection reads them.
5. The UK page and the prose of uk/spec/target_sets.yaml described the BRMA
   row filter and the frs_brma stage that #931 retired. Only description
   and rationale text changes in the UK file: its content hash and the UK
   solve fingerprint are the same (test_uk_solve_scope.py, test_uk_graph.py
   pass with no change of a pinned value); the byte fingerprint moves, so
   the UK national line computes again one time.
6. The level check of the compile reads compiled targets only. The US
   ladder population levels (us/local_target_construction.json) are now held
   to the level rule and to the built rows of the declared target sets when
   the file loads (require_declared_built_levels). It reads the two packaged
   declarations only.
7. Four #1728 changelog entries lose their US field counts.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
…ion 2)

Fourteen SOI quantities bound a Historic Table 2 US row (tax year 2022)
beside a newer Publication 1304 row (tax year 2023): no weight vector meets
both (microcosm#1243). Decision 2 of microcosm#1760 (ruled 27 Nov 2026):
the newer row is the national control, each state row keeps its share of
the US total of its own file, and the Historic Table 2 US row stops
binding.

- The shared arithmetic: cross_grain_controls.scaled_control, a derived
  control that is a value times the lower rows' share of their own source's
  total. The operator divides it, so each lower row takes one factor and
  the lower rows are not scaled to sum to the value.
- The declaration: one derived control of the kind scaled in
  us/cross_grain_declarations.json, with an entry for each of the 14 pairs
  (the measure of the state rows, the table and the measure of the control,
  the publisher concept and the evidence of the concept match). The known
  gap of microcosm#1243 goes.
- The pass: fiscal_targets._nest_soi_state_rows_in_newer_national_controls,
  in the compile after rows 1 and 2 and before the state AGI bands, on
  target_nesting.national_share_surface. A state is a control level too, so
  each state is a leg of its own and the country covers them all. A state
  row lands at the control's period (uprating_to_period) and ages from
  there with its control. The compile refuses a pair with two controls or
  two own totals, with state rows of two periods, with a row that another
  rule rebased, or whose rows do not bind one quantity under the declared
  publisher concept (ledger_source_concept).
- What follows a state row: the state AGI bands (the band rule reads the
  period that a rebased total is at), the district rows and the county rows
  (the county pass pairs by the tax year of the state row's own data). A
  district-file row of a paired measure takes the same factor in the
  compile, so its relation to its state row, and the factors and the bound
  of the district bridge, stay as they were.
- A reconciled state row carries the operator's keys; its
  cross_grain_parent is the national control.
- The US compile now imports the operator, its row-level pass, the US
  declaration reader and the US adapter. The implementation hash of the
  gate battery covers every module that its bindings reach by an import
  statement, and that closure holds the US compile, so it grows by these
  four modules (243 to 247). test_transport_evidence_kernels.py lists them.
  The gate battery computes again on the next UK run, as it does after any
  edit of the US compile; its outputs do not change.

The concept check of the 14 pairs, on pinned data: the two rows of each pair
carry one publisher concept and one return universe, and in tax year 2022
the Historic Table 2 US row is 0.974 to 1.009 of the other table's row
(twelve from the feed; the two Table 1.2 pairs from the IRS file as
Chronicle pins it at 13294b93).

On the pinned feed: 714 state rows take a factor of 0.986 to 1.156 on the
published values (an amount moves by 0.978 to 1.122 at the build year); 15
national rows stop binding (14 Historic Table 2 US rows and the state_2022
copy of the US return count); the compile goes from 28,116 to 28,101
targets and national_state from 6,316 to 6,301; the local surfaces keep
their counts and move in value. The pins are measured again. The US F0 pin
tools ran and moved no pin.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
- docs/us-target-nesting.md: a section on the national-to-state pass (the
  rule, where it runs, what follows a state row, the keys, the guard, and
  the table of the 14 pairs with their factors and concept checks); what
  the joint surface needs before it can be built; what the gate battery's
  implementation hash covers since decision 2.
- docs/us-target-nesting-rule-design.md: the status of 1 Dec 2026, with the
  two choices of the build that are open to a ruling.
- docs/us-target-sets.md: the counts and registry versions after the pass.
- docs/us-chronicle-feed-repin.md, docs/us-acs-local-soi-target-surface.md:
  one paragraph each.
- changelog.d: an entry for the pass.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
@juaristi22 juaristi22 changed the title Nest the US target rows on the shared cross-grain operator, and re-pin the US feed (#1760: Stage A and steps 1 to 3) Nest the US target rows on the shared cross-grain operator, and re-pin the US feed (#1760: Stage A, steps 1 to 3 and decision 2) Dec 1, 2026
juaristi22 and others added 3 commits December 1, 2026 16:23
A second adversarial review read the branch at 30b22ee. These are its
items on the national-to-state pass of decision 2. No pinned value moves.

- A state that one pair lacks no longer stops the compile. The pass ran all
  pairs in one operator call, where the country covered the states of every
  pair, so a pair with a state less was refused as an empty leg. Each pair
  is now a pass of its own (target_nesting.national_share_surface).
- A district-file row of a paired measure takes the factor only when it is
  of the state rows' tax year and binds their quantity; the compile refuses
  it otherwise. A follower is matched by its measure id, as the district
  bridge matches it, and the declaration says so.
- The pass no longer skips in silence where a conflict would stay. With the
  newer row beside state rows, it refuses when the US total of the state
  rows' own file is missing or of another tax year. With the newer row, the
  US total and no state row, the US total stops binding.
- The pass records what it did where a stage keeps the nesting receipts
  (target_nesting.record_pass_receipt): the factor of each pair, the district
  rows that followed, the rows that stopped binding and the pairs it left,
  with the reason.
- The guards are as strict as the page says: each row of a pair must carry
  the declared publisher concept (a row with none is refused), the control
  and the US total must be of one sign and not zero, and a derivation that
  cannot run names its quantity.
- Two behaviours had tests on the pinned feed only, which CI does not have.
  They now have tests on small inputs: the pass in the whole compile, with a
  state band and aging (it fails when the pass is removed or runs after the
  bands), and a county block under a state row that took a newer national
  level.

The pages: the target-sets page gave the state-row counts of the old pin
(4,431, 5,860 and 4,635 state rows and 441 country rows now); the county
bridge medians are 1.1246 and 1.0059 since decision 2; the list of
pinned-input test files has nine files; the joint surface is a follow-up
PR (ruled 1 Dec 2026).

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
main has the renewal of the UK register expiries (microcosm#1834). Without
it the engine-free job stops at the UK adjudication notice test on every
branch from 1 Dec 2026.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
…1760)

The feed re-pin to Chronicle 13294b93 brought in the 102 Historic Table 2
state rows of the charitable deduction (tax year 2022). The only national
row of that quantity is Publication 1304 Table 2.1, for tax year 2023, and
both bind one model column. At the build year 2024 the 51 states sum to
1.069 of the national row for the amount and to 1.028 for the returns, so
no weight vector meets them together. The national-to-state pass cannot
give the state rows the national level: the feed holds no Historic Table 2
US row for this quantity, and the pass needs it for the shares. A second
review of the branch found this (1 Dec 2026).

Ruled on 1 Dec 2026: the repair goes in the follow-up of microcosm#1760
that makes the levels consistent, and the rows are held out until then.

- us/cross_grain_declarations.json: a known gap can hold its rows out of
  the national solve (held_out_of_national_solve: a level, a record set
  family, measures). One gap does, for the charitable rows. A second gap
  records the SALT and real estate taxes deductions, which bind two
  national rows of two tax years as on main; every row of it binds.
- us_runtime.fiscal_targets.us_target_is_held_out_known_gap is the test,
  and spec/target_sets.yaml excludes by it in national_state, beside the
  district classifier (predicate held_out_known_gap).
- The national tool passes the predicate. Its selection receipt counts the
  held-out rows apart (held_out_known_gap_targets, only when there are
  any); dropped_congressional_district_targets counts district rows only,
  as before.

On the pinned feed national_state goes from 6,301 to 6,199 targets. The
compiled registry, the full mode and every local surface are unchanged:
the state rows stay the parents of the district rows there, and no
national row binds on a local surface. The US F0 pins move with the
target-set file (one authored field more).

The 8 Table 1.4 rows of partnership and S corporation net income and net
loss, which the re-pin also brought in, are not held out. They sum to less
than the Historic Table 2 combined row, and that is no conflict: a row
binds the positive part of its variable on each return, so the four parts
do not fix the combined quantity, and the combined target is inside the
range that they allow. The page says so.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>

@vahid-ahmadi vahid-ahmadi left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Light pass, focused on the target changes, since an adversarial review and your rulings already cover the operator. Two requests and one view on the open decision.

1. Reconcile the compile change. full goes from 31,748 to 28,116 targets (−3,632). The description lists:

  • +204 Historic Table 2 state rows, +2 national QBI rows and +8 Table 1.4 rows;
  • 6,104 district rows deferred;
  • 102 charitable rows held out of national mode.

Those don't add up to −3,632 on their own: 31,748 + 214 − 6,104 is 25,858, so about 2,250 rows are explained elsewhere. That's presumably the district file's changes (the state and US rows removed, the at-large areas, the 2022 tax year) and Row 4 retiring. A short table of the net change by source and reason, in docs/us-chronicle-feed-repin.md, would let a reviewer confirm that nothing dropped out by accident. "Target values change" PRs are where that matters most.

2. Check the effect on the build before merging. Since target values change, it's worth comparing the next national build's fit on the unchanged targets with the current build's. A big shift there would point to a nesting or rebase side effect rather than the new feed.

On the open decision: what mortgage_interest_paid_* binds. IRS A19300/N19300 is mortgage interest paid to financial institutions, before any limits. deductible_mortgage_interest is the amount after the TCJA acquisition-debt limit and the itemising choice, so it would sit below the target by construction. If policyengine-us has a pre-limit paid-interest input, binding to that matches the IRS concept better. If not, keeping these rows deferred, as you have, is safer than binding to the deductible amount.

The rest looks consistent with the rulings on #1760:

  • every district row now nests in its Historic Table 2 state row on both modes;
  • DC's seat 98 is mapped to 00;
  • the SSA workbook replaces the state SSI file whose state rows summed to more than its US row;
  • the 12 new district families are deferred to #1731.

Review drafted with AI assistance and checked against the code at f50fedd250702a9f98fd44afa55c46abf29c726f.

A review of the pull request asked how the release compile goes from 31,748
to 28,116 targets, because the listed changes do not add up to the
difference by themselves.

docs/us-chronicle-feed-repin.md now has the account, measured on two
compiled registries at the build year 2024 (the code before the re-pin on
the old feed, and this branch on the new feed):

- the release compile by source and level: the district file's own state
  rows (-2,601) and US rows (-49), the two interest paid deduction measures
  of the district file (-872), the Historic Table 2 state rows that stood in
  for a district in nine areas (-324), and the new rows (+204, +2, +8);
- why the 6,104 deferred district rows are not a removal of 6,104 rows:
  5,232 of them are of twelve measures that the old feed did not hold;
- the production national mode by id: 4,830 of its 6,102 old targets keep
  their value, 1,257 move (with the cause of each group), 112 are new and
  15 are gone.

The design page records the ruling of 1 Dec 2026 that the two build choices
of decision 2 stand.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>

@anth-volk anth-volk left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Three minor fixes from a read of d6ce5d6c1, each with a suggested change. Two larger findings follow in a separate review.

Drafted with AI assistance (Claude) and checked against d6ce5d6c1.

kept_ids = {id(spec) for spec in kept}
dropped = [spec for spec in specs if id(spec) not in kept_ids]
districts = sum(1 for spec in dropped if _target_is_congressional_district(spec))
held_out = len(dropped) - districts

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Recommended fix (minor). held_out counts every dropped row that is not a district row, so held_out_known_gap_targets would also count rows that any exclusion added to national_state later drops. Counting with the predicate itself, and refusing a dropped row that neither exclusion names, keeps the receipt exact:

Suggested change
held_out = len(dropped) - districts
held_out = sum(1 for spec in dropped if us_target_is_held_out_known_gap(spec))
if districts + held_out != len(dropped):
raise ValueError(
f"Target surface {mode!r} dropped {len(dropped) - districts - held_out} "
"target(s) that neither of its exclusions names."
)

Comment on lines +211 to +213
# The shared cross-grain operator divides each state's total among its
# counties (microcosm#1760); the rounding residual goes to the largest
# county, never a small one.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Recommended fix (minor). Since step 3 there is no step that gives a rounding remainder to the largest county: county_population_rows gives each county its overlap population times the state total over the state's summed overlap populations (the operator's row x control / sum of rows). The comment still describes the allocator that step 3 removed:

Suggested change
# The shared cross-grain operator divides each state's total among its
# counties (microcosm#1760); the rounding residual goes to the largest
# county, never a small one.
# The shared cross-grain operator divides each state's total among its
# counties (microcosm#1760): each county takes its overlap population
# times the state total over the sum of its state's overlap populations.

#: Puerto Rico (state 72) is outside the County Files. The county facts loader
#: drops its municipios with a count; a row that still reaches this module is
#: a defect, never a county to fit.
PUERTO_RICO_STATE = 72
PUERTO_RICO_STATE = _target_nesting().PUERTO_RICO_STATE

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Recommended fix (minor). COUNTY_PREFIX now has two definitions: target_nesting.COUNTY_PREFIX and the literal at line 60 of this module, which this module no longer uses itself. test_us_target_nesting_county.py checks that they agree, but docs/agent-guide.md asks for shared static data to be imported rather than copied. Taking it from target_nesting, as PUERTO_RICO_STATE on this line does, keeps the module's public name for that test, and the literal at line 60 can then go:

Suggested change
PUERTO_RICO_STATE = _target_nesting().PUERTO_RICO_STATE
PUERTO_RICO_STATE = _target_nesting().PUERTO_RICO_STATE
#: The GEOID prefix of a county-equivalent in the ledger feeds.
COUNTY_PREFIX = _target_nesting().COUNTY_PREFIX

@anth-volk anth-volk left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Requesting changes for the two findings in the inline comments. Neither moves a value on the pinned feed, but each is a case the code expects (a docstring in one, an explicit branch in the other) and handles only in part, and neither shape has a test. Both come from how the compile passes are put together, so I'd rather fix them in the structure than patch each branch. Below is one possible implementation; another design that removes the same failure modes is fine.

Why these happened

The compile runs a series of passes over the target list in memory: taxable interest, capital gains, the new national-to-state pass, the AGI bands, the profile. Each pass builds its own grouping key from a family label parsed out of the record set id, and records what it did in metadata strings (uprating_factor, uprating_to_period, cross_grain_parent, soi_share_total_source_record_id) that later passes and readers interpret. This PR adds a pass and gives two of those strings new readers: the AGI-band controls now read uprating_to_period, and a state row's cross_grain_parent now names a national row.

  • The first finding is a grouping error. The label congressional_district merges district files of different boundary vintages. That was safe while the denominator was one published row per file, with a check that the files agree; a sum over the label is not.
  • The second is a branching error. The national-to-state pass has several outcomes for each pair (skipped, recorded as left as it is, refused, retired without scaling, scaled), and the scaling of district-file rows is attached to only one of them.

A possible implementation

1. Key facts on their source file. Parse each fact once, when the feed loads, into typed keys, and group on them in every pass:

@dataclass(frozen=True)
class SourceFile:
    publisher: str                 # "irs_soi"
    table: str                     # "congressional_district", "historic_table_2", "table_1_4", ...
    tax_year: int
    boundary_vintage: str | None   # "117th_congress" for a district file
    universe: str                  # "all_returns", ...


@dataclass(frozen=True)
class Quantity:
    variable: str
    measure_mode: str
    filters: tuple[tuple[str, str], ...]   # filing status, AGI class, itemizer, ...

Where two files are meant to be read as one, a declaration says so; no parser merges them.

2. Give a denominator a type. It is either a published row or a sum built under checked conditions:

@dataclass(frozen=True)
class PublishedTotal:
    fact_id: str
    value: float


@dataclass(frozen=True)
class SumOfRows:
    source: SourceFile             # exactly one file
    members: tuple[str, ...]       # fact ids, checked complete against the file's district plan
    value: float


def total_for(source: SourceFile, quantity: Quantity) -> PublishedTotal | SumOfRows:
    """Exactly one total for a file and a quantity, or an error."""

SumOfRows cannot span two files and total_for cannot return two totals, which removes the first finding. soi_share_total_source_record_id can still name the sum's record set and member count, as it does now.

3. Record a target's adjustments as typed data. Keep them on the target, and write today's metadata keys from them only when the registry is saved, so the output bytes need not change:

@dataclass(frozen=True)
class Rescale:
    rule: str                      # "national_soi_pairs", "capital_gains_shares", ...
    factor: float
    control: str                   # the control row's id
    denominator: PublishedTotal | SumOfRows
    to_period: str


@dataclass(frozen=True)
class Target:
    key: tuple[SourceFile, Quantity, str]   # file, quantity, geography
    source_value: float
    adjustments: tuple[Rescale, ...]

    @property
    def value(self) -> float: ...           # source value x every factor

    @property
    def period(self) -> str: ...            # the last adjustment's to_period, else the source year

The AGI-band controls would read target.period instead of uprating_to_period, and "a row takes one control" becomes one check over adjustments instead of a check in each pass.

4. Plan, then apply. Each rule returns a list of operations, and one function applies every list:

Op = ScaleRows | StopBinding | Refuse


def national_soi_pairs(groups: QuantityGroups, pairs: Sequence[NationalSoiPair]) -> list[Op]:
    ops: list[Op] = []
    for pair in pairs:
        group = groups.of(pair)  # the control, the own-file total, state rows, district-file rows
        match group.shape:
            case Shape.NO_CONTROL:
                continue
            case Shape.NO_OWN_TOTAL:
                ops.append(Refuse(pair, "the state rows have no US total of their own file"))
            case Shape.CONTROL_AND_TOTAL:
                factor = group.control.value / group.own_total.value
                ops.append(StopBinding(group.own_total))
                ops.append(ScaleRows(group.rows_below_control, factor, rule="national_soi_pairs"))
    return ops

rows_below_control holds the state rows and the district-file rows of the quantity together, so no branch can scale one and skip the other, which removes the second finding. A match over a small enumeration lets a type checker report a shape that has no case.

5. Check invariants after each pass, with one shared checker:

  • a target's value equals its source value times its factors;
  • each declared parent and its children add up within the declared tolerance;
  • no two binding targets measure one Quantity at one geography.

The last check finds the #1243 kind of conflict without a review, including the SALT, real estate taxes and charitable cases this PR declares as known gaps. Those would become exceptions in the declarations, each with its issue and an expiry date.

6. Test the shapes the code says it handles. Generate small feeds (Hypothesis) with two district files in one tax year, a US total with no state rows, a missing district, and district-file rows present or absent, and use the invariants above as the expected results. A tool that compares two compiled registries value by value and groups the differences by source file (the table in docs/us-chronicle-feed-repin.md) could then run on every re-pin.

Scope

Steps 1, 2 and 4 are enough for the two findings and could land in this PR, with the compiled registry on the pinned feed byte-identical before and after (compare the two registries). Steps 3, 5 and 6 could go in the follow-up of #1760 with the joint surface: with the national control, the state rows and the district rows in one declared hierarchy and one operator call, district-file rows are children of their state rows and need no separate follower step.

Drafted with AI assistance (Claude) and checked against d6ce5d6c1.

return totals


def _soi_capital_gains_district_sums(

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Double counting when the feed holds more than one district file for a tax year. _soi_capital_gains_district_sums keys its sums by (family, measure, filing status, universe, tax year). The family label congressional_district covers every district record set of that tax year: the docstring of _soi_capital_gains_share_national_totals above says district packages of different boundary vintages share it. Before this PR each package's own US row was the denominator, and two packages whose US rows disagreed were refused. Here the district rows of every package are added into one sum, and record_sets.setdefault names only the first record set.

With two packages for TY2022, the denominator is about twice the US total and every district capital-gains share comes out at about half its value, with no error. The pinned feed has one package, so nothing moves today. The review body has a structural fix.

retired.add(own[0])
for family in pair.retire_also:
retired.update(totals.get(("country", family, pair.lower_measure), []))
if not states:

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

District rows of a paired measure keep their old level in this branch. When a pair has its newer national row and the Historic Table 2 US total but no Historic Table 2 state rows, this branch stops the US total from binding and continues. The follower loop (the district-file rows of the paired measure, line 1965) runs only for the pairs in plans, so those district rows are not given the factor here, although it is known (control_spec.value / own_spec.value).

On the national tool's full mode they would then bind at the TY2022 level under the TY2023 national row, which is the conflict the follower rule was added to remove (the taxable IRA distributions example in the PR description, 1.0056). All 14 pairs have state rows on the pinned feed, so nothing moves today. The review body has a structural fix.

This branch has not been deployed

No deployments
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.

3 participants