Files
rune/scripts/walk_close_contract_cache.py
T

89 lines
3.9 KiB
Python

#!/usr/bin/env python3
"""Walk + close the #2479 dichotomy-wave contract for cache in ONE
process (draft -> approved -> building -> verifying -> closed).
CS_RUST_LIB must point 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"))
from rune.construction_interface import ConstructionInterface
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 and PHASEB_SHA):
sys.exit("usage: walk_close_contract_cache.py <parity_sha> <phaseb_sha>")
iface = ConstructionInterface(builder="factory-gap-ca")
r = iface.submit_need(
"Close the cache dichotomy PARTIAL gaps (#2479 tranche, GO "
"verdict): port the eleven audit-named missing oracle fns "
"name-preserving 1:1 (_record_hit, _record_miss, flush_stats, "
"get_cache, put_cache, invalidate_scope, invalidate_all, _now_ts, "
"_parse_ts, cache_stats, handle_hook) with the in-memory hit/miss "
"accumulation (threshold 50 / interval 30s), INVALIDATION_MAP, the "
"full schema (both indexes) and an oracle-byte-parity CLI; clock/"
"monotonic/DB behind Env seams; freeze oracle truth via the shared "
"scripts/freeze_truth.py harness (78 cases, every freezable branch, "
"sandboxed RUNE_MEMORY_DIR) embedded VERBATIM in the Go battery; "
"live parity 100% on the new fns via the CLI surface; all existing "
"tests green; gofmt + vet + build clean; Phase B language-advantage "
"pass (pooled *sql.DB, half-work ContentHash, Builder Compress).",
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"cache GO dichotomy gap-close — parity commit {PARITY_SHA}, "
f"Phase B commit {PHASEB_SHA}; dichotomy audit fn coverage "
"6/17 -> 17/17 FULL; frozen-truth battery 78 cases vs live "
"oracle (scripts/gen_cache_truth.py, byte-identical regen + "
"freeze_truth.py --verify green in a fresh sandbox); Go "
"battery replays frozen truth verbatim + threshold/interval "
"flush seam pins + now-rendering + PLUGIN manifest + 16-case "
"CLI live parity; standalone live parity 100% (16/16) via "
"scripts/check_cache_parity.py re-run green after Phase B and "
"after the rebase; go test green, gofmt/vet/build clean, "
"Python oracle battery 12 passed both pins (delegation live "
"and RUNE_CACHE_CORE=python). Documented divergences: argparse "
"stderr/exit-2 machinery bytes (stdout usage gates ported "
"byte-exactly); the 30s interval flush branch is pinned by "
"both batteries' seams (not freezable — no oracle fn can idle "
"30s). No other divergences: pending-hit visibility, upsert "
"stat preservation, .0f half-even hit_rate, rune-slice "
"truncation and ensure_ascii rendering are mirrored 1:1 and "
"pinned by both batteries."
),
}], scope_files=[
"src/rune/cache.py",
"src/go/cache/main.go",
"src/go/cache/cache.go",
"src/go/cache/cache_hash.go",
"src/go/cache/compress.go",
"src/go/cache/pyjson.go",
"src/go/cache/cache_test.go",
"src/go/cache/truth_hash_test.go",
"src/go/cache/frozen_truth.json",
"scripts/gen_cache_truth.py",
"scripts/check_cache_parity.py",
"tests/test_cache.py",
"verification/summary-cache.md",
])
print("close:", json.dumps(c)[:300])
print("CONTRACT", cid, "closed" if c.get("success") else "CLOSE_FAILED")