#!/usr/bin/env python3 """Open → walk → close the #2479 dichotomy-wave construction contracts for the forge + verification_layer GO batch (factory-batch-c). Full lifecycle per contract, both back-to-back 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-batch-c") CONTRACTS = [ { "module": "forge", "cid": "BUILDER-2026-10-12T17:43:29Z-ea9485-factory-batch-c", "need": ( "Port src/rune/forge.py to FULL Go (dichotomy factory, issue " "#2479 tranche, batch-c): the §18L forge boundary — ForgeAdapter " "protocol, ForgeUnavailable, GiteaForge (env/push/commit_status/" "ci_runs_for_sha/create_or_patch_release), default_forge, and the " "scripts/gitea_auth credential ladder — name-preserving in " "src/go/forge with IO behind CommandRunner/HTTPTransport/" "TokenSource seams, frozen-truth battery (34 rows), live parity " "100%, Phase B goroutine fan-out (Snapshot), compile-time seam " "assertions." ), "evidence": ( "forge parity port — 34/34 frozen rows replay verbatim (truth " "regenerated live twice, byte-stable), battery covers every " "public fn + branch (push truncation, status/runs HTTP capture " "byte-parity, credential ladder all 3 rungs, release argv + " "last-200 fallback), race-clean, gofmt/vet clean; Python oracle " "tests green. SHAs: cdcae1ea (feat) ac114c32 (Phase B), pushed " "gitea/master on top of 78a36204." ), "scope_files": [ "src/rune/forge.py", "src/go/forge/main.go", "src/go/forge/truth_test.go", "src/go/forge/phaseb.go", "src/go/forge/phaseb_test.go", "src/go/forge/truth.json", "scripts/gen_forge_truth.py", ], }, { "module": "verification_layer", "cid": "BUILDER-2026-10-12T17:46:05Z-c1a38e-factory-batch-c", "need": ( "Port src/rune/verification_layer.py to FULL Go (dichotomy " "factory, issue #2479 tranche, batch-c): all seven verifiers " "(exit_code, unit_test, schema, file_exists, file_changed, " "tool_receipt, constraint_check) + unknown-verifier dispatch, " "VerificationResult.to_dict byte-rendering, handle_hook, " "PLUGIN manifest — the Rust evidence_provenance semantics " "carried 1:1 (verification.rs), name-preserving in " "src/go/verification_layer with the FS probe behind a seam, " "frozen-truth battery (62 rows), live parity 100%, Phase B " "Verifier registry + VerifyAll goroutine fan-out." ), "evidence": ( "verification_layer parity port — 62/62 frozen rows replay " "verbatim byte-for-byte (truth regenerated live twice, " "byte-stable) + 15/15 live CLI parity sweep incl. unicode " "ensure_ascii escapes and non-string failures pass-through; " "battery covers every verifier pass+fail branches, dispatch, " "hook, PLUGIN; race-clean, gofmt/vet clean; Python tests green " "(test_verification_layer_demo + test_evidence_provenance_shims, " "7 passed). SHAs: d9009cc2 (feat) 2750eba0 (Phase B), pushed " "gitea/master on top of 78a36204." ), "scope_files": [ "src/rune/verification_layer.py", "src/go/verification_layer/main.go", "src/go/verification_layer/truth_test.go", "src/go/verification_layer/phaseb.go", "src/go/verification_layer/phaseb_test.go", "src/go/verification_layer/truth.json", "scripts/gen_verification_layer_truth.py", ], }, ] cids = [] for spec in CONTRACTS: r = iface.submit_need(spec["need"], origin="builder", contract_id=spec["cid"]) print("submit_need:", json.dumps(r)[:200]) if not r.get("success"): print("NEED FAILED — aborting") sys.exit(1) cid = r["ids"]["contract_id"] cids.append(cid) print("contract_id:", cid) for phase in ("approved", "building", "verifying"): t = iface.transition(cid, phase) print(f"transition->{phase}:", json.dumps(t)[:150]) if not t.get("success"): sys.exit(1) c = iface.close(cid, observed_evidence=[{ "kind": "port_evidence", "detail": spec["evidence"], }], scope_files=spec["scope_files"]) print("close:", json.dumps(c)[:200]) print("CONTRACT", cid, spec["module"], "closed" if c.get("success") else "CLOSE_FAILED") print("-" * 60) print("ALL CONTRACTS:", json.dumps(cids))