#!/usr/bin/env python3 """Close the #2479 dichotomy-wave hook_engine gap contract (GO port). Full lifecycle walk in ONE process (shared-store clobber hazard; segment transitions take ~60s each over ~610 segments — do NOT split across processes). Carries the already-pushed SHAs as evidence: feat cba7c986 close PARTIAL gaps — dichotomy wave (parity) ref d38a4317 Phase B language-advantage pass Usage: close_contract_hook_engine.py """ import json import sys from pathlib import Path sys.path.insert(0, str(Path(__file__).resolve().parents[1] / "src")) from rune.construction_interface import ConstructionInterface PARITY_SHA = "cba7c986" PHASE_B_SHA = "d38a4317" EVIDENCE = f"parity {PARITY_SHA}; phase B {PHASE_B_SHA}" iface = ConstructionInterface(builder="factory-gap-he") r = iface.submit_need( "hook_engine dichotomy gap-close (GO): name-preserving port of the 5 " "unmatched placement-engine functions (discover_functions, " "tag_function, validate_placements, generate_report, handle_hook plus " "auto_tag companion) into src/go/hook-engine, IO behind injectable " "seams, frozen-truth battery (truth_gap.json, 14 cases / 8 fns) " "generated against the live Python oracle, gofmt/vet clean; Phase B " "memoization (placement computed once, bytes identical) + the " "oracle's main() CLI (scan/recommend/validate/report/hook). Battery " "7/7 green, CLI smoke verified (scan 265 discovered / 12 tagged). " "Delivered on gitea/master: feat " + PARITY_SHA + ", Phase B " + PHASE_B_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)