98 lines
4.9 KiB
Python
98 lines
4.9 KiB
Python
#!/usr/bin/env python3
|
|
"""Close the #2479 dichotomy-wave contract for task_persist in ONE
|
|
process (submit → approved → building → verifying → closed), with SHA
|
|
evidence. Run with CS_RUST_LIB pointing at a built capability_scoring .so."""
|
|
import json
|
|
import sys
|
|
from pathlib import Path
|
|
|
|
sys.path.insert(0, str(Path(__file__).resolve().parents[1] / "src"))
|
|
|
|
PARITY_SHA = sys.argv[1] if len(sys.argv) > 1 else ""
|
|
PHASEB_SHA = sys.argv[2] if len(sys.argv) > 2 else ""
|
|
if not PARITY_SHA:
|
|
sys.exit("usage: walk_close_contract_task_persist.py <parity_sha> [phaseb_sha]")
|
|
|
|
from rune.construction_interface import ConstructionInterface
|
|
|
|
iface = ConstructionInterface(builder="factory-gap-tp")
|
|
|
|
r = iface.submit_need(
|
|
"Port task_persist to FULL Rust (#2479 dichotomy tranche, RUST "
|
|
"verdict): the 5 PARTIAL gaps (_save, export, restore, main, "
|
|
"handle_hook) plus hardening of the 5 matched fns — PYTHON-JSON byte "
|
|
"contract (insertion-order keys via serde_json preserve_order, "
|
|
"ensure_ascii \\uXXXX escapes with surrogate pairs, ', '/': ' compact "
|
|
"and indent=2 pretty separators, integral floats rendering '2.0'), "
|
|
"json.JSONDecodeError message parity on the frozen corpus classes "
|
|
"(Expecting value / property name / ',' delimiter / Extra data), "
|
|
"fcntl.flock(LOCK_EX) mirrored with libc::flock over the whole "
|
|
"read-modify-write, atomic '<path>.tmp'+fsync+rename ledger writes, "
|
|
"str[:80] CODEPOINT truncation law, Python truthiness guards (empty "
|
|
"strings do not update), argparse dispatcher with exact usage/error "
|
|
"text at COLUMNS=80, KeyError/AttributeError/TypeError crash-class "
|
|
"envelopes, and the handle_hook on_session_end save with 120-codepoint "
|
|
"error truncation. No-clock/no-path laws: now and ledger paths are "
|
|
"always arguments. Frozen truth 75 cases from the live oracle via the "
|
|
"shared harness + tp_freeze_seams sitecustomize rig (per-case sandbox "
|
|
"dirs, aware frozen clock, COLUMNS pin, <sd> path normalization) — "
|
|
"byte-identical regeneration and freeze_truth.py --verify --module "
|
|
"rune.task_persist OK; frozen battery replays all 75 verbatim; live "
|
|
"parity tp_parity binary == frozen truth == live oracle 75/75 (100%).",
|
|
origin="builder",
|
|
)
|
|
print("submit_need:", json.dumps(r)[:200])
|
|
if not r.get("success"):
|
|
sys.exit(1)
|
|
cid = r["ids"]["contract_id"]
|
|
print("contract_id:", cid)
|
|
|
|
for phase in ("approved", "building", "verifying"):
|
|
t = iface.transition(cid, phase)
|
|
if not t.get("success"):
|
|
print(f"transition->{phase} FAILED:", json.dumps(t)[:300])
|
|
sys.exit(1)
|
|
print("walked to verifying")
|
|
|
|
c = iface.close(cid, observed_evidence=[{
|
|
"kind": "port_evidence",
|
|
"detail": (
|
|
f"task_persist RUST dichotomy completion — parity commit {PARITY_SHA}"
|
|
+ (f", Phase B commit {PHASEB_SHA}" if PHASEB_SHA else "")
|
|
+ "; fn coverage 5/10 PARTIAL -> 10/10 FULL (audit CURRENT "
|
|
"instrument; docs/dichotomy-rebase-honest-audit.md row 'task_persist "
|
|
"269 10/10 RUST'); frozen-truth battery replays 75 cases byte-identical "
|
|
"(src/rust/task_persist/src/frozen_tp_truth.json, generated from the "
|
|
"live oracle through scripts/gen_task_persist_gap_truth.py + the "
|
|
"scripts/tp_freeze_seams sitecustomize rig — re-run regenerates "
|
|
"byte-identical; shared-harness verify: freeze_truth.py --verify "
|
|
"--module rune.task_persist OK); live parity via the built tp_parity "
|
|
"binary 75/75 (100%) across all 10 fns (scripts/"
|
|
"check_task_persist_parity.py); cargo build/clippy -D warnings/"
|
|
"rustfmt clean; Python suite tests/test_task_persist.py 8 passed "
|
|
"under BOTH pins (RUNE_TASK_PERSIST_CORE unset and =python — the env "
|
|
"is inert by design, no delegation seam). Documented divergences: "
|
|
"NaN/Infinity ledger literals treated as corrupt (Python json accepts "
|
|
"them); -h/--help argparse render not ported; JSONDecodeError message "
|
|
"parity covers the frozen corpus classes; lone surrogates "
|
|
"unrepresentable in serde Values; CLI crash tracebacks surface as "
|
|
"__CRASH__:<envelope> on stdout (path-dependent traceback text stays "
|
|
"out of the corpus). Evidence: verification/tp-*.log, tp-summary.md."
|
|
),
|
|
}], scope_files=[
|
|
"src/rune/task_persist.py",
|
|
"src/rust/task_persist/Cargo.toml",
|
|
"src/rust/task_persist/src/lib.rs",
|
|
"src/rust/task_persist/src/tpops.rs",
|
|
"src/rust/task_persist/src/frozen_tp_battery.rs",
|
|
"src/rust/task_persist/src/frozen_tp_truth.json",
|
|
"src/rust/task_persist/src/bin/tp_parity.rs",
|
|
"scripts/gen_task_persist_gap_truth.py",
|
|
"scripts/check_task_persist_parity.py",
|
|
"scripts/tp_freeze_seams/sitecustomize.py",
|
|
"tests/test_task_persist.py",
|
|
"scripts/walk_close_contract_task_persist.py",
|
|
])
|
|
print("close:", json.dumps(c)[:300])
|
|
print("CONTRACT", cid, "closed" if c.get("success") else "CLOSE_FAILED")
|