143 lines
6.4 KiB
Python
143 lines
6.4 KiB
Python
#!/usr/bin/env python3
|
|
"""Close the #2479 dichotomy-wave memory_store WORKING-SET/STATS family gap
|
|
contract (GO port, builder factory-heavy-ms-stats). Full lifecycle walk in
|
|
ONE process (shared-store clobber hazard). 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.
|
|
|
|
Carries the already-pushed parity SHA as evidence:
|
|
feat f55108dd close stats-family audit gaps — dichotomy wave
|
|
|
|
Usage: close_contract_memory_store_stats.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 = "f55108dd"
|
|
EVIDENCE = f"parity {PARITY_SHA}"
|
|
|
|
NEED = (
|
|
"memory_store WORKING-SET/STATS family dichotomy gap-close (GO): "
|
|
"name-preserving port of the 5 currently-audit-missing slice fns "
|
|
"into src/go/memory-store-deep/gaps_stats.go (NEW family file, "
|
|
"siblings untouched) — reindex_entries, wake_up, storage_backend, "
|
|
"stats_for_path, handle_hook. The 12 remaining slice fns "
|
|
"(working_set/get/clear, audit_append/verify, stats, touch, "
|
|
"memory_health_check, tier_demotion_sweep, _map_reduce, main) were "
|
|
"already landed by earlier waves — audit re-run FIRST per lane law; "
|
|
"only currently-unmatched fns ported. Seams per the landed crate's "
|
|
"law: wake_up's row-fetch stays facade-side (rows ride the truth "
|
|
"input); the rust read backend is an injectable probe+reader "
|
|
"(mems_loader is Python FFI machinery — availability + query traffic "
|
|
"is the contract); reindex's vec side runs on the plain-table "
|
|
"entries_vec mirror (production vec0 observed only through "
|
|
"COUNT/LEFT JOIN/DELETE/INSERT). Frozen truth 24 rows "
|
|
"(truth_stats_gaps.json) from the live oracle under pinned rigs "
|
|
"(HOME pin, frozen clock, _embed off/scripted, fake mems_loader via "
|
|
"sys.modules, RUNE_MEMORY_STORAGE juggling) — byte-identical across "
|
|
"regenerations. Battery gaps_stats_test.go replays canonically with "
|
|
"GAPS_TRUTH_PATH override; live parity 24/24 (fresh live-oracle "
|
|
"capture -> Go battery) via scripts/check_memory_store_stats_parity.py; "
|
|
"gofmt/vet/build/full-test clean; Python module suite failure sets "
|
|
"byte-identical across BOTH pins (RUNE_RETRIEVAL_CORE live + python; "
|
|
"9 pre-existing delegation/seam failures, none this port); ruff "
|
|
"clean. Documented divergences: contentless-FTS5 NULL text readback "
|
|
"(both engines agree, post-state rows pin it); json.dumps float-list "
|
|
"format mirrored by pyJSONFloatList (', ' separators, integral "
|
|
"floats keep '.0'); by_topic tie order is engine-shaped (fixtures "
|
|
"use distinct counts). Audit: memory_store 44/68 -> 51/68; slice "
|
|
"fully matched; read_query x2 counters (dm lane's slice) flipped "
|
|
"via this port's ReadQuery interface method name — name-collision "
|
|
"flip, NOT a dm port. Delivered on gitea/master: feat " + PARITY_SHA + "."
|
|
)
|
|
|
|
iface = ConstructionInterface(builder="factory-heavy-ms-stats")
|
|
|
|
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": "memory_store stats-family dichotomy completion — "
|
|
f"parity {PARITY_SHA} feat(memory_store): close "
|
|
"stats-family audit gaps — dichotomy wave; pushed "
|
|
"gitea/master after fetch+rebase (ancestor-verified). "
|
|
"Go kernels at src/go/memory-store-deep/gaps_stats.go "
|
|
"close the slice's audit gaps name-preserving (5 fns; "
|
|
"the full 17-fn slice incl. earlier-wave landings is "
|
|
"matched). Generator scripts/gen_memory_store_stats_truth.py: "
|
|
"24-row frozen truth from the live oracle under rigs "
|
|
"(frozen clock, _embed off/scripted, fake mems_loader "
|
|
"sys.modules injection, plain-table entries_vec mirror) "
|
|
"regenerates byte-identical (--check green twice). "
|
|
"Battery gaps_stats_test.go replays the truth "
|
|
"canonically; live parity scripts/"
|
|
"check_memory_store_stats_parity.py 24/24 (fresh "
|
|
"live-oracle capture through the Go battery via "
|
|
"GAPS_TRUTH_PATH); gofmt/vet/build/go test clean; "
|
|
"Python module suite both pins: failure sets "
|
|
"byte-identical (9 pre-existing, none this port); "
|
|
"ruff clean. Divergences documented in verification/"
|
|
"msstats-summary.md: contentless-FTS5 NULL text "
|
|
"readback; json.dumps float-list format (pyJSONFloatList "
|
|
"mirror); by_topic tie order engine-shaped; read_query "
|
|
"x2 counters flipped by the interface method name (dm "
|
|
"lane owns the fn).",
|
|
}],
|
|
scope_files=[
|
|
"src/go/memory-store-deep/gaps_stats.go",
|
|
"src/go/memory-store-deep/gaps_stats_test.go",
|
|
"src/go/memory-store-deep/truth_stats_gaps.json",
|
|
"scripts/gen_memory_store_stats_truth.py",
|
|
"scripts/check_memory_store_stats_parity.py",
|
|
"verification/msstats-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)
|