diff --git a/AGENTS.md b/AGENTS.md index 30a71991..f0296173 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -44,7 +44,7 @@ Decisions live in `docs/decisions.md`: - routing: loop-claude measures review rounds and unfinished verdicts per rung every 20 cycles, and calls for a routing change when, of two rungs with 5 or more chunks each, the lower took more of either than the one above, or when 5 or more subagents of one type had reports longer than the tool results they read - routing: a worker delegates a task only where it needs just the task's conclusion, and each subagent runs on the rung its task's L picks from the project's rung, never below the project's rung when it files or scores todo.md items - 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: a worker whose run ends asking for a higher rung, citing an escalation trigger the judge finds in the transcript, steps one rung up as the judge interrupts or next cycle, up to two rungs above the rung its item picks +- routing: a worker whose run ends asking for a higher rung, citing an escalation trigger the judge finds in the transcript, steps one rung up as the judge interrupts or quotes an answer, or next cycle, up to two rungs above the rung its item picks - routing: on a model judge-replay covered, the judge runs on the rung a review would get from the highest E + I among its chunk's items, never below the project's rung - routing: the stability reviewer runs no lower than the project's rung while the worker runs below it, until `stability-replay` shows a lower rung finding every 🔴 and 🟡 the project's rung finds diff --git a/CHANGELOG.md b/CHANGELOG.md index 2252d941..f6100774 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,7 +2,7 @@ ## Unreleased -- `loop-claude` steps the worker one rung up as the judge interrupts or quotes an answer from `README.md` or the records, when the run that asked also asked `loop-claude` for a higher rung and the judge quotes the escalation trigger it cites. Before, the step was lost, and the worker carried on from the answer on its old rung. The step has the same limits as the step on an unfinished verdict, and no later ruling of that cycle carries a second escalation. The archive's interrupt and quoted-answer outcomes now name the worker's rung. +- When a worker's run ends with a question and a request for a higher rung, `loop-claude` now steps the worker one rung up as the judge interrupts, or as it answers the question with a quote from `README.md` or another file it may quote. The judge must quote a passage showing that the escalation trigger the run cites fired. Before, the step was lost for an answered question, and the worker carried on from the answer on its old rung. The step has the same limits as the step on an unfinished verdict, and no later ruling of that cycle carries a second escalation. The archive's interrupt and quoted-answer outcomes now name the worker's rung. - A scoring run due because a release's items ran out costs four more seats: it is done twice on one head. `larv-review agreement` compares how often Mid A and the inherited architect vote alike in paired rulings with how often their overall scores move the same way between the two runs. After 10 such pairs it gives a verdict, and on `Assumption fails:` larv-review asks you whether to keep the paired ruling. - `workflow-bench/bench.py` gives each run a fixed list of allowed tools. Before, it skipped every permission check. A run may launch agents, run `/security-review`, edit its clone (not the clone's `.git/` or `.claude/`) and its report, and read its clone and the copy of `~/.claude` it benches. For git it gets one command, `workflow-bench/review_git.py`, and no bare `git`. The wrapper runs `log`, `diff`, `show`, `status`, `ls-files`, `add` and `commit -m` on the run's clone, whatever the working directory. It allows only the options it lists for each, and refuses an argument that names a path outside the clone. git runs with no global or system config, hook, pager or editor. A run loads no settings or MCP servers from `~/.claude` or from the case's clone, so their hooks and extra directories do not apply to it. Every other call is denied. Expect a benched review that needs another git command, or to run a project's code or tests, to say in its report that it could not. - Every goal in `README.md` → Goals is marked `**Maintain:**`, a state to hold, or `**Achieve:**`, a direction to pursue. Each achieve goal has a signal, a counter-signal and a one-line reason under it. A change that breaks a maintain goal is redesigned or dropped, whatever it scores: `rules/todo-items.md` says so, and larv-review's goal alignment step no longer merges such a PR. `rules/goals-and-audience.md` states the form for every project's README. Expect larv-review to stop a PR on a maintain goal where it asked you before. diff --git a/bin/loop_claude/cycle/prompts.py b/bin/loop_claude/cycle/prompts.py index 87f3574d..7f144d5a 100644 --- a/bin/loop_claude/cycle/prompts.py +++ b/bin/loop_claude/cycle/prompts.py @@ -119,13 +119,13 @@ def resumed(unfinished_evidence: str, route: Route, anchor: Rung | None) -> str: def rungs_held(route: Route, anchor: Rung | None) -> str: - """The sentences that depend on the worker's rung: where its reviews, its subagents and their reruns run.""" + """The sentences that depend on the worker's rung: where its reviews run and rerun, and where its escalated subagents run.""" return f"{review_launches(route, anchor)}{escalation(route, anchor)}{reruns(route, anchor)}" def answered(question: str, answer: str, route: Route, anchor: Rung | None, stepped: bool) -> str: """stepped is whether the answer's ruling stepped the worker up, so the prompt names its new rung, as resumed does.""" - on = f" Your request for a higher rung went through: loop-claude runs you on {route.rung}.{rungs_held(route, anchor)}" if stepped else "" + on = f" Your request for a higher rung went through: loop-claude runs you on {route.rung}.{rungs_held(route, anchor)} A further request for a higher rung steps you up no more in this cycle." if stepped else "" return f"Your question: {question}\n\n{QUOTE_SOURCES} answers it:\n\n{answer}\n\nContinue the task.{on}" diff --git a/bin/loop_claude/cycle/run.py b/bin/loop_claude/cycle/run.py index a8fbf43a..9ac9d7dc 100644 --- a/bin/loop_claude/cycle/run.py +++ b/bin/loop_claude/cycle/run.py @@ -41,7 +41,7 @@ class Cycle: # Empty when the previous cycle's verdict was not Unfinished. unfinished_evidence: str # Only an interrupt's or a quoted answer's escalation changes the route within a cycle. No transition reads the route or the fields below, so they stay out of the states. - # The route that ruling left, for ask and keep_answer to archive; None unless the latest event stepped the route up. + # The route before that ruling stepped it up, for ask and keep_answer to archive; None unless the latest event stepped the route up. stepped_from: Route | None = None # Whether an interrupt or a quoted answer of this cycle took an escalation, after which no ruling of the cycle carries one. escalation_spent: bool = False diff --git a/bin/loop_claude/loop/main.py b/bin/loop_claude/loop/main.py index 6398f278..6f3d1757 100644 --- a/bin/loop_claude/loop/main.py +++ b/bin/loop_claude/loop/main.py @@ -37,8 +37,8 @@ copied to $LOOP_CLAUDE_TRANSCRIPTS///.jsonl (default line with a timestamp, the same for every cycle of a chunk. Beside the copy, .outcomes.md holds the verdict, with the transcript passage the judge rested it on, any passage it quoted to show an escalation trigger fired, and the judge's rung; each answer the judge quoted, with the -question it answers and any such passage; each judge reply the loop rejected, with the reason and the reply as json; -and why the loop stopped. Each of these opens with its UTC time. Claude Code keeps a folder per +question it answers and any passage it quoted to show an escalation trigger fired; each judge +reply the loop rejected, with the reason and the reply as json; and why the loop stopped. Each of these opens with its UTC time. Claude Code keeps a folder per session beside its transcript, holding the subagents' transcripts among other files; that folder, and every other file named after the session except the transcript, are copied into /session/. A file there is replaced only by a version that grew from it. A file Claude Code @@ -83,11 +83,12 @@ scale counts as none. Every second unfinished verdict on a chunk steps it up one higher rung, once the judge quotes the transcript showing that the escalation trigger it named fired (~/.claude/CLAUDE.md → "Working with the codebase" lists them). An interrupt or a quoted answer with such a quote steps the rung as it comes in, before the human is asked or the worker resumes -(routing.stepped_by_ruling), and no later ruling of that cycle carries a second escalation. Either step stops two rungs -above the rung the chunk's item picks, and the worker's prompts offer it only while the worker is -below that limit. Each finished or unfinished verdict, interrupt, quoted answer, stop and step-up in the archive names the -worker's rung, with the item, L and E + I that routed the chunk, and any taken-in E + I that picks a -higher review rung, which is archived as a step-up too. A rerun resumes an open chunk on the latest +(routing.stepped_by_ruling), and no later ruling of that cycle carries a second escalation. Each step +on an escalation stops two rungs above the rung the chunk's item picks, and the worker's prompts +offer it only while the worker is below that limit. Each finished or unfinished verdict, interrupt, +quoted answer, stop and step-up in the archive names the worker's rung, with the item, L and E + I +that routed the chunk, and any taken-in E + I that picks a higher review rung, which is archived as +a step-up too. A rerun resumes an open chunk on the latest route named there, and counts its unfinished verdicts afresh. A rung no longer on the ladder, or below the one its item's L picks, is dropped, and the chunk is routed afresh from todo.md. So is a chunk whose archived line names an R + C, as loop-claude wrote before it routed on L. A todo.md or diff --git a/bin/loop_claude/test_loop_claude.py b/bin/loop_claude/test_loop_claude.py index 7aaf77bb..ae2dc662 100644 --- a/bin/loop_claude/test_loop_claude.py +++ b/bin/loop_claude/test_loop_claude.py @@ -345,7 +345,7 @@ class Cycles(unittest.TestCase): self.assertEqual(concluded.route, Route(Routing.OPUS, 179, 2, 5)) first, resumed = fake.made("stream_claude") self.assertEqual([args[args.index("--effort") + 1] for args in (first, resumed)], ["high", "medium"]) - self.assertTrue(resumed[resumed.index("-p") + 1].endswith(f"Continue the task. Your request for a higher rung went through: loop-claude runs you on {Routing.OPUS}.{prompts.rungs_held(concluded.route, Routing.OPUS)}")) + self.assertTrue(resumed[resumed.index("-p") + 1].endswith(f"Continue the task. Your request for a higher rung went through: loop-claude runs you on {Routing.OPUS}.{prompts.rungs_held(concluded.route, Routing.OPUS)} A further request for a higher rung steps you up no more in this cycle.")) self.assertNotIn("went through", first[first.index("-p") + 1]) answered = f"Verdict: quoted answer\n\nWhich one?\n\n{prompts.QUOTE_SOURCES} says:\n> Use A.\n\nEvidence:\n> working\n\nEscalation:\n> working\n\nJudge: judge-model\nWorker: {Route(Routing.SONNET, 179, 2, 5)}\n" stepped = f"Stepped up\n\nWorker: {Route(Routing.OPUS, 179, 2, 5)}\n" diff --git a/docs/decisions.md b/docs/decisions.md index 8bc93a44..0131a346 100644 --- a/docs/decisions.md +++ b/docs/decisions.md @@ -284,17 +284,17 @@ loop-claude's prompt names the rungs a trigger opens, so the worker computes no Valid while the ladder orders its rungs by competence. -## routing: a worker whose run ends asking for a higher rung, citing an escalation trigger the judge finds in the transcript, steps one rung up as the judge interrupts or next cycle, up to two rungs above the rung its item picks +## routing: a worker whose run ends asking for a higher rung, citing an escalation trigger the judge finds in the transcript, steps one rung up as the judge interrupts or quotes an answer, or next cycle, up to two rungs above the rung its item picks 2026-10-15, lilleman asked for it. Serves goals 1.1 and 1.4: when the hard part is the rest of the chunk, handing it to subagents piece by piece leaves the worker, which reads and checks each of their diffs, on a rung that proved too low. The worker climbs only once its run records a trigger. -loop-claude's prompt offers the step beside the escalated subagent of `routing: a worker hands a task one rung up`, as long as the limit leaves a rung that subagent may take without the human's yes. The worker then ends its run asking loop-claude for a higher rung and naming the trigger. The judge quotes an earlier passage that shows the trigger fired, such as a review round's commit title or the worker's report of the failing test, never the request itself. The trigger must have fired since any earlier such request, so one trigger buys one step. The judge sees the worker's text and tool calls but no tool results, so the quote shows that the run recorded the trigger, not that a tool's output bears it out. loop-claude checks the quote word for word, as it checks a quoted answer, since stitched fragments can make up a trigger. Without such a quote, the rung holds. A misquote is no failure, since holding the rung is safe and three failures stop an unattended loop. The next prompt names the worker's rung, so the worker learns whether the step went through. So does the prompt that resumes a worker with a quoted answer whose ruling stepped it up. +loop-claude's prompt offers the step beside the escalated subagent of `routing: a worker hands a task one rung up`, as long as the limit leaves a rung that subagent may take without the human's yes. The worker then ends its run asking loop-claude for a higher rung and naming the trigger. The judge quotes an earlier passage that shows the trigger fired, such as a review round's commit title or the worker's report of the failing test, never the request itself. The trigger must have fired since any earlier such request, so one trigger buys one step. The judge sees the worker's text and tool calls but no tool results, so the quote shows that the run recorded the trigger, not that a tool's output bears it out. loop-claude checks the quote word for word, as it checks a quoted answer, since stitched fragments can make up a trigger. Without such a quote, the rung holds. A misquote is no failure, since holding the rung is safe and three failures stop an unattended loop. The next cycle's prompt names the worker's rung, so the worker learns whether the step went through. A worker that a quoted answer stepped up learns it sooner, from the prompt that resumes it with the answer. -A run that asks for a higher rung may also ask a question that only the human, or only README.md or the records, can answer. The judge then interrupts or quotes the answer, and either ruling carries the quote too, checked the same way. loop-claude steps the rung as the ruling comes in, before the human is asked or the worker resumes with the quoted answer, since the work after the answer is work the stepped rung should do. An interrupt or a quoted answer is no unfinished verdict, so it adds to no count. The judge may quote a different passage for the trigger that already stepped the rung, and loop-claude cannot tell that from a new trigger. So once an interrupt or a quoted answer has taken an escalation, no later ruling of that cycle carries one. A trigger that fires after the human's answer waits for the next cycle. +A run that asks for a higher rung may also ask a question. The judge then interrupts, or quotes the answer from README.md or the records, and either ruling carries the escalation quote too, checked the same way. loop-claude steps the rung as the ruling comes in, before the human is asked or the worker resumes with the quoted answer, since the work after the answer is work the stepped rung should do. An interrupt or a quoted answer is no unfinished verdict, so it adds to no count. The judge may quote a different passage for the trigger that already stepped the rung, and loop-claude cannot tell that from a new trigger. So once an interrupt or a quoted answer has taken an escalation, no later ruling of that cycle carries one. A trigger that fires after the answer steps nothing in that cycle. The step is one rung up from the rung the worker would otherwise hold: its own, or the rung an item the judge saw it take in picks, whichever is higher. It resets the count of unfinished verdicts, so the step every second one takes counts afresh; when both steps fall on one verdict, the worker steps once. It stops at the limit escalated subagents stop at, two rungs above the rung the chunk started on. Past that limit the rung holds: loop-claude takes no yes from the human between cycles, so a worker there asks the human for an escalated subagent instead. The judge keeps its rung, as `routing: on a model judge-replay covered` says. -The archive quotes the judge's passage under `Escalation:` in the unfinished verdict, the interrupt or the quoted answer. The step an unfinished verdict causes is archived after it. The step an interrupt or a quoted answer causes is archived with it, at once: the interrupt or answer names the rung the worker ran on until then, and a step-up archived beside it names the rung it runs on from then. So the routing figures charge each stretch to its own rung, and a loop that dies while the human answers resumes on the stepped rung. `bin/routing_figures/` counts neither as an escalation by trigger, which it counts only from subagent prompts. +The archive quotes the judge's passage under `Escalation:` in the unfinished verdict, the interrupt or the quoted answer. The step an unfinished verdict causes is archived after it. The step an interrupt or a quoted answer causes is archived with it, at once: the interrupt or answer names the rung the worker ran on until then, and a step-up archived beside it names the rung it runs on from then. So the routing figures charge each stretch to its own rung, and a loop that dies while the human answers resumes on the stepped rung. `bin/routing_figures/` counts none of these steps as an escalation by trigger, which it counts only from subagent prompts. Valid while the worker reports in its transcript the triggers that fired. diff --git a/todo.md b/todo.md index d8828c72..9ab4e3d5 100644 --- a/todo.md +++ b/todo.md @@ -12,7 +12,7 @@ | ID | Release | Blocked by | Exempt | Item | L | E | I | R | S | Moves | Score | |---|---|---|---|---|---|---|---|---|---|---|---| -| 180 | 0.2.0 | | question | **Settle whether a trigger that fires after a quoted answer's or an interrupt's step-up may still step the worker in the same cycle.** | 2 | 2 | 2 | 4 | 3 | 1.1 by 3 | 4.1 | +| 180 | 0.2.0 | | question | **Settle how a trigger that fires after a step-up at an interrupt or a quoted answer steps the worker, which today it never does.** | 2 | 2 | 2 | 4 | 3 | 1.1 by 3 | 4.1 | | 168 | 0.2.0 | | | **Have the human answer an interrupt on loop-claude's terminal and resume the worker headless with the answer, opening the interactive session only when they ask for it.** | 4 | 2 | 3 | 7 | 5 | 1.5 by 8 | 1.8 | | 73 | 0.2.0 | | | **Have each reviewer write its full report to a file and return the worker only its findings' one-line summaries.** | 3 | 2 | 3 | 6 | 5 | 1.4 by 4 | 1.1 | | 159 | 0.2.0 | | decision | **Run each review pass on the lowest rung that a replay of its archived rounds shows finding every 🔴 and 🟡 the project's rung finds, even below the worker's rung.** | 4 | 2 | 3 | 7 | 6 | 1.4 by 7 | 1.1 | @@ -84,9 +84,9 @@ ## Details -### 180. Settle whether a trigger that fires after a quoted answer's or an interrupt's step-up may still step the worker in the same cycle. +### 180. Settle how a trigger that fires after a step-up at an interrupt or a quoted answer steps the worker, which today it never does. -`docs/decisions.md` → `routing: a worker whose run ends asking for a higher rung…` says a trigger that fires after the human's answer waits for the next cycle. But once an interrupt or a quoted answer has taken an escalation, `unspent` in `bin/loop_claude/cycle/run.py` drops the escalation of every later ruling of the cycle. The dropped request stays in the transcript, so in the next cycle the judge finds no trigger that fired since the worker's last request, and the worker cannot be stepped for it. Since a quoted answer resumes the worker headless up to three times a cycle, the loss is now reachable unattended. +`docs/decisions.md` → `routing: a worker whose run ends asking for a higher rung…` says a trigger that fires after the human's answer waits for the next cycle. Today it steps nothing: once an interrupt or a quoted answer has taken an escalation, `unspent` in `bin/loop_claude/cycle/run.py` drops the escalation of every later ruling of the cycle. The dropped request stays in the transcript, so in the next cycle the judge finds no trigger that fired since the worker's last request, and the worker cannot be stepped for it. Since a quoted answer resumes the worker headless up to three times a cycle, the loss is now reachable unattended. Options: @@ -99,7 +99,7 @@ Only the human can choose, and the answer revises that decision. Found by the st Today an interrupt runs `claude --resume` on the terminal and waits for it to exit (`bin/loop_claude/cycle/interrupt.py`). Once the human answers, the worker carries on in that interactive session, so the loop waits until the human exits it, often for the rest of the chunk. Instead, the loop prints the question and reads the answer on its own terminal. The next cycle resumes the worker headless with a prompt like `prompts.answered`'s, saying the human gave the answer. A word typed in place of an answer, such as `/talk`, opens today's interactive session, for when the human wants to read the diff or discuss first. An empty answer stops the loop, as an interrupt with nothing typed does today. A release ready to cut still opens the interactive session. Bench the word, and the line that asks for the answer, as `CLAUDE.md` says. -The judge must treat an answer typed at the loop's terminal as the human's. `bin/claude_code/transcript.py`'s `render` labels every `-p` prompt `[loop]`, so an answer passed on headless would read as one quoted from the records. The judge would then never hold the chunk open until that answer is recorded. The change touches two places the comprehension seats found hard: `bin/loop_claude/cycle/judge.py`'s `run_judge` and `bin/loop_claude/loop/main.py`'s help. Leave each easier to read. When the interrupt has stepped the worker's rung up (`Cycle.stepped_from`), the headless resume prompt names the worker's new rung and repeats the rung-dependent sentences, as `prompts.answered` does after a quoted answer's step (`prompts.rungs_held`), since the worker otherwise never learns the step went through, and `docs/decisions.md` says the next prompt names it. +The judge must treat an answer typed at the loop's terminal as the human's. `bin/claude_code/transcript.py`'s `render` labels every `-p` prompt `[loop]`, so an answer passed on headless would read as one quoted from the records. The judge would then never hold the chunk open until that answer is recorded. The change touches two places the comprehension seats found hard: `bin/loop_claude/cycle/judge.py`'s `run_judge` and `bin/loop_claude/loop/main.py`'s help. Leave each easier to read. When the interrupt stepped the worker's rung up (`Cycle.stepped_from`), have the headless resume prompt name the new rung and repeat `prompts.rungs_held`, as `prompts.answered` does after a quoted answer's step. Otherwise the worker learns of the step only next cycle, though `docs/decisions.md` says the next prompt names it. ### 73. Have each reviewer write its full report to a file and return the worker only its findings' one-line summaries.