From fc24e9bae286f90b8e88a7bda38115225d17db0d Mon Sep 17 00:00:00 2001 From: Lilleman auf Larv Date: Sat, 17 Oct 2026 22:24:37 +0200 Subject: [PATCH 1/7] Step the worker up as the judge quotes an answer when the run also cites an escalation trigger --- CHANGELOG.md | 2 +- bin/loop_claude/cycle/judge.py | 22 ++++++------ bin/loop_claude/cycle/run.py | 35 ++++++++++++------- bin/loop_claude/loop/main.py | 6 ++-- bin/loop_claude/test_loop_claude.py | 32 +++++++++++++++-- bin/transcript_archive/outcomes.py | 10 +++--- .../test_transcript_archive.py | 6 ++++ docs/decisions.md | 4 +-- docs/reading-cost.md | 8 +++++ todo.md | 5 --- 10 files changed, 90 insertions(+), 40 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1b63650c..2252d941 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,7 +2,7 @@ ## Unreleased -- `loop-claude` steps the worker one rung up as the judge interrupts, when the run that asked the human 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 human's 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 outcome now names the worker's rung. +- `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. - 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/judge.py b/bin/loop_claude/cycle/judge.py index bd55375c..0bc893d6 100644 --- a/bin/loop_claude/cycle/judge.py +++ b/bin/loop_claude/cycle/judge.py @@ -59,8 +59,8 @@ class Reply: bundled: int = dataclasses.field(metadata={"description": "The highest L the agent states for a todo.md item it took into this chunk; 0 when it states none."}) # Routes the next cycle's judge and reviewers, as bundled routes the worker. bundled_escape_and_impact: int = dataclasses.field(metadata={"description": "The highest E + I the agent states for a todo.md item it took into this chunk; 0 when it states none."}) - # Routes the worker one rung up, as the judge interrupts or on the next cycle: docs/decisions.md → `routing: a worker whose run ends asking for a higher rung`. - escalation: str = dataclasses.field(metadata={"description": "Empty unless the chunk is unfinished or interrupt is true, and the agent's run ends asking loop-claude for a higher rung, citing an escalation trigger. Then: a verbatim quote, without elisions, of an earlier transcript passage showing the trigger fired after any earlier such request, such as a review round's commit title or the agent's report of the finding or failing test. Never the request itself."}) + # Routes the worker one rung up, as the judge interrupts or quotes an answer, or on the next cycle: docs/decisions.md → `routing: a worker whose run ends asking for a higher rung`. + escalation: str = dataclasses.field(metadata={"description": "Empty unless the chunk is unfinished, interrupt is true or answer quotes a passage, and the agent's run ends asking loop-claude for a higher rung, citing an escalation trigger. Then: a verbatim quote, without elisions, of an earlier transcript passage showing the trigger fired after any earlier such request, such as a review round's commit title or the agent's report of the finding or failing test. Never the request itself."}) evidence: str = dataclasses.field(metadata={"description": "A verbatim quote of the one transcript passage the verdict rests on, without elisions: what triggers the interrupt; for a quoted answer, the agent's question; else what shows the chunk finished or the work remaining."}) finished: bool = dataclasses.field(metadata={"description": "Whether the chunk is finished."}) interrupt: bool = dataclasses.field(metadata={"description": "Whether the human must now be interrupted."}) @@ -99,6 +99,9 @@ class QuotedAnswer: evidence: str question: str answer: str + # As on Interrupt. + escalation: str = "" + bundled: int = 0 @dataclasses.dataclass(frozen=True) @@ -136,7 +139,7 @@ def verdict_from(output: object) -> Verdict | Failure: if output["answer"].strip(): if not output["question"].strip(): return Failure("the judge quoted an answer without a question") - return QuotedAnswer(output["evidence"], output["question"], output["answer"]) + return QuotedAnswer(output["evidence"], output["question"], output["answer"], output["escalation"], bundled) if output["finished"]: return Finished(output["evidence"]) bundled_escape_and_impact = output["bundled_escape_and_impact"] if on_its_scale(output["bundled_escape_and_impact"]) else 0 @@ -179,15 +182,14 @@ def run_judge(root: str, args: list[str], prompt: str, shown: str, quotable: str def quotes_checked(verdict: Verdict, shown: str, quotable: str) -> Verdict: """The verdict with its quotes checked word for word, since stitched fragments can say what the records or the transcript do not: - - a quoted answer, against quotable: a misquote puts the question to the human; - - an escalation, on an interrupt or an unfinished verdict, against shown: a misquote drops it, so the worker's rung holds. + - a quoted answer, against quotable: a misquote puts the question to the human, with the escalation it carried; + - an escalation, on any ruling but a finished one, against shown: a misquote drops it, so the worker's rung holds. A misquote is no Failure, which would otherwise exit an unattended loop. """ - match verdict: - case QuotedAnswer() if not verbatim(verdict.answer, quotable): - return Interrupt(verdict.evidence, verdict.question) - case Interrupt() | Unfinished() if verdict.escalation and not verbatim(verdict.escalation, shown): - return dataclasses.replace(verdict, escalation="") + if isinstance(verdict, QuotedAnswer) and not verbatim(verdict.answer, quotable): + verdict = Interrupt(verdict.evidence, verdict.question, verdict.escalation, verdict.bundled) + if isinstance(verdict, Interrupt | QuotedAnswer | Unfinished) and verdict.escalation and not verbatim(verdict.escalation, shown): + return dataclasses.replace(verdict, escalation="") return verdict diff --git a/bin/loop_claude/cycle/run.py b/bin/loop_claude/cycle/run.py index 2a1998c8..8f7ceba7 100644 --- a/bin/loop_claude/cycle/run.py +++ b/bin/loop_claude/cycle/run.py @@ -40,10 +40,10 @@ class Cycle: anchor: Rung | None # Empty when the previous cycle's verdict was not Unfinished. unfinished_evidence: str - # Only an interrupt'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 interrupt left, for ask to archive; None unless the latest event stepped the route up. + # 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. stepped_from: Route | None = None - # Whether an interrupt of this cycle took an escalation, after which no ruling of the cycle carries one. + # 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 @@ -69,9 +69,9 @@ def run_cycle(cycle: Cycle) -> Stop | Concluded: def escalated(cycle: Cycle, event: Event) -> Cycle: - """The cycle after event. Where the judge interrupted with an escalation, its route steps up before the human is asked, so the work after the answer runs on it.""" + """The cycle after event. Where the judge interrupted or quoted an answer with an escalation, its route steps up before the human is asked or the worker resumes, so the work after the answer runs on it.""" cycle = dataclasses.replace(cycle, stepped_from=None) - if not (isinstance(event, Ruled) and isinstance(event.verdict, Interrupt) and event.verdict.escalation): + if not (isinstance(event, Ruled) and isinstance(event.verdict, Interrupt | QuotedAnswer) and event.verdict.escalation): return cycle route = stepped_by_interrupt(cycle.anchor, cycle.route, event.verdict.bundled) if cycle.anchor else cycle.route return dataclasses.replace(cycle, route=route, stepped_from=cycle.route if route != cycle.route else None, escalation_spent=True) @@ -130,7 +130,11 @@ def worker_start(cycle: Cycle, answered: QuotedAnswer | None) -> list[str]: def keep_answer(cycle: Cycle, answered: QuotedAnswer) -> Stop | None: path = transcript_file(cycle.session) - if path and (failure := archive(cycle.project_archive, path, cycle.task, outcomes.answered(answered.question, prompts.QUOTE_SOURCES, answered.answer, answered.evidence, str(judge_of(cycle))), cycle.effects.now())): + if not path: + return None + # As in ask: the answer names the rung the worker ran on until then, and a step-up archived after it names the rung it runs on from then. + quoted = outcomes.answered(answered.question, prompts.QUOTE_SOURCES, answered.answer, answered.evidence, answered.escalation, str(judge_of(cycle)), str(cycle.stepped_from or cycle.route)) + if failure := archive_stepped(cycle, path, quoted): return Stop(1, failure.reason) return None @@ -144,8 +148,8 @@ def rule(cycle: Cycle, transcript_path: str) -> Ruled | Stop: def unspent(verdict: Verdict, spent: bool) -> Verdict: - """The verdict without its escalation once an interrupt of the cycle took one. The judge may quote a different passage for the trigger that already stepped the route, and no comparison of quotes tells the two apart, so one trigger buys one step. It lives here, not in judge.quotes_checked, since it reads the cycle, and judge-replay replays the judge alone.""" - if spent and isinstance(verdict, Interrupt | Unfinished) and verdict.escalation: + """The verdict without its escalation once an interrupt or a quoted answer of the cycle took one. The judge may quote a different passage for the trigger that already stepped the route, and no comparison of quotes tells the two apart, so one trigger buys one step. It lives here, not in judge.quotes_checked, since it reads the cycle, and judge-replay replays the judge alone.""" + if spent and isinstance(verdict, Interrupt | QuotedAnswer | Unfinished) and verdict.escalation: return dataclasses.replace(verdict, escalation="") return verdict @@ -161,13 +165,20 @@ def ask(cycle: Cycle, transcript_path: str, ruling: Interrupt | QuotedAnswer) -> question = question_for(ruling) # Archived now, so the transcript the question was asked on is kept with it; the human's answer then grows the transcript. # The interrupt names the rung the worker ran on before it; a step-up archived after it names the stepped rung, so the figures charge each stretch to its own rung. - interrupted = outcomes.interrupted(question, ruling.evidence, str(judge_of(cycle)), ruling.escalation if isinstance(ruling, Interrupt) else "", str(cycle.stepped_from or cycle.route)) - for outcome in (interrupted, outcomes.stepped_up(str(cycle.route))) if cycle.stepped_from else (interrupted,): - if failure := archive(cycle.project_archive, transcript_path, cycle.task, outcome, cycle.effects.now()): - return Stop(1, failure.reason) + interrupted = outcomes.interrupted(question, ruling.evidence, str(judge_of(cycle)), ruling.escalation, str(cycle.stepped_from or cycle.route)) + if failure := archive_stepped(cycle, transcript_path, interrupted): + return Stop(1, failure.reason) return interrupt(cycle.root, cycle.session.id, cycle.route.rung, transcript_path, question, cycle.paths, worker_environment(cycle), cycle.effects) or HumanAnswered() +def archive_stepped(cycle: Cycle, transcript_path: str, outcome: str) -> Failure | None: + """Archives the outcome of a ruling, then the step-up it caused when it stepped the route. The first failure is returned.""" + for kept in (outcome, outcomes.stepped_up(str(cycle.route))) if cycle.stepped_from else (outcome,): + if failure := archive(cycle.project_archive, transcript_path, cycle.task, kept, cycle.effects.now()): + return failure + return None + + def question_for(ruling: Interrupt | QuotedAnswer) -> str: if isinstance(ruling, Interrupt): return ruling.question diff --git a/bin/loop_claude/loop/main.py b/bin/loop_claude/loop/main.py index 5a162fca..07201188 100644 --- a/bin/loop_claude/loop/main.py +++ b/bin/loop_claude/loop/main.py @@ -81,9 +81,9 @@ E + I, or the routed item's (Route.reviewed_on in bin/model_routing/route.py). A scale counts as none. Every second unfinished verdict on a chunk steps it up one rung (routing.stepped). So does an unfinished verdict on a worker that ended its run asking for a 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 with such a quote -steps the rung as it comes in, before the human is asked (routing.stepped_by_interrupt), and no later -ruling of that cycle carries a second escalation. Either step stops two rungs +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_interrupt), 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, 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 diff --git a/bin/loop_claude/test_loop_claude.py b/bin/loop_claude/test_loop_claude.py index 5784e4cc..caea0c14 100644 --- a/bin/loop_claude/test_loop_claude.py +++ b/bin/loop_claude/test_loop_claude.py @@ -105,8 +105,8 @@ def ran(stdout="", code=0, stderr=""): return subprocess.CompletedProcess([], code, stdout, stderr) -def judged(verdict, evidence="working", answer=""): - reply = {"answer": answer, "bundled": 0, "bundled_escape_and_impact": 0, "escalation": "", "evidence": evidence, "finished": verdict == "finished", "interrupt": verdict == "interrupt", "question": "Which one?" if verdict in ("interrupt", "quoted") else ""} +def judged(verdict, evidence="working", answer="", escalation=""): + reply = {"answer": answer, "bundled": 0, "bundled_escape_and_impact": 0, "escalation": escalation, "evidence": evidence, "finished": verdict == "finished", "interrupt": verdict == "interrupt", "question": "Which one?" if verdict in ("interrupt", "quoted") else ""} return ran(json.dumps({"structured_output": reply})) @@ -334,9 +334,23 @@ class Cycles(unittest.TestCase): self.assertEqual(len(fake.made("stream_claude")), 4) self.assertEqual(printed.getvalue().count("=== README.md's Goals and Audience, AGENTS.md, docs/decisions.md, ~/.claude/CLAUDE.md, ~/.claude/rules/ or ~/.claude/skills/larv-review/standards/ answered: Which one? ===\nUse *A*."), 3) self.assertIn("Which one?\n\nREADME.md's Goals and Audience, AGENTS.md, docs/decisions.md, ~/.claude/CLAUDE.md, ~/.claude/rules/ or ~/.claude/skills/larv-review/standards/ says:\nUse *A*.\n\nThose files have answered 3 questions this cycle", said.getvalue()) - quoted = "2026-09-21T14:13:20Z Verdict: quoted answer\n\nWhich one?\n\nREADME.md's Goals and Audience, AGENTS.md, docs/decisions.md, ~/.claude/CLAUDE.md, ~/.claude/rules/ or ~/.claude/skills/larv-review/standards/ says:\n> Use *A*.\n\nEvidence:\n> working\n\nJudge: judge-model\n" + quoted = "2026-09-21T14:13:20Z Verdict: quoted answer\n\nWhich one?\n\nREADME.md's Goals and Audience, AGENTS.md, docs/decisions.md, ~/.claude/CLAUDE.md, ~/.claude/rules/ or ~/.claude/skills/larv-review/standards/ says:\n> Use *A*.\n\nEvidence:\n> working\n\nJudge: judge-model\nWorker: worker-model\n" self.assertEqual(self.archived_outcomes(), [f"Task: Do it.\n\n2026-09-21T14:13:20Z Verdict: interrupt\n\nWhich one?\n\nREADME.md's Goals and Audience, AGENTS.md, docs/decisions.md, ~/.claude/CLAUDE.md, ~/.claude/rules/ or ~/.claude/skills/larv-review/standards/ says:\nUse *A*.\n\nThose files have answered 3 questions this cycle, the most allowed, so this one comes to you.\n\nEvidence:\n> working\n\nJudge: judge-model\nWorker: worker-model\n\n2026-09-21T14:13:20Z Stopped: the human is needed to answer the question above, but the interrupt ended with nothing typed\n\nWorker: worker-model\n", *[f"Task: Do it.\n\n{quoted}"] * 3]) + def test_a_quoted_answer_that_cites_an_escalation_trigger_steps_the_worker_up_before_it_resumes_and_archives_the_step(self): + fake = FakeEffects(streams=[Worker(self.paths.claude_code_transcripts.parent)] * 2, claude=[judged("quoted", answer="Use A.", escalation="working"), judged("finished")]) + cycle = dataclasses.replace(self.cycle(fake, records="From AGENTS.md:\nUse A."), anchor=Routing.OPUS, route=Route(Routing.SONNET, 179, 2, 5)) + with contextlib.redirect_stdout(io.StringIO()): + concluded = run.run_cycle(cycle) + 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"]) + 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" + kept = "".join(self.archived_outcomes()) + self.assertIn(f"Z {answered}\n20", kept) + self.assertIn(f"Z {stepped}", kept) + def test_stops_when_a_quoted_answer_cannot_be_archived(self): self.archive.parent.mkdir(parents=True) self.archive.write_text("") @@ -1097,6 +1111,17 @@ class Verdict(unittest.TestCase): self.assertEqual(judge.quotes_checked(Interrupt("e", "q", "round 2: … 🔴"), shown, ""), Interrupt("e", "q")) self.assertEqual(judge.quotes_checked(Unfinished("e", 0, "round 3: 🔴"), shown, ""), Unfinished("e")) + def test_takes_an_escalation_quote_and_a_bundled_l_on_a_quoted_answer(self): + reply = {"answer": "A.", "bundled": 4, "bundled_escape_and_impact": 0, "escalation": "round 2: 🔴", "interrupt": False, "evidence": "e", "finished": False, "question": "Which one?"} + self.assertEqual(verdict_from(reply), QuotedAnswer("e", "Which one?", "A.", "round 2: 🔴", 4)) + self.assertEqual(verdict_from({**reply, "bundled": 5}), QuotedAnswer("e", "Which one?", "A.", "round 2: 🔴")) + + def test_drops_an_escalation_quote_the_transcript_does_not_hold_word_for_word_from_a_quoted_answer(self): + shown = "The agent: round 2: 🔴. Which one?" + self.assertEqual(judge.quotes_checked(QuotedAnswer("e", "q", "A.", "round 2: 🔴"), shown, "A."), QuotedAnswer("e", "q", "A.", "round 2: 🔴")) + self.assertEqual(judge.quotes_checked(QuotedAnswer("e", "q", "A.", "round 2: … 🔴"), shown, "A."), QuotedAnswer("e", "q", "A.")) + self.assertEqual(judge.quotes_checked(QuotedAnswer("e", "q", "not there", "round 2: 🔴", 4), shown, "A."), Interrupt("e", "q", "round 2: 🔴", 4)) + def test_puts_a_quoted_answer_the_records_do_not_hold_word_for_word_to_the_human(self): self.assertEqual(judge.quotes_checked(QuotedAnswer("e", "q", "not there"), "shown", "the records"), Interrupt("e", "q")) self.assertEqual(judge.quotes_checked(QuotedAnswer("e", "q", "the records"), "shown", "From the records: the records"), QuotedAnswer("e", "q", "the records")) @@ -1104,6 +1129,7 @@ class Verdict(unittest.TestCase): def test_drops_an_escalation_from_every_ruling_of_a_cycle_once_an_interrupt_took_one(self): self.assertEqual(run.unspent(Unfinished("e", 0, "round 2: 🔴"), True), Unfinished("e")) self.assertEqual(run.unspent(Interrupt("e", "q", "another passage"), True), Interrupt("e", "q")) + self.assertEqual(run.unspent(QuotedAnswer("e", "q", "A.", "another passage"), True), QuotedAnswer("e", "q", "A.")) self.assertEqual(run.unspent(Unfinished("e", 0, "round 2: 🔴"), False), Unfinished("e", 0, "round 2: 🔴")) diff --git a/bin/transcript_archive/outcomes.py b/bin/transcript_archive/outcomes.py index fa5811ef..fa1abcbf 100644 --- a/bin/transcript_archive/outcomes.py +++ b/bin/transcript_archive/outcomes.py @@ -16,9 +16,9 @@ FINISHED_AT = re.compile(rf"^({STAMPED}) {re.escape(FINISHED)}$", re.MULTILINE) UNFINISHED_AT = re.compile(rf"^{STAMPED} {re.escape(UNFINISHED)}$", re.MULTILINE) # A verdict closes each cycle the judge ruled on; an interrupt or a stop closes none. VERDICT_AT = re.compile(rf"^{STAMPED} (?:{re.escape(FINISHED)}|{re.escape(UNFINISHED)})$", re.MULTILINE) -# An outcome opens with its UTC stamp; a verdict that closes a cycle, an interrupt, a stop, or a step up ends with the worker line. +# An outcome opens with its UTC stamp; a verdict that closes a cycle, an interrupt, a quoted answer, a stop, or a step up ends with the worker line. OUTCOME_AT = re.compile(rf"^({STAMPED}) ", re.MULTILINE) -NAMES_A_WORKER = ("Verdict: finished\n", "Verdict: unfinished\n", "Verdict: interrupt\n", "Stopped: ", "Stepped up\n") +NAMES_A_WORKER = ("Verdict: finished\n", "Verdict: unfinished\n", "Verdict: interrupt\n", "Verdict: quoted answer\n", "Stopped: ", "Stepped up\n") WORKER = "Worker: " # The rung that judged a verdict. JUDGE = "Judge: " @@ -40,8 +40,10 @@ def interrupted(question: str, evidence: str, judge: str, escalation: str, worke return f"{INTERRUPTED}\n\n{question}\n\nEvidence:\n{quoted(evidence)}\n\n{escalated}{JUDGE}{judge}\n{WORKER}{worker}" -def answered(question: str, sources: str, answer: str, evidence: str, judge: str) -> str: - return f"{ANSWERED}\n\n{question}\n\n{sources} says:\n{quoted(answer)}\n\nEvidence:\n{quoted(evidence)}\n\n{JUDGE}{judge}" +def answered(question: str, sources: str, answer: str, evidence: str, escalation: str, judge: str, worker: str) -> str: + """escalation and worker are as on interrupted.""" + escalated = f"Escalation:\n{quoted(escalation)}\n\n" if escalation else "" + return f"{ANSWERED}\n\n{question}\n\n{sources} says:\n{quoted(answer)}\n\nEvidence:\n{quoted(evidence)}\n\n{escalated}{JUDGE}{judge}\n{WORKER}{worker}" def rejected(why: str, reply: str, judge: str) -> str: diff --git a/bin/transcript_archive/test_transcript_archive.py b/bin/transcript_archive/test_transcript_archive.py index 2f09f32c..5aa4d496 100644 --- a/bin/transcript_archive/test_transcript_archive.py +++ b/bin/transcript_archive/test_transcript_archive.py @@ -64,10 +64,16 @@ class Outcomes(unittest.TestCase): self.assertEqual(outcomes.interrupted("q?", "e", "j", "round 2: 🔴", "w"), "Verdict: interrupt\n\nq?\n\nEvidence:\n> e\n\nEscalation:\n> round 2: 🔴\n\nJudge: j\nWorker: w") self.assertEqual(outcomes.interrupted("q?", "e", "j", "", "w"), "Verdict: interrupt\n\nq?\n\nEvidence:\n> e\n\nJudge: j\nWorker: w") + def test_archives_the_escalation_and_the_worker_a_quoted_answer_names(self): + self.assertEqual(outcomes.answered("q?", "AGENTS.md", "A.", "e", "round 2: 🔴", "j", "w"), "Verdict: quoted answer\n\nq?\n\nAGENTS.md says:\n> A.\n\nEvidence:\n> e\n\nEscalation:\n> round 2: 🔴\n\nJudge: j\nWorker: w") + self.assertEqual(outcomes.answered("q?", "AGENTS.md", "A.", "e", "", "j", "w"), "Verdict: quoted answer\n\nq?\n\nAGENTS.md says:\n> A.\n\nEvidence:\n> e\n\nJudge: j\nWorker: w") + self.assertEqual(outcomes.workers(f"{utc(NOW)} {outcomes.answered('q?', 'AGENTS.md', 'A.', 'e', '', 'j', 'w')}\n"), [(utc(NOW), "w")]) + def test_reads_no_worker_from_an_outcome_written_before_the_worker_line(self): kept = f"Task: Do it.\n\n{utc(NOW)} Stopped: Ctrl-C\n\n{utc(NOW)} Verdict: unfinished\n\nEvidence:\n> Worker: no\n" self.assertEqual(outcomes.workers(kept), []) self.assertEqual(outcomes.workers(f"{utc(NOW)} {outcomes.stepped_up('w')}\n"), [(utc(NOW), "w")]) + self.assertEqual(outcomes.workers(f"{utc(NOW)} Verdict: quoted answer\n\nq?\n\nAGENTS.md says:\n> A.\n\nEvidence:\n> e\n\nJudge: j\n"), []) def test_takes_the_outcome_written_last_within_one_second(self): with tempfile.TemporaryDirectory() as root: diff --git a/docs/decisions.md b/docs/decisions.md index fb1e291b..f0cdbfc5 100644 --- a/docs/decisions.md +++ b/docs/decisions.md @@ -290,11 +290,11 @@ Valid while the ladder orders its rungs by competence. 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. -A run that asks for a higher rung may also ask the human something only they can answer. The judge then interrupts, and the interrupt carries the quote too, checked the same way. loop-claude steps the rung as the interrupt comes in, before the human is asked, since the human's answer is followed by work the stepped rung should do: in the session the interrupt opens, and in whatever run resumes with the answer. An interrupt 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 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 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. 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 or the interrupt. The step an unfinished verdict causes is archived after it. The step an interrupt causes is archived with it, at once: the interrupt 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 neither 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/docs/reading-cost.md b/docs/reading-cost.md index f31e1933..5ae353ef 100644 --- a/docs/reading-cost.md +++ b/docs/reading-cost.md @@ -624,3 +624,11 @@ Read most (opens and searches): ## Reading cost, chunk 819681d5ebae, finished 2026-10-17T19:47:42Z 98148 new input tokens before the first commit. + +## Reading cost, chunk 3721394862b1, finished 2026-10-17T20:18:33Z + +133110 new input tokens before the first commit. + +Read most (opens and searches): + +- `rules/todo-items.md` 1 diff --git a/todo.md b/todo.md index baaee3a0..82972764 100644 --- a/todo.md +++ b/todo.md @@ -12,7 +12,6 @@ | ID | Release | Blocked by | Exempt | Item | L | E | I | R | S | Moves | Score | |---|---|---|---|---|---|---|---|---|---|---|---| -| 179 | 0.2.0 | | defect | **Step the worker one rung up when the judge quotes an answer from the README or the records and the run also cites an escalation trigger, as it does on an interrupt.** | 2 | 2 | 3 | 5 | 4 | 1.3 by 3, 1.1 by 2 | 7.3 | | 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,10 +83,6 @@ ## Details -### 179. Step the worker one rung up when the judge quotes an answer from the README or the records and the run also cites an escalation trigger, as it does on an interrupt. - -A defect against goal 1.3, the same rules in every session, and a sibling of the interrupt case the previous chunk fixed (`docs/decisions.md` → `routing: a worker whose run ends asking for a higher rung…`). `verdict_from` in `bin/loop_claude/cycle/judge.py` builds a `QuotedAnswer` without the reply's `escalation`, so a run that asks a question the README or the records answer, and also asks loop-claude for a higher rung, loses the step: the worker resumes with the quoted answer in the same cycle on its old rung, and cannot ask again because a step-up needs a trigger that fired since its last request. Have `QuotedAnswer` carry the escalation and the bundled L, check it word for word as on an interrupt, and step the route as the answer is quoted, before the worker resumes (`bin/loop_claude/cycle/run.py` `escalated`). The same limits hold: one rung, at most two above the item's rung, one step per trigger per cycle, and the step is archived with the quoted-answer outcome as an interrupt's is. Found by the stability review of PR #305. - ### 168. 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. 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. -- 2.52.0 From 5b536afdf9b49cc0b82eb454dadadc96997cec6e Mon Sep 17 00:00:00 2001 From: Lilleman auf Larv Date: Sat, 17 Oct 2026 22:37:11 +0200 Subject: [PATCH 2/7] =?UTF-8?q?Answer=20stability=20round=201:=200=20?= =?UTF-8?q?=F0=9F=94=B4,=205=20=F0=9F=9F=A1;=20tell=20the=20resumed=20work?= =?UTF-8?q?er=20its=20stepped=20rung,=20rename=20the=20step=20for=20ruling?= =?UTF-8?q?s,=20build=20NAMES=5FA=5FWORKER=20from=20the=20verdict=20consta?= =?UTF-8?q?nts,=20and=20test=20the=20capped=20answer=20and=20a=20failed=20?= =?UTF-8?q?interrupt=20archive?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- bin/loop_claude/cycle/prompts.py | 13 +++++++--- bin/loop_claude/cycle/run.py | 8 +++--- bin/loop_claude/loop/main.py | 8 +++--- bin/loop_claude/routing.py | 4 +-- bin/loop_claude/test_loop_claude.py | 38 +++++++++++++++++++++++------ bin/transcript_archive/outcomes.py | 12 ++++++--- docs/decisions.md | 2 +- todo.md | 16 ++++++++++-- 8 files changed, 73 insertions(+), 28 deletions(-) diff --git a/bin/loop_claude/cycle/prompts.py b/bin/loop_claude/cycle/prompts.py index b40bb8ba..87f3574d 100644 --- a/bin/loop_claude/cycle/prompts.py +++ b/bin/loop_claude/cycle/prompts.py @@ -115,11 +115,18 @@ def resumed(unfinished_evidence: str, route: Route, anchor: Rung | None) -> str: """Names the worker's rung, so it learns whether its request for a higher rung went through, and the project's again, since a step-up between cycles may have taken the worker above it.""" on = f" loop-claude runs you on {route.rung}." if anchor else "" 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}.{on}{review_launches(route, anchor)}{escalation(route, anchor)}{reruns(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}.{on}{rungs_held(route, anchor)}" -def answered(question: str, answer: str) -> str: - return f"Your question: {question}\n\n{QUOTE_SOURCES} answers it:\n\n{answer}\n\nContinue the task." +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.""" + 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 "" + return f"Your question: {question}\n\n{QUOTE_SOURCES} answers it:\n\n{answer}\n\nContinue the task.{on}" def past_the_cap(question: str, answer: str, cap: int) -> str: diff --git a/bin/loop_claude/cycle/run.py b/bin/loop_claude/cycle/run.py index 8f7ceba7..a8fbf43a 100644 --- a/bin/loop_claude/cycle/run.py +++ b/bin/loop_claude/cycle/run.py @@ -9,7 +9,7 @@ from loop_claude.effects import Effects from failure import Failure from loop_claude.cycle.judge import Finished, Interrupt, judge, QuotedAnswer, Rejected, Unfinished, Verdict from loop_claude.cycle.interrupt import interrupt -from loop_claude.routing import judge_rung, stepped_by_interrupt +from loop_claude.routing import judge_rung, stepped_by_ruling from transcript_archive import outcomes from loop_claude.paths import Paths from loop_claude.cycle import prompts @@ -49,7 +49,7 @@ class Cycle: @dataclasses.dataclass(frozen=True) class Concluded: - """How a cycle ended: its verdict, and the route it ended on, which an interrupt's escalation may have stepped up from the route it began on.""" + """How a cycle ended: its verdict, and the route it ended on, which an interrupt's or a quoted answer's escalation may have stepped up from the route it began on.""" verdict: Finished | Unfinished route: Route @@ -73,7 +73,7 @@ def escalated(cycle: Cycle, event: Event) -> Cycle: cycle = dataclasses.replace(cycle, stepped_from=None) if not (isinstance(event, Ruled) and isinstance(event.verdict, Interrupt | QuotedAnswer) and event.verdict.escalation): return cycle - route = stepped_by_interrupt(cycle.anchor, cycle.route, event.verdict.bundled) if cycle.anchor else cycle.route + route = stepped_by_ruling(cycle.anchor, cycle.route, event.verdict.bundled) if cycle.anchor else cycle.route return dataclasses.replace(cycle, route=route, stepped_from=cycle.route if route != cycle.route else None, escalation_spent=True) @@ -122,7 +122,7 @@ def worker_environment(cycle: Cycle) -> dict[str, str]: def worker_start(cycle: Cycle, answered: QuotedAnswer | None) -> list[str]: if answered is not None: - return worker_args(cycle.session, cycle.route.rung, prompts.answered(answered.question, answered.answer), resume=True) + return worker_args(cycle.session, cycle.route.rung, prompts.answered(answered.question, answered.answer, cycle.route, cycle.anchor, cycle.stepped_from is not None), resume=True) if session_open(cycle.session): return worker_args(cycle.session, cycle.route.rung, prompts.resumed(cycle.unfinished_evidence, cycle.route, cycle.anchor), resume=True) return worker_args(cycle.session, cycle.route.rung, prompts.fresh(cycle.task, cycle.premises, cycle.route, cycle.anchor, cycle.facts), resume=False) diff --git a/bin/loop_claude/loop/main.py b/bin/loop_claude/loop/main.py index 07201188..6398f278 100644 --- a/bin/loop_claude/loop/main.py +++ b/bin/loop_claude/loop/main.py @@ -37,7 +37,7 @@ 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; each judge reply the loop rejected, with the reason and the reply as json; +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 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 @@ -83,9 +83,9 @@ 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_interrupt), and no later ruling of that cycle carries a second escalation. Either step stops two rungs +(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, stop and step-up in the archive names the +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 @@ -226,7 +226,7 @@ def run_loop(argv: list[str], env: typing.Mapping[str, str], paths: Paths, launc concluded = run_cycle(Cycle(anchor=anchor, effects=effects, facts=facts, judge_model=models.judge, paths=paths, premises=premises, project_archive=archive_folder, records=records, root=loop_run.root, route=route, session=session, task=loop_run.task, unfinished_evidence=loop_run.unfinished_evidence)) if isinstance(concluded, Stop): return concluded - # The route the cycle ended on, which a step-up at an interrupt may have raised and archived, is the one the verdict steps from. + # The route the cycle ended on, which a step-up at an interrupt or a quoted answer may have raised and archived, is the one the verdict steps from. ended = dataclasses.replace(loop_run, route=concluded.route if anchor else None) before, loop_run = ended.route, after_verdict(ended, anchor, concluded.verdict) if stop := archive_step(archive_folder, session, loop_run, before, effects): diff --git a/bin/loop_claude/routing.py b/bin/loop_claude/routing.py index 2eb463c3..419d469f 100644 --- a/bin/loop_claude/routing.py +++ b/bin/loop_claude/routing.py @@ -71,8 +71,8 @@ def stepped(anchor: Rung, route: Route, bundled: int, escalated: bool) -> Route: return dataclasses.replace(route, rung=rung, unfinished=unfinished) -def stepped_by_interrupt(anchor: Rung, route: Route, bundled: int) -> Route: - """The route after the judge's interrupt carried an escalation: taken_in's rung, one rung up while that is below escalation_cap. An interrupt is no unfinished verdict, so the count of those restarts only with a step.""" +def stepped_by_ruling(anchor: Rung, route: Route, bundled: int) -> Route: + """The route after the judge's interrupt or quoted answer carried an escalation: taken_in's rung, one rung up while that is below escalation_cap. Neither is an unfinished verdict, so the count of those restarts only with a step.""" rung = taken_in(anchor, route, bundled) return stepped_from(route, rung) if below_cap(anchor, route, rung) else dataclasses.replace(route, rung=rung) diff --git a/bin/loop_claude/test_loop_claude.py b/bin/loop_claude/test_loop_claude.py index caea0c14..7aaf77bb 100644 --- a/bin/loop_claude/test_loop_claude.py +++ b/bin/loop_claude/test_loop_claude.py @@ -345,12 +345,32 @@ 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.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" kept = "".join(self.archived_outcomes()) self.assertIn(f"Z {answered}\n20", kept) self.assertIn(f"Z {stepped}", kept) + def test_a_quoted_answer_past_the_cap_archives_the_escalation_it_carried_with_the_interrupt_and_steps_up(self): + steps = [judged("quoted", answer="Use A.")] * 3 + [judged("quoted", answer="Use A.", escalation="working")] + fake = FakeEffects(streams=[Worker(self.paths.claude_code_transcripts.parent)] * 4, claude=steps, on_terminal_claude=[0], git=[ran()]) + cycle = dataclasses.replace(self.cycle(fake, records="From AGENTS.md:\nUse A."), anchor=Routing.OPUS, route=Route(Routing.SONNET, 179, 2, 5)) + with contextlib.redirect_stdout(io.StringIO()), contextlib.redirect_stderr(io.StringIO()): + self.assertEqual(run.run_cycle(cycle), Stop(2, "the human is needed to answer the question above, but the interrupt ended with nothing typed")) + kept = "".join(self.archived_outcomes()) + self.assertIn(f"Evidence:\n> working\n\nEscalation:\n> working\n\nJudge: judge-model\nWorker: {Route(Routing.SONNET, 179, 2, 5)}\n", kept) + self.assertIn(f"Stepped up\n\nWorker: {Route(Routing.OPUS, 179, 2, 5)}\n", kept) + + def test_stops_when_an_interrupt_cannot_be_archived(self): + self.archive.parent.mkdir(parents=True) + self.archive.write_text("") + fake = FakeEffects(streams=[Worker(self.paths.claude_code_transcripts.parent)], claude=[judged("interrupt")], on_terminal_claude=[0]) + stop = run.run_cycle(self.cycle(fake)) + self.assertRegex(stop.reason, f"^could not archive the transcript: {self.archive}/[0-9a-f]{{64}}: Not a directory$") + self.assertEqual(fake.made("claude_on_terminal"), []) + def test_stops_when_a_quoted_answer_cannot_be_archived(self): self.archive.parent.mkdir(parents=True) self.archive.write_text("") @@ -660,15 +680,15 @@ class Routing(unittest.TestCase): self.assertEqual(routing.stepped(self.OPUS, Route(self.SONNET, 3, 2, 4), 4, True), Route(self.HIGH, 3, 2, 4, unfinished=1)) def test_steps_up_a_rung_as_the_judge_interrupts_up_to_two_above_the_items_rung_without_counting_an_unfinished_verdict(self): - self.assertEqual(routing.stepped_by_interrupt(self.OPUS, Route(self.HIGH, 3, 4, 5, unfinished=1), 0), Route(self.XHIGH, 3, 4, 5)) - self.assertEqual(routing.stepped_by_interrupt(self.OPUS, Route(self.XHIGH, 3, 4, 5), 0), Route(self.MAX, 3, 4, 5)) - self.assertEqual(routing.stepped_by_interrupt(self.OPUS, Route(self.MAX, 3, 4, 5, unfinished=1), 0), Route(self.MAX, 3, 4, 5, unfinished=1)) - self.assertEqual(routing.stepped_by_interrupt(self.OPUS, Route(self.SONNET, 3, 2, 4), 0), Route(self.OPUS, 3, 2, 4)) + self.assertEqual(routing.stepped_by_ruling(self.OPUS, Route(self.HIGH, 3, 4, 5, unfinished=1), 0), Route(self.XHIGH, 3, 4, 5)) + self.assertEqual(routing.stepped_by_ruling(self.OPUS, Route(self.XHIGH, 3, 4, 5), 0), Route(self.MAX, 3, 4, 5)) + self.assertEqual(routing.stepped_by_ruling(self.OPUS, Route(self.MAX, 3, 4, 5, unfinished=1), 0), Route(self.MAX, 3, 4, 5, unfinished=1)) + self.assertEqual(routing.stepped_by_ruling(self.OPUS, Route(self.SONNET, 3, 2, 4), 0), Route(self.OPUS, 3, 2, 4)) def test_steps_up_from_the_rung_a_taken_in_item_picks_as_the_judge_interrupts(self): - self.assertEqual(routing.stepped_by_interrupt(self.OPUS, Route(self.OPUS, 3, 3, 4), 4), Route(self.XHIGH, 3, 3, 4)) - self.assertEqual(routing.stepped_by_interrupt(self.OPUS, Route(self.XHIGH, 3, 4, 5), 4), Route(self.MAX, 3, 4, 5)) - self.assertEqual(routing.stepped_by_interrupt(self.OPUS, Route(self.MAX, 3, 4, 5, unfinished=1), 4), Route(self.MAX, 3, 4, 5, unfinished=1)) + self.assertEqual(routing.stepped_by_ruling(self.OPUS, Route(self.OPUS, 3, 3, 4), 4), Route(self.XHIGH, 3, 3, 4)) + self.assertEqual(routing.stepped_by_ruling(self.OPUS, Route(self.XHIGH, 3, 4, 5), 4), Route(self.MAX, 3, 4, 5)) + self.assertEqual(routing.stepped_by_ruling(self.OPUS, Route(self.MAX, 3, 4, 5, unfinished=1), 4), Route(self.MAX, 3, 4, 5, unfinished=1)) def test_keeps_an_e_plus_i_taken_in_only_where_it_picks_a_higher_review_rung(self): taken = Route(self.OPUS, 3, 3, 4).taking_in(6) @@ -1120,7 +1140,9 @@ class Verdict(unittest.TestCase): shown = "The agent: round 2: 🔴. Which one?" self.assertEqual(judge.quotes_checked(QuotedAnswer("e", "q", "A.", "round 2: 🔴"), shown, "A."), QuotedAnswer("e", "q", "A.", "round 2: 🔴")) self.assertEqual(judge.quotes_checked(QuotedAnswer("e", "q", "A.", "round 2: … 🔴"), shown, "A."), QuotedAnswer("e", "q", "A.")) - self.assertEqual(judge.quotes_checked(QuotedAnswer("e", "q", "not there", "round 2: 🔴", 4), shown, "A."), Interrupt("e", "q", "round 2: 🔴", 4)) + + def test_puts_a_quoted_answer_the_records_do_not_hold_to_the_human_with_the_escalation_it_carried(self): + self.assertEqual(judge.quotes_checked(QuotedAnswer("e", "q", "not there", "round 2: 🔴", 4), "The agent: round 2: 🔴.", "A."), Interrupt("e", "q", "round 2: 🔴", 4)) def test_puts_a_quoted_answer_the_records_do_not_hold_word_for_word_to_the_human(self): self.assertEqual(judge.quotes_checked(QuotedAnswer("e", "q", "not there"), "shown", "the records"), Interrupt("e", "q")) diff --git a/bin/transcript_archive/outcomes.py b/bin/transcript_archive/outcomes.py index fa1abcbf..7ca18946 100644 --- a/bin/transcript_archive/outcomes.py +++ b/bin/transcript_archive/outcomes.py @@ -18,31 +18,35 @@ UNFINISHED_AT = re.compile(rf"^{STAMPED} {re.escape(UNFINISHED)}$", re.MULTILINE VERDICT_AT = re.compile(rf"^{STAMPED} (?:{re.escape(FINISHED)}|{re.escape(UNFINISHED)})$", re.MULTILINE) # An outcome opens with its UTC stamp; a verdict that closes a cycle, an interrupt, a quoted answer, a stop, or a step up ends with the worker line. OUTCOME_AT = re.compile(rf"^({STAMPED}) ", re.MULTILINE) -NAMES_A_WORKER = ("Verdict: finished\n", "Verdict: unfinished\n", "Verdict: interrupt\n", "Verdict: quoted answer\n", "Stopped: ", "Stepped up\n") +NAMES_A_WORKER = (*(f"{verdict}\n" for verdict in (FINISHED, UNFINISHED, INTERRUPTED, ANSWERED)), "Stopped: ", "Stepped up\n") WORKER = "Worker: " # The rung that judged a verdict. JUDGE = "Judge: " +def escalation_block(escalation: str) -> str: + return f"Escalation:\n{quoted(escalation)}\n\n" if escalation else "" + + def finished(worker: str, evidence: str, judge: str) -> str: return f"{FINISHED}\n\nEvidence:\n{quoted(evidence)}\n\n{JUDGE}{judge}\n{WORKER}{worker}" def unfinished(worker: str, evidence: str, judge: str, escalation: str) -> str: """escalation is the judge's quote showing that the worker's cited escalation trigger fired; empty for none.""" - escalated = f"Escalation:\n{quoted(escalation)}\n\n" if escalation else "" + escalated = escalation_block(escalation) return f"{UNFINISHED}\n\nEvidence:\n{quoted(evidence)}\n\n{escalated}{JUDGE}{judge}\n{WORKER}{worker}" def interrupted(question: str, evidence: str, judge: str, escalation: str, worker: str) -> str: """escalation is the judge's quote showing that the worker's cited escalation trigger fired; empty for none. worker is the rung the worker ran on until the interrupt.""" - escalated = f"Escalation:\n{quoted(escalation)}\n\n" if escalation else "" + escalated = escalation_block(escalation) return f"{INTERRUPTED}\n\n{question}\n\nEvidence:\n{quoted(evidence)}\n\n{escalated}{JUDGE}{judge}\n{WORKER}{worker}" def answered(question: str, sources: str, answer: str, evidence: str, escalation: str, judge: str, worker: str) -> str: """escalation and worker are as on interrupted.""" - escalated = f"Escalation:\n{quoted(escalation)}\n\n" if escalation else "" + escalated = escalation_block(escalation) return f"{ANSWERED}\n\n{question}\n\n{sources} says:\n{quoted(answer)}\n\nEvidence:\n{quoted(evidence)}\n\n{escalated}{JUDGE}{judge}\n{WORKER}{worker}" diff --git a/docs/decisions.md b/docs/decisions.md index f0cdbfc5..8bc93a44 100644 --- a/docs/decisions.md +++ b/docs/decisions.md @@ -288,7 +288,7 @@ Valid while the ladder orders its rungs by competence. 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. +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. 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. diff --git a/todo.md b/todo.md index 82972764..d8828c72 100644 --- a/todo.md +++ b/todo.md @@ -6,12 +6,13 @@ `Bar = 0.1` -`Next ID = 180` +`Next ID = 181` ## Items | 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 | | 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 | @@ -83,11 +84,22 @@ ## 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. + +`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. + +Options: + +- Clear `escalation_spent` when a worker run ends. Risk: the judge may quote a different passage for the trigger that already stepped the rung, and loop-claude cannot tell, so one trigger could buy two steps. +- Tell the worker in its next prompt that its request was dropped, and why. + +Only the human can choose, and the answer revises that decision. Found by the stability review of PR #307. + ### 168. 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. 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. +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. ### 73. Have each reviewer write its full report to a file and return the worker only its findings' one-line summaries. -- 2.52.0 From 24173eb17f842f2642187729cae32353ec6dcb83 Mon Sep 17 00:00:00 2001 From: Lilleman auf Larv Date: Sat, 17 Oct 2026 22:37:11 +0200 Subject: [PATCH 3/7] =?UTF-8?q?Answer=20principles=20round=201:=200=20?= =?UTF-8?q?=F0=9F=94=B4,=202=20=F0=9F=9F=A1;=20fixed=20in=20the=20previous?= =?UTF-8?q?=20commit?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit -- 2.52.0 From 2890399e45b61e54b2505a686fbdb0d61e20481e Mon Sep 17 00:00:00 2001 From: Lilleman auf Larv Date: Sat, 17 Oct 2026 22:37:11 +0200 Subject: [PATCH 4/7] =?UTF-8?q?Answer=20security=20round=201:=200=20?= =?UTF-8?q?=F0=9F=94=B4,=200=20=F0=9F=9F=A1;=20no=20finding?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit -- 2.52.0 From 528eee19960a31a151e37aca13d04a6cbf5fdf67 Mon Sep 17 00:00:00 2001 From: Lilleman auf Larv Date: Sat, 17 Oct 2026 22:44:03 +0200 Subject: [PATCH 5/7] =?UTF-8?q?Answer=20prose=20round=201:=200=20?= =?UTF-8?q?=F0=9F=94=B4,=205=20=F0=9F=9F=A1;=20retitle=20the=20decision=20?= =?UTF-8?q?for=20quoted=20answers,=20say=20what=20a=20later=20trigger=20do?= =?UTF-8?q?es,=20split=20the=20long=20sentences,=20and=20warn=20the=20step?= =?UTF-8?q?ped=20worker=20that=20a=20further=20request=20steps=20nothing?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- AGENTS.md | 2 +- CHANGELOG.md | 2 +- bin/loop_claude/cycle/prompts.py | 4 ++-- bin/loop_claude/cycle/run.py | 2 +- bin/loop_claude/loop/main.py | 15 ++++++++------- bin/loop_claude/test_loop_claude.py | 2 +- docs/decisions.md | 8 ++++---- todo.md | 8 ++++---- 8 files changed, 22 insertions(+), 21 deletions(-) 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. -- 2.52.0 From 4e1df2769876fd3bd2dfb62cef144dcca3c7589e Mon Sep 17 00:00:00 2001 From: Lilleman auf Larv Date: Sat, 17 Oct 2026 22:44:03 +0200 Subject: [PATCH 6/7] =?UTF-8?q?Answer=20principles=20round=202:=200=20?= =?UTF-8?q?=F0=9F=94=B4,=200=20=F0=9F=9F=A1;=20both=20auditors=20approved?= =?UTF-8?q?=20the=20answers?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit -- 2.52.0 From 81a07fe685f733dd779819cf9c2bf450065fc303 Mon Sep 17 00:00:00 2001 From: Lilleman auf Larv Date: Sat, 17 Oct 2026 22:44:03 +0200 Subject: [PATCH 7/7] =?UTF-8?q?Answer=20stability=20round=202:=200=20?= =?UTF-8?q?=F0=9F=94=B4,=200=20=F0=9F=9F=A1;=20the=20reviewer=20approved?= =?UTF-8?q?=20the=20answers?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit -- 2.52.0