Files
rune/scripts/open_contract_worthiness.py
Nick 5ac385832f feat(worthiness): port to FULL Rust — dichotomy wave
RUST verdict (dichotomy law, #2479 tranche, contract
BUILDER-2026-10-12T02:14:11Z-69cc9a-factory-wave): worthiness.py's full
constitution-grounded filter surface is ported to src/rust/worthiness —
all nine question kernels (pi_safety protective-frame branch, honesty
good/bad signal counting with the exact note formats, material_reality
finance→hustle/caring lattice, root_cause spin-first ordering, respect
rigid-first ordering, assistant_goal with the store-derived domain
vocabulary, durability, epistemology with the unsound-bare-absolute
precheck, expression with the four signal groups), the two-axis assess
verdict lattice (expression targets skip epistemology unless the text is
a bare factual absolute; last-veto-wins overwrite; DEFER/PROMOTE/ABSORB
threshold boundaries), is_bare_factual (padded-token matching; the
oracle's subjective-predicate list is DEAD CODE and stays dead),
verdict_label with the passthrough fallback.

DOMAIN-CACHE LAW mirrored: q_assistant_goal's `assist = _domain_terms();
assist += [universal..]` mutates the oracle's cache IN PLACE, inflating
hit counts on every call within the 300 s TTL. The Rust kernel owns the
cache (Mutex) and extends it on every call; the store read crosses back
as the `domain_terms` op served by the loader with the oracle's verbatim
query body (sans cache). Frozen truth caught this working: single-hit
counts only land on a process's first q_assistant_goal call.

Wiring: wr_loader.py ctypes loader mirroring broker_loader.py/pc_loader.py
(doc-envelope FFI, op-host callback for domain_terms, oracle-verbatim
tuple unwrapping, free via capability_scoring cs_free_string — no free
symbol re-export), facade delegation in worthiness.py with
RUNE_WR_CORE=python fallback pin.

Truth: frozen_wr_truth.json — 51 cases from the live oracle (deep-copied
inputs, RUNE_WR_CORE=python pinned, every public fn and every branch
incl. all four verdicts, veto last-wins, boundary totals -1.0/0.0,
fact=None coercion, verdict_label passthrough), replayed VERBATIM by the
in-crate branch battery. Battery caught one real port bug pre-landing
(the AESTHETIC signal list was missing 'wonder' — expression hit counts
diverged 5 vs 6). Live parity: facade 51/51 + kernel 51/51 (direct
loader), kernel pass in a subprocess (process-global cache law).
Python tests green both modes.
2026-10-12 03:59:47 +01:00

46 lines
1.6 KiB
Python

#!/usr/bin/env python3
"""Open the #2479 dichotomy-wave construction contract for worthiness.
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/worthiness.py to FULL Rust (dichotomy factory, "
"issue #2479 tranche): doc-envelope FFI, ctypes loader, facade "
"delegation with RUNE_WR_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": "worthiness parity port — evidence attached at close "
"(SHAs reported in the builder report)",
}], scope_files=[
"src/rune/worthiness.py",
"src/rune/wr_loader.py",
"src/rust/worthiness/src/lib.rs",
"src/rust/worthiness/src/branch_battery.rs",
"scripts/gen_worthiness_truth.py",
])
print("close:", json.dumps(c)[:400])
print("CONTRACT", cid, "closed" if c.get("success") else "CLOSE_FAILED")