From b6c42bbf48e4b7458817dd8a578d2c7c2195e6f6 Mon Sep 17 00:00:00 2001 From: Lilleman auf Larv Date: Sun, 4 Oct 2026 17:15:41 +0200 Subject: [PATCH] Answer prose round 1: the help, changelog and resume prompt say who is shown the passage; the reload message names the state; item 59 holds one change --- CHANGELOG.md | 2 +- bin/loop_claude/claude_code/entries.py | 2 +- bin/loop_claude/cycle/run.py | 2 +- bin/loop_claude/cycle/worker.py | 2 +- bin/loop_claude/loop/main.py | 10 +++++----- bin/test_loop_claude.py | 6 +++--- todo.md | 4 +--- 7 files changed, 13 insertions(+), 15 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index da211ef7..97b7c486 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,7 +2,7 @@ ## Unreleased -- `loop-claude` resumes an unfinished chunk with the passage the judge quoted as the work remaining. A loop started before this change exits 1 at its next reload; rerun it. +- When `loop-claude`'s judge rules a chunk unfinished, the resumed worker is shown the passage the judge quoted as the work remaining. A loop started before this change exits 1 at its next reload; rerun it. - larv-review's architecture pass and full security scan get short names, `Architecture` and `Full scan`. Each round's commit is titled with its pass's name in lower case: `Answer full scan round 1: …`. - larv-review's comprehension floor now says, without another file open, what the scoring run measures. A project's `docs/decisions.md` keeps the last scoring run's scores, and a later run scoring below them blocks the merge until fixed. After three rounds larv-review asks you; an unattended run leaves the PR unmerged with the question. A PR under the floor that scores no lower than the last run merges once you decide to ship. A decision in `docs/decisions.md` that lets every chunk ship under the floor counts as yours. A project without those scores gets them at its next scoring run. - `loop-claude`'s judge reads your `~/.claude/CLAUDE.md` beside the project's `AGENTS.md` and `docs/decisions.md`. It no longer interrupts for a choice that file settles, and it answers the worker's questions from it. diff --git a/bin/loop_claude/claude_code/entries.py b/bin/loop_claude/claude_code/entries.py index 1bd0b534..84f2915a 100644 --- a/bin/loop_claude/claude_code/entries.py +++ b/bin/loop_claude/claude_code/entries.py @@ -65,7 +65,7 @@ def human_text(entry: dict) -> str | None: return text if isinstance(text, str) else "".join(part_text(part) or "" for part in parts(entry)) -# {"type": "user", "promptSource": "sdk", "message": {"content": "Continue the task; the previous run stopped before it was finished."}} +# {"type": "user", "promptSource": "sdk", "message": {"content": "Continue the task; the previous run ended before the chunk was finished."}} def loop_text(entry: dict) -> str | None: """What a -p prompt of loop-claude's told the agent.""" text = content(entry) diff --git a/bin/loop_claude/cycle/run.py b/bin/loop_claude/cycle/run.py index 674b635b..48e56ec2 100644 --- a/bin/loop_claude/cycle/run.py +++ b/bin/loop_claude/cycle/run.py @@ -117,6 +117,6 @@ def close(cycle: Cycle, transcript_path: str, verdict: Finished | Unfinished) -> return Archived() -# Blockquoted, so evidence holding blank lines still ends visibly where the next outcome starts. +# Blockquoted, so evidence holding blank lines still ends visibly where the text after it starts. def quoted(passage: str) -> str: return "\n".join(f"> {line}" for line in passage.splitlines()) diff --git a/bin/loop_claude/cycle/worker.py b/bin/loop_claude/cycle/worker.py index 8c910684..f131d30a 100644 --- a/bin/loop_claude/cycle/worker.py +++ b/bin/loop_claude/cycle/worker.py @@ -44,7 +44,7 @@ def worker_args(task: str, session: Session, model: str, resuming: bool, answere start = ["-p", f"Your question: {answered.question}\n\n{QUOTE_SOURCES} answers it:\n\n{answered.answer}\n\nContinue the task.", "--resume", str(session.id)] elif resuming: ruled = f" A judge ruled the chunk unfinished, quoting this passage of your transcript as the work remaining:\n\n{remaining}\n\n" if remaining else " " - start = ["-p", f"Continue the task; the previous run stopped before it was finished.{ruled}The chunk is finished once it is merged, or nothing remains that you could do on your own. Even then, it is finished only once {ANSWERS_RECORDED}.", "--resume", str(session.id)] + start = ["-p", f"Continue the task; the previous run ended before the chunk was finished.{ruled}The chunk is finished once it is merged, or nothing remains that you could do on your own. Even then, it is finished only once {ANSWERS_RECORDED}.", "--resume", str(session.id)] else: # --session-id creates the session under the id loop-claude keeps; --resume continues that session. start = ["-p", f"{task}\n\nContinue any open draft PR or worktree for the chunk before creating a new one.", "--name", session.name, "--session-id", str(session.id)] diff --git a/bin/loop_claude/loop/main.py b/bin/loop_claude/loop/main.py index 0d49b169..9de7f303 100644 --- a/bin/loop_claude/loop/main.py +++ b/bin/loop_claude/loop/main.py @@ -16,8 +16,8 @@ does a question asked again after its answer. The fourth question they answer in the human too, with the quote. A question only the human can answer, or a release ready to cut, is an interrupt: `claude --resume` on the terminal, every worktree first marked trusted in ~/.claude.json. An unfinished chunk resumes -its session next cycle, given the passage the judge quoted as the work remaining; the next chunk -starts a fresh session. +its session next cycle, and the worker is shown the passage the judge quoted as the work remaining. +The next chunk starts a fresh session. Cycles continue until an exit below or Ctrl-C. Words: ~/.claude/CLAUDE.md → "Vocabulary". Each project has one session, named "A loop-claude", where is the checkout's path @@ -53,8 +53,8 @@ Exit 1, saying why, when: - a finished chunk's session cannot be deleted - claude cannot start for an interrupt - python cannot start for a reload -- a reload cannot read the cycle number, work remaining, checkout root and task the running script - handed it, likely because the edit changed that handover +- a reload cannot read the state the running script handed it, likely because the edit changed that + handover - the worker or the judge fails three times running, retried a minute apart within the cycle. A worker fails when claude cannot start, exits non-zero, is killed, or ends without a result event; a judge when claude cannot start or exits non-zero, or its reply misses or mistypes a field, @@ -136,5 +136,5 @@ def loop_run_from(argv: list[str], cwd: pathlib.Path, effects: Effects) -> LoopR return root if isinstance(root, Stop) else LoopRun(0, "", root, task) loop_run = decode_handed(argv[1], LoopRun) if len(argv) == 2 else None if not (loop_run and loop_run.root and loop_run.task): - return Stop(1, f"the edited loop-claude cannot read the cycle number, work remaining, checkout root and task the running one handed it, likely because the edit changed that handover; rerun loop-claude . Handed: {' '.join(argv[1:])}") + return Stop(1, f"the edited loop-claude cannot read the state the running one handed it, likely because the edit changed that handover; rerun loop-claude . Handed: {' '.join(argv[1:])}") return loop_run diff --git a/bin/test_loop_claude.py b/bin/test_loop_claude.py index 978edaba..300be867 100644 --- a/bin/test_loop_claude.py +++ b/bin/test_loop_claude.py @@ -397,7 +397,7 @@ class WorkerArgs(unittest.TestCase): resumed = worker.worker_args("Do it.", opened, "m", True) self.assertEqual(resumed[resumed.index("--resume") + 1], str(opened.id)) self.assertNotIn("Do it.", " ".join(resumed)) - self.assertTrue(resumed[resumed.index("-p") + 1].startswith("Continue the task; the previous run stopped before it was finished. The chunk is finished once")) + self.assertTrue(resumed[resumed.index("-p") + 1].startswith("Continue the task; the previous run ended before the chunk was finished. The chunk is finished once")) class Records(unittest.TestCase): @@ -570,7 +570,7 @@ class LoopRuns(unittest.TestCase): def test_stops_naming_the_reload_when_it_hands_over_anything_but_the_state_with_a_task(self): for handed in (["3", "2", "/r", "do it"], ["3"], ["[1]"], [json.dumps({"cycle_number": 3, "remaining": "", "root": "/r"})], [json.dumps({"cycle_number": 3, "remaining": "", "root": "/r", "task": ""})], [json.dumps({"cycle_number": "3", "remaining": "", "root": "/r", "task": "do it"})], [json.dumps({"cycle_number": 3, "remaining": "", "root": "", "task": "do it"})], [json.dumps({"cycle_number": 3, "remaining": "", "root": "/r", "task": "do it", "turns": 1})], [json.dumps({"cycle_number": 3, "failures": 0, "remaining": "", "root": "/r", "task": "do it"})]): with self.subTest(handed=handed): - self.assertEqual(main.loop_run_from([main.RELOAD_FLAG, *handed], CWD, FakeEffects().effects()), Stop(1, f"the edited loop-claude cannot read the cycle number, work remaining, checkout root and task the running one handed it, likely because the edit changed that handover; rerun loop-claude . Handed: {' '.join(handed)}")) + self.assertEqual(main.loop_run_from([main.RELOAD_FLAG, *handed], CWD, FakeEffects().effects()), Stop(1, f"the edited loop-claude cannot read the state the running one handed it, likely because the edit changed that handover; rerun loop-claude . Handed: {' '.join(handed)}")) def test_decodes_a_state_whose_annotations_are_strings(self): @dataclasses.dataclass(frozen=True) @@ -617,7 +617,7 @@ class ExitContract(unittest.TestCase): ("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", "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 cycle number,', "a reload cannot read the cycle number, work remaining, checkout root and task"), + ("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"), ("loop/reload.py", "exec_if_edited", "1", "f'could not reload loop-claude:", "python cannot start for a reload"), ("project/checkout.py", "checkout_root", "1", "f'could not start git:", git), ("project/checkout.py", "checkout_root", "1", "found.stderr.strip()", git), diff --git a/todo.md b/todo.md index 8ffb7bc0..f07556c7 100644 --- a/todo.md +++ b/todo.md @@ -68,9 +68,7 @@ The repo has no CI, so larv-review's gate is the local run, and larv-review's Ga ### 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 now 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 4.4). - -The quote is the worker's own words, so it may not say why they fall short; the product-owner review of PR #214 suggests the judge also name what remains, which needs a check other than the transcript grounding the quote has. +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 4.4). ### 5. Key a project on its checkout's full path, and refuse to start while another session uses that key.