M2.8: switch over to the new loop
CI / checks (push) Skipped
CI / checks (pull_request) Successful in 2m16s
CI / e2e (pull_request) Successful in 10m51s

nisse-dev now runs only the conversational loop. The gated state machine
it was built alongside is gone:

- Removed control.py, planner.py, executor.py, approvals.py, gates.py
  (command_form moves to loop/reader.py), publish.py and poller.py, the
  old assembly in agent.py (its shared helpers move to loop/build.py),
  the store's state-machine view (get_state, transition), their tests,
  the old end-to-end and live planning/milestone/gate tests, and
  specs/orchestrator.qnt with its scenarios.
- Roles are driver, helper, expert and classifier; driver is required.
  loop:, roles.planner, roles.executor and tuning.executor are refused
  with what to use instead; tuning.driver takes the turn cap and failure
  limit.
- The benchmark and the capability matrix measure the driver: the
  loop's own system prompt and tools, the task's plan as the agreed
  restatement. Task plans end with finish_milestone, so earlier runs
  show as (old); stored runs' executor tuning reads as the driver's.
- A delegation on the loop records what its helper's alias resolved to
  (L9), as the old path's did.
- The dump shows a work item's revision and what it waits for.
- Behaviour the old tests covered and the loop shares stays covered:
  driver runs that fail on a model call, stop mid-turn, reset the
  failure count; go-aheads ignoring case and punctuation; a request too
  big to fit is never sent; the assembly tests, now on build_loop_agent.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01PPQ14L3LikyefCMFBqEbKE
This commit is contained in:
dongarandClaude Opus 5.5 committed 2026-10-08 03:12:58 +00:00
1 parent 09232dcbdd
commit 6ae2375194
89 files changed
+951 -8592

No files matched your search

+80 -1
View File
@@ -9,11 +9,19 @@ import pytest
from model_contract import assert_renderable
from nisse_dev.cancel import Cancel
from nisse_dev.canonical import AssistantText, CanonicalEvent, Fact, ToolCall
from nisse_dev.canonical import (
AssistantText,
CanonicalEvent,
Fact,
ToolCall,
ToolResult,
)
from nisse_dev.gitea import Issue
from nisse_dev.llm import LLMError
from nisse_dev.loop.agent import LoopAgent
from nisse_dev.loop.driver import Driver
from nisse_dev.loop.items import CLOSED, GO_AHEAD, READY, RUNNING, WAITING, loop_of
from nisse_dev.loop.reader import command_form
from nisse_dev.oplog import OpLog
from nisse_dev.state import StateStore
from nisse_dev.transport import InMemoryTransport
@@ -205,6 +213,22 @@ def test_before_the_go_ahead_nothing_can_change_or_close(h: Harness) -> None:
assert {"restate", "ask_human", "read_file", "run_command"} <= h.model.offered[0]
@pytest.mark.parametrize("text", ["Go", "GO", "Go.", "go!", " go "])
def test_a_go_ahead_ignores_case_and_trailing_punctuation(
h: Harness, text: str
) -> None:
# A phone keyboard's "Approve" once counted as feedback, not approval (#64).
h.model.turns.append([call("close_item", summary="added and tested")])
h.agent.intake()
h.say(text)
assert h.store.work_items()[0].status == "closed"
def test_the_command_form_keeps_inner_words_apart() -> None:
assert command_form(" Do NEXT.") == "do next"
assert command_form("go ahead, but carefully") == "go ahead, but carefully"
def test_go_starts_the_work_and_close_item_closes_the_issue(h: Harness) -> None:
h.model.turns.append([call("close_item", summary="added and tested")])
h.agent.intake()
@@ -368,6 +392,61 @@ def test_stop_ends_a_run_at_the_next_boundary(tmp_path: Path) -> None:
assert outcome.kind == "stopped"
def test_a_failed_model_call_fails_the_run(tmp_path: Path) -> None:
class Down:
def complete(self, events, tools, model, system=None): # type: ignore[no-untyped-def]
raise LLMError("proxy down")
outcome = Driver(Down(), "m").run( # type: ignore[arg-type]
driver_log(tmp_path), system="s", tools=_tools("read_file"), workspace=None
)
assert outcome.kind == "failed" and "proxy down" in outcome.note
def test_stop_mid_turn_skips_the_rest_of_its_calls(tmp_path: Path) -> None:
cancel = Cancel()
def start(arguments: dict[str, Any]) -> tuple[str, bool]:
cancel.set() # the operator's stop lands while this call runs
return "started", True
model = ScriptedModel(
[call("start_milestone", name="m"), call("read_file", path="a")]
)
log = driver_log(tmp_path)
outcome = Driver(model, "m", cancel=cancel).run(
log,
system="s",
tools=_tools("start_milestone", "read_file"),
workspace=None,
handlers={"start_milestone": start},
)
assert outcome.kind == "stopped"
results = [e.event for e in log.read() if isinstance(e.event, ToolResult)]
assert [r.success for r in results] == [True, False] # the read never ran
def test_a_command_that_works_resets_the_failure_count(tmp_path: Path) -> None:
class Commands:
def dispatch(self, tool: str, arguments: dict[str, Any]) -> Any:
ok = arguments["command"] == "good"
return type("Outcome", (), {"result": "out", "success": ok})()
def run(command: str) -> list[Any]:
return [call("run_command", command=command)]
model = ScriptedModel(
run("bad"), run("good"), run("bad"), [call("ask_human", question="?")]
)
outcome = Driver(model, "m", failure_limit=2).run(
driver_log(tmp_path),
system="s",
tools=_tools("run_command", "ask_human"),
workspace=Commands(), # type: ignore[arg-type]
)
assert outcome.kind == "wait" # never two failures in a row
def _tools(*names: str) -> list[dict[str, Any]]:
return [
{"type": "function", "function": {"name": n, "parameters": {}}} for n in names