160 lines
7.4 KiB
Python
160 lines
7.4 KiB
Python
#!/usr/bin/env python3
|
|
"""Close the #2479 dichotomy-wave tool_executor fsops-family gap
|
|
contract (GO port, contract factory-heavy-te-fs). Full lifecycle walk in
|
|
ONE process (shared-store clobber hazard). The final step is iface.close()
|
|
with contract_quality observed_evidence (the bare `transition -> closed`
|
|
is rejected by the quality gate). Safe to re-run: pass the existing
|
|
contract id to resume an interrupted walk.
|
|
|
|
Carries the already-pushed parity SHA as evidence:
|
|
feat e07a6bf9 close fsops-family PARTIAL gaps — dichotomy wave (33/47 -> 43/47)
|
|
|
|
Usage: walk_close_contract_tool_executor_fsops.py [contract_id]
|
|
"""
|
|
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 = "e07a6bf9"
|
|
EVIDENCE = f"parity {PARITY_SHA}"
|
|
|
|
NEED = (
|
|
"tool_executor fsops-family dichotomy gap-close (GO): name-preserving "
|
|
"port of the 10 audit-missing FILESYSTEM/REPO/MEMORY tool fns "
|
|
"(_resolve_execution_cwd, _run_command, _edit_file, _glob_files, "
|
|
"_repo_map, _repo_map_fallback, _read_persona, _query_memory, "
|
|
"_check_growth, _diagnose_behavior) into src/go/tool-executor/"
|
|
"gaps_fsops.go. Kernels: execution-cwd precedence (explicit > "
|
|
"project registry > process; refusal wrap 'project execution "
|
|
"refused: …'); run_command argv/shell gate with TRUE shlex "
|
|
"tokenization (strings.Fields parity bug fixed), shell-syntax "
|
|
"refusal set, 30s timeout, stderr '[stderr]' merge, exit-code "
|
|
"suffix, 10000-CHAR truncation; edit_file exactly-once preview; "
|
|
"glob_files pathlib semantics (dotfiles matched per-segment, ** "
|
|
"crosses hidden dirs, a/** zero-dir — probed on 3.14) with "
|
|
"mtime-desc order; repo_map tree-sitter branch + native grep-regex "
|
|
"fallback (raw-readdir fts interleaving, 20-line cap per lang); "
|
|
"read_persona 5000-CHAR block slice; query_memory '[%.2f] text' "
|
|
"200-CHAR cap; check_growth [-limit:] semantics incl. limit=0 ALL "
|
|
"and negative-from-front, 100-CHAR detail cap, em-dash separator; "
|
|
"diagnose_behavior ordered issue scan + insertion-order "
|
|
"json.dumps(indent=2) diagnosis, CHAR text_length. Subprocess/IO "
|
|
"law: registry / memory store / tree-sitter / process-cwd / exec "
|
|
"behind injectable seams (undoDirFn precedent), battery pins "
|
|
"rig-mirroring fakes. Parity-defect fixes: paths.go write-denial "
|
|
"list now Python-repr (pyListRepr), argv-type isinstance gate. "
|
|
"Frozen truth 48 rows via the shared freeze_truth harness under "
|
|
"scripts/tefs_freeze_seams (fixed /tmp/tefs-freeze-rig root, HOME "
|
|
"pin, fixture registry store, memory_store stub, subprocess.run "
|
|
"patched for tree-sitter only), byte-identical across repeated "
|
|
"--verify runs; Go battery truth_fsops_test.go replays the truth "
|
|
"VERBATIM (48 rows + 10 hermetic seam units); live parity "
|
|
"scripts/check_tool_executor_fsops_parity.py 48/48 (live oracle vs "
|
|
"go test parity mode on the SAME rig tree); gofmt/vet/build clean; "
|
|
"full go test green; Python suite failure set byte-identical across "
|
|
"delegation-live and RUNE_*_CORE=python pins (228 pre-existing "
|
|
"failures, none touching this module); ruff clean. Divergences "
|
|
"(documented): interpreter-shaped exception text compared by class "
|
|
"+ prefix (quirk #31 family); edit diff markers-only (difflib hunk "
|
|
"shape); grep traversal order fs-shaped on both sides; timeout "
|
|
"branch battery/seam-only (30s wall). Dichotomy audit 33/47 PARTIAL "
|
|
"-> 43/47 FULL (92%); the remaining 4 fns (_execute_tool_now, "
|
|
"serialize/deserialize_prepared_tool, confirm_write) are the sibling "
|
|
"dispatch/prepared lane. Delivered on gitea/master: feat "
|
|
+ PARITY_SHA + "."
|
|
)
|
|
|
|
iface = ConstructionInterface(builder="factory-heavy-te-fs")
|
|
|
|
if len(sys.argv) > 1:
|
|
cid = sys.argv[1]
|
|
print("resuming contract:", cid)
|
|
else:
|
|
r = iface.submit_need(NEED, 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)
|
|
|
|
|
|
def phase_of(cid):
|
|
doc = iface.scaffold.load()
|
|
e = iface.scaffold.contract(doc, cid)
|
|
return e.get("phase") if e else "MISSING"
|
|
|
|
|
|
phase = phase_of(cid)
|
|
print("current phase:", phase)
|
|
for want in ("approved", "building", "verifying"):
|
|
if phase == want or phase in ("verifying", "closed"):
|
|
break
|
|
t = iface.transition(cid, want, evidence_ref=EVIDENCE)
|
|
ok = t.get("success")
|
|
print(f"transition->{want}:", "ok" if ok else json.dumps(t)[:300])
|
|
if not ok:
|
|
sys.exit(1)
|
|
phase = want
|
|
|
|
c = iface.close(
|
|
cid,
|
|
observed_evidence=[{
|
|
"kind": "port_evidence",
|
|
"detail": "tool_executor fsops-family completion — parity "
|
|
f"{PARITY_SHA} feat(tool_executor): close fsops-family "
|
|
"PARTIAL gaps — dichotomy wave; pushed gitea/master. Go "
|
|
"port at src/go/tool-executor/gaps_fsops.go closes the "
|
|
"family audit gaps name-preserving (33/47 -> 43/47 FULL, "
|
|
"92%; sibling dispatch lane keeps 4). Generator "
|
|
"scripts/gen_tool_executor_fsops_truth.py: 48-row frozen "
|
|
"truth (shared freeze_truth harness under scripts/"
|
|
"tefs_freeze_seams — fixed /tmp/tefs-freeze-rig root, "
|
|
"HOME pin, registry-store + memory_store stub fixtures, "
|
|
"subprocess.run patched for tree-sitter only) "
|
|
"regenerates byte-identical; freeze_truth --verify OK "
|
|
"twice against the live oracle. Battery "
|
|
"truth_fsops_test.go replays the truth VERBATIM (48 rows "
|
|
"+ 10 hermetic seam units for the "
|
|
"missing-file/malformed/crash-parity branches); live "
|
|
"parity scripts/check_tool_executor_fsops_parity.py "
|
|
"48/48 (live oracle vs go-test parity mode, same rig "
|
|
"tree); gofmt/vet/build + full go test green; Python "
|
|
"suite failure set byte-identical across delegation-live "
|
|
"and pinned runs; ruff clean. Parity-defect fixes: "
|
|
"pyListRepr write-denial message (paths.go), argv "
|
|
"isinstance gate + shlex tokenization (strings.Fields "
|
|
"bug). Divergences documented in verification/"
|
|
"tefs-summary.md (seam-pinned IO, interpreter-shaped "
|
|
"exception text by prefix, diff markers, fs-shaped grep "
|
|
"order).",
|
|
}],
|
|
scope_files=[
|
|
"src/go/tool-executor/gaps_fsops.go",
|
|
"src/go/tool-executor/truth_fsops.json",
|
|
"src/go/tool-executor/truth_fsops_test.go",
|
|
"src/go/tool-executor/parity_fsops_live_test.go",
|
|
"src/go/tool-executor/paths.go",
|
|
"scripts/tefs_freeze_seams/sitecustomize.py",
|
|
"scripts/gen_tool_executor_fsops_truth.py",
|
|
"scripts/check_tool_executor_fsops_parity.py",
|
|
"verification/tefs-summary.md",
|
|
],
|
|
)
|
|
print("close:", json.dumps(c)[:400])
|
|
final = phase_of(cid)
|
|
print("FINAL PHASE:", final)
|
|
ok = c.get("success") and final == "closed"
|
|
print("CLOSED" if ok else "CLOSE_FAILED", cid)
|
|
sys.exit(0 if ok else 1)
|