Files
rune/scripts/close_contract_cron_engine.py
T
Nick 666e9a84a9 chore(store): close cron_engine dichotomy contract BUILDER-2026-10-14T01:32:43Z-61be7a-factory-gap-ce (parity 4204667f, phase B folded)
Walked submit→approved→building→verifying in one process, closed via the
contract_quality evidence path (port_evidence: 27/27 FULL audit, 46-case
byte-identical frozen truth + regen, gap replay 46/46, legacy 25/25, live
parity 3/3, CLI byte-identical both pins; verification/ce-*).
2026-10-14 03:45:22 +01:00

90 lines
3.8 KiB
Python

#!/usr/bin/env python3
"""Close the #2479 dichotomy-wave cron_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 SHA as evidence:
feat c113b8e6 close PARTIAL gaps — dichotomy wave (Phase B folded)
Usage: close_contract_cron_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 = "c113b8e6"
EVIDENCE = f"parity {PARITY_SHA}; phase B folded into the parity commit"
iface = ConstructionInterface(builder="factory-gap-ce")
r = iface.submit_need(
"cron_engine dichotomy gap-close (GO): name-preserving port of the 14 "
"unmatched functions (get_cron_engine singleton family, run_task "
"method+module, start_engine/stop_engine, to_dict, "
"fire_on_task_complete, stop, _run_loop, _parse_cron_field/"
"_should_run mirror-carried, _execute_task, _log_execution/_log_error "
"with 5MB rotation) into src/go/cron-engine, plus Python-exact "
"ordered _save/_load (insertion order + ensure_ascii + CronTask(**) "
"TypeError semantics), a shlex.split port with the oracle's ValueError "
"messages, pyISO isoformat parity, and subprocess error-message "
"translation (FileNotFoundError/PermissionError/TimeoutExpired str(e) "
"forms; nonzero exit is a returncode, not an error). IO behind "
"injectable clock/sleep/exec/recordFailure seams. Frozen-truth battery "
"(truth_gap.json, 46 cases / 12 wrapper fns) via the shared harness + "
"wrapper shims — byte-identical --verify and fresh re-freeze. gofmt/"
"vet/build clean; gap replay 46/46 + legacy 25/25 + 5 tests green; "
"live parity 3/3 scenarios (31 ops) oracle-vs-GO identical; CLI "
"byte-identical under both Python pins. dichotomy audit cron_engine "
"27/27 FULL. 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"):
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)
cres = iface.close(c, observed_evidence=[{
"kind": "port_evidence",
"detail": (
f"cron_engine GO dichotomy gap-close — parity commit {PARITY_SHA} "
f"(Phase B folded); dichotomy audit fn coverage 13/27 PARTIAL -> "
f"27/27 FULL (missing list emptied); 46-case frozen gap truth "
f"(scripts/gen_cron_engine_gap_truth.py wrapper shims — byte-identical "
f"--verify AND fresh re-freeze), gap replay 46/46 + legacy 25/25 + 5 "
f"Go tests green, gofmt/vet/build clean, live parity 3/3 scenarios "
f"(31 ops oracle-vs-GO identical via scripts/check_cron_engine_"
f"parity.py), CLI byte-identical under both Python pins. Evidence: "
f"verification/ce-* (exit codes + summary committed)."
),
}], scope_files=[
"src/rune/cron_engine.py",
"src/go/cron-engine/main.go",
"src/go/cron-engine/scenario.go",
"src/go/cron-engine/truth_gap.json",
"src/go/cron-engine/truth_gap_test.go",
"scripts/gen_cron_engine_gap_truth.py",
"scripts/check_cron_engine_parity.py",
])
print("close:", json.dumps(cres)[:300])
if not cres.get("success"):
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)