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.