Repository navigation
Nest the US target rows on the shared cross-grain operator (#1760: Stage A and steps 1 and 2, no target change) - #1791
Draft
juaristi22 wants to merge 25 commits into
Draft
juaristi22 wants to merge 25 commits into
juaristi22 wants to merge 25 commits into
Conversation
…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>
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>
…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>
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Part of #1760. Draft. No target value changes in what is here now.
Where this stands
docs/us-target-nesting-rule-design.md: the rule, nine decisions (accepted 27 Nov 2026), and one general model to declare them13294b93). The feed re-pin comes firstThe first ruling is in this comment on #1760. The page for the code is
docs/us-target-nesting.md.What this does
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.
No target value changes. On the pinned feed and ladder, each of the 26,272 rows of the
state_cdSOI surface has the bits of the value it had. The other three surfaces (full,state,totals) have the bytes they had.The parts
microcosm/build/cross_grain.pyreconcile_rows: the operator on target rows, with an answer for each row), and the allocators. No country in itmicrocosm/build/cross_grain_controls.pyus/cross_grain_declarations.jsonus_runtime/cross_grain_declarations.pyus_runtime/target_nesting.pytools/us_acs_local_cd_surface.py,tools/us_acs_local_county_surface.pytarget_nesting.jsontools/build_us_acs_local_release.pyWhat step 2 changes (by design)
On valid data the rows and their values are the same. These things differ.
Metadata keys. District and county rows carry the operator's keys, as UK rows do.
cross_grain_parentstate_cd_parent_target_name,state_county_parent_target_namecross_grain_value_beforestate_cd_cd_file_value,state_county_source_valuecross_grain_factorstate_cd_rebase_factor,state_cd_level_bridge_factorcross_grain_controlstate_cd_parent_basis,state_cd_level_bridge_siblingcross_grain_membersstate_county_cell_membersSix old keys have no new one, because another place holds the value (the parent row, the operator's receipt, the declaration).
Receipts. The district receipt names the bridge and its bound under
bridge, with the legs it unbound;level_bridge_out_of_bandandfactor_by_measurereplacefactor_bandandrebase_factor_by_measure.internal_consistencyis gone. County blocks loseshare_sum.So three pins of
state_cdmoved (the registry, the roles and the receipts), and were measured again. The target count and the population matrix are the same.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.
One check is gone: that the district file's own state row is the sum of its district rows within
1e-6. Row 4 of the compile scales the district rows to that state row before this pass runs, so the sum holds by construction. On the pinned feed 22,236 district-file district rows carry row 4's marker. The 436 that do not are the one measure with no state parent, which is never bound.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. The old code accepted that. It does not occur on the pinned feed.
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.
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.What item 5 leaves open: for the six concepts that only the district file has, the district file's state row is the control (2,562 district rows on the pinned feed). This pass does not check that row 4 ran. After the feed re-pin those concepts take a Historic Table 2 parent, and the bound of the bridge guards them.
Since Stage A, three inputs that the oldest code computed are refused by the operator (rows that sum to less than
1e-9of 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 materializeagain.What stays until the feed re-pin
Declared under
until_the_feed_repin:row x control / numpy sum. The US rows were made withmath.fsum, and the county rows with a residual rule. On the pinned feed the numpy sum changes the last bit of 5,533 of 21,743 district values. At the re-pin the allocators go, and those values move in the last bits.Also not built yet, because no rule in force uses them: the derived control of the kind
scaled(decision 2), and one pass on one joint surface (the four passes call one function, each on its own surface).Commits
288b2e3caPins on the code as it is (the pin test of #1755, cherry-picked)mainas it ise3e483dbdThe allocator hooke29843dc7(pinned by sha256): same value bytes, receipts and refusal textsbc8aa6ae1cross_grain_controlsd1f62f9ddThe US declaration, its reader and the adapter base6da6e3b12District SOI shares on the operator (row 5)55fa55c36County population, county SOI shares, county households on the operator (rows 8, 6, 7)c3dc13b4cThe inventory, the docs page, the coverage test3aac702e3Merge ofmain(5589fae09), with the US F0 pins written again--checkpasses350cd9de2,17ee67085,035881105The rule, the rulings, one general model (docs only)947978c46The bound, the members and the bridge selector, general in the operator938c7faa6Annotations that the spine-blindness check needsd91ae5b37The operator refuses a declared leg with no row, and holds the keys of a reconciled row2264fb377The US on the model011651554The pages and the changelog625c93702The ten rulings of 27 Nov on the steps, in the design page6e76eaee6The county rows on the pinned county facts: held to the old code, and pinnedfa297a018The county SOI bridge declares the bound of the district bridgef1c17c5e1A leg holds each declared member one time; the row-level pass refuses two shapes; two more bit-for-bit tests of the operatorbb6776f87A lost district refusal is back; the declaration and the coverage check are tighterff0b9fa15A later stage refuses targets and district receipts of older code672e82936The pagesa8b9d2c52Merge ofmain(be6a1983d), with the US F0 pins written again--checkpasses. The tests ran on the merged tree on 28 Nov (see "Tests run here")ca5e864bcThe property test of the district shares draws no block that the operator refuses, and the refusal has one more fixed caseThe county rows on the real inputs
The pinned county facts file (922 MB, sha256
67b0998a…) is now a test input on the build machine. Two tests intest_us_target_nesting_county.pyread the pinned feed, the PUMA ladder and that file, whenMICROCOSM_US_CHRONICLE_FACTS,MICROCOSM_US_PUMA_LADDER_ARTIFACTandMICROCOSM_US_CHRONICLE_COUNTY_FACTSname them. They skip in CI.The bytes of those rows and receipts are pinned.
The county SOI bridge now declares the bound of the district bridge (1.25 around the median factor across states, unbind; ruled 27 Nov 2026). The code before had no bound. Its factors on those inputs:
adjusted_gross_incomereturn_countNo leg is outside the bound, so it unbinds nothing and no county value changes. A state that is outside it loses its county rows of that measure, the receipt names it under
bridge.unbound, and its state row stays.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.What held. UK outputs are the same: it made each operator call of the UK tests also run the old copy of the operator (129 calls through real UK rules, 30 partition calls), with no difference in values, receipts or refusal texts. No US value changes on the pinned inputs. The copy of the old US code is text-identical to the tools on
main. Loss-weight groups and hold-out roles are the same on the pinned surface.What it found, and what the commits after it do:
--stage materializeagainPins
--checkpass.state_cdbytes intest_us_acs_local_surface_bytes.py: three hashes moved, by design (see above).test_us_target_nesting_district.py::test_the_pinned_feed_surface_is_the_old_surfaceholds each row to the old value bits, parent, factor and value before, and the receipt's counts, drops and summaries.The UK
cross_grain.py. So the UK target nodes, and every node after them, compute again on the next UK run. The outputs are the same: the differential test compares the operator with the file before any edit on 400 seeded surfaces, and it pins the list of definitions that this branch changed or added.uk/oruk_runtime/changes, and no UK test changes.cross_grain_controls.Merges
main: merged at5589fae09(commit3aac702e3), and again atbe6a1983d(commita8b9d2c52, 114 commits later). The second time, the same two generated pin files conflicted.maintouches none of the nesting files.us/local_target_construction.json(state_cd_parent_target_name,state_county_parent_target_name), and its pin test holds thestate_cdregistry bytes. The PR that merges second takes the other's change: the declaration readscross_grain_parent, and the threestate_cdhashes are the ones here. It also runs the pin tools again.Tests run here
Environment: Python 3.13, no country engine (as CI's engine-free job). The pinned feed and the PUMA ladder were set for the feed-gated tests.
These ran on 28 Nov on the tree of
ca5e864bc, which is the second merge ofmainand one test correction. The three pinned inputs were set, so no feed-gated test skipped:test_cross_grain.py, the three bit-for-bit tests of the operator, the model tests, the row-level pass, the CI test plantest_us_spine_blindness.py,test_us_spec_engine_repin.py, the declaration and coverage tests, both equivalence files, the pinned bytes, the county facts pin, the loss weightstest_us_acs_local_*.pyCI=true)ruff check .,tools/ci_test_plan.py verify, both pin tools with--checkNo pinned byte moved with the second merge of
main: the pinned bytes, the pinned district and county comparisons and the pinned coverage pass on the merged tree.Step 2's larger sweep (transport kernels,
test_country_spec.py, the exact-K ladder, the scorer) passed on the tree of step 2 and did not run again.Old against new on random inputs, counted outside the tests:
CI
On
a8b9d2c52, nine jobs passed: bothengine-uk, bothengine-us,integration-uk,lint,wheels,installed-emitterandselect-countries. The twoengine-freejobs failed on one test,test_district_targets_add_up_to_one_state_vintage.1e-9of its control. That is one of the three refusals listed above, so the code did what it declares. The test's value range was too wide for it.ca5e864bcnarrows the range to eight orders of magnitude, and adds the drawn case to the refusal test.ca5e864bcall twelve checks pass (read on 28 Nov 2026). It is the first run on this branch in which the twoengine-freejobs completed: they stop at the first failure, and each earlier run failed or was cancelled by a push.Not verified
state_countysurface. 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.ca5e864bc(see "CI").Rulings and what is open
Ten calls on the steps were ruled on 27 Nov 2026. They are in section 4 of the design page, and in this comment on #1760 with the nine decisions. In short: no allocator after the re-pin; a concept takes its state parent from one source; this PR does not merge while a UK release is between its first build and its sign-off; #1755 merges first; decisions 4 and 7 go in their own PRs.
An eleventh call, from the measured county factors: the county SOI bridge declares the band of the district bridge. The eleven findings of the adversarial review are fixed on a later go ("Fix all"), with the guard for older checkpoints.
No call is open.
🤖 Generated with Claude Code