From 58c44fdd994f12337ade4b42686619cf52d68e01 Mon Sep 17 00:00:00 2001 From: Max Ghenis Date: Mon, 16 Nov 2026 08:03:10 -0500 Subject: [PATCH 1/4] Name the US calibration arms by builder flag in pinned and generated text microcosm#1540 left five pieces of wording because changing them moves hash pins, a test-pinned string or a generated contract. This changes them and regenerates every pin with the repo's tools. - solve.py: calibrate_l0_refit says what it does instead of calling itself the production path; L0RefitResult, calibrate_l0_refit and refit_l0_selection drop "production artifact" and "shipped weights". - ssi_take_up.py: the delivery gate docstring names the arms by flag. The builder fences only --dense-default-dataset, keyed on the flag alone; the L0+refit arm and --exact-k keep hard enforcement. - build_us_fiscal_refresh_release.py: the dense SSI fence text that builds write into manifests names the arms the same way, and its test requires the flag names and refuses the retired labels. - US calibration contract: release modes take the builder's dataset.default.method values (l0_refit, dense_no_l0), and refit_contracts.default_sparse becomes l0_refit. Nothing outside the generator, the schema and the generated YAML reads the names. - us-release-build-rule.md: says which code uses microcosm.build.holdout and that no held-out test compares a US national candidate with the incumbent. Every pin below was written by its tool, none by hand: repin_us_spec_engine_contracts.py (two passes, --check rc 0), generate_us_bundle_from_constants.py (--check rc 0), spec_engine_coverage.py (two passes, --check rc 0; 42395/42395 fields, 41/41 inventory checks), graph_parity_repin.py calibrate (pins.json only; direct.csv unchanged). ruff format changed only the quotes the repinner writes. No flag, default, calibration, draw, RNG rule or dataset changes. Co-Authored-By: Claude Opus 5.5 --- changelog.d/calibration-arm-wording.fixed.md | 1 + docs/evidence/spec-engine/us-f0-coverage.json | 20 +++++++-------- docs/us-release-build-rule.md | 17 ++++++++++--- .../build/spec_engine/field_usage.py | 2 +- .../build/spec_engine/inventory_coverage.py | 4 +-- .../schema/calibration.schema.json | 14 +++++------ .../microcosm/build/us/spec/calibration.yaml | 8 +++--- .../microcosm/build/us_runtime/ssi_take_up.py | 18 +++++++------ .../test_spec_engine_calibration_semantics.py | 2 +- .../shared/test_spec_engine_loader.py | 2 +- .../us/test_us_fiscal_refresh_builder.py | 12 ++++++--- .../engine_free/us/test_us_ssi_take_up.py | 6 ++--- .../us/test_us_multispine_pool_tool.py | 2 +- .../src/microcosm/calibrate/solve.py | 25 ++++++++++--------- .../parity/kernels/calibrate/pins.json | 2 +- tools/build_us_fiscal_refresh_release.py | 7 +++--- tools/spec_engine_coverage.py | 2 +- tools/us_bundle_generation/contracts.py | 16 +++++++++--- 18 files changed, 95 insertions(+), 65 deletions(-) create mode 100644 changelog.d/calibration-arm-wording.fixed.md diff --git a/changelog.d/calibration-arm-wording.fixed.md b/changelog.d/calibration-arm-wording.fixed.md new file mode 100644 index 0000000000..af6c6edbb2 --- /dev/null +++ b/changelog.d/calibration-arm-wording.fixed.md @@ -0,0 +1 @@ +The US builder's dense SSI fence text, which builds write into their manifests, and the `us_ssi_take_up_delivery_gate` docstring now name the builder's arms by flag: the fences apply to `--dense-default-dataset`, and the L0+refit arm (neither flag) and `--exact-k` keep hard enforcement. They no longer call the dense arm "diagnostic" or the L0+refit arm "the sparse certified default". The `calibrate_l0_refit` and `L0RefitResult` docstrings say what the function returns instead of calling it the production path. The generated US calibration contract's release modes are renamed to the builder's `dataset.default.method` values: `default_sparse_l0_refit` becomes `l0_refit`, `dense_diagnostic` becomes `dense_no_l0`, and `refit_contracts.default_sparse` becomes `refit_contracts.l0_refit`. The US release build rule now says which code uses `microcosm.build.holdout`, and that no held-out test compares a US national candidate with the incumbent. No flag, default, calibration, draw or dataset changes. diff --git a/docs/evidence/spec-engine/us-f0-coverage.json b/docs/evidence/spec-engine/us-f0-coverage.json index 01959ce14b..f16066eba8 100644 --- a/docs/evidence/spec-engine/us-f0-coverage.json +++ b/docs/evidence/spec-engine/us-f0-coverage.json @@ -109,7 +109,7 @@ "mode": "legacy_behavior", "pointer_class": "all", "pointer_count": 320, - "pointer_sha256": "49a153b065b59950d910f9e2bcfcd7005e5babaecf9b41b1cc9704a7f20dcc5b", + "pointer_sha256": "5336f77a10b2f0aa03f6bc221f3c5b8390adccaeed8ee3e7251292606a83a7fd", "rationale": null, "relative_sink_prefix": "/calibration_contract", "source_prefix": "/authored/spec~1calibration.yaml", @@ -771,7 +771,7 @@ "legacy_behavior": 14269 }, "multiple_primary_use_field_count": 0, - "pointer_inventory_sha256": "81bc649e653b467b0da8fa7442a895fe45f24a263c725d764ca9ed8f4441325c", + "pointer_inventory_sha256": "aef9c71b32492d8e2fb643a5334dce4bf3f3a3d0ed1fce603cea3cba6d44c77b", "resolved_binding_field_count": 9786, "unused_field_count": 0 }, @@ -1642,13 +1642,13 @@ "compiler_ir.node_slices" ], "expected": { - "map_sha256": "8d0542f7b83f030772e6e53b5742d0f13bcad82325a4e9b66d5d999a3fbb5276", - "protocol_sha256": "3ab23e82779263dabe8da210de55ce7f12fdc0464e8145ca2c18649426b7f976" + "map_sha256": "4082e6e5ca5199c0bd96fa4d954d09e368a0f5ff0f4ce8995b7173ff9e5ed5ad", + "protocol_sha256": "54a913c973b1fbdf3510bc09e20b2f85f5297ebc32e833f8590a8891405a3ca3" }, "failures": [], "observed": { - "map_sha256": "8d0542f7b83f030772e6e53b5742d0f13bcad82325a4e9b66d5d999a3fbb5276", - "protocol_sha256": "3ab23e82779263dabe8da210de55ce7f12fdc0464e8145ca2c18649426b7f976" + "map_sha256": "4082e6e5ca5199c0bd96fa4d954d09e368a0f5ff0f4ce8995b7173ff9e5ed5ad", + "protocol_sha256": "54a913c973b1fbdf3510bc09e20b2f85f5297ebc32e833f8590a8891405a3ca3" }, "status": "covered" }, @@ -1663,7 +1663,7 @@ "compiler_ir.seed_stream_map" ], "expected": { - "implementation_sha256": "3ab23e82779263dabe8da210de55ce7f12fdc0464e8145ca2c18649426b7f976", + "implementation_sha256": "54a913c973b1fbdf3510bc09e20b2f85f5297ebc32e833f8590a8891405a3ca3", "protocol": "legacy-v1", "streams": [ "build_model", @@ -1684,7 +1684,7 @@ }, "failures": [], "observed": { - "implementation_sha256": "3ab23e82779263dabe8da210de55ce7f12fdc0464e8145ca2c18649426b7f976", + "implementation_sha256": "54a913c973b1fbdf3510bc09e20b2f85f5297ebc32e833f8590a8891405a3ca3", "protocol": "legacy-v1", "streams": [ "build_model", @@ -2585,7 +2585,7 @@ "country": "us", "schema_id": "country_spec", "schema_version": 1, - "spec_sha256": "fa75bd68f579fd7fb0dd0eed955c867415c251f11fc34087bbc24ae3a77a2a49" + "spec_sha256": "f58dc9a843f3291eb7d944658f673cd7121d20a8c807ef65df5cafc4a00b4745" } }, "report_schema_version": 3, @@ -2595,7 +2595,7 @@ "country": "us", "schema_id": "country_spec", "schema_version": 1, - "spec_sha256": "fa75bd68f579fd7fb0dd0eed955c867415c251f11fc34087bbc24ae3a77a2a49" + "spec_sha256": "f58dc9a843f3291eb7d944658f673cd7121d20a8c807ef65df5cafc4a00b4745" }, "status": "pass" } diff --git a/docs/us-release-build-rule.md b/docs/us-release-build-rule.md index 25c405f7ed..4d033084c4 100644 --- a/docs/us-release-build-rule.md +++ b/docs/us-release-build-rule.md @@ -18,10 +18,19 @@ frozen comparison register, both rescored on it, with strict improvement `tools/build_us_fiscal_refresh_release.py`). That gate runs on the `--exact-k` arm only, and that arm takes a pool manifest, which the release tool refuses to combine with `--base-h5`. A `--base-h5` release runs no improvement gate. -Main has no US held-out test: the rotated-fold holdout in -`microcosm.build.holdout` is imported by the UK runtime and UK tools only. So a -US release says it beats the incumbent on the frozen register, and says it beats -it on held-out cells only once a US holdout exists and has run. +Main has no held-out test that compares a US national candidate with the +incumbent. The rotated folds in `microcosm.build.holdout` run only in the UK +runtime (`uk_runtime/local_rowwise.py`). US code imports only the module's +keyed-hash helpers. The ACS local-area tools (`tools/us_acs_local_cd_surface.py` +and `tools/us_acs_local_county_surface.py`) use them to keep blocks of district +and county SOI targets out of the local-area solve, then score those blocks +against a pro-rata baseline; the scores are marked report-only and refuse +nothing. `us_runtime/support_mix.py` uses them to split targets for the +support-mix bake-off. The national builder imports neither helper. Its three +`*_holdout.json` reports compare one build with outside benchmarks and never +refuse a release. So a US national release says it beats the incumbent on the +frozen register, and says it beats it on held-out cells only once a national +holdout exists and has run. Publication stays a human step. Since the US repository's switch to `releases.json`, the release tool writes each build to diff --git a/packages/microcosm-build/src/microcosm/build/spec_engine/field_usage.py b/packages/microcosm-build/src/microcosm/build/spec_engine/field_usage.py index 102a01f6bf..29a4918fa6 100644 --- a/packages/microcosm-build/src/microcosm/build/spec_engine/field_usage.py +++ b/packages/microcosm-build/src/microcosm/build/spec_engine/field_usage.py @@ -362,7 +362,7 @@ def _path_inventory(rows: Sequence[tuple[str, object]]) -> tuple[int, str]: ), "calibration": ( 320, - "49a153b065b59950d910f9e2bcfcd7005e5babaecf9b41b1cc9704a7f20dcc5b", + "5336f77a10b2f0aa03f6bc221f3c5b8390adccaeed8ee3e7251292606a83a7fd", ), "catalog_columns": ( 1_593, diff --git a/packages/microcosm-build/src/microcosm/build/spec_engine/inventory_coverage.py b/packages/microcosm-build/src/microcosm/build/spec_engine/inventory_coverage.py index 4adbf3565b..4d96c9ecbc 100644 --- a/packages/microcosm-build/src/microcosm/build/spec_engine/inventory_coverage.py +++ b/packages/microcosm-build/src/microcosm/build/spec_engine/inventory_coverage.py @@ -392,8 +392,8 @@ # microcosm#1096 moves both again: solve's opt-in softmax mass # parametrization projects exactly onto the capped simplex; the default # projection parametrization is unchanged. - "seed_map": "8d0542f7b83f030772e6e53b5742d0f13bcad82325a4e9b66d5d999a3fbb5276", - "seed_protocol": "3ab23e82779263dabe8da210de55ce7f12fdc0464e8145ca2c18649426b7f976", + "seed_map": "4082e6e5ca5199c0bd96fa4d954d09e368a0f5ff0f4ce8995b7173ff9e5ed5ad", + "seed_protocol": "54a913c973b1fbdf3510bc09e20b2f85f5297ebc32e833f8590a8891405a3ca3", "source_manifest": "dc3879886d2a69f20fb982a675d7fb322c0e4017afef6471be54b0ee3cbd2af6", "take_up": "9522ce40f7dea569312dd7a7beb474e5a5afadd2f1e10cb5876534c3ef623d35", "tail": "565f0ceeadab69d3e96a886a00dd0305f7425fa3acde24d12ba48db2b37d5fc0", diff --git a/packages/microcosm-build/src/microcosm/build/spec_engine/schema/calibration.schema.json b/packages/microcosm-build/src/microcosm/build/spec_engine/schema/calibration.schema.json index 5bc064fe0c..efaac418e4 100644 --- a/packages/microcosm-build/src/microcosm/build/spec_engine/schema/calibration.schema.json +++ b/packages/microcosm-build/src/microcosm/build/spec_engine/schema/calibration.schema.json @@ -22,9 +22,9 @@ "refit_contracts": { "type": "object", "additionalProperties": false, - "required": ["default_sparse", "exact_k"], + "required": ["l0_refit", "exact_k"], "properties": { - "default_sparse": {"$ref": "#/$defs/refit_contract"}, + "l0_refit": {"$ref": "#/$defs/refit_contract"}, "exact_k": {"$ref": "#/$defs/refit_contract"} } }, @@ -577,12 +577,12 @@ "type": "object", "additionalProperties": false, "required": [ - "default_sparse_l0_refit", - "dense_diagnostic", + "l0_refit", + "dense_no_l0", "exact_k_or_full_pool_refit" ], "properties": { - "default_sparse_l0_refit": { + "l0_refit": { "type": "object", "additionalProperties": false, "required": ["kernel", "solver_ref", "selection_contract_ref", "refit_contract_ref"], @@ -590,10 +590,10 @@ "kernel": {"const": "kernel:calibrate_l0_refit"}, "solver_ref": {"const": "solver"}, "selection_contract_ref": {"const": "solver.l0_contract"}, - "refit_contract_ref": {"const": "refit_contracts.default_sparse"} + "refit_contract_ref": {"const": "refit_contracts.l0_refit"} } }, - "dense_diagnostic": { + "dense_no_l0": { "type": "object", "additionalProperties": false, "required": ["kernel", "solver_ref", "l0_mode", "refit_contract_ref"], diff --git a/packages/microcosm-build/src/microcosm/build/us/spec/calibration.yaml b/packages/microcosm-build/src/microcosm/build/us/spec/calibration.yaml index e16aea188b..f659af868a 100644 --- a/packages/microcosm-build/src/microcosm/build/us/spec/calibration.yaml +++ b/packages/microcosm-build/src/microcosm/build/us/spec/calibration.yaml @@ -195,7 +195,7 @@ solver: l1_lambda: 0.0 l2_anchor_weights: null refit_contracts: - default_sparse: + l0_refit: support: selection_weight_above_prune_relative_atol subset_source: selection_stage_frame starting_weights: selection_stage_calibrated_weights @@ -222,12 +222,12 @@ refit_contracts: source: run_request default: null release_modes: - default_sparse_l0_refit: + l0_refit: kernel: kernel:calibrate_l0_refit solver_ref: solver selection_contract_ref: solver.l0_contract - refit_contract_ref: refit_contracts.default_sparse - dense_diagnostic: + refit_contract_ref: refit_contracts.l0_refit + dense_no_l0: kernel: kernel:calibrate solver_ref: solver l0_mode: none diff --git a/packages/microcosm-build/src/microcosm/build/us_runtime/ssi_take_up.py b/packages/microcosm-build/src/microcosm/build/us_runtime/ssi_take_up.py index 3c133614d4..6bac673dfa 100644 --- a/packages/microcosm-build/src/microcosm/build/us_runtime/ssi_take_up.py +++ b/packages/microcosm-build/src/microcosm/build/us_runtime/ssi_take_up.py @@ -1640,16 +1640,20 @@ def us_ssi_take_up_delivery_gate( per-target knob (microcosm#492). The under-18 band stays fenced pending microcosm#453/#509 and is reported in the details, never enforced. - ``enforcement_fences`` fences normally-enforced bands for a specific - ARM with a documented adjudication (the under-18 pattern extended): - on the dense full-pool arm, microcosm#508 delivered-weight recomputes - have not landed the adult pair in band on either observed frame — + ``enforcement_fences`` fences normally-enforced bands for one builder + arm with a documented adjudication (the under-18 pattern extended). + The US builder passes them on its ``--dense-default-dataset`` arm + only: on that arm's two observed full-pool runs, microcosm#508 + delivered-weight recomputes have not landed the adult pair in band — P2's clean one-retry record, and P3's delivered-basis chain that ``ssi_take_up_prior_basis_from_artifact`` now refuses outright (microcosm#566/#567) — so its adult bands ship in the scorecard as - known boundaries rather than enforced contracts. The fence text - rides each fenced row; the sparse certified default passes no - fences and keeps hard enforcement. + known boundaries rather than enforced contracts. The builder keys + the fences on the flag alone, so a dense run whose selection source + first cuts the pool is fenced too. The fence text rides each fenced + row. The L0+refit arm (neither ``--exact-k`` nor + ``--dense-default-dataset``) and the ``--exact-k`` arm pass no fences + and keep hard enforcement. """ expected_targets = _normalize_targets(targets) diff --git a/packages/microcosm-build/tests/engine_free/shared/test_spec_engine_calibration_semantics.py b/packages/microcosm-build/tests/engine_free/shared/test_spec_engine_calibration_semantics.py index 79aec84704..a50c62825b 100644 --- a/packages/microcosm-build/tests/engine_free/shared/test_spec_engine_calibration_semantics.py +++ b/packages/microcosm-build/tests/engine_free/shared/test_spec_engine_calibration_semantics.py @@ -31,7 +31,7 @@ ROOT = _TEST_PATHS.repository US_ROOT = ROOT / "packages/microcosm-build/src/microcosm/build/us" CANONICAL_LEGACY_PROJECTION_SHA256 = ( - "b289d8a5dd4d82ba311f71bc9909e2f2c4829566e7ff6226e517ef5f74eceeba" + "025ed1037145ceb73230352560f045e58f610995bc6b21bcf8b3f835b727fb33" ) diff --git a/packages/microcosm-build/tests/engine_free/shared/test_spec_engine_loader.py b/packages/microcosm-build/tests/engine_free/shared/test_spec_engine_loader.py index 4fc18c403d..6f2aa42931 100644 --- a/packages/microcosm-build/tests/engine_free/shared/test_spec_engine_loader.py +++ b/packages/microcosm-build/tests/engine_free/shared/test_spec_engine_loader.py @@ -27,7 +27,7 @@ def test_semantic_hash_has_golden_vector_and_surface_separation(tmp_path) -> Non # The hierarchy value ranks move medicaid_take_up's attested bytes. # microcosm#1096's exact softmax cap projection in solve moves it too. assert first.spec_sha256 == ( - "fac42090cfab91ce96b2e73c6dc0dbd53cd2c7583ce058220fc12bda98433e55" + "ab59cb4ecbd0fd659a14a62ed80a630ba4ddc3923dcb8aa90aad831f7397407b" ) second_root = _rich_minimal(tmp_path / "xy", note="second", store="local:b") diff --git a/packages/microcosm-build/tests/engine_free/us/test_us_fiscal_refresh_builder.py b/packages/microcosm-build/tests/engine_free/us/test_us_fiscal_refresh_builder.py index feda21a8dd..29f437d2b5 100644 --- a/packages/microcosm-build/tests/engine_free/us/test_us_fiscal_refresh_builder.py +++ b/packages/microcosm-build/tests/engine_free/us/test_us_fiscal_refresh_builder.py @@ -379,8 +379,9 @@ def test_the_run_refuses_skipped_checks_left_files_before_any_side_effect() -> N def test_dense_ssi_fences_cover_the_enforced_bands_and_cite_the_adjudication() -> None: """microcosm#566/#567: the dense-arm fence table must cover exactly the normally-enforced bands, and every fence must carry the recompute - adjudication, its re-adjudication trigger, and the sparse contrast — - a fence without its documented reason is forbidden.""" + adjudication, its re-adjudication trigger, and the arms that keep hard + enforcement, each named by its builder flag — a fence without its + documented reason is forbidden.""" from microcosm.build.us_runtime.ssi_take_up import ( US_SSI_TAKE_UP_ENFORCED_BAND_KEYS, ) @@ -392,7 +393,12 @@ def test_dense_ssi_fences_cover_the_enforced_bands_and_cite_the_adjudication() - assert "microcosm#566/#567" in text, band assert "microcosm#508" in text, band assert "Re-adjudicates" in text, band - assert "sparse certified" in text, band + assert "--dense-default-dataset arm" in text, band + assert "The L0+refit and --exact-k arms pass no fences" in text, band + # The text names arms by builder flag, not by the retired + # "dense diagnostic" and "sparse certified default" labels. + assert "diagnostic arm" not in text, band + assert "sparse certified" not in text, band # The adjudication must claim only what the artifacts support: # recomputes failed to land the pair in band — NOT a proven # periodic map (sol round-1 blocker 3). The refusal scans the diff --git a/packages/microcosm-build/tests/engine_free/us/test_us_ssi_take_up.py b/packages/microcosm-build/tests/engine_free/us/test_us_ssi_take_up.py index dc9531076e..e3cb214331 100644 --- a/packages/microcosm-build/tests/engine_free/us/test_us_ssi_take_up.py +++ b/packages/microcosm-build/tests/engine_free/us/test_us_ssi_take_up.py @@ -935,8 +935,8 @@ def test_delivery_gate_fences_override_enforcement_with_their_adjudication() -> **{"18_64": 80.0, "65_plus": 90.0}, # both far outside the envelope ) fences = { - "18_64": "Fenced for the dense diagnostic arm (microcosm#566/#567).", - "65_plus": "Fenced for the dense diagnostic arm (microcosm#566/#567).", + "18_64": "Fenced for the --dense-default-dataset arm (microcosm#566/#567).", + "65_plus": "Fenced for the --dense-default-dataset arm (microcosm#566/#567).", } gate = us_ssi_take_up_delivery_gate( delivered, targets=_TARGETS, enforcement_fences=fences @@ -959,7 +959,7 @@ def test_delivery_gate_fences_override_enforcement_with_their_adjudication() -> def test_delivery_gate_partial_fence_keeps_the_other_band_enforced() -> None: _, _, _, diagnostics = _assigned() - fences = {"65_plus": "Fenced for the dense diagnostic arm (microcosm#566)."} + fences = {"65_plus": "Fenced for the --dense-default-dataset arm (microcosm#566)."} # The un-fenced band still hard-fails on a miss... missed = _delivered(diagnostics, **{"18_64": 80.0, "65_plus": 90.0}) gate = us_ssi_take_up_delivery_gate( diff --git a/packages/microcosm-build/tests/engine_workflow/us/test_us_multispine_pool_tool.py b/packages/microcosm-build/tests/engine_workflow/us/test_us_multispine_pool_tool.py index d7c84c6702..73247eef87 100644 --- a/packages/microcosm-build/tests/engine_workflow/us/test_us_multispine_pool_tool.py +++ b/packages/microcosm-build/tests/engine_workflow/us/test_us_multispine_pool_tool.py @@ -356,7 +356,7 @@ def capture_equality(expected: object, actual: object) -> None: # The hierarchy value ranks move it through medicaid_take_up's # attested bytes. # microcosm#1096's exact softmax cap projection in solve moves it. - "spec_sha256": "fa75bd68f579fd7fb0dd0eed955c867415c251f11fc34087bbc24ae3a77a2a49", + "spec_sha256": "f58dc9a843f3291eb7d944658f673cd7121d20a8c807ef65df5cafc4a00b4745", }, } diff --git a/packages/microcosm-calibrate/src/microcosm/calibrate/solve.py b/packages/microcosm-calibrate/src/microcosm/calibrate/solve.py index 31f7c56e69..24ab4c4fbc 100644 --- a/packages/microcosm-calibrate/src/microcosm/calibrate/solve.py +++ b/packages/microcosm-calibrate/src/microcosm/calibrate/solve.py @@ -450,8 +450,8 @@ class L0RefitResult: hard-concrete L0 gates. The :attr:`refit` stage keeps either the legacy weight-threshold support or a caller-supplied exact-k support, removes the gates and L0 penalty, and runs ordinary calibration on the resulting frame. - Convenience properties delegate to :attr:`refit`, because the refit frame - and weights are the production artifact. + Convenience properties delegate to :attr:`refit`, because the refit stage + produces the calibrated frame and weights. """ selection: CalibrationResult @@ -3414,21 +3414,21 @@ def refit_l0_selection( explicitly selects the existing thresholded path and leaves its starting weights unchanged. ``l2_lambda`` applies the soft concentration penalty to the refit itself — - the stage that produces the shipped weights; the default ``0.0`` keeps the - refit unpenalized. + the stage whose weights this function returns; the default ``0.0`` keeps + the refit unpenalized. On the legacy path, the refit's starting weights are the *selection stage's calibrated weights*, which are already concentrated — so with ``l2_anchor="initial"`` a strong penalty pulls toward their square (more concentration, lower ESS). Pass ``l2_anchor="uniform"`` when the penalty's - job is to spread the shipped weights, or ``l2_anchor="design"`` to anchor at + job is to spread the returned weights, or ``l2_anchor="design"`` to anchor at the *pre-selection* initial weights of the surviving records — "stay near the survey design", the natural choice when the candidate frame carries real design weights rather than a uniform reset. On the explicit exact-k path, the starting weights and design anchor instead use the original-frame design weights after the same normalized Horvitz--Thompson projection. ``l2_basis`` selects the refit penalty's form (see :func:`calibrate`); - ``"chi_square"`` with the ``"design"`` anchor pulls the shipped weights + ``"chi_square"`` with the ``"design"`` anchor pulls the returned weights toward the survivors' design weights themselves rather than their square. ``mass_parametrization`` applies to the refit, which has no gates (see :func:`calibrate`). @@ -3617,11 +3617,12 @@ def calibrate_l0_refit( ) -> L0RefitResult: """Select a sparse support with L0 gates, then refit ordinary calibration. - This is the production "generate big, then prune" path when the final - artifact should be a sparse calibrated frame rather than the raw gated L0 - weights. The first stage is exactly :func:`calibrate` with L0 pruning - enabled by ``target_records`` or a positive fixed ``l0_lambda``. The second - stage delegates to :func:`refit_l0_selection`. + Use it for a "generate big, then prune" solve whose result should be a + sparse calibrated frame rather than the raw gated L0 weights. The first + stage is exactly :func:`calibrate` with L0 pruning enabled by + ``target_records`` or a positive fixed ``l0_lambda``. The second stage + delegates to :func:`refit_l0_selection`, and the result's frame and + weights are the refit stage's. ``l2_lambda`` applies the soft concentration penalty to both stages. ``refit_l2_lambda`` overrides the refit stage only (the ``refit_epochs`` / @@ -3630,7 +3631,7 @@ def calibrate_l0_refit( override) penalties are both expressible. ``l2_anchor`` / ``refit_l2_anchor`` follow the same inherit-or-override pattern; note the refit starts from the selection stage's concentrated weights, so a - penalized refit whose goal is spreading the shipped weights should anchor + penalized refit whose goal is spreading the returned weights should anchor ``"uniform"`` (see :func:`refit_l0_selection`). ``l2_basis`` / ``refit_l2_basis`` follow the same pattern for the penalty's form. ``refit_mass_parametrization`` applies to the refit stage only: the diff --git a/packages/microcosm-graph/tests/fixtures/parity/kernels/calibrate/pins.json b/packages/microcosm-graph/tests/fixtures/parity/kernels/calibrate/pins.json index a33ecd8cca..683dc738b5 100644 --- a/packages/microcosm-graph/tests/fixtures/parity/kernels/calibrate/pins.json +++ b/packages/microcosm-graph/tests/fixtures/parity/kernels/calibrate/pins.json @@ -1 +1 @@ -{"dependencies":{"numpy":"2.4.6","pandas":"3.0.3","scipy":"1.17.1","torch":"2.12.0"},"implementation_hash":"07e4330f69e7d909027ae5ec1e474b45fb38d4461ac4ad349970e03be9cbfeb6","kernel":"calibrate.adam@1","node":"calibrate","node_key":"2972c813b95a3b6d117a3795692804e89e388578d6e142a18cea8d0624999896","numeric":"bitwise","platform":"arm64/darwin/py3.14","platforms":{"arm64/darwin/py3.14":{"direct":"direct.csv","node_key":"2972c813b95a3b6d117a3795692804e89e388578d6e142a18cea8d0624999896"}},"seed":0} +{"dependencies":{"numpy":"2.4.6","pandas":"3.0.3","scipy":"1.17.1","torch":"2.12.0"},"implementation_hash":"f8f8c62daebfd24988b5de1950486b7edb2ba1df9b7b04cf4b7c32cc067da337","kernel":"calibrate.adam@1","node":"calibrate","node_key":"3b8716c21debe594a2a15f03469257e7abc87b9b19768e28bc957ddc73d54d97","numeric":"bitwise","platform":"arm64/darwin/py3.14","platforms":{"arm64/darwin/py3.14":{"direct":"direct.csv","node_key":"3b8716c21debe594a2a15f03469257e7abc87b9b19768e28bc957ddc73d54d97"}},"seed":0} diff --git a/tools/build_us_fiscal_refresh_release.py b/tools/build_us_fiscal_refresh_release.py index 68f368a9bb..8e05283457 100644 --- a/tools/build_us_fiscal_refresh_release.py +++ b/tools/build_us_fiscal_refresh_release.py @@ -543,9 +543,9 @@ # The L0+refit and --exact-k arms pass no fences and keep hard enforcement. # RE-ADJUDICATES when microcosm#566's damped fixed-point protocol lands. _US_DENSE_SSI_FENCE_ADJUDICATION = ( - "Fenced for the dense diagnostic arm (microcosm#566/#567): " + "Fenced for the --dense-default-dataset arm (microcosm#566/#567): " "microcosm#508 delivered-weight recomputes have not landed the adult " - "band pair in the envelope on either observed frame (P2, current-" + "band pair in the envelope on either observed full-pool frame (P2, current-" "frame attempt then its one permitted recompute: +5.8%/+24.8% -> " "+8.2%/+20.0%; P3, attempts already anchored on delivered bases: " "65+ +34.6%, then +8.3%/+19.8% after recomputing again — a chain " @@ -553,7 +553,8 @@ "deleted microcosm#463-class loop. This band's miss ships in the " "scorecard as a known boundary — never as an enforced contract. " "Re-adjudicates when the microcosm#566 damped fixed-point protocol " - "lands. The sparse certified default keeps hard enforcement." + "lands. The L0+refit and --exact-k arms pass no fences and keep hard " + "enforcement." ) US_DENSE_SSI_TAKE_UP_ENFORCEMENT_FENCES: dict[str, str] = { "18_64": _US_DENSE_SSI_FENCE_ADJUDICATION, diff --git a/tools/spec_engine_coverage.py b/tools/spec_engine_coverage.py index df4457159d..e8cd142fae 100644 --- a/tools/spec_engine_coverage.py +++ b/tools/spec_engine_coverage.py @@ -41,7 +41,7 @@ REPORT_SCHEMA_VERSION = 3 EXPECTED_POINTER_INVENTORY_SHA256 = ( - "81bc649e653b467b0da8fa7442a895fe45f24a263c725d764ca9ed8f4441325c" + "aef9c71b32492d8e2fb643a5334dce4bf3f3a3d0ed1fce603cea3cba6d44c77b" ) DEFAULT_REPORT_PATH = ( Path(__file__).resolve().parents[1] diff --git a/tools/us_bundle_generation/contracts.py b/tools/us_bundle_generation/contracts.py index 9738516919..f5ca2086ae 100644 --- a/tools/us_bundle_generation/contracts.py +++ b/tools/us_bundle_generation/contracts.py @@ -1466,7 +1466,7 @@ def build_calibration_contract() -> dict[str, object]: }, }, "refit_contracts": { - "default_sparse": { + "l0_refit": { "support": "selection_weight_above_prune_relative_atol", "subset_source": "selection_stage_frame", "starting_weights": "selection_stage_calibrated_weights", @@ -1493,14 +1493,22 @@ def build_calibration_contract() -> dict[str, object]: "seed": {"source": "run_request", "default": None}, }, }, + # One mode per builder arm. The first two keys are the + # dataset.default.method values the builder writes for its arms: + # l0_refit when the caller sets neither --exact-k nor + # --dense-default-dataset, and dense_no_l0 for + # --dense-default-dataset. The third is the --exact-k arm. Every + # mode shares the solver block; its kernel is the l0_refit arm's + # because _fiscal_release_cli_defaults reads the parse with neither + # flag set. "release_modes": { - "default_sparse_l0_refit": { + "l0_refit": { "kernel": _kernel_ref(solve.calibrate_l0_refit), "solver_ref": "solver", "selection_contract_ref": "solver.l0_contract", - "refit_contract_ref": "refit_contracts.default_sparse", + "refit_contract_ref": "refit_contracts.l0_refit", }, - "dense_diagnostic": { + "dense_no_l0": { "kernel": _kernel_ref(solve.calibrate), "solver_ref": "solver", "l0_mode": "none", From bd438d81388ce64306c7f865bd388f9a65bfc859 Mon Sep 17 00:00:00 2001 From: Max Ghenis Date: Mon, 16 Nov 2026 08:36:28 -0500 Subject: [PATCH 2/4] Record why microcosm#1641 moves the seed and spec pins The comments beside EXPECTED_HASHES, the loader golden and the multispine spec_sha256 list each change that moved them. This adds microcosm#1641: the solve and ssi_take_up docstrings and the calibration contract's renamed modes. Comments only; the repinner, coverage and generator --check runs pass. Co-Authored-By: Claude Opus 5.5 --- .../src/microcosm/build/spec_engine/inventory_coverage.py | 6 ++++-- .../tests/engine_free/shared/test_spec_engine_loader.py | 1 + .../engine_workflow/us/test_us_multispine_pool_tool.py | 4 +++- 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/packages/microcosm-build/src/microcosm/build/spec_engine/inventory_coverage.py b/packages/microcosm-build/src/microcosm/build/spec_engine/inventory_coverage.py index 4d96c9ecbc..ac0bf92e0a 100644 --- a/packages/microcosm-build/src/microcosm/build/spec_engine/inventory_coverage.py +++ b/packages/microcosm-build/src/microcosm/build/spec_engine/inventory_coverage.py @@ -391,8 +391,10 @@ # becomes the takes_up_tanf_if_eligible its draw always used. # microcosm#1096 moves both again: solve's opt-in softmax mass # parametrization projects exactly onto the capped simplex; the default - # projection parametrization is unchanged. - "seed_map": "4082e6e5ca5199c0bd96fa4d954d09e368a0f5ff0f4ce8995b7173ff9e5ed5ad", + # projection parametrization is unchanged. microcosm#1641 moves both + # again: docstrings in solve and ssi_take_up name the builder's arms by + # flag; no draw, RNG rule, QRF target or solve changes. + "seed_map":"4082e6e5ca5199c0bd96fa4d954d09e368a0f5ff0f4ce8995b7173ff9e5ed5ad", "seed_protocol": "54a913c973b1fbdf3510bc09e20b2f85f5297ebc32e833f8590a8891405a3ca3", "source_manifest": "dc3879886d2a69f20fb982a675d7fb322c0e4017afef6471be54b0ee3cbd2af6", "take_up": "9522ce40f7dea569312dd7a7beb474e5a5afadd2f1e10cb5876534c3ef623d35", diff --git a/packages/microcosm-build/tests/engine_free/shared/test_spec_engine_loader.py b/packages/microcosm-build/tests/engine_free/shared/test_spec_engine_loader.py index 6f2aa42931..7c5332d61f 100644 --- a/packages/microcosm-build/tests/engine_free/shared/test_spec_engine_loader.py +++ b/packages/microcosm-build/tests/engine_free/shared/test_spec_engine_loader.py @@ -26,6 +26,7 @@ def test_semantic_hash_has_golden_vector_and_surface_separation(tmp_path) -> Non # The opt-in cross-fitted gate calibration moves the fit kernels' bytes. # The hierarchy value ranks move medicaid_take_up's attested bytes. # microcosm#1096's exact softmax cap projection in solve moves it too. + # microcosm#1641's docstrings in solve and ssi_take_up move it again. assert first.spec_sha256 == ( "ab59cb4ecbd0fd659a14a62ed80a630ba4ddc3923dcb8aa90aad831f7397407b" ) diff --git a/packages/microcosm-build/tests/engine_workflow/us/test_us_multispine_pool_tool.py b/packages/microcosm-build/tests/engine_workflow/us/test_us_multispine_pool_tool.py index 73247eef87..6481636ba5 100644 --- a/packages/microcosm-build/tests/engine_workflow/us/test_us_multispine_pool_tool.py +++ b/packages/microcosm-build/tests/engine_workflow/us/test_us_multispine_pool_tool.py @@ -356,7 +356,9 @@ def capture_equality(expected: object, actual: object) -> None: # The hierarchy value ranks move it through medicaid_take_up's # attested bytes. # microcosm#1096's exact softmax cap projection in solve moves it. - "spec_sha256": "f58dc9a843f3291eb7d944658f673cd7121d20a8c807ef65df5cafc4a00b4745", + # microcosm#1641 moves it again: docstrings in solve and + # ssi_take_up, and the calibration contract's renamed modes. + "spec_sha256":"f58dc9a843f3291eb7d944658f673cd7121d20a8c807ef65df5cafc4a00b4745", }, } From 272783dbb1d1e13803579e7fc0303af2674eead5 Mon Sep 17 00:00:00 2001 From: Max Ghenis Date: Mon, 16 Nov 2026 11:43:14 -0500 Subject: [PATCH 3/4] Finish the refit-stage wording in solve and scope the holdout claim solve.py's module docstring, L0RefitResult.effective_sample_size and L0RefitResult.options still said the refit weights "ship" or called them "production"; they now say what calibrate_l0_refit returns, and three test_solve.py comments follow. The build rule's holdout paragraph now scopes "only the UK runtime runs the rotated folds" to the packages and tools, names the ACS local-area experiment that also uses them, and says support_mix also orders ACS households with the hash helpers. The contract generator's release_modes comment no longer says the kernel follows from _fiscal_release_cli_defaults: the kernel and default mode are set by hand to match that parse. solve.py's bytes moved again, so the repinner, bundle generator, coverage tool and graph-parity repin rewrote the seed, loader, multispine, coverage-report and calibrate pins; the three --check runs exit 0. Co-Authored-By: Claude Opus 5.5 --- changelog.d/calibration-arm-wording.fixed.md | 2 +- docs/evidence/spec-engine/us-f0-coverage.json | 16 +++++++-------- docs/us-release-build-rule.md | 20 +++++++++++-------- .../build/spec_engine/inventory_coverage.py | 10 +++++----- .../shared/test_spec_engine_loader.py | 2 +- .../us/test_us_multispine_pool_tool.py | 2 +- .../src/microcosm/calibrate/solve.py | 7 ++++--- .../tests/engine_free/shared/test_solve.py | 10 +++++----- .../parity/kernels/calibrate/pins.json | 2 +- tools/us_bundle_generation/contracts.py | 7 ++++--- 10 files changed, 42 insertions(+), 36 deletions(-) diff --git a/changelog.d/calibration-arm-wording.fixed.md b/changelog.d/calibration-arm-wording.fixed.md index af6c6edbb2..2882e35ac5 100644 --- a/changelog.d/calibration-arm-wording.fixed.md +++ b/changelog.d/calibration-arm-wording.fixed.md @@ -1 +1 @@ -The US builder's dense SSI fence text, which builds write into their manifests, and the `us_ssi_take_up_delivery_gate` docstring now name the builder's arms by flag: the fences apply to `--dense-default-dataset`, and the L0+refit arm (neither flag) and `--exact-k` keep hard enforcement. They no longer call the dense arm "diagnostic" or the L0+refit arm "the sparse certified default". The `calibrate_l0_refit` and `L0RefitResult` docstrings say what the function returns instead of calling it the production path. The generated US calibration contract's release modes are renamed to the builder's `dataset.default.method` values: `default_sparse_l0_refit` becomes `l0_refit`, `dense_diagnostic` becomes `dense_no_l0`, and `refit_contracts.default_sparse` becomes `refit_contracts.l0_refit`. The US release build rule now says which code uses `microcosm.build.holdout`, and that no held-out test compares a US national candidate with the incumbent. No flag, default, calibration, draw or dataset changes. +The US builder's dense SSI fence text, which builds write into their manifests, and the `us_ssi_take_up_delivery_gate` docstring now name the builder's arms by flag: the fences apply to `--dense-default-dataset`, and the L0+refit arm (neither flag) and `--exact-k` keep hard enforcement. They no longer call the dense arm "diagnostic" or the L0+refit arm "the sparse certified default". The `calibrate_l0_refit` and `L0RefitResult` docstrings, and the rest of `solve.py`'s wording about the refit stage, say what the function returns instead of calling it the production path or its weights shipped. The generated US calibration contract's release modes are renamed to the builder's `dataset.default.method` values: `default_sparse_l0_refit` becomes `l0_refit`, `dense_diagnostic` becomes `dense_no_l0`, and `refit_contracts.default_sparse` becomes `refit_contracts.l0_refit`. The US release build rule now says which code uses `microcosm.build.holdout`, and that no held-out test compares a US national candidate with the incumbent. No flag, default, calibration, draw or dataset changes. diff --git a/docs/evidence/spec-engine/us-f0-coverage.json b/docs/evidence/spec-engine/us-f0-coverage.json index cd349025a7..c3497238e7 100644 --- a/docs/evidence/spec-engine/us-f0-coverage.json +++ b/docs/evidence/spec-engine/us-f0-coverage.json @@ -1642,13 +1642,13 @@ "compiler_ir.node_slices" ], "expected": { - "map_sha256": "ab72ea715a838a3d75fba710102dc1fb35e52124913ca3bb81abebbf7cc8a295", - "protocol_sha256": "258166672c1360b1ebc73ecfb87992a8b578241dec58e0d7f2e9f535b971b533" + "map_sha256": "9af72034a243547c1fe24636aa1e004a0d5ae2f5ae8065391d6669599bcf4834", + "protocol_sha256": "ae823ebfa88867d16587688699aa1c86726d52ce242f9e75703fce601d7802c6" }, "failures": [], "observed": { - "map_sha256": "ab72ea715a838a3d75fba710102dc1fb35e52124913ca3bb81abebbf7cc8a295", - "protocol_sha256": "258166672c1360b1ebc73ecfb87992a8b578241dec58e0d7f2e9f535b971b533" + "map_sha256": "9af72034a243547c1fe24636aa1e004a0d5ae2f5ae8065391d6669599bcf4834", + "protocol_sha256": "ae823ebfa88867d16587688699aa1c86726d52ce242f9e75703fce601d7802c6" }, "status": "covered" }, @@ -1663,7 +1663,7 @@ "compiler_ir.seed_stream_map" ], "expected": { - "implementation_sha256": "258166672c1360b1ebc73ecfb87992a8b578241dec58e0d7f2e9f535b971b533", + "implementation_sha256": "ae823ebfa88867d16587688699aa1c86726d52ce242f9e75703fce601d7802c6", "protocol": "legacy-v1", "streams": [ "build_model", @@ -1684,7 +1684,7 @@ }, "failures": [], "observed": { - "implementation_sha256": "258166672c1360b1ebc73ecfb87992a8b578241dec58e0d7f2e9f535b971b533", + "implementation_sha256": "ae823ebfa88867d16587688699aa1c86726d52ce242f9e75703fce601d7802c6", "protocol": "legacy-v1", "streams": [ "build_model", @@ -2585,7 +2585,7 @@ "country": "us", "schema_id": "country_spec", "schema_version": 1, - "spec_sha256": "c3d44edaebef397c191b19741c74a283a2bae2a6451842857bee3e9e73b4e838" + "spec_sha256": "33cf0b1ee55ae59ce8f5f159ef2d683f4b2a36321c3c82f177cdb5de92979bf4" } }, "report_schema_version": 3, @@ -2595,7 +2595,7 @@ "country": "us", "schema_id": "country_spec", "schema_version": 1, - "spec_sha256": "c3d44edaebef397c191b19741c74a283a2bae2a6451842857bee3e9e73b4e838" + "spec_sha256": "33cf0b1ee55ae59ce8f5f159ef2d683f4b2a36321c3c82f177cdb5de92979bf4" }, "status": "pass" } diff --git a/docs/us-release-build-rule.md b/docs/us-release-build-rule.md index 4d033084c4..b5722c7fb8 100644 --- a/docs/us-release-build-rule.md +++ b/docs/us-release-build-rule.md @@ -19,14 +19,18 @@ frozen comparison register, both rescored on it, with strict improvement arm only, and that arm takes a pool manifest, which the release tool refuses to combine with `--base-h5`. A `--base-h5` release runs no improvement gate. Main has no held-out test that compares a US national candidate with the -incumbent. The rotated folds in `microcosm.build.holdout` run only in the UK -runtime (`uk_runtime/local_rowwise.py`). US code imports only the module's -keyed-hash helpers. The ACS local-area tools (`tools/us_acs_local_cd_surface.py` -and `tools/us_acs_local_county_surface.py`) use them to keep blocks of district -and county SOI targets out of the local-area solve, then score those blocks -against a pro-rata baseline; the scores are marked report-only and refuse -nothing. `us_runtime/support_mix.py` uses them to split targets for the -support-mix bake-off. The national builder imports neither helper. Its three +incumbent. Among the packages and tools, only the UK runtime +(`uk_runtime/local_rowwise.py`) runs the rotated folds in +`microcosm.build.holdout`; an ACS local-area experiment +(`experiments/us-acs-local-l2-basis-20260928/prepare.py`) also uses them. US +package and tool code imports only the module's keyed-hash helpers. The ACS +local-area tools (`tools/us_acs_local_cd_surface.py` and +`tools/us_acs_local_county_surface.py`) use them to keep blocks of district and +county SOI targets out of the local-area solve, then score those blocks against +a pro-rata baseline; the scores are marked report-only and refuse nothing. +`us_runtime/support_mix.py` uses them to split targets and to order ACS +households for the support-mix bake-off. The national builder imports neither +helper. Its three `*_holdout.json` reports compare one build with outside benchmarks and never refuse a release. So a US national release says it beats the incumbent on the frozen register, and says it beats it on held-out cells only once a national diff --git a/packages/microcosm-build/src/microcosm/build/spec_engine/inventory_coverage.py b/packages/microcosm-build/src/microcosm/build/spec_engine/inventory_coverage.py index 50228deba7..c21af64af5 100644 --- a/packages/microcosm-build/src/microcosm/build/spec_engine/inventory_coverage.py +++ b/packages/microcosm-build/src/microcosm/build/spec_engine/inventory_coverage.py @@ -395,11 +395,11 @@ # microcosm#1387 moves both again: the ACS transfer's opt-in SEMP-covered # partnership step changes acs_transfer's attested bytes. Off its flag no # draw, RNG rule or QRF target changes. - # microcosm#1641 moves both again: docstrings in solve and ssi_take_up - # name the builder's arms by flag; no draw, RNG rule, QRF target or solve - # changes. - "seed_map": "ab72ea715a838a3d75fba710102dc1fb35e52124913ca3bb81abebbf7cc8a295", - "seed_protocol": "258166672c1360b1ebc73ecfb87992a8b578241dec58e0d7f2e9f535b971b533", + # microcosm#1641 moves both again: it rewords docstrings in solve and + # ssi_take_up, and ssi_take_up's now names the builder's arms by flag; no + # draw, RNG rule, QRF target or solve changes. + "seed_map": "9af72034a243547c1fe24636aa1e004a0d5ae2f5ae8065391d6669599bcf4834", + "seed_protocol": "ae823ebfa88867d16587688699aa1c86726d52ce242f9e75703fce601d7802c6", "source_manifest": "dc3879886d2a69f20fb982a675d7fb322c0e4017afef6471be54b0ee3cbd2af6", "take_up": "9522ce40f7dea569312dd7a7beb474e5a5afadd2f1e10cb5876534c3ef623d35", "tail": "565f0ceeadab69d3e96a886a00dd0305f7425fa3acde24d12ba48db2b37d5fc0", diff --git a/packages/microcosm-build/tests/engine_free/shared/test_spec_engine_loader.py b/packages/microcosm-build/tests/engine_free/shared/test_spec_engine_loader.py index d4d90f73f4..829570d5b3 100644 --- a/packages/microcosm-build/tests/engine_free/shared/test_spec_engine_loader.py +++ b/packages/microcosm-build/tests/engine_free/shared/test_spec_engine_loader.py @@ -30,7 +30,7 @@ def test_semantic_hash_has_golden_vector_and_surface_separation(tmp_path) -> Non # attested bytes. # microcosm#1641's docstrings in solve and ssi_take_up move it again. assert first.spec_sha256 == ( - "cb7ae69611eccba12474c47716e56cfe11f5865bd0312847a47b8acba8de2e92" + "3bac57449d5ce4fa047a8e8d9c4dd82d97c62c760090ace2b8238fb739e4834a" ) second_root = _rich_minimal(tmp_path / "xy", note="second", store="local:b") diff --git a/packages/microcosm-build/tests/engine_workflow/us/test_us_multispine_pool_tool.py b/packages/microcosm-build/tests/engine_workflow/us/test_us_multispine_pool_tool.py index 3b086aef70..bd620ceca7 100644 --- a/packages/microcosm-build/tests/engine_workflow/us/test_us_multispine_pool_tool.py +++ b/packages/microcosm-build/tests/engine_workflow/us/test_us_multispine_pool_tool.py @@ -360,7 +360,7 @@ def capture_equality(expected: object, actual: object) -> None: # acs_transfer's attested bytes. # microcosm#1641 moves it again: docstrings in solve and # ssi_take_up, and the calibration contract's renamed modes. - "spec_sha256": "c3d44edaebef397c191b19741c74a283a2bae2a6451842857bee3e9e73b4e838", + "spec_sha256": "33cf0b1ee55ae59ce8f5f159ef2d683f4b2a36321c3c82f177cdb5de92979bf4", }, } diff --git a/packages/microcosm-calibrate/src/microcosm/calibrate/solve.py b/packages/microcosm-calibrate/src/microcosm/calibrate/solve.py index 24ab4c4fbc..949aa06617 100644 --- a/packages/microcosm-calibrate/src/microcosm/calibrate/solve.py +++ b/packages/microcosm-calibrate/src/microcosm/calibrate/solve.py @@ -51,7 +51,8 @@ ``mass="conserve"``; ``max_weight_ratio`` remains the hard safety bound. This penalty is only implemented by ``method="adam"``. In the two-stage :func:`calibrate_l0_refit` path it applies to both stages unless - ``refit_l2_lambda`` overrides the refit stage — the stage whose weights ship. + ``refit_l2_lambda`` overrides the refit stage, whose weights that function + returns. - ``l2_basis`` selects the penalty's functional form. ``"record"`` (default) is the record-weighted ``mean(r ** 2)`` above, ``r = w / anchor``. Under ``mass="conserve"`` its target-free minimizer is ``w ∝ anchor ** 2``, and @@ -548,7 +549,7 @@ def fraction_within_10pct(self) -> float: @property def effective_sample_size(self) -> float: - """Kish ESS of the post-L0 refit weights (the shipped vector).""" + """Kish ESS of the post-L0 refit weights (the returned vector).""" return self.refit.effective_sample_size @property @@ -568,7 +569,7 @@ def chi_square_distance(self) -> float: @property def options(self) -> Mapping[str, object]: - """Combined production options and selection provenance.""" + """Combined refit options and selection provenance.""" return { **dict(self.refit.options), "post_l0_refit": True, diff --git a/packages/microcosm-calibrate/tests/engine_free/shared/test_solve.py b/packages/microcosm-calibrate/tests/engine_free/shared/test_solve.py index abc542b09d..540657a3d3 100644 --- a/packages/microcosm-calibrate/tests/engine_free/shared/test_solve.py +++ b/packages/microcosm-calibrate/tests/engine_free/shared/test_solve.py @@ -917,7 +917,7 @@ def test_l0_refit_returns_refit_on_selected_support(feasible_frame) -> None: assert result.frame.n("household") == result.selection.n_nonzero assert len(result.selected_entity_ids) == result.selection.n_nonzero assert result.n_nonzero == result.selection.n_nonzero - # The production weights are the ordinary no-L0 refit on the L0-selected + # The returned weights are the ordinary no-L0 refit on the L0-selected # support, not the raw gated selection weights. assert result.final_loss <= result.selection.final_loss + 0.02 @@ -1750,9 +1750,9 @@ def test_refit_design_anchor_uses_pre_selection_weights() -> None: Provenance must show the refit ran with an explicit anchor labelled 'design' while the selection stage recorded the equivalent 'initial' - anchor, so a design-weighted production run can regularize the shipped - weights toward the survey design rather than toward the selection - stage's concentrated output. + anchor, so a design-weighted run can regularize the returned weights + toward the survey design rather than toward the selection stage's + concentrated output. """ frame, targets, _ = _l2_concentration_fixture() result = calibrate_l0_refit( @@ -1775,7 +1775,7 @@ def test_refit_design_anchor_uses_pre_selection_weights() -> None: def test_l0_refit_result_delegates_summary_metrics_to_refit() -> None: - """The two-stage result reports the refit's (shipped) summary metrics.""" + """The two-stage result reports the refit's summary metrics.""" frame, targets, _ = _l2_concentration_fixture() result = calibrate_l0_refit( frame, diff --git a/packages/microcosm-graph/tests/fixtures/parity/kernels/calibrate/pins.json b/packages/microcosm-graph/tests/fixtures/parity/kernels/calibrate/pins.json index 683dc738b5..b4f1103099 100644 --- a/packages/microcosm-graph/tests/fixtures/parity/kernels/calibrate/pins.json +++ b/packages/microcosm-graph/tests/fixtures/parity/kernels/calibrate/pins.json @@ -1 +1 @@ -{"dependencies":{"numpy":"2.4.6","pandas":"3.0.3","scipy":"1.17.1","torch":"2.12.0"},"implementation_hash":"f8f8c62daebfd24988b5de1950486b7edb2ba1df9b7b04cf4b7c32cc067da337","kernel":"calibrate.adam@1","node":"calibrate","node_key":"3b8716c21debe594a2a15f03469257e7abc87b9b19768e28bc957ddc73d54d97","numeric":"bitwise","platform":"arm64/darwin/py3.14","platforms":{"arm64/darwin/py3.14":{"direct":"direct.csv","node_key":"3b8716c21debe594a2a15f03469257e7abc87b9b19768e28bc957ddc73d54d97"}},"seed":0} +{"dependencies":{"numpy":"2.4.6","pandas":"3.0.3","scipy":"1.17.1","torch":"2.12.0"},"implementation_hash":"9695adced75ad8cae90d60d2702009ec9ab05e993ac5bce46f3c5f8703b4bc58","kernel":"calibrate.adam@1","node":"calibrate","node_key":"50c6ecdd91383554c96f772e6fd81582a8795ba3346e7dd210d48b6f62b5d7c6","numeric":"bitwise","platform":"arm64/darwin/py3.14","platforms":{"arm64/darwin/py3.14":{"direct":"direct.csv","node_key":"50c6ecdd91383554c96f772e6fd81582a8795ba3346e7dd210d48b6f62b5d7c6"}},"seed":0} diff --git a/tools/us_bundle_generation/contracts.py b/tools/us_bundle_generation/contracts.py index f5ca2086ae..988399eeaf 100644 --- a/tools/us_bundle_generation/contracts.py +++ b/tools/us_bundle_generation/contracts.py @@ -1498,9 +1498,10 @@ def build_calibration_contract() -> dict[str, object]: # l0_refit when the caller sets neither --exact-k nor # --dense-default-dataset, and dense_no_l0 for # --dense-default-dataset. The third is the --exact-k arm. Every - # mode shares the solver block; its kernel is the l0_refit arm's - # because _fiscal_release_cli_defaults reads the parse with neither - # flag set. + # mode shares the solver block. Its kernel and l0_contract.default_mode + # are set by hand to the l0_refit arm's, and + # _fiscal_release_cli_defaults reads its other defaults from a builder + # parse with neither flag set. "release_modes": { "l0_refit": { "kernel": _kernel_ref(solve.calibrate_l0_refit), From 57dd7f345f3536e94998b338331c56ce80acf778 Mon Sep 17 00:00:00 2001 From: Max Ghenis Date: Mon, 16 Nov 2026 20:25:43 -0500 Subject: [PATCH 4/4] Call P2 and P3 frames and finish the returned-weights wording The SSI gate docstring now calls P2 and P3 that arm's two observed full-pool frames: microcosm#567 records two attempts on each. A comment in _optimize_proximal and the last test_solve docstring that said the refit weights ship or are published now say returned weights. The release_modes comment notes that solver.l0.mode keeps the approved binding literal exact_k_projection. solve and ssi_take_up are attested modules, so the repinner, coverage tool and graph-parity repin rewrote the seed, loader, multispine, coverage-report and calibrate pins. The three --check runs exit 0 and tools/ci_test_plan.py verify reports ok. Co-Authored-By: Claude Opus 5.5 --- docs/evidence/spec-engine/us-f0-coverage.json | 16 ++++++++-------- .../build/spec_engine/inventory_coverage.py | 4 ++-- .../microcosm/build/us_runtime/ssi_take_up.py | 2 +- .../shared/test_spec_engine_loader.py | 2 +- .../us/test_us_multispine_pool_tool.py | 2 +- .../src/microcosm/calibrate/solve.py | 2 +- .../tests/engine_free/shared/test_solve.py | 4 ++-- .../fixtures/parity/kernels/calibrate/pins.json | 2 +- tools/us_bundle_generation/contracts.py | 3 ++- 9 files changed, 19 insertions(+), 18 deletions(-) diff --git a/docs/evidence/spec-engine/us-f0-coverage.json b/docs/evidence/spec-engine/us-f0-coverage.json index b9de3700ec..8f5110e817 100644 --- a/docs/evidence/spec-engine/us-f0-coverage.json +++ b/docs/evidence/spec-engine/us-f0-coverage.json @@ -1642,13 +1642,13 @@ "compiler_ir.node_slices" ], "expected": { - "map_sha256": "b394824bc6889d7be249f40eace2bc688ffbbd3b35ac3e5956a62584739e5eea", - "protocol_sha256": "1f0c278174a4944d4d8a29fa3dda4b55f89ba86c8e0b70d19d253c64f828b144" + "map_sha256": "66464f34f733e698385e7930074aea50e3d352181d0e9731ef0a699fec2c85ed", + "protocol_sha256": "be8c5cd773e3be74e4c9d87f18bd5a42a3307f20b53985c2489dbc13937e796e" }, "failures": [], "observed": { - "map_sha256": "b394824bc6889d7be249f40eace2bc688ffbbd3b35ac3e5956a62584739e5eea", - "protocol_sha256": "1f0c278174a4944d4d8a29fa3dda4b55f89ba86c8e0b70d19d253c64f828b144" + "map_sha256": "66464f34f733e698385e7930074aea50e3d352181d0e9731ef0a699fec2c85ed", + "protocol_sha256": "be8c5cd773e3be74e4c9d87f18bd5a42a3307f20b53985c2489dbc13937e796e" }, "status": "covered" }, @@ -1663,7 +1663,7 @@ "compiler_ir.seed_stream_map" ], "expected": { - "implementation_sha256": "1f0c278174a4944d4d8a29fa3dda4b55f89ba86c8e0b70d19d253c64f828b144", + "implementation_sha256": "be8c5cd773e3be74e4c9d87f18bd5a42a3307f20b53985c2489dbc13937e796e", "protocol": "legacy-v1", "streams": [ "build_model", @@ -1684,7 +1684,7 @@ }, "failures": [], "observed": { - "implementation_sha256": "1f0c278174a4944d4d8a29fa3dda4b55f89ba86c8e0b70d19d253c64f828b144", + "implementation_sha256": "be8c5cd773e3be74e4c9d87f18bd5a42a3307f20b53985c2489dbc13937e796e", "protocol": "legacy-v1", "streams": [ "build_model", @@ -2585,7 +2585,7 @@ "country": "us", "schema_id": "country_spec", "schema_version": 1, - "spec_sha256": "ce49749a0e1118886dbfeeddb17e2d94e22c099f7742579caf20b85ed4193652" + "spec_sha256": "7ee3e8499a9bf73df25f38d2e3c8f598907ac6cdba8bd1a9c45f58fcb389b266" } }, "report_schema_version": 3, @@ -2595,7 +2595,7 @@ "country": "us", "schema_id": "country_spec", "schema_version": 1, - "spec_sha256": "ce49749a0e1118886dbfeeddb17e2d94e22c099f7742579caf20b85ed4193652" + "spec_sha256": "7ee3e8499a9bf73df25f38d2e3c8f598907ac6cdba8bd1a9c45f58fcb389b266" }, "status": "pass" } diff --git a/packages/microcosm-build/src/microcosm/build/spec_engine/inventory_coverage.py b/packages/microcosm-build/src/microcosm/build/spec_engine/inventory_coverage.py index 590341228f..89c501c9e5 100644 --- a/packages/microcosm-build/src/microcosm/build/spec_engine/inventory_coverage.py +++ b/packages/microcosm-build/src/microcosm/build/spec_engine/inventory_coverage.py @@ -400,8 +400,8 @@ # microcosm#1641 moves both again: it rewords docstrings in solve and # ssi_take_up, and ssi_take_up's now names the builder's arms by flag; no # draw, RNG rule, QRF target or solve changes. - "seed_map": "b394824bc6889d7be249f40eace2bc688ffbbd3b35ac3e5956a62584739e5eea", - "seed_protocol": "1f0c278174a4944d4d8a29fa3dda4b55f89ba86c8e0b70d19d253c64f828b144", + "seed_map": "66464f34f733e698385e7930074aea50e3d352181d0e9731ef0a699fec2c85ed", + "seed_protocol": "be8c5cd773e3be74e4c9d87f18bd5a42a3307f20b53985c2489dbc13937e796e", "source_manifest": "dc3879886d2a69f20fb982a675d7fb322c0e4017afef6471be54b0ee3cbd2af6", "take_up": "9522ce40f7dea569312dd7a7beb474e5a5afadd2f1e10cb5876534c3ef623d35", "tail": "565f0ceeadab69d3e96a886a00dd0305f7425fa3acde24d12ba48db2b37d5fc0", diff --git a/packages/microcosm-build/src/microcosm/build/us_runtime/ssi_take_up.py b/packages/microcosm-build/src/microcosm/build/us_runtime/ssi_take_up.py index 6bac673dfa..c8f7334eed 100644 --- a/packages/microcosm-build/src/microcosm/build/us_runtime/ssi_take_up.py +++ b/packages/microcosm-build/src/microcosm/build/us_runtime/ssi_take_up.py @@ -1643,7 +1643,7 @@ def us_ssi_take_up_delivery_gate( ``enforcement_fences`` fences normally-enforced bands for one builder arm with a documented adjudication (the under-18 pattern extended). The US builder passes them on its ``--dense-default-dataset`` arm - only: on that arm's two observed full-pool runs, microcosm#508 + only: on that arm's two observed full-pool frames, microcosm#508 delivered-weight recomputes have not landed the adult pair in band — P2's clean one-retry record, and P3's delivered-basis chain that ``ssi_take_up_prior_basis_from_artifact`` now refuses outright diff --git a/packages/microcosm-build/tests/engine_free/shared/test_spec_engine_loader.py b/packages/microcosm-build/tests/engine_free/shared/test_spec_engine_loader.py index 7bbb633369..e2202ac75e 100644 --- a/packages/microcosm-build/tests/engine_free/shared/test_spec_engine_loader.py +++ b/packages/microcosm-build/tests/engine_free/shared/test_spec_engine_loader.py @@ -32,7 +32,7 @@ def test_semantic_hash_has_golden_vector_and_surface_separation(tmp_path) -> Non # kernels' bytes too. # microcosm#1641's docstrings in solve and ssi_take_up move it again. assert first.spec_sha256 == ( - "8dabc127136d86cc25d4149754c567d427e16a2029938c1d4808ca32b933890c" + "bd93079b79cb2bebb0da292082241a9a1ad27693bb15dbfed7d93376eb9a0f18" ) second_root = _rich_minimal(tmp_path / "xy", note="second", store="local:b") diff --git a/packages/microcosm-build/tests/engine_workflow/us/test_us_multispine_pool_tool.py b/packages/microcosm-build/tests/engine_workflow/us/test_us_multispine_pool_tool.py index af33f0f80d..2e9cd07a57 100644 --- a/packages/microcosm-build/tests/engine_workflow/us/test_us_multispine_pool_tool.py +++ b/packages/microcosm-build/tests/engine_workflow/us/test_us_multispine_pool_tool.py @@ -363,7 +363,7 @@ def capture_equality(expected: object, actual: object) -> None: # microcosm#1543's fit input checks in microcosm.fit.qrf move it again. # microcosm#1641 moves it again: docstrings in solve and # ssi_take_up, and the calibration contract's renamed modes. - "spec_sha256": "ce49749a0e1118886dbfeeddb17e2d94e22c099f7742579caf20b85ed4193652", + "spec_sha256": "7ee3e8499a9bf73df25f38d2e3c8f598907ac6cdba8bd1a9c45f58fcb389b266", }, } diff --git a/packages/microcosm-calibrate/src/microcosm/calibrate/solve.py b/packages/microcosm-calibrate/src/microcosm/calibrate/solve.py index 949aa06617..e55a42a470 100644 --- a/packages/microcosm-calibrate/src/microcosm/calibrate/solve.py +++ b/packages/microcosm-calibrate/src/microcosm/calibrate/solve.py @@ -1641,7 +1641,7 @@ def _optimize_proximal( final = (torch.clamp(ratio, min=0.0) * w0_t).detach().numpy().astype(np.float64) # Make sub-threshold residuals exact zeros so the reported n_nonzero and the - # shipped dataset agree on which records survived. + # returned weights agree on which records survived. final[final <= prune_atol] = 0.0 if max_weight_ratio is not None: final = np.minimum(final, max_weight_ratio * w0) diff --git a/packages/microcosm-calibrate/tests/engine_free/shared/test_solve.py b/packages/microcosm-calibrate/tests/engine_free/shared/test_solve.py index 540657a3d3..7b52e4ccd8 100644 --- a/packages/microcosm-calibrate/tests/engine_free/shared/test_solve.py +++ b/packages/microcosm-calibrate/tests/engine_free/shared/test_solve.py @@ -1476,10 +1476,10 @@ def test_calibration_result_reports_weight_concentration(feasible_frame) -> None def test_refit_l0_selection_threads_l2_lambda_to_refit() -> None: - """The refit stage — the weights that ship — receives its own L2 penalty. + """The refit stage, which sets the returned weights, receives its own L2 penalty. The refit previously hardcoded ``l2_lambda=0.0``, so a concentration - penalty could shape support selection but never the published weights. + penalty could shape support selection but never the returned weights. The regression contract is *threading*, pinned via the recorded solver options: exactly what the hardcoded zero would have violated. diff --git a/packages/microcosm-graph/tests/fixtures/parity/kernels/calibrate/pins.json b/packages/microcosm-graph/tests/fixtures/parity/kernels/calibrate/pins.json index b4f1103099..da0abddedc 100644 --- a/packages/microcosm-graph/tests/fixtures/parity/kernels/calibrate/pins.json +++ b/packages/microcosm-graph/tests/fixtures/parity/kernels/calibrate/pins.json @@ -1 +1 @@ -{"dependencies":{"numpy":"2.4.6","pandas":"3.0.3","scipy":"1.17.1","torch":"2.12.0"},"implementation_hash":"9695adced75ad8cae90d60d2702009ec9ab05e993ac5bce46f3c5f8703b4bc58","kernel":"calibrate.adam@1","node":"calibrate","node_key":"50c6ecdd91383554c96f772e6fd81582a8795ba3346e7dd210d48b6f62b5d7c6","numeric":"bitwise","platform":"arm64/darwin/py3.14","platforms":{"arm64/darwin/py3.14":{"direct":"direct.csv","node_key":"50c6ecdd91383554c96f772e6fd81582a8795ba3346e7dd210d48b6f62b5d7c6"}},"seed":0} +{"dependencies":{"numpy":"2.4.6","pandas":"3.0.3","scipy":"1.17.1","torch":"2.12.0"},"implementation_hash":"3df328c2d5f449de45a543be8b5f4caf0cf2ff417542b0dc1251c7e4bfd33e64","kernel":"calibrate.adam@1","node":"calibrate","node_key":"98df2301f04fc79ffe90a07306a51d4fa8ad0cda6777d480ae6c172adef20dfe","numeric":"bitwise","platform":"arm64/darwin/py3.14","platforms":{"arm64/darwin/py3.14":{"direct":"direct.csv","node_key":"98df2301f04fc79ffe90a07306a51d4fa8ad0cda6777d480ae6c172adef20dfe"}},"seed":0} diff --git a/tools/us_bundle_generation/contracts.py b/tools/us_bundle_generation/contracts.py index 0161777710..4cf286ecd3 100644 --- a/tools/us_bundle_generation/contracts.py +++ b/tools/us_bundle_generation/contracts.py @@ -1501,7 +1501,8 @@ def build_calibration_contract() -> dict[str, object]: # mode shares the solver block. Its kernel and l0_contract.default_mode # are set by hand to the l0_refit arm's, and # _fiscal_release_cli_defaults reads its other defaults from a builder - # parse with neither flag set. + # parse with neither flag set. solver.l0.mode keeps the approved binding + # literal exact_k_projection, which neither of those sets. "release_modes": { "l0_refit": { "kernel": _kernel_ref(solve.calibrate_l0_refit),