86 lines
3.7 KiB
Python
86 lines
3.7 KiB
Python
#!/usr/bin/env python3
|
|
"""Walk + close the #2479 dichotomy-wave contract for token_optimizer on the
|
|
FRESH master store (one process, per the shared-store clobber pattern)."""
|
|
import json
|
|
import sys
|
|
from pathlib import Path
|
|
|
|
REPO = Path(__file__).resolve().parents[1]
|
|
import os
|
|
|
|
if not os.environ.get("CS_RUST_LIB"):
|
|
os.environ["CS_RUST_LIB"] = str(
|
|
REPO / "src" / "rust" / "capability_scoring" / "target" / "release"
|
|
/ "libcapability_scoring.so")
|
|
|
|
sys.path.insert(0, str(REPO / "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_token_optimizer.py <parity_sha> <phaseb_sha>")
|
|
|
|
iface = ConstructionInterface(builder="factory-gap-to")
|
|
|
|
r = iface.submit_need(
|
|
"Close the PARTIAL gaps in src/rust/token_optimizer against the "
|
|
"src/rune/token_optimizer.py oracle (dichotomy wave, issue #2479 "
|
|
"tranche): the nine audit-named functions (get_optimizer construction "
|
|
"decision + FFI op with the _load partial-adoption quirk; _tc_core/"
|
|
"_to_core probe pin contracts; CacheEntry.to_dict; _to_state/"
|
|
"_apply_state transfer forms; _write_snapshot file-doc conversion; "
|
|
"_run_kernel op dispatch; _compress_context tc delegation mirror), "
|
|
"frozen-truth gap battery generated against the live oracle through "
|
|
"the to_freeze_seams rig (byte-identical --verify), Rust battery + "
|
|
"clippy -D warnings clean, live parity 60/60 (FFI construction rows, "
|
|
"40 dual-mode fuzz trials, module-API/singleton E2E), Python oracle "
|
|
"tests green under both pins, Phase B language-advantage pass.",
|
|
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(f"transition->{phase}: ok")
|
|
print("walked to verifying")
|
|
|
|
c = iface.close(cid, observed_evidence=[{
|
|
"kind": "port_evidence",
|
|
"detail": (
|
|
f"token_optimizer RUST dichotomy gap-close — parity commit {PARITY_SHA}, "
|
|
f"Phase B commit {PHASEB_SHA}; dichotomy audit fn coverage 16/25 PARTIAL "
|
|
"-> 25/25 FULL (missing list emptied); 19-case frozen gap truth "
|
|
"(scripts/gen_token_optimizer_truth.py under scripts/to_freeze_seams — "
|
|
"byte-identical across generation and --verify runs; pins the _load "
|
|
"partial-adoption quirk + CacheEntry kwargs semantics), Rust battery 7/7 "
|
|
"with the gap truth embedded via include_str!, live parity 60/60 "
|
|
"(frozen FFI construction rows + pin contracts both directions + 40 "
|
|
"dual-mode fuzz trials + module-API/singleton E2E), cargo clippy "
|
|
"--all-targets -D warnings 0, Python tests both pins "
|
|
"(test_token_optimizer_cache + test_token_optimizer_port 5/5 each; 7 "
|
|
"test_rust_core_shims failures pre-existing, verified identical on the "
|
|
"stashed clean base — other modules' unbuilt worktree kernels)."
|
|
),
|
|
}], scope_files=[
|
|
"src/rune/token_optimizer.py",
|
|
"src/rune/to_loader.py",
|
|
"src/rust/token_optimizer/src/lib.rs",
|
|
"src/rust/token_optimizer/src/branch_battery.rs",
|
|
"src/rust/token_optimizer/frozen_truth.json",
|
|
"src/rust/token_optimizer/Cargo.toml",
|
|
"scripts/gen_token_optimizer_truth.py",
|
|
"scripts/to_freeze_seams/sitecustomize.py",
|
|
"scripts/check_token_optimizer_parity.py",
|
|
])
|
|
print("close:", json.dumps(c)[:300])
|
|
print("CONTRACT", cid, "closed" if c.get("success") else "CLOSE_FAILED")
|