Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions changelog.d/us-base-engine-lock-check-once.changed.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
The US base stage checks the policyengine-us lock file (`engine_abi.lock.json`) once in the `--stage all` process instead of in every step process and QRF worker. The parent hands each step process a record of its check (lock file SHA-256, installed policyengine-us version and take-up and sources domain digest, in `MICROCOSM_ENGINE_ABI_LOCK_CHECK_RECORD`), and `run_primary_puf_qrf_chain` hands every QRF worker it starts the record of its caller's own check, so the QRF workers of `tools/build_us_multispine_pool.py` and of the release tool's stacked spine skip the derivation too. A child with its parent's record compares those three values instead of building two tax-benefit systems, and refuses to run when any differs. Processes without a record from their parent still run the full check. `microcosm.calibrate.solve` now imports torch inside the functions that use it, so importing `microcosm.calibrate` no longer imports torch. Together these cut a step process start from about 38 s and 1.5 GB peak resident memory to about 6 s and 0.3 GB, and a QRF worker start from about 37 s and 1.75 GB to about 8 s and 0.3 GB, on a 10-core Mac. The QRF worker identity digest changes once: its import trace no longer opens `gate_shadow.py`, `multispine_pool.py` or `us_late_overlap_ownership.py`, and imports fewer standard-library and third-party modules. The seed-protocol and seed-map digests and the US `spec_sha256` pins move because `solve.py` and `puf_qrf_chain.py` are attested kernel sources; no draw or data output changes. UK full builds re-solve once after this merges: `calibrate.adam@1`, whose hash every UK solve kernel embeds, and `uk.full.problem@1` both hash `calibrate.solve`, so a build run with `--require-solve-reuse` against a graph store written before the merge stops with `SolveReuseError`. So merge before a UK build that writes the store or after the build that reuses it, not between the two.
16 changes: 8 additions & 8 deletions docs/evidence/spec-engine/us-f0-coverage.json
Original file line number Diff line number Diff line change
Expand Up @@ -1642,13 +1642,13 @@
"compiler_ir.node_slices"
],
"expected": {
"map_sha256": "20648ca766969baf424f491150ab3d12b3edeb89a0544433e64e88c8efb42bb2",
"protocol_sha256": "c321797d65496f01b3186c83dee038c10dec9ed504d1d08a84b452d5f6538c15"
"map_sha256": "9c809470367a211c88ba047211ad9461850ca56100af41d56d807312ee8ccd5f",
"protocol_sha256": "eea4cf01a4924295e760edbe74e368dc6a48d66334ffe9a04d2fa13beebee2c5"
},
"failures": [],
"observed": {
"map_sha256": "20648ca766969baf424f491150ab3d12b3edeb89a0544433e64e88c8efb42bb2",
"protocol_sha256": "c321797d65496f01b3186c83dee038c10dec9ed504d1d08a84b452d5f6538c15"
"map_sha256": "9c809470367a211c88ba047211ad9461850ca56100af41d56d807312ee8ccd5f",
"protocol_sha256": "eea4cf01a4924295e760edbe74e368dc6a48d66334ffe9a04d2fa13beebee2c5"
},
"status": "covered"
},
Expand All @@ -1663,7 +1663,7 @@
"compiler_ir.seed_stream_map"
],
"expected": {
"implementation_sha256": "c321797d65496f01b3186c83dee038c10dec9ed504d1d08a84b452d5f6538c15",
"implementation_sha256": "eea4cf01a4924295e760edbe74e368dc6a48d66334ffe9a04d2fa13beebee2c5",
"protocol": "legacy-v1",
"streams": [
"build_model",
Expand All @@ -1684,7 +1684,7 @@
},
"failures": [],
"observed": {
"implementation_sha256": "c321797d65496f01b3186c83dee038c10dec9ed504d1d08a84b452d5f6538c15",
"implementation_sha256": "eea4cf01a4924295e760edbe74e368dc6a48d66334ffe9a04d2fa13beebee2c5",
"protocol": "legacy-v1",
"streams": [
"build_model",
Expand Down Expand Up @@ -2585,7 +2585,7 @@
"country": "us",
"schema_id": "country_spec",
"schema_version": 1,
"spec_sha256": "b94bfc6a5742de010443938a676d4d34e70df80dd405f89e2ff7a70f747c8107"
"spec_sha256": "4c3c3beab01e381aadfea510f61ca28117670d35c6bed1e4bb0df2fa1be07b2e"
}
},
"report_schema_version": 3,
Expand All @@ -2595,7 +2595,7 @@
"country": "us",
"schema_id": "country_spec",
"schema_version": 1,
"spec_sha256": "b94bfc6a5742de010443938a676d4d34e70df80dd405f89e2ff7a70f747c8107"
"spec_sha256": "4c3c3beab01e381aadfea510f61ca28117670d35c6bed1e4bb0df2fa1be07b2e"
},
"status": "pass"
}
11 changes: 10 additions & 1 deletion docs/spec-engine.md
Original file line number Diff line number Diff line change
Expand Up @@ -411,7 +411,16 @@ final_owner_stage: …
compilation; engine bumps fail closed until the lock is regenerated
and every bundle-owned treatment re-reviewed. The engine owns its
facts; the bundle owns treatments and pipelines; neither derives from
the other at build time.
the other at build time. A process that passed the comparison (fully, or
by matching its own parent's record) can pass the processes it starts a
record of it in
`MICROCOSM_ENGINE_ABI_LOCK_CHECK_RECORD` (the lock file's SHA-256, the
installed policyengine-us version and a digest of the take-up and
sources domains, bound to the issuing process ID). A direct child
compares those three values instead of deriving the lock again and
refuses to run when any differs. In the US base stage, the `--stage all`
process passes its record to each step process, and each step process
passes a record of its own check to the QRF workers it starts.
- Column/entity mapping comes from the ABI projection with a
**total-and-injective assertion** (the suffix naming rule died on
`takes_up_eitc`/`takes_up_dc_ptc`).
Expand Down
19 changes: 19 additions & 0 deletions packages/microcosm-build/src/microcosm/build/country_spec.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@
"ResolvedCountrySpec",
"country_resource",
"country_stage_plan",
"country_engine_abi_lock_check_environment",
"load_country_take_up_contract_projection",
"load_country_spec",
"load_gates_manifest",
Expand Down Expand Up @@ -2057,6 +2058,24 @@ def _select_take_up_compatibility_payload(
return projection


def country_engine_abi_lock_check_environment(country: str) -> dict[str, str]:
"""Hand this process's check of a country's lock file to a child process.

The result holds the record of the check of the packaged
``engine_abi.lock.json`` (the package directory that
:func:`load_country_take_up_contract_projection` reads) that this process
passed, or is empty when no attested check passed here; see
:func:`microcosm.build.spec_engine.engine_abi.engine_abi_lock_check_environment`.
"""

from microcosm.build.spec_engine.engine_abi import (
engine_abi_lock_check_environment,
)

root = Path(str(importlib_resources.files("microcosm.build").joinpath(country)))
return engine_abi_lock_check_environment(root)


def load_country_take_up_contract_projection(
country: str | Path,
) -> Mapping[str, Any] | None:
Expand Down
Loading
Loading