Files
rune/scripts/close_contract_memory_store_io.py
Nick 763ae54874 chore(store): close memory_store IO-family dichotomy contract BUILDER-2026-10-14T21:20:59Z-fce64d-factory-heavy-ms-io (parity aed3c27c, phase B 599978d9)
One-process walk approved->building->verifying->closed via iface.close()
(observed_evidence + scope_files). Evidence: scripts/close_contract_memory_store_io.py,
verification/ms-io-*. Battery 53/53, live parity 22/22, module audit 68/68
with both lanes merged.
2026-10-15 02:03:26 +01:00

142 lines
6.1 KiB
Python

#!/usr/bin/env python3
"""Close the #2479 dichotomy-wave memory_store IO-family gap contract (GO
port, HEAVY-PORT lane rune-wave-dm). Full lifecycle walk in ONE process
(shared-store clobber hazard). Safe to re-run: pass the existing contract
id to resume an interrupted walk.
Carries the already-pushed parity SHAs as evidence:
feat <FEAT> close IO-family gaps — dichotomy wave (30/68 -> 59/68)
refactor <PHASEB> Phase B language-advantage pass
Usage: close_contract_memory_store_io.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 = "770dac59"
PHASEB_SHA = "e8a97036"
EVIDENCE = f"parity {PARITY_SHA}, phase B {PHASEB_SHA}"
NEED = (
"memory_store IO/SCHEMA/LIFECYCLE family dichotomy gap-close (GO, "
"HEAVY-PORT lane rune-wave-dm): name-preserving port of the 27 "
"audit-missing IO-family functions into src/go/memory-store-deep/"
"gaps_io.go (new family file, sibling files untouched) — nowIso, "
"ctxBudget, Embed, tempJson, entitiesToJson, aaakSummary, "
"autoAssociate, dfWord, runLexiconReconcile, ensureMemoryTypeColumn, "
"FtsDelete, reindexEntries, addChunk, extractEpub, mineFile, "
"mineDirectory, wakeUp, storageBackend/ReadQuery, statsForPath, "
"associate, linkedEntries, makeScene, sceneEntries, listScenes, "
"hierarchy, handleHook. SQLite stays facade-side (modernc, landed "
"crate seams); vec0 tables are plain tables with oracle-except-path "
"degradation; FTS5 contentless indexes are real. Fix-first: removed "
"the function-local import subprocess breaking mine_file html "
"(proven (1, '') after). Frozen truth 53 rows via the shared harness "
"pattern (declarative setup-SQL fixtures, clock-free), byte-identical "
"across regenerations; battery truth_io_test.go 53/53; live parity "
"22/22; gofmt+vet+build clean; Python suite live pin 87 passed, "
"python pin failure set byte-identical to stashed base (23 "
"pre-existing). Dichotomy audit 30/68 -> 59/68; remaining 9 missing "
"are the sibling lane's retrieval/ranking family. Delivered on "
"gitea/master: feat " + PARITY_SHA + ", phase B " + PHASEB_SHA + "."
)
iface = ConstructionInterface(builder="factory-heavy-ms-io")
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
r = iface.close(
cid,
observed_evidence=[{
"kind": "port_evidence",
"detail": "memory_store IO-family dichotomy completion — parity "
f"{PARITY_SHA} feat(memory-store-deep): close IO-family "
"gaps (HEAVY-PORT lane rune-wave-dm); pushed gitea/"
"master (ancestor-verified after two sibling-race "
"rebases; observations.jsonl union-resolved). Go port at "
"src/go/memory-store-deep/gaps_io.go (NEW family file, "
"sibling files untouched) closes all 27 IO-family audit "
"name-forms. Generator scripts/"
"gen_memory_store_io_truth.py: 53-row frozen truth "
"(declarative setup-SQL fixtures + files map, "
"clock-free) regenerates byte-identical; battery "
"truth_io_test.go replays 53/53; live parity scripts/"
"check_memory_store_io_parity.py 22/22 (oracle-vs-"
"truth drift + go battery + rebuild/reconcile "
"contracts); gofmt+vet+go build ./...+go test ./... "
"clean (sibling batteries included); Python live pin 87 "
"passed, python pin failure set byte-identical to the "
"stashed base (23 pre-existing, retired _py_* "
"stranglers). Fix-first: removed the function-local "
"import subprocess breaking mine_file html (proven "
"(1, '') after). Phase B "
f"{PHASEB_SHA}: sibling integration (truncateRunesIO/"
"FtsDeleteDB rename after the retrieval lane's "
"gaps_retrieval.go landed mid-flight; same semantics, "
"per-file ownership) + determinism tiebreaks "
"(hierarchy count-desc/name-asc, wakeUp id-ASC, "
"mineDirectory top-level node_modules pruning) — "
"behavior-identical, battery + parity re-green. Module "
"audit 68/68 with both lanes merged; vec0 tables are "
"plain tables with oracle-except-path degradation "
"(documented).",
}],
scope_files=[
"src/go/memory-store-deep/gaps_io.go",
"src/go/memory-store-deep/truth_io.json",
"src/go/memory-store-deep/truth_io_test.go",
"src/rune/memory_store.py",
"scripts/gen_memory_store_io_truth.py",
"scripts/check_memory_store_io_parity.py",
"scripts/open_contract_memory_store_io.py",
"scripts/close_contract_memory_store_io.py",
"verification/summary-ms-io.md",
],
)
print("close:", json.dumps(r)[:400])
final = phase_of(cid)
print("FINAL PHASE:", final)
ok = r.get("success") and final == "closed"
print("CLOSED" if ok else "CLOSE_FAILED", cid)
sys.exit(0 if ok else 1)