Files
rune/scripts/admit_wave_k9_continuous_runtime.py
T
2026-10-17 12:02:43 +01:00

114 lines
4.8 KiB
Python

"""Admission dispatch for wave K9 (continuous runtime, task 1.1).
classify + activate + admit (the headless scaffolding entry law,
tests/test_construction_admission.py pattern): the REAL continuous
headless runtime on the Go side — no sessions, face attach/detach,
auto-start (systemd user unit), auto-recover (crash → restart → resume),
exit checkpoint with canonical refs — built on the existing rune project,
user-dispatch approved.
"""
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 = (
"build the real continuous runtime on the Go side (rune-runtime spec "
"task 1.1): rune run hosts the serve surface as the face-agnostic core "
"— no sessions, faces attach/detach over the live HTTP seam without "
"stopping work (the I1 bridge pattern extended to the runtime side), "
"auto-start via a systemd user unit (Restart=on-failure, SIGTERM stop "
"= deliberate exit), auto-recover (crash leaves no checkpoint; restart "
"resumes from the fsynced effects journal with explicit gap status), "
"exit checkpoint (active/incomplete tasks, pending decisions, replay "
"cursor, evidence pointers, atomic write), and irreversible effects "
"executed exactly once keyed by effect_id"
)
AFFECTED = [
"src/go/rune-entry/internal/entry/runtime.go",
"src/go/rune-entry/internal/entry/runtime_serve.go",
"src/go/rune-entry/internal/entry/autostart.go",
"src/go/rune-entry/internal/entry/runtime_test.go",
"src/go/rune-entry/internal/entry/cli.go",
"src/go/rune-entry/internal/entry/testdata/runtime/crash-replay/effects.jsonl",
"src/go/rune-entry/internal/entry/testdata/runtime/crash-replay/checkpoint.json",
"src/go/rune-entry/internal/entry/testdata/runtime/crash-replay/dispatch.log",
]
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-K9-continuous-runtime",
"objective": OBJECTIVE,
"origin": "worker",
"project": "rune",
"task_ref": "wave-K9-continuous-runtime",
"affected_surface": AFFECTED,
"evidence_refs": [
"docs/openspec/changes/add-native-rune-tui/specs/rune-runtime/spec.md",
"tui/runtime/runtime.go",
"tui/bridge/bridge.go",
"src/go/rune-entry/internal/entry/serve.go",
],
}
act = cact.activate(md, need=need, scaffold=scaffold,
builder="wave-K9-continuous-runtime")
print("activated:", act.get("activated"), act.get("mode"))
env = cadm.admit(
act,
objective=OBJECTIVE,
builder="wave-K9-continuous-runtime",
affected_surface=AFFECTED,
evidence_refs=need["evidence_refs"],
origin="worker",
task_ref="wave-K9-continuous-runtime",
expected_new_entities=[
"src/go/rune-entry/internal/entry/runtime.go",
"src/go/rune-entry/internal/entry/runtime_serve.go",
"src/go/rune-entry/internal/entry/autostart.go",
"src/go/rune-entry/internal/entry/testdata/runtime/crash-replay/",
],
expected_runtime_effects=[
"rune run serves the /v1 surface as the continuous program's face-agnostic core",
"faces attach/detach without stopping work; no session is created",
"deliberate exit (SIGTERM/SIGINT, POST /v1/runtime/exit) writes the canonical checkpoint",
"crash restart resumes from the effects journal with explicit gap status",
"irreversible effects execute exactly once (effect_id journal keys)",
"systemd user unit auto-starts at login and restarts after crashes",
],
verification_obligations=[
"go test ./internal/entry/ -run 'TestDetachNeverStopsWork|TestRestartResumesInFlightTaskNoDuplicateEffects|TestCrashReplayFixture|TestDeliberateExitWritesCheckpoint|TestSystemdUnitPinned|TestRuntimeServe' green",
"unified_check --members go_suite green (no NEW failing module)",
],
approval_ref="user:wave-K9-continuous dispatch",
contract_id="ADMIT-wave-K9-continuous-runtime",
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())