Repository navigation
Declare target sets and target registers as data, with shared code for the US and the UK (no target change) - #1755
juaristi22 wants to merge 35 commits into
Conversation
microcosm.calibrate.target_sets reads one country's declarations of what each product calibrates to. For each product and mode, a declaration has compiled clauses (families, levels, metadata tests, named exclusions, a named rule) and the rows the tool builds itself, each with a rationale. select_target_set keeps each clause's specs in compile order, clause by clause in declaration order. The module holds no country code: a country passes its named predicates and rules. A target's family and level are the labels the shared target-loss rule reads (microcosm#1729). Part of microcosm#1728. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
us/target_sets.json declares the national tool's --target-surface modes and the ACS local tool's --soi-mode modes. _select_target_surface, state_admin_surface and soi_surface_predicate now select by it. us/country_package.json lists the new resource. On the pinned 41b2fb2 feed every surface keeps the same targets in the same order (count and TargetRegistry version, measured on main 0f963ac): national full 31,748 and national_state 6,102; local state 4,380 (4,867 with the ladder's 487 population rows), totals 255, full 29,977, state_cd 26,425 and state_county 4,380. test_us_target_sets.py pins them, and checks that every compiled target's level is the one target_geography_level gives. docs/us-target-sets.md explains the declarations. docs/us-fact-to-target.md now says that the national and the local product calibrate to different subsets of the one compiled registry. Part of microcosm#1728. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The US runtime module classification (test_us_spine_blindness) now lists `us_runtime/target_sets.py` as a reviewed non-registry module. It names and loads the declared target sets, selects target specs only, and reads no frame. Registering `us/target_sets.json` as a `legacy_json` row in `country_package.json` adds the row's three normative fields: 42407 configuration fields (32621 authored), the `country_manifest` claim at 116 pointers, and a new pointer inventory digest. The row also moves the US bundle's semantic `spec_sha256` to f130419c, which pool builds record in their run config's spec binding. No target changes. Run on the merge of main 268156c, in an environment without country engines: `tools/repin_us_spec_engine_contracts.py --legacy-only` (no change), then without it, then `tools/spec_engine_coverage.py`. Both tools' `--check` modes pass, and coverage reads 42407/42407 fields and 41/41 inventory checks. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…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>
C1 of the shared-code work in microcosm#1728. No target changes. - The ledger filter rules move verbatim from tools/build_us_fiscal_refresh_release.py to microcosm.build.us_runtime.ledger_filter_rules: 25 names, 446 lines. They say how the national irs_soi slice reads a spec's AGI band, filing status and EITC child count, and which restated ledger_filter_* keys a spec may carry. Each definition is byte-identical. The tool imports all 25 names back (its materializer and filter guard call them, and tests and tools/bakeoff_us_support_mix.py read them there). It drops the two FSA balance-bound imports that only the moved code used, and keeps the two age-stamp keys, which a test reads through the tool. - tools/us_acs_local_cd_surface.py reads the rules from the package, so it no longer imports the national tool. - tools/build_us_acs_local_release.py compiles the registry in one function: _compiled_fiscal_registry takes the district crosswalk that state_admin_surface also gives the state_cd rule. - test_us_spine_blindness.py classifies the new module. - Two tests in test_us_fiscal_refresh_builder.py changed a rule on a freshly loaded tool and relied on that copy being thrown away. The rules now live in one package module that every load shares, so both use monkeypatch: one removes the age rule for its own run only, and one empties the refused EITC child-count sides where the comparison reads them. Proof: test_us_acs_local_surface_bytes.py (the C0 pins) passes unchanged on the pinned feed and ladder for state, totals, full and state_cd, and the pinned surfaces of test_us_target_sets.py pass. In all, 3,714 tests in the 47 files that load the changed tools or hold the module and binding registers pass locally (8 skipped), with the pinned feed and ladder set. Left for later commits, as planned: the import cycle between the district and county modules goes when C3 moves the population rows, and the county code's use of the argparse namespace moves with the county rung (C5), because #1719 changes check_support. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The US bundle generator writes country_package.json from LEGACY_RESOURCE_PATHS. The target_sets.json row was in the committed manifest but not in the generator, so the engine-tier check test_generator_reproduces_every_checked_in_bundle_byte failed on 3316038. The generated manifest now equals the committed one (checked without a country engine), and both re-pin tools' --check modes pass. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
C2 of the shared-code work in microcosm#1728. No target, role or receipt changes. - microcosm.build.target_holdouts (new, country-free) draws held-out targets by hashed blocks from declared passes: scope and eligibility tests on the record, unit fields joined with '|', a concept-family rule, the salt, the default and largest fraction, and the receipt keys in order. It also builds the training target set, and scores the held rows against a pro-rata baseline (the parent target times the child's population share), with the populations attached from declared fields. - us/local_target_construction.json (new) declares the US district and county passes, their concept-family rule and their scoring, with the values the tools held. microcosm.build.us_runtime.local_target_construction reads it. - tools/us_acs_local_cd_surface.py, tools/us_acs_local_county_surface.py and tools/build_us_acs_local_release.py keep their function names and call the shared code. - The new resource row: country_package.json, the bundle generator's LEGACY_RESOURCE_PATHS, the US F0 re-pin (42,410 configuration fields, country_manifest at 119 pointers; the US bundle spec_sha256 moves to c25fbed9), and the module classification. Proof: - test_us_acs_local_surface_bytes.py (C0) passes unchanged on the pinned feed and ladder: the roles, units, populations and hold-out receipts are byte-identical. - test_us_target_holdouts.py (91 tests) holds the tool functions to verbatim copies of the replaced code (test_support/microcosm_build/us_target_holdouts_reference.py) on random records: roles, receipts, populations, training sets and scores, with key order. - test_target_holdouts.py (30 tests) tests the shared module on a made-up country. - 4,044 tests in the 51 files that load the changed tools or hold the registers pass locally (8 skipped), with the pinned feed and ladder set. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
C3 of the shared-code work in microcosm#1728. No target changes. - microcosm.build.ladder_population_targets (new, country-free) makes, for each declared geography level, the population rows (household size times the cell indicator; a household of size zero supports its cell but adds nothing), the cells that no household supports, and the target specs with their calibration hierarchy. Names, record code fields, geography ids, labels, sources and families are declared; a country passes a label lookup for each label kind. - us/local_target_construction.json gains the ladder_population section: the state and district levels with the values the tools held. microcosm.build.us_runtime.local_target_construction reads it and gives the label lookups (Census state names, and congressional_district_label). - tools/us_acs_local_cd_surface.py (population_rows, population_target_name) and tools/build_us_acs_local_release.py (population_targets, population_target_specs) keep their names and call the shared code. The county population rows and specs stay with the county rung (C5). - The district module no longer imports the county module: the local tool's population_targets picks the county rung's rows for a county run, and the district rows refuse a county level. No spec-engine pin moves: the pins read the resource row, not its content. Proof: - test_us_acs_local_surface_bytes.py (C0) and the pinned surfaces of test_us_target_sets.py pass unchanged on the pinned feed and ladder. - test_us_ladder_population.py (54 tests) holds the tool functions to verbatim copies of the replaced code (test_support/microcosm_build/us_ladder_population_reference.py) on random households and ladders: records, matrix rows, dropped cells and specs. - test_ladder_population_targets.py (13 tests) tests the shared module on a made-up country. - 4,111 tests in the 53 files that load the changed tools or hold the registers ran locally with the pinned feed and ladder. All passed (8 skipped) except one C2 test that checks the file's top-level keys; this commit adds the new section to it, and that file passes. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
C6 of the shared-code work in microcosm#1728, with the docs. No target changes. - microcosm.build.declared_registers (new, country-free) reads a reviewed register from a package JSON file: a description, the key fields (one, or a tuple), the value fields (one, a tuple, or none for a set) and the entries in order, each with an optional note. JSON arrays read back as tuples, so a register reads back as the Python literal it replaces. - us/fiscal_target_registers.json (new) holds 13 registers of the US fiscal target compile, generated from the live objects: the fact exclusions with their reasons and vintage scope, the misread source columns, the restamped source packages, the SOI variable maps, the direct and indicator Ledger targets, and the M-CHIP states. The comments that stood beside them in the code are their descriptions and the notes of their entries. microcosm.build.us_runtime.fiscal_target_registers names the file. - us_runtime/fiscal_targets.py and us_runtime/source_vintage.py keep every name and read the registers from the file (about 890 lines of literals go). - The new resource row: country_package.json, the bundle generator's LEGACY_RESOURCE_PATHS, the US F0 re-pin (42,413 configuration fields), the module classification, and the two modules the transport bindings now reach (BINDING_MODULES_ADDED_AFTER_BASE). - docs/us-target-sets.md describes the declared construction (us/local_target_construction.json) and the compile registers, and how to change them. Proof, measured on 904a46d before the move and pinned in test_us_fiscal_target_registers.py: - each register's digest (keys, values, Python types and entry order); - the pinned-feed compile under four flag sets (with and without aging, with and without the student-loan targets): count, TargetRegistry.version and the sha256 of the full registry JSON; - the exclusion receipt. test_declared_registers.py tests the shared reader on made-up registers. 5,599 tests in the 94 files that load the changed tools or the compile, or hold the registers, ran locally with the pinned feed and ladder. All passed (46 skipped) except one case of the new register test: it read the module's dict after another test had reordered it (monkeypatch.delitem restores a key at the end). The test now reads each fiscal_targets register fresh from the file and checks the module's content; it passes after those tests in one process. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> # Conflicts: # docs/evidence/spec-engine/us-f0-coverage.json # packages/microcosm-build/tests/engine_workflow/us/test_us_multispine_pool_tool.py
Two generated pin files conflicted: the US F0 coverage evidence and the multispine pool tool's spec_sha256. Took main's side of both, then ran tools/repin_us_spec_engine_contracts.py --legacy-only, the full re-pin and tools/spec_engine_coverage.py (42,413 of 42,413 configuration fields); both --check modes pass. The pool tool's pin comment now names this PR's three declared US resources. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Commit C2 moved csr_row_measure from the district tool to the shared microcosm.build.target_holdouts. The calibration diagnostics name a callable measure <module>.<qualified name>, so each matrix-row measure is now microcosm.build.target_holdouts.target_matrix_row[N] instead of us_acs_local_cd_surface.target_matrix_row[N]. The targets and weights do not change, but target_surface.sha256 does. María accepted the new name on 26 Nov 2026 (microcosm#1759 plan, decision 1). The new test pins it, and the changelog says so for anyone who compares two releases. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
microcosm.calibrate.target_sets gains what the UK selection needs, as data: - A declaration can give a level_rule in place of level_keys: the metadata keys, a closed set of levels or "*", and whether two keys that disagree are refused. level_keys stays the short form of an open rule that takes the first key, so the US declarations read as before. - select_by_levels keeps the targets of a run-time set of levels (all by default) in compile order, for a mode with one clause for each level of a closed set. It returns them as a registry with the receipt schema microcosm.calibrate.target-selection.v1, and refuses a bad request, a requested level that no target has, and an empty selection, with the texts of microcosm.calibrate.target_selection. Nothing calls it yet (microcosm#1759, step D1). New shared tests cover the rule's forms and refusals and the selection and its receipt; the existing target-set tests pass unchanged. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The UK now declares its target sets the way the US does (microcosm#1759, step D2): - uk/target_sets.json (a new legacy_json row in uk/country_package.json) declares the UK level rule: a target's level is geography_level or ledger_geography_level, the two must agree, and it must be one of country, region, constituency, la and brma. It also declares the full build's product with one mode, "levels", that has one clause for each level. - uk_runtime/target_sets.py names the file and products. graph_targets.target_geography reads the declared rule, and uk.full.target_selection@1 calls the shared select_by_levels. - microcosm.calibrate.target_selection and its tests are removed: the UK kernel was the only caller. - The full-graph target kernels hash the shared and UK target-set modules in place of target_selection. The national kernels now hash them too: the national problem writes each row's level, and it now reads the level through the UK adapter, not through graph_targets, which those kernels never hashed. No selection changes. test_uk_level_selection.py compares the new code with verbatim copies of the removed selector and UK resolver (test_support/microcosm_build/target_selection_reference.py) on 400 random registries and requests: the same registry version, the same receipt bytes, or the same refusal type and text. The new resource is in the UK solve fingerprint, so the first UK build after this change computes the spine from frs_brma on, the target nodes and the national graph again. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The two UK calibration lines (microcosm#1301) become the modes of a calibration_line product in uk/target_sets.json (microcosm#1759, step D3): - Each mode has one clause that keeps every compiled national reference except the ones the predicate off_calibration_line names. - uk_runtime.ledger_targets.uk_registry_on_calibration_line selects through the declared mode with the shared select_target_set. It binds that predicate to the contract targets whose calibration_lines leave the line out. The membership stays with each target in uk/uk_population_targets.json. - UK_CALIBRATION_LINES is the product's declared modes. - The shared selector reads a target's level only when an active clause tests levels, so the closed UK level rule does not refuse rows that a line selection never places by level. The US declarations are open rules, so their results do not change. - ledger_targets now imports the shared and UK target-set modules, so both join UK_TARGET_COMPILE_MODULE_NAMES. No line changes. test_uk_calibration_line_selection.py holds the new function to a verbatim copy of the old one (test_support/microcosm_build/calibration_line_reference.py). It covers 150 random registries on each line and an unknown line: the same registry (the same object when nothing drops), the same receipt, or the same refusal. The existing line, CenTax and measurement-period tests pass unchanged. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…e US The UK rowwise hold-out and the US local hold-out keep their own draws: rotated folds over the UK's local target rows, and hashed blocks over US units. They now share the two steps after the draw (microcosm#1759, step D4): - microcosm.build.holdout.HoldoutSplit names a split's training rows and held rows. fold_splits makes one for each rotated fold, and target_holdouts.role_split makes one from the US roles. - microcosm.build.holdout.held_estimates gives the held rows' estimates from the target matrix and the solved weights, in float64. rotated_uk_local_holdout (with the size stage's record columns) and target_holdouts.score_holdout both call it. - The UK hold-out node (uk.full.rotated-holdout@1) now also hashes microcosm.build.holdout. It already ran rotated_folds from that module without hashing it. No result changes. test_holdout.py compares fold_splits with the old rotated_folds and setdiff1d code. It also compares held_estimates with the replaced UK and US expressions on random float64 and float32 data, byte for byte. The 91 US hold-out tests still match the verbatim copies of the old tool code, and the UK hold-out, candidate-scorer and graph tests pass unchanged. The UK fold constants stay in local_rowwise.py, as María ruled. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
microcosm.build.declared_registers gains what every signed register file needs, for any country (microcosm#1759, step D5): - read_strict_json reads JSON and refuses duplicate keys, non-finite numbers and malformed text, with the texts the UK reviewed-exclusion reader uses; - canonical_date reads a date only as YYYY-MM-DD (date.fromisoformat also accepts the compact and week-date forms); - ReviewWindow is an entry's window, approved_on to expires_on with both days in force, and gives its state on a date and the days left; - stale_entries gives the declared entries that name nothing found. They return values; the country's code keeps its error texts and decides what a lapse does. No code calls them yet. The new shared tests cover each function; the US register tests and spec-engine checks pass unchanged. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The UK compile-side loaders of signed entries now use the shared review core (microcosm#1759, step D6): - measure_simulation.load_uk_calibration_measure_exclusions reads each approval and expiry with canonical_date. - apply_uk_calibration_measure_exclusions checks each window and its seven-day warning with ReviewWindow, and finds stale entries with stale_entries. - support_floor.uk_support_floor_from_payload reads the floor's dates with canonical_date, and UKSupportFloor.assert_in_force uses ReviewWindow. Each function keeps its texts, its order and its policy. The full-graph target kernels and the national kernels now also hash declared_registers, which these modules import (test_uk_target_compile_modules found the new import). No change in results, warnings or refusals. test_uk_review_loaders.py holds the new code to verbatim copies of the old functions (test_support/microcosm_build/uk_review_loaders_reference.py) on the packaged file, on 13 changed copies and on the days around each window edge (34 refusals and 34 warnings among the cases). The existing exclusion, support-floor and full-target tests pass unchanged. The small-cell deferrals (ledger_targets.assert_uk_local_deferrals_in_force) keep their own expiry check: it parses with date.fromisoformat, so it also accepts compact dates, and moving it would change what it accepts. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The UK reviewed-exclusion registers (target fit, local target fit and area support) now use the shared review core (microcosm#1759, step D7): - weighted_integrity._read_register_payload reads with read_strict_json, which keeps its texts for duplicate keys, non-finite numbers and malformed JSON. The "must be a JSON object" check stays with the UK. - UKReviewedExclusion reads approved_on and expires_on with canonical_date, with the same message. Its new window() gives the ReviewWindow, and expired and premature read it. - The national gate kernel and uk.full gate kernels, which hash weighted_integrity, now also hash declared_registers. Every public name stays where battery_bindings and the tools import it. battery_bindings, gate_battery, stage_health and graph_evidence are not changed. No change in what these registers read, accept or refuse. test_uk_reviewed_exclusions_core.py holds the new code to verbatim copies of the old reader, date checks and window methods (test_support/microcosm_build/uk_reviewed_exclusion_reference.py) on the three packaged files, on ten changed texts, on ten date pairs and on the days around every packaged entry's window. The existing weighted-integrity, terminal-gate, battery-binding, graph and CLI tests pass unchanged. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The digests were measured at 38dbd01, before the UK selection moved to the shared target sets: the full surface, the selection for 19 parameter sets (13 selections, 6 refusals) and the national registry, on the pinned Chronicle feed and the 2021 output-area ladder, at calibration year 2025 and review date 2026-11-26. The tests run when MICROCOSM_UK_CHRONICLE_FACTS and MICROCOSM_UK_OA_LADDER are set. The selection tests can read a saved surface (MICROCOSM_UK_TARGET_SURFACE) that has the pinned digest. Part of microcosm#1759. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
docs/uk-target-sets.md describes the UK declaration (the level rule, the full build's selection by level and the calibration lines), the shared hold-out split, the signed entries on the shared review core, what stays UK code and what a UK build computes again. The US page and uk/target_sets.json link to it. Part of microcosm#1759. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The review of microcosm#1755 found that three readers took a repeated JSON key without a word: plain json.loads keeps the last one, so a second mode or register of one name replaced the first. The target-set reader, the declared registers and the US local target construction now refuse a repeated key and a non-finite number. A version must be the integer 1 (True passed before), and a list of clause names refuses "*", which would match only a name "*". The packaged files already pass, so no selection or register changes. Part of microcosm#1728. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
The review of microcosm#1755 found that the shared code wrote generic refusal texts, and that the tests compared only the error class. - A pass's scoring declares child_label and parent_label, and a ladder level declares code_name. With them the pro-rata baseline refusals and the ladder's state-code refusal have the replaced texts again. - assign_holdout_roles refuses None for the fraction and the salt. Only an omitted argument draws with the declared value, so a caller that forwards an unset option cannot hold targets out silently. - The US tests compare each refusal's class and text with the replaced code. Three cases still differ from the replaced code, because one shared check now serves both passes: the county fraction refusal also names the value, the district pass checks its salt before it reads a record, and the county scorer reads role on every record. The tests pin them. No run of the tool reaches them: the command line checks fractions and salts first, and the district pass gives every record a role. No target, role or receipt changes. Part of microcosm#1728. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
The shared strict reader raises DeclaredRegisterError, a ValueError subclass. A gate that fails closed records the class name of the error in its report, so a malformed register gave a different report than before (the review of microcosm#1755). The UK reader raises a plain ValueError with the same text again. The UK loader tests now compare the error class as well as the text. Part of microcosm#1759. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
uk.full.rotated-holdout@1 rebuilds the problem inputs, so it runs the declared level rule (microcosm.calibrate.target_sets through the UK adapter) and the review core (microcosm.build.declared_registers). It hashed neither (the review of microcosm#1755). No stale result was possible, because a node key chains through its producers' keys, but the kernel now hashes what it runs. test_uk_graph_terminal.py pins these entries, the shared hold-out module, and the review core in each gate kernel's hash. No test pinned them before. Part of microcosm#1759. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Corrections from the review of microcosm#1755. They change texts and add one test; no code path changes. - held_estimates multiplies in float64. It gives the bytes of the replaced UK expression for a float64 matrix, which the UK problem matrix always is. A new test pins the float32 case, where the two differ. - The SOI clause of the local state and state_county modes reads a row's level as ledger_geography_level, else geography_level. The replaced filter read only ledger_geography_level. Every compiled row carries it. - The byte pins of test_us_acs_local_surface_bytes.py were measured after the declared selection replaced the selection code, so they hold the later moves only. - docs/us-target-sets.md lists the refusals that keep their texts and the three that differ. docs/uk-target-sets.md states the hold-out kernel's hash and the reader's error class. Part of microcosm#1728 and microcosm#1759. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
fiscal_target_registers.json was listed before fiscal_target_references.json, the one row of the 28 US JSON resources out of order (the review of microcosm#1755). The package list and the generator's list now agree on the sorted order. Both --check modes of the re-pin tools pass with no pin changed, so the order moves no spec-engine pin. Part of microcosm#1728. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Main brings the renewed UK register entries (the clock tests of the engine-free job pass again), the UK feed pin e4d46c93 and the LCFS work of microcosm#1736. No file conflicted. Both --check modes of the US re-pin tools pass with no pin changed. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
The digests of test_uk_target_surface_pins.py hold Chronicle feed 15040ea5, the UK input files of 38dbd01 and review date 2026-11-26. Every pin passed at 9130ebe, after the move to shared code: that is the proof of the move. Main has re-pinned the UK feed to e4d46c93 and renewed register entries with approval date 2026-11-27 (microcosm#1736). So the surface is different now, and the renewed entries are not in force on the old review date. The tests now skip, with the reason, while the package pins another feed than PINNED_FEED_COMMIT. To use them again, measure the surface, the selections and the national registry on the new feed, and set the feed commit, the review date and the digests together. Part of microcosm#1759. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Review: three suggestions on the target-set declarationsThe shared selector and the US declarations select what main selects. A comparison of main's local filters with this branch's, on 2,100 combinations of metadata values, differed only in the cases the description lists under "Differences on other feeds". The three suggestions below are about the declaration format and the UK cache key. 1. Use the UK's
|
…'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>
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>
From the review of microcosm#1755 (suggestions 1 and 2). One form for the level rule. us/target_sets.json now declares a level_rule, as the UK file does: the first of ledger_geography_level and geography_level that has a value, any level accepted. The shared reader loses the short level_keys form and target_level; target_set_census takes the rule. us_runtime.target_loss_weights.target_geography_level reads the declared rule in place of its own copy of that reading. A test holds it to a verbatim copy of the replaced code. On the pinned feed all 31,748 compiled targets set ledger_geography_level only, so no compiled target sets both level fields; a test pins that. A record of the rows left out by level. select_target_set counts, by family and level, the targets that an active clause names by family and that no such clause keeps at their level (left_out_by_level). The ACS local tool writes the counts in materialize_rss.json under target_levels_left_out, beside the SOI receipt, whose pinned bytes are equal. The assertion that could not fail (undeclared_cells on the kept rows) is replaced by a pin of the counts for each local mode: the country rows of the three families in every mode, and the district SOI rows in state and state_county. No target, order or pinned receipt changes. The US rule stays open: a closed rule and a refusal of an undeclared level add run-time refusals to a US build, and they are not in this commit. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
From the review of microcosm#1755 (suggestion 3). The declared target sets decide what a build calibrates to, and most of each file is prose: a description for each mode and a rationale for each clause. They were legacy_json resources, the kind for files from before the spec engine. The bundle gives that kind no semantic content, so the bundle's spec_sha256 did not cover a clause, and the UK solve keyed on the file's bytes: a reworded rationale merged between the two builds of a local release would force the second build to solve again (microcosm#1301). The spec engine already separates a typed resource's normative content from its documentation. So the target sets become a typed resource: - A new resource kind, target_sets, with target_sets.schema.json, the sixteenth schema of the catalog. Each description and rationale is documentation; every other field is normative. - us/target_sets.json and uk/target_sets.json become us/spec/target_sets.yaml and uk/spec/target_sets.yaml. The products and the modes are lists with an id, so their declared order is content (two UK refusals list the calibration lines in that order); the order of the fields of an object is not content. - microcosm.calibrate.target_sets takes the object the spec engine parsed. Its own file reader is removed. The country modules read through country_spec.load_country_target_sets, which loads the one resource as the bundle loader does. - The country spec records, for each typed resource, the sha256 of its normative projection (ResolvedCountrySpec.content_hashes). fingerprint_excluding takes that hash for the resources named in by_content, and the UK solve fingerprint names its target sets there. The calibrated gates and the release manifests keep the byte hash. The US typed files are generated from the constants-era code. That code never held the target sets, so the US file is written by hand: the generator declares its manifest row (AUTHORED_DOMAIN_KINDS) and does not write it. The F0 field ledger has a reviewed claim for the domain, a front-end validation with its own verifier: the release tools read the typed domain themselves, so it does not pass through the constants adapter. The US pins move to 42,557 configuration fields and a new spec_sha256, which now covers the declared clauses. No target, order or receipt changes. The pinned US surfaces, censuses and receipt bytes hold on the pinned feed, and the UK selection and calibration-line tests still match the verbatim copies of the replaced code. test_uk_solve_scope.py edits the packaged file both ways: a reworded description or rationale, another layout or another order of a set of names re-keys no solve kernel; a new level, a changed clause level or family, a removed exclusion, or another order of the clauses or the modes re-keys every solve kernel. The UK solve fingerprint has a new value, so the first UK build after this change computes the solve-scoped nodes again, with the same outputs. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Two generated pin files conflicted, as in the earlier merges: the US F0 coverage evidence and the spec_sha256 pin of the multispine pool test. The re-pin tools regenerated both for the merged tree (42,557 of 42,557 configuration fields, 41 of 41 inventory checks). Main raised microcosm-emitter-interface to 0.18.0; no other file needed a change. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
The country spec now checks a package's declared target sets with the shared reader when it loads the bundle, and the US field ledger does the same for its target_sets claim. So the gate bindings' source closure reaches microcosm.calibrate.target_sets, one module more than the reviewed list of test_transport_evidence_kernels.py. The module joins that list. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
The country spec's loader now checks a bundle's declared target sets with microcosm.calibrate.target_sets (microcosm#1728). country_spec is a listed transport compile module, so the closure test needs each of its first-party imports listed or excluded with a reason. Target compilation calls only the reference validators of country_spec. They do not read the reader, and a target set selects among the targets after the compile. So the reader joins EXCLUDED_DIRECT_IMPORTS with that reason, like the other imports of the loader. No compile kernel hashes the list module, so no node key changes. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
|
Thank you for the review. All three points led to a change on this branch. Two refusals from points 1 and 2 wait for María's decision. 1. One form for the level rule: done (
|
| Family | Level | Rows | Left out by |
|---|---|---|---|
usda_snap |
country |
2 | every local mode |
cms_medicaid |
country |
3 | every local mode |
irs_soi |
country |
441 | every local mode |
irs_soi |
congressional_district |
22,996 | state and state_county |
select_target_setnow returnsleft_out_by_level: the targets that an active clause names by family and that no such clause keeps at their level, by (family, level).- The local tool writes the counts in
materialize_rss.jsonundertarget_levels_left_out. They are beside the SOI receipt, not in it, for two reasons: the pinned receipt bytes stay equal, and the counts cover SNAP and Medicaid too. - You were right about the pinned test:
undeclared_cellson the kept rows could not fail. It is replaced by a pin of the table above for each mode. The case of your example (a county row of a family whose clause keeps the state level) is a shared test,test_a_selection_counts_the_specs_it_leaves_out_by_level. - Not done yet: the refusal. The design that fits the table is
left_out_levelson a clause (level → reason), with a refusal of any other level of the clause's families. It is a second run-time refusal in a US build, so it waits for the same decision.
3. UK cache key: done by the schema route (8fd3e88e9)
The declared target sets are now a typed resource of the spec engine, as you proposed.
- Kind and schema. A new kind
target_setswithtarget_sets.schema.json(the sixteenth schema of the catalog). Eachdescriptionandrationaleisx-spec-surface: documentation; every other field is normative. - Files.
us/spec/target_sets.yamlanduk/spec/target_sets.yaml. A typed resource must be YAML by the loader's rule, so the engine's strict YAML 1.2 reader reads them, and_read_declaration_fileis gone from the shared reader. - The key.
ResolvedCountrySpec.content_hashesholds the sha256 of each typed resource's normative projection, fromnormalize_and_project.fingerprint_excluding(..., by_content=...)takes it, anduk_solve_fingerprint()namesspec/target_sets.yaml. The byte hash stays inresource_hashes, in the full fingerprint and in the release manifests. - A side effect that I think is the main gain. As
legacy_jsonthe files had no semantic content in the bundle, so a changed US clause moved no pin. The bundle'sspec_sha256now covers the clauses. - Tests, as you listed.
test_uk_solve_scope.pyedits the packaged file both ways. A reworded description or rationale, another layout (JSON in place of block YAML, fields in reverse order) or another order of a set of names re-keys no solve kernel. A new level, a changed clause level or family, a removed exclusion, or another order of the clauses or of the modes re-keys every solve kernel.
Three things differ from your sketch, and I would like your view on the last one:
- Products and modes are lists with an
id. The engine sorts the keys of an object, and the order of the UK calibration lines is content: two refusals list them in that order. So an ordered thing must be a list. - The country modules read through a narrow loader,
country_spec.load_country_target_sets. It loads the one resource as the bundle loader does (parse, schema, defaults, normalize), in the wayload_country_take_up_contract_projectiondoes for take-up. UK modules read the calibration lines at import, and a full bundle load there costs too much. - The US file is written by hand in a generated bundle. The constants-era code never held the target sets, so
generate_us_bundle_from_constants.pyonly declares the manifest row (AUTHORED_DOMAIN_KINDS). The F0 field ledger has a new claim,target_sets:FRONT_END_VALIDATIONwithNO_GENERATION0_EFFECT, and a verifier that checks the domain against the schema and the shared reader. The release tools read the typed domain themselves, so it does not pass through the constants adapter. No claim in the ledger is like it yet. Is that the right classification, or do you want an adapter surface for it?
The US pins move: 42,557 configuration fields (32,771 authored) and a new spec_sha256. Every CI job passes on 5eac92f5f, the US engine jobs among them. Two reviewed module lists needed the shared reader, because the country spec now checks the declared target sets when it loads a bundle: the gate battery's binding identity (884f1eb53) and the exclusions of the transport compile list (5eac92f5f).
Not in this PR: us/local_target_construction.json and us/fiscal_target_registers.json are still legacy_json, and the other typed UK resources still enter the solve fingerprint by their bytes.
Drafted with AI assistance.
Part of #1728 (work item 1) and of #1759.
This PR stays a draft while more commits land on this branch. Those commits also keep the calibrated targets the same.
The national and the local build compile the same target registry, then each tool keeps a subset. Until now the subset was in tool code. This PR declares it as data, for each product and mode, and both tools select by the declaration. The UK now selects its targets with the same shared code (see "#1759 on this branch"). No target surface changes, in the US or the UK.
What this PR adds
packages/microcosm-calibrate/src/microcosm/calibrate/target_sets.pypackages/microcosm-build/src/microcosm/build/us/spec/target_sets.yamlnational(--target-surface:full,national_state) and productlocal(--soi-mode:state,totals,full,state_cd,state_county).us/country_package.jsonlists it as a typed resource of kindtarget_sets.packages/microcosm-build/src/microcosm/build/spec_engine/schema/target_sets.schema.jsonpackages/microcosm-build/src/microcosm/build/us_runtime/target_sets.pycongressional_districtpredicate and thestate_cd_district_sharesrule.tools/build_us_fiscal_refresh_release.py_select_target_surfaceselects by the declaration.tools/build_us_acs_local_release.pystate_admin_surfaceandsoi_surface_predicateselect by the declaration.docs/us-target-sets.mdA declaration states, for each mode:
state_county, the county SOI shares and ACS households). The declaration names their family and levels.A target's family is
TargetSpec.family. Its level comes from the level rule that the file declares: for the US,ledger_geography_level, elsegeography_level. These are the labels that the shared target-loss rule of #1735 reads, so a target has one family and one level everywhere. The UK declares its own level rule inuk/spec/target_sets.yaml(see "#1759 on this branch").Proof of no change
Each surface was measured on the pinned
41b2fb2feed on main0f963ac77before the change and on this branch after it. The count, theTargetRegistryversion (an order-sensitive content hash), the family × level census and the selection receipt are identical for every surface:nationalfull4cc4cfb7a147nationalnational_state4dfe25b1238alocalstate0ee16ca42be5;69b952ef181flocaltotalsc6a0f757c0bclocalfullb6c71f2e8505localstate_cde0bb302e3addlocalstate_county0ee16ca42be5test_us_target_sets.pypins all of these. The pinned-feed tests run whenMICROCOSM_US_CHRONICLE_FACTSnames the feed; the 4,867 test also needsMICROCOSM_US_PUMA_LADDER_ARTIFACT(the ladder with SHA25639a2ab2a…).Differences on other feeds
The local SNAP, Medicaid,
totals,fullandstate_cdfilters used to keep every row that carriesstate_fips, at any level. Their clauses now also name the level: state for SNAP and Medicaid, state and district for the SOI rows oftotals,fullandstate_cd. On the pinned feed every such row is at a declared level, so nothing changes. On a feed with such rows at another level (for example county rows in the main feed), they stay out until a clause names the level.The SOI clause of
stateandstate_countyreads a row's level as every clause does:ledger_geography_level, elsegeography_level. The filter it replaced read onlyledger_geography_level. So a state SOI row that carries onlygeography_levelnow enters these two modes. Every compiled row carriesledger_geography_level, so no compiled registry changes.The national modes keep
"*"for families and levels, as before: a family that a re-pin adds still entersfullandnational_state(unless the district classifier drops it).Pins that move
The US bundle has three new resources: the typed
spec/target_sets.yaml, and thelegacy_jsonrowsus/local_target_construction.jsonandus/fiscal_target_registers.json. They move the US F0 spec-engine pins:country_manifestclaim has 122 pointers, and a newtarget_setsclaim in the field ledger has 144.spec_sha256ise76daa6c. Pool builds record it in their run config's spec binding. It now covers the declared clauses of the target sets.target_sets.schema.json, and a resource kindtarget_sets.These are identities, not targets: no target changes.
us_runtime/target_sets.pyjoins the reviewed non-registry modules intest_us_spine_blindness.py.The spec-engine pins are US-only, and the UK gate battery's fingerprint covers only the gates manifest. So the new UK resource
uk/spec/target_sets.yamlmoves no pin. It does change the UK solve fingerprint (see "What a UK build computes again" below).The US JSON resource rows are in sorted order since
202b82526. The order moves no pin: both--checkmodes of the re-pin tools pass unchanged.Merges
a2e5f4d11is merged in (c586e1cab, by Auto-fix on 27 Nov). Only the two generated pin files conflicted; the re-pin tools regenerated them for the merged tree (42,557 of 42,557 fields), and both--checkmodes pass. Main raisedmicrocosm-emitter-interfaceto 0.18.0.5589fae09is merged in (781e78408, 27 Nov). No file conflicted, and both--checkmodes of the re-pin tools pass with no pin changed. Main brings the renewed UK register entries, the UK feed pine4d46c93and the LCFS work of Draw LCFS spending as a budget and a donor's mix, and fix the donor's income predictors (#1717) #1736.4b78a9b23is merged in (38dbd0187, by Auto-fix on 26 Nov). As in the merge below, only the two generated pin files conflicted; the re-pin tools regenerated them (42,413 of 42,413 fields), and both--checkmodes pass.5df16cfd2, which includes Shared calibration machinery for local areas: weight rules, loss caps, area support, weight bound and a spine diagnostic #1735, is merged in (508351658). Only the two generated pin files that both PRs moved conflicted (the coverage evidence and the pool tool'sspec_sha256pin). The merge took main's version and regenerated both with the re-pin tools on the merged code; both--checkmodes pass.1f833383a), measured again at this head: Ready the US ACS local-area lane for the next national build on policyengine-us 2.145.3 (#1661, #1675, #1154) #1719 is far behind main, and 24 files conflict with main5589fae09without this PR. This PR adds five, and the Consolidate the shared target code so it serves the UK and the US #1759 commits add none. Four are generated spec-engine pin files (field_usage.py,tools/spec_engine_coverage.pyand their two tests); a re-run of the re-pin tools regenerates them. The fifth isus_runtime/fiscal_targets.py: Ready the US ACS local-area lane for the next national build on policyengine-us 2.145.3 (#1661, #1675, #1154) #1719 edits a three-line comment about the mortgage-interest inputs (policyengine-us#9605), which is now the note of thehome_mortgage_interest_amountentry inus/fiscal_target_registers.json. The local and national tool files already conflict without this PR, and the county module merges cleanly.Tests
packages/microcosm-build/tests/engine_free/shared/test_spec_engine_target_sets.py(the resource kind and its schema, the documentation projection, the content hash and the narrow loader; 67 tests),packages/microcosm-calibrate/tests/engine_free/shared/test_target_sets.py(the shared reader and selector, 50 tests) andpackages/microcosm-build/tests/engine_free/us/test_us_target_sets.py(the US declarations against the tools, the pinned surfaces, and a check that every compiled target's level is the level thattarget_loss_weights.target_geography_levelgives).test_us_acs_local_release_tool.py,test_us_acs_local_county_surface.py,test_us_acs_local_sparse_cd.py,test_us_fiscal_refresh_builder.py,test_us_fiscal_targets.py,test_release_target_parity.py,test_first_party_imports.py,test_transport_evidence_kernels.py, and the country-package and spec-engine tests (test_spec_only_country_packages.py,test_country_spec.py,test_us_spec_bundle.py,test_spec_source_citations.py,test_spec_engine_loader.py,test_spec_engine_reemission.py,test_transport_composed_graph.py).ruffandtools/ci_test_plan.py verifypass.test_uk_level_selection.py,test_uk_calibration_line_selection.py,test_uk_review_loaders.py,test_uk_reviewed_exclusions_core.pyandtest_uk_target_surface_pins.py, with additions totest_target_sets.py,test_holdout.py,test_declared_registers.pyandtest_us_target_holdouts.py. The verbatim copies of the replaced code are intest_support/microcosm_build/.test_uk_target_compile_modules.py,test_country_spec.py,test_first_party_imports.py, the US pinned-feed pins (34 tests, at D4; D5 to D7 change no US code), and all 22 UK pin tests at9130ebe15(the surface and the national registry compiled from the pinned feed; the 19 selections on the pinned surface).test_uk_solve_scope.pyand the UK and shared tests that read the country spec or the solve fingerprint; both--checkmodes of the US re-pin tools and the coverage tool (42,557 of 42,557 fields, 41 of 41 checks). Theengine_contractandengine_workflowtests need the US engine, which the local environment does not have: they run in CI. On884f1eb53both engine-free jobs failed on one test, the closure check of the transport compile list (test_transport_compile_modules.py);5eac92f5fcorrects it. On5eac92f5fevery CI job passes: lint, wheels, integration-uk, and engine-free, engine-uk and engine-us on Python 3.13 and 3.14.9130ebe15and202b82526every CI job passed except engine-free, which failed only on a UK clock test (test_no_committed_exclusion_is_about_to_lapse) that failed on main too. Main has renewed the entries (Draw LCFS spending as a budget and a donor's mix, and fix the donor's income predictors (#1717) #1736), and this branch has that main merged. After the merge, 1,660 touched UK tests (every clock test among them) and 1,680 touched US and shared tests with the pinned US feed pass locally.Builds
None. No surface changes in either country, so no build is needed. The first UK build after this PR merges computes some nodes again, with the same outputs (see "What a UK build computes again").
Shared-code work on this branch
The calibrated targets stay the same for now, so that #1719 keeps its behavior. The tool code that builds the target surfaces moves to shared code in later commits on this branch, each with no target change. Done so far:
f605ffa07(C0):test_us_acs_local_surface_bytes.pyfollows the target part ofdo_materializefor each non-county--soi-modeand pins the sha256 oftarget_registry.json,target_roles.json, the target receipts (SOI surface, district and county hold-outs) and the population rows' matrix, on the pinned feed and ladder. These pins also catch a change of metadata key order, whichTargetRegistry.versiondoes not (it sorts the keys).state_countyis not pinned yet: it needs the pinned county facts and a household frame.fb34e5e29(C1): the US ledger filter rules (25 names, 446 lines) move verbatim from the national tool tous_runtime/ledger_filter_rules.py; the tool imports them back. Two builder tests that changed a rule on a fresh copy of the tool now usemonkeypatch, because every load of the tool shares the package module. The district surface reads them from the package, so it no longer imports the national tool. The local tool compiles the registry in one function. The C0 pins pass unchanged.868f414bc(C2): the district and county hold-outs run on the new sharedmicrocosm.build.target_holdouts(hashed blocks from declared passes, the training target set, and scoring against the pro-rata baseline). The US passes are declared in the newus/local_target_construction.json; the tool functions keep their names.test_us_target_holdouts.pyholds them to verbatim copies of the replaced code on random records (91 tests), and the C0 pins pass unchanged.904a46d86(C3): the state and district ladder population rows and specs run on the new sharedmicrocosm.build.ladder_population_targets, declared in theladder_populationsection. The district module no longer imports the county module.test_us_ladder_population.pyholds the tool functions to verbatim copies of the replaced code (54 tests), and the C0 pins pass unchanged.33cdf6667(C6): the 13 reviewed registers of the US fiscal target compile (the fact exclusions with their reasons and vintage scope, the misread source columns, the restamped source packages, the SOI variable maps, the direct and indicator Ledger targets, the M-CHIP states) move tous/fiscal_target_registers.json, with their code comments as descriptions and notes. The new sharedmicrocosm.build.declared_registersreads them back as the literals they replace, and the code keeps every name.test_us_fiscal_target_registers.pypins each register's digest as measured on the literals, the pinned-feed compile under four flag sets (full registry JSON) and the exclusion receipt.docs/us-target-sets.mddescribes the declared construction and the registers.The district SOI shares of
state_cdand the county rung stay tool code. They make child rows as shares of parent rows, and one nesting rule across all levels will replace them, together with the district rows of #1731.#1759 on this branch: one shared module for each job, in both countries
María ruled (26 Nov) that #1759 goes into this PR, so that the duplicates this PR made do not reach main. Each commit keeps the outputs of both countries the same and carries its own proof. The proofs compare the new code with verbatim copies of the code it replaced (in
test_support/microcosm_build/*_reference.py).fba28da98test_us_target_holdouts.pyca3a67e9b15040ea5, sha2569fc0715e…) and the OA ladder, at calibration year 2025 and review date 2026-11-26: the full surface, the selection for 19 parameter sets (13 selections, 6 refusals) and the national registry. The digests were measured at38dbd0187, before D1.test_uk_target_surface_pins.pypasses at9130ebe15: the surface and the national registry compiled again from the feed, and the 19 selections. Main has since re-pinned the UK feed toe4d46c93(#1736), so these tests skip, with the reason, until the pins are measured again on the new feed (ca2444289)e9317a3bbmicrocosm.calibrate.target_setsreads a declaredlevel_rule(keys, a closed set of levels, refusal of a conflict), andselect_by_levelskeeps a run-time set of levels in compile order, with the receiptmicrocosm.calibrate.target-selection.v1. The USlevel_keysform was unchanged at this commit; since36d976c7bthe US file declares its rule in the same form (see the review of 27 Nov below).61e24394duk/target_sets.json(since8fd3e88e9:uk/spec/target_sets.yaml): the level rule and the full build's selection by level.uk.full.target_selection@1selects with the shared code, andtarget_geographyreads the declared rule.microcosm.calibrate.target_selectionis removed (the UK kernel was its only caller).test_uk_level_selection.py: 400 random registries and requests, refusals included0d5dc1a9dcalibration_lineproduct. The line filter selects through it with one UK predicate; each target'scalibration_linesstays in the contract. The shared selector reads a level only when a clause tests levels.test_uk_calibration_line_selection.py4e74c81a1microcosm.build.holdoutgainsHoldoutSplit,fold_splitsandheld_estimates; the UK rowwise hold-out and the US local hold-out both use them. The draws stay apart on purpose.test_holdout.py: byte-equal to the replaced UK and US expressions on float64 matrices, which both builds pass2ead043a4microcosm.build.declared_registersgains the shared review core for signed entries:read_strict_json,canonical_date,ReviewWindowandstale_entries.c866b8951test_uk_review_loaders.py34c8d436atest_uk_reviewed_exclusions_core.py9130ebe15docs/uk-target-sets.mddescribes the UK declaration, the hold-outs, the signed entries and what stays UK code.Where a UK kernel now runs a shared module, it also hashes that module. The import-coverage test (
test_uk_target_compile_modules.py) checks this for the target, problem and national kernels, andtest_uk_graph_terminal.pypins the entries of the hold-out kernel and of each gate kernel.One label changes (ruling 1). Commit C2 moved
csr_row_measureto the sharedmicrocosm.build.target_holdouts. The calibration diagnostics name each matrix-row measure<module>.<name>, so a US local release now writesmicrocosm.build.target_holdouts.target_matrix_row[N]where it wroteus_acs_local_cd_surface.target_matrix_row[N]. The targets and weights are the same, buttarget_surface.sha256incalibration_diagnostics.jsonandbuild_manifest.jsonchanges. María accepted the new name on 26 Nov, because no build uses these files at the moment. The changelog records it for anyone who compares two releases.The UK hold-out stays as it is (ruling 5). The UK rowwise hold-out keeps its constants: 5 rotated folds over the local target rows, seed 20260529 (
UK_LOCAL_HOLDOUT_FOLDSandUK_LOCAL_HOLDOUT_SEEDinuk_runtime/local_rowwise.py). It is report-only. A stricter UK hold-out, for example one that declares its draw as data the wayus/local_target_construction.jsondoes, would start there.What stays country code.
state_cd, the county rung andoff_surface_cells.pybelong to the nesting work of US targets: one declared nesting rule across national, state, district and county levels #1760, which runs in parallel.What a UK build computes again.
uk/spec/target_sets.yamlis a new solve-scoped UK resource, so it is in the UK solve fingerprint (by its normative content since8fd3e88e9), which the spine gates also hash. The first UK build after this PR merges computes these again: the spine fromfrs_brmaon, the target nodes and every node after them, and the national graph. The target nodes write the same bytes (the UK pins above), and the other nodes run the same code on the same inputs. A UK release that is between its first build and its sign-off build when this PR merges would not reuse its solve.Review by anth-volk (27 Nov)
The review made three suggestions on the declaration format and the UK cache key. Each led to a change. No target, order or pinned receipt changes: every surface pin in this description holds.
36d976c7blevel_rule, as the UK file does. Thelevel_keysform andtarget_levelare removed from the shared reader.us_runtime.target_loss_weights.target_geography_levelreads the declared rule, and a test holds it to a verbatim copy of the replaced code. On the pinned feed all 31,748 compiled targets setledger_geography_levelonly, so no target sets both fields; a test pins this.36d976c7bselect_target_setreturnsleft_out_by_level: the targets that an active clause names by family and that no such clause keeps at their level. The local tool writes the counts inmaterialize_rss.jsonundertarget_levels_left_out, beside the SOI receipt (its pinned bytes are equal). The assertion that could not fail (undeclared_cellson the kept rows) is replaced by a pin of the counts for each local mode.8fd3e88e9target_sets, schematarget_sets.schema.json, filesus/spec/target_sets.yamlanduk/spec/target_sets.yaml. The schema marks eachdescriptionandrationaleas documentation. The country spec records the hash of each typed resource's normative projection, and the UK solve fingerprint takes it for its target sets. A reworded rationale or a new layout re-keys no solve node; a changed clause, level or exclusion re-keys every one. The calibrated gates and the release manifests keep the byte hash.884f1eb53addsmicrocosm.calibrate.target_setsto the reviewed list of modules in the gate battery's binding identity (test_transport_evidence_kernels.py): the country spec now checks the declared target sets with the shared reader when it loads a bundle. For the same reason,5eac92f5fnames the reader intransport.compile_modules.EXCLUDED_DIRECT_IMPORTS:country_specis a listed transport compile module, and the compile calls only its reference validators, which do not read the reader. No compile kernel hashes the list module, so no node key changes.What the typed resource changes beyond the cache key.
spec_sha256now covers the declared clauses. Aslegacy_jsonthe files had no semantic content in the bundle, so a changed US clause moved no pin.id. The spec engine sorts the keys of an object, and the order of the UK calibration lines is content (two refusals list them), so an ordered thing must be a list.country_spec.load_country_target_sets, which loads the one resource as the bundle loader does.AUTHORED_DOMAIN_KINDSof the generator), with a reviewed claim in the F0 field ledger: a front-end validation whose verifier checks the domain against the schema and the shared reader. This claim is new in kind (a typed domain that the release tools read themselves, not through the constants adapter), so it needs a look from the owners of the spec engine.The rows left out by level on the pinned feed. The review expected every count to be zero. They are not: no local mode keeps a country row, and the
stateandstate_countymodes keep no district SOI row (main's filter tested that level in code).usda_snapcountrycms_medicaidcountryirs_soicountryirs_soicongressional_districtstateandstate_countyNot in this PR.
us/local_target_construction.jsonandus/fiscal_target_registers.jsonare stilllegacy_json. By the same principle they should be typed resources; that is a follow-up.What a UK build computes again is as stated above: the solve fingerprint has a new value, and the outputs are the same bytes.
Adversarial review (27 Nov)
A fresh reviewer agent read the whole diff against the claim that no output changes. It found no build input where the targets, their order, a receipt or a cache key differ. It found these gaps, and each has a fix on this branch:
dcd2e470ejson.loadskeeps the last one),["*"]as a literal name andtrueas a version.8fd3e88e9the spec engine's strict reader reads the target sets; it refuses a repeated key too.47561f9a3fraction=Nonedrew the declared default without a word.child_labelandparent_labelof a pass's scoring,code_nameof a ladder level).Noneis refused. The tests compare class and text.f7cdd43fcValueErroragain, and the UK tests compare the class.b66abff84test_uk_graph_terminal.pypins these entries and the review core in each gate kernel's hash.0f4b6e8castateSOI clause, the float64 premise ofheld_estimates, what the byte pins of C0 cover, and a stale field count in the changelog.202b82526Three refusals differ on purpose. One shared check now serves both US hold-out passes:
roleon every record, as the district scorer always did.No run of the tool reaches these cases: the command line checks fractions and salts first, and the district pass gives every record a role.
test_us_target_holdouts.pypins all three, anddocs/us-target-sets.mdlists them under "Refusals". A refusal is still aValueError(the shared error classes are subclasses).What the proofs do not cover. The pinned-feed tests do not run in CI, because CI has no feed; the random-record comparisons and the register digests do. The UK pins cover the compile, the selection and the national registry, on feed
15040ea5; they skip since main re-pinned the UK feed. The UK problem, measures, hold-out and gate nodes rest on the comparisons with the replaced code.Not in this PR
us/spec/target_sets.yaml, with its pins and a build.state_cd, the county rung and the UKoff_surface_cells.py).🤖 Generated with Claude Code