Files
rune/scripts/admit_wave_k27_plan_loop.py
Nick b0c287ba8b feat(runtime): batch — plan loop 4.2, self-transformation 6.2, taxonomy closure 6.3, taxonomy dispatch fix
- 4.2 Plan loop runtime (tui/planloop): full consent-gated process —
  contextual offer (sustained-pattern or explicit), never-interrupts-
  active-Task, initial plan -> research -> viability -> revised ->
  targeted research -> final viability -> owner-gated start ->
  dependency-ordered execution -> independent review -> report;
  return-to-plan on contradiction (round++, targeted re-research,
  start gate re-arms, done steps survive); durable/resumable/piecewise
  through the K25 plan store. 8 frozen tests red-first x5 green.

- 6.2 Self-transformation pipeline (src/rune/self_transform_pipeline.py):
  13 stages, PROPOSE->...->ROLLBACK_OR_CLOSE; DEP06 mediation at stage 4
  + shadow wrap (audit catches hidden writes); DEP07 activation at stage
  6; DEP05 owner envelopes at stage 8 (authenticated, reserved, then
  REFUSED — SELF_ACTIVATION_IMPOSSIBLE per D10, stages 9-11 structurally
  unreachable); D03 render, D05 per-effect, D06 vintage, D08 rollback-
  pause; journal receipts digest-verified. 36/36 frozen tests red-first.

- 6.3 Taxonomy closure: NO taxonomy code ships — scan conformance
  (planted router tripped RED, removed, 8/8 green); authority path
  unchanged (user: envelope still required, 53 passed); TUI unblocked.
  8 frozen tests red-first. Taxonomy dispatch marker fix.
2026-10-17 22:17:31 +01:00

138 lines
5.7 KiB
Python

"""Admission dispatch for the K27 plan-loop wave (task 4.2).
classify + activate + admit (the headless scaffolding entry law,
scripts/admit_wave_k26_update_apply.py pattern): the full Plan process
runtime in tui/planloop on top of the landed substrate — the K17 mode
enforcement (consent-gated PLAN entry, the tool matrix) and the K25
durable plan document store (/v1/plans). Contextual offer (sustained
make-something detection + explicit request), the never-interrupt hold
while a Task is active, the frozen stage sequence, owner-gated explicit
start, staged execution in Task, independent review, final report, and
the material-flaw return (targeted research re-runs, the start gate
re-arms, done steps survive). Pinned by frozen tests: full loop on a
synthetic feature request, return-to-plan on injected contradiction,
never-interrupts-active-Task conformance. Red-first. 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 task-4.2 Plan process runtime in tui/planloop on top of "
"the landed substrate (K17 mode enforcement, K25 plan document "
"store): the contextual offer — sustained make-something detection "
"over real conversation plus the explicit-request path, held (never "
"enterable, visibly) while a Task is active — the consent-gated "
"entry into PLAN, the frozen ten-stage sequence (initial plan, "
"research protocol, viability, evidence-informed plan with staged "
"steps, targeted research, final viability), the owner-gated "
"explicit start with the PLAN→TASK handoff, dependency-ordered "
"staged execution under the K17 tool matrix (done steps never "
"redone — piecewise), independent review (named reviewer, never "
"the implementer), the final report, and the material-flaw return "
"(round increments, targeted research and final viability re-run, "
"the start gate re-arms, done steps survive). Every mutation rides "
"the store's append-only revision trail as a loop-state snapshot, "
"so the process is durable, recallable and piecewise (Resume). "
"Frozen tests: full loop on a synthetic feature request (incl. "
"resume from a restarted store), return-to-plan on an injected "
"mid-implementation contradiction, never-interrupts-active-Task "
"conformance, plus the offer-detector set and the K17 execution "
"gates. Red-first."
)
AFFECTED = [
"tui/planloop/offer.go",
"tui/planloop/offer_test.go",
"tui/planloop/loop.go",
"tui/planloop/loop_test.go",
"tui/planloop/store.go",
"tui/planloop/README.md",
]
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-K27-plan-loop",
"objective": OBJECTIVE,
"origin": "worker",
"project": "rune",
"task_ref": "wave-K27-plan-loop",
"affected_surface": AFFECTED,
"evidence_refs": [
"docs/openspec/changes/add-native-rune-tui/tasks.md",
"tui/modes/plan.go",
"tui/modes/modes.go",
"src/go/rune-entry/internal/entry/plan_store.go",
"src/go/rune-entry/internal/entry/runtime_serve.go",
],
}
act = cact.activate(md, need=need, scaffold=scaffold,
builder="wave-K27-plan-loop")
print("activated:", act.get("activated"), act.get("mode"))
env = cadm.admit(
act,
objective=OBJECTIVE,
builder="wave-K27-plan-loop",
affected_surface=AFFECTED,
evidence_refs=need["evidence_refs"],
origin="worker",
task_ref="wave-K27-plan-loop",
expected_new_entities=[
"tui/planloop Plan process runtime (Detect/EnterPlan offer "
"gate, Loop driver with Advance/SetSteps/SignalStart/"
"Execute/Review/Return/Report, PlanStore seam + ServePlans "
"client, Resume recall)",
],
expected_runtime_effects=[
"the Plan process may offer (sustained pattern or explicit "
"request, held while a Task runs), enter PLAN only on "
"consent, and drive one plan through the frozen sequence "
"persisting every stage/step/verdict to the plan store's "
"append-only trail; execution tools stay unreachable "
"outside TASK (K17 matrix); nothing starts without the "
"owner's explicit signal, and a contradiction returns work "
"to Plan with the gate re-armed",
],
verification_obligations=[
"go test ./planloop/ -count=1 green in tui/ (frozen full "
"loop, return-to-plan, never-interrupt, offer set, "
"execution gates)",
"gofmt -l and go vet clean on tui/planloop",
"go build ./planloop/ ./modes/ green in tui/ (module-wide "
"build blocked by a parallel wave's in-flight tui/lanes "
"edit, not this package)",
],
approval_ref="user:wave-K27-plan-loop dispatch",
contract_id="ADMIT-wave-K27-plan-loop",
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())