Files
rune/scripts/close_contract_layout_contract.py
Nick 4402c4284b chore(store): close layout_contract dichotomy contract BUILDER-2026-10-14T05:21:12Z-4723a5-factory-gap-lc (parity 4bbed58d)
Walk draft->approved->building->verifying in one process; final entry
via close() per the quality-gate law (predicted-vs-observed
contract_quality computed; raw closed-transition refused — the first
walk attempt hit exactly that gate and completed through close()).
2026-10-14 06:25:44 +01:00

74 lines
2.9 KiB
Python

#!/usr/bin/env python3
"""Close the #2479 dichotomy-wave layout_contract gap contract (Rust port).
Full lifecycle walk in ONE process (shared-store clobber hazard; segment
transitions take ~60s each — do NOT split across processes). Carries the
already-pushed parity SHA as evidence:
feat 9ed9a7a2 close PARTIAL gaps — dichotomy wave-5
Usage: close_contract_layout_contract.py
"""
import json
import os
import sys
from pathlib import Path
os.environ.setdefault(
"CS_RUST_LIB",
"/mnt/workdrive/rune/src/rust/capability_scoring/target/release/libcapability_scoring.so",
)
sys.path.insert(0, str(Path(__file__).resolve().parents[1] / "src"))
from rune.construction_interface import ConstructionInterface
PARITY_SHA = "9ed9a7a2"
EVIDENCE = f"parity {PARITY_SHA}"
iface = ConstructionInterface(builder="factory-gap-lc")
r = iface.submit_need(
"layout_contract dichotomy gap-close (Rust): name-preserving port "
"of the 4 audit-missing functions (define_region, bind_component, "
"amend_layout_contract, record_layout_observation) into "
"src/rust/layout_contract/src/kernels.rs as pure doc-in/doc-out "
"kernels (now is an argument; structural_store merge law "
"replicated), FFI lc_define_region/lc_bind_component/"
"lc_amend_layout_contract/lc_record_observation + lc_replay, facade "
"delegation with ValueError translation and identity-preserving "
"absorb, freeze rig scripts/lc_freeze_seams (blanket + EXPLICIT "
"core pins, frozen clock on both now seams, doc-carrying wrappers), "
"35-case frozen corpus frozen_lc_gap_truth.json via the shared "
"harness verified byte-identical, gap_battery 10/10 (verbatim "
"replay + FFI roundtrip + branch proofs), clippy -D warnings clean, "
"live parity 35/35 + byte-identical re-freeze "
"(scripts/check_layout_contract_parity.py), layout+consumer tests "
"64/64 BOTH pins. Ladder caught and fixed 4 real divergences "
"pre-commit: re-bind assigns a fresh amendments ledger; identities "
"merge is wholesale key assignment (add_entity .update() law); "
"framework detail rides **framework_attrs (no named param); "
"serde_json preserve_order for insertion-order stability. Dichotomy "
"audit 2/6 PARTIAL -> 6/6 FULL (RUST). Delivered on gitea/master: "
"feat " + PARITY_SHA + ".",
origin="builder",
)
print("submit_need:", json.dumps(r)[:300])
if not r.get("success"):
print("NEED FAILED — aborting")
sys.exit(1)
c = r["ids"]["contract_id"]
print("contract_id:", c)
for phase in ("approved", "building", "verifying", "closed"):
t = iface.transition(c, phase, evidence_ref=EVIDENCE)
ok = t.get("success")
print(f"transition->{phase}:", "ok" if ok else json.dumps(t)[:300])
if not ok:
sys.exit(1)
doc = iface.scaffold.load()
e = iface.scaffold.contract(doc, c)
print("FINAL PHASE:", e.get("phase") if e else "MISSING")
if not e or e.get("phase") != "closed":
sys.exit(1)
print("CLOSED", c)