diff --git a/AGENTS.md b/AGENTS.md index dbed2c53..0a42931b 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -33,7 +33,7 @@ Decisions live in `docs/decisions.md`: - worker: a chunk's worker writes the simplest change that solves its item, test first wherever a test can check the change, and reads a technical principle only where the item, a finding or its own record names it; larv-review's reviewers hold the change to the principles and to the standards in `skills/larv-review/standards/` - review: stability and product-owner report only a defect, a broken requirement of the plan or the goals, a breach of a technical principle, or for stability a hard place the change touches; each architect finding names a later change the PR makes harder; prose runs only on a chunk that changes prose - review: the stability pass mutation-tests the lines a chunk changes, in place of measuring test coverage -- routing: one ladder of (model, effort) rungs, ordered by the Artificial Analysis Intelligence Index with Fable 5.1 at max on top; a task's R + C picks a rung by fixed bands, counted from the cheapest rung of the project's model, and a chunk's worker never runs below that rung +- routing: one ladder of (model, effort) rungs, ordered by the Artificial Analysis Intelligence Index with Fable 5.1 at max on top; a task's R + C picks a rung by fixed bands, counted from the cheapest rung of the project's model, and a chunk's worker may run below that rung, launching its reviewers on that rung ## Working rules diff --git a/CHANGELOG.md b/CHANGELOG.md index 64d29767..6821397f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,7 +2,7 @@ ## Unreleased -- `loop-claude` routes each chunk's worker on a ladder of model and effort rungs, from Haiku 5.5 at low effort to Fable 5.1 at max, when the project's model is on it. As a chunk starts, the R + C of `todo.md`'s top item in the next release picks the rung: 11–12 one rung above the project's model, which for Opus 5.5 is Opus 5.5 at high effort, and so on up to four rungs. The worker never runs below the project's model's cheapest rung, which for Opus 5.5 is medium effort, below the xhigh `settings.json` sets. It steps up one rung after every second unfinished verdict on a chunk, and to a higher rung when it takes in an item of higher R + C. Each cycle's header, and each finished or unfinished verdict, stop and step-up in the archive, name the worker's rung; a rerun resumes an open chunk on the latest rung archived for it. `docs/decisions.md` → `routing:` gives the ladder, its source and the bands. Expect a chunk on an easy item to cost less than under xhigh, and one on an item of R + C 15 or more to cost more. +- `loop-claude` routes each chunk's worker on a ladder of model and effort rungs, from Haiku 5.5 at low effort to Fable 5.1 at max, when the project's model is on it. As a chunk starts, the R + C of `todo.md`'s top item in the next release picks the rung: 11–12 picks one rung above the project's rung, so Opus 5.5 at high for an Opus 5.5 project, and so on up to four rungs. An item of R + C 10 or less runs the worker at or below the project's model's cheapest rung, which for Opus 5.5 is medium effort, below the xhigh `settings.json` sets. While the worker runs below the project's model's cheapest rung, it launches every reviewer, comprehension seat and security pass, the full scan included, in a subagent on that rung. It steps up one rung after every second unfinished verdict on a chunk, and to a higher rung when it takes in an item of higher R + C. Each cycle's header, and each finished or unfinished verdict, stop and step-up in the archive, name the worker's rung; a rerun resumes an open chunk on the latest rung archived for it. `docs/decisions.md` → `routing:` gives the ladder, its source and the bands. Expect a chunk on an easy item to cost much less than under xhigh, and perhaps to take more review rounds, and one on an item of R + C 15 or more to cost more. - A session reads `todo.md` up to `## Details`, and the details of only the items its chunk takes. It reads a `docs/decisions.md` entry only where the entry's title leaves open what it needs. Both rules are in `CLAUDE.md`, so they hold from a session's start. The decisions rule replaces one in `rules/decisions.md`, which loads only once a session has opened `docs/decisions.md` or `AGENTS.md`. A chunk's opening line now counts the unreleased changes instead of listing them. Expect fewer tokens read before a chunk's first commit. - larv-review's stability and product-owner reviewers report only a defect, a requirement of the plan or the goals that the change breaks, a breach of a technical principle, or for stability a hard place the change touches; the stability reviewer leaves the style of comments to the prose reviewer, which now also reads help and error text. Each architect finding names a concrete later change the PR makes harder, and one that names none is dropped. The prose pass runs only on a chunk that changes prose a reader reads, such as docs, comments, help text or `todo.md`, and skips a code-only chunk. Expect fewer findings and fewer review rounds. - Every `todo.md` item carries a C score, how hard the change is to get right, from 1 to 10, in a column after S. C stays out of the score. `rank_todo.py` fails on an items table without the column, and the rule hook then blocks committing that `todo.md`. Before the next commit that changes a project's `todo.md`, add the column and score every item's C, as `rank_todo.py --help` shows. diff --git a/bin/loop_claude/cycle/prompts.py b/bin/loop_claude/cycle/prompts.py index 2edce9f2..6287115d 100644 --- a/bin/loop_claude/cycle/prompts.py +++ b/bin/loop_claude/cycle/prompts.py @@ -1,3 +1,4 @@ +from model_routing.ladder import highest, Rung from loop_claude.project.records import HUMAN_RULE_NAMES, RECORD_FILES from markdown_text import quoted from loop_claude.routing import Route @@ -14,13 +15,17 @@ ANSWER_DESTINATIONS = "README.md's Goals or Audience, " + ", ".join(RECORD_FILES ANSWERS_RECORDED = f"every answer the human typed in it that a later chunk could need is recorded in {ANSWER_DESTINATIONS} at the one place it governs" -def fresh(task: str, premises: str, route: Route) -> str: - routed = f"{routed_by(route)}\n\n" if route.item else "" +def fresh(task: str, premises: str, route: Route, anchor: Rung | None) -> str: + routed = f"{routed_by(route, anchor)}\n\n" if route.item else "" return f"{task}\n\nContinue any open draft PR or worktree for the chunk before creating a new one.\n\n{routed}The chunk's todo.md items, or else the task above, set its scope. The goals below choose between ways to deliver that scope, and never widen it.\n\nFrom README.md:\n{premises}" -def routed_by(route: Route) -> str: - return f"loop-claude runs you on {route.rung}, routed by item {route.item}'s R + C of {route.risk_and_complexity}. Name each todo.md item this chunk takes, with its R + C, whether or not it is item {route.item}." +def routed_by(route: Route, anchor: Rung | None) -> str: + said = f"loop-claude runs you on {route.rung}, routed by item {route.item}'s R + C of {route.risk_and_complexity}. Name each todo.md item this chunk takes, with its R + C, whether or not it is item {route.item}." + if anchor is None or highest(route.rung, anchor) == route.rung: + return said + # The Agent tool takes a family name, such as opus, and runs that family's latest model; each rung names its family's latest, so the two match. + return f"{said} Your rung is below the project's, {anchor}: launch each reviewer, each comprehension seat and the security pass's subagent with the Agent tool's model `{anchor.model.split('-')[1]}` and effort `{anchor.effort}`, and run a full scan only from such a subagent, since the scan's agents run on the model that starts them." def resumed(unfinished_evidence: str) -> str: diff --git a/bin/loop_claude/cycle/run.py b/bin/loop_claude/cycle/run.py index 3b5fc656..3f2fc80f 100644 --- a/bin/loop_claude/cycle/run.py +++ b/bin/loop_claude/cycle/run.py @@ -16,6 +16,7 @@ from claude_code.transcript import read_transcript, render from loop_claude.cycle.retry import retried from loop_claude.routing import Route from loop_claude.cycle.worker import run_worker, worker_args +from model_routing.ladder import Rung from loop_claude.stop import Stop @@ -31,6 +32,8 @@ class Cycle: session: Session task: str route: Route + # The project's rung; None for a model off the ladder. + anchor: Rung | None # Empty when the previous cycle's verdict was not Unfinished. unfinished_evidence: str @@ -86,7 +89,7 @@ def worker_start(cycle: Cycle, answered: QuotedAnswer | None) -> list[str]: return worker_args(cycle.session, cycle.route.rung, prompts.answered(answered.question, answered.answer), resume=True) if session_open(cycle.session): return worker_args(cycle.session, cycle.route.rung, prompts.resumed(cycle.unfinished_evidence), resume=True) - return worker_args(cycle.session, cycle.route.rung, prompts.fresh(cycle.task, cycle.premises, cycle.route), resume=False) + return worker_args(cycle.session, cycle.route.rung, prompts.fresh(cycle.task, cycle.premises, cycle.route, cycle.anchor), resume=False) def keep_answer(cycle: Cycle, answered: QuotedAnswer) -> Stop | None: diff --git a/bin/loop_claude/loop/main.py b/bin/loop_claude/loop/main.py index b48c05e7..ea9fe014 100644 --- a/bin/loop_claude/loop/main.py +++ b/bin/loop_claude/loop/main.py @@ -36,23 +36,26 @@ the transcript, are copied into /session/. A file there is replaced only grew from it. A file Claude Code rewrote lands beside its copy as .. Every claude loop-claude starts runs the project's model, saved per in -~/.claude/loop-claude-models.json and read each cycle; a project without an entry, as on its first +~/.claude/loop-claude-models.json and read each cycle, unless routing, below, puts the worker and +the interrupt on another rung; a project without an entry, as on its first run, is asked for one. LOOP_CLAUDE_JUDGE_MODEL overrides it for the judge, LOOP_CLAUDE_WORKER_MODEL for the worker and the interrupt; with both set, nothing is asked. Where that model is on the routing ladder (bin/model_routing/ladder.py), the worker and the interrupt run on one of the ladder's rungs: a model at an effort. As a chunk starts, the R + C of todo.md's top item in the next release, skipping an item marked question, picks the rung. It -counts from the model's cheapest rung and never goes 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 -the item, and asks the worker to name each item the chunk takes, with its R + C. The judge reports -the highest R + C the worker states, and the next cycle steps up to the rung that R + C picks, -never down. Every second unfinished verdict on a chunk steps it up one rung. Each finished or -unfinished verdict, stop and step-up in the archive names the worker's rung, with the item and -R + C that routed the chunk; a rerun resumes an open chunk on the latest rung named there, and -counts its unfinished verdicts afresh. A rung no longer on the ladder, or -below the model's cheapest, is dropped, and the chunk is routed afresh from todo.md. A todo.md or -an archive that cannot be read or parsed is said on stderr, and the chunk is routed without it. +counts from the model's cheapest rung, and an R + C of 8 or less picks a rung 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 the item, and asks the worker to name each item the chunk takes, with its +R + C. When that rung is below the model's cheapest, the prompt also has the worker launch each +reviewer, each comprehension seat and the security pass in subagents on the cheapest rung. The +judge reports the highest R + C the worker states, and the next cycle steps up to the rung that +R + C picks, never down. Every second unfinished verdict on a chunk steps it up one rung. Each +finished or unfinished verdict, stop and step-up in the archive names the worker's rung, with the +item and R + C that routed the chunk; a rerun resumes an open chunk on the latest rung named there, +and counts its unfinished verdicts afresh. A rung no longer on the ladder, or below the one its +item's R + C picks, is dropped, and the chunk is routed afresh from todo.md. A todo.md or an +archive that cannot be read or parsed is said on stderr, and the chunk is routed without it. 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. @@ -153,7 +156,7 @@ def run_loop(argv: list[str], env: typing.Mapping[str, str], paths: Paths, launc loop_run = routed(loop_run, anchor, lambda: archived_route(archive_folder, session), lambda: plan_item(root)) 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_folder, records=records, root=loop_run.root, route=route, session=session, task=loop_run.task, unfinished_evidence=loop_run.unfinished_evidence)) + verdict = run_cycle(Cycle(anchor=anchor, effects=effects, judge_model=models.judge, paths=paths, premises=premises, project_archive=archive_folder, 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 before, loop_run = loop_run.route, after_verdict(loop_run, anchor, verdict) @@ -162,8 +165,8 @@ def run_loop(argv: list[str], env: typing.Mapping[str, str], paths: Paths, launc def routed(loop_run: LoopRun, anchor: Rung | None, archived: typing.Callable[[], Route | None], item: typing.Callable[[], Item | None]) -> LoopRun: - """The loop run with its chunk's route, none off the ladder. A chunk keeps its route, or on a rerun the one its archive last names, - while that is at or above anchor, the project's rung; else the plan item routes it afresh.""" + """The loop run with its chunk's route, or None when the project's model is off the ladder. A chunk keeps its route, or on a rerun the one its archive last names, + while that is at or above the rung its item's R + C picks from anchor, the project's rung; else the plan item routes it afresh.""" if anchor is None: return dataclasses.replace(loop_run, route=None) route = loop_run.route or archived() diff --git a/bin/loop_claude/routing.py b/bin/loop_claude/routing.py index dd637906..1064532f 100644 --- a/bin/loop_claude/routing.py +++ b/bin/loop_claude/routing.py @@ -3,7 +3,7 @@ import dataclasses import re from failure import Failure -from model_routing.ladder import highest, picked, Rung, stepped_up +from model_routing.ladder import highest, LADDER, picked, Rung, stepped_up from todo_table import Item, items UNFINISHED_PER_STEP = 2 @@ -45,20 +45,22 @@ def routed_item(todo: str) -> Item | Failure | None: def first_route(anchor: Rung, item: Item | None) -> Route: - """The route a chunk starts on: the rung its item's R + C picks from anchor, the project's rung, never below it.""" + """The route a chunk starts on: the rung its item's R + C picks from anchor, the project's rung.""" if item is None: return Route(anchor) - return Route(highest(anchor, picked(anchor, item.risk_and_complexity)), item.id, item.risk_and_complexity) + return Route(picked(anchor, item.risk_and_complexity), item.id, item.risk_and_complexity) def kept(route: Route, anchor: Rung) -> bool: - """Whether a route carries on from anchor, the project's rung: its rung is on the ladder at or above it.""" - return highest(route.rung, anchor) == route.rung + """Whether a chunk keeps route: its rung is on the ladder at or above the rung its item's R + C picks from anchor, the project's rung, or anchor itself when no item routed it.""" + return highest(route.rung, picked(anchor, route.risk_and_complexity) if route.item else anchor) == route.rung def stepped(anchor: Rung, route: Route, bundled: int) -> Route: """The route after one more unfinished verdict; bundled is the highest R + C the judge saw the worker take into the chunk, 0 for none.""" - rung = highest(route.rung, anchor, picked(anchor, bundled) if bundled else anchor) + # An archived rung since removed from LADDER restarts from the project's rung. + rung = route.rung if route.rung in LADDER else anchor + rung = highest(rung, picked(anchor, bundled)) if bundled else rung if route.unfinished + 1 >= UNFINISHED_PER_STEP: return dataclasses.replace(route, rung=stepped_up(rung), unfinished=0) return dataclasses.replace(route, rung=rung, unfinished=route.unfinished + 1) diff --git a/bin/loop_claude/test_black_box.py b/bin/loop_claude/test_black_box.py index 6621291b..c995bb53 100644 --- a/bin/loop_claude/test_black_box.py +++ b/bin/loop_claude/test_black_box.py @@ -395,6 +395,16 @@ class Cycles(unittest.TestCase): self.assertIn(" Verdict: unfinished\n\nEvidence:\n> three\n\nWorker: claude-opus-5-5 at xhigh effort, routed by item 4's R + C of 11\n\n Stepped up\n\nWorker: claude-fable-5-1 at max effort, routed by item 4's R + C of 11\n", outcomes) self.assertIn(" Verdict: finished\n\nEvidence:\n> four\n\nWorker: claude-fable-5-1 at max effort, routed by item 4's R + C of 11\n", outcomes) + def test_runs_a_cheap_items_worker_below_the_projects_rung_with_its_reviewers_on_it(self): + checkout = Checkout(self) + checkout.env["LOOP_CLAUDE_WORKER_MODEL"] = "claude-opus-5-5" + (checkout.root / "todo.md").write_text(TODO.replace("| 5 | 2 | 6 |", "| 2 | 2 | 5 |")) + run = checkout.run([worker(say="one"), judge(finished=True, evidence="one"), worker(say="next chunk")]) + self.assertEqual(run.code, 130) + first = next(call for call in run.calls if call["role"] == "worker") + self.assertEqual((argument(first, "--model"), argument(first, "--effort")), ("claude-sonnet-5-5", "high")) + self.assertIn("Your rung is below the project's, claude-opus-5-5 at medium effort: launch each reviewer, each comprehension seat and the security pass's subagent with the Agent tool's model `opus` and effort `medium`", argument(first, "-p")) + def test_a_rerun_resumes_an_open_chunk_on_the_rung_it_last_ran(self): checkout = Checkout(self) checkout.env["LOOP_CLAUDE_WORKER_MODEL"] = "claude-opus-5-5" diff --git a/bin/loop_claude/test_loop_claude.py b/bin/loop_claude/test_loop_claude.py index 62788113..02a0ab0a 100644 --- a/bin/loop_claude/test_loop_claude.py +++ b/bin/loop_claude/test_loop_claude.py @@ -171,7 +171,7 @@ class Cycles(unittest.TestCase): self.archive = project_archive(str(self.home / "code" / "proj"), self.home, {}) def cycle(self, fake, records="", unfinished_evidence=""): - return run.Cycle(effects=fake.effects(), judge_model="judge-model", paths=self.paths, premises="## Goals", project_archive=self.archive, records=records, root=str(self.home), route=routing.Route(Rung("worker-model")), session=self.session, task="Do it.", unfinished_evidence=unfinished_evidence) + return run.Cycle(anchor=None, effects=fake.effects(), judge_model="judge-model", paths=self.paths, premises="## Goals", project_archive=self.archive, records=records, root=str(self.home), route=routing.Route(Rung("worker-model")), session=self.session, task="Do it.", unfinished_evidence=unfinished_evidence) def archived_outcomes(self): return sorted(path.read_text() for path in self.archive.glob("*/*.outcomes.md")) @@ -410,10 +410,10 @@ class Routing(unittest.TestCase): self.assertIsNone(routing.routed_item(without_c)) self.assertEqual(routing.routed_item(TODO.replace("| 5 | 3 |", "| x | 3 |")), Failure("item 3's R 'x' is not a whole number from 1 to 10")) - def test_starts_a_chunk_on_the_rung_its_items_r_plus_c_picks_never_below_the_projects(self): + def test_starts_a_chunk_on_the_rung_its_items_r_plus_c_picks_below_the_projects_too(self): self.assertEqual(routing.first_route(self.OPUS, routing.routed_item(TODO)), routing.Route(self.HIGH, 3, 11)) cheap = routing.routed_item(TODO.replace("| 5 | 3 | 6 |", "| 1 | 3 | 1 |")) - self.assertEqual(routing.first_route(self.OPUS, cheap), routing.Route(self.OPUS, 3, 2)) + self.assertEqual(routing.first_route(self.OPUS, cheap), routing.Route(Rung("claude-haiku-5-5", "xhigh"), 3, 2)) self.assertEqual(routing.first_route(self.OPUS, None), routing.Route(self.OPUS)) def test_steps_up_a_rung_after_every_second_unfinished_verdict(self): @@ -427,6 +427,12 @@ class Routing(unittest.TestCase): self.assertEqual(routing.stepped(self.OPUS, routing.Route(self.XHIGH), 11).rung, self.XHIGH) self.assertEqual(routing.stepped(self.OPUS, routing.Route(self.OPUS, unfinished=1), 13).rung, Rung("claude-opus-5-5", "max")) + def test_steps_up_from_a_rung_below_the_projects_one_rung_at_a_time(self): + low = routing.Route(Rung("claude-haiku-5-5", "xhigh"), 3, 2, 1) + self.assertEqual(routing.stepped(self.OPUS, low, 0).rung, Rung("claude-haiku-5-5", "max")) + self.assertEqual(routing.stepped(self.OPUS, routing.Route(low.rung, 3, 2), 0).rung, low.rung) + self.assertEqual(routing.stepped(self.OPUS, routing.Route(low.rung, 3, 2), 7).rung, Rung("claude-sonnet-5-5", "high")) + def test_a_rung_an_edit_took_off_the_ladder_counts_as_the_projects(self): self.assertEqual(routing.stepped(self.OPUS, routing.Route(Rung("claude-opus-5-5", "low")), 0).rung, self.OPUS) self.assertEqual(routing.stepped(self.OPUS, routing.Route(Rung("claude-opus-5-5", "low")), 2).rung, self.OPUS) @@ -439,7 +445,7 @@ class Routing(unittest.TestCase): self.assertEqual(str(routing.Route(Rung("worker-model"))), "worker-model") self.assertIsNone(routing.route_from("worker-model")) - def test_keeps_a_chunks_route_or_its_archived_one_at_or_above_the_projects_rung_and_else_routes_afresh(self): + def test_keeps_a_chunks_route_or_its_archived_one_at_or_above_the_rung_its_item_picks_and_else_routes_afresh(self): def run_with(route=None): return main.LoopRun(cycle_number=1, root="/r", task="do it", unfinished_evidence="", route=route) item = routing.routed_item(TODO) @@ -452,6 +458,9 @@ class Routing(unittest.TestCase): self.assertEqual(main.routed(run_with(), self.OPUS, lambda: None, lambda: item).route, routing.Route(self.HIGH, 3, 11)) below = routing.Route(Rung("claude-sonnet-5-5", "high")) self.assertEqual(main.routed(run_with(below), self.OPUS, never, lambda: None).route, routing.Route(self.OPUS)) + cheap = routing.Route(Rung("claude-sonnet-5-5", "high"), 4, 6) + self.assertEqual(main.routed(run_with(cheap), self.OPUS, never, never).route, cheap) + self.assertEqual(main.routed(run_with(routing.Route(Rung("claude-haiku-5-5", "max"), 4, 7)), self.OPUS, never, lambda: None).route, routing.Route(self.OPUS)) class RouteSources(unittest.TestCase): @@ -522,15 +531,22 @@ class Steps(unittest.TestCase): class WorkerArgs(unittest.TestCase): def test_names_the_route_in_a_fresh_prompt_only_where_an_item_routed_it(self): - routed = prompts.fresh("Do it.", "## Goals", routing.Route(Rung("m", "high"), 3, 11)) + routed = prompts.fresh("Do it.", "## Goals", routing.Route(Rung("m", "high"), 3, 11), None) self.assertIn("Continue any open draft PR or worktree for the chunk before creating a new one.\n\nloop-claude runs you on m at high effort, routed by item 3's R + C of 11. Name each todo.md item this chunk takes, with its R + C, whether or not it is item 3.\n\nThe chunk's", routed) - unrouted = prompts.fresh("Do it.", "## Goals", routing.Route(Rung("m"))) + unrouted = prompts.fresh("Do it.", "## Goals", routing.Route(Rung("m")), None) self.assertIn("before creating a new one.\n\nThe chunk's", unrouted) self.assertNotIn("loop-claude runs you on", unrouted) + def test_keeps_reviewers_on_the_projects_rung_while_the_worker_runs_below_it(self): + opus = Rung("claude-opus-5-5", "medium") + below = prompts.fresh("Do it.", "## Goals", routing.Route(Rung("claude-sonnet-5-5", "high"), 3, 5), opus) + self.assertIn("whether or not it is item 3. Your rung is below the project's, claude-opus-5-5 at medium effort: launch each reviewer, each comprehension seat and the security pass's subagent with the Agent tool's model `opus` and effort `medium`, and run a full scan only from such a subagent, since the scan's agents run on the model that starts them.\n\n", below) + for route in (routing.Route(opus, 3, 9), routing.Route(Rung("claude-opus-5-5", "high"), 3, 11)): + self.assertNotIn("below the project's", prompts.fresh("Do it.", "## Goals", route, opus)) + def test_opens_a_fresh_session_by_name_and_resumes_an_open_one(self): opened = session.session_named("A proj loop-claude", pathlib.Path("/h/.claude/projects")) - fresh = worker.worker_args(opened, Rung("m"), prompts.fresh("Do it.", "## Goals\n1. g\n\n## Audience\nme", routing.Route(Rung("m"))), resume=False) + fresh = worker.worker_args(opened, Rung("m"), prompts.fresh("Do it.", "## Goals\n1. g\n\n## Audience\nme", routing.Route(Rung("m")), None), resume=False) self.assertEqual(fresh[fresh.index("--session-id") + 1], str(opened.id)) self.assertEqual(fresh[fresh.index("--name") + 1], "A proj loop-claude") resumed = worker.worker_args(opened, Rung("m"), prompts.resumed(""), resume=True) diff --git a/docs/decisions.md b/docs/decisions.md index 2f344244..dc988fbc 100644 --- a/docs/decisions.md +++ b/docs/decisions.md @@ -170,13 +170,15 @@ The run has no time cap. Limiting it to the changed lines already bounds it by t Valid while a mutation run on a chunk's changed lines stays cheap beside the review itself. -## routing: one ladder of (model, effort) rungs, ordered by the Artificial Analysis Intelligence Index with Fable 5.1 at max on top; a task's R + C picks a rung by fixed bands, counted from the cheapest rung of the project's model, and a chunk's worker never runs below that rung +## routing: one ladder of (model, effort) rungs, ordered by the Artificial Analysis Intelligence Index with Fable 5.1 at max on top; a task's R + C picks a rung by fixed bands, counted from the cheapest rung of the project's model, and a chunk's worker may run below that rung, launching its reviewers on that rung 2026-10-14, lilleman. Serves goal 1.4, and goal 1.3: one ladder, the same in every project, read by loop-claude now, and by larv-review and the worker once items 90 and 92 land. `bin/model_routing/ladder.py` holds the rungs and the bands. The rungs, least competent first: Haiku 5.5 at low, medium, high, xhigh and max; Sonnet 5.5 at high; Opus 5.5 at medium, high, xhigh and max; Fable 5.1 at max. The order and the cut come from the Artificial Analysis Intelligence Index (https://artificialanalysis.ai/leaderboards/models, read 2026-10-14), which scores each model at each effort and gives a cost per task. A rung stays only where no cheaper rung scores as high, so a step up always buys more score (goal 1.4). That cut drops Sonnet 5.5 at low, medium, xhigh and max, Opus 5.5 at low, and every Fable 5.1 rung, and every tie in the index falls among the dropped rungs. lilleman put Fable 5.1 at max back on top: the index scores it under Opus 5.5 at high, but Anthropic's model catalog names Fable the most capable model, and for the hardest tasks lilleman wants the highest quality at any price. -A chunk's worker never runs below the project's rung, until `todo.md` item 93 shows a cheaper worker takes no more review rounds (goal 1.1). A project's rung is its model's cheapest rung, which for Opus 5.5 is its default effort, medium. lilleman chose medium knowing `settings.json` runs Opus 5.5 at xhigh, so a routed worker runs below the effort an interactive session takes. A model off the ladder routes nothing: claude runs it at the effort its settings give. R + C steps a task from the project's rung: 2–4 three rungs down, 5–6 two down, 7–8 one down, 9–10 none, 11–12 one up, 13–14 two up, 15–16 three up, 17 and above four up. A step past either end stops there. The bands spread the R + C that `todo.md`'s items held on 2026-10-14, 2 to 12, across the rungs, so most tasks would step down; a chunk's worker does not, until item 93 lands. S never moves a rung, so a huge task with low R and C runs cheap. The comprehension panel and the security pass stay on the project's model. `score-outcomes` had too few finished chunks to ground the bands; `todo.md` item 94 measures the routes' outcomes, and a change to the ladder or the bands is lilleman's. +A chunk's worker runs on the rung its item picks, below the project's rung too. Only chunks run below the project's rung can prove that a cheaper worker holds quality (goal 1.1). So on 2026-10-14 lilleman chose a trial on real chunks: a replay of past chunks spends on work nothing ships (goal 1.4). Review holds quality meanwhile. While the worker runs below the project's rung, loop-claude's prompt has it launch each reviewer, each comprehension seat and the security pass's subagent on the project's rung, through the Agent tool's model and effort. It runs a full scan only from such a subagent, because the `claude-security` plugin's researchers and verifiers inherit the model that starts them. A subagent that cannot run the scan leaves it unavailable, so larv-review runs `/security-review` in its place. The cost of a cheaper worker shows as extra review rounds and unfinished verdicts, which `todo.md` item 94 is to measure, interrupting lilleman when a rung takes more of either than the rung above. A project's rung is its model's cheapest rung, which for Opus 5.5 is its default effort, medium. lilleman chose medium knowing `settings.json` runs Opus 5.5 at xhigh, so a routed worker runs below the effort an interactive session takes. + +A model off the ladder routes nothing: claude runs it at the effort its settings give. R + C steps a task from the project's rung: 2–4 three rungs down, 5–6 two down, 7–8 one down, 9–10 none, 11–12 one up, 13–14 two up, 15–16 three up, 17 and above four up. A step past either end stops there. The bands spread the R + C that `todo.md`'s items held on 2026-10-14, 2 to 12, across the rungs, so most tasks step down. S never moves a rung, so a huge task with low R and C runs cheap. While the worker runs above the project's rung, the comprehension seats and the security pass inherit its rung; `todo.md` item 138 keeps them on the project's rung. `score-outcomes` had too few finished chunks to ground the bands, and a change to the ladder or the bands is lilleman's. The worker changes rung only as the chunk starts, after every second unfinished verdict, or when the judge reports a taken-in item whose R + C picks a higher rung, because a model switch inside a session discards its prompt cache. loop-claude routes on the first row of the next release in `todo.md`'s table that waits on no question. It reads neither an order the plan states in prose nor the task, so a chunk may start on another item's rung: a higher one costs money, and a lower one holds until the judge reports the item the worker took in, after the first cycle. `todo.md` item 136 ends this, routing on the item the worker says it takes. diff --git a/docs/reading-cost.md b/docs/reading-cost.md index 099ef84b..21b42e25 100644 --- a/docs/reading-cost.md +++ b/docs/reading-cost.md @@ -265,3 +265,20 @@ Read most (opens and searches): - `AGENTS.md` 1 - `README.md` 1 - `agents/stability-reviewer.md` 1 + +## Reading cost, chunk 6c8adbd6a04e, finished 2026-10-14T21:40:54Z + +110916 new input tokens before the first commit. + +Read most (opens and searches): + +- `todo.md` 6 +- `CHANGELOG.md` 3 +- `README.md` 3 +- `bin/loop_claude/test_black_box.py` 2 +- `bin/rank_todo.py` 2 +- `bin/todo_table.py` 2 +- `bin/claude_code/model_catalog.py` 1 +- `bin/larv_review/plan.py` 1 +- `bin/loop_claude/cycle/judge.py` 1 +- `bin/loop_claude/cycle/prompts.py` 1 diff --git a/todo.md b/todo.md index e5fbb8b4..90162821 100644 --- a/todo.md +++ b/todo.md @@ -6,7 +6,7 @@ `Bar = 9` -`Next ID = 138` +`Next ID = 139` | Goal | W | |---|---| @@ -26,11 +26,11 @@ Release 0.2.0 takes items 125, 114 and 124 first, whatever their scores: Shape i | ID | Release | Exempt | Item | R | S | C | A | G | Goals | Score | |---|---|---|---|---|---|---|---|---|---|---| -| 93 | 0.1.0 | decision | **Let a chunk's worker start below the project's model, once the archive shows chunks on a lower rung took no more review rounds than chunks on the project's model.** | 3 | 2 | 6 | 6 | 7 | 1.1, 1.4 | 22.4 | | 94 | 0.1.0 | decision | **Every 20th cycle, have loop-claude measure token spend and routing outcomes, file them here, and interrupt the human only when they call for a routing change.** | 3 | 5 | 6 | 6 | 7 | 1.1, 1.4 | 21.6 | | 90 | 0.1.0 | | **Route each reviewer by the chunk's R + C, once a replay of past chunks shows the routed reviewer finds the 🔴 and 🟡 findings on record.** | 4 | 5 | 8 | 6 | 7 | 1.4 | 20.2 | | 92 | 0.1.0 | | **Have the worker route each subagent by its task's R + C, and delegate a task only when the worker needs just its conclusion.** | 2 | 2 | 5 | 5 | 6 | 1.4 | 19.0 | | 89 | 0.1.0 | | **Run the judge on the rung its chunk's R + C picks, once a replay of archived transcripts shows it returns the verdicts on record.** | 3 | 4 | 7 | 5 | 6 | 1.4 | 17.5 | +| 138 | 0.1.0 | decision | **Keep the comprehension seats and the security pass on the project's rung while a chunk's worker runs above it.** | 2 | 2 | 3 | 4 | 5 | 1.1 | 15.4 | | 136 | 0.1.0 | decision | **Route a chunk on the item its worker says it takes, in place of the next release's first row.** | 2 | 3 | 4 | 4 | 5 | 1.4 | 14.8 | | 105 | 0.2.0 | decision | **Compare review rounds per pass and reading cost for the five chunks before and after the `worker:` decision moved the principles out of the worker's context, and file an item if either rose.** | 1 | 2 | 3 | 5 | 6 | 1.4 | 20.0 | | 112 | 0.2.0 | | **Count an item as shipped only where its chunk built it, so an item a chunk dropped from the plan gets no outcome.** | 2 | 3 | 5 | 5 | 6 | 1.1 | 19.1 | @@ -87,10 +87,6 @@ Release 0.2.0 takes items 125, 114 and 124 first, whatever their scores: Shape i ## Details -### 93. Let a chunk's worker start below the project's model, once the archive shows chunks on a lower rung took no more review rounds than chunks on the project's model. - -Goal 1.1 asks for proven quality, so stepping down waits on the archive's evidence. - ### 94. Every 20th cycle, have loop-claude measure token spend and routing outcomes, file them here, and interrupt the human only when they call for a routing change. Count the cycles across all projects in loop-claude's archive, which holds every project's transcripts on the machine. Measure in code, as `bin/reading-cost` does, so the check itself costs no model run (goal 1.4): tokens by project, subagent type, rung and tool, and per routed chunk its review rounds and unfinished verdicts. A loop on another project cannot commit here, so it writes the figures to the archive, and this repo's next chunk files or refreshes one plan item from them. The ladder's thresholds and the delegation rule are decisions, so a change to them is the human's. Interrupt when chunks on a rung took more review rounds or unfinished verdicts than chunks on the rung above, or when subagent reports fill more of the worker's peak context than the searches they replaced would have; never twice for the same figures (goal 1.2). @@ -109,9 +105,13 @@ State in `CLAUDE.md` when the worker delegates: a search or read that spans many loop-claude starts the judge itself (`bin/loop_claude/cycle/judge.py`), so it routes without any skill change. Replay the judge on archived cycles at the candidate rung, and switch only when its interrupts and verdicts match those on record. +### 138. Keep the comprehension seats and the security pass on the project's rung while a chunk's worker runs above it. + +`bin/loop_claude/cycle/prompts.py`'s `routed_by` names the project's rung only while the worker runs below it, so from Opus 5.5 at high up to Fable 5.1 at max the seats and the `/security-review` subagent inherit the worker's rung, and the seats' scores vary with each item's R + C. The other reviewers may stay on the worker's higher rung; item 90 routes them. + ### 136. Route a chunk on the item its worker says it takes, in place of the next release's first row. -loop-claude routes on the first row of the next release, while the worker takes the item the plan's prose orders first, or a prerequisite, as the chunk that shipped 88 took it over 93. A first row of higher R + C pays for a dearer rung all chunk; one of lower R + C holds until the judge reports the item taken in. The judge reports the item the worker takes only after the first cycle, so routing the first cycle right needs the item before the worker starts. +loop-claude routes on the first row of the next release, while the worker takes the item the plan's prose orders first, or a prerequisite, as the chunk that shipped item 88, a prerequisite, took item 88 in place of the first row. A first row of higher R + C pays for a dearer rung all chunk; one of lower R + C holds until the judge reports the item taken in. The judge reports the item the worker takes only after the first cycle, so routing the first cycle right needs the item before the worker starts. ### 105. Compare review rounds per pass and reading cost for the five chunks before and after the `worker:` decision moved the principles out of the worker's context, and file an item if either rose. @@ -201,7 +201,7 @@ PR #257's scoring run put Shape at 6.25, the lowest dimension. `bin/` holds abou ### 118. Have `score-outcomes` count review rounds only from chunks merged after 2026-10-13, when review passes were narrowed, so C's medians compare chunks reviewed under one rule. -Since 2026-10-13 (`docs/decisions.md` → "review: stability and product-owner report only…"), reviewers report fewer findings and later rounds review only the answers to earlier ones, to cut rounds. A chunk merged before it took more rounds for the same C, so mixing both eras skews C's medians and item 93's comparison of rungs. +Since 2026-10-13 (`docs/decisions.md` → "review: stability and product-owner report only…"), reviewers report fewer findings and later rounds review only the answers to earlier ones, to cut rounds. A chunk merged before it took more rounds for the same C, so mixing both eras skews C's medians and item 94's comparison of rungs. ### 130. Move the vote counting out of `bin/larv_review/ruling.py`'s `votes`, so reading a votes file decides nothing.