Answer principles round 1: 1 🔴, 2 🟡; name the worker's rung on an interrupt and archive its step-up at once, step from the taken-in item, drop every escalation after the first step of a cycle, and state stepped's rules once

This commit is contained in:
2026-10-17 22:10:33 +02:00
parent 1c503e8818
commit 602a5fac16
12 changed files with 86 additions and 54 deletions
+1 -1
View File
@@ -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 obeys the same limits as before, and the verdict after the interrupt steps nothing on the same quote.
- `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 obeys the same limits as before, and no later ruling in that cycle steps it again. The archive's interrupt outcome now names 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.
+5 -3
View File
@@ -89,6 +89,8 @@ class Interrupt:
question: str
# The judge's quote showing that the worker's cited escalation trigger fired; empty for none.
escalation: str = ""
# The bundled L the judge saw, 0 for none, as on Unfinished: an escalation steps up from the rung that item picks.
bundled: int = 0
@dataclasses.dataclass(frozen=True)
@@ -125,18 +127,18 @@ def verdict_from(output: object) -> Verdict | Failure:
# type(), not isinstance(): JSON true is no integer.
if type(output.get(name)) is not kind:
return Failure(f"the judge's reply has no {name} of type {JSON_TYPES[kind]}")
# A bundled level off its scale counts as none: holding the rung is safe, and three failures would stop an unattended loop.
bundled = output["bundled"] if 0 <= output["bundled"] <= HIGHEST_L else 0
if output["interrupt"]:
if not output["question"].strip():
return Failure("the judge interrupted without a question")
return Interrupt(output["evidence"], output["question"], output["escalation"])
return Interrupt(output["evidence"], output["question"], output["escalation"], bundled)
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"])
if output["finished"]:
return Finished(output["evidence"])
# A bundled level off its scale counts as none: holding the rung is safe, and three failures would stop an unattended loop.
bundled = output["bundled"] if 0 <= output["bundled"] <= HIGHEST_L else 0
bundled_escape_and_impact = output["bundled_escape_and_impact"] if on_its_scale(output["bundled_escape_and_impact"]) else 0
return Unfinished(output["evidence"], bundled, output["escalation"], bundled_escape_and_impact)
+18 -11
View File
@@ -7,7 +7,7 @@ from transcript_archive.write import archive
from claude_code.session import delete_session, Session, session_open, transcript_file
from loop_claude.effects import Effects
from failure import Failure
from loop_claude.cycle.judge import Finished, Interrupt, judge, plain, QuotedAnswer, Rejected, Unfinished, Verdict
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 transcript_archive import outcomes
@@ -40,8 +40,11 @@ class Cycle:
anchor: Rung | None
# Empty when the previous cycle's verdict was not Unfinished.
unfinished_evidence: str
# The judge's quote that stepped the route up as an interrupt; a later ruling quoting it again steps nothing.
escalation_spent: str = ""
# The route changes within a cycle only as an interrupt carries an escalation, and no transition reads it 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.
stepped_from: Route | None = None
# Whether an interrupt of this cycle took an escalation, after which no ruling of the cycle carries one.
escalation_spent: bool = False
@dataclasses.dataclass(frozen=True)
@@ -66,11 +69,12 @@ def run_cycle(cycle: Cycle) -> Stop | Concluded:
def escalated(cycle: Cycle, event: Event) -> Cycle:
"""The cycle after the judge interrupted with an escalation: its route stepped up before the human is asked, so the work after the answer runs on it."""
"""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."""
cycle = dataclasses.replace(cycle, stepped_from=None)
if not (isinstance(event, Ruled) and isinstance(event.verdict, Interrupt) and event.verdict.escalation):
return cycle
route = stepped_by_interrupt(cycle.anchor, cycle.route) if cycle.anchor else cycle.route
return dataclasses.replace(cycle, route=route, escalation_spent=event.verdict.escalation)
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)
def stopped(cycle: Cycle, stop: Stop, why: str) -> Stop:
@@ -139,9 +143,9 @@ def rule(cycle: Cycle, transcript_path: str) -> Ruled | Stop:
return verdict if isinstance(verdict, Stop) else Ruled(unspent(verdict, cycle.escalation_spent))
def unspent(verdict: Verdict, spent: str) -> Verdict:
"""The verdict without an escalation that already stepped the route as an interrupt, so one trigger buys one step."""
if isinstance(verdict, Interrupt | Unfinished) and verdict.escalation and plain(verdict.escalation) == plain(spent):
def unspent(verdict: Verdict, spent: bool) -> Verdict:
"""The verdict without its escalation once an interrupt of the cycle took one. The judge may quote another passage for the trigger that stepped the route, which no comparison of quotes can tell, 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:
return dataclasses.replace(verdict, escalation="")
return verdict
@@ -156,8 +160,11 @@ def keep_rejection(cycle: Cycle, transcript_path: str, rejected: Rejected) -> St
def ask(cycle: Cycle, transcript_path: str, ruling: Interrupt | QuotedAnswer) -> HumanAnswered | Stop:
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.
if failure := archive(cycle.project_archive, transcript_path, cycle.task, outcomes.interrupted(question, ruling.evidence, str(judge_of(cycle)), ruling.escalation if isinstance(ruling, Interrupt) else ""), cycle.effects.now()):
return Stop(1, failure.reason)
# The interrupt names the rung the worker ran on until it, and a step-up then the rung it runs on from it, 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)
return interrupt(cycle.root, cycle.session.id, cycle.route.rung, transcript_path, question, cycle.paths, worker_environment(cycle), cycle.effects) or HumanAnswered()
+6 -6
View File
@@ -82,10 +82,10 @@ scale counts as none. Every second unfinished verdict on a chunk steps it up one
(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, and the verdict after it steps nothing on
the same quote (routing.stepped_by_interrupt). That step stops two rungs
steps the rung as it comes in, before the human is asked, and no later ruling of that cycle steps it
again (routing.stepped_by_interrupt). That 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, stop and step-up in the archive names the
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
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,9 +226,9 @@ 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
# A route the cycle stepped up as the judge interrupted counts as the one the verdict steps from.
ended = dataclasses.replace(loop_run, route=concluded.route) if loop_run.route else loop_run
before, loop_run = loop_run.route, after_verdict(ended, anchor, concluded.verdict)
# 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.
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):
return stop
if stop := check_routing(archive_root(paths.home, env), anchor or Rung(models.worker), paths, effects):
+12 -9
View File
@@ -60,27 +60,30 @@ def escalation_cap(anchor: Rung, route: Route) -> Rung:
def stepped(anchor: Rung, route: Route, bundled: int, escalated: bool) -> Route:
"""The route after one more unfinished verdict: taken_in's rung, one rung up on every second unfinished verdict or on an escalation the judge found, and one rung up where both fall on one verdict.
"""The route after one more unfinished verdict. Its rung never falls below taken_in's. It steps up one rung on every second unfinished verdict, or on an escalation the judge found while the rung is below escalation_cap; where both fall on one verdict, it steps once.
bundled and escalated are the verdict's fields, not the verdict, since loop_claude.cycle.judge imports this module through prompts.
"""
rung = taken_in(anchor, route, bundled)
unfinished = route.unfinished + 1
if unfinished >= UNFINISHED_PER_STEP or (escalated and below_cap(anchor, route, rung)):
return dataclasses.replace(route, rung=stepped_up(rung), unfinished=0)
return stepped_from(route, rung)
return dataclasses.replace(route, rung=rung, unfinished=unfinished)
def stepped_by_interrupt(anchor: Rung, route: Route) -> Route:
"""The route after the judge's interrupt carried an escalation: one rung up from kept_rung, up to escalation_cap. An interrupt is no unfinished verdict, so the count of those restarts only with a step."""
rung = kept_rung(anchor, route)
if below_cap(anchor, route, rung):
return dataclasses.replace(route, rung=stepped_up(rung), unfinished=0)
return route
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."""
rung = taken_in(anchor, route, bundled)
return stepped_from(route, rung) if below_cap(anchor, route, rung) else dataclasses.replace(route, rung=rung)
def stepped_from(route: Route, rung: Rung) -> Route:
"""The route one rung above rung, with the count of unfinished verdicts restarted."""
return dataclasses.replace(route, rung=stepped_up(rung), unfinished=0)
def below_cap(anchor: Rung, route: Route, rung: Rung) -> bool:
"""Whether an escalation trigger may take the worker one rung up from rung without the human's yes."""
"""Whether an escalation trigger may take the worker one rung up from rung without the human's yes: rung is below escalation_cap, two rungs above item_rung."""
return position(rung) < position(escalation_cap(anchor, route))
+3 -3
View File
@@ -465,7 +465,7 @@ class Cycles(unittest.TestCase):
cited = "Stability round 2: a 🔴."
run = checkout.run([
worker(say=f"{cited} Trigger 3 fired; I ask for a higher rung. Shall I use A or B?"), judge(interrupt=True, evidence="Shall I use A or B?", question="A or B?", escalation=cited),
interrupt(type="B"), judge(evidence="B", escalation=cited),
interrupt(type="B"), judge(evidence="B", escalation="Trigger 3 fired; I ask for a higher rung."),
worker(say="carrying on"),
], terminal_input="")
self.assertEqual(run.code, 130)
@@ -474,7 +474,7 @@ class Cycles(unittest.TestCase):
outcomes = sorted(verdict.removeprefix(f"Task: {TASK}\n\n") for verdict in checkout.archived().values())
self.assertIn("<UTC> Stepped up\n\nWorker: claude-opus-5-5 at xhigh effort, routed by item 4's L of 4 and E + I of 5\n", "".join(outcomes))
self.assertNotIn("at max effort", "".join(outcomes))
self.assertIn("Verdict: interrupt\n\nA or B?\n\nEvidence:\n> Shall I use A or B?\n\nEscalation:\n> Stability round 2: a 🔴.\n\nJudge: judge-model\n", "".join(outcomes))
self.assertIn("Verdict: interrupt\n\nA or B?\n\nEvidence:\n> Shall I use A or B?\n\nEscalation:\n> Stability round 2: a 🔴.\n\nJudge: judge-model\nWorker: claude-opus-5-5 at high effort, routed by item 4's L of 4 and E + I of 5\n\n<UTC> Stepped up\n\nWorker: claude-opus-5-5 at xhigh effort, routed by item 4's L of 4 and E + I of 5\n", "".join(outcomes))
def test_runs_a_cheap_items_worker_below_the_projects_rung_with_its_reviewers_and_judge_on_it(self):
checkout = Checkout(self)
@@ -642,7 +642,7 @@ class Interrupt(unittest.TestCase):
self.assertEqual(run.stderr.strip().splitlines()[-2:], ["A or B?", "the human is needed to answer the question above, but stdin or stdout is not a terminal; rerun loop-claude on a terminal"])
[(copy, verdict)] = checkout.archived().items()
self.assertEqual(copy, (checkout.transcripts()[0]).read_text())
self.assertEqual(verdict, f"Task: {TASK}\n\n<UTC> Verdict: interrupt\n\nA or B?\n\nEvidence:\n> Shall I use A or B?\n\nJudge: judge-model\n\n<UTC> Stopped: the human is needed to answer the question above, but stdin or stdout is not a terminal; rerun loop-claude on a terminal\n\nWorker: worker-model\n")
self.assertEqual(verdict, f"Task: {TASK}\n\n<UTC> Verdict: interrupt\n\nA or B?\n\nEvidence:\n> Shall I use A or B?\n\nJudge: judge-model\nWorker: worker-model\n\n<UTC> Stopped: the human is needed to answer the question above, but stdin or stdout is not a terminal; rerun loop-claude on a terminal\n\nWorker: worker-model\n")
self.assertEqual(stat.S_IMODE((checkout.temp / "deep").stat().st_mode), 0o700)
self.assertIn(f"transcript: {checkout.archive() / 'proj'}/", run.stderr)
session = argument(run.calls[0], "--session-id")
+22 -7
View File
@@ -315,7 +315,7 @@ class Cycles(unittest.TestCase):
return 0
fake = FakeEffects(streams=[Worker(self.paths.claude_code_transcripts.parent)], claude=[judged("interrupt"), judged("unfinished")], on_terminal_claude=[answer], git=[ran()])
self.assertEqual(run.run_cycle(self.cycle(fake)).verdict, Unfinished("working"))
self.assertEqual(self.archived_outcomes(), ["Task: Do it.\n\n2026-09-21T14:13:20Z Verdict: interrupt\n\nWhich one?\n\nEvidence:\n> working\n\nJudge: judge-model\n", "Task: Do it.\n\n2026-09-21T14:13:20Z Verdict: unfinished\n\nEvidence:\n> working\n\nJudge: judge-model\nWorker: worker-model\n"])
self.assertEqual(self.archived_outcomes(), ["Task: Do it.\n\n2026-09-21T14:13:20Z Verdict: interrupt\n\nWhich one?\n\nEvidence:\n> working\n\nJudge: judge-model\nWorker: worker-model\n", "Task: Do it.\n\n2026-09-21T14:13:20Z Verdict: unfinished\n\nEvidence:\n> working\n\nJudge: judge-model\nWorker: worker-model\n"])
self.assertIn(str(self.session.id), fake.made("claude_on_terminal")[0])
judge_prompts = [stdin for args, stdin in fake.made("claude")]
self.assertEqual(len(judge_prompts), 2)
@@ -335,7 +335,7 @@ class Cycles(unittest.TestCase):
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"
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\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])
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_stops_when_a_quoted_answer_cannot_be_archived(self):
self.archive.parent.mkdir(parents=True)
@@ -646,10 +646,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)), Route(self.XHIGH, 3, 4, 5))
self.assertEqual(routing.stepped_by_interrupt(self.OPUS, Route(self.XHIGH, 3, 4, 5)), Route(self.MAX, 3, 4, 5))
self.assertEqual(routing.stepped_by_interrupt(self.OPUS, Route(self.MAX, 3, 4, 5, unfinished=1)), Route(self.MAX, 3, 4, 5, unfinished=1))
self.assertEqual(routing.stepped_by_interrupt(self.OPUS, Route(self.SONNET, 3, 2, 4)), Route(self.OPUS, 3, 2, 4))
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))
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))
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)
@@ -1083,13 +1088,23 @@ class Verdict(unittest.TestCase):
def test_takes_an_escalation_quote_on_an_interrupt(self):
reply = {"answer": "", "bundled": 0, "bundled_escape_and_impact": 0, "escalation": "round 2: 🔴", "interrupt": True, "evidence": "e", "finished": False, "question": "Which one?"}
self.assertEqual(verdict_from(reply), Interrupt("e", "Which one?", "round 2: 🔴"))
self.assertEqual(verdict_from({**reply, "bundled": 4}), Interrupt("e", "Which one?", "round 2: 🔴", 4))
self.assertEqual(verdict_from({**reply, "bundled": 5}), Interrupt("e", "Which one?", "round 2: 🔴"))
def test_drops_an_escalation_quote_the_transcript_does_not_hold_word_for_word_from_an_interrupt_or_an_unfinished_verdict(self):
shown = "The agent: round 2: 🔴. Which one?"
self.assertEqual(judge.quotes_checked(Interrupt("e", "q", "round 2: 🔴"), shown, ""), Interrupt("e", "q", "round 2: 🔴"))
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"))
self.assertEqual(judge.quotes_checked(QuotedAnswer("e", "q", "not there"), shown, "the records"), Interrupt("e", "q"))
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"))
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(Unfinished("e", 0, "round 2: 🔴"), False), Unfinished("e", 0, "round 2: 🔴"))
class LoopRuns(unittest.TestCase):
+1 -1
View File
@@ -191,7 +191,7 @@ class Archive(unittest.TestCase):
def test_counts_the_verdicts_across_every_projects_chunks(self):
self.chunk("home/x", "c1", stamped("2026-10-14T10:00:00Z", outcomes.unfinished("w", "e", "j", "")) + stamped("2026-10-14T10:01:00Z", outcomes.stopped("w", "Ctrl-C")) + stamped("2026-10-14T10:02:00Z", outcomes.finished("w", "e", "j")), [])
self.chunk("log", "c2", stamped("2026-10-14T10:00:00Z", outcomes.interrupted("q", "e", "j", "")), [])
self.chunk("log", "c2", stamped("2026-10-14T10:00:00Z", outcomes.interrupted("q", "e", "j", "", "w")), [])
self.assertEqual(archive.cycles(self.root), 2)
self.assertEqual(archive.cycles(self.root / "missing"), 0)
+5 -5
View File
@@ -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, 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 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", "Stopped: ", "Stepped up\n")
NAMES_A_WORKER = ("Verdict: finished\n", "Verdict: unfinished\n", "Verdict: interrupt\n", "Stopped: ", "Stepped up\n")
WORKER = "Worker: "
# The rung that judged a verdict.
JUDGE = "Judge: "
@@ -34,10 +34,10 @@ def unfinished(worker: str, evidence: str, judge: str, escalation: str) -> str:
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) -> str:
"""escalation is the judge's quote showing that the worker's cited escalation trigger fired; empty for none."""
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 ""
return f"{INTERRUPTED}\n\n{question}\n\nEvidence:\n{quoted(evidence)}\n\n{escalated}{JUDGE}{judge}"
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:
@@ -47,22 +47,22 @@ class Outcomes(unittest.TestCase):
def test_the_archive_stamps_what_it_reads_back(self):
self.assertRegex(f"{utc(NOW)} {outcomes.finished('m', 'merged', 'j')}", outcomes.FINISHED_AT)
def test_reads_back_the_worker_of_each_outcome_that_closes_a_cycle(self):
def test_reads_back_the_worker_of_each_outcome_that_names_one(self):
kept = "Task: Do it.\n\n" + "\n".join(f"{utc(NOW + offset)} {outcome}\n" for offset, outcome in enumerate([
outcomes.unfinished("w1", "Worker: not this", "j", ""),
outcomes.interrupted("Which one?\nWorker: nor this", "e", "j", ""),
outcomes.interrupted("Which one?\nWorker: nor this", "e", "j", "", "w1b"),
outcomes.stopped("w2", "the judge failed\nthree times"),
outcomes.finished("w3", "merged", "j"),
]))
self.assertEqual(outcomes.workers(kept), [(utc(NOW), "w1"), (utc(NOW + 2), "w2"), (utc(NOW + 3), "w3")])
self.assertEqual(outcomes.workers(kept), [(utc(NOW), "w1"), (utc(NOW + 1), "w1b"), (utc(NOW + 2), "w2"), (utc(NOW + 3), "w3")])
def test_archives_the_escalation_an_unfinished_verdict_quotes_beside_its_evidence(self):
self.assertEqual(outcomes.unfinished("w", "e", "j", "round 2: 🔴"), "Verdict: unfinished\n\nEvidence:\n> e\n\nEscalation:\n> round 2: 🔴\n\nJudge: j\nWorker: w")
self.assertEqual(outcomes.unfinished("w", "e", "j", ""), "Verdict: unfinished\n\nEvidence:\n> e\n\nJudge: j\nWorker: w")
def test_archives_the_escalation_an_interrupt_quotes_beside_its_evidence(self):
self.assertEqual(outcomes.interrupted("q?", "e", "j", "round 2: 🔴"), "Verdict: interrupt\n\nq?\n\nEvidence:\n> e\n\nEscalation:\n> round 2: 🔴\n\nJudge: j")
self.assertEqual(outcomes.interrupted("q?", "e", "j", ""), "Verdict: interrupt\n\nq?\n\nEvidence:\n> e\n\nJudge: j")
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_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"
+2 -2
View File
@@ -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 may also ask the human something only they can answer, so the judge's 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, and a quote that stepped the rung steps it no more: the verdict the judge gives after the interrupt, quoting the same passage, holds the rung. The limits are the same.
A run may also ask the human something only they can answer, so the judge's 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. The step starts from the rung an item the judge saw the worker take in picks, as below. An interrupt is no unfinished verdict, so it adds to no count. One trigger buys one step, but loop-claude cannot tell two passages that show one trigger fired apart, so once an interrupt has taken an escalation, no later ruling of that cycle carries one: the verdict the judge gives after the interrupt holds the rung. A trigger that fires after the human's answer waits for the next cycle. The limits are the same.
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, beside any step-up it causes. `bin/routing_figures/` counts that verdict as unfinished, not 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 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 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 that verdict as unfinished, not as an escalation by trigger, which it counts only from subagent prompts.
Valid while the worker reports in its transcript the triggers that fired.
+6 -1
View File
@@ -6,12 +6,13 @@
`Bar = 0.1`
`Next ID = 179`
`Next ID = 180`
## Items
| 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 |
@@ -83,6 +84,10 @@
## 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.