Files
rune/scripts/admit_wave_retire_tool_executor.py
Nick c8b12cc496
CI Pipeline / documentation (push) Successful in 12s
CI Pipeline / best-practices (push) Successful in 13s
CI Pipeline / required-checks (push) Canceled after 0s
CI Pipeline / CI Pipeline / notify-event-bridge (push) Canceled after 0s
CI Pipeline / lint (push) Canceled after 16s
CI Pipeline / go-surface (push) Canceled after 16s
CI Pipeline / rust-surface (push) Canceled after 16s
CI Pipeline / gitea-offline (push) Canceled after 2s
CI Pipeline / unit-tests (push) Canceled after 17s
CI Pipeline / canary (push) Canceled after 17s
CI Pipeline / type-check (push) Canceled after 3s
deploy / deploy (push) Canceled after 2s
Auto-version and Release / release (push) Canceled after 18s
feat(tool-executor): the LOCAL TOOL EXECUTION GO DELEGATION — LocalToolRuntime's executor becomes a fail-loud delegation facade over src/go/tool-executor: the four read-only ops (read_file, list_directory, glob_files, grep_files) resolve through the Go binary by default with the JSON envelope preserved exactly; run_command stays behind the approval door (mutating — never silently executed); the Python bodies stay as oracle/escape hatch (RUNE_TOOL_EXECUTOR_ENGINE=python, RUNE_TOOL_EXECUTOR_BIN override, typed RuntimeError on missing binary, no Python deletion). Red-first parity battery caught four real Go↔Python divergences (trailing-newline line numbering, windowing context markers + offset-relative numbering, absolute grep paths, oracle error texts) before landing — all fixed byte-identical; scripted-executor test fixtures pin the python escape hatch (Gitea #2575 wave B, red-first)
2026-10-24 07:11:06 +01:00

133 lines
5.6 KiB
Python

"""Admission dispatch for wave retire-tool-executor (Gitea #2575
rebalanced overnight queue, wave B): wire local_tool_runtime.py to the
Go tool-executor engine.
classify + activate + admit (headless scaffolding entry law,
scripts/admit_wave_retire_reconcile_tools.py pattern): the Go executor
exists (src/go/tool-executor, full CLI surface read_file/list_directory/
glob_files/grep_files/run_command, JSON envelope {success,result,error})
but src/rune/local_tool_runtime.py never delegates to it. This wave wires
the fail-loud delegation facade (LocalToolRuntime's executor resolves the
four READ-ONLY ops through the Go binary by default; run_command stays
behind the Python approval door — mutating, never silently executed),
keeps the Python bodies as oracle/escape hatch
(RUNE_TOOL_EXECUTOR_ENGINE=python, NO Python deletion — PORT → INTEGRATE
→ REMOVE), and pins the port with a red-first parity battery
(tests/test_tool_executor_delegation.py) against the Python oracle.
"""
import json
import os
import sys
sys.path.insert(0, os.path.join(os.path.dirname(__file__), "..", "src"))
from rune import construction_activation as cact # noqa: E402
from rune import construction_admission as cadm # noqa: E402
from rune import construction_mode as cmode # noqa: E402
from rune import scaffold as sc # noqa: E402
ROOT = os.path.join(os.path.dirname(__file__), "..")
OBJECTIVE = (
"Close the wave-181 full-switchover blocker: Go port of the local "
"tool execution — wire local_tool_runtime.py to the existing "
"src/go/tool-executor engine. LocalToolRuntime executor becomes "
"a fail-loud delegation facade: the four read-only file ops "
"(read_file, directory enumeration, glob, grep) resolve through "
"the Go binary by default, JSON envelope preserved exactly; "
"run_command stays behind the approval door (mutating, never "
"silently executed). Python bodies stay as oracle escape hatch "
"(RUNE_TOOL_EXECUTOR_ENGINE=python, RUNE_TOOL_EXECUTOR_BIN "
"override, typed RuntimeError when the binary is missing — no "
"silent fallback, no Python deletion; PORT → INTEGRATE → REMOVE). "
"Red-first parity battery tests/test_tool_executor_delegation.py "
"pins Go to the Python oracle envelope-for-envelope"
)
AFFECTED = [
"src/go/tool-executor/",
"src/rune/local_tool_runtime.py",
"tests/test_tool_executor_delegation.py",
"tests/test_local_tool_runtime.py",
"tests/test_p0_05_native_tools.py",
"tests/test_mode_dispatch_gate.py",
"verification/integrated/tool-executor-integrated.json",
"scripts/admit_wave_retire_tool_executor.py",
]
def main() -> int:
store = os.path.join(ROOT, "store", "scaffold")
scaffold = sc.Scaffold(store, "rune")
md = cmode.classify_mode(
OBJECTIVE,
target_project="rune",
project_exists=True,
affected_surface=AFFECTED,
)
print("classified mode:", md.mode)
need = {
"need_id": "need-wave-retire-tool-executor",
"objective": OBJECTIVE,
"origin": "worker",
"project": "rune",
"task_ref": "wave-retire-tool-executor",
"affected_surface": AFFECTED,
"evidence_refs": [
"src/go/tool-executor/internal/toolexec/cli.go",
"src/rune/local_tool_runtime.py",
"src/rune/tool_executor.py",
"tests/test_tool_executor_delegation.py",
"verification/integrated/reconcile-tools-integrated.json",
],
}
act = cact.activate(md, need=need, scaffold=scaffold,
builder="wave-retire-tool-executor")
print("activated:", act.get("activated"), act.get("mode"))
env = cadm.admit(
act,
objective=OBJECTIVE,
builder="wave-retire-tool-executor",
affected_surface=AFFECTED,
evidence_refs=need["evidence_refs"],
origin="worker",
task_ref="wave-retire-tool-executor",
expected_new_entities=[
"tests/test_tool_executor_delegation.py (red-first parity "
"battery: Go delegation == Python oracle envelope-for-"
"envelope; fail-loud binary-missing refusal; run_command "
"never delegates; default-is-go pin)",
"verification/integrated/tool-executor-integrated.json "
"(integrated receipt, soak clock before any Python deletion)",
],
expected_runtime_effects=[
"LocalToolRuntime's executor resolves read_file, "
"list_directory, glob_files and grep_files through the Go "
"tool-executor binary by default; envelopes preserved "
"exactly",
"RUNE_TOOL_EXECUTOR_ENGINE=python pins the oracle path; "
"a missing engine binary raises a typed RuntimeError (no "
"silent Python fallback)",
"run_command dispatches through the Python authority path "
"only (approval door preserved, no Go bypass)",
],
verification_obligations=[
"go test -race -short ./... in src/go/tool-executor green",
"pytest tests/test_tool_executor_delegation.py "
"tests/test_local_tool_runtime.py tests/test_p0_05_native_tools.py "
"tests/test_mode_dispatch_gate.py tests/test_context_broker.py "
"green",
],
approval_ref="user:gitea #2575 rebalanced overnight queue, wave B "
"2026-10-24",
contract_id="ADMIT-wave-retire-tool-executor",
project_store=store,
project_id="rune",
)
print(json.dumps(env, indent=2, default=str)[:2400])
return 0 if env.get("success") else 1
if __name__ == "__main__":
sys.exit(main())