Files
rune/scripts/open_contract_experience_encoding.py
Nick d929b9a068 feat(experience_encoding): port to FULL Rust — dichotomy wave
RUST verdict (dichotomy law, #2479 tranche, contract
BUILDER-2026-10-12T10:31:15Z-0436f5-factory-wave): experience_encoding's
single admission decision is ported to src/rust/experience_encoding —
the full event → evaluate → classify → attach-provenance flow (empty/
short char-count gate with its 14/15 boundary, whitespace/case-insensitive
duplicate scan over normalized episode texts, framing-only no-lexical-
signal filter, grounded → EPISODE/EVIDENCE split with sorted-top3 share
reasons and novel-axis grounding, provenance attachment with the
dict.get quirk preserved: a present-but-null source/session_id pins as
null — the default applies only to a MISSING key).

LEXICON-SEAM LAW mirrored: the oracle's flat `import lexicon_evolution`
is an environment seam (ImportError → conservative evidence admission,
which also BEATS a would-be duplicate because the dup check runs inside
the try). The Rust kernel mirrors it via the payload's
`lexicon_available` flag; the facade derives it from the live import.
The lexical decisions themselves cross to the lexicon_evolution sibling
crate IN-PROCESS (library dependency, the exact mirror of the oracle's
import — no FFI hop).

Wiring: ee_loader.py ctypes loader mirroring broker_loader.py/le_loader.py
(doc-envelope FFI, oracle-verbatim dict unwrap, free via
capability_scoring cs_free_string — no free symbol re-export), facade
delegation in experience_encoding.py with RUNE_EE_CORE=python fallback
pin, _py_evaluate preserved as the load-bearing oracle body.

Truth: frozen_ee_truth.json — 29 cases from the live oracle (deep-copied
inputs, RUNE_EE_CORE=python pinned, every branch incl. all three
verdicts and all five reasons, provenance null/empty-string quirks,
punctuation-survives-normalization non-duplicate, lexicon-blocked
ordering proofs, corpus fallback to episode texts, corpus override
killing the share but not the grounding), replayed VERBATIM by the
in-crate branch battery (whole-doc compare). Live parity: facade 29/29 +
kernel 29/29 (direct loader), RUNE_EE_CORE=python fallback 29/29.
Python tests green both modes (test_governance_quartet 15/15).
2026-10-12 11:56:55 +01:00

46 lines
1.6 KiB
Python

#!/usr/bin/env python3
"""Open the #2479 dichotomy-wave construction contract for experience_encoding.
Full lifecycle in ONE process (shared-store clobber hazard)."""
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/experience_encoding.py to FULL Rust (dichotomy factory, "
"issue #2479 tranche): doc-envelope FFI, ctypes loader, facade "
"delegation with RUNE_EE_CORE=python pin, frozen-truth battery, "
"live parity 100%, Phase B language-advantage pass.",
origin="builder",
)
print("submit_need:", json.dumps(r)[:400])
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", "verifying"):
t = iface.transition(cid, phase)
print(f"transition->{phase}:", json.dumps(t)[:300])
if not t.get("success"):
sys.exit(1)
c = iface.close(cid, observed_evidence=[{
"kind": "port_evidence",
"detail": "experience_encoding parity port — evidence attached at close "
"(SHAs reported in the builder report)",
}], scope_files=[
"src/rune/experience_encoding.py",
"src/rune/ee_loader.py",
"src/rust/experience_encoding/src/lib.rs",
"src/rust/experience_encoding/src/branch_battery.rs",
"scripts/gen_experience_encoding_truth.py",
])
print("close:", json.dumps(c)[:400])
print("CONTRACT", cid, "closed" if c.get("success") else "CLOSE_FAILED")