One-process walk draft->approved->building->verifying->closed via iface.close(contract_quality observed_evidence + scope_files). Evidence: scripts/close_contract_dependency_tracker.py, verification/dt-*
159 lines
7.3 KiB
Python
159 lines
7.3 KiB
Python
#!/usr/bin/env python3
|
|
"""Close the #2479 dichotomy-wave dependency_tracker gap contract (RUST
|
|
port). Full lifecycle walk in ONE process (shared-store clobber hazard;
|
|
segment transitions take ~60s each — do NOT split across processes). The
|
|
final step is iface.close() with contract_quality observed_evidence (the
|
|
bare `transition -> closed` is rejected by the quality gate). Safe to
|
|
re-run: pass the existing contract id to resume an interrupted walk.
|
|
|
|
Carries the already-pushed parity SHAs as evidence:
|
|
feat 2c308d90 close PARTIAL gaps — dichotomy wave (2/5 -> 6/6)
|
|
refactor a8a6efd7 Phase B language-advantage pass
|
|
|
|
Usage: close_contract_dependency_tracker.py [contract_id]
|
|
"""
|
|
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",
|
|
)
|
|
os.environ.setdefault(
|
|
"DT_RUST_LIB",
|
|
"/mnt/workdrive/rune-wave-dl/src/rust/dependency_tracker/target/release/libdependency_tracker.so",
|
|
)
|
|
|
|
sys.path.insert(0, str(Path(__file__).resolve().parents[1] / "src"))
|
|
|
|
from rune.construction_interface import ConstructionInterface
|
|
|
|
PARITY_SHA = "2c308d90"
|
|
PHASEB_SHA = "a8a6efd7"
|
|
EVIDENCE = f"parity {PARITY_SHA}, phase B {PHASEB_SHA}"
|
|
|
|
NEED = (
|
|
"dependency_tracker dichotomy gap-close (RUST): name-preserving port "
|
|
"of the 3 audit-missing functions (check_propagation, get_full_map, "
|
|
"main) into src/rust/dependency_tracker — and wholesale replacement "
|
|
"of the W6-era stub whose get_dependents/propagate were semantically "
|
|
"INVERTED (map KEYS collected for value-list hits; transitive BFS "
|
|
"where the oracle classifies direct dependents; audit_ledger "
|
|
"one-chain precedent). Kernels: get_dependents (posix basename + map "
|
|
"lookup), check_propagation, propagate (full classification matrix — "
|
|
"propagated-with-reference / not-found / no-direct-reference / "
|
|
"IsADirectoryError crash-parity with errno mapping and "
|
|
"Display-suffix stripping; dry_run would-update short-circuit), "
|
|
"get_full_map (dict INSERTION order — the warm_router dict-literal "
|
|
"overwrite quirk: first position, last value), main (CLI mirror, "
|
|
"pure fn over argv incl. the frozen argparse help). Facade seam: the "
|
|
"4 compute fns delegate via dt_loader (RUNE_DEPENDENCY_TRACKER_CORE="
|
|
"python pins the load-bearing Python bodies); SCRIPTS_DIR stays "
|
|
"import-time Python and rides the propagate payload; main() stays "
|
|
"Python argparse (process boundary); main_cli is the JSON-native "
|
|
"stdout+rc capture mirror. New quirk proved and recorded: Python "
|
|
"3.14 OSError.__str__ QUOTES the filename (frozen battery row 20). "
|
|
"Frozen truth 24 rows via the shared freeze_truth harness under "
|
|
"scripts/dt_freeze_seams (HOME='.' + cwd-is-the-rig + deterministic "
|
|
"fixture tree; COLUMNS=80 help width pin), byte-identical across "
|
|
"repeated --verify runs; cargo battery replays the truth VERBATIM "
|
|
"in order (to_string equality pins dict insertion order); live "
|
|
"parity 72/72 (pinned facade / live facade / kernel direct); clippy "
|
|
"-D warnings + fmt clean; Python suite both pins: failure set "
|
|
"byte-identical across pins AND the stashed base (244 pre-existing, "
|
|
"none touching this module); ruff clean; spine scope test green. "
|
|
"Dichotomy audit 2/5 PARTIAL -> 6/6 FULL (RUST). Delivered on "
|
|
"gitea/master: feat " + PARITY_SHA + ", phase B " + PHASEB_SHA + "."
|
|
)
|
|
|
|
iface = ConstructionInterface(builder="factory-gap-dt")
|
|
|
|
if len(sys.argv) > 1:
|
|
cid = sys.argv[1]
|
|
print("resuming contract:", cid)
|
|
else:
|
|
r = iface.submit_need(NEED, 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)
|
|
|
|
|
|
def phase_of(cid):
|
|
doc = iface.scaffold.load()
|
|
e = iface.scaffold.contract(doc, cid)
|
|
return e.get("phase") if e else "MISSING"
|
|
|
|
|
|
phase = phase_of(cid)
|
|
print("current phase:", phase)
|
|
for want in ("approved", "building", "verifying"):
|
|
if phase == want or phase in ("verifying", "closed"):
|
|
break
|
|
t = iface.transition(cid, want, evidence_ref=EVIDENCE)
|
|
ok = t.get("success")
|
|
print(f"transition->{want}:", "ok" if ok else json.dumps(t)[:300])
|
|
if not ok:
|
|
sys.exit(1)
|
|
phase = want
|
|
|
|
c = iface.close(
|
|
cid,
|
|
observed_evidence=[{
|
|
"kind": "port_evidence",
|
|
"detail": "dependency_tracker dichotomy completion — parity "
|
|
f"{PARITY_SHA} feat(dependency_tracker): close PARTIAL "
|
|
"gaps — dichotomy wave; pushed gitea/master (ancestor-"
|
|
"verified). Rust port at src/rust/dependency_tracker "
|
|
"closes the audit gaps name-preserving (6/6 FULL: the 5 "
|
|
"oracle fns + the main_cli mirror) and REPLACES the "
|
|
"inverted W6 stub. Generator scripts/"
|
|
"gen_dependency_tracker_truth.py: 24-row frozen truth "
|
|
"(shared freeze_truth harness under scripts/"
|
|
"dt_freeze_seams — HOME='.' cwd-is-the-rig, "
|
|
"deterministic fixture tree, COLUMNS=80) regenerates "
|
|
"byte-identical; freeze_truth --verify OK twice against "
|
|
"the pinned oracle. Battery gap_battery.rs replays the "
|
|
"truth VERBATIM in order (to_string equality pins dict "
|
|
"insertion order); live parity "
|
|
"scripts/check_dependency_tracker_parity.py 72/72 "
|
|
"(pinned facade / live facade / kernel direct); clippy "
|
|
"-D warnings + fmt clean; Python both pins: failure set "
|
|
"byte-identical across pins and the stashed base (244 "
|
|
"pre-existing, none touching this module); ruff clean. "
|
|
"New quirk recorded in docs/dichotomy-oracle-quirks."
|
|
"json: Python 3.14 OSError.__str__ quotes the filename "
|
|
"(proved by frozen battery row 20). Phase B "
|
|
f"{PHASEB_SHA}: subcommand enum + exhaustive match "
|
|
"dispatch, fmt::Write rendering, shared section() "
|
|
"renderer — behavior-identical, battery + parity "
|
|
"re-green. Divergences (documented): SCRIPTS_DIR is "
|
|
"import-time Python and rides the FFI payload; Rust "
|
|
"main mirrors well-formed CLI invocations + the no-cmd "
|
|
"help branch (argparse error machinery stays Python — "
|
|
"the facade main never delegates); argparse help width "
|
|
"pinned at 80 by the rig.",
|
|
}],
|
|
scope_files=[
|
|
"src/rust/dependency_tracker/src/lib.rs",
|
|
"src/rust/dependency_tracker/src/gap_battery.rs",
|
|
"src/rust/dependency_tracker/src/frozen_dt_truth.json",
|
|
"src/rust/dependency_tracker/Cargo.toml",
|
|
"src/rune/dependency_tracker.py",
|
|
"src/rune/dt_loader.py",
|
|
"scripts/dt_freeze_seams/sitecustomize.py",
|
|
"scripts/gen_dependency_tracker_truth.py",
|
|
"scripts/check_dependency_tracker_parity.py",
|
|
],
|
|
)
|
|
print("close:", json.dumps(c)[:400])
|
|
final = phase_of(cid)
|
|
print("FINAL PHASE:", final)
|
|
ok = c.get("success") and final == "closed"
|
|
print("CLOSED" if ok else "CLOSE_FAILED", cid)
|
|
sys.exit(0 if ok else 1)
|