From 4fa114905a139a6f5a84470b5cafc1373d5f852d Mon Sep 17 00:00:00 2001 From: Lilleman auf Larv Date: Fri, 23 Oct 2026 15:06:10 +0200 Subject: [PATCH 01/11] Record reading cost for PR #370 --- docs/reading-cost.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/docs/reading-cost.md b/docs/reading-cost.md index 2fe1084a..7b7d9a1e 100644 --- a/docs/reading-cost.md +++ b/docs/reading-cost.md @@ -863,3 +863,7 @@ Read most (opens and searches): Read most (opens and searches): - `rules/decisions.md` 1 + +## Reading cost, chunk e94dd7a98ff8, finished 2026-10-23T12:59:22Z + +71809 new input tokens before the first commit. -- 2.52.0 From 008c187192d19f5e74d6e140f28761516891e6d0 Mon Sep 17 00:00:00 2001 From: Lilleman auf Larv Date: Fri, 23 Oct 2026 15:06:10 +0200 Subject: [PATCH 02/11] Stop loop-claude and ask the human after six unfinished verdicts running --- CHANGELOG.md | 1 + bin/loop_claude/loop/main.py | 26 +++++++++++++++++++++----- bin/loop_claude/loop/reload.py | 2 ++ bin/loop_claude/test_black_box.py | 21 ++++++++++++++++++++- bin/loop_claude/test_loop_claude.py | 4 +++- todo.md | 5 ----- 6 files changed, 47 insertions(+), 12 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b6aedd80..2085a76c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,7 @@ ## Unreleased +- `loop-claude` now stops with exit 2 when the judge rules one chunk unfinished 6 cycles running, so a worker and a judge that disagree can no longer cycle unattended without end. Rerunning resumes the chunk and gives it 6 more cycles. No chunk in the archive has had more than one unfinished verdict. - Reviewers now mark a 🔴 or 🟡 `[misread]` where it arose because the implementer misread code that had already shipped. A round's commit title now counts the marked findings, as in `Answer stability round 1: 1 🔴, 2 🟡 (1 misread); …`, and rule-hook's `round-title-counts` blocks a round title without that count. `score-outcomes` shows the count on each finished item, and lists it after the medians for each chunk whose round titles carry it, newest first. A chunk whose round titles predate this change reads as unknown. - Sessions running at once no longer starve the machine. A new tool, `run-heavy `, runs a heavy command, such as a full gate, mutation tests, an e2e run or a `docker build`, once it holds one of the machine's heavy slots: one per 4 CPUs, shared by every session. `CLAUDE.md` has every session run its heavy commands under it, and rule-hook blocks a `docker build` or a mutation run outside it. loop-claude now waits to start a worker while less than a quarter of the machine's memory is available. - larv-review's skill now says a commit answering the external auto-reviewer takes no `Answer round` title, and that `larv-review round-count` doesn't list the auto-reviewer. A worker who followed the skill used to get a "not a pass" warning. diff --git a/bin/loop_claude/loop/main.py b/bin/loop_claude/loop/main.py index 909ed5ec..fd073bbe 100644 --- a/bin/loop_claude/loop/main.py +++ b/bin/loop_claude/loop/main.py @@ -107,6 +107,8 @@ Exit 2, when the human is needed and cannot answer: - the input ends while a model is picked - an interrupt's answer is empty, or the input ends before one is typed - the claude opened for /talk, or for a release ready to cut, ends with nothing typed +- the judge rules a chunk unfinished 6 cycles running; a finished chunk restarts the run, and a rerun + gives the chunk 6 more Rerunning resumes any open session. """ @@ -115,7 +117,7 @@ import pathlib import sys import typing -from loop_claude.routing import after_unfinished, first_route, kept, routed_item +from loop_claude.routing import after_unfinished, ESCALATION_CAP, first_route, kept, routed_item, UNFINISHED_PER_STEP from transcript_archive.write import archive from transcript_archive.location import archive_root, project_archive from loop_claude.loop.routing_check import check_routing @@ -139,10 +141,12 @@ from loop_claude.project.premises import read_premises from loop_claude.project.records import read_records from model_routing.route import Route, route_from from claude_code.session import Session, session_named, session_open, transcript_file -from loop_claude.stop import Stop +from loop_claude.stop import needs_human, Stop # Seconds routing waits for origin to name its default branch, asked only where the checkout records none; past them, the chunk runs on the project's rung. ORIGIN_TIMEOUT = 60 +# How many unfinished verdicts running end the loop to ask the human, so a worker and a judge that disagree about a chunk cannot cycle unattended without end: the worker's two escalation steps, which every second verdict takes, and one step's worth more at the top. No archived chunk has had more than one. +UNFINISHED_LIMIT = UNFINISHED_PER_STEP * (ESCALATION_CAP + 1) def main(argv: list[str], env: typing.Mapping[str, str], paths: Paths, launcher: pathlib.Path, cwd: pathlib.Path, effects: Effects) -> int: @@ -188,6 +192,8 @@ def run_loop(argv: list[str], env: typing.Mapping[str, str], paths: Paths, launc loop_run = after_verdict(loop_run, project, concluded) if stop := archive_step(archive_folder, session, loop_run.task, concluded.route, loop_run.route, effects): return stop + if stop := past_limit(archive_folder, session, loop_run, effects): + return stop if stop := check_routing(archive_root(paths.home, env), project or Rung(models.worker), paths, effects): return stop @@ -204,11 +210,11 @@ def routed(route: Route | None, project: Rung | None, model: str, archived: typi def after_verdict(loop_run: LoopRun, project: Rung | None, concluded: Concluded) -> LoopRun: - """The loop run the next cycle starts from. A finished chunk drops its route. An unfinished one takes the route stepped_route makes, and the evidence the judge gave for the verdict.""" + """The loop run the next cycle starts from. A finished chunk drops its route and its run of unfinished verdicts. An unfinished one takes the route stepped_route makes, the evidence the judge gave for the verdict, and counts the verdict.""" verdict = concluded.verdict if isinstance(verdict, Finished): - return dataclasses.replace(loop_run, route=None, unfinished_evidence="") - return dataclasses.replace(loop_run, route=stepped_route(project, concluded.route, verdict), unfinished_evidence=verdict.evidence) + return dataclasses.replace(loop_run, route=None, unfinished_evidence="", unfinished_run=0) + return dataclasses.replace(loop_run, route=stepped_route(project, concluded.route, verdict), unfinished_evidence=verdict.evidence, unfinished_run=loop_run.unfinished_run + 1) def stepped_route(project: Rung | None, ended_on: Route, verdict: Unfinished) -> Route: @@ -216,6 +222,16 @@ def stepped_route(project: Rung | None, ended_on: Route, verdict: Unfinished) -> return after_unfinished(project, ended_on, verdict) if project else ended_on +def past_limit(archive_folder: pathlib.Path, session: Session, loop_run: LoopRun, effects: Effects) -> Stop | None: + """The stop that asks the human once the chunk has had UNFINISHED_LIMIT unfinished verdicts running, archived with the route the next cycle would run on, so a rerun resumes on it.""" + if loop_run.unfinished_run < UNFINISHED_LIMIT or loop_run.route is None: + return None + stop = needs_human("decide whether the chunk is finished", f"the judge ruled it unfinished {loop_run.unfinished_run} cycles running; rerun loop-claude to give it {UNFINISHED_LIMIT} more") + path = transcript_file(session) + failure = archive(archive_folder, path, loop_run.task, outcomes.stopped(loop_run.route.worker_line(), stop.reason), effects.now()) if path else None + return Stop(1, f"{failure.reason}\n{stop.reason}") if failure else stop + + def archive_step(archive_folder: pathlib.Path, session: Session, task: str, before: Route, after: Route | None, effects: Effects) -> Stop | None: """Archives the route after an unfinished verdict as a step-up, where its worker line differs from the one before it: a higher rung, or a higher E + I taken in. The verdict itself names the route before, which its cycle ran on.""" if after is None or after.worker_line() == before.worker_line(): diff --git a/bin/loop_claude/loop/reload.py b/bin/loop_claude/loop/reload.py index eb52cb62..8c4108a1 100644 --- a/bin/loop_claude/loop/reload.py +++ b/bin/loop_claude/loop/reload.py @@ -24,6 +24,8 @@ class LoopRun: unfinished_evidence: str # Set by each unfinished verdict; None before the chunk's first one, and once it finishes. route: Route | None = None + # How many unfinished verdicts the chunk has had running; a finished chunk restarts it, and a rerun starts it at 0. + unfinished_run: int = 0 def decode_handed(handed: str, kind: type[T]) -> T | None: diff --git a/bin/loop_claude/test_black_box.py b/bin/loop_claude/test_black_box.py index ee37f2ba..d15ad153 100644 --- a/bin/loop_claude/test_black_box.py +++ b/bin/loop_claude/test_black_box.py @@ -648,6 +648,25 @@ class Cycles(unittest.TestCase): self.assertIn("claude left no transcript for session", run.stderr) + def test_exits_2_after_six_unfinished_verdicts_running_and_a_rerun_gets_six_more(self): + checkout = Checkout(self) + six = [step for _ in range(6) for step in (worker(), judge())] + run = checkout.run(six + [worker()]) + self.assertEqual((run.code, run.roles()), (2, ["worker", "judge"] * 6)) + self.assertEqual(run.stderr.strip().splitlines()[-1], "the human is needed to decide whether the chunk is finished, but the judge ruled it unfinished 6 cycles running; rerun loop-claude to give it 6 more") + stops = [outcome for outcome in checkout.archived().values() if "Stopped: " in outcome] + self.assertEqual(len(stops), 1) + self.assertIn(f" Stopped: the human is needed to decide whether the chunk is finished, but the judge ruled it unfinished 6 cycles running; rerun loop-claude to give it 6 more\n\nWorker: {OFF_LADDER}\n", stops[0]) + run = checkout.run(six[:-2] + [worker()]) + self.assertEqual((run.code, run.roles()), (130, ["worker", "judge"] * 6)) + + def test_five_unfinished_verdicts_and_a_finished_one_do_not_add_up_to_six(self): + checkout = Checkout(self) + five = [step for _ in range(5) for step in (worker(), judge())] + run = checkout.run(five + [worker(), judge(finished=True)] + five + [worker()]) + self.assertEqual((run.code, run.roles()), (130, ["worker", "judge"] * 12)) + + class Interrupt(unittest.TestCase): def test_exits_2_off_a_terminal_and_resumes_on_the_next_run(self): checkout = Checkout(self) @@ -868,7 +887,7 @@ class Reload(unittest.TestCase): self.assertEqual(run.roles(), ["worker", "judge"] * 5) self.assertIn("keeping the running script", run.stderr) reloads = [json.loads(argv[1]) for argv in run.starts if argv[:1] == ["--reloaded"]] - self.assertEqual(reloads, [{"cycle_number": cycle, "root": str(checkout.root), "task": TASK, "unfinished_evidence": "working", "route": OFF_LADDER_ROUTE} for cycle in (2, 3, 4)]) + self.assertEqual(reloads, [{"cycle_number": cycle, "root": str(checkout.root), "task": TASK, "unfinished_evidence": "working", "route": OFF_LADDER_ROUTE, "unfinished_run": cycle} for cycle in (2, 3, 4)]) self.assertIn("=== cycle 5,", run.stdout) outside = checkout.temp / "outside" diff --git a/bin/loop_claude/test_loop_claude.py b/bin/loop_claude/test_loop_claude.py index e330fc82..5c916220 100644 --- a/bin/loop_claude/test_loop_claude.py +++ b/bin/loop_claude/test_loop_claude.py @@ -1010,7 +1010,8 @@ class Steps(unittest.TestCase): def test_a_finished_verdict_clears_the_route_and_the_evidence(self): run_with = main.LoopRun(cycle_number=1, root="/r", task="do it", unfinished_evidence="old", route=Route(self.OPUS)) self.assertEqual(main.after_verdict(run_with, self.OPUS, run.Concluded(Finished("x"), run_with.route)), dataclasses.replace(run_with, route=None, unfinished_evidence="")) - self.assertEqual(main.after_verdict(run_with, self.OPUS, run.Concluded(Unfinished("new", 4), run_with.route)), dataclasses.replace(run_with, route=Route(Rung("claude-opus-5-5", "high"), unfinished=1), unfinished_evidence="new")) + self.assertEqual(main.after_verdict(dataclasses.replace(run_with, unfinished_run=3), self.OPUS, run.Concluded(Finished("x"), run_with.route)).unfinished_run, 0) + self.assertEqual(main.after_verdict(run_with, self.OPUS, run.Concluded(Unfinished("new", 4), run_with.route)), dataclasses.replace(run_with, route=Route(Rung("claude-opus-5-5", "high"), unfinished=1), unfinished_evidence="new", unfinished_run=1)) def test_steps_from_the_route_its_cycle_ended_on_which_a_ruling_may_have_raised(self): run_with = main.LoopRun(cycle_number=1, root="/r", task="do it", unfinished_evidence="", route=Route(self.OPUS, 3, 3, 4)) @@ -1538,6 +1539,7 @@ class ExitContract(unittest.TestCase): ("cycle/run.py", "ask", "1", "failure.reason", read), ("cycle/run.py", "close", "1", "failure.reason", read), ("cycle/run.py", "close", "1", "failure.reason", "a finished chunk's session cannot be deleted"), + ("loop/main.py", "past_limit", "1", "f'{failure.reason}\\n{stop.reason}'", read), ("loop/main.py", "archive_step", "1", "failure.reason", read), ("loop/main.py", "loop_run_from", "0 if task else 1", "__doc__.strip()", "no task is given"), ("loop/main.py", "loop_run_from", "1", 'f"the edited loop-claude cannot read the state', "a reload cannot read the state the running script handed it"), diff --git a/todo.md b/todo.md index c5133e4c..8fdad24d 100644 --- a/todo.md +++ b/todo.md @@ -13,7 +13,6 @@ | ID | Release | Blocked by | Exempt | Item | L | E | I | R | S | Moves | Score | |---|---|---|---|---|---|---|---|---|---|---|---| | 226 | 0.4.0 | | question | **Answer whether rule-hook's `run-heavy` rule should also catch a mutation run or docker build behind `uv run`, `poetry run`, `python3 -m`, `sudo`, `docker image build` and `docker compose up --build`, or narrow the `machine load:` decision's wording.** | 2 | 2 | 3 | 5 | 3 | 1.2 by 2, 1.5 by 2 | 4.0 | -| 59 | 0.4.0 | | | **Bound a run of unfinished verdicts on one chunk, so a worker and judge that disagree cannot cycle unattended without end.** | 2 | 1 | 3 | 4 | 3 | 1.4 by 6 | 6.0 | | 167 | 0.4.0 | | | **Refuse a `/security-review` or `/claude-security` Skill call below the project's rung, as rule-hook refuses such an Agent call.** | 3 | 2 | 3 | 6 | 2 | 1.1 by 4 | 5.6 | | 6 | 0.4.0 | | decision | **Move what `loop-claude` writes out of `~/.claude.json`, and ask the human about each write that must stay.** | 3 | 3 | 3 | 7 | 3 | 1.1 by 5 | 5.3 | | 225 | 0.4.0 | | | **Add the value-taking options of docker that `DOCKER_VALUED` lacks, so rule-hook's `run-heavy` rule reads their value as a value and not as the subcommand.** | 1 | 1 | 3 | 3 | 2 | 1.5 by 2 | 2.6 | @@ -75,10 +74,6 @@ Found by review of PR #370. Today `uv run mutmut run`, `poetry run mutmut run`, `python3 -m mutmut run`, `sudo docker build .`, `docker image build .` and `docker compose up --build` pass the rule, which `docs/decisions.md` → `machine load: …` and `RULES["run-heavy"]` describe as blocking docker builds and mutation runs. The rule's own text says a gate script isn't checked since no program can tell it from a light one, so the human decides where the line sits. Say what the rule's "checked" text promises either way. Where the answer widens the rule, the change touches `heavy` in `bin/rule_hook/heavy_command.py`, which the comprehension seats found hard: make it easier to read. -### 59. Bound a run of unfinished verdicts on one chunk, so a worker and judge that disagree cannot cycle unattended without end. - -Raised by the product-owner review of PR #211. The resumed worker gets the judge's quote of the work remaining, but a worker that still thinks the chunk done can answer each cycle the same way, and each cycle costs a worker and a judge run (goal 1.4). - ### 167. Refuse a `/security-review` or `/claude-security` Skill call below the project's rung, as rule-hook refuses such an Agent call. rule-hook checks Agent calls (item 163) but no Skill calls. A worker that invokes `/security-review` in its own context, instead of in a subagent, runs the pass on its own rung, and nothing blocks it. Check Skill calls too: `breaches_of` in bin/rule_hook/main.py takes a Skill call whose skill is `security-review` or `claude-security` as a review launch, and settings.json's PreToolUse matcher gains Skill. Found by the systems-architect's review of PR #295. -- 2.52.0 From 2135afe8d79589feccaa0474a931c90a0b7600bc Mon Sep 17 00:00:00 2001 From: Lilleman auf Larv Date: Fri, 23 Oct 2026 15:09:46 +0200 Subject: [PATCH 03/11] =?UTF-8?q?Answer=20architecture=20round=201:=201=20?= =?UTF-8?q?=F0=9F=94=B4,=204=20=F0=9F=9F=A1=20(0=20misread);=20share=20the?= =?UTF-8?q?=20stop=20archiving,=20fix=20the=20limit=20at=206,=20reword=20t?= =?UTF-8?q?he=20exit-2=20contract,=20close=20the=20cycle=20in=20one=20step?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- bin/loop_claude/cycle/run.py | 10 ++++-- bin/loop_claude/loop/main.py | 54 +++++++++++++++++------------ bin/loop_claude/test_black_box.py | 4 +-- bin/loop_claude/test_loop_claude.py | 6 ++-- 4 files changed, 44 insertions(+), 30 deletions(-) diff --git a/bin/loop_claude/cycle/run.py b/bin/loop_claude/cycle/run.py index cf65353b..fec99f47 100644 --- a/bin/loop_claude/cycle/run.py +++ b/bin/loop_claude/cycle/run.py @@ -76,9 +76,13 @@ def ruling_step_up(cycle: Cycle, verdict: Verdict) -> StepUp | None: def stopped(cycle: Cycle, stop: Stop, why: str) -> Stop: - path = transcript_file(cycle.session) - failure = archive(cycle.project_archive, path, cycle.task, outcomes.stopped(cycle.route.worker_line(), why), cycle.effects.now()) if path else None - # A failed archive exits 1 whatever the stop; when the stop was this archive failing, its reason is said once. + return archived_stop(cycle.project_archive, cycle.session, cycle.task, cycle.route, stop, why, cycle.effects) + + +def archived_stop(project_archive: pathlib.Path, session: Session, task: str, route: Route, stop: Stop, why: str, effects: Effects) -> Stop: + """stop, once archived with the route the worker holds. A failed archive exits 1 whatever the stop; when the stop was this archive failing, its reason is said once.""" + path = transcript_file(session) + failure = archive(project_archive, path, task, outcomes.stopped(route.worker_line(), why), effects.now()) if path else None return Stop(1, f"{failure.reason}\n{stop.reason}".rstrip()) if failure and failure.reason != stop.reason else stop diff --git a/bin/loop_claude/loop/main.py b/bin/loop_claude/loop/main.py index fd073bbe..0ca62357 100644 --- a/bin/loop_claude/loop/main.py +++ b/bin/loop_claude/loop/main.py @@ -102,13 +102,13 @@ Exit 1, saying why, when: more than 2 minutes past. The judge's reply gives its reset time only as text, so the judge is always retried every 10 minutes. stderr says when the next try is due. -Exit 2, when the human is needed and cannot answer: +Exit 2, when the human is needed to go on and cannot be asked, or the chunk has gone on too long: - stdin or stdout is not a terminal, when a model must be picked or an interrupt answered - the input ends while a model is picked - an interrupt's answer is empty, or the input ends before one is typed - the claude opened for /talk, or for a release ready to cut, ends with nothing typed -- the judge rules a chunk unfinished 6 cycles running; a finished chunk restarts the run, and a rerun - gives the chunk 6 more +- the judge rules a chunk unfinished 6 cycles running; finish the chunk yourself, or rerun to give it + 6 more. A finished chunk restarts the run. Rerunning resumes any open session. """ @@ -117,12 +117,12 @@ import pathlib import sys import typing -from loop_claude.routing import after_unfinished, ESCALATION_CAP, first_route, kept, routed_item, UNFINISHED_PER_STEP +from loop_claude.routing import after_unfinished, first_route, kept, routed_item from transcript_archive.write import archive from transcript_archive.location import archive_root, project_archive from loop_claude.loop.routing_check import check_routing from loop_claude.project.checkout import checkout_root -from loop_claude.cycle.run import Concluded, Cycle, run_cycle +from loop_claude.cycle.run import archived_stop, Concluded, Cycle, run_cycle from loop_claude.loop.reload import decode_handed, exec_if_edited, fingerprint, LoopRun, RELOAD_FLAG from chunk_pick import default_plan, DefaultPlan from git_repo import default_ref @@ -145,8 +145,8 @@ from loop_claude.stop import needs_human, Stop # Seconds routing waits for origin to name its default branch, asked only where the checkout records none; past them, the chunk runs on the project's rung. ORIGIN_TIMEOUT = 60 -# How many unfinished verdicts running end the loop to ask the human, so a worker and a judge that disagree about a chunk cannot cycle unattended without end: the worker's two escalation steps, which every second verdict takes, and one step's worth more at the top. No archived chunk has had more than one. -UNFINISHED_LIMIT = UNFINISHED_PER_STEP * (ESCALATION_CAP + 1) +# How many unfinished verdicts running end the loop, so a worker and a judge that disagree about a chunk cannot cycle unattended without end. A policy number, not derived from the routing steps: well above the one unfinished verdict any archived chunk has had, and low enough that a stuck pair spends six worker and judge runs, not more. "loop-claude --help" states it. +UNFINISHED_LIMIT = 6 def main(argv: list[str], env: typing.Mapping[str, str], paths: Paths, launcher: pathlib.Path, cwd: pathlib.Path, effects: Effects) -> int: @@ -189,11 +189,10 @@ def run_loop(argv: list[str], env: typing.Mapping[str, str], paths: Paths, launc concluded = run_cycle(Cycle(effects=effects, facts=facts, judge_model=models.judge, paths=paths, premises=premises, project=project, 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 - loop_run = after_verdict(loop_run, project, concluded) - if stop := archive_step(archive_folder, session, loop_run.task, concluded.route, loop_run.route, effects): - return stop - if stop := past_limit(archive_folder, session, loop_run, effects): - return stop + closed = closed_cycle(loop_run, project, concluded, archive_folder, session, effects) + if isinstance(closed, Stop): + return closed + loop_run = closed if stop := check_routing(archive_root(paths.home, env), project or Rung(models.worker), paths, effects): return stop @@ -209,12 +208,31 @@ def routed(route: Route | None, project: Rung | None, model: str, archived: typi return route if route and kept(route, project) else first_route(project, item()) +def closed_cycle(loop_run: LoopRun, project: Rung | None, concluded: Concluded, archive_folder: pathlib.Path, session: Session, effects: Effects) -> LoopRun | Stop: + """The loop run after a cycle concluded, with the step-up archived; the stop that asks the human, archived, once the chunk has had UNFINISHED_LIMIT unfinished verdicts running.""" + after = after_verdict(loop_run, project, concluded) + if stop := archive_step(archive_folder, session, after.task, concluded.route, after.route, effects): + return stop + if limit := past_limit(after): + # An unfinished verdict always leaves a route. It is archived as the next cycle would run on it, so a rerun resumes there. + return archived_stop(archive_folder, session, after.task, after.route or concluded.route, limit, limit.reason, effects) + return after + + +def past_limit(loop_run: LoopRun) -> Stop | None: + """The stop that asks the human once the loop run holds UNFINISHED_LIMIT unfinished verdicts running.""" + if loop_run.unfinished_run < UNFINISHED_LIMIT: + return None + return needs_human("decide whether the chunk is finished", f"the judge ruled it unfinished {loop_run.unfinished_run} cycles running and loop-claude does not go on unasked; finish the chunk yourself, or rerun loop-claude to give it {UNFINISHED_LIMIT} more cycles") + + def after_verdict(loop_run: LoopRun, project: Rung | None, concluded: Concluded) -> LoopRun: """The loop run the next cycle starts from. A finished chunk drops its route and its run of unfinished verdicts. An unfinished one takes the route stepped_route makes, the evidence the judge gave for the verdict, and counts the verdict.""" verdict = concluded.verdict if isinstance(verdict, Finished): return dataclasses.replace(loop_run, route=None, unfinished_evidence="", unfinished_run=0) - return dataclasses.replace(loop_run, route=stepped_route(project, concluded.route, verdict), unfinished_evidence=verdict.evidence, unfinished_run=loop_run.unfinished_run + 1) + route = stepped_route(project, concluded.route, verdict) + return dataclasses.replace(loop_run, route=route, unfinished_evidence=verdict.evidence, unfinished_run=loop_run.unfinished_run + 1) def stepped_route(project: Rung | None, ended_on: Route, verdict: Unfinished) -> Route: @@ -222,16 +240,6 @@ def stepped_route(project: Rung | None, ended_on: Route, verdict: Unfinished) -> return after_unfinished(project, ended_on, verdict) if project else ended_on -def past_limit(archive_folder: pathlib.Path, session: Session, loop_run: LoopRun, effects: Effects) -> Stop | None: - """The stop that asks the human once the chunk has had UNFINISHED_LIMIT unfinished verdicts running, archived with the route the next cycle would run on, so a rerun resumes on it.""" - if loop_run.unfinished_run < UNFINISHED_LIMIT or loop_run.route is None: - return None - stop = needs_human("decide whether the chunk is finished", f"the judge ruled it unfinished {loop_run.unfinished_run} cycles running; rerun loop-claude to give it {UNFINISHED_LIMIT} more") - path = transcript_file(session) - failure = archive(archive_folder, path, loop_run.task, outcomes.stopped(loop_run.route.worker_line(), stop.reason), effects.now()) if path else None - return Stop(1, f"{failure.reason}\n{stop.reason}") if failure else stop - - def archive_step(archive_folder: pathlib.Path, session: Session, task: str, before: Route, after: Route | None, effects: Effects) -> Stop | None: """Archives the route after an unfinished verdict as a step-up, where its worker line differs from the one before it: a higher rung, or a higher E + I taken in. The verdict itself names the route before, which its cycle ran on.""" if after is None or after.worker_line() == before.worker_line(): diff --git a/bin/loop_claude/test_black_box.py b/bin/loop_claude/test_black_box.py index d15ad153..ec57b7c4 100644 --- a/bin/loop_claude/test_black_box.py +++ b/bin/loop_claude/test_black_box.py @@ -653,10 +653,10 @@ class Cycles(unittest.TestCase): six = [step for _ in range(6) for step in (worker(), judge())] run = checkout.run(six + [worker()]) self.assertEqual((run.code, run.roles()), (2, ["worker", "judge"] * 6)) - self.assertEqual(run.stderr.strip().splitlines()[-1], "the human is needed to decide whether the chunk is finished, but the judge ruled it unfinished 6 cycles running; rerun loop-claude to give it 6 more") + self.assertEqual(run.stderr.strip().splitlines()[-1], "the human is needed to decide whether the chunk is finished, but the judge ruled it unfinished 6 cycles running and loop-claude does not go on unasked; finish the chunk yourself, or rerun loop-claude to give it 6 more cycles") stops = [outcome for outcome in checkout.archived().values() if "Stopped: " in outcome] self.assertEqual(len(stops), 1) - self.assertIn(f" Stopped: the human is needed to decide whether the chunk is finished, but the judge ruled it unfinished 6 cycles running; rerun loop-claude to give it 6 more\n\nWorker: {OFF_LADDER}\n", stops[0]) + self.assertIn(f" Stopped: the human is needed to decide whether the chunk is finished, but the judge ruled it unfinished 6 cycles running and loop-claude does not go on unasked; finish the chunk yourself, or rerun loop-claude to give it 6 more cycles\n\nWorker: {OFF_LADDER}\n", stops[0]) run = checkout.run(six[:-2] + [worker()]) self.assertEqual((run.code, run.roles()), (130, ["worker", "judge"] * 6)) diff --git a/bin/loop_claude/test_loop_claude.py b/bin/loop_claude/test_loop_claude.py index 5c916220..d9aad476 100644 --- a/bin/loop_claude/test_loop_claude.py +++ b/bin/loop_claude/test_loop_claude.py @@ -1013,6 +1013,9 @@ class Steps(unittest.TestCase): self.assertEqual(main.after_verdict(dataclasses.replace(run_with, unfinished_run=3), self.OPUS, run.Concluded(Finished("x"), run_with.route)).unfinished_run, 0) self.assertEqual(main.after_verdict(run_with, self.OPUS, run.Concluded(Unfinished("new", 4), run_with.route)), dataclasses.replace(run_with, route=Route(Rung("claude-opus-5-5", "high"), unfinished=1), unfinished_evidence="new", unfinished_run=1)) + def test_help_states_the_limit_of_unfinished_verdicts_running(self): + self.assertIn(f"unfinished {main.UNFINISHED_LIMIT} cycles running", " ".join(main.__doc__.split())) + def test_steps_from_the_route_its_cycle_ended_on_which_a_ruling_may_have_raised(self): run_with = main.LoopRun(cycle_number=1, root="/r", task="do it", unfinished_evidence="", route=Route(self.OPUS, 3, 3, 4)) raised = Route(Rung("claude-opus-5-5", "high"), 3, 3, 4, escalated_at=5) @@ -1531,7 +1534,7 @@ class ExitContract(unittest.TestCase): ("cycle/interrupt.py", "talk", "1", "f'could not start claude for the interrupt:", "claude cannot start for an interrupt"), ("cycle/interrupt.py", "talk", "1", "f'could not tell whether you typed anything:", read), ("cycle/retry.py", "retried", "1", "f'the {who} failed three times running:", "the worker or the judge fails three times running"), - ("cycle/run.py", "stopped", "1", "f'{failure.reason}", read), + ("cycle/run.py", "archived_stop", "1", "f'{failure.reason}", read), ("cycle/run.py", "work", "1", "f'claude left no transcript for session", "claude leaves no transcript"), ("cycle/run.py", "keep_answer", "1", "failure.reason", read), ("cycle/run.py", "rule", "1", "entries.reason", read), @@ -1539,7 +1542,6 @@ class ExitContract(unittest.TestCase): ("cycle/run.py", "ask", "1", "failure.reason", read), ("cycle/run.py", "close", "1", "failure.reason", read), ("cycle/run.py", "close", "1", "failure.reason", "a finished chunk's session cannot be deleted"), - ("loop/main.py", "past_limit", "1", "f'{failure.reason}\\n{stop.reason}'", read), ("loop/main.py", "archive_step", "1", "failure.reason", read), ("loop/main.py", "loop_run_from", "0 if task else 1", "__doc__.strip()", "no task is given"), ("loop/main.py", "loop_run_from", "1", 'f"the edited loop-claude cannot read the state', "a reload cannot read the state the running script handed it"), -- 2.52.0 From ca6bce76ce1ad82b6cf03c399d31aee4ecfcd5a0 Mon Sep 17 00:00:00 2001 From: Lilleman auf Larv Date: Wed, 28 Oct 2026 02:24:41 +0100 Subject: [PATCH 04/11] Say in the comment at UNFINISHED_LIMIT that it counts every unfinished verdict --- bin/loop_claude/loop/main.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/loop_claude/loop/main.py b/bin/loop_claude/loop/main.py index 0ca62357..db7975bf 100644 --- a/bin/loop_claude/loop/main.py +++ b/bin/loop_claude/loop/main.py @@ -145,7 +145,7 @@ from loop_claude.stop import needs_human, Stop # Seconds routing waits for origin to name its default branch, asked only where the checkout records none; past them, the chunk runs on the project's rung. ORIGIN_TIMEOUT = 60 -# How many unfinished verdicts running end the loop, so a worker and a judge that disagree about a chunk cannot cycle unattended without end. A policy number, not derived from the routing steps: well above the one unfinished verdict any archived chunk has had, and low enough that a stuck pair spends six worker and judge runs, not more. "loop-claude --help" states it. +# How many unfinished verdicts running end the loop, so a worker and a judge that disagree about a chunk cannot cycle unattended without end. A policy number, not derived from the routing steps: well above the one unfinished verdict any archived chunk has had, and low enough that a stuck pair spends six worker and judge runs, not more. It counts every unfinished verdict, including those of cycles where the human answered an interrupt: a rerun is cheap, and a chunk that needs six answers is worth a look. "loop-claude --help" states it. UNFINISHED_LIMIT = 6 -- 2.52.0 From 2815b895894a90b09b7e0672bea053de83b32667 Mon Sep 17 00:00:00 2001 From: Lilleman auf Larv Date: Wed, 28 Oct 2026 02:40:46 +0100 Subject: [PATCH 05/11] =?UTF-8?q?Answer=20stability=20round=201:=201=20?= =?UTF-8?q?=F0=9F=94=B4,=204=20=F0=9F=9F=A1=20(1=20misread);=20sort=20the?= =?UTF-8?q?=20imports,=20test=20the=20stop's=20stepped=20route=20on=20the?= =?UTF-8?q?=20ladder,=20fix=20the=20false=20archive=20claim,=20and=20asser?= =?UTF-8?q?t=20the=20stop's=20facts,=20not=20its=20sentence?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CHANGELOG.md | 2 +- bin/loop_claude/loop/main.py | 10 +++++----- bin/loop_claude/test_black_box.py | 17 ++++++++++++++--- bin/loop_claude/test_loop_claude.py | 5 ++--- 4 files changed, 22 insertions(+), 12 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 527d0330..d65c387d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,7 +2,7 @@ ## Unreleased -- `loop-claude` now stops with exit 2 when the judge rules one chunk unfinished 6 cycles running, so a worker and a judge that disagree can no longer cycle unattended without end. Rerunning resumes the chunk and gives it 6 more cycles. No chunk in the archive has had more than one unfinished verdict. +- `loop-claude` now stops with exit 2 when the judge rules one chunk unfinished 6 cycles running, so a worker and a judge that disagree can no longer cycle unattended without end. Rerunning resumes the chunk and gives it 6 more cycles. - larv-review now launches a round's reviewers in up to three waves, each wave's reviewers in one message, in place of one reviewer at a time: first the architect, then the principles auditors with the security and overrides passes, then the stability, product-owner and prose passes. Each wave now lasts as long as its slowest reviewer, where a round used to last as long as all its reviewers one after another. - loop-claude's worker, and every subagent it launches, now run with a 200k auto-compact window, handed as `CLAUDE_CODE_AUTO_COMPACT_WINDOW`: Claude Code compacts their context at about 170k tokens, where it used to let it grow to about 967k. loop-claude's judge no longer reads a compaction summary as words you typed. `CLAUDE.md` has a new section, "Compact instructions", saying what a summary keeps. - On Linux, `run-heavy` now caps the memory of a container its command makes with `docker run` or `docker create`. A container that sets no limit gets a memory limit and a swap limit, both the slot's share: three quarters of the machine's memory, split across the heavy slots. A container that sets one of the two limits keeps it, and gets the other as large. This covers containers a project's own scripts start, which rule-hook can't see. A `docker compose` service, and a docker named by its full path, get no cap. rule-hook's `docker-run-memory` now lets a `docker run` under run-heavy pass. diff --git a/bin/loop_claude/loop/main.py b/bin/loop_claude/loop/main.py index f760d2a5..6b960ed1 100644 --- a/bin/loop_claude/loop/main.py +++ b/bin/loop_claude/loop/main.py @@ -124,9 +124,9 @@ import typing from loop_claude.routing import after_unfinished, first_route, kept, routed_item from transcript_archive.write import archive from transcript_archive.location import archive_root, project_archive +from loop_claude.cycle.run import archived_stop, Concluded, Cycle, run_cycle from loop_claude.loop.routing_check import check_routing from loop_claude.project.checkout import checkout_root -from loop_claude.cycle.run import archived_stop, Concluded, Cycle, run_cycle from loop_claude.loop.reload import decode_handed, exec_if_edited, fingerprint, LoopRun, RELOAD_FLAG from chunk_pick import default_plan, DefaultPlan from git_repo import default_ref @@ -136,6 +136,7 @@ from loop_claude.verdicts import Finished, Unfinished from loop_claude.project.model_choice import get_or_ask_models from todo_table import Item from transcript_archive.read import latest_worker +from loop_claude.stop import needs_human, Stop from transcript_archive import outcomes from loop_claude.paths import Paths from project_key import project_key @@ -145,11 +146,10 @@ from loop_claude.project.premises import read_premises from loop_claude.project.records import read_records from model_routing.route import Route, route_from from claude_code.session import Session, session_named, session_open, transcript_file -from loop_claude.stop import needs_human, Stop # Seconds routing waits for origin to name its default branch, asked only where the checkout records none; past them, the chunk runs on the project's rung. ORIGIN_TIMEOUT = 60 -# How many unfinished verdicts running end the loop, so a worker and a judge that disagree about a chunk cannot cycle unattended without end. A policy number, not derived from the routing steps: well above the one unfinished verdict any archived chunk has had, and low enough that a stuck pair spends six worker and judge runs, not more. It counts every unfinished verdict, including those of cycles where the human answered an interrupt: a rerun is cheap, and a chunk that needs six answers is worth a look. "loop-claude --help" states it. +# How many unfinished verdicts running end the loop, so a worker and a judge that disagree about a chunk cannot cycle unattended without end. A policy number, not derived from the routing steps: well above the two unfinished verdicts running that archived chunks have reached at most, and low enough that a stuck pair spends six worker and judge runs, not more. It counts every unfinished verdict, including those of cycles where the human answered an interrupt: a rerun is cheap, and a chunk that needs six answers is worth a look. "loop-claude --help" states it. UNFINISHED_LIMIT = 6 @@ -217,13 +217,13 @@ def closed_cycle(loop_run: LoopRun, project: Rung | None, concluded: Concluded, after = after_verdict(loop_run, project, concluded) if stop := archive_step(archive_folder, session, after.task, concluded.route, after.route, effects): return stop - if limit := past_limit(after): + if limit := reached_limit(after): # An unfinished verdict always leaves a route. It is archived as the next cycle would run on it, so a rerun resumes there. return archived_stop(archive_folder, session, after.task, after.route or concluded.route, limit, limit.reason, effects) return after -def past_limit(loop_run: LoopRun) -> Stop | None: +def reached_limit(loop_run: LoopRun) -> Stop | None: """The stop that asks the human once the loop run holds UNFINISHED_LIMIT unfinished verdicts running.""" if loop_run.unfinished_run < UNFINISHED_LIMIT: return None diff --git a/bin/loop_claude/test_black_box.py b/bin/loop_claude/test_black_box.py index ec57b7c4..abd14196 100644 --- a/bin/loop_claude/test_black_box.py +++ b/bin/loop_claude/test_black_box.py @@ -647,19 +647,30 @@ class Cycles(unittest.TestCase): self.assertEqual((run.code, run.roles()), (1, ["worker"])) self.assertIn("claude left no transcript for session", run.stderr) - def test_exits_2_after_six_unfinished_verdicts_running_and_a_rerun_gets_six_more(self): checkout = Checkout(self) six = [step for _ in range(6) for step in (worker(), judge())] run = checkout.run(six + [worker()]) self.assertEqual((run.code, run.roles()), (2, ["worker", "judge"] * 6)) - self.assertEqual(run.stderr.strip().splitlines()[-1], "the human is needed to decide whether the chunk is finished, but the judge ruled it unfinished 6 cycles running and loop-claude does not go on unasked; finish the chunk yourself, or rerun loop-claude to give it 6 more cycles") + self.assertIn("the judge ruled it unfinished 6 cycles running", run.stderr.strip().splitlines()[-1]) + self.assertIn("rerun loop-claude to give it 6 more cycles", run.stderr.strip().splitlines()[-1]) stops = [outcome for outcome in checkout.archived().values() if "Stopped: " in outcome] self.assertEqual(len(stops), 1) - self.assertIn(f" Stopped: the human is needed to decide whether the chunk is finished, but the judge ruled it unfinished 6 cycles running and loop-claude does not go on unasked; finish the chunk yourself, or rerun loop-claude to give it 6 more cycles\n\nWorker: {OFF_LADDER}\n", stops[0]) + self.assertIn(f"\n\nWorker: {OFF_LADDER}\n", stops[0]) run = checkout.run(six[:-2] + [worker()]) self.assertEqual((run.code, run.roles()), (130, ["worker", "judge"] * 6)) + def test_archives_the_stop_on_the_route_the_sixth_verdict_stepped_to_and_a_rerun_resumes_there(self): + checkout = Checkout(self) + checkout.env["LOOP_CLAUDE_WORKER_MODEL"] = "claude-opus-5-5" + checkout.commit_plan(CHEAP) + run = checkout.run([step for _ in range(6) for step in (worker(), judge())] + [worker()]) + self.assertEqual(run.code, 2) + stepped = ' Stepped up\n\nWorker: {"model": "claude-opus-5-5", "effort": "xhigh", "item": 4, "likelihood": 2, "escape_and_impact": 3}\n\n Stopped: ' + self.assertEqual(len([outcome for outcome in checkout.archived().values() if stepped in outcome]), 1) + run = checkout.run([worker()]) + self.assertEqual([(argument(call, "--model"), argument(call, "--effort")) for call in run.calls if call["role"] == "worker"], [("claude-opus-5-5", "xhigh")]) + def test_five_unfinished_verdicts_and_a_finished_one_do_not_add_up_to_six(self): checkout = Checkout(self) five = [step for _ in range(5) for step in (worker(), judge())] diff --git a/bin/loop_claude/test_loop_claude.py b/bin/loop_claude/test_loop_claude.py index 967b86b8..61511e60 100644 --- a/bin/loop_claude/test_loop_claude.py +++ b/bin/loop_claude/test_loop_claude.py @@ -1013,9 +1013,6 @@ class Steps(unittest.TestCase): self.assertEqual(main.after_verdict(dataclasses.replace(run_with, unfinished_run=3), self.OPUS, run.Concluded(Finished("x"), run_with.route)).unfinished_run, 0) self.assertEqual(main.after_verdict(run_with, self.OPUS, run.Concluded(Unfinished("new", 4), run_with.route)), dataclasses.replace(run_with, route=Route(Rung("claude-opus-5-5", "high"), unfinished=1), unfinished_evidence="new", unfinished_run=1)) - def test_help_states_the_limit_of_unfinished_verdicts_running(self): - self.assertIn(f"unfinished {main.UNFINISHED_LIMIT} cycles running", " ".join(main.__doc__.split())) - def test_steps_from_the_route_its_cycle_ended_on_which_a_ruling_may_have_raised(self): run_with = main.LoopRun(cycle_number=1, root="/r", task="do it", unfinished_evidence="", route=Route(self.OPUS, 3, 3, 4)) raised = Route(Rung("claude-opus-5-5", "high"), 3, 3, 4, escalated_at=5) @@ -1521,6 +1518,8 @@ class HelpLimits(unittest.TestCase): self.assertIn(f"still running after {PYTHON_TIMEOUT} s", said) self.assertIn(f"Once {measure.CYCLES_PER_CHECK} cycles have closed across all projects", said) self.assertIn(f"run with a {worker.COMPACT_WINDOW // 1000}k auto-compact window", said) + self.assertIn(f"unfinished {main.UNFINISHED_LIMIT} cycles running", said) + self.assertIn(f"rerun to give it {main.UNFINISHED_LIMIT} more", said) class ExitContract(unittest.TestCase): -- 2.52.0 From 4bcead0b897776552561998a715fe62b1c4b0edf Mon Sep 17 00:00:00 2001 From: Lilleman auf Larv Date: Wed, 28 Oct 2026 02:40:46 +0100 Subject: [PATCH 06/11] =?UTF-8?q?Answer=20principles=20round=201:=201=20?= =?UTF-8?q?=F0=9F=94=B4,=203=20=F0=9F=9F=A1=20(0=20misread);=20the=20stabi?= =?UTF-8?q?lity=20round's=20commit=20fixes=20the=20import=20order=20and=20?= =?UTF-8?q?the=20untested=20stepped=20route,=20and=20folds=20the=20help=20?= =?UTF-8?q?test=20into=20HelpLimits;=20LoopRun=20keeps=20three=20fields=20?= =?UTF-8?q?since=20renaming=20one=20stops=20a=20running=20loop=20at=20its?= =?UTF-8?q?=20next=20reload?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit -- 2.52.0 From 8caf92dfbef3c1a88b74494b072816be9296ab6e Mon Sep 17 00:00:00 2001 From: Lilleman auf Larv Date: Wed, 28 Oct 2026 02:40:46 +0100 Subject: [PATCH 07/11] =?UTF-8?q?Answer=20product-owner=20round=201:=200?= =?UTF-8?q?=20=F0=9F=94=B4,=200=20=F0=9F=9F=A1=20(0=20misread);=20say=20in?= =?UTF-8?q?=20the=20comment=20at=20UNFINISHED=5FLIMIT=20that=20it=20counts?= =?UTF-8?q?=20every=20unfinished=20verdict?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit -- 2.52.0 From 7a7528fba837e36965e32efa2c9d64d04e38df27 Mon Sep 17 00:00:00 2001 From: Lilleman auf Larv Date: Wed, 28 Oct 2026 02:45:15 +0100 Subject: [PATCH 08/11] =?UTF-8?q?Answer=20prose=20round=201:=200=20?= =?UTF-8?q?=F0=9F=94=B4,=204=20=F0=9F=9F=A1=20(0=20misread);=20reword=20th?= =?UTF-8?q?e=20exit-2=20heading=20and=20bullet,=20drop=20the=20false=20cla?= =?UTF-8?q?im=20of=20six=20runs,=20say=20the=20stop=20needs=20the=20human,?= =?UTF-8?q?=20and=20record=20at=20LoopRun=20why=20its=20fields=20stay=20ap?= =?UTF-8?q?art?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- bin/loop_claude/loop/main.py | 15 +++++++-------- bin/loop_claude/loop/reload.py | 2 +- 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/bin/loop_claude/loop/main.py b/bin/loop_claude/loop/main.py index 6b960ed1..e384f4a3 100644 --- a/bin/loop_claude/loop/main.py +++ b/bin/loop_claude/loop/main.py @@ -106,13 +106,12 @@ Exit 1, saying why, when: more than 2 minutes past. The judge's reply gives its reset time only as text, so the judge is always retried every 10 minutes. stderr says when the next try is due. -Exit 2, when the human is needed to go on and cannot be asked, or the chunk has gone on too long: +Exit 2, when the human is needed to go on: - stdin or stdout is not a terminal, when a model must be picked or an interrupt answered - the input ends while a model is picked - an interrupt's answer is empty, or the input ends before one is typed - the claude opened for /talk, or for a release ready to cut, ends with nothing typed -- the judge rules a chunk unfinished 6 cycles running; finish the chunk yourself, or rerun to give it - 6 more. A finished chunk restarts the run. +- the judge rules a chunk unfinished 6 cycles running; rerun to give it 6 more Rerunning resumes any open session. """ @@ -149,7 +148,7 @@ from claude_code.session import Session, session_named, session_open, transcript # Seconds routing waits for origin to name its default branch, asked only where the checkout records none; past them, the chunk runs on the project's rung. ORIGIN_TIMEOUT = 60 -# How many unfinished verdicts running end the loop, so a worker and a judge that disagree about a chunk cannot cycle unattended without end. A policy number, not derived from the routing steps: well above the two unfinished verdicts running that archived chunks have reached at most, and low enough that a stuck pair spends six worker and judge runs, not more. It counts every unfinished verdict, including those of cycles where the human answered an interrupt: a rerun is cheap, and a chunk that needs six answers is worth a look. "loop-claude --help" states it. +# How many unfinished verdicts running end the loop, so a worker and a judge that disagree about a chunk cannot cycle unattended without end. A policy number, not derived from the routing steps: well above the two unfinished verdicts running that archived chunks have reached at most, and low enough that a stuck pair is stopped after six cycles. It counts every unfinished verdict, including those of cycles where the human answered an interrupt: a rerun is cheap, and a chunk that needs that many answers is worth a look. UNFINISHED_LIMIT = 6 @@ -213,21 +212,21 @@ def routed(route: Route | None, project: Rung | None, model: str, archived: typi def closed_cycle(loop_run: LoopRun, project: Rung | None, concluded: Concluded, archive_folder: pathlib.Path, session: Session, effects: Effects) -> LoopRun | Stop: - """The loop run after a cycle concluded, with the step-up archived; the stop that asks the human, archived, once the chunk has had UNFINISHED_LIMIT unfinished verdicts running.""" + """The loop run after a cycle concluded, with the step-up archived; the stop that needs the human, archived, once the chunk has had UNFINISHED_LIMIT unfinished verdicts running.""" after = after_verdict(loop_run, project, concluded) if stop := archive_step(archive_folder, session, after.task, concluded.route, after.route, effects): return stop if limit := reached_limit(after): - # An unfinished verdict always leaves a route. It is archived as the next cycle would run on it, so a rerun resumes there. + # An unfinished verdict always leaves a route. The stop is archived with that route, the one the next cycle would run on, so a rerun resumes there. return archived_stop(archive_folder, session, after.task, after.route or concluded.route, limit, limit.reason, effects) return after def reached_limit(loop_run: LoopRun) -> Stop | None: - """The stop that asks the human once the loop run holds UNFINISHED_LIMIT unfinished verdicts running.""" + """The stop that needs the human once the loop run holds UNFINISHED_LIMIT unfinished verdicts running.""" if loop_run.unfinished_run < UNFINISHED_LIMIT: return None - return needs_human("decide whether the chunk is finished", f"the judge ruled it unfinished {loop_run.unfinished_run} cycles running and loop-claude does not go on unasked; finish the chunk yourself, or rerun loop-claude to give it {UNFINISHED_LIMIT} more cycles") + return needs_human("go on with the chunk", f"the judge ruled it unfinished {loop_run.unfinished_run} cycles running; finish the chunk yourself, or rerun loop-claude to give it {UNFINISHED_LIMIT} more cycles") def after_verdict(loop_run: LoopRun, project: Rung | None, concluded: Concluded) -> LoopRun: diff --git a/bin/loop_claude/loop/reload.py b/bin/loop_claude/loop/reload.py index 8c4108a1..f6d8dd53 100644 --- a/bin/loop_claude/loop/reload.py +++ b/bin/loop_claude/loop/reload.py @@ -24,7 +24,7 @@ class LoopRun: unfinished_evidence: str # Set by each unfinished verdict; None before the chunk's first one, and once it finishes. route: Route | None = None - # How many unfinished verdicts the chunk has had running; a finished chunk restarts it, and a rerun starts it at 0. + # How many unfinished verdicts the chunk has had running; a finished chunk and a rerun each set it to 0. It stays apart from route and unfinished_evidence, though all three change together at each verdict: merging or renaming a field stops a running loop at its next reload. unfinished_run: int = 0 -- 2.52.0 From c64b3f362ddba8f296916c4db6ad1bfd4ec763ae Mon Sep 17 00:00:00 2001 From: Lilleman auf Larv Date: Wed, 28 Oct 2026 02:45:15 +0100 Subject: [PATCH 09/11] =?UTF-8?q?Answer=20principles=20round=202:=200=20?= =?UTF-8?q?=F0=9F=94=B4,=201=20=F0=9F=9F=A1=20(0=20misread);=20record=20at?= =?UTF-8?q?=20LoopRun=20why=20its=20three=20fields=20stay=20apart?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit -- 2.52.0 From 51faf71ecc117483a06a6bac2228f8a45fd394b1 Mon Sep 17 00:00:00 2001 From: Lilleman auf Larv Date: Wed, 28 Oct 2026 02:45:15 +0100 Subject: [PATCH 10/11] =?UTF-8?q?Answer=20stability=20round=202:=200=20?= =?UTF-8?q?=F0=9F=94=B4,=200=20=F0=9F=9F=A1=20(0=20misread);=20nothing=20t?= =?UTF-8?q?o=20change?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit -- 2.52.0 From 946815a4954e43d06ef1ec3aaa61522942d41acd Mon Sep 17 00:00:00 2001 From: Lilleman auf Larv Date: Wed, 28 Oct 2026 02:47:14 +0100 Subject: [PATCH 11/11] Record the comprehension check: PR #371 ruled the same --- bin/loop_claude/loop/main.py | 2 +- docs/comprehension-history.md | 25 +++++++++++++++++++++++++ 2 files changed, 26 insertions(+), 1 deletion(-) diff --git a/bin/loop_claude/loop/main.py b/bin/loop_claude/loop/main.py index e384f4a3..d51be907 100644 --- a/bin/loop_claude/loop/main.py +++ b/bin/loop_claude/loop/main.py @@ -217,7 +217,7 @@ def closed_cycle(loop_run: LoopRun, project: Rung | None, concluded: Concluded, if stop := archive_step(archive_folder, session, after.task, concluded.route, after.route, effects): return stop if limit := reached_limit(after): - # An unfinished verdict always leaves a route. The stop is archived with that route, the one the next cycle would run on, so a rerun resumes there. + # An unfinished verdict always leaves a route; the `or` only satisfies LoopRun.route's optional type. The stop is archived with that route, the one the next cycle would run on, so a rerun resumes there. return archived_stop(archive_folder, session, after.task, after.route or concluded.route, limit, limit.reason, effects) return after diff --git a/docs/comprehension-history.md b/docs/comprehension-history.md index 90e3fddd..46fcc58e 100644 --- a/docs/comprehension-history.md +++ b/docs/comprehension-history.md @@ -2767,3 +2767,28 @@ Junior A, decided by: - Locality: `bin/rule_hook/rules.py:154` `unlimited_container`: rule-hook copies run-heavy's PATH trick, and nothing in run_heavy points back to it - Locality: `bin/run_heavy/main.py:65` `capping`: one process sets RUN_HEAVY_MEMORY and PATH, and another reads them, so a docker run spans two processes + +## 2026-10-28T01:47:11Z, PR #371 at 51faf71, against 3bde9cd + +Ruling: same + +| Seat | Navigation | Locality | Shape | Self-sufficiency | Overall | +|---|---|---|---|---|---| +| Mid A | same | same | same | same | same | +| Inherited architect | same | same | same | same | same | + +Mid A, decided by: + +- Locality, Overall: `bin/loop_claude/loop/reload.py:28` `LoopRun.unfinished_run`: its name is one word from `Route.unfinished`, and the two reset at different times +- Locality: `bin/loop_claude/loop/main.py:214` `closed_cycle`: the order of archiving the step-up before the limit is checked has to be known, and the `or` fallback contradicts the comment above it +- Shape: `bin/loop_claude/cycle/worker.py:15` `AUTO_COMPACT_WINDOW`: the constant named for the window holds the environment variable's name +- Self-sufficiency: `bin/loop_claude/loop/main.py:151` `UNFINISHED_LIMIT`: the number rests on archive evidence the reader can't see +- Navigation: `bin/loop_claude/cycle/run.py:82` `archived_stop`: a loop-level stop goes through a cycle-level helper + +Inherited architect, decided by: + +- Locality, Overall: `bin/loop_claude/loop/main.py:214` `closed_cycle`: the order of its steps is easy to break, and the `or` fallback contradicts the comment above it +- Locality: `bin/loop_claude/loop/reload.py:28` `LoopRun.unfinished_run`: a rerun sets it to 0 only through the dataclass default, which the call site at `loop_run_from` doesn't say +- Navigation: `bin/loop_claude/cycle/judge.py:150` `run_judge`: the path from a rejected verdict to exit 1 crosses three files, and only some misquotes count +- Navigation, Shape: `bin/round_titles.py:8` `CAP`: the fourth-round cap lives in a module named for commit titles +- Self-sufficiency: `bin/loop_claude/loop/main.py:1` module docstring: the exit list maps a code to a cause, but no bullet links to the unit that raises it -- 2.52.0