diff --git a/CHANGELOG.md b/CHANGELOG.md index ad891685..c0226523 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,7 +2,7 @@ ## Unreleased -- A session or subagent below the project's rung, the cheapest rung of the project's model, no longer scores or reshapes `todo.md`: it drafts each new item and each change to a filed item, and before its next commit one subagent on the project's rung applies and scores the drafts and sets their release. It may still remove finished items. `rules/todo-items.md` states the rule. `CLAUDE.md` launches a subagent that files or scores items on the rung the new `subagent-rung --plan ` prints, never below the project's rung, and `loop-claude`'s prompt names that subagent among those a worker below the project's rung launches on it. Expect one extra subagent in a chunk that files items while its worker runs below the project's rung. +- A session or subagent below the project's rung, the cheapest rung of the project's model, no longer scores or reshapes `todo.md`: it drafts each new item and each change to a filed item, and before its next commit one subagent on the project's rung applies and scores the drafts and sets their release. It may still remove finished items. `rules/todo-items.md` states the rule. `CLAUDE.md` launches a subagent that files or scores items on the rung the new `subagent-rung --plan ` prints, never below the project's rung. Expect one extra subagent in a chunk that files items while its worker runs below the project's rung. - `loop-claude` runs the judge of an Opus 5.5 project on the rung the chunk's `todo.md` item picks, never below Opus 5.5 at medium effort, the project's rung. Before, the judge ran at the effort `settings.json` sets, xhigh. A replay of 39 archived verdicts found every cheaper rung missing verdicts. The judge keeps its rung when the worker steps up or takes in another item, and runs on the project's rung when no item routed the chunk. A project on another model keeps its judge at its settings' effort. Each verdict in the archive now names the judge's rung on a `Judge:` line. The new `bin/judge-replay ` replays the judge on archived verdicts and prints the cheapest rung that returns them. Expect the judge to cost less on items of R + C 12 or less, and more on items of R + C 15 or more. - Every 20 cycles across all projects, `loop-claude` measures every finished chunk in its archive, with no model run, and writes the figures to `routing-figures.md` at the archive's root: tokens by project, subagent type, rung and tool, and, for each chunk a `todo.md` item routed, grouped by the rung it started on: its review rounds past each pass's first, its unfinished verdicts and its subagents' rungs. It interrupts you, with `claude` on the project's model on the terminal in `~/.claude`, when chunks routed onto a rung took more review rounds or unfinished verdicts than chunks routed onto the next rung up, each rung with 5 chunks or more, or when 5 or more subagents of one type wrote reports longer than the tool results they read. Each call is raised once, then listed in `routing-calls-raised.md` beside the figures; the next chunk of this repo files a `todo.md` item for it. Off a terminal, the calls are said on stderr and the loop goes on. They are raised at the next measurement on a terminal. After a routing change, a `- Reset` line in that file makes the figures count only chunks finished after it, and lets its calls be raised again. Expect a pause of about ten seconds at each measurement. - A session delegates a task to a subagent only when it needs just the task's conclusion, such as a search across many files, and keeps edits in its own thread. It scores the task's R and C as for a `todo.md` item, and launches the subagent on the model and effort that the new `bin/subagent-rung ` picks from the project's model, such as `model sonnet, effort high`. `CLAUDE.md` states the rule. Expect searches to run on cheaper models, and less of each session's context to fill with search output. diff --git a/CLAUDE.md b/CLAUDE.md index ca1b1440..0af51e73 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -86,6 +86,7 @@ The rules only reviewers apply, for quality, comments, READMEs and prose, live i - **judge** — the headless claude that reads a worker's transcript each cycle and decides whether to interrupt and whether the chunk is finished. - **pass** — one kind of review a chunk may take, run in rounds by its reviewers until clean; `larv-review` §3 lists them. - **plan** — `todo.md`. +- **project's rung** — the cheapest rung of the project's model on loop-claude's routing ladder: the model loop-claude's prompt names as the project's, or else your own. - **premises** — the goals and audience under `## Goals` and `## Audience` in the project's `README.md`. - **release** — a semver version the human cuts. - **reviewer** — a reporter of findings: an agent under `~/.claude/agents/`, `/security-review` or a forge's auto-reviewer. diff --git a/bin/loop_claude/cycle/prompts.py b/bin/loop_claude/cycle/prompts.py index c772f5a0..74adca76 100644 --- a/bin/loop_claude/cycle/prompts.py +++ b/bin/loop_claude/cycle/prompts.py @@ -28,9 +28,9 @@ def off_the_projects_rung(route: Route, anchor: Rung | None) -> str: """Which subagents to launch on the project's rung, anchor, while the worker runs off it; empty while it runs on it, as a chunk no item routed starts: `routing.first_route` starts it on anchor.""" if anchor is None or route.rung == anchor: return "" - # Below the project's rung, the reviewers and the plan's scorer stay on it to hold quality; above it, the seats score every chunk on one rung, and the security pass spends no more than the project chose. + # Below the project's rung, the reviewers stay on it to hold quality; above it, the seats score every chunk on one rung, and the security pass spends no more than the project chose. below = highest(route.rung, anchor) == anchor - launched = "each reviewer, each comprehension seat, the security pass's subagent and each subagent that files or scores todo.md items" if below else "each comprehension seat and the security pass's subagent" + launched = "each reviewer, each comprehension seat and the security pass's subagent" if below else "each comprehension seat and the security pass's subagent" return f" Your rung is {'below' if below else 'above'} the project's, {anchor}: launch {launched} with the Agent tool set to {anchor.agent_args()}. Run a full scan only from such a subagent, since the scan's agents run on the model that starts them." diff --git a/bin/loop_claude/routing.py b/bin/loop_claude/routing.py index f82de58a..264f0f7c 100644 --- a/bin/loop_claude/routing.py +++ b/bin/loop_claude/routing.py @@ -2,7 +2,7 @@ import dataclasses from failure import Failure -from model_routing.ladder import highest, LADDER, picked, project_rung, Rung, stepped_up +from model_routing.ladder import floored, highest, LADDER, picked, project_rung, Rung, stepped_up from todo_table import Item, items from model_routing.route import Route @@ -34,7 +34,7 @@ def kept(route: Route, anchor: Rung) -> bool: def item_rung(anchor: Rung, route: Route) -> Rung: - """The rung the route's item's R + C picks from anchor, the project's rung, or anchor itself when no item routed it. The worker may run on a rung below anchor; judge_rung lifts the judge's rung to anchor.""" + """The rung the route's item's R + C picks from anchor, the project's rung, or anchor itself when no item routed it. The worker may run on a rung below anchor; judge_rung floors the judge's rung at anchor.""" return picked(anchor, route.risk_and_complexity) if route.item else anchor @@ -58,4 +58,4 @@ def judge_rung(judge_model: str, route: Route) -> Rung: anchor = project_rung(judge_model) if anchor is None or judge_model not in JUDGE_REPLAYED: return Rung(judge_model) - return highest(anchor, item_rung(anchor, route)) + return floored(anchor, route.risk_and_complexity) if route.item else anchor diff --git a/bin/loop_claude/test_black_box.py b/bin/loop_claude/test_black_box.py index 7afccd3b..365afad9 100644 --- a/bin/loop_claude/test_black_box.py +++ b/bin/loop_claude/test_black_box.py @@ -406,7 +406,7 @@ class Cycles(unittest.TestCase): ruling = next(call for call in run.calls if call["role"] == "judge") self.assertEqual((argument(ruling, "--model"), argument(ruling, "--effort")), ("claude-opus-5-5", "medium")) self.assertIn("Judge: claude-opus-5-5 at medium effort\nWorker: claude-sonnet-5-5 at high effort", "".join(checkout.archived().values())) - self.assertIn("Your rung is below the project's, claude-opus-5-5 at medium effort: launch each reviewer, each comprehension seat, the security pass's subagent and each subagent that files or scores todo.md items with the Agent tool set to model opus, effort medium", argument(first, "-p")) + 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 set to model opus, effort medium", argument(first, "-p")) def test_a_rerun_resumes_an_open_chunk_on_the_rung_it_last_ran(self): checkout = Checkout(self) diff --git a/bin/loop_claude/test_loop_claude.py b/bin/loop_claude/test_loop_claude.py index 341856ca..187ce021 100644 --- a/bin/loop_claude/test_loop_claude.py +++ b/bin/loop_claude/test_loop_claude.py @@ -646,7 +646,7 @@ class WorkerArgs(unittest.TestCase): 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", 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, the security pass's subagent and each subagent that files or scores todo.md items with the Agent tool set to model opus, effort medium. Run a full scan only from such a subagent, since the scan's agents run on the model that starts them.\n\n", below) + 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 set to model opus, effort medium. Run a full scan only from such a subagent, since the scan's agents run on the model that starts them.\n\n", below) self.assertNotIn("the project's", prompts.fresh("Do it.", "## Goals", Route(opus, 3, 9), opus)) def test_keeps_seats_and_the_security_pass_on_the_projects_rung_while_the_worker_runs_above_it(self): diff --git a/bin/model_routing/ladder.py b/bin/model_routing/ladder.py index c1a3195d..55243389 100644 --- a/bin/model_routing/ladder.py +++ b/bin/model_routing/ladder.py @@ -49,6 +49,11 @@ def picked(anchor: Rung, risk_and_complexity: int) -> Rung: return climbed(anchor, next((step for highest, step in BANDS if risk_and_complexity <= highest), ABOVE_THE_BANDS)) +def floored(anchor: Rung, risk_and_complexity: int) -> Rung: + """The rung a task's R + C picks from anchor, the project's rung, never below anchor.""" + return highest(anchor, picked(anchor, risk_and_complexity)) + + def stepped_up(rung: Rung) -> Rung: """The rung above, or the top one; a rung off the ladder steps to the bottom one.""" return climbed(rung, 1) diff --git a/bin/model_routing/test_ladder.py b/bin/model_routing/test_ladder.py index 3f01adda..37100460 100644 --- a/bin/model_routing/test_ladder.py +++ b/bin/model_routing/test_ladder.py @@ -4,7 +4,7 @@ import unittest sys.path.insert(0, str(pathlib.Path(__file__).resolve().parents[1])) -from model_routing.ladder import highest, LADDER, picked, project_rung, Rung, stepped_up +from model_routing.ladder import floored, highest, LADDER, picked, project_rung, Rung, stepped_up OPUS = Rung("claude-opus-5-5", "medium") @@ -33,6 +33,13 @@ class Ladder(unittest.TestCase): self.assertEqual(stepped_up(LADDER[-1]), LADDER[-1]) self.assertEqual(stepped_up(OPUS), Rung("claude-opus-5-5", "high")) + def test_floors_the_picked_rung_at_the_projects_rung(self): + self.assertEqual(floored(OPUS, 2), OPUS) + self.assertEqual(floored(OPUS, 12), Rung("claude-opus-5-5", "high")) + + def test_names_each_rung_by_a_family_the_agent_tool_takes(self): + self.assertEqual({rung.agent_args().split(",")[0] for rung in LADDER}, {"model haiku", "model sonnet", "model opus", "model fable"}) + def test_ranks_a_rung_off_the_ladder_below_every_rung_on_it(self): self.assertEqual(highest(OPUS, LADDER[-1], LADDER[0]), LADDER[-1]) self.assertEqual(highest(Rung("claude-opus-5-5", "low"), LADDER[0]), LADDER[0]) diff --git a/bin/subagent_rung/main.py b/bin/subagent_rung/main.py index ae2b0cd8..37de6cea 100644 --- a/bin/subagent_rung/main.py +++ b/bin/subagent_rung/main.py @@ -15,7 +15,7 @@ Exit 1, saying why, on bad arguments. import re import sys -from model_routing.ladder import highest, picked, project_rung +from model_routing.ladder import floored, picked, project_rung USAGE = "usage: subagent-rung [--plan] , R+C a whole number from 2 to 20" @@ -25,8 +25,7 @@ def agent_args(model: str, risk_and_complexity: int, planning: bool = False) -> anchor = project_rung(model) if anchor is None: return None - rung = picked(anchor, risk_and_complexity) - return (highest(rung, anchor) if planning else rung).agent_args() + return (floored if planning else picked)(anchor, risk_and_complexity).agent_args() def main(argv: list[str]) -> int: diff --git a/docs/decisions.md b/docs/decisions.md index 3d085f04..81ab70a1 100644 --- a/docs/decisions.md +++ b/docs/decisions.md @@ -118,7 +118,7 @@ 2026-10-15, lilleman. Serves goal 1.1: a cheaper rung writes worse scores, and a wrong score routes a chunk onto the wrong rung, ranks the plan wrong and drops an item under the bar that should stay. The project's rung is the cheapest rung of the project's model, as in `routing: one ladder`. Below it, a session or subagent may not score an item, move it between releases, split a milestone, delete an item under the bar, or rewrite a filed item. It drafts each new item, and each change to a filed item, such as a refresh a rule asks for, and one subagent on the project's rung applies and scores the drafts together before the next commit, so one launch covers a chunk's drafts (goal 1.4). A security finding gets that subagent at once, since it is filed the moment it is found. Removing a finished item closes work and plans none, so any rung does it. Scoring a delegated task's R + C runs on any rung too: a launch on the project's rung to score each delegation would cost more than the cheaper task saves (goal 1.4). -Three places carry the rule: `rules/todo-items.md` states it and loads with `todo.md`; `CLAUDE.md`'s delegation rule launches the scoring subagent on the rung `bin/subagent-rung --plan` prints, which never falls below the project's, so the routing bands keep one owner; and `bin/loop_claude/cycle/prompts.py`'s `off_the_projects_rung` names that subagent among those a worker below the project's rung launches on it. Valid while a worker may run below the project's rung. +Two places carry the rule: `rules/todo-items.md` states it and loads with `todo.md`, and `CLAUDE.md`'s delegation rule launches the scoring subagent on the rung `bin/subagent-rung --plan` prints. That rung is the one the task's R + C picks, never below the project's, so a hard scoring task still climbs; `floored` in `bin/model_routing/ladder.py` computes it, as it does the judge's rung. loop-claude's prompt names no rung for this subagent, though the plan item asked it to: a second, fixed rung there would disagree with `--plan` on a scoring task of R + C 11 or more, and the prompt already tells a worker it runs below the project's rung, which brings the rule into play. Valid while a worker may run below the project's rung. ## settings.json: Claude Code runs in auto mode with the dangerous-mode prompt skipped diff --git a/rules/todo-items.md b/rules/todo-items.md index e7888d49..a8e97add 100644 --- a/rules/todo-items.md +++ b/rules/todo-items.md @@ -6,7 +6,7 @@ paths: # Todo items (`todo.md`) - **`todo.md` is mandatory in every project, in one shape**, which `~/.claude/bin/rank_todo.py` checks and ranks; its `--help` shows a valid file. `## Scoring` holds the formula, the bar and the goal weights; `## Items` is one table of every item; `## Details` holds each item's detail under its ID. Cite an item by its ID. The formula, bar and weights are the project's own to tune. -- **Plan only on the project's rung or above.** The project's rung is the cheapest rung of the project's model: the model loop-claude's prompt names as the project's, or else your own. Below it, as loop-claude's prompt says when you are, never score or re-score an item, move it between releases, split a milestone into items, delete an item under the bar, or rewrite a filed item's tagline or detail. Draft each new item, and each change to a filed item, instead; before your next commit, one subagent on the project's rung applies the drafts together, scores them and sets their release; keep its scores and releases as it wrote them. A security finding gets that subagent at once. Any rung may remove a finished item's row and detail, and score a delegated task's R + C to pick its subagent's rung. +- **Plan only on the project's rung or above.** Below it, as loop-claude's prompt says when you are, never score or re-score an item, move it between releases, split a milestone into items, delete an item under the bar, or rewrite a filed item's tagline or detail. Draft each new item, and each change to a filed item, instead; before your next commit, one subagent, launched on the rung `CLAUDE.md`'s delegation rule gives a planning subagent, applies the drafts together, scores them and sets their release; keep its scores and releases as it wrote them. A security finding gets that subagent at once. Any rung may remove a finished item's row and detail, and score a delegated task's R + C to pick its subagent's rung. A subagent launched for another task leaves `todo.md` alone. - **An item's release allows the bump that semver read strictly asks for.** An item that changes what exists needs a major, or before 1.0.0 a minor. One that only adds needs a minor, and a fix a patch. - **Score an item when it is filed or edited.** Each of R, S, C, A and G is a whole number from 1 to 10: - **R** — the risk that the change creates serious bugs or issues. diff --git a/todo.md b/todo.md index 209c6d7d..fcff109a 100644 --- a/todo.md +++ b/todo.md @@ -205,7 +205,7 @@ Junior A and Mid A of PR #257's scoring run named `bin/shell_command.py:31` `seg ### 140. Split `docs/decisions.md` → `routing: one ladder` into one entry per decision, so a reader finds the rules for the ladder, the worker's rung, the routing figures and delegation by their titles. -The entry holds 7 paragraphs under one title of about 70 words chaining three decisions: the ladder and bands, the worker below the project's rung with its reviewers, the routing figures and calls, delegation, and when the worker changes rung. A reader after one rule reads the whole entry. The prose pass of the chunk that split out the judge's rung asked for the rest. +The entry holds 7 paragraphs under one title of about 70 words chaining three decisions: the ladder and bands, the worker below the project's rung with its reviewers, the routing figures and calls, delegation, and when the worker changes rung. A reader after one rule reads the whole entry. Name, in the delegation title, the floor that `todo.md: only a session or subagent on the project's rung or above scores or reshapes the plan…` puts under a planning subagent. The prose pass of the chunk that split out the judge's rung asked for the rest. ### 114. Run git through `git_repo.py` in `rule_hook`, `metric_bench`, `reading_cost` and `loop_claude`, keeping rule-hook's guards as an option, so one module owns how a tool runs git.