123 lines
5.6 KiB
Python
123 lines
5.6 KiB
Python
#!/usr/bin/env python3
|
|
"""Close the #2479 dichotomy-wave gap-closing construction contract for
|
|
capability_fit (RUST port). Full lifecycle walk in ONE process (shared-store
|
|
clobber hazard; segment transitions take ~60s each — do NOT split across
|
|
processes). Raw transition->closed is refused; the close path is
|
|
iface.close() with observed evidence. Carries the pushed parity SHA.
|
|
|
|
Usage: close_contract_gap_cf.py
|
|
"""
|
|
import json
|
|
import os
|
|
import sys
|
|
from pathlib import Path
|
|
|
|
os.environ.setdefault(
|
|
"CS_RUST_LIB",
|
|
"/mnt/workdrive/rune/src/rust/capability_scoring/target/release/libcapability_scoring.so",
|
|
)
|
|
|
|
sys.path.insert(0, str(Path(__file__).resolve().parents[1] / "src"))
|
|
|
|
from rune.construction_interface import ConstructionInterface # noqa: E402
|
|
|
|
PARITY_SHA = "25c8d344"
|
|
EVIDENCE = f"parity {PARITY_SHA}"
|
|
|
|
iface = ConstructionInterface(builder="factory-gap-cf")
|
|
|
|
r = iface.submit_need(
|
|
"capability_fit dichotomy gap-close (RUST): name-preserving port of "
|
|
"the 10 audit-missing functions (record_semantic_fit, "
|
|
"_provides_contracts, _consumers, discover_candidates, decide, "
|
|
"resolve, to_dict, from_dict; _result envelope + _cs_core probe "
|
|
"documented kernel-side) into src/rust/capability_fit as "
|
|
"record_semantic_fit / provides_contracts / consumers / "
|
|
"discover_candidates / decide / resolve / to_dict / from_dict "
|
|
"(CapabilityRequirement), with evaluate_fit reconciled to the LIVE "
|
|
"capability_scoring kernel semantics (missing-contract dedup, "
|
|
"consumers default [], maturity_rank/consumers extras gating), "
|
|
"Python repr(list) single-quote law in rationale strings, in-operator "
|
|
"substring/dict-key semantics, sorted(evidence) raw-list TypeError, "
|
|
"codepoint interpretation[:500], message-only exception contract, "
|
|
"bool-is-int confidence. Frozen truth: 34-case shared-harness "
|
|
"envelope (scripts/gen_capability_fit_gap_truth.py under "
|
|
"scripts/cf_freeze_seams — from_dict/to_dict composition + "
|
|
"raises-markers, evaluate_fit rows riding the capability_scoring "
|
|
".so) verified byte-identical via freeze_truth.py --verify; Rust "
|
|
"battery 1/1 (verbatim gap_battery.rs include_str! replay); live "
|
|
"parity frozen=34 fuzz=1436 live=5 failures=0 "
|
|
"(scripts/check_capability_fit_gap_parity.py, seed 2479); both-pins "
|
|
"pytest 28/28 (tests/test_capability_fit_port.py + tranche §27 "
|
|
"suite); clippy -D warnings + fmt + ruff clean. Dichotomy audit "
|
|
"capability_fit 2/12 PARTIAL -> 14/14 FULL (132/192 modules at "
|
|
"FULL). Delivered on gitea/master: feat " + PARITY_SHA + ".",
|
|
origin="builder",
|
|
)
|
|
print("submit_need:", json.dumps(r)[:300])
|
|
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, evidence_ref=EVIDENCE)
|
|
ok = t.get("success")
|
|
print(f"transition->{phase}:", "ok" if ok else json.dumps(t)[:300])
|
|
if not ok:
|
|
sys.exit(1)
|
|
|
|
c = iface.close(cid, observed_evidence=[{
|
|
"kind": "port_evidence",
|
|
"detail": (
|
|
f"capability_fit dichotomy gap-close — feat commit {PARITY_SHA}, "
|
|
"pushed and verified as a gitea/master ancestor. Module audit "
|
|
"2/12 PARTIAL -> 14/14 FULL (missing list empty). The 10 "
|
|
"audit-missing fns ported name-preserving into "
|
|
"src/rust/capability_fit (record_semantic_fit, "
|
|
"provides_contracts, consumers, discover_candidates, decide, "
|
|
"resolve, CapabilityRequirement::to_dict/from_dict; result_dict "
|
|
"mirrors decide's _result envelope; _cs_core/_cf_core probes + "
|
|
"_cf_kernel_exc documented kernel-side as machinery). "
|
|
"Frozen-truth battery (gap_battery.rs) replays the 34-case "
|
|
"shared-harness corpus VERBATIM (include_str!) — cargo test 1/1; "
|
|
"freeze_truth.py --verify 34 cases byte-identical against the "
|
|
"live oracle (cf_freeze_seams; evaluate_fit rows ride the "
|
|
"capability_scoring .so); live parity frozen=34 fuzz=1436 live=5 "
|
|
"failures=0 (check_capability_fit_gap_parity.py, seed 2479); "
|
|
"both-pins pytest 28/28 (test_capability_fit_port.py + tranche "
|
|
"§27 suite, python pin AND delegation-live); cargo clippy "
|
|
"-D warnings + fmt + ruff clean. "
|
|
"Evidence: verification/cf-*.exit + cf-summary.md "
|
|
"(committed with the feat). Oracle quirks preserved: repr(list) "
|
|
"single-quote rationale law, in-operator substring/dict-key "
|
|
"semantics + 'container or iterable' TypeError, sorted(evidence) "
|
|
"raw-list TypeError, codepoint interpretation[:500], message-only "
|
|
"exception contract, bool-is-int confidence, NaN-wire divergence "
|
|
"documented (serde_json rejects NaN; kernel range-check covers "
|
|
"non-finite by construction)."
|
|
),
|
|
}], scope_files=[
|
|
"src/rust/capability_fit/src/lib.rs",
|
|
"src/rust/capability_fit/src/gap_battery.rs",
|
|
"src/rust/capability_fit/frozen_gap_truth.json",
|
|
"src/rust/capability_fit/Cargo.toml",
|
|
"src/rune/capability_fit.py",
|
|
"src/rune/cf_loader.py",
|
|
"scripts/gen_capability_fit_gap_truth.py",
|
|
"scripts/cf_freeze_seams/sitecustomize.py",
|
|
"scripts/check_capability_fit_gap_parity.py",
|
|
"scripts/close_contract_gap_cf.py",
|
|
"tests/test_capability_fit_port.py",
|
|
"docs/dichotomy-rebase-honest-audit.md",
|
|
"verification/cf-summary.md",
|
|
])
|
|
print("close:", json.dumps(c)[:300])
|
|
final = iface.scaffold.contract(iface.scaffold.load(), cid)
|
|
phase = final.get("phase") if final else "MISSING"
|
|
print("FINAL PHASE:", phase)
|
|
if phase != "closed":
|
|
sys.exit(1)
|
|
print("CLOSED", cid)
|