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.