Files
rune/scripts/open_contract_contracts_gap.py
Nick 8f9835fb9b chore(store): close contracts dichotomy contract BUILDER-2026-10-13T17:54:28Z-10bd7d-factory-gap-ct (parity 11e4bd20)
gap-close 4/11 -> 11/11 (FULL): the 7 audit-missing fns (_ct_core,
_resolve_and_project, _run_contract_python, capture_signatures,
save_signatures, load_signatures, main as contracts_main) ported
name-preserving into src/rust/contracts with IO behind injectable
seams; 8 new doc-envelope FFI kernels via contracts_loader
(cs_free_string, never re-exported). Frozen truth ct_gap_truth.json
127 rows (harness --verify 23/23 byte-identical) embedded VERBATIM in
gap_battery; battery 19/19; live parity replay failures=0 (facade 30,
kernel 15); clippy -D warnings 0; fmt clean; pytest 6/6 both pins;
full-suite failure set byte-identical to base. One documented
eager/lazy divergence (projection-crash row) pinned both ways. Full
lifecycle walked in ONE process (approved->building->verifying->closed).
2026-10-13 18:57:28 +01:00

93 lines
4.2 KiB
Python

#!/usr/bin/env python3
"""Open + walk the gap-closing construction contract for contracts (Rust)
to closed. Full lifecycle in ONE process (builder=factory-gap-ct) — close-time
re-walk law: DRAFT → approved → building → verifying → closed."""
import json
import os
import sys
from pathlib import Path
ROOT = Path(__file__).resolve().parents[1]
os.environ["CS_RUST_LIB"] = str(
ROOT / "src" / "rust" / "capability_scoring" / "target" / "release" / "libcapability_scoring.so")
sys.path.insert(0, str(ROOT / "src"))
from rune.construction_interface import ConstructionInterface
iface = ConstructionInterface(builder="factory-gap-ct")
r = iface.submit_need(
"Close the PARTIAL gaps in src/rust/contracts against the "
"src/rune/contracts.py oracle (dichotomy wave, issue #2479 "
"tranche): name-preserving 1:1 port of the 7 unmatched functions "
"(_ct_core, _resolve_and_project, _run_contract_python, "
"capture_signatures, save_signatures, load_signatures, main), "
"IO behind injectable seams, frozen-truth battery generated against "
"the live Python oracle via the shared harness "
"scripts/freeze_truth.py (RUNE core pinned to python, deep-copied "
"inputs), existing tests green + clippy clean, live parity 100% on "
"the new functions, Phase B language-advantage pass.",
origin="builder",
)
print("submit_need:", json.dumps(r)[:300])
if not r.get("success"):
print("NEED FAILED — aborting")
sys.exit(1)
cid = r["ids"]["contract_id"]
print("contract_id:", cid)
for phase in ("approved", "building", "verifying"):
t = iface.transition(cid, phase)
print(f"transition->{phase}:", json.dumps(t)[:150])
if not t.get("success"):
sys.exit(1)
FEAT = os.environ.get("CT_FEAT_SHA", "66de70c7")
c = iface.close(cid, observed_evidence=[{
"kind": "port_evidence",
"detail": f"contracts dichotomy gap-close — {FEAT} feat(contracts): "
"close PARTIAL gaps — dichotomy wave (rebased onto "
"gitea/master and pushed; Phase B BTreeMap import + "
"rustfmt folded in). Audit contracts 4/11 -> 11/11 FULL. "
"All 7 audit-missing fns ported name-preserving into "
"src/rust/contracts (lib.rs) with IO behind injectable "
"seams (CoreProbe / Invoker / Signaturer / MainIO): "
"_ct_core gate, _resolve_and_project mapping, "
"_run_contract_python branch tree, run_all_contracts "
"loop, capture_signatures loop, save/load_signatures "
"byte-parity content kernels, contracts_main CLI "
"dispatch; 8 new FFI doc-envelope kernels (ct_gate, "
"ct_resolve, ct_run_python, ct_run_all, ct_capture, "
"ct_save, ct_load, ct_main) wired via contracts_loader "
"(cs_free_string, never re-exported). Frozen truth "
"ct_gap_truth.json 127 rows (23 shared-harness cases "
"byte-identical via freeze_truth --verify; extra: 30 "
"result rows, 15 delegated rows, run_all 42+42, 4 "
"probes, 5 file rows, 7 main rows) embedded VERBATIM in "
"gap_battery.rs; battery 19/19 green (12 gap + 7 prior); "
"live parity replay failures=0 (facade 30, kernel 15); "
"clippy --all-targets -D warnings 0; cargo fmt clean; "
"pytest tests/test_contracts_port.py 6/6 BOTH pins "
"(live + RUNE_CONTRACTS_CORE=python); full-suite failure "
"set byte-identical to base (118 pre-existing, none "
"new). One documented eager/lazy divergence "
"(projection-crash row): crash delegated vs PASS lazy "
"oracle — pinned both ways. Evidence: verification/"
"ct-gap-*.log in the worktree (paths in the agent "
"report).",
}], scope_files=[
"src/rune/contracts_loader.py",
"src/rust/contracts/src/lib.rs",
"src/rust/contracts/src/gap_battery.rs",
"src/rust/contracts/src/ct_gap_truth.json",
"scripts/ct_rig.py",
"scripts/ct_rig_badimport.py",
"scripts/gen_contracts_gap_truth.py",
"scripts/open_contract_contracts_gap.py",
])
print("close:", json.dumps(c)[:300])
if not c.get("success"):
print("CLOSE FAILED")
sys.exit(1)
print("CONTRACT", cid, "CLOSED")