Files
rune/scripts/open_contract_inference_trace.py
T
Nick b5228ace36 feat(inference_trace): port to FULL Rust — dichotomy wave
DICHOTOMY VERDICT: RUST (deterministic decision core; file IO stays
Python-side by design, not by omission — append/rotate/replace, directory
creation, file reads, argv/print are the Python strangler seams).

Replaces the stale W6 stub (wrong struct shape, price_for only).

Ported (name-preserving, src/rust/inference_trace/src/lib.rs):
- price_for (empty map: None for ALL models), trace_dir/trace_path
  (explicit-arg wins else <rune_home>/state)
- serialize (sort_keys + compact separators; recursive BTreeMap key sort)
- rotate_plan (ordered shift pairs BACKUPS..1, I1 source-guard semantics)
  + should_rotate (strict >), read_select (limit trims last N pre-parse,
  blank lines skipped), cli_tail + format_record (indent=2 sorted shape)
- it_loader.py: 6 doc-envelope symbols, freed via capability_scoring
  cs_free_string (never re-exported); facade delegation in
  inference_trace.py with RUNE_IT_CORE=python pin; python fallbacks
  byte-identical.

Truth: scripts/gen_inference_trace_truth.py freezes 24 cases from the live
oracle (RUNE_IT_CORE=python pinned, isolated RUNE_HOME, every public
function, all branches) into frozen_it_truth.json; battery replays it
VERBATIM (6 tests green). Live parity 100% (24/24 byte-identical vs the
freshly built .so). 129 consumer tests green.

Contract BUILDER-2026-10-12T13:55:29Z-148b8f-factory-wave.
2026-10-12 16:55:24 +01:00

41 lines
1.5 KiB
Python

#!/usr/bin/env python3
"""Open the #2479 dichotomy-wave construction contract for inference_trace
(Rust port). Draft→approved→building in ONE process; verifying→closed at
delivery with SHA evidence."""
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
iface = ConstructionInterface(builder="factory-wave")
r = iface.submit_need(
"Port src/rune/inference_trace.py to FULL Rust (dichotomy factory, "
"issue #2479 tranche): name-preserving doc-envelope FFI for the "
"inference-trace kernel (price_for, trace path resolution, record "
"serialization, rotation policy decision, read/limit selection; "
"file IO stays Python-side), ctypes loader it_loader.py mirroring "
"broker_loader.py (free via capability_scoring cs_free_string), facade "
"delegation with RUNE_IT_CORE=python pin, frozen-truth battery "
"generated against the live Python oracle, live parity 100%, Phase B "
"language-advantage pass.",
origin="builder",
)
print("submit_need:", json.dumps(r)[:200])
if not r.get("success"):
print("NEED FAILED — aborting")
sys.exit(1)
cid = r["ids"]["contract_id"]
print("contract_id:", cid)
for phase in ("approved", "building"):
t = iface.transition(cid, phase)
print(f"transition->{phase}:", json.dumps(t)[:200])
if not t.get("success"):
sys.exit(1)
print("CONTRACT", cid, "IN BUILDING (close at delivery with SHAs)")