From 3f26e9f3ea0cd378c25d41cf82a04f6081f9e6a7 Mon Sep 17 00:00:00 2001 From: Lilleman auf Larv Date: Thu, 15 Oct 2026 15:50:03 +0200 Subject: [PATCH] =?UTF-8?q?Answer=20product-owner=20round=201:=200=20?= =?UTF-8?q?=F0=9F=94=B4,=202=20=F0=9F=9F=A1;=20floor=20a=20planning=20suba?= =?UTF-8?q?gent's=20rung=20in=20subagent-rung=20--plan,=20and=20keep=20its?= =?UTF-8?q?=20scores=20as=20written?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CHANGELOG.md | 2 +- CLAUDE.md | 2 +- README.md | 2 +- bin/subagent_rung/main.py | 27 ++++++++++++++++--------- bin/subagent_rung/test_subagent_rung.py | 11 +++++++--- docs/decisions.md | 2 +- rules/todo-items.md | 2 +- 7 files changed, 30 insertions(+), 18 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e2881976..ad891685 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` keeps a subagent that files or scores items at or above 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, 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. - `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 10f79626..ca1b1440 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -52,7 +52,7 @@ The rules only reviewers apply, for quality, comments, READMEs and prose, live i - Keep the project's main checkout (e.g. `~/code/log`, never a worktree) current: when it is behind `origin` — a merge landed, or a fetch shows it — run `git pull --ff-only` there instead of reporting the lag, never with `--autostash`: a dirty checkout is a finding to report, not to carry along. - Run a project's language runtime, package manager, and task runner through its container/tooling setup, never directly on the host unless a decision puts them there. Example: `docker compose run --rm app …`. - Tear down test containers after a run. -- Delegate a task to a subagent only when you need just its conclusion: a search or read across many files, or work independent enough to run in parallel. Keep edits, and whatever you must check line by line, in your own thread: you would read a delegated diff again to check it. Score the task's R and C as for a `todo.md` item. Launch the subagent with the model and effort that `~/.claude/bin/subagent-rung ` prints. `` is the project's model id, such as `claude-opus-5-5`: the one loop-claude's prompt names as the project's, or else your own. A reviewer, a comprehension seat or the security pass takes the model and effort loop-claude's prompt gives it; given none, launch it with no model or effort, so it runs on your rung. A subagent that files or scores `todo.md` items takes the higher of the rungs `subagent-rung ` and `subagent-rung 9` print; the latter is the project's rung. +- Delegate a task to a subagent only when you need just its conclusion: a search or read across many files, or work independent enough to run in parallel. Keep edits, and whatever you must check line by line, in your own thread: you would read a delegated diff again to check it. Score the task's R and C as for a `todo.md` item. Launch the subagent with the model and effort that `~/.claude/bin/subagent-rung ` prints. `` is the project's model id, such as `claude-opus-5-5`: the one loop-claude's prompt names as the project's, or else your own. A reviewer, a comprehension seat or the security pass takes the model and effort loop-claude's prompt gives it; given none, launch it with no model or effort, so it runs on your rung. A subagent that files or scores `todo.md` items takes the rung `subagent-rung --plan ` prints, which is never below the project's. - Give a subagent only the access its job needs, and state the limits in its prompt. One that only reads, such as a prose review, gets no shell and no edits. One that probes a build tags the image as throwaway and removes it afterwards, writes only to the session scratchpad, and removes no image or file it did not create. - Check `README.md` first for build, test, install, and codegen commands, and fix one that misbehaves in the same change. Refresh `README.md` whenever you change what it describes, keeping it true, not longer. - Where `~/.claude/bin/rule-hook` does not check it, such as an image named in test code, a Kubernetes manifest, a `docker run` line or a file a Bash command writes, pin a container image to its full patch version and a GitHub Action to a semver tag. diff --git a/README.md b/README.md index 6573673a..863c43ac 100644 --- a/README.md +++ b/README.md @@ -76,7 +76,7 @@ Install puts only `loop-claude` on `PATH`; call the others by their path, such a - `rule-hook [overrides]` blocks a tool call that breaks a rule a program can check, unless the call overrides the rule; `settings.json` → `hooks` runs it before each Bash, Edit, MultiEdit and Write call, and `rule-hook --help` states the rules and the override. - `score-outcomes [R S C]` lists the finished items whose guessed R, S and C sit nearest the given scores, with what their chunks measured, and each score's median outcome; `score-outcomes --help` states the measures. - `statusline.py` renders Claude Code's status line; `settings.json` → `statusLine` runs it. -- `subagent-rung ` prints the Agent tool's model and effort for a subagent's task, picked by its R + C from the project's model; `subagent-rung --help` states the rule. +- `subagent-rung [--plan] ` prints the Agent tool's model and effort for a subagent's task, picked by its R + C from the project's model, and with `--plan` never below the project's rung; `subagent-rung --help` states the rule. Test on the host, with `uv` on `PATH` to fetch mypy and the Python version Install names (`docs/decisions.md` → `bin/`): `python3 -m unittest discover -s bin -p 'test_*.py'` diff --git a/bin/subagent_rung/main.py b/bin/subagent_rung/main.py index 4d849e3a..ae2b0cd8 100644 --- a/bin/subagent_rung/main.py +++ b/bin/subagent_rung/main.py @@ -1,10 +1,12 @@ """Print the Agent tool's model and effort for a subagent's task: docs/decisions.md → `routing:`. -usage: subagent-rung +usage: subagent-rung [--plan] is the project's model, such as claude-opus-5-5, and the task's R + C, a whole number from 2 to 20, scored as for a todo.md item. It prints the rung that R + C picks from the -model's cheapest rung, in the Agent tool's words, such as `model sonnet, effort high`. For a model +model's cheapest rung, the project's rung, in the Agent tool's words, such as `model sonnet, effort +high`. --plan, for a task that files or scores todo.md items, prints the project's rung where that +R + C picks a lower one: rules/todo-items.md plans only on the project's rung or above. For a model off the routing ladder, the tool prints nothing on stdout, says so on stderr and exits 0; launch the subagent with no model or effort. @@ -13,26 +15,31 @@ Exit 1, saying why, on bad arguments. import re import sys -from model_routing.ladder import picked, project_rung +from model_routing.ladder import highest, picked, project_rung -USAGE = "usage: subagent-rung , R+C a whole number from 2 to 20" +USAGE = "usage: subagent-rung [--plan] , R+C a whole number from 2 to 20" -def agent_args(model: str, risk_and_complexity: int) -> str | None: - """The Agent tool's model and effort for the rung risk_and_complexity picks from model's cheapest rung; None for a model off the ladder.""" +def agent_args(model: str, risk_and_complexity: int, planning: bool = False) -> str | None: + """The Agent tool's model and effort for the rung risk_and_complexity picks from model's cheapest rung, never below it when planning; None for a model off the ladder.""" anchor = project_rung(model) - return picked(anchor, risk_and_complexity).agent_args() if anchor else None + if anchor is None: + return None + rung = picked(anchor, risk_and_complexity) + return (highest(rung, anchor) if planning else rung).agent_args() def main(argv: list[str]) -> int: if argv[:1] in (["-h"], ["--help"]): print(__doc__.strip()) return 0 - if len(argv) != 2 or not re.fullmatch(r"[2-9]|1[0-9]|20", argv[1]): + planning = argv[:1] == ["--plan"] + operands = argv[1:] if planning else argv + if len(operands) != 2 or not re.fullmatch(r"[2-9]|1[0-9]|20", operands[1]): print(f"subagent-rung: cannot read the arguments{' ' + ' '.join(argv) if argv else ''}; {USAGE}", file=sys.stderr) return 1 - model, total = argv - args = agent_args(model, int(total)) + model, total = operands + args = agent_args(model, int(total), planning) if args is None: print(f"subagent-rung: {model} is not on the routing ladder; pass the Agent tool no model or effort", file=sys.stderr) else: diff --git a/bin/subagent_rung/test_subagent_rung.py b/bin/subagent_rung/test_subagent_rung.py index 3d92449c..d2b80a68 100644 --- a/bin/subagent_rung/test_subagent_rung.py +++ b/bin/subagent_rung/test_subagent_rung.py @@ -20,14 +20,19 @@ class SubagentRung(unittest.TestCase): self.assertEqual(main.agent_args("claude-opus-5-5", 20), "model fable, effort max") self.assertEqual(main.agent_args("claude-haiku-5-5", 2), "model haiku, effort low") + def test_a_planning_task_never_runs_below_the_projects_rung(self): + self.assertEqual(main.agent_args("claude-opus-5-5", 2, planning=True), "model opus, effort medium") + self.assertEqual(main.agent_args("claude-opus-5-5", 12, planning=True), "model opus, effort high") + self.assertEqual(self.run_tool("--plan", "claude-opus-5-5", "7").stdout, "model opus, effort medium\n") + def test_picks_nothing_for_a_model_off_the_ladder(self): self.assertIsNone(main.agent_args("claude-opus-5", 9)) def test_refuses_an_r_plus_c_outside_2_to_20_or_a_wrong_count_of_arguments(self): - for argv in (["claude-opus-5-5", "1"], ["claude-opus-5-5", "02"], ["claude-opus-5-5", "21"], ["claude-opus-5-5", "x"], ["claude-opus-5-5"], ["9", "claude-opus-5-5"]): + for argv in (["claude-opus-5-5", "1"], ["claude-opus-5-5", "02"], ["claude-opus-5-5", "21"], ["claude-opus-5-5", "x"], ["claude-opus-5-5"], ["9", "claude-opus-5-5"], ["claude-opus-5-5", "9", "--plan"], ["--planning", "claude-opus-5-5", "9"]): result = self.run_tool(*argv) self.assertEqual((result.returncode, result.stdout), (1, ""), argv) - self.assertIn("usage: subagent-rung ", result.stderr) + self.assertIn("usage: subagent-rung [--plan] ", result.stderr) def test_the_launcher_prints_the_rung_and_exits_0_on_and_off_the_ladder(self): on = self.run_tool("claude-opus-5-5", "12") @@ -38,7 +43,7 @@ class SubagentRung(unittest.TestCase): for bound, rung in (("2", "model haiku, effort xhigh\n"), ("20", "model fable, effort max\n")): self.assertEqual(self.run_tool("claude-opus-5-5", bound).stdout, rung) for flag in ("-h", "--help"): - self.assertIn("usage: subagent-rung ", self.run_tool(flag).stdout) + self.assertIn("usage: subagent-rung [--plan] ", self.run_tool(flag).stdout) if __name__ == "__main__": diff --git a/docs/decisions.md b/docs/decisions.md index f4935f51..3d085f04 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 keeps the scoring subagent at or above the project's rung; 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. +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. ## 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 e39d2f2e..e7888d49 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. 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.** 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. - **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.