Answer architecture round 1: 0 🔴, 4 🟡 (0 misread); move the shared loop state out of loop_claude, split ranking and routing, give the reviewer rung one rule
CI / tests (pull_request) Successful in 2m14s

This commit is contained in:
2026-11-10 22:03:16 +01:00
parent 8a80d452f2
commit 70a1b95086
70 changed files with 748 additions and 625 deletions
+11 -11
View File
@@ -4,7 +4,7 @@ import typing
from release_plan.release_standing import default_plan, DefaultPlan
from git_cli.git_repo import default_ref, file_at
from loop_claude.effects import Effects, say
from loop_effects.effects import Effects, say
from failure import Failure
from loop_claude.routing import first_route, kept, routed_item
from release_plan.todo_table import Item
@@ -13,22 +13,22 @@ from loop_claude.cycle import prompts
from model_routing.route import Route, route_from
from model_routing.ladder import Rung
from claude_code.session import Session, session_open, transcript_file
from loop_claude.running_loops import Show, taken_items
from loop_state.running_loops import Show, taken_items
# Seconds routing waits for origin to name its default branch, asked only where the checkout records none; past them, the chunk runs on the project's rung.
ORIGIN_TIMEOUT = 60
def shown_items(show: Show, root: str, routed: int) -> typing.Callable[[tuple[int, ...]], None]:
def shown_items(show: Show, root: str, routed: int, effects: Effects) -> typing.Callable[[tuple[int, ...]], None]:
"""A function that lists in loop-inbox the items a chunk takes, given the IDs the judge found taken in. routed is the item the chunk was routed on, 0 for none. shown_items reads todo.md once, as the cycle starts, and the function shows those taglines."""
todo = fetched_todo(root)
todo = fetched_todo(root, effects)
return lambda taken_in: show(taken_items(todo, routed, taken_in))
def fetched_todo(root: str) -> str | Failure:
def fetched_todo(root: str, effects: Effects) -> str | Failure:
"""todo.md on the default branch, as last fetched. fetched_plan reads it too, but also the release tag, CHANGELOG.md and each todo.md since the tag, which the listing doesn't need."""
ref = default_ref(root, ORIGIN_TIMEOUT)
return ref if isinstance(ref, Failure) else file_at(ref, "todo.md", root)
ref = default_ref(root, ORIGIN_TIMEOUT, run=effects.git)
return ref if isinstance(ref, Failure) else file_at(ref, "todo.md", root, effects.git)
def routed(route: Route | None, project: Rung | None, model: str, archived: typing.Callable[[], Route | None], item: typing.Callable[[], Item | None]) -> Route:
@@ -58,7 +58,7 @@ def archived_route(archive_folder: pathlib.Path, session: Session, effects: Effe
def chunk_start(session: Session, preflight: pathlib.Path, root: str, effects: Effects) -> tuple[str, typing.Callable[[], Item | None]]:
"""The facts for a fresh worker's prompt, empty where the session is open, and the reader of the item that routes the chunk. The reader reads the default branch as last fetched: for a fresh chunk, by the preflight that runs first; for an open session, which runs none, by whatever fetched last."""
facts = "" if session_open(session) else chunk_facts(preflight, root, effects)
return facts, lambda: plan_item(fetched_plan(root), effects)
return facts, lambda: plan_item(fetched_plan(root, effects), effects)
def chunk_facts(preflight: pathlib.Path, root: str, effects: Effects) -> str:
@@ -69,10 +69,10 @@ def chunk_facts(preflight: pathlib.Path, root: str, effects: Effects) -> str:
return prompts.preflight_facts(done.stdout.strip())
def fetched_plan(root: str) -> DefaultPlan | Failure:
def fetched_plan(root: str, effects: Effects) -> DefaultPlan | Failure:
"""What the default branch, as last fetched, holds for routing."""
ref = default_ref(root, ORIGIN_TIMEOUT)
return ref if isinstance(ref, Failure) else default_plan(root, ref)
ref = default_ref(root, ORIGIN_TIMEOUT, run=effects.git)
return ref if isinstance(ref, Failure) else default_plan(root, ref, effects.git)
def plan_item(plan: DefaultPlan | Failure, effects: Effects) -> Item | None: