From 2815b895894a90b09b7e0672bea053de83b32667 Mon Sep 17 00:00:00 2001 From: Lilleman auf Larv Date: Wed, 28 Oct 2026 02:40:46 +0100 Subject: [PATCH] =?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):