From b0daa3ed2597a8c58112721a0c9ce66c7752c3b2 Mon Sep 17 00:00:00 2001 From: Lilleman auf Larv Date: Thu, 15 Oct 2026 15:43:01 +0200 Subject: [PATCH 01/26] Score and reshape the plan only on the project's rung or above --- AGENTS.md | 1 + CHANGELOG.md | 1 + CLAUDE.md | 2 +- bin/loop_claude/cycle/prompts.py | 4 ++-- bin/loop_claude/test_black_box.py | 2 +- bin/loop_claude/test_loop_claude.py | 2 +- docs/decisions.md | 6 ++++++ rules/todo-items.md | 1 + todo.md | 26 +------------------------- 9 files changed, 15 insertions(+), 30 deletions(-) diff --git a/AGENTS.md b/AGENTS.md index ec3b6d5d..b9364893 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -26,6 +26,7 @@ Decisions live in `docs/decisions.md`: - settings.json: Claude Code runs in auto mode with the dangerous-mode prompt skipped - the repo may name bender, bender-infra and ai-sandbox - todo.md: one table of items scored by the formula and goal weights it states, held to its bar, ranked by `bin/rank_todo.py` +- todo.md: only a session or subagent on the project's rung or above scores or reshapes the plan; one below it drafts new items for a subagent on that rung to file and score, and removes finished ones - reading cost: larv-review measures each finished chunk from loop-claude's archive and appends the figure to `docs/reading-cost.md` in the next chunk's PR - reading cost: a rise is the last 5 chunks' median above the 5 before them, and files or refreshes one plan item - rule-hook: a PreToolUse hook enforces each rule a program can check, a `# rule-override : ` marker overrides one, and larv-review's overrides pass rules on each override before merge diff --git a/CHANGELOG.md b/CHANGELOG.md index 56ef20a8..403e8f90 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +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 before its next commit one subagent on the project's rung files 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. - `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 c4862024..b6300ffc 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, or else none. +- 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. Two kinds of subagent take another rung. A reviewer, a comprehension seat or the security pass takes the model and effort loop-claude's prompt gives it, or else none. A subagent that files or scores `todo.md` items never runs below the project's rung, which `subagent-rung 9` prints. - 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/bin/loop_claude/cycle/prompts.py b/bin/loop_claude/cycle/prompts.py index 21b76003..ce20fec7 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.""" if anchor is None or route.rung == anchor: return "" - # 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 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 = highest(route.rung, anchor) == anchor - launched = "each reviewer, each comprehension seat and the security pass's subagent" if below else "each comprehension seat and the security pass's subagent" + 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" 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/test_black_box.py b/bin/loop_claude/test_black_box.py index 365afad9..7afccd3b 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 and the security pass's subagent 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, 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")) 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 187ce021..341856ca 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 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.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.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/docs/decisions.md b/docs/decisions.md index 4793dbd3..ca671024 100644 --- a/docs/decisions.md +++ b/docs/decisions.md @@ -114,6 +114,12 @@ 2026-10-02, lilleman. Serves goal 1: findings were filed faster than chunks closed them, so the plan grew without telling what mattered. Each item is scored as `~/.claude/rules/todo-items.md` says; this repo's formula counts value highest and size least. An item under the bar is not kept; this repo's bar started at 10 and was set to 9 the same day, purging the 17 items under it. An Exempt cell keeps a row past the bar where a rule needs it kept. lilleman retired the two decisions whose plans the purge removed: the stats line in the transcript archive, and three benches before a workflow change merges. A finding under the bar is recorded nowhere, so a later review may raise it again, and the run rescores it. That costs one scoring; a ledger of dropped findings would regrow the list the bar caps. larv-review's "Round cap" โ†’ "Done" counts a finding named under the bar as settled, so one raised again holds no pass open. `rank_todo.py --check` is part of larv-review's gate, since only a check keeps the stored Score from going stale. The format is mandatory in every project, as the premises are (goal 1.3); the formula, bar and weights are each project's own. A script ranks the table so a re-rank after each addition or edit is deterministic and cheap. A ๐ŸŸก against a technical principle is exempt as `principle`, because its audience value scores low and the bar would drop every one. A ๐ŸŸข against a principle is scored like any other finding. 2026-10-08, lilleman: the goal weights in `todo.md` depart from an even spread by position, which would weigh goal 4, leaking nothing, at 0.11. Valid while one human sets the bar and reads the ranking, and while the items marked `principle` stay few enough to rank. +## todo.md: only a session or subagent on the project's rung or above scores or reshapes the plan; one below it drafts new items for a subagent on that rung to file and score, and removes finished ones + +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 one subagent on the project's rung files 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. + ## settings.json: Claude Code runs in auto mode with the dangerous-mode prompt skipped 2026-10-04, lilleman, answering the principles audit of PR #215. Serves goal 1: this setup is meant to run in a sandbox and to work autonomously, so tool access is granted by the sandbox, as "Always grant explicit access to data" in `principles/technical-principles.md` asks. Valid while every machine taking this checkout is such a sandbox. diff --git a/rules/todo-items.md b/rules/todo-items.md index ee739b48..bec74d83 100644 --- a/rules/todo-items.md +++ b/rules/todo-items.md @@ -6,6 +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's tagline and detail instead; before your next commit, one subagent on the project's rung files and scores the drafts together 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. - **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 6750616b..209c6d7d 100644 --- a/todo.md +++ b/todo.md @@ -22,14 +22,11 @@ ## Items -Release 0.1.0 takes item 141 first, whatever its score: item 142's first trigger needs its rule. - Release 0.2.0 takes items 125, 114 and 124 first, whatever their scores: Shape is the lowest dimension, per `docs/decisions.md` โ†’ `larv-review: a project lifting itself to the comprehension floor starts at the lowest dimension`. | ID | Release | Exempt | Item | R | S | C | A | G | Goals | Score | |---|---|---|---|---|---|---|---|---|---|---| | 142 | 0.1.0 | | **Let a chunk's worker hand a task to a subagent one rung up when an escalation trigger fires, at most two rungs above the rung it started the chunk on without the human's yes.** | 4 | 5 | 6 | 7 | 8 | 1.1, 1.4 | 24.6 | -| 141 | 0.1.0 | | **Score and reshape the plan only on the project's rung or above, and let a worker or subagent below it only draft new items and remove finished ones.** | 3 | 4 | 4 | 6 | 8 | 1.1 | 23.8 | | 144 | 0.1.0 | | **Let a reviewer or comprehension seat that rules the work below standard rerun its review one rung up, outside the round cap, and let the worker escalate under item 142.** | 4 | 5 | 6 | 6 | 7 | 1.1 | 20.6 | | 145 | 0.1.0 | | **Run the stability reviewer on the worker's rung while the worker runs below the project's rung, once a replay of past stability rounds on that rung finds the ๐Ÿ”ด and ๐ŸŸก findings on record.** | 4 | 5 | 6 | 6 | 7 | 1.4 | 20.2 | | 143 | 0.1.0 | | **Resume a worker one rung up in the next cycle when its run ends asking for a higher rung and the judge finds the escalation trigger it cites in the transcript.** | 5 | 5 | 7 | 6 | 7 | 1.1, 1.4 | 19.6 | @@ -95,7 +92,7 @@ Release 0.2.0 takes items 125, 114 and 124 first, whatever their scores: Shape i The human asked for this on 2026-10-15. Four triggers mean a task is too hard for the worker's rung: -1. A re-score of the item, made on the project's rung per item 141, picks a higher rung than the worker's. +1. A re-score of the item, made on the project's rung as `rules/todo-items.md` requires, picks a higher rung than the worker's. 2. The same failing test or finding survives two fix attempts. 3. A pass reports a ๐Ÿ”ด in round 2 or later, as the `Answer round :` commit titles show. 4. A reviewer or comprehension seat rules the work below standard, per item 144. @@ -104,27 +101,6 @@ When one fires, the worker hands the hard part to a subagent one rung above its This revises `docs/decisions.md` โ†’ `routing: one ladder`, where the worker routes each subagent by its task's R + C alone, and the delegation rule in `CLAUDE.md`. The comprehension seats found it hard to follow which model a subagent gets: `CLAUDE.md`'s delegation rule, `bin/loop_claude/cycle/prompts.py`'s `off_the_projects_rung` and `bin/model_routing/ladder.py`'s `Rung.agent_args` each hold part of it. Make it easier to read. -### 141. Score and reshape the plan only on the project's rung or above, and let a worker or subagent below it only draft new items and remove finished ones. - -The human set this rule on 2026-10-15. The project's rung is the cheapest rung of the model `loop-claude-models.json` pins, or of the session's own model outside loop-claude. Below that rung, a worker or subagent may not: - -- score or re-score an item; -- move an item between releases; -- split a milestone into items; -- delete an item under the bar; -- rewrite an item's tagline or detail once it is filed. - -Any rung may: - -- remove a finished item's row and detail, which closes work and plans none; -- score a delegated task's R + C to pick its subagent's rung, since launching a subagent on the project's rung to score each delegation would cost more than running the task on a cheaper rung saves. - -A worker below the project's rung drafts each new item's tagline and detail. Before its next commit, one subagent on the project's rung files and scores the drafts together and sets their release. A security finding gets that subagent at once, since it is filed the moment it is found. - -Write the rule in `rules/todo-items.md`, which loads with `todo.md`. Add to `CLAUDE.md`'s delegation rule: a scoring or planning subagent runs on the rung `subagent-rung` prints, or on the project's rung where that is higher. In `bin/loop_claude/cycle/prompts.py`'s `off_the_projects_rung`, add the scoring and planning subagent to those a worker below the project's rung launches on the project's rung. Three places carry the rule, so record it in `docs/decisions.md`. - -The comprehension seats found it hard to follow which model a subagent gets: `CLAUDE.md`'s delegation rule, `off_the_projects_rung` and `bin/model_routing/ladder.py`'s `Rung.agent_args` each hold part of it. Make it easier to read. - ### 144. Let a reviewer or comprehension seat that rules the work below standard rerun its review one rung up, outside the round cap, and let the worker escalate under item 142. The human asked for this on 2026-10-15, and for the worker to escalate too. A reviewer rules the work below standard when it reports an architect BLOCK or a finding against `skills/larv-review/standards/quality.md`. It may then ask for its pass to rerun one rung up, and that rerun counts toward no round cap. A comprehension seat rules it below standard when it votes "worse" in a paired ruling. It may then ask for the ruling to rerun with its seat one rung up. Either ruling is trigger 4 of item 142. No ruling raises the judge's own rung. From d332123f5627ca498444d15c4e1cd93a906df0c4 Mon Sep 17 00:00:00 2001 From: Lilleman auf Larv Date: Thu, 15 Oct 2026 15:43:16 +0200 Subject: [PATCH 02/26] Record the reading cost of the last finished chunk --- docs/reading-cost.md | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/docs/reading-cost.md b/docs/reading-cost.md index 241c5b28..85169749 100644 --- a/docs/reading-cost.md +++ b/docs/reading-cost.md @@ -333,3 +333,20 @@ Read most (opens and searches): - `bin/claude_code/entries.py` 1 - `bin/claude_code/trust.py` 1 - `bin/git_command.py` 1 + +## Reading cost, chunk d99303ae50a1, finished 2026-10-15T13:40:09Z + +120770 new input tokens before the first commit. + +Read most (opens and searches): + +- `bin/loop_claude/cycle/judge.py` 8 +- `todo.md` 4 +- `README.md` 3 +- `.gitignore` 2 +- `bin/loop_claude/cycle/run.py` 2 +- `bin/loop_claude/effects.py` 2 +- `bin/loop_claude/loop/main.py` 2 +- `bin/loop_claude/project/model_choice.py` 2 +- `docs/decisions.md` 2 +- `rules/todo-items.md` 2 From c1d8af1d1fd751e15f6632eff4e08adeb7a9e98f Mon Sep 17 00:00:00 2001 From: Lilleman auf Larv Date: Thu, 15 Oct 2026 15:43:31 +0200 Subject: [PATCH 03/26] Say that a reviewer given no rung runs on the worker's --- CLAUDE.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CLAUDE.md b/CLAUDE.md index b6300ffc..bbe8d353 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. Two kinds of subagent take another rung. A reviewer, a comprehension seat or the security pass takes the model and effort loop-claude's prompt gives it, or else none. A subagent that files or scores `todo.md` items never runs below the project's rung, which `subagent-rung 9` prints. +- 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. Two kinds of subagent take another rung. A reviewer, a comprehension seat or the security pass takes the model and effort loop-claude's prompt gives it, or else none, so it runs on your rung. A subagent that files or scores `todo.md` items never runs below the project's rung, which `subagent-rung 9` prints. - 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. From 202cef0e781a4f18a73c61632b53c1dd67de8be0 Mon Sep 17 00:00:00 2001 From: Lilleman auf Larv Date: Thu, 15 Oct 2026 15:46:37 +0200 Subject: [PATCH 04/26] =?UTF-8?q?Answer=20stability=20round=201:=200=20?= =?UTF-8?q?=F0=9F=94=B4,=203=20=F0=9F=9F=A1;=20let=20a=20draft=20change=20?= =?UTF-8?q?a=20filed=20item,=20state=20each=20subagent's=20rung=20directly?= =?UTF-8?q?,=20and=20say=20why=20an=20unrouted=20chunk=20gets=20no=20note?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CHANGELOG.md | 2 +- CLAUDE.md | 2 +- bin/loop_claude/cycle/prompts.py | 2 +- docs/decisions.md | 2 +- rules/todo-items.md | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 403e8f90..e2881976 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 before its next commit one subagent on the project's rung files 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` 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. - `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 bbe8d353..10f79626 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. Two kinds of subagent take another rung. A reviewer, a comprehension seat or the security pass takes the model and effort loop-claude's prompt gives it, or else none, so it runs on your rung. A subagent that files or scores `todo.md` items never runs below the project's rung, which `subagent-rung 9` prints. +- 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. - 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/bin/loop_claude/cycle/prompts.py b/bin/loop_claude/cycle/prompts.py index ce20fec7..c772f5a0 100644 --- a/bin/loop_claude/cycle/prompts.py +++ b/bin/loop_claude/cycle/prompts.py @@ -25,7 +25,7 @@ def routed_by(route: Route, anchor: Rung | None) -> str: 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.""" + """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. diff --git a/docs/decisions.md b/docs/decisions.md index ca671024..f4935f51 100644 --- a/docs/decisions.md +++ b/docs/decisions.md @@ -116,7 +116,7 @@ ## todo.md: only a session or subagent on the project's rung or above scores or reshapes the plan; one below it drafts new items for a subagent on that rung to file and score, and removes finished ones -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 one subagent on the project's rung files 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). +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. diff --git a/rules/todo-items.md b/rules/todo-items.md index bec74d83..e39d2f2e 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's tagline and detail instead; before your next commit, one subagent on the project's rung files and scores the drafts together 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. 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. From 3f26e9f3ea0cd378c25d41cf82a04f6081f9e6a7 Mon Sep 17 00:00:00 2001 From: Lilleman auf Larv Date: Thu, 15 Oct 2026 15:50:03 +0200 Subject: [PATCH 05/26] =?UTF-8?q?Answer=20product-owner=20round=201:=200?= =?UTF-8?q?=20=F0=9F=94=B4,=202=20=F0=9F=9F=A1;=20floor=20a=20planning=20s?= =?UTF-8?q?ubagent's=20rung=20in=20subagent-rung=20--plan,=20and=20keep=20?= =?UTF-8?q?its=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. From 4d70b7e5a36ca4730463d47e6cc7b9a2ee84a9f5 Mon Sep 17 00:00:00 2001 From: Lilleman auf Larv Date: Thu, 15 Oct 2026 15:54:28 +0200 Subject: [PATCH 06/26] =?UTF-8?q?Answer=20architecture=20round=201:=201=20?= =?UTF-8?q?=F0=9F=94=B4,=207=20=F0=9F=9F=A1;=20give=20the=20planning=20sub?= =?UTF-8?q?agent's=20rung=20one=20owner=20in=20subagent-rung=20--plan,=20s?= =?UTF-8?q?hare=20the=20floor=20with=20the=20judge=20in=20ladder.floored,?= =?UTF-8?q?=20check=20each=20rung's=20family=20name,=20and=20define=20the?= =?UTF-8?q?=20project's=20rung=20once?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CHANGELOG.md | 2 +- CLAUDE.md | 1 + bin/loop_claude/cycle/prompts.py | 4 ++-- bin/loop_claude/routing.py | 6 +++--- bin/loop_claude/test_black_box.py | 2 +- bin/loop_claude/test_loop_claude.py | 2 +- bin/model_routing/ladder.py | 5 +++++ bin/model_routing/test_ladder.py | 9 ++++++++- bin/subagent_rung/main.py | 5 ++--- docs/decisions.md | 2 +- rules/todo-items.md | 2 +- todo.md | 2 +- 12 files changed, 27 insertions(+), 15 deletions(-) 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. From 26023836b29498f7ef62063e685a1958aa18cb94 Mon Sep 17 00:00:00 2001 From: Lilleman auf Larv Date: Thu, 15 Oct 2026 16:00:38 +0200 Subject: [PATCH 07/26] Name the planning subagent's command in the prompt to a worker below the project's rung, answering stability round 3's question --- CHANGELOG.md | 2 +- bin/loop_claude/cycle/prompts.py | 4 +++- bin/loop_claude/test_loop_claude.py | 2 +- docs/decisions.md | 2 +- 4 files changed, 6 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index c0226523..19590ca0 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. 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 to a worker below that rung names the command. 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/bin/loop_claude/cycle/prompts.py b/bin/loop_claude/cycle/prompts.py index 74adca76..fe39438e 100644 --- a/bin/loop_claude/cycle/prompts.py +++ b/bin/loop_claude/cycle/prompts.py @@ -31,7 +31,9 @@ def off_the_projects_rung(route: Route, anchor: Rung | None) -> str: # 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 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." + # A plan subagent's rung climbs with its task's R + C, so the prompt names the command, not a rung: rules/todo-items.md. + planning = " Launch each subagent that files or scores todo.md items on the rung `subagent-rung --plan ` prints." if below else "" + 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.{planning}" def resumed(unfinished_evidence: str, route: Route, anchor: Rung | None) -> str: diff --git a/bin/loop_claude/test_loop_claude.py b/bin/loop_claude/test_loop_claude.py index 187ce021..9912f7c1 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 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.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. Launch each subagent that files or scores todo.md items on the rung `subagent-rung --plan ` prints.\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/docs/decisions.md b/docs/decisions.md index 81ab70a1..e876a259 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). -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. +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: 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 that rung, as it does the judge's. `bin/loop_claude/cycle/prompts.py`'s `off_the_projects_rung` names the same command to a worker below the project's rung, never a fixed rung, which would disagree with `--plan` on a scoring task of R + C 11 or more. 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 From fbe9502a39a624e9f3427cbb769352e32d1b6783 Mon Sep 17 00:00:00 2001 From: Lilleman auf Larv Date: Thu, 15 Oct 2026 16:00:46 +0200 Subject: [PATCH 08/26] =?UTF-8?q?Answer=20security=20round=201:=200=20?= =?UTF-8?q?=F0=9F=94=B4,=200=20=F0=9F=9F=A1;=20no=20findings?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit From 514a44fad46815abdb0f2d47b20106c00a662ee8 Mon Sep 17 00:00:00 2001 From: Lilleman auf Larv Date: Thu, 15 Oct 2026 16:00:46 +0200 Subject: [PATCH 09/26] =?UTF-8?q?Answer=20stability=20round=202:=200=20?= =?UTF-8?q?=F0=9F=94=B4,=200=20=F0=9F=9F=A1;=20every=20round-1=20answer=20?= =?UTF-8?q?holds?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit From 574f213754c15c664fce5ea30f3e5ee396def1a4 Mon Sep 17 00:00:00 2001 From: Lilleman auf Larv Date: Thu, 15 Oct 2026 16:00:46 +0200 Subject: [PATCH 10/26] =?UTF-8?q?Answer=20architecture=20round=202:=200=20?= =?UTF-8?q?=F0=9F=94=B4,=200=20=F0=9F=9F=A1;=20every=20round-1=20answer=20?= =?UTF-8?q?holds?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit From 53592863b43b3a6832a622a8814447af0bb1aebc Mon Sep 17 00:00:00 2001 From: Lilleman auf Larv Date: Thu, 15 Oct 2026 16:00:46 +0200 Subject: [PATCH 11/26] =?UTF-8?q?Answer=20product-owner=20round=202:=200?= =?UTF-8?q?=20=F0=9F=94=B4,=200=20=F0=9F=9F=A1;=20every=20round-1=20answer?= =?UTF-8?q?=20holds?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit From 1e065c16790aa1a34e30c3c41e672ba909f884dc Mon Sep 17 00:00:00 2001 From: Lilleman auf Larv Date: Thu, 15 Oct 2026 16:00:46 +0200 Subject: [PATCH 12/26] =?UTF-8?q?Answer=20stability=20round=203:=200=20?= =?UTF-8?q?=F0=9F=94=B4,=200=20=F0=9F=9F=A1;=20one=20question,=20answered?= =?UTF-8?q?=20by=20naming=20subagent-rung=20--plan=20in=20the=20prompt?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit From f13447f22873a26e0eaa9ecc42f5f613ad75c04e Mon Sep 17 00:00:00 2001 From: Lilleman auf Larv Date: Thu, 15 Oct 2026 16:05:15 +0200 Subject: [PATCH 13/26] =?UTF-8?q?Answer=20prose=20round=201:=200=20?= =?UTF-8?q?=F0=9F=94=B4,=205=20=F0=9F=9F=A1;=20give=20the=20prompt=20the?= =?UTF-8?q?=20tool's=20full=20path=20and=20the=20project's=20model,=20coun?= =?UTF-8?q?t=20the=20decision's=20places=20right,=20split=20the=20plan=20r?= =?UTF-8?q?ule's=20sentences,=20and=20fix=20item=20140's=20order?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- AGENTS.md | 2 +- CHANGELOG.md | 2 +- CLAUDE.md | 4 ++-- bin/loop_claude/cycle/prompts.py | 5 ++--- bin/loop_claude/routing.py | 2 +- bin/loop_claude/test_loop_claude.py | 2 +- bin/subagent_rung/main.py | 2 +- docs/decisions.md | 6 +++--- rules/todo-items.md | 2 +- todo.md | 4 ++-- 10 files changed, 15 insertions(+), 16 deletions(-) diff --git a/AGENTS.md b/AGENTS.md index b9364893..8a31e2fc 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -26,7 +26,7 @@ Decisions live in `docs/decisions.md`: - settings.json: Claude Code runs in auto mode with the dangerous-mode prompt skipped - the repo may name bender, bender-infra and ai-sandbox - todo.md: one table of items scored by the formula and goal weights it states, held to its bar, ranked by `bin/rank_todo.py` -- todo.md: only a session or subagent on the project's rung or above scores or reshapes the plan; one below it drafts new items for a subagent on that rung to file and score, and removes finished ones +- todo.md: only a session or subagent on the project's rung or above scores or reshapes the plan; one below it drafts new items and changes to filed ones for a subagent at or above that rung to apply and score, and removes finished ones - reading cost: larv-review measures each finished chunk from loop-claude's archive and appends the figure to `docs/reading-cost.md` in the next chunk's PR - reading cost: a rise is the last 5 chunks' median above the 5 before them, and files or refreshes one plan item - rule-hook: a PreToolUse hook enforces each rule a program can check, a `# rule-override : ` marker overrides one, and larv-review's overrides pass rules on each override before merge diff --git a/CHANGELOG.md b/CHANGELOG.md index 19590ca0..7727200b 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 to a worker below that rung names the command. 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 or above applies and scores the drafts and sets their release. It may still remove finished items. `rules/todo-items.md` states the rule. `CLAUDE.md` has a session launch a subagent that files or scores items on the rung the new `bin/subagent-rung --plan ` prints, never below the project's rung, and `loop-claude`'s prompt to a worker below that rung names the command. 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 0af51e73..9cc96ac7 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 rung `subagent-rung --plan ` prints, which is never below the project's. +- 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 model. A subagent that files or scores `todo.md` items takes the rung `~/.claude/bin/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. @@ -86,8 +86,8 @@ 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`. +- **project's rung** โ€” the cheapest rung on loop-claude's routing ladder of the project's model, which is the model loop-claude's prompt names as the project's, or else your own. - **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. - **round cap** โ€” the rounds one pass may take per chunk; `larv-review` ยง3 โ†’ "Round cap". diff --git a/bin/loop_claude/cycle/prompts.py b/bin/loop_claude/cycle/prompts.py index fe39438e..71d090f1 100644 --- a/bin/loop_claude/cycle/prompts.py +++ b/bin/loop_claude/cycle/prompts.py @@ -25,14 +25,13 @@ def routed_by(route: Route, anchor: Rung | None) -> str: 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.""" + """Which subagents to launch on the project's rung, anchor, and below it which on the --plan rung; empty while the worker runs on anchor, as every chunk no item routed starts (routing.first_route).""" if anchor is None or route.rung == anchor: return "" # 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 and the security pass's subagent" if below else "each comprehension seat and the security pass's subagent" - # A plan subagent's rung climbs with its task's R + C, so the prompt names the command, not a rung: rules/todo-items.md. - planning = " Launch each subagent that files or scores todo.md items on the rung `subagent-rung --plan ` prints." if below else "" + planning = f" Launch each subagent that files or scores todo.md items on the rung `~/.claude/bin/subagent-rung --plan {anchor.model} ` prints." if below else "" 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.{planning}" diff --git a/bin/loop_claude/routing.py b/bin/loop_claude/routing.py index 264f0f7c..0b168250 100644 --- a/bin/loop_claude/routing.py +++ b/bin/loop_claude/routing.py @@ -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 floors the judge's rung at 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.""" return picked(anchor, route.risk_and_complexity) if route.item else anchor diff --git a/bin/loop_claude/test_loop_claude.py b/bin/loop_claude/test_loop_claude.py index 9912f7c1..b6bb422a 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 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. Launch each subagent that files or scores todo.md items on the rung `subagent-rung --plan ` prints.\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. Launch each subagent that files or scores todo.md items on the rung `~/.claude/bin/subagent-rung --plan claude-opus-5-5 ` prints.\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/subagent_rung/main.py b/bin/subagent_rung/main.py index 37de6cea..a73091f9 100644 --- a/bin/subagent_rung/main.py +++ b/bin/subagent_rung/main.py @@ -6,7 +6,7 @@ usage: subagent-rung [--plan] 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, 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 +R + C picks a lower one, as ~/.claude/rules/todo-items.md lets only the project's rung or above plan. 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. diff --git a/docs/decisions.md b/docs/decisions.md index e876a259..88815908 100644 --- a/docs/decisions.md +++ b/docs/decisions.md @@ -114,11 +114,11 @@ 2026-10-02, lilleman. Serves goal 1: findings were filed faster than chunks closed them, so the plan grew without telling what mattered. Each item is scored as `~/.claude/rules/todo-items.md` says; this repo's formula counts value highest and size least. An item under the bar is not kept; this repo's bar started at 10 and was set to 9 the same day, purging the 17 items under it. An Exempt cell keeps a row past the bar where a rule needs it kept. lilleman retired the two decisions whose plans the purge removed: the stats line in the transcript archive, and three benches before a workflow change merges. A finding under the bar is recorded nowhere, so a later review may raise it again, and the run rescores it. That costs one scoring; a ledger of dropped findings would regrow the list the bar caps. larv-review's "Round cap" โ†’ "Done" counts a finding named under the bar as settled, so one raised again holds no pass open. `rank_todo.py --check` is part of larv-review's gate, since only a check keeps the stored Score from going stale. The format is mandatory in every project, as the premises are (goal 1.3); the formula, bar and weights are each project's own. A script ranks the table so a re-rank after each addition or edit is deterministic and cheap. A ๐ŸŸก against a technical principle is exempt as `principle`, because its audience value scores low and the bar would drop every one. A ๐ŸŸข against a principle is scored like any other finding. 2026-10-08, lilleman: the goal weights in `todo.md` depart from an even spread by position, which would weigh goal 4, leaking nothing, at 0.11. Valid while one human sets the bar and reads the ranking, and while the items marked `principle` stay few enough to rank. -## todo.md: only a session or subagent on the project's rung or above scores or reshapes the plan; one below it drafts new items for a subagent on that rung to file and score, and removes finished ones +## todo.md: only a session or subagent on the project's rung or above scores or reshapes the plan; one below it drafts new items and changes to filed ones for a subagent at or above that rung to apply and score, and removes finished ones -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). +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. Below the project's rung, 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. Before the next commit, one subagent on the project's rung or above applies and scores the drafts. One launch covers all of 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: 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 that rung, as it does the judge's. `bin/loop_claude/cycle/prompts.py`'s `off_the_projects_rung` names the same command to a worker below the project's rung, never a fixed rung, which would disagree with `--plan` on a scoring task of R + C 11 or more. 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: the one the task's R + C picks, never below the project's, so a hard scoring task still climbs. `bin/loop_claude/cycle/prompts.py`'s `off_the_projects_rung` names the same command to a worker below the project's rung, never a fixed rung, which would disagree with `--plan` on a scoring task of R + C 11 or more. Valid while a worker or subagent 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 a8e97add..462f41c3 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.** 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. +- **Plan only on the project's rung or above.** loop-claude's prompt tells you when you run below it. Below it, 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, launch one subagent to apply the drafts, score them and set their release. Launch it on the rung `CLAUDE.md`'s delegation rule gives a subagent that files or scores items. Keep the scores and releases it writes. For a security finding, launch it at once. Any rung may remove a finished item's row and detail, and score a delegated task's R + C. 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 fcff109a..b568ca64 100644 --- a/todo.md +++ b/todo.md @@ -92,7 +92,7 @@ Release 0.2.0 takes items 125, 114 and 124 first, whatever their scores: Shape i The human asked for this on 2026-10-15. Four triggers mean a task is too hard for the worker's rung: -1. A re-score of the item, made on the project's rung as `rules/todo-items.md` requires, picks a higher rung than the worker's. +1. A re-score of the item, made on the project's rung or above, as `rules/todo-items.md` requires, picks a higher rung than the worker's. 2. The same failing test or finding survives two fix attempts. 3. A pass reports a ๐Ÿ”ด in round 2 or later, as the `Answer round :` commit titles show. 4. A reviewer or comprehension seat rules the work below standard, per item 144. @@ -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. 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. +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. Once split, the delegation entry's title names 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 subagent that files or scores items. ### 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. From 0e75f58b1267632609934fc2d472beafea1cb03f Mon Sep 17 00:00:00 2001 From: Lilleman auf Larv Date: Thu, 15 Oct 2026 16:08:22 +0200 Subject: [PATCH 14/26] Record the comprehension check: paired ruling same against b281392 --- docs/comprehension-history.md | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/docs/comprehension-history.md b/docs/comprehension-history.md index 9c860076..753ff59d 100644 --- a/docs/comprehension-history.md +++ b/docs/comprehension-history.md @@ -1712,3 +1712,23 @@ Inherited architect, decided by: - Shape: `bin/judge_replay/main.py:31` imports: one launcher reaching into five `loop_claude` internals, balanced by `judge`, `judge_once` and `judge_args` in `bin/loop_claude/cycle/judge.py:123` now three units with truthful names - Locality: `bin/loop_claude/routing.py:51` `judge_rung`: derives its own anchor from the judge model while `Cycle.anchor` is the worker's, so "anchor" means two rungs in one cycle when the models differ - Self-sufficiency: `bin/loop_claude/routing.py:54` `judge_rung` docstring: points into the plan at item 136, and `JUDGE_REPLAYED` and `REFERENCE_EFFORT` rest on a past replay and a past settings value the code cannot show + +## 2026-10-15T14:08:19Z, PR #273 at f13447f, against b281392 + +Ruling: same + +| Seat | Navigation | Locality | Shape | Self-sufficiency | Overall | +|---|---|---|---|---|---| +| Mid A | same | same | better | same | same | +| Inherited architect | same | worse | same | same | same | + +Mid A, decided by: + +- Shape: `bin/model_routing/ladder.py:52` `floored`: names the rule "the rung R + C picks, never below the project's rung" beside `picked`, for two callers, where the base built it inline in `judge_rung` from `highest` and `item_rung` + +Inherited architect, decided by: + +- Locality: `rules/todo-items.md:9` "Plan only on the project's rung or above": the planning rule spans the rule file, `CLAUDE.md:55`, `bin/subagent_rung/main.py`'s help and `ladder.floored`, with no one file holding it whole +- Locality: `bin/loop_claude/cycle/prompts.py:34` `off_the_projects_rung`: the prompt spells out another tool's command line, `subagent-rung --plan`, with nothing tying the two, and its docstring points to `routing.first_route` in another module +- Locality: `bin/loop_claude/routing.py:61` `judge_rung`: reads in one line and drops the two-way reference with `item_rung`, but writes the no-item branch a second time +- Shape, Self-sufficiency: `bin/model_routing/ladder.py:52` `floored`: a truthfully named helper, offset by `bin/subagent_rung/main.py:23` `agent_args`'s boolean `planning` and position-sensitive `--plan` parsing From f6d4d8c881d1177dd86195fd24f4aa2b7e681db8 Mon Sep 17 00:00:00 2001 From: Lilleman auf Larv Date: Thu, 15 Oct 2026 16:16:13 +0200 Subject: [PATCH 15/26] Let a worker hand a too-hard task to a subagent one rung up per escalation trigger, at most two above its item's rung --- AGENTS.md | 1 + CHANGELOG.md | 1 + CLAUDE.md | 6 ++++++ bin/loop_claude/cycle/prompts.py | 23 +++++++++++++++++--- bin/loop_claude/test_loop_claude.py | 15 ++++++++++--- bin/routing_figures/measure.py | 14 +++++++++--- bin/routing_figures/test_routing_figures.py | 17 +++++++++++---- docs/decisions.md | 12 ++++++++++- todo.md | 24 +++++---------------- 9 files changed, 80 insertions(+), 33 deletions(-) diff --git a/AGENTS.md b/AGENTS.md index 8a31e2fc..1c986e34 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -35,6 +35,7 @@ Decisions live in `docs/decisions.md`: - 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 may run below that rung, launching its reviewers on that rung; the worker routes each subagent it delegates to by the R + C of the subagent's task +- routing: a worker hands a task one rung up on each escalation trigger, to at most two rungs above the rung its item picks without the human's yes, and opens the subagent's prompt with the trigger so the routing figures count it - routing: on a model judge-replay covered, the judge runs on the rung its chunk's item picks, never below the project's rung ## Working rules diff --git a/CHANGELOG.md b/CHANGELOG.md index 7727200b..fe7514cd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,7 @@ ## Unreleased +- A session hands a task that proves too hard for its rung to a subagent one rung up, edits included, when a trigger fires: a re-score of the item on the project's rung or above picks a higher rung, the same failing test or finding survives two fix attempts, or a review pass reports a ๐Ÿ”ด in round 2 or later. Each further trigger climbs one more rung, to at most two rungs above the rung the chunk's `todo.md` item picks, unless you agree. `CLAUDE.md` states the rule, and `loop-claude`'s prompt names the rungs a trigger opens. The worker opens the subagent's prompt with `Escalation trigger :`, and `routing-figures.md` counts the escalations by trigger. Expect a chunk that gets stuck to spend more on the stuck part, and fewer unfinished verdicts. - 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 or above applies and scores the drafts and sets their release. It may still remove finished items. `rules/todo-items.md` states the rule. `CLAUDE.md` has a session launch a subagent that files or scores items on the rung the new `bin/subagent-rung --plan ` prints, never below the project's rung, and `loop-claude`'s prompt to a worker below that rung names the command. 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. diff --git a/CLAUDE.md b/CLAUDE.md index 9cc96ac7..dfb2f369 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -53,6 +53,12 @@ The rules only reviewers apply, for quality, comments, READMEs and prose, live i - 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 model. A subagent that files or scores `todo.md` items takes the rung `~/.claude/bin/subagent-rung --plan ` prints, which is never below the project's. +- Escalate a task that proves too hard for your rung. Three triggers say so: + 1. A re-score of the item, made on the project's rung or above, picks a rung above yours. + 2. The same failing test or finding survives two fix attempts. + 3. A pass reports a ๐Ÿ”ด in round 2 or later. + + When one fires, hand the hard part, edits included, to a subagent on the rung loop-claude's prompt names, one above yours. Open the subagent's prompt with `Escalation trigger :` and the evidence, so loop-claude's routing figures count it. Each later subagent on that task runs on that rung or higher, and each further trigger moves it one rung up, to at most the highest rung the prompt names. Ask the human before going higher, or when no prompt names a rung. - 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/bin/loop_claude/cycle/prompts.py b/bin/loop_claude/cycle/prompts.py index 71d090f1..a0aa4fe0 100644 --- a/bin/loop_claude/cycle/prompts.py +++ b/bin/loop_claude/cycle/prompts.py @@ -1,8 +1,13 @@ -from model_routing.ladder import highest, Rung +from model_routing.ladder import climbed, highest, LADDER, position, Rung from loop_claude.project.records import HUMAN_RULE_NAMES, RECORD_FILES +from loop_claude.routing import item_rung from markdown_text import quoted from model_routing.route import Route +# How many rungs above the one its item picks the worker may escalate a task without the human's yes: docs/decisions.md โ†’ `routing: a worker hands a task one rung up`. +ESCALATION_CAP = 2 + + def either(names: tuple[str, ...]) -> str: """The names as `a, b or c`.""" return f"{', '.join(names[:-1])} or {names[-1]}" @@ -21,7 +26,7 @@ def fresh(task: str, premises: str, route: Route, anchor: Rung | None) -> str: def routed_by(route: Route, anchor: Rung | None) -> 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}.{off_the_projects_rung(route, anchor)}" + 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}.{off_the_projects_rung(route, anchor)}{escalation(route, anchor)}" def off_the_projects_rung(route: Route, anchor: Rung | None) -> str: @@ -35,10 +40,22 @@ def off_the_projects_rung(route: Route, anchor: Rung | None) -> str: 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.{planning}" +def escalation(route: Route, anchor: Rung | None) -> str: + """The rungs an escalation trigger lets the worker hand a task to: from one above its own up to ESCALATION_CAP above the rung its item picks; empty off the ladder or on its top rung.""" + if anchor is None or route.rung not in LADDER or route.rung == LADDER[-1]: + return "" + cap = position(climbed(item_rung(anchor, route), ESCALATION_CAP)) + rungs = [f"`{rung.agent_args()}`" for rung in LADDER[position(route.rung) + 1:cap + 1]] + if not rungs: + return " An escalation trigger in `~/.claude/CLAUDE.md` lets you hand a task to a subagent above your rung only once the human agrees." + further = f", and on each further trigger one rung higher, up to {rungs[-1]}" if len(rungs) > 1 else "" + return f" When an escalation trigger in `~/.claude/CLAUDE.md` fires, hand the task to a subagent with the Agent tool set to {rungs[0]}, one rung above yours{further}; above that, ask the human first." + + def resumed(unfinished_evidence: str, route: Route, anchor: Rung | None) -> str: """Names the project's rung again, since a step-up between cycles may have taken the worker above it.""" ruled = f" A judge ruled the chunk unfinished, quoting this passage of your transcript as the work remaining:\n\n{quoted(unfinished_evidence)}\n\n" if unfinished_evidence else " " - return f"Continue the task; the previous run ended before the chunk was finished.{ruled}The chunk is finished once it is merged, or nothing remains that you could do on your own. Even then, it is finished only once {ANSWERS_RECORDED}.{off_the_projects_rung(route, anchor)}" + return f"Continue the task; the previous run ended before the chunk was finished.{ruled}The chunk is finished once it is merged, or nothing remains that you could do on your own. Even then, it is finished only once {ANSWERS_RECORDED}.{off_the_projects_rung(route, anchor)}{escalation(route, anchor)}" def answered(question: str, answer: str) -> str: diff --git a/bin/loop_claude/test_loop_claude.py b/bin/loop_claude/test_loop_claude.py index b6bb422a..5a77202d 100644 --- a/bin/loop_claude/test_loop_claude.py +++ b/bin/loop_claude/test_loop_claude.py @@ -646,16 +646,25 @@ 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 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. Launch each subagent that files or scores todo.md items on the rung `~/.claude/bin/subagent-rung --plan claude-opus-5-5 ` prints.\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. Launch each subagent that files or scores todo.md items on the rung `~/.claude/bin/subagent-rung --plan claude-opus-5-5 ` prints. When an escalation trigger", 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): opus = Rung("claude-opus-5-5", "medium") above = prompts.fresh("Do it.", "## Goals", Route(Rung("claude-opus-5-5", "high"), 3, 11), opus) stepped_up = prompts.resumed("", Route(Rung("claude-opus-5-5", "high"), 3, 9), opus) - self.assertTrue(stepped_up.endswith(" Your rung is above the project's, claude-opus-5-5 at medium effort: launch 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."), stepped_up) + self.assertIn(" Your rung is above the project's, claude-opus-5-5 at medium effort: launch 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. When an escalation trigger", stepped_up) self.assertNotIn("the project's", prompts.resumed("", Route(opus, 3, 9), opus)) - self.assertIn("whether or not it is item 3. Your rung is above the project's, claude-opus-5-5 at medium effort: launch 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", above) + self.assertIn("whether or not it is item 3. Your rung is above the project's, claude-opus-5-5 at medium effort: launch 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. When an escalation trigger", above) + + def test_names_the_rungs_an_escalation_trigger_lets_the_worker_hand_a_task_to_at_most_two_above_its_items(self): + opus = Rung("claude-opus-5-5", "medium") + fresh = prompts.fresh("Do it.", "## Goals", Route(opus, 3, 9), opus) + self.assertIn("whether or not it is item 3. When an escalation trigger in `~/.claude/CLAUDE.md` fires, hand the task to a subagent with the Agent tool set to `model opus, effort high`, one rung above yours, and on each further trigger one rung higher, up to `model opus, effort xhigh`; above that, ask the human first.\n\n", fresh) + self.assertTrue(prompts.resumed("", Route(Rung("claude-opus-5-5", "high"), 3, 9), opus).endswith(" When an escalation trigger in `~/.claude/CLAUDE.md` fires, hand the task to a subagent with the Agent tool set to `model opus, effort xhigh`, one rung above yours; above that, ask the human first.")) + self.assertTrue(prompts.resumed("", Route(Rung("claude-opus-5-5", "xhigh"), 3, 9), opus).endswith(" An escalation trigger in `~/.claude/CLAUDE.md` lets you hand a task to a subagent above your rung only once the human agrees.")) + self.assertNotIn("escalation", prompts.resumed("", Route(Rung("claude-fable-5-1", "max"), 3, 20), opus)) + self.assertNotIn("escalation", prompts.resumed("", Route(Rung("m")), None)) 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")) diff --git a/bin/routing_figures/measure.py b/bin/routing_figures/measure.py index 0cfd50c2..56d7a806 100644 --- a/bin/routing_figures/measure.py +++ b/bin/routing_figures/measure.py @@ -20,6 +20,8 @@ MEASURED_AT_LEAST = 5 DIMENSIONS = ("project", "subagent type", "rung", "tool") # The tool label of a message that follows no tool call, such as the first message after a prompt. PROMPT = "prompt" +# How a worker opens the prompt of a subagent it escalates a task to: CLAUDE.md โ†’ "Working with the codebase". +ESCALATION = re.compile(r"Escalation trigger ([0-9]+):") @dataclasses.dataclass(frozen=True) @@ -52,13 +54,14 @@ class Reports: @dataclasses.dataclass(frozen=True) class ChunkFigures: - """tokens maps each of DIMENSIONS to its labels' tokens; start is the rung a routed chunk started on, None where no item routed it.""" + """tokens maps each of DIMENSIONS to its labels' tokens; start is the rung a routed chunk started on, None where no item routed it; escalated counts the worker's escalations by trigger.""" tokens: dict[str, collections.Counter[str]] start: Rung | None rounds_past_first: int unfinished: int delegated: collections.Counter[str] reports: dict[str, Reports] + escalated: collections.Counter[str] @dataclasses.dataclass(frozen=True) @@ -68,6 +71,7 @@ class Figures: tokens: dict[str, collections.Counter[str]] routed: dict[Rung, list[ChunkFigures]] reports: dict[str, Reports] + escalated: collections.Counter[str] skipped: tuple[str, ...] = () @@ -89,7 +93,8 @@ def measured(chunk: Chunk, home: str) -> ChunkFigures: for _, tools, spent in spend(subagent.entries): add(tokens, chunk.project, kind, rung, tools, spent) start = route_from(cycles[0][1]) if cycles else None - return ChunkFigures(tokens, start.rung if start and start.item else None, rounds_past_first(chunk.worker, home), sum(len(UNFINISHED_AT.findall(kept)) for kept in chunk.outcomes), delegated, reports) + escalated = collections.Counter(found[1] for _, arguments in launches.values() if (found := ESCALATION.match(str(arguments.get("prompt") or "")))) + return ChunkFigures(tokens, start.rung if start and start.item else None, rounds_past_first(chunk.worker, home), sum(len(UNFINISHED_AT.findall(kept)) for kept in chunk.outcomes), delegated, reports, escalated) def agent_calls(worker: list[dict]) -> dict[str, tuple[str, dict]]: @@ -182,12 +187,13 @@ def totals(chunks: list[ChunkFigures], skipped: tuple[str, ...] = ()) -> Figures tokens = {dimension: sum((chunk.tokens.get(dimension, collections.Counter()) for chunk in chunks), collections.Counter()) for dimension in DIMENSIONS} routed: dict[Rung, list[ChunkFigures]] = {} reports: dict[str, Reports] = {} + escalated: collections.Counter[str] = sum((chunk.escalated for chunk in chunks), collections.Counter()) for chunk in chunks: if chunk.start: routed.setdefault(chunk.start, []).append(chunk) for kind, found in chunk.reports.items(): reports[kind] = reports.get(kind, Reports(0, 0, 0)) + found - return Figures(len(chunks), tokens, routed, reports, skipped) + return Figures(len(chunks), tokens, routed, reports, escalated, skipped) def calls(figures: Figures) -> list[str]: @@ -222,6 +228,8 @@ def render(figures: Figures, found: list[str], at: str, cycle: int, since: str) ]), "## Subagent reports against the searches they ran, in characters", table(("Subagent type", "Subagents", "Reports", "Searches"), [(kind, str(found.subagents), str(found.report), str(found.searches)) for kind, found in sorted(figures.reports.items())]), + "## Escalations by trigger", + table(("Trigger", "Subagents"), [(trigger, str(times)) for trigger, times in sorted(figures.escalated.items(), key=lambda item: int(item[0]))]), *(["## Chunks skipped, unreadable", "".join(f"- {folder}\n" for folder in figures.skipped).rstrip("\n")] if figures.skipped else []), ] return "\n\n".join(sections) + "\n" diff --git a/bin/routing_figures/test_routing_figures.py b/bin/routing_figures/test_routing_figures.py index 26bb0227..be7d6bf9 100644 --- a/bin/routing_figures/test_routing_figures.py +++ b/bin/routing_figures/test_routing_figures.py @@ -37,8 +37,8 @@ def stamped(at, outcome): return f"{at} {outcome}\n" -def figures(start=LOW, rounds=0, unfinished=0, reports=None): - return ChunkFigures({}, start, rounds, unfinished, collections.Counter(), reports or {}) +def figures(start=LOW, rounds=0, unfinished=0, reports=None, escalated=None): + return ChunkFigures({}, start, rounds, unfinished, collections.Counter(), reports or {}, collections.Counter(escalated or {})) class Measured(unittest.TestCase): @@ -72,6 +72,13 @@ class Measured(unittest.TestCase): self.assertEqual(found.tokens["subagent type"], {"worker": 111, "Explore": 222}) self.assertEqual(found.reports, {"Explore": Reports(2, 35, 20)}) + def test_counts_the_workers_escalations_by_the_trigger_each_subagents_prompt_opens_with(self): + worker = [ + message("m1", "2026-10-14T10:00:00Z", call("Agent", "a1", prompt="Escalation trigger 2: the test failed twice"), call("Agent", "a2", prompt="Escalation trigger 2: again"), call("Agent", "a3", prompt="Escalation trigger 3: a ๐Ÿ”ด in round 2")), + message("m2", "2026-10-14T10:01:00Z", call("Agent", "a4", prompt="Find the callers. Escalation trigger 1: not at the start"), call("Agent", "a5", prompt="Escalation trigger x: no number")), + ] + self.assertEqual(measured(Chunk("log", [], worker, []), "/h").escalated, {"2": 2, "3": 1}) + def test_counts_review_rounds_past_each_passs_first_once_per_title(self): commit = lambda id_, title: message(id_, "2026-10-14T10:00:00Z", call("Bash", command=f"git commit -m '{title}'")) worker = [commit("m1", "Answer stability round 1: 1 ๐Ÿ”ด, 0 ๐ŸŸก"), commit("m2", "Answer stability round 2: 0 ๐Ÿ”ด, 0 ๐ŸŸก"), commit("m3", "Answer stability round 2: 0 ๐Ÿ”ด, 0 ๐ŸŸก"), commit("m4", "Answer prose round 1: 0 ๐Ÿ”ด, 1 ๐ŸŸก")] @@ -139,15 +146,17 @@ class Calls(unittest.TestCase): self.assertEqual(calls(totals([figures(reports={"Explore": Reports(1, 20, 30)})] * 5)), []) def test_renders_each_dimension_largest_first_and_the_calls(self): - chunk = ChunkFigures({"project": collections.Counter({"a": 2, "b": 20})}, LOW, 1, 0, collections.Counter({str(HIGH): 2}), {"Explore": Reports(2, 3, 4)}) + chunk = ChunkFigures({"project": collections.Counter({"a": 2, "b": 20})}, LOW, 1, 0, collections.Counter({str(HIGH): 2}), {"Explore": Reports(2, 3, 4)}, collections.Counter()) text = render(totals([chunk]), ["Call."], "2026-10-15T00:00:00Z", 40, "") self.assertIn("Measured 2026-10-15T00:00:00Z, at cycle 40 across loop-claude's archive, from 1 finished chunk.", text) self.assertIn("## Calls for a routing change\n\n- Call.\n", text) self.assertIn("| b | 20 |\n| a | 2 |", text) self.assertIn(f"| {LOW} | 1 | 1.0 | 0.0 | {HIGH} 2 |", text) - two = ChunkFigures({}, HIGH, 0, 1, collections.Counter({str(HIGH): 2, str(LOW): 1}), {}) + two = ChunkFigures({}, HIGH, 0, 1, collections.Counter({str(HIGH): 2, str(LOW): 1}), {}, collections.Counter()) self.assertIn(f"| {LOW} | 1 | 1.0 | 0.0 | {HIGH} 2 |\n| {HIGH} | 1 | 0.0 | 1.0 | {HIGH} 2, {LOW} 1 |", render(totals([two, chunk]), [], "2026-10-15T00:00:00Z", 40, "")) self.assertIn("| Explore | 2 | 3 | 4 |", text) + self.assertIn("## Escalations by trigger\n\n| Trigger | Subagents |\n| --- | --- |\n| 2 | 3 |\n| 3 | 1 |\n", render(totals([figures(escalated={"2": 2}), figures(escalated={"2": 1, "3": 1})]), [], "2026-10-15T00:00:00Z", 40, "")) + self.assertIn("## Escalations by trigger\n\nNone.\n", text) self.assertIn("## Calls for a routing change\n\nNone.\n", render(totals([]), [], "2026-10-15T00:00:00Z", 20, "")) self.assertIn("from 0 finished chunks that finished after the reset of 2026-10-14T00:00:00Z.", render(totals([]), [], "2026-10-15T00:00:00Z", 20, "2026-10-14T00:00:00Z")) diff --git a/docs/decisions.md b/docs/decisions.md index 88815908..9fd83041 100644 --- a/docs/decisions.md +++ b/docs/decisions.md @@ -188,12 +188,22 @@ The cost of a cheaper worker shows as extra review rounds and unfinished verdict 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, loop-claude's prompt has it launch the comprehension seats and the security pass's subagent on the project's rung too. So the seats score every chunk on one rung, and the security pass spends no more than the project chose. The prompt after each unfinished verdict repeats this, since a step-up may have taken the worker above the project's rung. The other reviewers inherit the worker's higher rung. On 2026-10-15 lilleman dropped routing them by R + C instead: a worker climbs because its chunk proved harder than its score said, which is when a cheaper reviewer is the bigger risk. `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 delegates a task only when it needs just the task's conclusion: a search or read across many files, or work independent enough to run in parallel. Edits, and whatever it must check line by line, stay in its own thread, since it would read a delegated diff again to check it. Measured over archived worker transcripts, subagent reports cost a median 8% of the worker's peak context, and `sed -n` and `grep` output made up 41% of its Bash results, so delegated searches save the most context. It scores each delegated task's R and C as for an item, and `bin/subagent-rung` turns them into the Agent tool's model and effort, counted from the project's rung. The rule names both, because the Agent tool sets a subagent's effort only when instructions ask. `CLAUDE.md` states the rule, since it holds in every session. +The worker delegates a task only when it needs just the task's conclusion: a search or read across many files, or work independent enough to run in parallel. Edits, and whatever it must check line by line, stay in its own thread, since it would read a delegated diff again to check it. Measured over archived worker transcripts, subagent reports cost a median 8% of the worker's peak context, and `sed -n` and `grep` output made up 41% of its Bash results, so delegated searches save the most context. It scores each delegated task's R and C as for an item, and `bin/subagent-rung` turns them into the Agent tool's model and effort, counted from the project's rung. The rule names both, because the Agent tool sets a subagent's effort only when instructions ask. `CLAUDE.md` states the rule, since it holds in every session. A task that proves too hard for the worker's rung escalates instead, by the next entry. 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. Valid while the index ranks these models, and while no newer model joins the catalog. +## routing: a worker hands a task one rung up on each escalation trigger, to at most two rungs above the rung its item picks without the human's yes, and opens the subagent's prompt with the trigger so the routing figures count it + +2026-10-15, lilleman asked for it. Serves goals 1.1 and 1.4: a task too hard for a cheap rung gets a dearer one only once it proves hard, and only for the part that proved hard. + +Three triggers in `CLAUDE.md` โ†’ "Working with the codebase" mark a task too hard: a re-score of the item on the project's rung or above picks a higher rung, the same failing test or finding survives two fix attempts, or a pass reports a ๐Ÿ”ด in round 2 or later. When one fires, the worker hands the hard part to a subagent one rung above its own, edits included, though the delegation rule keeps edits in the worker's thread: the escalation exists because the worker could not get them right. Each further trigger on that task climbs one more rung. Without lilleman's yes the climb stops two rungs above the rung the chunk's item picks, the rung the chunk started on, or the project's rung for a chunk no item routed. A step-up between cycles raises the worker but not that limit, so the worker never escalates past what its item was judged to need by more than two rungs (goal 1.4). + +loop-claude's prompt names the rungs a trigger opens, so the worker computes no rung positions. Its `ESCALATION_CAP` in `bin/loop_claude/cycle/prompts.py` holds the two. The worker opens each escalated subagent's prompt with `Escalation trigger :`. The archive keeps the raw transcript, which holds that prompt, and `bin/routing_figures/` counts the escalations by trigger in `routing-figures.md`. + +Valid while the ladder orders its rungs by competence. + ## routing: on a model judge-replay covered, the judge runs on the rung its chunk's item picks, never below the project's rung 2026-10-15, lilleman's plan, settled by the replay below. Serves goals 1.2 and 1.4, under the ladder and bands of `routing: one ladder`. diff --git a/todo.md b/todo.md index b568ca64..dc670745 100644 --- a/todo.md +++ b/todo.md @@ -26,8 +26,7 @@ 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 | |---|---|---|---|---|---|---|---|---|---|---| -| 142 | 0.1.0 | | **Let a chunk's worker hand a task to a subagent one rung up when an escalation trigger fires, at most two rungs above the rung it started the chunk on without the human's yes.** | 4 | 5 | 6 | 7 | 8 | 1.1, 1.4 | 24.6 | -| 144 | 0.1.0 | | **Let a reviewer or comprehension seat that rules the work below standard rerun its review one rung up, outside the round cap, and let the worker escalate under item 142.** | 4 | 5 | 6 | 6 | 7 | 1.1 | 20.6 | +| 144 | 0.1.0 | | **Let a reviewer or comprehension seat that rules the work below standard rerun its review one rung up, outside the round cap, and make that ruling an escalation trigger for the worker.** | 4 | 5 | 6 | 6 | 7 | 1.1 | 20.6 | | 145 | 0.1.0 | | **Run the stability reviewer on the worker's rung while the worker runs below the project's rung, once a replay of past stability rounds on that rung finds the ๐Ÿ”ด and ๐ŸŸก findings on record.** | 4 | 5 | 6 | 6 | 7 | 1.4 | 20.2 | | 143 | 0.1.0 | | **Resume a worker one rung up in the next cycle when its run ends asking for a higher rung and the judge finds the escalation trigger it cites in the transcript.** | 5 | 5 | 7 | 6 | 7 | 1.1, 1.4 | 19.6 | | 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 | @@ -88,22 +87,9 @@ Release 0.2.0 takes items 125, 114 and 124 first, whatever their scores: Shape i ## Details -### 142. Let a chunk's worker hand a task to a subagent one rung up when an escalation trigger fires, at most two rungs above the rung it started the chunk on without the human's yes. +### 144. Let a reviewer or comprehension seat that rules the work below standard rerun its review one rung up, outside the round cap, and make that ruling an escalation trigger for the worker. -The human asked for this on 2026-10-15. Four triggers mean a task is too hard for the worker's rung: - -1. A re-score of the item, made on the project's rung or above, as `rules/todo-items.md` requires, picks a higher rung than the worker's. -2. The same failing test or finding survives two fix attempts. -3. A pass reports a ๐Ÿ”ด in round 2 or later, as the `Answer round :` commit titles show. -4. A reviewer or comprehension seat rules the work below standard, per item 144. - -When one fires, the worker hands the hard part to a subagent one rung above its own and cites the trigger in the subagent's prompt. Each later subagent on that task runs on the raised rung or higher. None runs more than two rungs above the rung the worker started the chunk on unless the human agrees. loop-claude archives each step with its trigger, and `routing-figures.md` counts them. - -This revises `docs/decisions.md` โ†’ `routing: one ladder`, where the worker routes each subagent by its task's R + C alone, and the delegation rule in `CLAUDE.md`. The comprehension seats found it hard to follow which model a subagent gets: `CLAUDE.md`'s delegation rule, `bin/loop_claude/cycle/prompts.py`'s `off_the_projects_rung` and `bin/model_routing/ladder.py`'s `Rung.agent_args` each hold part of it. Make it easier to read. - -### 144. Let a reviewer or comprehension seat that rules the work below standard rerun its review one rung up, outside the round cap, and let the worker escalate under item 142. - -The human asked for this on 2026-10-15, and for the worker to escalate too. A reviewer rules the work below standard when it reports an architect BLOCK or a finding against `skills/larv-review/standards/quality.md`. It may then ask for its pass to rerun one rung up, and that rerun counts toward no round cap. A comprehension seat rules it below standard when it votes "worse" in a paired ruling. It may then ask for the ruling to rerun with its seat one rung up. Either ruling is trigger 4 of item 142. No ruling raises the judge's own rung. +The human asked for this on 2026-10-15, and for the worker to escalate too. A reviewer rules the work below standard when it reports an architect BLOCK or a finding against `skills/larv-review/standards/quality.md`. It may then ask for its pass to rerun one rung up, and that rerun counts toward no round cap. A comprehension seat rules it below standard when it votes "worse" in a paired ruling. It may then ask for the ruling to rerun with its seat one rung up. Either ruling becomes a fourth escalation trigger in `CLAUDE.md` โ†’ "Working with the codebase". No ruling raises the judge's own rung. This revises `docs/decisions.md` โ†’ `routing: one ladder`, which launches the reviewers on the project's rung while the worker runs below it, and on the worker's rung otherwise. It also revises `review: a pass gets at most three rounds per chunk`. The comprehension seats found larv-review ยง3's "Round cap" hard to read; word the exception so "Round cap" gets easier to read, or land it in item 120's table. @@ -117,9 +103,9 @@ This revises `docs/decisions.md` โ†’ `routing: one ladder`. ### 143. Resume a worker one rung up in the next cycle when its run ends asking for a higher rung and the judge finds the escalation trigger it cites in the transcript. -The human asked for this on 2026-10-15. A worker may end its run asking for a higher rung, citing a trigger of item 142. The judge looks for that trigger in the transcript. Where it finds it, the next cycle resumes the session one rung up; otherwise the rung holds. The worker never steps down within a chunk, and goes at most two rungs above the rung it started the chunk on unless the human agrees. +The human asked for this on 2026-10-15. A worker may end its run asking for a higher rung, citing an escalation trigger of `CLAUDE.md` โ†’ "Working with the codebase". The judge looks for that trigger in the transcript. Where it finds it, the next cycle resumes the session one rung up; otherwise the rung holds. The worker never steps down within a chunk, and goes at most two rungs above the rung it started the chunk on unless the human agrees. -This revises `docs/decisions.md` โ†’ `routing: one ladder`, where the worker steps up only after every second unfinished verdict or when the judge reports a taken-in item that picks a higher rung. This item adds a third way. It needs item 142, which defines the triggers. +This revises `docs/decisions.md` โ†’ `routing: one ladder`, where the worker steps up only after every second unfinished verdict or when the judge reports a taken-in item that picks a higher rung. This item adds a third way. The comprehension seats found two places it touches hard to read. Word the new check so that `bin/loop_claude/cycle/judge.py`'s `JUDGE_RULES` gets easier to read. `bin/loop_claude/routing.py`'s `kept` and `stepped` use different floors, and `stepped` does two jobs; make them easier to read where the new step joins them. From 33d5013039be0e42440183c68b6931f9beb9fbfc Mon Sep 17 00:00:00 2001 From: Lilleman auf Larv Date: Thu, 15 Oct 2026 16:16:21 +0200 Subject: [PATCH 16/26] Record the reading cost of the last chunk --- docs/reading-cost.md | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/docs/reading-cost.md b/docs/reading-cost.md index 85169749..9a0ba951 100644 --- a/docs/reading-cost.md +++ b/docs/reading-cost.md @@ -350,3 +350,20 @@ Read most (opens and searches): - `bin/loop_claude/project/model_choice.py` 2 - `docs/decisions.md` 2 - `rules/todo-items.md` 2 + +## Reading cost, chunk 49ec71f5e51c, finished 2026-10-15T14:08:59Z + +64058 new input tokens before the first commit. + +Read most (opens and searches): + +- `todo.md` 5 +- `CHANGELOG.md` 3 +- `docs/decisions.md` 3 +- `CLAUDE.md` 1 +- `README.md` 1 +- `bin/loop_claude/cycle/prompts.py` 1 +- `bin/loop_claude/test_black_box.py` 1 +- `bin/loop_claude/test_loop_claude.py` 1 +- `bin/model_routing/ladder.py` 1 +- `bin/subagent_rung/main.py` 1 From c0be1fdffc4646e469bbfcf7d41e8654e7ce5887 Mon Sep 17 00:00:00 2001 From: Lilleman auf Larv Date: Thu, 15 Oct 2026 16:20:28 +0200 Subject: [PATCH 17/26] =?UTF-8?q?Answer=20architecture=20round=201:=201=20?= =?UTF-8?q?=F0=9F=94=B4,=206=20=F0=9F=9F=A1;=20escalate=20in=20an=20unrout?= =?UTF-8?q?ed=20chunk's=20first=20cycle,=20hold=20the=20limit=20and=20mark?= =?UTF-8?q?er=20in=20routing.py,=20count=20escalations=20per=20starting=20?= =?UTF-8?q?rung,=20decline=20counting=20the=20limit=20from=20the=20current?= =?UTF-8?q?=20rung?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CLAUDE.md | 2 +- bin/loop_claude/cycle/prompts.py | 23 ++++++------- bin/loop_claude/routing.py | 15 +++++++- bin/loop_claude/test_loop_claude.py | 8 +++-- bin/routing_figures/measure.py | 38 ++++++++++++++------- bin/routing_figures/test_routing_figures.py | 9 +++-- docs/decisions.md | 4 +-- todo.md | 2 +- 8 files changed, 63 insertions(+), 38 deletions(-) diff --git a/CLAUDE.md b/CLAUDE.md index dfb2f369..f0fb5e33 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -58,7 +58,7 @@ The rules only reviewers apply, for quality, comments, READMEs and prose, live i 2. The same failing test or finding survives two fix attempts. 3. A pass reports a ๐Ÿ”ด in round 2 or later. - When one fires, hand the hard part, edits included, to a subagent on the rung loop-claude's prompt names, one above yours. Open the subagent's prompt with `Escalation trigger :` and the evidence, so loop-claude's routing figures count it. Each later subagent on that task runs on that rung or higher, and each further trigger moves it one rung up, to at most the highest rung the prompt names. Ask the human before going higher, or when no prompt names a rung. + When one fires, hand the hard part, edits included, to a subagent on the rung loop-claude's prompt names, one above yours. Cite the trigger and its evidence in the subagent's prompt, in the words loop-claude's prompt gives. Each later subagent on that task runs on that rung or higher, and each further trigger moves it one rung up, to at most the highest rung the prompt names. Ask the human before going higher, or when no prompt names a rung. - 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/bin/loop_claude/cycle/prompts.py b/bin/loop_claude/cycle/prompts.py index a0aa4fe0..05cbbfff 100644 --- a/bin/loop_claude/cycle/prompts.py +++ b/bin/loop_claude/cycle/prompts.py @@ -1,13 +1,9 @@ -from model_routing.ladder import climbed, highest, LADDER, position, Rung +from loop_claude.routing import ESCALATION_MARKER, escalation_rungs +from model_routing.ladder import highest, LADDER, Rung from loop_claude.project.records import HUMAN_RULE_NAMES, RECORD_FILES -from loop_claude.routing import item_rung from markdown_text import quoted from model_routing.route import Route -# How many rungs above the one its item picks the worker may escalate a task without the human's yes: docs/decisions.md โ†’ `routing: a worker hands a task one rung up`. -ESCALATION_CAP = 2 - - def either(names: tuple[str, ...]) -> str: """The names as `a, b or c`.""" return f"{', '.join(names[:-1])} or {names[-1]}" @@ -21,7 +17,8 @@ ANSWERS_RECORDED = f"every answer the human typed in it that a later chunk could def fresh(task: str, premises: str, route: Route, anchor: Rung | None) -> str: - routed = f"{routed_by(route, anchor)}\n\n" if route.item else "" + # A chunk no item routed gets no route paragraph, but may still escalate. + routed = f"{routed_by(route, anchor)}\n\n" if route.item else "".join(f"{text.lstrip()}\n\n" for text in [escalation(route, anchor)] if text) 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}" @@ -41,15 +38,15 @@ def off_the_projects_rung(route: Route, anchor: Rung | None) -> str: def escalation(route: Route, anchor: Rung | None) -> str: - """The rungs an escalation trigger lets the worker hand a task to: from one above its own up to ESCALATION_CAP above the rung its item picks; empty off the ladder or on its top rung.""" - if anchor is None or route.rung not in LADDER or route.rung == LADDER[-1]: + """The rungs routing.escalation_rungs opens to the worker, and how to mark an escalated subagent's prompt; empty off the ladder or on its top rung.""" + if anchor is None or route.rung not in LADDER[:-1]: return "" - cap = position(climbed(item_rung(anchor, route), ESCALATION_CAP)) - rungs = [f"`{rung.agent_args()}`" for rung in LADDER[position(route.rung) + 1:cap + 1]] + marked = f" Open the subagent's prompt with `{ESCALATION_MARKER} :`, n the trigger's number." + rungs = [f"`{rung.agent_args()}`" for rung in escalation_rungs(anchor, route)] if not rungs: - return " An escalation trigger in `~/.claude/CLAUDE.md` lets you hand a task to a subagent above your rung only once the human agrees." + return f" An escalation trigger in `~/.claude/CLAUDE.md` lets you hand a task to a subagent above your rung only once the human agrees.{marked}" further = f", and on each further trigger one rung higher, up to {rungs[-1]}" if len(rungs) > 1 else "" - return f" When an escalation trigger in `~/.claude/CLAUDE.md` fires, hand the task to a subagent with the Agent tool set to {rungs[0]}, one rung above yours{further}; above that, ask the human first." + return f" When an escalation trigger in `~/.claude/CLAUDE.md` fires, hand the task to a subagent with the Agent tool set to {rungs[0]}, one rung above yours{further}; above that, ask the human first.{marked}" def resumed(unfinished_evidence: str, route: Route, anchor: Rung | None) -> str: diff --git a/bin/loop_claude/routing.py b/bin/loop_claude/routing.py index 0b168250..4ee3d353 100644 --- a/bin/loop_claude/routing.py +++ b/bin/loop_claude/routing.py @@ -1,12 +1,15 @@ """Which ladder rung a chunk's worker and judge run on: docs/decisions.md โ†’ `routing:`.""" import dataclasses +from model_routing.ladder import climbed, floored, highest, LADDER, picked, position, project_rung, Rung, stepped_up from failure import Failure -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 UNFINISHED_PER_STEP = 2 +# How many rungs above item_rung the worker may escalate a task without the human's yes, and how it opens an escalated subagent's prompt: docs/decisions.md โ†’ `routing: a worker hands a task one rung up`. +ESCALATION_CAP = 2 +ESCALATION_MARKER = "Escalation trigger" # The models `judge-replay` found returning, on their cheapest rung, every verdict the reference judge reproduced: docs/decisions.md โ†’ `routing: on a model judge-replay covered`. JUDGE_REPLAYED = ("claude-opus-5-5",) @@ -38,6 +41,16 @@ def item_rung(anchor: Rung, route: Route) -> Rung: return picked(anchor, route.risk_and_complexity) if route.item else anchor +def escalation_rungs(anchor: Rung, route: Route) -> tuple[Rung, ...]: + """The rungs an escalation trigger opens to the worker, least competent first: from one above its own up to ESCALATION_CAP above item_rung; none off the ladder. + + A step-up between cycles raises the worker but not that limit, as lilleman set it from the rung the chunk started on. + """ + if route.rung not in LADDER: + return () + return LADDER[position(route.rung) + 1:position(climbed(item_rung(anchor, route), ESCALATION_CAP)) + 1] + + 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.""" # An archived rung since removed from LADDER restarts from the project's rung. diff --git a/bin/loop_claude/test_loop_claude.py b/bin/loop_claude/test_loop_claude.py index 5a77202d..5c537a3e 100644 --- a/bin/loop_claude/test_loop_claude.py +++ b/bin/loop_claude/test_loop_claude.py @@ -660,11 +660,13 @@ class WorkerArgs(unittest.TestCase): def test_names_the_rungs_an_escalation_trigger_lets_the_worker_hand_a_task_to_at_most_two_above_its_items(self): opus = Rung("claude-opus-5-5", "medium") fresh = prompts.fresh("Do it.", "## Goals", Route(opus, 3, 9), opus) - self.assertIn("whether or not it is item 3. When an escalation trigger in `~/.claude/CLAUDE.md` fires, hand the task to a subagent with the Agent tool set to `model opus, effort high`, one rung above yours, and on each further trigger one rung higher, up to `model opus, effort xhigh`; above that, ask the human first.\n\n", fresh) - self.assertTrue(prompts.resumed("", Route(Rung("claude-opus-5-5", "high"), 3, 9), opus).endswith(" When an escalation trigger in `~/.claude/CLAUDE.md` fires, hand the task to a subagent with the Agent tool set to `model opus, effort xhigh`, one rung above yours; above that, ask the human first.")) - self.assertTrue(prompts.resumed("", Route(Rung("claude-opus-5-5", "xhigh"), 3, 9), opus).endswith(" An escalation trigger in `~/.claude/CLAUDE.md` lets you hand a task to a subagent above your rung only once the human agrees.")) + self.assertIn("whether or not it is item 3. When an escalation trigger in `~/.claude/CLAUDE.md` fires, hand the task to a subagent with the Agent tool set to `model opus, effort high`, one rung above yours, and on each further trigger one rung higher, up to `model opus, effort xhigh`; above that, ask the human first. Open the subagent's prompt with `Escalation trigger :`, n the trigger's number.\n\n", fresh) + self.assertTrue(prompts.resumed("", Route(Rung("claude-opus-5-5", "high"), 3, 9), opus).endswith(" When an escalation trigger in `~/.claude/CLAUDE.md` fires, hand the task to a subagent with the Agent tool set to `model opus, effort xhigh`, one rung above yours; above that, ask the human first. Open the subagent's prompt with `Escalation trigger :`, n the trigger's number.")) + self.assertTrue(prompts.resumed("", Route(Rung("claude-opus-5-5", "xhigh"), 3, 9), opus).endswith(" An escalation trigger in `~/.claude/CLAUDE.md` lets you hand a task to a subagent above your rung only once the human agrees. Open the subagent's prompt with `Escalation trigger :`, n the trigger's number.")) self.assertNotIn("escalation", prompts.resumed("", Route(Rung("claude-fable-5-1", "max"), 3, 20), opus)) self.assertNotIn("escalation", prompts.resumed("", Route(Rung("m")), None)) + self.assertNotIn("escalation", prompts.resumed("", Route(Rung("claude-opus-5-5", "low"), 3, 9), opus)) + self.assertIn("before creating a new one.\n\nWhen an escalation trigger in `~/.claude/CLAUDE.md` fires, hand the task to a subagent with the Agent tool set to `model opus, effort high`, one rung above yours, and on each further trigger one rung higher, up to `model opus, effort xhigh`; above that, ask the human first. Open the subagent's prompt with `Escalation trigger :`, n the trigger's number.\n\nThe chunk's", prompts.fresh("Do it.", "## Goals", Route(opus), 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")) diff --git a/bin/routing_figures/measure.py b/bin/routing_figures/measure.py index 56d7a806..315a0673 100644 --- a/bin/routing_figures/measure.py +++ b/bin/routing_figures/measure.py @@ -7,6 +7,7 @@ import typing from claude_code.entries import assistant_parts, parts, tool_call, usage_count from git_command import commits +from loop_claude.routing import ESCALATION_MARKER from model_routing.ladder import position, Rung from round_titles import round_counts from model_routing.route import route_from @@ -20,8 +21,7 @@ MEASURED_AT_LEAST = 5 DIMENSIONS = ("project", "subagent type", "rung", "tool") # The tool label of a message that follows no tool call, such as the first message after a prompt. PROMPT = "prompt" -# How a worker opens the prompt of a subagent it escalates a task to: CLAUDE.md โ†’ "Working with the codebase". -ESCALATION = re.compile(r"Escalation trigger ([0-9]+):") +ESCALATION = re.compile(rf"{ESCALATION_MARKER} ([0-9]+):") @dataclasses.dataclass(frozen=True) @@ -61,7 +61,7 @@ class ChunkFigures: unfinished: int delegated: collections.Counter[str] reports: dict[str, Reports] - escalated: collections.Counter[str] + escalated: collections.Counter[int] @dataclasses.dataclass(frozen=True) @@ -71,7 +71,6 @@ class Figures: tokens: dict[str, collections.Counter[str]] routed: dict[Rung, list[ChunkFigures]] reports: dict[str, Reports] - escalated: collections.Counter[str] skipped: tuple[str, ...] = () @@ -93,8 +92,21 @@ def measured(chunk: Chunk, home: str) -> ChunkFigures: for _, tools, spent in spend(subagent.entries): add(tokens, chunk.project, kind, rung, tools, spent) start = route_from(cycles[0][1]) if cycles else None - escalated = collections.Counter(found[1] for _, arguments in launches.values() if (found := ESCALATION.match(str(arguments.get("prompt") or "")))) - return ChunkFigures(tokens, start.rung if start and start.item else None, rounds_past_first(chunk.worker, home), sum(len(UNFINISHED_AT.findall(kept)) for kept in chunk.outcomes), delegated, reports, escalated) + return ChunkFigures( + tokens=tokens, + start=start.rung if start and start.item else None, + rounds_past_first=rounds_past_first(chunk.worker, home), + unfinished=sum(len(UNFINISHED_AT.findall(kept)) for kept in chunk.outcomes), + delegated=delegated, + reports=reports, + escalated=escalations(launches), + ) + + +def escalations(launches: dict[str, tuple[str, dict]]) -> collections.Counter[int]: + """How many Agent calls the worker escalated on each trigger, by the trigger number each call's prompt opens with.""" + opened = (ESCALATION.match(str(arguments.get("prompt") or "")) for _, arguments in launches.values()) + return collections.Counter(int(found[1]) for found in opened if found) def agent_calls(worker: list[dict]) -> dict[str, tuple[str, dict]]: @@ -187,13 +199,12 @@ def totals(chunks: list[ChunkFigures], skipped: tuple[str, ...] = ()) -> Figures tokens = {dimension: sum((chunk.tokens.get(dimension, collections.Counter()) for chunk in chunks), collections.Counter()) for dimension in DIMENSIONS} routed: dict[Rung, list[ChunkFigures]] = {} reports: dict[str, Reports] = {} - escalated: collections.Counter[str] = sum((chunk.escalated for chunk in chunks), collections.Counter()) for chunk in chunks: if chunk.start: routed.setdefault(chunk.start, []).append(chunk) for kind, found in chunk.reports.items(): reports[kind] = reports.get(kind, Reports(0, 0, 0)) + found - return Figures(len(chunks), tokens, routed, reports, escalated, skipped) + return Figures(len(chunks), tokens, routed, reports, skipped) def calls(figures: Figures) -> list[str]: @@ -222,19 +233,22 @@ def render(figures: Figures, found: list[str], at: str, cycle: int, since: str) "".join(f"- {call}\n" for call in found).rstrip("\n") or "None.", *[part for dimension in DIMENSIONS for part in (f"## Tokens by {dimension}", table((dimension.capitalize(), "Tokens"), [(label, str(tokens)) for label, tokens in figures.tokens[dimension].most_common()]))], "## Routed chunks by the rung they started on", - table(("Rung", "Chunks", "Review rounds past each pass's first, mean", "Unfinished verdicts, mean", "Subagent rungs"), [ - (str(rung), str(len(chunks)), f"{mean(chunks, lambda chunk: chunk.rounds_past_first):.1f}", f"{mean(chunks, lambda chunk: chunk.unfinished):.1f}", ", ".join(f"{label} {times}" for label, times in sum((chunk.delegated for chunk in chunks), collections.Counter()).most_common())) + table(("Rung", "Chunks", "Review rounds past each pass's first, mean", "Unfinished verdicts, mean", "Subagent rungs", "Escalations by trigger"), [ + (str(rung), str(len(chunks)), f"{mean(chunks, lambda chunk: chunk.rounds_past_first):.1f}", f"{mean(chunks, lambda chunk: chunk.unfinished):.1f}", ", ".join(f"{label} {times}" for label, times in sum((chunk.delegated for chunk in chunks), collections.Counter()).most_common()), escalated(chunks)) for rung, chunks in sorted(figures.routed.items(), key=lambda item: position(item[0])) ]), "## Subagent reports against the searches they ran, in characters", table(("Subagent type", "Subagents", "Reports", "Searches"), [(kind, str(found.subagents), str(found.report), str(found.searches)) for kind, found in sorted(figures.reports.items())]), - "## Escalations by trigger", - table(("Trigger", "Subagents"), [(trigger, str(times)) for trigger, times in sorted(figures.escalated.items(), key=lambda item: int(item[0]))]), *(["## Chunks skipped, unreadable", "".join(f"- {folder}\n" for folder in figures.skipped).rstrip("\n")] if figures.skipped else []), ] return "\n\n".join(sections) + "\n" +def escalated(chunks: list[ChunkFigures]) -> str: + """The chunks' escalations as `trigger 2: 3, trigger 3: 1`.""" + return ", ".join(f"trigger {trigger}: {times}" for trigger, times in sorted(sum((chunk.escalated for chunk in chunks), collections.Counter()).items())) + + def table(header: tuple[str, ...], rows: list[tuple[str, ...]]) -> str: if not rows: return "None." diff --git a/bin/routing_figures/test_routing_figures.py b/bin/routing_figures/test_routing_figures.py index be7d6bf9..77a429ad 100644 --- a/bin/routing_figures/test_routing_figures.py +++ b/bin/routing_figures/test_routing_figures.py @@ -77,7 +77,7 @@ class Measured(unittest.TestCase): message("m1", "2026-10-14T10:00:00Z", call("Agent", "a1", prompt="Escalation trigger 2: the test failed twice"), call("Agent", "a2", prompt="Escalation trigger 2: again"), call("Agent", "a3", prompt="Escalation trigger 3: a ๐Ÿ”ด in round 2")), message("m2", "2026-10-14T10:01:00Z", call("Agent", "a4", prompt="Find the callers. Escalation trigger 1: not at the start"), call("Agent", "a5", prompt="Escalation trigger x: no number")), ] - self.assertEqual(measured(Chunk("log", [], worker, []), "/h").escalated, {"2": 2, "3": 1}) + self.assertEqual(measured(Chunk("log", [], worker, []), "/h").escalated, {2: 2, 3: 1}) def test_counts_review_rounds_past_each_passs_first_once_per_title(self): commit = lambda id_, title: message(id_, "2026-10-14T10:00:00Z", call("Bash", command=f"git commit -m '{title}'")) @@ -151,12 +151,11 @@ class Calls(unittest.TestCase): self.assertIn("Measured 2026-10-15T00:00:00Z, at cycle 40 across loop-claude's archive, from 1 finished chunk.", text) self.assertIn("## Calls for a routing change\n\n- Call.\n", text) self.assertIn("| b | 20 |\n| a | 2 |", text) - self.assertIn(f"| {LOW} | 1 | 1.0 | 0.0 | {HIGH} 2 |", text) + self.assertIn(f"| {LOW} | 1 | 1.0 | 0.0 | {HIGH} 2 | |", text) two = ChunkFigures({}, HIGH, 0, 1, collections.Counter({str(HIGH): 2, str(LOW): 1}), {}, collections.Counter()) - self.assertIn(f"| {LOW} | 1 | 1.0 | 0.0 | {HIGH} 2 |\n| {HIGH} | 1 | 0.0 | 1.0 | {HIGH} 2, {LOW} 1 |", render(totals([two, chunk]), [], "2026-10-15T00:00:00Z", 40, "")) + self.assertIn(f"| {LOW} | 1 | 1.0 | 0.0 | {HIGH} 2 | |\n| {HIGH} | 1 | 0.0 | 1.0 | {HIGH} 2, {LOW} 1 | |", render(totals([two, chunk]), [], "2026-10-15T00:00:00Z", 40, "")) self.assertIn("| Explore | 2 | 3 | 4 |", text) - self.assertIn("## Escalations by trigger\n\n| Trigger | Subagents |\n| --- | --- |\n| 2 | 3 |\n| 3 | 1 |\n", render(totals([figures(escalated={"2": 2}), figures(escalated={"2": 1, "3": 1})]), [], "2026-10-15T00:00:00Z", 40, "")) - self.assertIn("## Escalations by trigger\n\nNone.\n", text) + self.assertIn(f"| {LOW} | 2 | 0.0 | 0.0 | | trigger 2: 3, trigger 10: 1 |", render(totals([figures(escalated={2: 2}), figures(escalated={2: 1, 10: 1})]), [], "2026-10-15T00:00:00Z", 40, "")) self.assertIn("## Calls for a routing change\n\nNone.\n", render(totals([]), [], "2026-10-15T00:00:00Z", 20, "")) self.assertIn("from 0 finished chunks that finished after the reset of 2026-10-14T00:00:00Z.", render(totals([]), [], "2026-10-15T00:00:00Z", 20, "2026-10-14T00:00:00Z")) diff --git a/docs/decisions.md b/docs/decisions.md index 9fd83041..ca84275f 100644 --- a/docs/decisions.md +++ b/docs/decisions.md @@ -198,9 +198,9 @@ Valid while the index ranks these models, and while no newer model joins the cat 2026-10-15, lilleman asked for it. Serves goals 1.1 and 1.4: a task too hard for a cheap rung gets a dearer one only once it proves hard, and only for the part that proved hard. -Three triggers in `CLAUDE.md` โ†’ "Working with the codebase" mark a task too hard: a re-score of the item on the project's rung or above picks a higher rung, the same failing test or finding survives two fix attempts, or a pass reports a ๐Ÿ”ด in round 2 or later. When one fires, the worker hands the hard part to a subagent one rung above its own, edits included, though the delegation rule keeps edits in the worker's thread: the escalation exists because the worker could not get them right. Each further trigger on that task climbs one more rung. Without lilleman's yes the climb stops two rungs above the rung the chunk's item picks, the rung the chunk started on, or the project's rung for a chunk no item routed. A step-up between cycles raises the worker but not that limit, so the worker never escalates past what its item was judged to need by more than two rungs (goal 1.4). +Three triggers in `CLAUDE.md` โ†’ "Working with the codebase" mark a task too hard: a re-score of the item on the project's rung or above picks a higher rung, the same failing test or finding survives two fix attempts, or a pass reports a ๐Ÿ”ด in round 2 or later. When one fires, the worker hands the hard part to a subagent one rung above its own, edits included, though the delegation rule keeps edits in the worker's thread: the escalation exists because the worker could not get them right. Each further trigger on that task climbs one more rung. Without lilleman's yes the climb stops two rungs above the rung the chunk's item picks, the rung the chunk started on, or the project's rung for a chunk no item routed. A step-up between cycles raises the worker but not that limit: lilleman set the limit from the rung the chunk started on, so a worker that has stepped up may need a yes for its first escalation. -loop-claude's prompt names the rungs a trigger opens, so the worker computes no rung positions. Its `ESCALATION_CAP` in `bin/loop_claude/cycle/prompts.py` holds the two. The worker opens each escalated subagent's prompt with `Escalation trigger :`. The archive keeps the raw transcript, which holds that prompt, and `bin/routing_figures/` counts the escalations by trigger in `routing-figures.md`. +loop-claude's prompt names the rungs a trigger opens, so the worker computes no rung positions, and tells the worker to open each escalated subagent's prompt with `Escalation trigger :`. `bin/loop_claude/routing.py` holds the limit and that marker. The archive keeps the raw transcript, which holds the marked prompt, and `bin/routing_figures/` counts the escalations by trigger for each rung routed chunks started on, in `routing-figures.md`. Valid while the ladder orders its rungs by competence. diff --git a/todo.md b/todo.md index dc670745..9b01fa40 100644 --- a/todo.md +++ b/todo.md @@ -91,7 +91,7 @@ Release 0.2.0 takes items 125, 114 and 124 first, whatever their scores: Shape i The human asked for this on 2026-10-15, and for the worker to escalate too. A reviewer rules the work below standard when it reports an architect BLOCK or a finding against `skills/larv-review/standards/quality.md`. It may then ask for its pass to rerun one rung up, and that rerun counts toward no round cap. A comprehension seat rules it below standard when it votes "worse" in a paired ruling. It may then ask for the ruling to rerun with its seat one rung up. Either ruling becomes a fourth escalation trigger in `CLAUDE.md` โ†’ "Working with the codebase". No ruling raises the judge's own rung. -This revises `docs/decisions.md` โ†’ `routing: one ladder`, which launches the reviewers on the project's rung while the worker runs below it, and on the worker's rung otherwise. It also revises `review: a pass gets at most three rounds per chunk`. The comprehension seats found larv-review ยง3's "Round cap" hard to read; word the exception so "Round cap" gets easier to read, or land it in item 120's table. +This revises `docs/decisions.md` โ†’ `routing: one ladder`, which launches the reviewers on the project's rung while the worker runs below it, and on the worker's rung otherwise. It also revises `review: a pass gets at most three rounds per chunk`. Which rung a subagent gets is spread over three rules in `CLAUDE.md` โ†’ "Working with the codebase" (delegation, planning subagents and reviewers, escalation) and `bin/loop_claude/cycle/prompts.py`'s `off_the_projects_rung` and `escalation`; fold the `CLAUDE.md` rules into one ordered rule as this item adds its trigger. The comprehension seats found larv-review ยง3's "Round cap" hard to read; word the exception so "Round cap" gets easier to read, or land it in item 120's table. ### 145. Run the stability reviewer on the worker's rung while the worker runs below the project's rung, once a replay of past stability rounds on that rung finds the ๐Ÿ”ด and ๐ŸŸก findings on record. From d7193f65da780cc0dd6a4bbcd97b597c9953df14 Mon Sep 17 00:00:00 2001 From: Lilleman auf Larv Date: Thu, 15 Oct 2026 16:28:11 +0200 Subject: [PATCH 18/26] =?UTF-8?q?Answer=20stability=20round=201:=201=20?= =?UTF-8?q?=F0=9F=94=B4,=206=20=F0=9F=9F=A1;=20keep=20the=20marker=20in=20?= =?UTF-8?q?model=5Frouting=20so=20routing=5Ffigures=20imports=20nothing=20?= =?UTF-8?q?of=20loop=5Fclaude,=20total=20escalations=20across=20every=20ch?= =?UTF-8?q?unk,=20fold=20CLAUDE.md's=20subagent=20rung=20rules=20into=20on?= =?UTF-8?q?e=20ordered=20rule?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CLAUDE.md | 10 ++++++-- bin/loop_claude/cycle/prompts.py | 16 ++++++------- bin/loop_claude/routing.py | 3 +-- bin/loop_claude/test_loop_claude.py | 3 ++- bin/model_routing/route.py | 2 ++ bin/routing_figures/measure.py | 26 ++++++++++++++------- bin/routing_figures/test_routing_figures.py | 4 +++- docs/decisions.md | 2 +- todo.md | 2 +- 9 files changed, 44 insertions(+), 24 deletions(-) diff --git a/CLAUDE.md b/CLAUDE.md index f0fb5e33..5ee8cb6e 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -52,13 +52,19 @@ 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 model. A subagent that files or scores `todo.md` items takes the rung `~/.claude/bin/subagent-rung --plan ` prints, which is never below the project's. +- 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. Launch the subagent with the model and effort of the first case that fits: + 1. A reviewer, a comprehension seat or the security pass: those loop-claude's prompt gives it. Given none, pass no model or effort, so it runs on your model. + 2. An escalated task, below: the rung loop-claude's prompt names for escalation. + 3. A subagent that files or scores `todo.md` items: what `~/.claude/bin/subagent-rung --plan ` prints, which is never below the project's rung. + 4. Any other: what `~/.claude/bin/subagent-rung ` prints. + + Score the task's R and C as for a `todo.md` item. `` 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. - Escalate a task that proves too hard for your rung. Three triggers say so: 1. A re-score of the item, made on the project's rung or above, picks a rung above yours. 2. The same failing test or finding survives two fix attempts. 3. A pass reports a ๐Ÿ”ด in round 2 or later. - When one fires, hand the hard part, edits included, to a subagent on the rung loop-claude's prompt names, one above yours. Cite the trigger and its evidence in the subagent's prompt, in the words loop-claude's prompt gives. Each later subagent on that task runs on that rung or higher, and each further trigger moves it one rung up, to at most the highest rung the prompt names. Ask the human before going higher, or when no prompt names a rung. + When one fires, hand the hard part, edits included, to a subagent on the rung loop-claude's prompt names, one above yours. Cite the trigger and its evidence in the subagent's prompt, in the words loop-claude's prompt gives. Each later subagent on that task runs on that rung or higher, and each further trigger moves it one rung up, to at most the highest rung the prompt names. Ask the human before going higher. Where loop-claude's prompt names no escalation, as on the ladder's top rung or off it, keep the task in your own thread. - 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/bin/loop_claude/cycle/prompts.py b/bin/loop_claude/cycle/prompts.py index 05cbbfff..718739bd 100644 --- a/bin/loop_claude/cycle/prompts.py +++ b/bin/loop_claude/cycle/prompts.py @@ -1,8 +1,8 @@ -from loop_claude.routing import ESCALATION_MARKER, escalation_rungs -from model_routing.ladder import highest, LADDER, Rung +from model_routing.ladder import climbed, highest, LADDER, Rung +from model_routing.route import ESCALATION_MARKER, Route +from loop_claude.routing import escalation_rungs from loop_claude.project.records import HUMAN_RULE_NAMES, RECORD_FILES from markdown_text import quoted -from model_routing.route import Route def either(names: tuple[str, ...]) -> str: """The names as `a, b or c`.""" @@ -17,8 +17,8 @@ ANSWERS_RECORDED = f"every answer the human typed in it that a later chunk could def fresh(task: str, premises: str, route: Route, anchor: Rung | None) -> str: - # A chunk no item routed gets no route paragraph, but may still escalate. - routed = f"{routed_by(route, anchor)}\n\n" if route.item else "".join(f"{text.lstrip()}\n\n" for text in [escalation(route, anchor)] if text) + escalated = escalation(route, anchor).lstrip() + routed = f"{routed_by(route, anchor)}\n\n" if route.item else (f"{escalated}\n\n" if escalated 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}" @@ -27,7 +27,7 @@ def routed_by(route: Route, anchor: Rung | None) -> str: def off_the_projects_rung(route: Route, anchor: Rung | None) -> str: - """Which subagents to launch on the project's rung, anchor, and below it which on the --plan rung; empty while the worker runs on anchor, as every chunk no item routed starts (routing.first_route).""" + """Which subagents to launch on the project's rung, anchor, and below it which on the --plan rung; empty while the worker runs on anchor, as every chunk no item routed does until it steps up.""" if anchor is None or route.rung == anchor: return "" # 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. @@ -38,13 +38,13 @@ def off_the_projects_rung(route: Route, anchor: Rung | None) -> str: def escalation(route: Route, anchor: Rung | None) -> str: - """The rungs routing.escalation_rungs opens to the worker, and how to mark an escalated subagent's prompt; empty off the ladder or on its top rung.""" + """The rungs an escalation trigger opens to the worker, from one above its own up to two above the rung its chunk started on, and how to mark an escalated subagent's prompt; empty off the ladder or on its top rung.""" if anchor is None or route.rung not in LADDER[:-1]: return "" marked = f" Open the subagent's prompt with `{ESCALATION_MARKER} :`, n the trigger's number." rungs = [f"`{rung.agent_args()}`" for rung in escalation_rungs(anchor, route)] if not rungs: - return f" An escalation trigger in `~/.claude/CLAUDE.md` lets you hand a task to a subagent above your rung only once the human agrees.{marked}" + return f" An escalation trigger in `~/.claude/CLAUDE.md` lets you hand a task to a subagent with the Agent tool set to `{climbed(route.rung, 1).agent_args()}`, one rung above yours, only once the human agrees.{marked}" further = f", and on each further trigger one rung higher, up to {rungs[-1]}" if len(rungs) > 1 else "" return f" When an escalation trigger in `~/.claude/CLAUDE.md` fires, hand the task to a subagent with the Agent tool set to {rungs[0]}, one rung above yours{further}; above that, ask the human first.{marked}" diff --git a/bin/loop_claude/routing.py b/bin/loop_claude/routing.py index 4ee3d353..657511b2 100644 --- a/bin/loop_claude/routing.py +++ b/bin/loop_claude/routing.py @@ -7,9 +7,8 @@ from todo_table import Item, items from model_routing.route import Route UNFINISHED_PER_STEP = 2 -# How many rungs above item_rung the worker may escalate a task without the human's yes, and how it opens an escalated subagent's prompt: docs/decisions.md โ†’ `routing: a worker hands a task one rung up`. +# How many rungs above item_rung the worker may escalate a task without the human's yes: docs/decisions.md โ†’ `routing: a worker hands a task one rung up`. ESCALATION_CAP = 2 -ESCALATION_MARKER = "Escalation trigger" # The models `judge-replay` found returning, on their cheapest rung, every verdict the reference judge reproduced: docs/decisions.md โ†’ `routing: on a model judge-replay covered`. JUDGE_REPLAYED = ("claude-opus-5-5",) diff --git a/bin/loop_claude/test_loop_claude.py b/bin/loop_claude/test_loop_claude.py index 5c537a3e..5198155f 100644 --- a/bin/loop_claude/test_loop_claude.py +++ b/bin/loop_claude/test_loop_claude.py @@ -662,8 +662,9 @@ class WorkerArgs(unittest.TestCase): fresh = prompts.fresh("Do it.", "## Goals", Route(opus, 3, 9), opus) self.assertIn("whether or not it is item 3. When an escalation trigger in `~/.claude/CLAUDE.md` fires, hand the task to a subagent with the Agent tool set to `model opus, effort high`, one rung above yours, and on each further trigger one rung higher, up to `model opus, effort xhigh`; above that, ask the human first. Open the subagent's prompt with `Escalation trigger :`, n the trigger's number.\n\n", fresh) self.assertTrue(prompts.resumed("", Route(Rung("claude-opus-5-5", "high"), 3, 9), opus).endswith(" When an escalation trigger in `~/.claude/CLAUDE.md` fires, hand the task to a subagent with the Agent tool set to `model opus, effort xhigh`, one rung above yours; above that, ask the human first. Open the subagent's prompt with `Escalation trigger :`, n the trigger's number.")) - self.assertTrue(prompts.resumed("", Route(Rung("claude-opus-5-5", "xhigh"), 3, 9), opus).endswith(" An escalation trigger in `~/.claude/CLAUDE.md` lets you hand a task to a subagent above your rung only once the human agrees. Open the subagent's prompt with `Escalation trigger :`, n the trigger's number.")) + self.assertTrue(prompts.resumed("", Route(Rung("claude-opus-5-5", "xhigh"), 3, 9), opus).endswith(" An escalation trigger in `~/.claude/CLAUDE.md` lets you hand a task to a subagent with the Agent tool set to `model opus, effort max`, one rung above yours, only once the human agrees. Open the subagent's prompt with `Escalation trigger :`, n the trigger's number.")) self.assertNotIn("escalation", prompts.resumed("", Route(Rung("claude-fable-5-1", "max"), 3, 20), opus)) + self.assertIn("hand the task to a subagent with the Agent tool set to `model fable, effort max`, one rung above yours;", prompts.resumed("", Route(Rung("claude-opus-5-5", "max"), 3, 13), opus)) self.assertNotIn("escalation", prompts.resumed("", Route(Rung("m")), None)) self.assertNotIn("escalation", prompts.resumed("", Route(Rung("claude-opus-5-5", "low"), 3, 9), opus)) self.assertIn("before creating a new one.\n\nWhen an escalation trigger in `~/.claude/CLAUDE.md` fires, hand the task to a subagent with the Agent tool set to `model opus, effort high`, one rung above yours, and on each further trigger one rung higher, up to `model opus, effort xhigh`; above that, ask the human first. Open the subagent's prompt with `Escalation trigger :`, n the trigger's number.\n\nThe chunk's", prompts.fresh("Do it.", "## Goals", Route(opus), opus)) diff --git a/bin/model_routing/route.py b/bin/model_routing/route.py index a4677520..ad626fa7 100644 --- a/bin/model_routing/route.py +++ b/bin/model_routing/route.py @@ -4,6 +4,8 @@ import re from model_routing.ladder import Rung +# How a worker opens the prompt of a subagent it escalates a task to, `Escalation trigger 2: โ€ฆ`: docs/decisions.md โ†’ `routing: a worker hands a task one rung up`. +ESCALATION_MARKER = "Escalation trigger" ROUTED = re.compile(r"(?P\S+) at (?P\S+) effort(?:, routed by item (?P[0-9]+)'s R \+ C of (?P[0-9]+))?") diff --git a/bin/routing_figures/measure.py b/bin/routing_figures/measure.py index 315a0673..233e5f04 100644 --- a/bin/routing_figures/measure.py +++ b/bin/routing_figures/measure.py @@ -7,10 +7,9 @@ import typing from claude_code.entries import assistant_parts, parts, tool_call, usage_count from git_command import commits -from loop_claude.routing import ESCALATION_MARKER +from model_routing.route import ESCALATION_MARKER, route_from from model_routing.ladder import position, Rung from round_titles import round_counts -from model_routing.route import route_from from shell_command import simple_commands from transcript_archive.outcomes import UNFINISHED_AT, workers @@ -66,11 +65,12 @@ class ChunkFigures: @dataclasses.dataclass(frozen=True) class Figures: - """skipped names each chunk folder the archive could not read whole.""" + """escalated counts every chunk's escalations by trigger, routed or not; skipped names each chunk folder the archive could not read whole.""" chunks: int tokens: dict[str, collections.Counter[str]] routed: dict[Rung, list[ChunkFigures]] reports: dict[str, Reports] + escalated: collections.Counter[int] skipped: tuple[str, ...] = () @@ -204,7 +204,7 @@ def totals(chunks: list[ChunkFigures], skipped: tuple[str, ...] = ()) -> Figures routed.setdefault(chunk.start, []).append(chunk) for kind, found in chunk.reports.items(): reports[kind] = reports.get(kind, Reports(0, 0, 0)) + found - return Figures(len(chunks), tokens, routed, reports, skipped) + return Figures(len(chunks), tokens, routed, reports, summed(chunks, lambda chunk: chunk.escalated), skipped) def calls(figures: Figures) -> list[str]: @@ -234,9 +234,10 @@ def render(figures: Figures, found: list[str], at: str, cycle: int, since: str) *[part for dimension in DIMENSIONS for part in (f"## Tokens by {dimension}", table((dimension.capitalize(), "Tokens"), [(label, str(tokens)) for label, tokens in figures.tokens[dimension].most_common()]))], "## Routed chunks by the rung they started on", table(("Rung", "Chunks", "Review rounds past each pass's first, mean", "Unfinished verdicts, mean", "Subagent rungs", "Escalations by trigger"), [ - (str(rung), str(len(chunks)), f"{mean(chunks, lambda chunk: chunk.rounds_past_first):.1f}", f"{mean(chunks, lambda chunk: chunk.unfinished):.1f}", ", ".join(f"{label} {times}" for label, times in sum((chunk.delegated for chunk in chunks), collections.Counter()).most_common()), escalated(chunks)) + (str(rung), str(len(chunks)), f"{mean(chunks, lambda chunk: chunk.rounds_past_first):.1f}", f"{mean(chunks, lambda chunk: chunk.unfinished):.1f}", subagent_rungs(chunks), triggers(summed(chunks, lambda chunk: chunk.escalated))) for rung, chunks in sorted(figures.routed.items(), key=lambda item: position(item[0])) ]), + f"Escalations by trigger across every chunk, routed or not: {triggers(figures.escalated) or 'none'}.", "## Subagent reports against the searches they ran, in characters", table(("Subagent type", "Subagents", "Reports", "Searches"), [(kind, str(found.subagents), str(found.report), str(found.searches)) for kind, found in sorted(figures.reports.items())]), *(["## Chunks skipped, unreadable", "".join(f"- {folder}\n" for folder in figures.skipped).rstrip("\n")] if figures.skipped else []), @@ -244,9 +245,18 @@ def render(figures: Figures, found: list[str], at: str, cycle: int, since: str) return "\n\n".join(sections) + "\n" -def escalated(chunks: list[ChunkFigures]) -> str: - """The chunks' escalations as `trigger 2: 3, trigger 3: 1`.""" - return ", ".join(f"trigger {trigger}: {times}" for trigger, times in sorted(sum((chunk.escalated for chunk in chunks), collections.Counter()).items())) +def summed(chunks: list[ChunkFigures], of: typing.Callable[[ChunkFigures], collections.Counter]) -> collections.Counter: + return sum(map(of, chunks), collections.Counter()) + + +def subagent_rungs(chunks: list[ChunkFigures]) -> str: + """The rungs the chunks' subagents ran on, most used first, as `claude-opus-5-5 at high effort 2, โ€ฆ`.""" + return ", ".join(f"{label} {times}" for label, times in summed(chunks, lambda chunk: chunk.delegated).most_common()) + + +def triggers(escalated: collections.Counter[int]) -> str: + """Escalations as `trigger 2: 3, trigger 3: 1`.""" + return ", ".join(f"trigger {trigger}: {times}" for trigger, times in sorted(escalated.items())) def table(header: tuple[str, ...], rows: list[tuple[str, ...]]) -> str: diff --git a/bin/routing_figures/test_routing_figures.py b/bin/routing_figures/test_routing_figures.py index 77a429ad..16e0a55a 100644 --- a/bin/routing_figures/test_routing_figures.py +++ b/bin/routing_figures/test_routing_figures.py @@ -155,7 +155,9 @@ class Calls(unittest.TestCase): two = ChunkFigures({}, HIGH, 0, 1, collections.Counter({str(HIGH): 2, str(LOW): 1}), {}, collections.Counter()) self.assertIn(f"| {LOW} | 1 | 1.0 | 0.0 | {HIGH} 2 | |\n| {HIGH} | 1 | 0.0 | 1.0 | {HIGH} 2, {LOW} 1 | |", render(totals([two, chunk]), [], "2026-10-15T00:00:00Z", 40, "")) self.assertIn("| Explore | 2 | 3 | 4 |", text) - self.assertIn(f"| {LOW} | 2 | 0.0 | 0.0 | | trigger 2: 3, trigger 10: 1 |", render(totals([figures(escalated={2: 2}), figures(escalated={2: 1, 10: 1})]), [], "2026-10-15T00:00:00Z", 40, "")) + escalated = render(totals([figures(escalated={2: 2}), figures(escalated={2: 1, 10: 1}), figures(start=None, escalated={3: 1})]), [], "2026-10-15T00:00:00Z", 40, "") + self.assertIn(f"| {LOW} | 2 | 0.0 | 0.0 | | trigger 2: 3, trigger 10: 1 |\n\nEscalations by trigger across every chunk, routed or not: trigger 2: 3, trigger 3: 1, trigger 10: 1.\n", escalated) + self.assertIn("Escalations by trigger across every chunk, routed or not: none.\n", text) self.assertIn("## Calls for a routing change\n\nNone.\n", render(totals([]), [], "2026-10-15T00:00:00Z", 20, "")) self.assertIn("from 0 finished chunks that finished after the reset of 2026-10-14T00:00:00Z.", render(totals([]), [], "2026-10-15T00:00:00Z", 20, "2026-10-14T00:00:00Z")) diff --git a/docs/decisions.md b/docs/decisions.md index ca84275f..32d8b7ab 100644 --- a/docs/decisions.md +++ b/docs/decisions.md @@ -200,7 +200,7 @@ Valid while the index ranks these models, and while no newer model joins the cat Three triggers in `CLAUDE.md` โ†’ "Working with the codebase" mark a task too hard: a re-score of the item on the project's rung or above picks a higher rung, the same failing test or finding survives two fix attempts, or a pass reports a ๐Ÿ”ด in round 2 or later. When one fires, the worker hands the hard part to a subagent one rung above its own, edits included, though the delegation rule keeps edits in the worker's thread: the escalation exists because the worker could not get them right. Each further trigger on that task climbs one more rung. Without lilleman's yes the climb stops two rungs above the rung the chunk's item picks, the rung the chunk started on, or the project's rung for a chunk no item routed. A step-up between cycles raises the worker but not that limit: lilleman set the limit from the rung the chunk started on, so a worker that has stepped up may need a yes for its first escalation. -loop-claude's prompt names the rungs a trigger opens, so the worker computes no rung positions, and tells the worker to open each escalated subagent's prompt with `Escalation trigger :`. `bin/loop_claude/routing.py` holds the limit and that marker. The archive keeps the raw transcript, which holds the marked prompt, and `bin/routing_figures/` counts the escalations by trigger for each rung routed chunks started on, in `routing-figures.md`. +loop-claude's prompt names the rungs a trigger opens, so the worker computes no rung positions, and tells the worker to open each escalated subagent's prompt with `Escalation trigger :`. `bin/loop_claude/routing.py` holds the limit, and `bin/model_routing/route.py` the marker, beside the other words the archive records, since both loop-claude and `bin/routing_figures/` read it. The archive keeps the raw transcript, which holds the marked prompt, and `bin/routing_figures/` counts the escalations by trigger for each rung routed chunks started on, in `routing-figures.md`. Valid while the ladder orders its rungs by competence. diff --git a/todo.md b/todo.md index 9b01fa40..dc670745 100644 --- a/todo.md +++ b/todo.md @@ -91,7 +91,7 @@ Release 0.2.0 takes items 125, 114 and 124 first, whatever their scores: Shape i The human asked for this on 2026-10-15, and for the worker to escalate too. A reviewer rules the work below standard when it reports an architect BLOCK or a finding against `skills/larv-review/standards/quality.md`. It may then ask for its pass to rerun one rung up, and that rerun counts toward no round cap. A comprehension seat rules it below standard when it votes "worse" in a paired ruling. It may then ask for the ruling to rerun with its seat one rung up. Either ruling becomes a fourth escalation trigger in `CLAUDE.md` โ†’ "Working with the codebase". No ruling raises the judge's own rung. -This revises `docs/decisions.md` โ†’ `routing: one ladder`, which launches the reviewers on the project's rung while the worker runs below it, and on the worker's rung otherwise. It also revises `review: a pass gets at most three rounds per chunk`. Which rung a subagent gets is spread over three rules in `CLAUDE.md` โ†’ "Working with the codebase" (delegation, planning subagents and reviewers, escalation) and `bin/loop_claude/cycle/prompts.py`'s `off_the_projects_rung` and `escalation`; fold the `CLAUDE.md` rules into one ordered rule as this item adds its trigger. The comprehension seats found larv-review ยง3's "Round cap" hard to read; word the exception so "Round cap" gets easier to read, or land it in item 120's table. +This revises `docs/decisions.md` โ†’ `routing: one ladder`, which launches the reviewers on the project's rung while the worker runs below it, and on the worker's rung otherwise. It also revises `review: a pass gets at most three rounds per chunk`. The comprehension seats found larv-review ยง3's "Round cap" hard to read; word the exception so "Round cap" gets easier to read, or land it in item 120's table. ### 145. Run the stability reviewer on the worker's rung while the worker runs below the project's rung, once a replay of past stability rounds on that rung finds the ๐Ÿ”ด and ๐ŸŸก findings on record. From 25f224a743c545b10c09c4a6454fa6dfcdefcb11 Mon Sep 17 00:00:00 2001 From: Lilleman auf Larv Date: Thu, 15 Oct 2026 16:28:11 +0200 Subject: [PATCH 19/26] =?UTF-8?q?Answer=20architecture=20round=202:=200=20?= =?UTF-8?q?=F0=9F=94=B4,=202=20=F0=9F=9F=A1;=20the=20uncounted=20escalatio?= =?UTF-8?q?ns=20of=20unrouted=20chunks,=20answered=20in=20stability=20roun?= =?UTF-8?q?d=201?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit From 29c538947bb9b62802f1def771e02f785af560c4 Mon Sep 17 00:00:00 2001 From: Lilleman auf Larv Date: Thu, 15 Oct 2026 16:28:11 +0200 Subject: [PATCH 20/26] =?UTF-8?q?Answer=20security=20round=201:=200=20?= =?UTF-8?q?=F0=9F=94=B4,=200=20=F0=9F=9F=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit From 1550c81917b25eec80df92b365f7c5d8bbb2f980 Mon Sep 17 00:00:00 2001 From: Lilleman auf Larv Date: Thu, 15 Oct 2026 16:28:11 +0200 Subject: [PATCH 21/26] =?UTF-8?q?Answer=20product-owner=20round=201:=200?= =?UTF-8?q?=20=F0=9F=94=B4,=200=20=F0=9F=9F=A1;=20name=20the=20rung=20a=20?= =?UTF-8?q?yes=20opens=20at=20the=20limit,=20keep=20the=20task=20when=20no?= =?UTF-8?q?=20escalation=20is=20named?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit From 827eeb1889d1ebe291298590c9d3f00c9a1aaf88 Mon Sep 17 00:00:00 2001 From: Lilleman auf Larv Date: Thu, 15 Oct 2026 16:34:47 +0200 Subject: [PATCH 22/26] =?UTF-8?q?Answer=20stability=20round=202:=200=20?= =?UTF-8?q?=F0=9F=94=B4,=201=20=F0=9F=9F=A1;=20an=20escalated=20subagent?= =?UTF-8?q?=20that=20files=20or=20scores=20todo.md=20items=20takes=20the?= =?UTF-8?q?=20--plan=20rung=20where=20higher,=20with=20prose=20round=201's?= =?UTF-8?q?=20fixes?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- AGENTS.md | 2 +- CHANGELOG.md | 2 +- CLAUDE.md | 10 ++++------ bin/loop_claude/cycle/prompts.py | 6 +++--- bin/loop_claude/test_loop_claude.py | 10 +++++----- bin/routing_figures/measure.py | 5 +++-- bin/routing_figures/test_routing_figures.py | 5 +++-- docs/decisions.md | 8 ++++---- 8 files changed, 24 insertions(+), 24 deletions(-) diff --git a/AGENTS.md b/AGENTS.md index 1c986e34..d5d465c8 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -35,7 +35,7 @@ Decisions live in `docs/decisions.md`: - 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 may run below that rung, launching its reviewers on that rung; the worker routes each subagent it delegates to by the R + C of the subagent's task -- routing: a worker hands a task one rung up on each escalation trigger, to at most two rungs above the rung its item picks without the human's yes, and opens the subagent's prompt with the trigger so the routing figures count it +- routing: a worker hands a task one rung up on each escalation trigger, up to two rungs above the rung its item picks unless the human agrees, and opens the subagent's prompt with the trigger so the routing figures count it - routing: on a model judge-replay covered, the judge runs on the rung its chunk's item picks, never below the project's rung ## Working rules diff --git a/CHANGELOG.md b/CHANGELOG.md index fe7514cd..758e2573 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,7 +2,7 @@ ## Unreleased -- A session hands a task that proves too hard for its rung to a subagent one rung up, edits included, when a trigger fires: a re-score of the item on the project's rung or above picks a higher rung, the same failing test or finding survives two fix attempts, or a review pass reports a ๐Ÿ”ด in round 2 or later. Each further trigger climbs one more rung, to at most two rungs above the rung the chunk's `todo.md` item picks, unless you agree. `CLAUDE.md` states the rule, and `loop-claude`'s prompt names the rungs a trigger opens. The worker opens the subagent's prompt with `Escalation trigger :`, and `routing-figures.md` counts the escalations by trigger. Expect a chunk that gets stuck to spend more on the stuck part, and fewer unfinished verdicts. +- A `loop-claude` worker hands a task that proves too hard for its rung to a subagent one rung up, edits included, when a trigger fires: a re-score of the item on the project's rung or above picks a higher rung, the same failing test or finding survives two fix attempts, or a review pass reports a ๐Ÿ”ด in round 2 or later. Each further trigger climbs one more rung, to at most two rungs above the rung the chunk's `todo.md` item picks, unless you agree. `CLAUDE.md` states the rule, and `loop-claude`'s prompt names the rungs a trigger opens. The worker opens the subagent's prompt with `Escalation trigger :`, and `routing-figures.md` counts the escalations by trigger. Expect a chunk that gets stuck to spend more on the stuck part, and fewer unfinished verdicts. - 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 or above applies and scores the drafts and sets their release. It may still remove finished items. `rules/todo-items.md` states the rule. `CLAUDE.md` has a session launch a subagent that files or scores items on the rung the new `bin/subagent-rung --plan ` prints, never below the project's rung, and `loop-claude`'s prompt to a worker below that rung names the command. 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. diff --git a/CLAUDE.md b/CLAUDE.md index 5ee8cb6e..f24d586e 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -52,19 +52,17 @@ 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. Launch the subagent with the model and effort of the first case that fits: +- 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. `` below 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. Launch the subagent with the model and effort of the first case that fits: 1. A reviewer, a comprehension seat or the security pass: those loop-claude's prompt gives it. Given none, pass no model or effort, so it runs on your model. - 2. An escalated task, below: the rung loop-claude's prompt names for escalation. + 2. An escalated task, below: the rung loop-claude's prompt names for escalation, or case 3's rung where the subagent files or scores `todo.md` items and that rung is higher. 3. A subagent that files or scores `todo.md` items: what `~/.claude/bin/subagent-rung --plan ` prints, which is never below the project's rung. 4. Any other: what `~/.claude/bin/subagent-rung ` prints. - - Score the task's R and C as for a `todo.md` item. `` 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. -- Escalate a task that proves too hard for your rung. Three triggers say so: +- Escalate a task that proves too hard for your rung. Three escalation triggers say so: 1. A re-score of the item, made on the project's rung or above, picks a rung above yours. 2. The same failing test or finding survives two fix attempts. 3. A pass reports a ๐Ÿ”ด in round 2 or later. - When one fires, hand the hard part, edits included, to a subagent on the rung loop-claude's prompt names, one above yours. Cite the trigger and its evidence in the subagent's prompt, in the words loop-claude's prompt gives. Each later subagent on that task runs on that rung or higher, and each further trigger moves it one rung up, to at most the highest rung the prompt names. Ask the human before going higher. Where loop-claude's prompt names no escalation, as on the ladder's top rung or off it, keep the task in your own thread. + When one fires, hand the hard part, edits included, to a subagent on the rung loop-claude's prompt names, one above yours. Open the subagent's prompt with the marker loop-claude's prompt gives, then the trigger's evidence. Each later subagent on that task runs on that rung or higher, and each further escalation trigger moves the task one rung higher, up to the highest rung loop-claude's prompt names. Ask the human before going higher. Where loop-claude's prompt names no escalation, as on the ladder's top rung or off it, keep the task in your own thread. - 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/bin/loop_claude/cycle/prompts.py b/bin/loop_claude/cycle/prompts.py index 718739bd..67548098 100644 --- a/bin/loop_claude/cycle/prompts.py +++ b/bin/loop_claude/cycle/prompts.py @@ -38,15 +38,15 @@ def off_the_projects_rung(route: Route, anchor: Rung | None) -> str: def escalation(route: Route, anchor: Rung | None) -> str: - """The rungs an escalation trigger opens to the worker, from one above its own up to two above the rung its chunk started on, and how to mark an escalated subagent's prompt; empty off the ladder or on its top rung.""" + """The prompt's escalation sentence: the rungs escalation_rungs opens, and the marker; empty off the ladder or on its top rung.""" if anchor is None or route.rung not in LADDER[:-1]: return "" marked = f" Open the subagent's prompt with `{ESCALATION_MARKER} :`, n the trigger's number." rungs = [f"`{rung.agent_args()}`" for rung in escalation_rungs(anchor, route)] if not rungs: - return f" An escalation trigger in `~/.claude/CLAUDE.md` lets you hand a task to a subagent with the Agent tool set to `{climbed(route.rung, 1).agent_args()}`, one rung above yours, only once the human agrees.{marked}" + return f" An escalation trigger in `~/.claude/CLAUDE.md` lets you hand the hard part of a task to a subagent with the Agent tool set to `{climbed(route.rung, 1).agent_args()}`, one rung above yours, only once the human agrees.{marked}" further = f", and on each further trigger one rung higher, up to {rungs[-1]}" if len(rungs) > 1 else "" - return f" When an escalation trigger in `~/.claude/CLAUDE.md` fires, hand the task to a subagent with the Agent tool set to {rungs[0]}, one rung above yours{further}; above that, ask the human first.{marked}" + return f" When an escalation trigger in `~/.claude/CLAUDE.md` fires, hand the hard part of the task to a subagent with the Agent tool set to {rungs[0]}, one rung above yours{further}; above that, ask the human first.{marked}" def resumed(unfinished_evidence: str, route: Route, anchor: Rung | None) -> str: diff --git a/bin/loop_claude/test_loop_claude.py b/bin/loop_claude/test_loop_claude.py index 5198155f..0c15b997 100644 --- a/bin/loop_claude/test_loop_claude.py +++ b/bin/loop_claude/test_loop_claude.py @@ -660,14 +660,14 @@ class WorkerArgs(unittest.TestCase): def test_names_the_rungs_an_escalation_trigger_lets_the_worker_hand_a_task_to_at_most_two_above_its_items(self): opus = Rung("claude-opus-5-5", "medium") fresh = prompts.fresh("Do it.", "## Goals", Route(opus, 3, 9), opus) - self.assertIn("whether or not it is item 3. When an escalation trigger in `~/.claude/CLAUDE.md` fires, hand the task to a subagent with the Agent tool set to `model opus, effort high`, one rung above yours, and on each further trigger one rung higher, up to `model opus, effort xhigh`; above that, ask the human first. Open the subagent's prompt with `Escalation trigger :`, n the trigger's number.\n\n", fresh) - self.assertTrue(prompts.resumed("", Route(Rung("claude-opus-5-5", "high"), 3, 9), opus).endswith(" When an escalation trigger in `~/.claude/CLAUDE.md` fires, hand the task to a subagent with the Agent tool set to `model opus, effort xhigh`, one rung above yours; above that, ask the human first. Open the subagent's prompt with `Escalation trigger :`, n the trigger's number.")) - self.assertTrue(prompts.resumed("", Route(Rung("claude-opus-5-5", "xhigh"), 3, 9), opus).endswith(" An escalation trigger in `~/.claude/CLAUDE.md` lets you hand a task to a subagent with the Agent tool set to `model opus, effort max`, one rung above yours, only once the human agrees. Open the subagent's prompt with `Escalation trigger :`, n the trigger's number.")) + self.assertIn("whether or not it is item 3. When an escalation trigger in `~/.claude/CLAUDE.md` fires, hand the hard part of the task to a subagent with the Agent tool set to `model opus, effort high`, one rung above yours, and on each further trigger one rung higher, up to `model opus, effort xhigh`; above that, ask the human first. Open the subagent's prompt with `Escalation trigger :`, n the trigger's number.\n\n", fresh) + self.assertTrue(prompts.resumed("", Route(Rung("claude-opus-5-5", "high"), 3, 9), opus).endswith(" When an escalation trigger in `~/.claude/CLAUDE.md` fires, hand the hard part of the task to a subagent with the Agent tool set to `model opus, effort xhigh`, one rung above yours; above that, ask the human first. Open the subagent's prompt with `Escalation trigger :`, n the trigger's number.")) + self.assertTrue(prompts.resumed("", Route(Rung("claude-opus-5-5", "xhigh"), 3, 9), opus).endswith(" An escalation trigger in `~/.claude/CLAUDE.md` lets you hand the hard part of a task to a subagent with the Agent tool set to `model opus, effort max`, one rung above yours, only once the human agrees. Open the subagent's prompt with `Escalation trigger :`, n the trigger's number.")) self.assertNotIn("escalation", prompts.resumed("", Route(Rung("claude-fable-5-1", "max"), 3, 20), opus)) - self.assertIn("hand the task to a subagent with the Agent tool set to `model fable, effort max`, one rung above yours;", prompts.resumed("", Route(Rung("claude-opus-5-5", "max"), 3, 13), opus)) + self.assertIn("hand the hard part of the task to a subagent with the Agent tool set to `model fable, effort max`, one rung above yours;", prompts.resumed("", Route(Rung("claude-opus-5-5", "max"), 3, 13), opus)) self.assertNotIn("escalation", prompts.resumed("", Route(Rung("m")), None)) self.assertNotIn("escalation", prompts.resumed("", Route(Rung("claude-opus-5-5", "low"), 3, 9), opus)) - self.assertIn("before creating a new one.\n\nWhen an escalation trigger in `~/.claude/CLAUDE.md` fires, hand the task to a subagent with the Agent tool set to `model opus, effort high`, one rung above yours, and on each further trigger one rung higher, up to `model opus, effort xhigh`; above that, ask the human first. Open the subagent's prompt with `Escalation trigger :`, n the trigger's number.\n\nThe chunk's", prompts.fresh("Do it.", "## Goals", Route(opus), opus)) + self.assertIn("before creating a new one.\n\nWhen an escalation trigger in `~/.claude/CLAUDE.md` fires, hand the hard part of the task to a subagent with the Agent tool set to `model opus, effort high`, one rung above yours, and on each further trigger one rung higher, up to `model opus, effort xhigh`; above that, ask the human first. Open the subagent's prompt with `Escalation trigger :`, n the trigger's number.\n\nThe chunk's", prompts.fresh("Do it.", "## Goals", Route(opus), 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")) diff --git a/bin/routing_figures/measure.py b/bin/routing_figures/measure.py index 233e5f04..c8278260 100644 --- a/bin/routing_figures/measure.py +++ b/bin/routing_figures/measure.py @@ -104,7 +104,7 @@ def measured(chunk: Chunk, home: str) -> ChunkFigures: def escalations(launches: dict[str, tuple[str, dict]]) -> collections.Counter[int]: - """How many Agent calls the worker escalated on each trigger, by the trigger number each call's prompt opens with.""" + """How many of the worker's Agent calls open with each escalation trigger's number.""" opened = (ESCALATION.match(str(arguments.get("prompt") or "")) for _, arguments in launches.values()) return collections.Counter(int(found[1]) for found in opened if found) @@ -237,7 +237,8 @@ def render(figures: Figures, found: list[str], at: str, cycle: int, since: str) (str(rung), str(len(chunks)), f"{mean(chunks, lambda chunk: chunk.rounds_past_first):.1f}", f"{mean(chunks, lambda chunk: chunk.unfinished):.1f}", subagent_rungs(chunks), triggers(summed(chunks, lambda chunk: chunk.escalated))) for rung, chunks in sorted(figures.routed.items(), key=lambda item: position(item[0])) ]), - f"Escalations by trigger across every chunk, routed or not: {triggers(figures.escalated) or 'none'}.", + "## Escalations by trigger across every chunk, routed or not", + f"{triggers(figures.escalated) or 'None'}.", "## Subagent reports against the searches they ran, in characters", table(("Subagent type", "Subagents", "Reports", "Searches"), [(kind, str(found.subagents), str(found.report), str(found.searches)) for kind, found in sorted(figures.reports.items())]), *(["## Chunks skipped, unreadable", "".join(f"- {folder}\n" for folder in figures.skipped).rstrip("\n")] if figures.skipped else []), diff --git a/bin/routing_figures/test_routing_figures.py b/bin/routing_figures/test_routing_figures.py index 16e0a55a..c6ec4f1b 100644 --- a/bin/routing_figures/test_routing_figures.py +++ b/bin/routing_figures/test_routing_figures.py @@ -156,8 +156,9 @@ class Calls(unittest.TestCase): self.assertIn(f"| {LOW} | 1 | 1.0 | 0.0 | {HIGH} 2 | |\n| {HIGH} | 1 | 0.0 | 1.0 | {HIGH} 2, {LOW} 1 | |", render(totals([two, chunk]), [], "2026-10-15T00:00:00Z", 40, "")) self.assertIn("| Explore | 2 | 3 | 4 |", text) escalated = render(totals([figures(escalated={2: 2}), figures(escalated={2: 1, 10: 1}), figures(start=None, escalated={3: 1})]), [], "2026-10-15T00:00:00Z", 40, "") - self.assertIn(f"| {LOW} | 2 | 0.0 | 0.0 | | trigger 2: 3, trigger 10: 1 |\n\nEscalations by trigger across every chunk, routed or not: trigger 2: 3, trigger 3: 1, trigger 10: 1.\n", escalated) - self.assertIn("Escalations by trigger across every chunk, routed or not: none.\n", text) + self.assertIn(f"| {LOW} | 2 | 0.0 | 0.0 | | trigger 2: 3, trigger 10: 1 |", escalated) + self.assertIn("## Escalations by trigger across every chunk, routed or not\n\ntrigger 2: 3, trigger 3: 1, trigger 10: 1.\n", escalated) + self.assertIn("## Escalations by trigger across every chunk, routed or not\n\nNone.\n", text) self.assertIn("## Calls for a routing change\n\nNone.\n", render(totals([]), [], "2026-10-15T00:00:00Z", 20, "")) self.assertIn("from 0 finished chunks that finished after the reset of 2026-10-14T00:00:00Z.", render(totals([]), [], "2026-10-15T00:00:00Z", 20, "2026-10-14T00:00:00Z")) diff --git a/docs/decisions.md b/docs/decisions.md index 32d8b7ab..1ce7e35b 100644 --- a/docs/decisions.md +++ b/docs/decisions.md @@ -188,19 +188,19 @@ The cost of a cheaper worker shows as extra review rounds and unfinished verdict 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, loop-claude's prompt has it launch the comprehension seats and the security pass's subagent on the project's rung too. So the seats score every chunk on one rung, and the security pass spends no more than the project chose. The prompt after each unfinished verdict repeats this, since a step-up may have taken the worker above the project's rung. The other reviewers inherit the worker's higher rung. On 2026-10-15 lilleman dropped routing them by R + C instead: a worker climbs because its chunk proved harder than its score said, which is when a cheaper reviewer is the bigger risk. `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 delegates a task only when it needs just the task's conclusion: a search or read across many files, or work independent enough to run in parallel. Edits, and whatever it must check line by line, stay in its own thread, since it would read a delegated diff again to check it. Measured over archived worker transcripts, subagent reports cost a median 8% of the worker's peak context, and `sed -n` and `grep` output made up 41% of its Bash results, so delegated searches save the most context. It scores each delegated task's R and C as for an item, and `bin/subagent-rung` turns them into the Agent tool's model and effort, counted from the project's rung. The rule names both, because the Agent tool sets a subagent's effort only when instructions ask. `CLAUDE.md` states the rule, since it holds in every session. A task that proves too hard for the worker's rung escalates instead, by the next entry. +The worker delegates a task only when it needs just the task's conclusion: a search or read across many files, or work independent enough to run in parallel. Edits, and whatever it must check line by line, stay in its own thread, since it would read a delegated diff again to check it. Measured over archived worker transcripts, subagent reports cost a median 8% of the worker's peak context, and `sed -n` and `grep` output made up 41% of its Bash results, so delegated searches save the most context. It scores each delegated task's R and C as for an item, and `bin/subagent-rung` turns them into the Agent tool's model and effort, counted from the project's rung. The rule names both, because the Agent tool sets a subagent's effort only when instructions ask. `CLAUDE.md` states the rule, since it holds in every session. A task that proves too hard for the worker's rung goes one rung up instead: `routing: a worker hands a task one rung up`. 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. Valid while the index ranks these models, and while no newer model joins the catalog. -## routing: a worker hands a task one rung up on each escalation trigger, to at most two rungs above the rung its item picks without the human's yes, and opens the subagent's prompt with the trigger so the routing figures count it +## routing: a worker hands a task one rung up on each escalation trigger, up to two rungs above the rung its item picks unless the human agrees, and opens the subagent's prompt with the trigger so the routing figures count it 2026-10-15, lilleman asked for it. Serves goals 1.1 and 1.4: a task too hard for a cheap rung gets a dearer one only once it proves hard, and only for the part that proved hard. -Three triggers in `CLAUDE.md` โ†’ "Working with the codebase" mark a task too hard: a re-score of the item on the project's rung or above picks a higher rung, the same failing test or finding survives two fix attempts, or a pass reports a ๐Ÿ”ด in round 2 or later. When one fires, the worker hands the hard part to a subagent one rung above its own, edits included, though the delegation rule keeps edits in the worker's thread: the escalation exists because the worker could not get them right. Each further trigger on that task climbs one more rung. Without lilleman's yes the climb stops two rungs above the rung the chunk's item picks, the rung the chunk started on, or the project's rung for a chunk no item routed. A step-up between cycles raises the worker but not that limit: lilleman set the limit from the rung the chunk started on, so a worker that has stepped up may need a yes for its first escalation. +Three escalation triggers in `CLAUDE.md` โ†’ "Working with the codebase" mark a task too hard: a re-score of the item on the project's rung or above picks a higher rung, the same failing test or finding survives two fix attempts, or a pass reports a ๐Ÿ”ด in round 2 or later. When one fires, the worker hands the hard part to a subagent one rung above its own, edits included, though the delegation rule keeps edits in the worker's thread: the escalation exists because the worker could not get them right. Each further trigger on that task climbs one more rung. Without lilleman's yes the climb stops two rungs above the rung the chunk started on: the rung its item picks, or the project's rung when no item routed it. A step-up between cycles raises the worker but not that limit: lilleman set the limit from the rung the chunk started on, so a worker that has stepped up may need a yes for its first escalation. -loop-claude's prompt names the rungs a trigger opens, so the worker computes no rung positions, and tells the worker to open each escalated subagent's prompt with `Escalation trigger :`. `bin/loop_claude/routing.py` holds the limit, and `bin/model_routing/route.py` the marker, beside the other words the archive records, since both loop-claude and `bin/routing_figures/` read it. The archive keeps the raw transcript, which holds the marked prompt, and `bin/routing_figures/` counts the escalations by trigger for each rung routed chunks started on, in `routing-figures.md`. +loop-claude's prompt names the rungs a trigger opens, so the worker computes no rung positions, and tells the worker to open each escalated subagent's prompt with `Escalation trigger :`. `bin/loop_claude/routing.py` holds the limit and `bin/model_routing/route.py` the marker. The archive keeps the raw transcript, which holds the marked prompt, and `bin/routing_figures/` counts the escalations by trigger in `routing-figures.md`, per starting rung for routed chunks and in total for every chunk. Valid while the ladder orders its rungs by competence. From f4b3a93429482511f1d1d0cd26670cb53f4f3081 Mon Sep 17 00:00:00 2001 From: Lilleman auf Larv Date: Thu, 15 Oct 2026 16:34:47 +0200 Subject: [PATCH 23/26] =?UTF-8?q?Answer=20prose=20round=201:=200=20?= =?UTF-8?q?=F0=9F=94=B4,=208=20=F0=9F=9F=A1;=20say=20escalation=20trigger,?= =?UTF-8?q?=20name=20the=20marker,=20fix=20the=20title's=20yes,=20drop=20a?= =?UTF-8?q?=20pointer=20by=20position,=20say=20a=20loop-claude=20worker=20?= =?UTF-8?q?in=20the=20changelog,=20give=20the=20escalation=20total=20its?= =?UTF-8?q?=20own=20heading?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit From a194d4a0d3a2b2eb9f8305508236d1ee40c6c10e Mon Sep 17 00:00:00 2001 From: Lilleman auf Larv Date: Thu, 15 Oct 2026 16:34:47 +0200 Subject: [PATCH 24/26] =?UTF-8?q?Answer=20architecture=20round=203:=200=20?= =?UTF-8?q?=F0=9F=94=B4,=200=20=F0=9F=9F=A1;=20state=20the=20every-chunk?= =?UTF-8?q?=20total=20in=20the=20decision?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit From 1431cc6ea5f1aad7ff61c5f3cd75ee277977b409 Mon Sep 17 00:00:00 2001 From: Lilleman auf Larv Date: Thu, 15 Oct 2026 16:36:28 +0200 Subject: [PATCH 25/26] =?UTF-8?q?Answer=20stability=20round=203:=200=20?= =?UTF-8?q?=F0=9F=94=B4,=200=20=F0=9F=9F=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit From c1bf6f128b979e519031e5891124824ae96a5dca Mon Sep 17 00:00:00 2001 From: Lilleman auf Larv Date: Thu, 15 Oct 2026 16:39:44 +0200 Subject: [PATCH 26/26] Record the comprehension check: paired ruling same against 2190ec8 --- docs/comprehension-history.md | 38 +++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/docs/comprehension-history.md b/docs/comprehension-history.md index 753ff59d..fbfb0051 100644 --- a/docs/comprehension-history.md +++ b/docs/comprehension-history.md @@ -1732,3 +1732,41 @@ Inherited architect, decided by: - Locality: `bin/loop_claude/cycle/prompts.py:34` `off_the_projects_rung`: the prompt spells out another tool's command line, `subagent-rung --plan`, with nothing tying the two, and its docstring points to `routing.first_route` in another module - Locality: `bin/loop_claude/routing.py:61` `judge_rung`: reads in one line and drops the two-way reference with `item_rung`, but writes the no-item branch a second time - Shape, Self-sufficiency: `bin/model_routing/ladder.py:52` `floored`: a truthfully named helper, offset by `bin/subagent_rung/main.py:23` `agent_args`'s boolean `planning` and position-sensitive `--plan` parsing + +## 2026-10-15T14:39:39Z, PR #274 at 1431cc6, against 2190ec8 + +Ruling: same + +| Seat | Navigation | Locality | Shape | Self-sufficiency | Overall | +|---|---|---|---|---|---| +| Mid A | same | same | same | worse | same | +| Inherited architect | same | worse | worse | worse | worse | +| Maintainability senior | same | worse | same | worse | worse | +| Junior A | same | same | same | worse | same | + +Mid A, decided by: + +- Self-sufficiency: `bin/routing_figures/measure.py:106` `escalations`: the figures count escalations by a bare trigger number, and only the prose list in `CLAUDE.md` says what each number is +- Self-sufficiency: `bin/loop_claude/routing.py:43` `escalation_rungs`: the docstring explains the cap by naming who set it, a reason only to someone who knows the decision + +Inherited architect, decided by: + +- Locality: `bin/loop_claude/cycle/prompts.py:44` `escalation`: the marker's `:` format is typed in the prompt and again in `measure.py`'s regex, and a mismatch makes the figures print None with no error +- Locality: `bin/loop_claude/routing.py:43` `escalation_rungs`: the upper bound counts from `item_rung` and the lower from `route.rung`, so a step-up shrinks or empties the window, explained only by naming who set it +- Locality, Shape: `bin/loop_claude/cycle/prompts.py:46` `escalation`: the past-the-cap branch is a third case the docstring omits, and prompts.py now imports policy from `loop_claude.routing` +- Shape: `bin/model_routing/route.py:8` `ESCALATION_MARKER`: the module is about a chunk's Route as archived, but the marker belongs to the subagent-prompt contract +- Shape, Self-sufficiency: `CLAUDE.md:60` "Working with the codebase": "escalation" already named the reviewer-to-reviewer ๐Ÿ”€ handoff in `skills/larv-review/SKILL.md:80`, and now also names handing a task one rung up +- Self-sufficiency: `bin/routing_figures/measure.py:258` `triggers`: `routing-figures.md` prints `trigger 2: 3`, and no code names what each number means + +Maintainability senior, decided by: + +- Locality: `bin/loop_claude/cycle/prompts.py:40` `escalation`: when the sentence appears is split between its own top-rung guard and `escalation_rungs`'s empty slice in another module +- Locality: `bin/loop_claude/cycle/prompts.py:19` `fresh`: one plain conditional became a nested one with an `lstrip`, and `routed_by` also appends the sentence, so both paths need tracing to rule out a double +- Self-sufficiency, Locality: `bin/routing_figures/measure.py:106` `escalations`: counts bare trigger numbers that only `CLAUDE.md`'s numbered list defines +- Self-sufficiency: `bin/loop_claude/routing.py:43` `escalation_rungs`: the cap's base is explained by who set it, and the slice takes decoding + +Junior A, decided by: + +- Self-sufficiency: `bin/routing_figures/measure.py:23` `ESCALATION`: trigger numbers mean something only in `CLAUDE.md:60`'s list, and renumbering it would silently change old figures +- Self-sufficiency, Shape: `CLAUDE.md:60` "Working with the codebase": "trigger" now names an escalation condition as well as the review-pass condition Vocabulary defines +- Self-sufficiency, Locality: `bin/loop_claude/cycle/prompts.py:40` `escalation`: the past-the-cap branch is missing from the docstring, and the off-ladder guard differs from `escalation_rungs`'s