Answer architecture round 1: 1 🔴, 5 🟡; track bin/model_routing, hand over the route by its rung, share the R + C mapping, record the routing item, and have the judge report R + C plainly

This commit is contained in:
2026-10-14 22:56:03 +02:00
parent a387e62e78
commit c75e576773
15 changed files with 258 additions and 111 deletions
+21 -22
View File
@@ -44,11 +44,12 @@ Where that model is on the routing ladder (bin/model_routing/ladder.py), the wor
interrupt run on a rung of it instead: a model at an effort. As a chunk starts, the R + C of
todo.md's top item in the next release, skipping a question, picks the rung from the model's
cheapest one, and never below it; without such an item, or with a C missing, the chunk runs on the
model's cheapest rung. The worker's first prompt names the rung and asks it to say when the chunk
takes in an item of higher R + C. The judge reports the highest such R + C it sees the worker say,
and the next cycle steps up to the rung that picks, never down. Every second unfinished verdict on
a chunk steps it up one rung. A rerun routes an open chunk afresh. The archive records each
verdict's rung.
model's cheapest rung. The worker's first prompt names the rung and the item, and asks it to name
each other item the chunk takes in, with its R + C. The judge reports the highest R + C it sees the
worker state, and the next cycle steps up to the rung that picks, never down. Every second
unfinished verdict on a chunk steps it up one rung. A rung an edit took off the ladder counts as
the model's cheapest. A rerun routes an open chunk afresh. The archive records each verdict's rung,
with the item and R + C that routed the chunk.
A change to bin/loop-claude or any bin/**/*.py takes effect at the next cycle boundary, once
loop-claude --help succeeds: the loop reloads into the edited script.
@@ -95,13 +96,12 @@ from loop_claude.cycle.run import Cycle, run_cycle
from loop_claude.loop.reload import decode_handed, exec_if_edited, fingerprint, LoopRun, RELOAD_FLAG
from loop_claude.effects import Effects
from loop_claude.cycle.judge import Finished, Unfinished
from loop_claude.cycle.routing import first_rung, routed_item, stepped
from loop_claude.loop.routing import first_route, Route, routed_item, stepped
from loop_claude.project.model_choice import get_or_ask_models
from model_routing.ladder import LADDER, project_rung, Rung
from loop_claude.paths import Paths
from transcript_archive.location import project_archive
from project_key import project_key
from loop_claude.cycle import prompts
from model_routing.ladder import project_rung, Rung
from loop_claude.project.premises import read_premises
from loop_claude.project.records import read_records
from claude_code.session import session_named
@@ -141,30 +141,29 @@ def run_loop(argv: list[str], env: typing.Mapping[str, str], paths: Paths, launc
if isinstance(models, Stop):
return models
anchor = project_rung(models.worker)
loop_run, worker, routed = route_worker(loop_run, anchor, models.worker)
print(f"\n=== cycle {loop_run.cycle_number}, worker on {worker} ===", flush=True)
verdict = run_cycle(Cycle(effects=effects, judge_model=models.judge, paths=paths, premises=premises, project_archive=archive, records=records, root=loop_run.root, routed=routed, session=session, task=loop_run.task, unfinished_evidence=loop_run.unfinished_evidence, worker=worker))
loop_run = routed(loop_run, anchor)
route = loop_run.route or Route(Rung(models.worker))
print(f"\n=== cycle {loop_run.cycle_number}, worker on {route.rung} ===", flush=True)
verdict = run_cycle(Cycle(effects=effects, judge_model=models.judge, paths=paths, premises=premises, project_archive=archive, records=records, root=loop_run.root, route=route, session=session, task=loop_run.task, unfinished_evidence=loop_run.unfinished_evidence))
if isinstance(verdict, Stop):
return verdict
loop_run = after_verdict(loop_run, anchor, verdict)
def route_worker(loop_run: LoopRun, anchor: int | None, project_model: str) -> tuple[LoopRun, Rung, str]:
"""The loop run, the worker's rung, and what the fresh prompt says of its route; a chunk is routed once, as it starts."""
def routed(loop_run: LoopRun, anchor: int | None) -> LoopRun:
"""The loop run with its chunk's route; a chunk is routed once, as it starts, and not at all off the ladder."""
if anchor is None:
return loop_run, Rung(project_model), ""
if loop_run.rung >= 0:
return loop_run, LADDER[loop_run.rung], ""
item = routed_item(read_todo(loop_run.root))
loop_run = dataclasses.replace(loop_run, rung=first_rung(anchor, item), unfinished=0)
return loop_run, LADDER[loop_run.rung], prompts.routed(LADDER[loop_run.rung], item) if item else ""
return dataclasses.replace(loop_run, route=None)
if loop_run.route:
return loop_run
return dataclasses.replace(loop_run, route=first_route(anchor, routed_item(read_todo(loop_run.root))))
def after_verdict(loop_run: LoopRun, anchor: int | None, verdict: Finished | Unfinished) -> LoopRun:
if isinstance(verdict, Finished):
return dataclasses.replace(loop_run, rung=-1, unfinished=0, unfinished_evidence="")
rung, unfinished = stepped(anchor, loop_run.rung, loop_run.unfinished, verdict.bundled) if anchor is not None else (loop_run.rung, 0)
return dataclasses.replace(loop_run, rung=rung, unfinished=unfinished, unfinished_evidence=verdict.evidence)
return dataclasses.replace(loop_run, route=None, unfinished_evidence="")
route = stepped(anchor, loop_run.route, verdict.bundled) if anchor is not None and loop_run.route else loop_run.route
return dataclasses.replace(loop_run, route=route, unfinished_evidence=verdict.evidence)
def read_todo(root: str) -> str: