From a48ac5c16a0ef61be196c415f87c0f821887bc16 Mon Sep 17 00:00:00 2001 From: Lilleman auf Larv Date: Sat, 3 Oct 2026 20:57:24 +0200 Subject: [PATCH 01/16] Keep every answer on record: the judge reads CLAUDE.md, holds a chunk open for an unrecorded answer, and archives each answer it quotes --- AGENTS.md | 2 +- CHANGELOG.md | 3 +++ bin/loop_claude/cycle/judge.py | 2 +- bin/loop_claude/cycle/judge_reply.py | 20 +++++++++-------- bin/loop_claude/cycle/run.py | 9 ++++++++ bin/loop_claude/cycle/worker.py | 4 ++-- bin/loop_claude/loop/main.py | 33 +++++++++++++++------------- bin/loop_claude/paths.py | 2 ++ bin/loop_claude/project/records.py | 15 +++++++------ bin/test_loop_claude.py | 33 ++++++++++++++++++---------- bin/test_loop_claude_black_box.py | 7 ++++-- docs/decisions.md | 6 +++-- todo.md | 15 ------------- 13 files changed, 85 insertions(+), 66 deletions(-) diff --git a/AGENTS.md b/AGENTS.md index 640a7ed5..8381c19e 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -3,7 +3,7 @@ Decisions live in `docs/decisions.md`: - larv-review: a project under the comprehension floor is fixed at the capping dimension -- loop-claude: a judge decides each interrupt and each quoted answer from the transcript, the README's premises, `AGENTS.md` and `docs/decisions.md`; the worker's own account of which goal settles a choice decides nothing +- loop-claude: a judge decides each interrupt and each quoted answer from the transcript, the README's premises, `AGENTS.md`, `docs/decisions.md` and `~/.claude/CLAUDE.md`, and holds a chunk open while an answer the human typed in it is recorded nowhere; the worker's own account of which goal settles a choice decides nothing - loop-claude: one session per project, its id derived from the checkout's path relative to `~/code`, or to `/` outside it - loop-claude: before an interrupt, it marks the checkout and each of its worktrees trusted in `~/.claude.json` - bin/: the tests rerun themselves on a `uv`-fetched Python at README Install's floor diff --git a/CHANGELOG.md b/CHANGELOG.md index 52e66790..cbfb36a0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,9 @@ ## Unreleased +- `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. +- `loop-claude`'s judge holds a chunk open while an answer you typed in it, that a later chunk could need, is recorded nowhere. It counts as recorded in the README's goals or audience, in `AGENTS.md` or `docs/decisions.md`, or in a code comment the transcript shows the worker writing. The resumed worker is told this rule. +- `loop-claude` archives each answer the judge quotes from the records in `.outcomes.md`, with the question it answers and its UTC time. - larv-review keeps its three-round cap across a resumed session. It closes each review round with a commit naming the pass and the round, empty when the round changed nothing, and counts rounds from the branch's own commits. - larv-review runs `/security-review` in a subagent, so the run goes on to the next pass without you prompting it. - larv-review asks once before the full security scan: it states the evidence and its recommendation, and `claude-security`'s cost prompt is the ask. diff --git a/bin/loop_claude/cycle/judge.py b/bin/loop_claude/cycle/judge.py index 130544b9..c9eb7ea1 100644 --- a/bin/loop_claude/cycle/judge.py +++ b/bin/loop_claude/cycle/judge.py @@ -54,7 +54,7 @@ def judge_prompt(task: str, premises: str, records: str, rendered_transcript: st """The prompt, and the part of the transcript it shows, which the judge's evidence must quote.""" head = ( f"From README.md:\n{premises}\n\n" - f"The project's records, its working rules and decisions:\n{records or 'none'}\n\n" + f"The records: the project's working rules and decisions, then the human's rules for every project:\n{records or 'none'}\n\n" f"The task an agent was given:\n{task}\n\n" "What the agent did and said, what the human typed on [human] lines and what loop-claude told it on [loop] lines, latest last:\n" ) diff --git a/bin/loop_claude/cycle/judge_reply.py b/bin/loop_claude/cycle/judge_reply.py index c7f8e1db..eb5b0c4e 100644 --- a/bin/loop_claude/cycle/judge_reply.py +++ b/bin/loop_claude/cycle/judge_reply.py @@ -3,39 +3,41 @@ import typing from failure import Failure +ANSWERS_RECORDED = "every answer the human typed in it that a later chunk could need is recorded: in README.md's Goals or Audience, in AGENTS.md or docs/decisions.md, or in a comment at the one place it governs" JUDGE_RULES = ( "Decide whether the human must now be interrupted. interrupt=true when any of these appear:\n" "- the agent asks the human anything, seeks approval, or says a decision is the human's, and neither " - "README.md nor the project's records settle the matter\n" + "README.md nor the records settle the matter\n" "- it asks again a question a [loop] line already answered\n" "- it carried on under an assumption that decides the deliverable, that the human could " - "reasonably reject and that neither README.md nor the project's records settle; a caveat about " + "reasonably reject and that neither README.md nor the records settle; a caveat about " "transient state it then handled is not one\n" "- it is blocked on something only the human can supply: a credential, a version bump, a choice " "outside the repo, or a release ready to cut, which only the human may publish\n" "- it flags that the goals, the plan in todo.md or the task itself is unclear, missing or in need of change\n" - "- it chose between alternatives that neither README.md nor the project's records discriminate " + "- it chose between alternatives that neither README.md nor the records discriminate " "between - neither rules the rejected one out - and the choice materially changes the deliverable\n" "interrupt=false otherwise. Bookkeeping the agent settled silently - what to document, wording, " "where a note goes - is not on its own a reason to interrupt. The human may have replied inside the transcript, on a [human] line: judge only what " "is still open, never a question they already answered there. A [loop] line is what loop-claude told " - "the agent, such as an answer quoted from README.md or the project's records.\n" + "the agent, such as an answer quoted from README.md or the records.\n" "Where the agent asked or flagged something itself, the question is that one, in the agent's own " "wording; never construct another from facts it stated.\n" - "Where README.md or the project's records answer the agent's own question and no [loop] line has " + "Where README.md or the records answer the agent's own question and no [loop] line has " "quoted that answer yet, set interrupt=false and quote the passage that answers it; the agent is " "then given that passage in place of the human's reply. An interrupt outranks a quoted answer, and either " "outranks finished.\n" "The chunk is the piece of work the agent is on, shipped as one pull request. " "finished=true when the chunk is complete: merged, or nothing remains that the agent could do on " - "its own. finished=false when work remains that a further run can continue: an open PR, a review " - "not yet run, CI not yet reported." + f"its own, and {ANSWERS_RECORDED}. Judge that from the files above; a comment counts only where the " + "transcript shows the agent writing it. finished=false when work remains that a further run can " + "continue: an open PR, a review not yet run, CI not yet reported, an answer not yet recorded." ) @dataclasses.dataclass(frozen=True) class Reply: - answer: str = dataclasses.field(metadata={"description": "With interrupt false, the passage of README.md or the project's records that answers the agent's question, quoted verbatim, without elisions. Empty otherwise."}) + answer: str = dataclasses.field(metadata={"description": "With interrupt false, the passage of README.md or the records that answers the agent's question, quoted verbatim, without elisions. Empty otherwise."}) evidence: str = dataclasses.field(metadata={"description": "A verbatim quote of the one transcript passage the verdict rests on, without elisions: what triggers the interrupt; for a quoted answer, the agent's question; else what shows the chunk finished or the work remaining."}) finished: bool = dataclasses.field(metadata={"description": "Whether the chunk is finished."}) interrupt: bool = dataclasses.field(metadata={"description": "Whether the human must now be interrupted."}) @@ -59,7 +61,7 @@ class Interrupt: @dataclasses.dataclass(frozen=True) class QuotedAnswer: - """The agent asked a question that README.md or the project's records answer. The answer field quotes the passage.""" + """The agent asked a question that README.md or the records answer. The answer field quotes the passage.""" evidence: str question: str answer: str diff --git a/bin/loop_claude/cycle/run.py b/bin/loop_claude/cycle/run.py index 195643d0..dcf16344 100644 --- a/bin/loop_claude/cycle/run.py +++ b/bin/loop_claude/cycle/run.py @@ -68,6 +68,8 @@ def step(cycle: Cycle, state: Active) -> Event | Stop: def work(cycle: Cycle, answered: QuotedAnswer | None) -> WorkerRan | Stop: if answered is not None: print(f"\n=== {QUOTE_SOURCES} answered: {answered.question} ===\n{answered.answer}", flush=True) + if stop := keep_answer(cycle, answered): + return stop # session_open runs inside the lambda: a failed attempt may have opened the session. if stop := retried("worker", lambda: run_worker(cycle.root, worker_args(cycle.task, cycle.session, cycle.models.worker, session_open(cycle.session), answered), cycle.effects), cycle.effects): return stop @@ -75,6 +77,13 @@ def work(cycle: Cycle, answered: QuotedAnswer | None) -> WorkerRan | Stop: return WorkerRan(path) if path is not None else Stop(1, f"claude left no transcript for session {cycle.session.id}") +def keep_answer(cycle: Cycle, answered: QuotedAnswer) -> Stop | None: + path = transcript_file(cycle.session) + if path and (failure := archive(cycle.project_key, path, cycle.task, f"Verdict: quoted answer\n\n{answered.question}\n\n{QUOTE_SOURCES} says:\n{quoted(answered.answer)}\n\nEvidence:\n{quoted(answered.evidence)}", cycle.effects.now(), cycle.paths)): + return Stop(1, failure.reason) + return None + + def rule(cycle: Cycle, transcript_path: str) -> Ruled | Stop: entries = read_transcript(transcript_path) if isinstance(entries, Failure): diff --git a/bin/loop_claude/cycle/worker.py b/bin/loop_claude/cycle/worker.py index 55775434..238ec6cc 100644 --- a/bin/loop_claude/cycle/worker.py +++ b/bin/loop_claude/cycle/worker.py @@ -1,10 +1,10 @@ +from loop_claude.cycle.judge_reply import ANSWERS_RECORDED, QuotedAnswer from loop_claude.claude_code.entries import assistant_parts, ends_stream, hit_limit, limit_said, parse_entry, rejected_until from loop_claude.effects import Effects from failure import Failure from loop_claude.cycle.retry import Limited from loop_claude.claude_code.transcript import part_line from loop_claude.project.records import QUOTE_SOURCES -from loop_claude.cycle.judge_reply import QuotedAnswer from loop_claude.claude_code.session import Session PRINTED_TOOL_INPUT = 160 @@ -43,7 +43,7 @@ def worker_args(task: str, session: Session, model: str, resuming: bool, answere if answered is not None: 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: - start = ["-p", "Continue the task; the previous run stopped before it was finished.", "--resume", str(session.id)] + start = ["-p", f"Continue the task; the previous run stopped before it was finished. The chunk is finished once it is merged and {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 222c63fd..f6ef4a18 100644 --- a/bin/loop_claude/loop/main.py +++ b/bin/loop_claude/loop/main.py @@ -4,13 +4,15 @@ usage: loop-claude Run it anywhere inside a project checkout whose README.md has ## Goals and ## Audience, the premises; the task runs at the checkout root. Each cycle a worker runs the task. A judge then reads -the transcript's end, the premises, and the project's records: AGENTS.md and docs/decisions.md, -where they exist. It rules whether the chunk, the work of one PR, is finished. A choice the worker -made that the premises or the records settle is not asked about. When the worker asks a question -they answer, the judge quotes the answer, loop-claude prints it, and the worker resumes with it. A -quote they do not hold word for word is dropped, and the question goes to the human. So does a -question asked again after its answer. The fourth question they answer in one cycle goes to the -human too, with the quote. +the transcript's end, the premises, and the records: the project's AGENTS.md and docs/decisions.md +and the human's ~/.claude/CLAUDE.md, where they exist. It rules whether the chunk, the work of one +PR, is finished. It is not while an answer the human typed in it, that a later chunk could need, is +recorded nowhere: not in the premises, AGENTS.md or docs/decisions.md, nor in a code comment the +transcript shows the worker writing. A choice the worker made that the premises or the records +settle is not asked about. When the worker asks a question they answer, the judge quotes the +answer, loop-claude prints it, and the worker resumes with it. A quote they do not hold word for +word is dropped, and the question goes to the human. So does a question asked again after its +answer. The fourth question they answer in one cycle goes to 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; the next chunk starts a fresh session. @@ -22,12 +24,12 @@ interrupt, and as every cycle ends, Ctrl-C and a failure included, the session's copied to $LOOP_CLAUDE_TRANSCRIPTS///.jsonl (default ~/.claude/loop-claude-transcripts), named by its hash. is the hash of the transcript's first line with a timestamp, the same for every cycle of a chunk. Beside the copy, .outcomes.md -holds the verdict, with the transcript passage the judge rested it on, and why the loop stopped. The -verdict and the stop each open with their UTC time. Claude Code keeps a folder per session beside -its transcript, holding the subagents' transcripts among other files; that folder, and every other -file named after the session except the transcript, are copied into /session/. A file there -is replaced only by a version that grew from it. A file Claude Code rewrote lands beside its copy as -.. +holds the verdict, with the transcript passage the judge rested it on; each answer quoted from the +records, with the question it answers; and why the loop stopped. Each of these opens with its UTC +time. Claude Code keeps a folder per session beside its transcript, holding the subagents' +transcripts among other files; that folder, and every other file named after the session except +the transcript, are copied into /session/. A file there is replaced only by a version that +grew from it. A file Claude Code rewrote lands beside its copy as .. Every claude loop-claude starts runs the project's model, saved per in ~/.claude/loop-claude-models.json and read each cycle; a project without an entry, as on its first @@ -40,7 +42,8 @@ loop-claude --help succeeds: the loop reloads into the edited script. Exit 1, saying why, when: - no task is given - git cannot start or finds no checkout -- README.md, or AGENTS.md or docs/decisions.md where they exist, cannot be read or is not UTF-8 +- README.md, or AGENTS.md, docs/decisions.md or ~/.claude/CLAUDE.md where they exist, cannot be + read or is not UTF-8 - README.md holds no premises - the models file cannot be read or written - claude leaves no transcript @@ -108,7 +111,7 @@ def run_loop(argv: list[str], env: typing.Mapping[str, str], paths: Paths, launc premises = read_premises(loop_run.root) if isinstance(premises, Stop): return premises - records = read_records(loop_run.root) + records = read_records(loop_run.root, paths.claude_md) if isinstance(records, Stop): return records models = get_or_ask_models(key, paths, env, effects) diff --git a/bin/loop_claude/paths.py b/bin/loop_claude/paths.py index 35ecdbc5..2b4e24eb 100644 --- a/bin/loop_claude/paths.py +++ b/bin/loop_claude/paths.py @@ -7,6 +7,7 @@ import typing class Paths: claude_code_transcripts: pathlib.Path claude_json: pathlib.Path + claude_md: pathlib.Path code: pathlib.Path model_catalog: pathlib.Path models_file: pathlib.Path @@ -18,6 +19,7 @@ def paths_from(home: pathlib.Path, env: typing.Mapping[str, str]) -> Paths: return Paths( claude_code_transcripts=claude / "projects", claude_json=home / ".claude.json", + claude_md=claude / "CLAUDE.md", code=home / "code", model_catalog=claude / "cache" / "model-catalog", models_file=claude / "loop-claude-models.json", diff --git a/bin/loop_claude/project/records.py b/bin/loop_claude/project/records.py index 42fe7d33..e764fadf 100644 --- a/bin/loop_claude/project/records.py +++ b/bin/loop_claude/project/records.py @@ -4,18 +4,19 @@ from loop_claude.project.checkout import read_checkout_file from loop_claude.stop import Stop RECORD_FILES = ("AGENTS.md", "docs/decisions.md") +HUMAN_RULES = "~/.claude/CLAUDE.md" # The files a quoted answer comes from, named as the human and the worker see them; of README.md the judge sees only the premises. -QUOTE_SOURCES = "README.md's Goals and Audience, " + " or ".join(RECORD_FILES) +QUOTE_SOURCES = "README.md's Goals and Audience, " + ", ".join(RECORD_FILES) + " or " + HUMAN_RULES -def read_records(root: str) -> str | Stop: - """The record files, each headed by its path; a file the project lacks is left out.""" +def read_records(root: str, claude_md: pathlib.Path) -> str | Stop: + """The project's record files, then the human's rules for every project, each headed by its name; a file that does not exist is left out.""" records = [] - for name in RECORD_FILES: - if not pathlib.Path(root, name).exists(): + for folder, name, heading in (*((root, name, name) for name in RECORD_FILES), (str(claude_md.parent), claude_md.name, HUMAN_RULES)): + if not pathlib.Path(folder, name).exists(): continue - text = read_checkout_file(root, name, "the judge cannot read the project's records") + text = read_checkout_file(folder, name, "the judge cannot read the records") if isinstance(text, Stop): return text - records.append(f"From {name}:\n{text.strip()}") + records.append(f"From {heading}:\n{text.strip()}") return "\n\n".join(records) diff --git a/bin/test_loop_claude.py b/bin/test_loop_claude.py index 9604a58d..8f7b3f61 100644 --- a/bin/test_loop_claude.py +++ b/bin/test_loop_claude.py @@ -159,7 +159,7 @@ class Transitions(unittest.TestCase): class QuestionFor(unittest.TestCase): def test_puts_an_interrupts_question_as_asked_and_a_quoted_answer_past_the_cap_with_its_quote(self): self.assertEqual(run.question_for(Interrupt("e", "Which one?")), "Which one?") - self.assertEqual(run.question_for(QuotedAnswer("e", "Which one?", "A.")), "Which one?\n\nREADME.md's Goals and Audience, AGENTS.md or docs/decisions.md says:\nA.\n\nThose files have answered 3 questions this cycle, the most allowed, so this one comes to you.") + self.assertEqual(run.question_for(QuotedAnswer("e", "Which one?", "A.")), "Which one?\n\nREADME.md's Goals and Audience, AGENTS.md, docs/decisions.md or ~/.claude/CLAUDE.md says:\nA.\n\nThose files have answered 3 questions this cycle, the most allowed, so this one comes to you.") class Quoted(unittest.TestCase): @@ -261,10 +261,12 @@ class Cycles(unittest.TestCase): with contextlib.redirect_stderr(io.StringIO()) as said, contextlib.redirect_stdout(io.StringIO()) as printed: self.assertEqual(run.run_cycle(self.cycle(fake, records="From AGENTS.md:\nUse A.")), Stop(2, "the human is needed to answer the question above, but the interrupt ended with nothing typed")) resumed = fake.made("stream_claude")[1] - self.assertEqual(resumed[resumed.index("-p") + 1], "Your question: Which one?\n\nREADME.md's Goals and Audience, AGENTS.md or docs/decisions.md answers it:\n\nUse *A*.\n\nContinue the task.") + self.assertEqual(resumed[resumed.index("-p") + 1], "Your question: Which one?\n\nREADME.md's Goals and Audience, AGENTS.md, docs/decisions.md or ~/.claude/CLAUDE.md answers it:\n\nUse *A*.\n\nContinue the task.") self.assertEqual(len(fake.made("stream_claude")), 4) - self.assertEqual(printed.getvalue().count("=== README.md's Goals and Audience, AGENTS.md or docs/decisions.md answered: Which one? ===\nUse *A*."), 3) - self.assertIn("Which one?\n\nREADME.md's Goals and Audience, AGENTS.md or docs/decisions.md says:\nUse *A*.\n\nThose files have answered 3 questions this cycle", said.getvalue()) + self.assertEqual(printed.getvalue().count("=== README.md's Goals and Audience, AGENTS.md, docs/decisions.md or ~/.claude/CLAUDE.md answered: Which one? ===\nUse *A*."), 3) + self.assertIn("Which one?\n\nREADME.md's Goals and Audience, AGENTS.md, docs/decisions.md or ~/.claude/CLAUDE.md 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 or ~/.claude/CLAUDE.md says:\n> Use *A*.\n\nEvidence:\n> working\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 or ~/.claude/CLAUDE.md 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\n2026-09-21T14:13:20Z Stopped: the human is needed to answer the question above, but the interrupt ended with nothing typed\n", *[f"Task: Do it.\n\n{quoted}"] * 3]) def test_an_answer_the_records_do_not_hold_is_dropped_and_the_question_goes_to_the_human(self): fake = FakeEffects(streams=[Worker(self.paths.claude_code_transcripts.parent)], claude=[judged("quoted", answer="Use ... A.")], on_terminal_claude=[0], git=[ran()]) @@ -388,21 +390,27 @@ class WorkerArgs(unittest.TestCase): class Records(unittest.TestCase): - def test_heads_each_record_the_project_has_by_its_path(self): + def test_heads_each_record_by_its_name_the_humans_rules_last(self): with tempfile.TemporaryDirectory() as root: - self.assertEqual(records.read_records(root), "") + claude_md = pathlib.Path(root, "home", ".claude", "CLAUDE.md") + self.assertEqual(records.read_records(root, claude_md), "") + claude_md.parent.mkdir(parents=True) + claude_md.write_text("# Global\n") + self.assertEqual(records.read_records(root, claude_md), "From ~/.claude/CLAUDE.md:\n# Global") pathlib.Path(root, "docs").mkdir() pathlib.Path(root, "docs", "decisions.md").write_text("# Decisions\n") - self.assertEqual(records.read_records(root), "From docs/decisions.md:\n# Decisions") pathlib.Path(root, "AGENTS.md").write_text("\n# Rules\n") - self.assertEqual(records.read_records(root), "From AGENTS.md:\n# Rules\n\nFrom docs/decisions.md:\n# Decisions") + self.assertEqual(records.read_records(root, claude_md), "From AGENTS.md:\n# Rules\n\nFrom docs/decisions.md:\n# Decisions\n\nFrom ~/.claude/CLAUDE.md:\n# Global") def test_stops_on_a_record_it_cannot_read(self): with tempfile.TemporaryDirectory() as root: + claude_md = pathlib.Path(root, "home", ".claude", "CLAUDE.md") + claude_md.mkdir(parents=True) + self.assertEqual(records.read_records(root, claude_md), Stop(1, f"CLAUDE.md in {claude_md.parent}: Is a directory - the judge cannot read the records.")) pathlib.Path(root, "docs", "decisions.md").mkdir(parents=True) - self.assertEqual(records.read_records(root), Stop(1, f"docs/decisions.md in {root}: Is a directory - the judge cannot read the project's records.")) + self.assertEqual(records.read_records(root, claude_md), Stop(1, f"docs/decisions.md in {root}: Is a directory - the judge cannot read the records.")) pathlib.Path(root, "AGENTS.md").write_bytes(b"# Rules\n\xff\n") - self.assertEqual(records.read_records(root), Stop(1, f"AGENTS.md in {root} is not UTF-8 on line 2 - the judge cannot read the project's records.")) + self.assertEqual(records.read_records(root, claude_md), Stop(1, f"AGENTS.md in {root} is not UTF-8 on line 2 - the judge cannot read the records.")) class Render(unittest.TestCase): @@ -583,7 +591,7 @@ class ExitContract(unittest.TestCase): def test_every_exit_1_stop_has_its_clause_in_help(self): read, git, premises_ = "a transcript cannot be read or archived", "git cannot start or finds no checkout", "README.md holds no premises" models_ = "the models file cannot be read or written" - unreadable = f"README.md, or {' or '.join(records.RECORD_FILES)} where they exist, cannot be read or is not UTF-8" + unreadable = f"README.md, or {', '.join(records.RECORD_FILES)} or {records.HUMAN_RULES} where they exist, cannot be read or is not UTF-8" # Every Stop whose code is not a literal 0, 2 or 130, in source order: path, function, code, start of reason, its --help clause. clauses = [ ("cycle/interrupt.py", "interrupt", "1", "entries.reason", read), @@ -592,6 +600,7 @@ class ExitContract(unittest.TestCase): ("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", "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), ("cycle/run.py", "ask", "1", "failure.reason", read), ("cycle/run.py", "close", "1", "failure.reason", read), @@ -620,7 +629,7 @@ class ExitContract(unittest.TestCase): for (path, function, code, reason), (want_path, want_function, want_code, reason_start, _) in zip(found, clauses): self.assertEqual((path, function, code), (want_path, want_function, want_code)) self.assertTrue(reason.startswith(reason_start), f"{path} {function}: {reason}") - help_exit_1 = main.__doc__[main.__doc__.index("Exit 1"):main.__doc__.index("Exit 2")] + help_exit_1 = " ".join(main.__doc__[main.__doc__.index("Exit 1"):main.__doc__.index("Exit 2")].split()) self.assertEqual([clause for *_, clause in clauses if f"- {clause}" not in help_exit_1], []) diff --git a/bin/test_loop_claude_black_box.py b/bin/test_loop_claude_black_box.py index caee0b24..3cb3698f 100644 --- a/bin/test_loop_claude_black_box.py +++ b/bin/test_loop_claude_black_box.py @@ -326,6 +326,8 @@ class Cycles(unittest.TestCase): (checkout.root / "sub").mkdir() (checkout.root / "docs").mkdir() (checkout.root / "docs" / "decisions.md").write_text("# Decisions\n") + (checkout.home / ".claude").mkdir() + (checkout.home / ".claude" / "CLAUDE.md").write_text("# Global instructions\n") run = checkout.run([ worker(say="started"), judge(evidence="started"), worker(say="landed-it", siblings=True), judge(finished=True, evidence="landed-it"), @@ -342,9 +344,10 @@ class Cycles(unittest.TestCase): self.assertEqual(argument(workers[2], "--session-id"), session) self.assertTrue(argument(workers[0], "-p").startswith(f"{TASK}\n\nContinue any open draft PR")) self.assertNotIn(TASK, argument(workers[1], "-p")) + self.assertIn("The chunk is finished once it is merged and every answer the human typed in it", argument(workers[1], "-p")) self.assertEqual({call["cwd"] for call in run.calls}, {str(checkout.root)}) self.assertIn("1. Work.", run.calls[1]["stdin"]) - self.assertIn("From docs/decisions.md:\n# Decisions", run.calls[1]["stdin"]) + self.assertIn("From docs/decisions.md:\n# Decisions\n\nFrom ~/.claude/CLAUDE.md:\n# Global instructions", run.calls[1]["stdin"]) self.assertEqual({argument(call, "--model") for call in workers}, {"worker-model"}) self.assertEqual({argument(call, "--model") for call in run.calls if call["role"] == "judge"}, {"judge-model"}) self.assertIn("landed-it", run.calls[3]["stdin"]) @@ -436,7 +439,7 @@ class Cycles(unittest.TestCase): self.assertIn("LATE", run.calls[1]["stdin"]) self.assertEqual(len(run.calls[1]["stdin"]), 400000) self.assertLess(run.calls[1]["stdin"].count("early"), 80000) - self.assertTrue(run.calls[1]["stdin"].rstrip().endswith("an open PR, a review not yet run, CI not yet reported.")) + self.assertTrue(run.calls[1]["stdin"].rstrip().endswith("CI not yet reported, an answer not yet recorded.")) def test_skips_a_malformed_transcript_or_stream_line(self): checkout = Checkout(self) diff --git a/docs/decisions.md b/docs/decisions.md index 51479ca7..67e54b53 100644 --- a/docs/decisions.md +++ b/docs/decisions.md @@ -4,13 +4,15 @@ 2026-09-20, lilleman. Serves goal 4. Across six projects scored with the four seats, Locality or Self-sufficiency capped every seat and Navigation capped none, so a layout fix would not lift a project under the floor. Valid while the scoring run keeps those four seats. -## loop-claude: a judge decides each interrupt and each quoted answer from the transcript, the README's premises, `AGENTS.md` and `docs/decisions.md`; the worker's own account of which goal settles a choice decides nothing +## loop-claude: a judge decides each interrupt and each quoted answer from the transcript, the README's premises, `AGENTS.md`, `docs/decisions.md` and `~/.claude/CLAUDE.md`, and holds a chunk open while an answer the human typed in it is recorded nowhere; the worker's own account of which goal settles a choice decides nothing 2026-09-21, lilleman. Serves goal 4. Asked to name the goal behind each choice, the worker cites a real goal for a choice that goal does not settle, and under-reports its own decisions; the judge's bar is whether the README discriminates between the alternatives. Valid while the worker's self-report stays unreliable. 2026-10-01, lilleman: the judge reads `docs/decisions.md` and `AGENTS.md` too, so an answer recorded there is not asked again (goal 4.2); its bar becomes whether the README or those files discriminate. 2026-10-03, implemented: when the README's premises or those files answer the worker's question, the judge quotes the answer verbatim and the worker resumes with it. The judge then sees the quote as a `[loop]` line. The worker asking it again shows the quote did not settle it, and the judge sends it to the human. A backstop of three quoted answers per cycle bounds what the judge misses, such as a reworded repeat or a worker asking without end, so the worker cannot loop unattended (goal 4.4); the fourth question that the README's premises or those files answer in one cycle goes to the human with the judge's quote. An interrupt does not reset the count, so every later question those files answer in that cycle also goes to the human. Valid while the worker writes records only in a worktree, as `CLAUDE.md` โ†’ "Working with the codebase" has it, so the records the judge reads from the checkout root are merged ones. -2026-10-03, lilleman: the judge is to read `~/.claude/CLAUDE.md` whole too. The worker follows that file, so a question it answers should not reach the human (goal 4.2). Reading the whole file is safe, because the judge may quote only words that appear in it. A list of sections would need keeping current. `todo.md` item 46 makes it so. Until then, a question only `CLAUDE.md` answers still goes to the human. +2026-10-03, lilleman: the judge is to read `~/.claude/CLAUDE.md` whole too. The worker follows that file, so a question it answers should not reach the human (goal 4.2). Reading the whole file is safe, because the judge may quote only words that appear in it. A list of sections would need keeping current. Implemented the same day. + +2026-10-03, lilleman: the judge rules a chunk finished only once every answer the human typed in it is recorded. A finished chunk's session is deleted, and its answers with it, so an answer recorded nowhere would be asked again in a later chunk (goal 4.2). Implemented the same day by claude, which settled two choices the ruling left open. First, an answer counts as recorded in a code comment the transcript shows the worker writing, beside `README.md`'s premises, `AGENTS.md` and `docs/decisions.md`: `CLAUDE.md` โ†’ "Ask, don't guess" puts a standing choice made in one place in a comment there, and a judge refusing it would hold the chunk open every cycle. Second, only an answer a later chunk could need must be recorded, so an approval such as "merge it" holds nothing open. The worker's resume prompt states the rule, so a chunk held open says why. ## loop-claude: one session per project, its id derived from the checkout's path relative to `~/code`, or to `/` outside it diff --git a/todo.md b/todo.md index 624e1426..94a99d22 100644 --- a/todo.md +++ b/todo.md @@ -25,9 +25,6 @@ | ID | Release | Exempt | Item | R | S | A | G | Goals | Score | |---|---|---|---|---|---|---|---|---|---| | 1 | 0.1.0 | question | **Say in README โ†’ Install how the transcript archive is backed up, once bender-infra backs up ai-sandbox's data volume.** | 3 | 5 | 8 | 9 | 2, 3 | 27.8 | -| 56 | 0.1.0 | | **Have the judge rule a chunk finished only once every answer the human typed in it is recorded in `README.md`, `AGENTS.md` or `docs/decisions.md`.** | 3 | 3 | 7 | 8 | 4, 4.2 | 21.0 | -| 46 | 0.1.0 | decision | **Let the judge read and quote `~/.claude/CLAUDE.md` whole, beside the project's records.** | 4 | 3 | 7 | 8 | 4, 4.2 | 20.0 | -| 57 | 0.1.0 | | **Archive each answer the judge quotes from the records, with the question it answers.** | 2 | 2 | 5 | 6 | 2, 4.2 | 18.2 | | 54 | 0.1.0 | | **Give each review pass a fixed name in larv-review ยง3's table, and count its rounds by that name.** | 2 | 1 | 6 | 6 | 4, 4.1 | 17.8 | | 55 | 0.1.0 | | **Make larv-review's comprehension floor readable without opening the panel skill, its scoring-run file and `AGENTS.md` in turn.** | 2 | 3 | 5 | 6 | 4, 4.1 | 15.3 | | 23 | 0.1.0 | | **Launch a principles auditor only for a principles file the project shows applies, and rerun only the reviewer whose finding a fix answers.** | 3 | 4 | 7 | 8 | 4.4 | 13.5 | @@ -53,18 +50,6 @@ It lives under `~/.claude`, which `.gitignore` keeps from the remote, so a lost The README line covers the bench's transcripts in `workflow-bench/logs/` too (goal 2). -### 56. Have the judge rule a chunk finished only once every answer the human typed in it is recorded in `README.md`, `AGENTS.md` or `docs/decisions.md`. - -2026-10-03, the human, answering the principles audit on PR #208: a finished chunk's session is deleted, and its `[human]` answers with it, so an answer recorded nowhere is asked again in a later chunk (goal 4.2). - -### 46. Let the judge read and quote `~/.claude/CLAUDE.md` whole, beside the project's records. - -The architecture pass's principles audit against README.md's goals, on PR #208, rated the gap ๐Ÿ”ด against goals 4 and 4.2: the worker follows `CLAUDE.md`, but the judge sees only the premises, `AGENTS.md` and `docs/decisions.md`. A choice `CLAUDE.md` settles therefore reads to the judge as one nothing discriminates, and a question it answers goes to the human. The fix revises the decision "loop-claude: a judge decides each interrupt and each quoted answer from the transcript, the README's premises, `AGENTS.md` and `docs/decisions.md`". - -### 57. Archive each answer the judge quotes from the records, with the question it answers. - -Raised by the product-owner review of PR #210: a quoted answer resumes the worker and leaves no line in `.outcomes.md`, so after an unattended run nothing shows which questions the records settled, or with what quote (goal 4.2). - ### 54. Give each review pass a fixed name in larv-review ยง3's table, and count its rounds by that name. Named under Shape by the PR #208 scoring runs: "Count" keys on `Answer round :`, but the table's first column names the architecture pass with a whole sentence, so a run can spell one pass two ways and restart its count. -- 2.52.0 From 0d85574a98359a8d31557fe7789fe312ff380e45 Mon Sep 17 00:00:00 2001 From: Lilleman auf Larv Date: Sat, 3 Oct 2026 20:58:10 +0200 Subject: [PATCH 02/16] Answer security round 1: nothing to change -- 2.52.0 From a43ef188d34926dafaebbae07984e40a6bf5ad3e Mon Sep 17 00:00:00 2001 From: Lilleman auf Larv Date: Sat, 3 Oct 2026 21:06:34 +0200 Subject: [PATCH 03/16] Answer stability round 1: count an answer the transcript shows written, give worker and judge one finish rule, cite CLAUDE.md by its heading, test a quoted answer that cannot be archived --- bin/loop_claude/cycle/judge_reply.py | 7 ++++--- bin/loop_claude/cycle/worker.py | 2 +- bin/loop_claude/loop/main.py | 6 +++--- bin/loop_claude/project/checkout.py | 8 ++++---- bin/loop_claude/project/premises.py | 4 ++-- bin/loop_claude/project/records.py | 7 ++++--- bin/test_loop_claude.py | 12 ++++++++++-- bin/test_loop_claude_black_box.py | 2 +- docs/decisions.md | 2 +- 9 files changed, 30 insertions(+), 20 deletions(-) diff --git a/bin/loop_claude/cycle/judge_reply.py b/bin/loop_claude/cycle/judge_reply.py index eb5b0c4e..15d8be3d 100644 --- a/bin/loop_claude/cycle/judge_reply.py +++ b/bin/loop_claude/cycle/judge_reply.py @@ -29,9 +29,10 @@ JUDGE_RULES = ( "outranks finished.\n" "The chunk is the piece of work the agent is on, shipped as one pull request. " "finished=true when the chunk is complete: merged, or nothing remains that the agent could do on " - f"its own, and {ANSWERS_RECORDED}. Judge that from the files above; a comment counts only where the " - "transcript shows the agent writing it. finished=false when work remains that a further run can " - "continue: an open PR, a review not yet run, CI not yet reported, an answer not yet recorded." + f"its own. Even then, it is finished only once {ANSWERS_RECORDED}. An answer counts as recorded " + "where the files above hold it, or where the transcript shows the agent writing it in one of those " + "places. finished=false when work remains that a further run can continue: an open PR, a review " + "not yet run, CI not yet reported, an answer not yet recorded." ) diff --git a/bin/loop_claude/cycle/worker.py b/bin/loop_claude/cycle/worker.py index 238ec6cc..1b15ed40 100644 --- a/bin/loop_claude/cycle/worker.py +++ b/bin/loop_claude/cycle/worker.py @@ -43,7 +43,7 @@ def worker_args(task: str, session: Session, model: str, resuming: bool, answere if answered is not None: 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: - start = ["-p", f"Continue the task; the previous run stopped before it was finished. The chunk is finished once it is merged and {ANSWERS_RECORDED}.", "--resume", str(session.id)] + start = ["-p", f"Continue the task; the previous run stopped before it was finished. The chunk is finished once it is complete and {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 f6ef4a18..c3d2c8e6 100644 --- a/bin/loop_claude/loop/main.py +++ b/bin/loop_claude/loop/main.py @@ -7,9 +7,9 @@ premises; the task runs at the checkout root. Each cycle a worker runs the task. the transcript's end, the premises, and the records: the project's AGENTS.md and docs/decisions.md and the human's ~/.claude/CLAUDE.md, where they exist. It rules whether the chunk, the work of one PR, is finished. It is not while an answer the human typed in it, that a later chunk could need, is -recorded nowhere: not in the premises, AGENTS.md or docs/decisions.md, nor in a code comment the -transcript shows the worker writing. A choice the worker made that the premises or the records -settle is not asked about. When the worker asks a question they answer, the judge quotes the +recorded nowhere: neither the premises, AGENTS.md or docs/decisions.md hold it, nor does the +transcript show the worker writing it there or in a code comment. A choice the worker made that the +premises or the records settle is not asked about. When the worker asks a question they answer, the judge quotes the answer, loop-claude prints it, and the worker resumes with it. A quote they do not hold word for word is dropped, and the question goes to the human. So does a question asked again after its answer. The fourth question they answer in one cycle goes to the human too, with the quote. diff --git a/bin/loop_claude/project/checkout.py b/bin/loop_claude/project/checkout.py index de5f057d..5b5c396e 100644 --- a/bin/loop_claude/project/checkout.py +++ b/bin/loop_claude/project/checkout.py @@ -29,11 +29,11 @@ def project_key(root: str, code: pathlib.Path) -> str: return root.removeprefix(f"{code}/").lstrip("/") -def read_checkout_file(root: str, name: str, consequence: str) -> str | Stop: +def read_utf8(folder: str, name: str, consequence: str) -> str | Stop: try: - return pathlib.Path(root, name).read_text(encoding="utf-8") + return pathlib.Path(folder, name).read_text(encoding="utf-8") except OSError as failure: - return Stop(1, f"{name} in {root}: {failure.strerror} - {consequence}.") + return Stop(1, f"{name} in {folder}: {failure.strerror} - {consequence}.") except UnicodeDecodeError as failure: line = failure.object.count(b"\n", 0, failure.start) + 1 - return Stop(1, f"{name} in {root} is not UTF-8 on line {line} - {consequence}.") + return Stop(1, f"{name} in {folder} is not UTF-8 on line {line} - {consequence}.") diff --git a/bin/loop_claude/project/premises.py b/bin/loop_claude/project/premises.py index a00b3647..a824c825 100644 --- a/bin/loop_claude/project/premises.py +++ b/bin/loop_claude/project/premises.py @@ -1,10 +1,10 @@ -from loop_claude.project.checkout import read_checkout_file +from loop_claude.project.checkout import read_utf8 from markdown_sections import sections from loop_claude.stop import Stop def read_premises(root: str) -> str | Stop: - text = read_checkout_file(root, "README.md", "no premises") + text = read_utf8(root, "README.md", "no premises") if isinstance(text, Stop): return text found = sections(text) diff --git a/bin/loop_claude/project/records.py b/bin/loop_claude/project/records.py index e764fadf..dd9b16d6 100644 --- a/bin/loop_claude/project/records.py +++ b/bin/loop_claude/project/records.py @@ -1,6 +1,6 @@ import pathlib -from loop_claude.project.checkout import read_checkout_file +from loop_claude.project.checkout import read_utf8 from loop_claude.stop import Stop RECORD_FILES = ("AGENTS.md", "docs/decisions.md") @@ -11,11 +11,12 @@ QUOTE_SOURCES = "README.md's Goals and Audience, " + ", ".join(RECORD_FILES) + " def read_records(root: str, claude_md: pathlib.Path) -> str | Stop: """The project's record files, then the human's rules for every project, each headed by its name; a file that does not exist is left out.""" + sources = [(root, name, name) for name in RECORD_FILES] + [(str(claude_md.parent), claude_md.name, HUMAN_RULES)] records = [] - for folder, name, heading in (*((root, name, name) for name in RECORD_FILES), (str(claude_md.parent), claude_md.name, HUMAN_RULES)): + for folder, name, heading in sources: if not pathlib.Path(folder, name).exists(): continue - text = read_checkout_file(folder, name, "the judge cannot read the records") + text = read_utf8(folder, name, "the judge cannot read the records") if isinstance(text, Stop): return text records.append(f"From {heading}:\n{text.strip()}") diff --git a/bin/test_loop_claude.py b/bin/test_loop_claude.py index 8f7b3f61..7edd9fa5 100644 --- a/bin/test_loop_claude.py +++ b/bin/test_loop_claude.py @@ -268,6 +268,14 @@ class Cycles(unittest.TestCase): quoted = "2026-09-21T14:13:20Z Verdict: quoted answer\n\nWhich one?\n\nREADME.md's Goals and Audience, AGENTS.md, docs/decisions.md or ~/.claude/CLAUDE.md says:\n> Use *A*.\n\nEvidence:\n> working\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 or ~/.claude/CLAUDE.md 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\n2026-09-21T14:13:20Z Stopped: the human is needed to answer the question above, but the interrupt ended with nothing typed\n", *[f"Task: Do it.\n\n{quoted}"] * 3]) + def test_stops_when_a_quoted_answer_cannot_be_archived(self): + self.paths.transcript_archive.parent.mkdir(parents=True) + self.paths.transcript_archive.write_text("") + fake = FakeEffects(streams=[Worker(self.paths.claude_code_transcripts.parent)], claude=[judged("quoted", answer="Use A.")]) + with contextlib.redirect_stdout(io.StringIO()): + self.assertEqual(run.run_cycle(self.cycle(fake, records="From AGENTS.md:\nUse A.")), Stop(1, f"could not archive the transcript: {self.paths.transcript_archive / 'proj'}: Not a directory")) + self.assertEqual(len(fake.made("stream_claude")), 1) + def test_an_answer_the_records_do_not_hold_is_dropped_and_the_question_goes_to_the_human(self): fake = FakeEffects(streams=[Worker(self.paths.claude_code_transcripts.parent)], claude=[judged("quoted", answer="Use ... A.")], on_terminal_claude=[0], git=[ran()]) with contextlib.redirect_stderr(io.StringIO()) as said: @@ -610,8 +618,8 @@ class ExitContract(unittest.TestCase): ("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), - ("project/checkout.py", "read_checkout_file", "1", "f'{name} in {root}:", unreadable), - ("project/checkout.py", "read_checkout_file", "1", "f'{name} in {root} is not UTF-8", unreadable), + ("project/checkout.py", "read_utf8", "1", "f'{name} in {folder}:", unreadable), + ("project/checkout.py", "read_utf8", "1", "f'{name} in {folder} is not UTF-8", unreadable), ("project/model_choice.py", "get_or_ask_model", "1", "f'could not save the model in", models_), ("project/model_choice.py", "read_models_file", "1", 'f"could not read {saved}: {getattr(', models_), ("project/model_choice.py", "read_models_file", "1", "f'could not read {saved}: not an object", models_), diff --git a/bin/test_loop_claude_black_box.py b/bin/test_loop_claude_black_box.py index 3cb3698f..09bc083c 100644 --- a/bin/test_loop_claude_black_box.py +++ b/bin/test_loop_claude_black_box.py @@ -344,7 +344,7 @@ class Cycles(unittest.TestCase): self.assertEqual(argument(workers[2], "--session-id"), session) self.assertTrue(argument(workers[0], "-p").startswith(f"{TASK}\n\nContinue any open draft PR")) self.assertNotIn(TASK, argument(workers[1], "-p")) - self.assertIn("The chunk is finished once it is merged and every answer the human typed in it", argument(workers[1], "-p")) + self.assertIn("The chunk is finished once it is complete and every answer the human typed in it", argument(workers[1], "-p")) self.assertEqual({call["cwd"] for call in run.calls}, {str(checkout.root)}) self.assertIn("1. Work.", run.calls[1]["stdin"]) self.assertIn("From docs/decisions.md:\n# Decisions\n\nFrom ~/.claude/CLAUDE.md:\n# Global instructions", run.calls[1]["stdin"]) diff --git a/docs/decisions.md b/docs/decisions.md index 67e54b53..1520227d 100644 --- a/docs/decisions.md +++ b/docs/decisions.md @@ -12,7 +12,7 @@ 2026-10-03, lilleman: the judge is to read `~/.claude/CLAUDE.md` whole too. The worker follows that file, so a question it answers should not reach the human (goal 4.2). Reading the whole file is safe, because the judge may quote only words that appear in it. A list of sections would need keeping current. Implemented the same day. -2026-10-03, lilleman: the judge rules a chunk finished only once every answer the human typed in it is recorded. A finished chunk's session is deleted, and its answers with it, so an answer recorded nowhere would be asked again in a later chunk (goal 4.2). Implemented the same day by claude, which settled two choices the ruling left open. First, an answer counts as recorded in a code comment the transcript shows the worker writing, beside `README.md`'s premises, `AGENTS.md` and `docs/decisions.md`: `CLAUDE.md` โ†’ "Ask, don't guess" puts a standing choice made in one place in a comment there, and a judge refusing it would hold the chunk open every cycle. Second, only an answer a later chunk could need must be recorded, so an approval such as "merge it" holds nothing open. The worker's resume prompt states the rule, so a chunk held open says why. +2026-10-03, lilleman: the judge rules a chunk finished only once every answer the human typed in it is recorded. A finished chunk's session is deleted, and its answers with it, so an answer recorded nowhere would be asked again in a later chunk (goal 4.2). Implemented the same day by claude, which settled two choices the ruling left open. First, an answer counts as recorded where the files the judge reads hold it, or where the transcript shows the worker writing it into `README.md`'s premises, `AGENTS.md`, `docs/decisions.md` or a code comment. The judge cannot read a code comment, yet `CLAUDE.md` โ†’ "Working loop", "Ask, don't guess" puts a standing choice made in one place there. And the judge reads the records from the main checkout once a cycle, which may not yet hold an answer the worker merged. A judge refusing either would hold the chunk open every cycle. Second, only an answer a later chunk could need must be recorded, so an approval such as "merge it" holds nothing open. The worker's resume prompt states the rule, so a chunk held open says why. ## loop-claude: one session per project, its id derived from the checkout's path relative to `~/code`, or to `/` outside it -- 2.52.0 From a6207e55c0770f5b0cb019832a04510394406dfd Mon Sep 17 00:00:00 2001 From: Lilleman auf Larv Date: Sat, 3 Oct 2026 21:09:31 +0200 Subject: [PATCH 04/16] Answer product-owner round 1: count an answer written where it belongs, todo.md and CLAUDE.md included, align help and changelog, file item 58 --- CHANGELOG.md | 2 +- bin/loop_claude/cycle/judge_reply.py | 6 +++--- bin/loop_claude/loop/main.py | 15 ++++++++------- docs/decisions.md | 2 +- todo.md | 7 ++++++- 5 files changed, 19 insertions(+), 13 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index cbfb36a0..59bcb218 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,7 +3,7 @@ ## Unreleased - `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. -- `loop-claude`'s judge holds a chunk open while an answer you typed in it, that a later chunk could need, is recorded nowhere. It counts as recorded in the README's goals or audience, in `AGENTS.md` or `docs/decisions.md`, or in a code comment the transcript shows the worker writing. The resumed worker is told this rule. +- `loop-claude`'s judge holds a chunk open while an answer you typed in it, that a later chunk could need, is recorded nowhere. It counts as recorded once the README's goals or audience, `AGENTS.md`, `docs/decisions.md` or `~/.claude/CLAUDE.md` hold it, or once the transcript shows the worker writing it into one of those, `todo.md` or a code comment. The resumed worker is told this rule. - `loop-claude` archives each answer the judge quotes from the records in `.outcomes.md`, with the question it answers and its UTC time. - larv-review keeps its three-round cap across a resumed session. It closes each review round with a commit naming the pass and the round, empty when the round changed nothing, and counts rounds from the branch's own commits. - larv-review runs `/security-review` in a subagent, so the run goes on to the next pass without you prompting it. diff --git a/bin/loop_claude/cycle/judge_reply.py b/bin/loop_claude/cycle/judge_reply.py index 15d8be3d..2b172599 100644 --- a/bin/loop_claude/cycle/judge_reply.py +++ b/bin/loop_claude/cycle/judge_reply.py @@ -3,7 +3,7 @@ import typing from failure import Failure -ANSWERS_RECORDED = "every answer the human typed in it that a later chunk could need is recorded: in README.md's Goals or Audience, in AGENTS.md or docs/decisions.md, or in a comment at the one place it governs" +ANSWERS_RECORDED = "every answer the human typed in it that a later chunk could need is recorded in the file where it belongs: README.md's Goals or Audience, AGENTS.md, docs/decisions.md, todo.md, ~/.claude/CLAUDE.md, or a comment at the one place it governs" JUDGE_RULES = ( "Decide whether the human must now be interrupted. interrupt=true when any of these appear:\n" "- the agent asks the human anything, seeks approval, or says a decision is the human's, and neither " @@ -30,8 +30,8 @@ JUDGE_RULES = ( "The chunk is the piece of work the agent is on, shipped as one pull request. " "finished=true when the chunk is complete: merged, or nothing remains that the agent could do on " f"its own. Even then, it is finished only once {ANSWERS_RECORDED}. An answer counts as recorded " - "where the files above hold it, or where the transcript shows the agent writing it in one of those " - "places. finished=false when work remains that a further run can continue: an open PR, a review " + "where the files above hold it, or where the transcript shows the agent writing it into one of " + "those files. finished=false when work remains that a further run can continue: an open PR, a review " "not yet run, CI not yet reported, an answer not yet recorded." ) diff --git a/bin/loop_claude/loop/main.py b/bin/loop_claude/loop/main.py index c3d2c8e6..a213390b 100644 --- a/bin/loop_claude/loop/main.py +++ b/bin/loop_claude/loop/main.py @@ -6,13 +6,14 @@ Run it anywhere inside a project checkout whose README.md has ## Goals and ## Au premises; the task runs at the checkout root. Each cycle a worker runs the task. A judge then reads the transcript's end, the premises, and the records: the project's AGENTS.md and docs/decisions.md and the human's ~/.claude/CLAUDE.md, where they exist. It rules whether the chunk, the work of one -PR, is finished. It is not while an answer the human typed in it, that a later chunk could need, is -recorded nowhere: neither the premises, AGENTS.md or docs/decisions.md hold it, nor does the -transcript show the worker writing it there or in a code comment. A choice the worker made that the -premises or the records settle is not asked about. When the worker asks a question they answer, the judge quotes the -answer, loop-claude prints it, and the worker resumes with it. A quote they do not hold word for -word is dropped, and the question goes to the human. So does a question asked again after its -answer. The fourth question they answer in one cycle goes to the human too, with the quote. +PR, is finished. It is not while an answer the human typed in it, that a later chunk could need, +is recorded nowhere: the premises and the records do not hold it, and the transcript does not show +the worker writing it into them, todo.md or a code comment. A choice the worker made that the +premises or the records settle is not asked about. When the worker asks a question they answer, +the judge quotes the answer, loop-claude prints it, and the worker resumes with it. A quote they do +not hold word for word is dropped, and the question goes to the human. So does a question asked +again after its answer. The fourth question they answer in one cycle goes to 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; the next chunk starts a fresh session. diff --git a/docs/decisions.md b/docs/decisions.md index 1520227d..75c00f1c 100644 --- a/docs/decisions.md +++ b/docs/decisions.md @@ -12,7 +12,7 @@ 2026-10-03, lilleman: the judge is to read `~/.claude/CLAUDE.md` whole too. The worker follows that file, so a question it answers should not reach the human (goal 4.2). Reading the whole file is safe, because the judge may quote only words that appear in it. A list of sections would need keeping current. Implemented the same day. -2026-10-03, lilleman: the judge rules a chunk finished only once every answer the human typed in it is recorded. A finished chunk's session is deleted, and its answers with it, so an answer recorded nowhere would be asked again in a later chunk (goal 4.2). Implemented the same day by claude, which settled two choices the ruling left open. First, an answer counts as recorded where the files the judge reads hold it, or where the transcript shows the worker writing it into `README.md`'s premises, `AGENTS.md`, `docs/decisions.md` or a code comment. The judge cannot read a code comment, yet `CLAUDE.md` โ†’ "Working loop", "Ask, don't guess" puts a standing choice made in one place there. And the judge reads the records from the main checkout once a cycle, which may not yet hold an answer the worker merged. A judge refusing either would hold the chunk open every cycle. Second, only an answer a later chunk could need must be recorded, so an approval such as "merge it" holds nothing open. The worker's resume prompt states the rule, so a chunk held open says why. +2026-10-03, lilleman: the judge rules a chunk finished only once every answer the human typed in it is recorded. A finished chunk's session is deleted, and its answers with it, so an answer recorded nowhere would be asked again in a later chunk (goal 4.2). Implemented the same day by claude, which settled two choices the ruling left open. First, an answer counts as recorded where the files the judge reads hold it, `~/.claude/CLAUDE.md` included, or where the transcript shows the worker writing it into one of them, `todo.md` or a code comment. The judge cannot read a code comment or `todo.md`, yet `CLAUDE.md` โ†’ "Working loop", "Ask, don't guess" puts a standing choice made in one place in a comment there, and the plan's approval belongs in `todo.md`. And the judge reads the records from the main checkout once a cycle, which may not yet hold an answer the worker merged. A judge refusing either would hold the chunk open every cycle. Second, only an answer a later chunk could need must be recorded, so an approval such as "merge it" holds nothing open. The worker's resume prompt states the rule, so a chunk held open says why. ## loop-claude: one session per project, its id derived from the checkout's path relative to `~/code`, or to `/` outside it diff --git a/todo.md b/todo.md index 94a99d22..b9340d49 100644 --- a/todo.md +++ b/todo.md @@ -6,7 +6,7 @@ `Bar = 9` -`Next ID = 58` +`Next ID = 59` | Goal | W | |---|---| @@ -26,6 +26,7 @@ |---|---|---|---|---|---|---|---|---|---| | 1 | 0.1.0 | question | **Say in README โ†’ Install how the transcript archive is backed up, once bender-infra backs up ai-sandbox's data volume.** | 3 | 5 | 8 | 9 | 2, 3 | 27.8 | | 54 | 0.1.0 | | **Give each review pass a fixed name in larv-review ยง3's table, and count its rounds by that name.** | 2 | 1 | 6 | 6 | 4, 4.1 | 17.8 | +| 58 | 0.1.0 | | **Resume the worker of a chunk the judge held open with the judge's evidence of what remains.** | 3 | 3 | 6 | 6 | 4, 4.4 | 16.3 | | 55 | 0.1.0 | | **Make larv-review's comprehension floor readable without opening the panel skill, its scoring-run file and `AGENTS.md` in turn.** | 2 | 3 | 5 | 6 | 4, 4.1 | 15.3 | | 23 | 0.1.0 | | **Launch a principles auditor only for a principles file the project shows applies, and rerun only the reviewer whose finding a fix answers.** | 3 | 4 | 7 | 8 | 4.4 | 13.5 | | 21 | 0.1.0 | | **Give `settings.json`'s model one writer, and sort its keys.** | 3 | 3 | 6 | 7 | 4.3 | 12.9 | @@ -54,6 +55,10 @@ The README line covers the bench's transcripts in `workflow-bench/logs/` too (go Named under Shape by the PR #208 scoring runs: "Count" keys on `Answer round :`, but the table's first column names the architecture pass with a whole sentence, so a run can spell one pass two ways and restart its count. +### 58. Resume the worker of a chunk the judge held open with the judge's evidence of what remains. + +Raised by the product-owner review of PR #211: an unfinished verdict resumes the worker with a generic prompt, so a worker that thinks the chunk done repeats itself, and nothing bounds a run of unfinished verdicts (goal 4.4). + ### 55. Make larv-review's comprehension floor readable without opening the panel skill, its scoring-run file and `AGENTS.md` in turn. Named under Self-sufficiency by the PR #208 scoring runs, as the worst of the skills' leans on other documents. -- 2.52.0 From 3afc0750795fe08fbbc407cb5f589651a7ea72a8 Mon Sep 17 00:00:00 2001 From: Lilleman auf Larv Date: Sat, 3 Oct 2026 21:09:31 +0200 Subject: [PATCH 05/16] Answer stability round 2: help rewrapped in the product-owner round 1 commit -- 2.52.0 From 19baebd388ebbd01e54ec2d9779350ac5a7adcc9 Mon Sep 17 00:00:00 2001 From: Lilleman auf Larv Date: Sat, 3 Oct 2026 21:12:37 +0200 Subject: [PATCH 06/16] Answer stability round 3: credit CLAUDE.md only where it already holds an answer, never a worker's write to it --- CHANGELOG.md | 2 +- bin/loop_claude/cycle/judge_reply.py | 6 +++--- bin/loop_claude/loop/main.py | 16 ++++++++-------- docs/decisions.md | 2 +- 4 files changed, 13 insertions(+), 13 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 59bcb218..71b9d769 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,7 +3,7 @@ ## Unreleased - `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. -- `loop-claude`'s judge holds a chunk open while an answer you typed in it, that a later chunk could need, is recorded nowhere. It counts as recorded once the README's goals or audience, `AGENTS.md`, `docs/decisions.md` or `~/.claude/CLAUDE.md` hold it, or once the transcript shows the worker writing it into one of those, `todo.md` or a code comment. The resumed worker is told this rule. +- `loop-claude`'s judge holds a chunk open while an answer you typed in it, that a later chunk could need, is recorded nowhere. It counts as recorded once the README's goals or audience, `AGENTS.md`, `docs/decisions.md` or `~/.claude/CLAUDE.md` hold it, or once the transcript shows the worker writing it into the README's goals or audience, `AGENTS.md`, `docs/decisions.md`, `todo.md` or a code comment. Only you edit `~/.claude/CLAUDE.md`. The resumed worker is told this rule. - `loop-claude` archives each answer the judge quotes from the records in `.outcomes.md`, with the question it answers and its UTC time. - larv-review keeps its three-round cap across a resumed session. It closes each review round with a commit naming the pass and the round, empty when the round changed nothing, and counts rounds from the branch's own commits. - larv-review runs `/security-review` in a subagent, so the run goes on to the next pass without you prompting it. diff --git a/bin/loop_claude/cycle/judge_reply.py b/bin/loop_claude/cycle/judge_reply.py index 2b172599..56eb447f 100644 --- a/bin/loop_claude/cycle/judge_reply.py +++ b/bin/loop_claude/cycle/judge_reply.py @@ -3,7 +3,7 @@ import typing from failure import Failure -ANSWERS_RECORDED = "every answer the human typed in it that a later chunk could need is recorded in the file where it belongs: README.md's Goals or Audience, AGENTS.md, docs/decisions.md, todo.md, ~/.claude/CLAUDE.md, or a comment at the one place it governs" +ANSWERS_RECORDED = "every answer the human typed in it that a later chunk could need is recorded in one of README.md's Goals or Audience, AGENTS.md, docs/decisions.md, todo.md or a comment at the one place it governs" JUDGE_RULES = ( "Decide whether the human must now be interrupted. interrupt=true when any of these appear:\n" "- the agent asks the human anything, seeks approval, or says a decision is the human's, and neither " @@ -30,8 +30,8 @@ JUDGE_RULES = ( "The chunk is the piece of work the agent is on, shipped as one pull request. " "finished=true when the chunk is complete: merged, or nothing remains that the agent could do on " f"its own. Even then, it is finished only once {ANSWERS_RECORDED}. An answer counts as recorded " - "where the files above hold it, or where the transcript shows the agent writing it into one of " - "those files. finished=false when work remains that a further run can continue: an open PR, a review " + "where the files above hold it, ~/.claude/CLAUDE.md included, or where the transcript shows the " + "agent writing it into one of those places. finished=false when work remains that a further run can continue: an open PR, a review " "not yet run, CI not yet reported, an answer not yet recorded." ) diff --git a/bin/loop_claude/loop/main.py b/bin/loop_claude/loop/main.py index a213390b..cdd6ea32 100644 --- a/bin/loop_claude/loop/main.py +++ b/bin/loop_claude/loop/main.py @@ -6,14 +6,14 @@ Run it anywhere inside a project checkout whose README.md has ## Goals and ## Au premises; the task runs at the checkout root. Each cycle a worker runs the task. A judge then reads the transcript's end, the premises, and the records: the project's AGENTS.md and docs/decisions.md and the human's ~/.claude/CLAUDE.md, where they exist. It rules whether the chunk, the work of one -PR, is finished. It is not while an answer the human typed in it, that a later chunk could need, -is recorded nowhere: the premises and the records do not hold it, and the transcript does not show -the worker writing it into them, todo.md or a code comment. A choice the worker made that the -premises or the records settle is not asked about. When the worker asks a question they answer, -the judge quotes the answer, loop-claude prints it, and the worker resumes with it. A quote they do -not hold word for word is dropped, and the question goes to the human. So does a question asked -again after its answer. The fourth question they answer in one cycle goes to the human too, with -the quote. +PR, is finished. It is not while an answer the human typed in it, that a later chunk could need, is +recorded nowhere: the premises and the records do not hold it, and the transcript does not show the +worker writing it into the premises, AGENTS.md, docs/decisions.md, todo.md or a code comment. A +choice the worker made that the premises or the records settle is not asked about. When the worker +asks a question they answer, the judge quotes the answer, loop-claude prints it, and the worker +resumes with it. A quote they do not hold word for word is dropped, and the question goes to the +human. So does a question asked again after its answer. The fourth question they answer in one cycle +goes to 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; the next chunk starts a fresh session. diff --git a/docs/decisions.md b/docs/decisions.md index 75c00f1c..cd8528ce 100644 --- a/docs/decisions.md +++ b/docs/decisions.md @@ -12,7 +12,7 @@ 2026-10-03, lilleman: the judge is to read `~/.claude/CLAUDE.md` whole too. The worker follows that file, so a question it answers should not reach the human (goal 4.2). Reading the whole file is safe, because the judge may quote only words that appear in it. A list of sections would need keeping current. Implemented the same day. -2026-10-03, lilleman: the judge rules a chunk finished only once every answer the human typed in it is recorded. A finished chunk's session is deleted, and its answers with it, so an answer recorded nowhere would be asked again in a later chunk (goal 4.2). Implemented the same day by claude, which settled two choices the ruling left open. First, an answer counts as recorded where the files the judge reads hold it, `~/.claude/CLAUDE.md` included, or where the transcript shows the worker writing it into one of them, `todo.md` or a code comment. The judge cannot read a code comment or `todo.md`, yet `CLAUDE.md` โ†’ "Working loop", "Ask, don't guess" puts a standing choice made in one place in a comment there, and the plan's approval belongs in `todo.md`. And the judge reads the records from the main checkout once a cycle, which may not yet hold an answer the worker merged. A judge refusing either would hold the chunk open every cycle. Second, only an answer a later chunk could need must be recorded, so an approval such as "merge it" holds nothing open. The worker's resume prompt states the rule, so a chunk held open says why. +2026-10-03, lilleman: the judge rules a chunk finished only once every answer the human typed in it is recorded. A finished chunk's session is deleted, and its answers with it, so an answer recorded nowhere would be asked again in a later chunk (goal 4.2). Implemented the same day by claude, which settled two choices the ruling left open. First, an answer counts as recorded where the files the judge reads hold it, `~/.claude/CLAUDE.md` included, or where the transcript shows the worker writing it into `README.md`'s premises, `AGENTS.md`, `docs/decisions.md`, `todo.md` or a code comment. A worker's write to `~/.claude/CLAUDE.md` does not count: `CLAUDE.md` โ†’ "Maintaining this file" leaves its edits to the human. The judge cannot read a code comment or `todo.md`, yet `CLAUDE.md` โ†’ "Working loop", "Ask, don't guess" puts a standing choice made in one place in a comment there, and the plan's approval belongs in `todo.md`. And the judge reads the records from the main checkout once a cycle, which may not yet hold an answer the worker merged. A judge refusing either would hold the chunk open every cycle. Second, only an answer a later chunk could need must be recorded, so an approval such as "merge it" holds nothing open. The worker's resume prompt states the rule, so a chunk held open says why. ## loop-claude: one session per project, its id derived from the checkout's path relative to `~/code`, or to `/` outside it -- 2.52.0 From d14e8548797ca6a352900ef8f1183ffa86303a80 Mon Sep 17 00:00:00 2001 From: Lilleman auf Larv Date: Sat, 3 Oct 2026 21:12:37 +0200 Subject: [PATCH 07/16] Answer product-owner round 2: "in one of" lands in the stability round 3 commit -- 2.52.0 From cf243cc72c946f61ba63afa40e8a7d13c76b5128 Mon Sep 17 00:00:00 2001 From: Lilleman auf Larv Date: Sat, 3 Oct 2026 21:15:44 +0200 Subject: [PATCH 08/16] Answer prose round 1: one list of places for an answer, plainer help and changelog, the todo.md premise named --- CHANGELOG.md | 4 ++-- bin/loop_claude/cycle/judge_reply.py | 6 +++--- bin/loop_claude/cycle/worker.py | 2 +- bin/loop_claude/loop/main.py | 20 ++++++++++---------- bin/test_loop_claude_black_box.py | 2 +- docs/decisions.md | 2 +- todo.md | 6 +++--- 7 files changed, 21 insertions(+), 21 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 71b9d769..033d3424 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,8 +3,8 @@ ## Unreleased - `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. -- `loop-claude`'s judge holds a chunk open while an answer you typed in it, that a later chunk could need, is recorded nowhere. It counts as recorded once the README's goals or audience, `AGENTS.md`, `docs/decisions.md` or `~/.claude/CLAUDE.md` hold it, or once the transcript shows the worker writing it into the README's goals or audience, `AGENTS.md`, `docs/decisions.md`, `todo.md` or a code comment. Only you edit `~/.claude/CLAUDE.md`. The resumed worker is told this rule. -- `loop-claude` archives each answer the judge quotes from the records in `.outcomes.md`, with the question it answers and its UTC time. +- `loop-claude`'s judge holds a chunk open until each answer you typed in it that a later chunk could need is recorded. An answer counts as recorded once the README's goals or audience, `AGENTS.md`, `docs/decisions.md` or `~/.claude/CLAUDE.md` hold it. It also counts once the transcript shows the worker writing it into the README's goals or audience, `AGENTS.md`, `docs/decisions.md`, `todo.md` or a code comment. The worker writing to `~/.claude/CLAUDE.md` does not count, since new rules there are yours. The resumed worker is told this rule. +- `loop-claude` archives each answer the judge quotes, with the question it answers and its UTC time, in `.outcomes.md`. - larv-review keeps its three-round cap across a resumed session. It closes each review round with a commit naming the pass and the round, empty when the round changed nothing, and counts rounds from the branch's own commits. - larv-review runs `/security-review` in a subagent, so the run goes on to the next pass without you prompting it. - larv-review asks once before the full security scan: it states the evidence and its recommendation, and `claude-security`'s cost prompt is the ask. diff --git a/bin/loop_claude/cycle/judge_reply.py b/bin/loop_claude/cycle/judge_reply.py index 56eb447f..ecc2d378 100644 --- a/bin/loop_claude/cycle/judge_reply.py +++ b/bin/loop_claude/cycle/judge_reply.py @@ -3,7 +3,7 @@ import typing from failure import Failure -ANSWERS_RECORDED = "every answer the human typed in it that a later chunk could need is recorded in one of README.md's Goals or Audience, AGENTS.md, docs/decisions.md, todo.md or a comment at the one place it governs" +ANSWERS_RECORDED = "every answer the human typed in it that a later chunk could need is recorded in README.md's Goals or Audience, AGENTS.md, docs/decisions.md, todo.md or a comment at the one place it governs" JUDGE_RULES = ( "Decide whether the human must now be interrupted. interrupt=true when any of these appear:\n" "- the agent asks the human anything, seeks approval, or says a decision is the human's, and neither " @@ -30,8 +30,8 @@ JUDGE_RULES = ( "The chunk is the piece of work the agent is on, shipped as one pull request. " "finished=true when the chunk is complete: merged, or nothing remains that the agent could do on " f"its own. Even then, it is finished only once {ANSWERS_RECORDED}. An answer counts as recorded " - "where the files above hold it, ~/.claude/CLAUDE.md included, or where the transcript shows the " - "agent writing it into one of those places. finished=false when work remains that a further run can continue: an open PR, a review " + "where README.md or the records above hold it, or where the transcript shows the agent writing it " + "into one of the places just listed, never ~/.claude/CLAUDE.md. finished=false when work remains that a further run can continue: an open PR, a review " "not yet run, CI not yet reported, an answer not yet recorded." ) diff --git a/bin/loop_claude/cycle/worker.py b/bin/loop_claude/cycle/worker.py index 1b15ed40..5fb19187 100644 --- a/bin/loop_claude/cycle/worker.py +++ b/bin/loop_claude/cycle/worker.py @@ -43,7 +43,7 @@ def worker_args(task: str, session: Session, model: str, resuming: bool, answere if answered is not None: 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: - start = ["-p", f"Continue the task; the previous run stopped before it was finished. The chunk is finished once it is complete and {ANSWERS_RECORDED}.", "--resume", str(session.id)] + start = ["-p", f"Continue the task; the previous run stopped before it was finished. The chunk is finished once it is merged, or nothing remains that you could do on your own, and {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 cdd6ea32..1d8beadf 100644 --- a/bin/loop_claude/loop/main.py +++ b/bin/loop_claude/loop/main.py @@ -6,14 +6,14 @@ Run it anywhere inside a project checkout whose README.md has ## Goals and ## Au premises; the task runs at the checkout root. Each cycle a worker runs the task. A judge then reads the transcript's end, the premises, and the records: the project's AGENTS.md and docs/decisions.md and the human's ~/.claude/CLAUDE.md, where they exist. It rules whether the chunk, the work of one -PR, is finished. It is not while an answer the human typed in it, that a later chunk could need, is -recorded nowhere: the premises and the records do not hold it, and the transcript does not show the -worker writing it into the premises, AGENTS.md, docs/decisions.md, todo.md or a code comment. A -choice the worker made that the premises or the records settle is not asked about. When the worker -asks a question they answer, the judge quotes the answer, loop-claude prints it, and the worker -resumes with it. A quote they do not hold word for word is dropped, and the question goes to the -human. So does a question asked again after its answer. The fourth question they answer in one cycle -goes to the human too, with the quote. +PR, is finished. A chunk stays unfinished until each answer the human typed in it that a later chunk +could need is recorded: the premises or the records hold it, or the transcript shows the worker +writing it into the premises, AGENTS.md, docs/decisions.md, todo.md or a code comment. A choice the +worker made that the premises or the records settle is not asked about. When the worker asks a +question they answer, the judge quotes the answer, loop-claude prints it, and the worker resumes +with it. A quote they do not hold word for word is dropped, and the question goes to the human. So +does a question asked again after its answer. The fourth question they answer in one cycle goes to +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; the next chunk starts a fresh session. @@ -25,8 +25,8 @@ interrupt, and as every cycle ends, Ctrl-C and a failure included, the session's copied to $LOOP_CLAUDE_TRANSCRIPTS///.jsonl (default ~/.claude/loop-claude-transcripts), named by its hash. is the hash of the transcript's first line with a timestamp, the same for every cycle of a chunk. Beside the copy, .outcomes.md -holds the verdict, with the transcript passage the judge rested it on; each answer quoted from the -records, with the question it answers; and why the loop stopped. Each of these opens with its UTC +holds the verdict, with the transcript passage the judge rested it on; each answer the judge +quoted, with the question it answers; and why the loop stopped. Each of these opens with its UTC time. Claude Code keeps a folder per session beside its transcript, holding the subagents' transcripts among other files; that folder, and every other file named after the session except the transcript, are copied into /session/. A file there is replaced only by a version that diff --git a/bin/test_loop_claude_black_box.py b/bin/test_loop_claude_black_box.py index 09bc083c..088168fd 100644 --- a/bin/test_loop_claude_black_box.py +++ b/bin/test_loop_claude_black_box.py @@ -344,7 +344,7 @@ class Cycles(unittest.TestCase): self.assertEqual(argument(workers[2], "--session-id"), session) self.assertTrue(argument(workers[0], "-p").startswith(f"{TASK}\n\nContinue any open draft PR")) self.assertNotIn(TASK, argument(workers[1], "-p")) - self.assertIn("The chunk is finished once it is complete and every answer the human typed in it", argument(workers[1], "-p")) + self.assertIn("The chunk is finished once it is merged, or nothing remains that you could do on your own, and every answer the human typed in it", argument(workers[1], "-p")) self.assertEqual({call["cwd"] for call in run.calls}, {str(checkout.root)}) self.assertIn("1. Work.", run.calls[1]["stdin"]) self.assertIn("From docs/decisions.md:\n# Decisions\n\nFrom ~/.claude/CLAUDE.md:\n# Global instructions", run.calls[1]["stdin"]) diff --git a/docs/decisions.md b/docs/decisions.md index cd8528ce..2ca36866 100644 --- a/docs/decisions.md +++ b/docs/decisions.md @@ -12,7 +12,7 @@ 2026-10-03, lilleman: the judge is to read `~/.claude/CLAUDE.md` whole too. The worker follows that file, so a question it answers should not reach the human (goal 4.2). Reading the whole file is safe, because the judge may quote only words that appear in it. A list of sections would need keeping current. Implemented the same day. -2026-10-03, lilleman: the judge rules a chunk finished only once every answer the human typed in it is recorded. A finished chunk's session is deleted, and its answers with it, so an answer recorded nowhere would be asked again in a later chunk (goal 4.2). Implemented the same day by claude, which settled two choices the ruling left open. First, an answer counts as recorded where the files the judge reads hold it, `~/.claude/CLAUDE.md` included, or where the transcript shows the worker writing it into `README.md`'s premises, `AGENTS.md`, `docs/decisions.md`, `todo.md` or a code comment. A worker's write to `~/.claude/CLAUDE.md` does not count: `CLAUDE.md` โ†’ "Maintaining this file" leaves its edits to the human. The judge cannot read a code comment or `todo.md`, yet `CLAUDE.md` โ†’ "Working loop", "Ask, don't guess" puts a standing choice made in one place in a comment there, and the plan's approval belongs in `todo.md`. And the judge reads the records from the main checkout once a cycle, which may not yet hold an answer the worker merged. A judge refusing either would hold the chunk open every cycle. Second, only an answer a later chunk could need must be recorded, so an approval such as "merge it" holds nothing open. The worker's resume prompt states the rule, so a chunk held open says why. +2026-10-03, lilleman: the judge rules a chunk finished only once every answer the human typed in it is recorded. A finished chunk's session is deleted, and its answers with it, so an answer recorded nowhere would be asked again in a later chunk (goal 4.2). Implemented the same day by claude, which settled two choices the ruling left open. First, an answer counts as recorded where the files the judge reads hold it, `~/.claude/CLAUDE.md` included, or where the transcript shows the worker writing it into `README.md`'s premises, `AGENTS.md`, `docs/decisions.md`, `todo.md` or a code comment. A worker's write to `~/.claude/CLAUDE.md` does not count: `CLAUDE.md` โ†’ "Maintaining this file" leaves new rules in it to the human. The judge cannot read a code comment or `todo.md`. Yet `CLAUDE.md` โ†’ "Working loop", "Ask, don't guess" puts a standing choice made in one place in a comment there. And the human's approval of a release's items, which "Working loop" requires, is the set of rows `todo.md` names for that release. The judge also reads the records once a cycle from the main checkout. That checkout may not yet hold an answer the worker wrote and merged. A judge that refused any of these would hold the chunk open every cycle. Second, only an answer a later chunk could need must be recorded, so an approval such as "merge it" holds nothing open. The worker's resume prompt states the rule, so a worker whose chunk is held open knows it. ## loop-claude: one session per project, its id derived from the checkout's path relative to `~/code`, or to `/` outside it diff --git a/todo.md b/todo.md index b9340d49..1a34f75f 100644 --- a/todo.md +++ b/todo.md @@ -26,7 +26,7 @@ |---|---|---|---|---|---|---|---|---|---| | 1 | 0.1.0 | question | **Say in README โ†’ Install how the transcript archive is backed up, once bender-infra backs up ai-sandbox's data volume.** | 3 | 5 | 8 | 9 | 2, 3 | 27.8 | | 54 | 0.1.0 | | **Give each review pass a fixed name in larv-review ยง3's table, and count its rounds by that name.** | 2 | 1 | 6 | 6 | 4, 4.1 | 17.8 | -| 58 | 0.1.0 | | **Resume the worker of a chunk the judge held open with the judge's evidence of what remains.** | 3 | 3 | 6 | 6 | 4, 4.4 | 16.3 | +| 58 | 0.1.0 | | **Give the worker of a chunk the judge held open the judge's evidence of what remains.** | 3 | 3 | 6 | 6 | 4, 4.4 | 16.3 | | 55 | 0.1.0 | | **Make larv-review's comprehension floor readable without opening the panel skill, its scoring-run file and `AGENTS.md` in turn.** | 2 | 3 | 5 | 6 | 4, 4.1 | 15.3 | | 23 | 0.1.0 | | **Launch a principles auditor only for a principles file the project shows applies, and rerun only the reviewer whose finding a fix answers.** | 3 | 4 | 7 | 8 | 4.4 | 13.5 | | 21 | 0.1.0 | | **Give `settings.json`'s model one writer, and sort its keys.** | 3 | 3 | 6 | 7 | 4.3 | 12.9 | @@ -55,9 +55,9 @@ The README line covers the bench's transcripts in `workflow-bench/logs/` too (go Named under Shape by the PR #208 scoring runs: "Count" keys on `Answer round :`, but the table's first column names the architecture pass with a whole sentence, so a run can spell one pass two ways and restart its count. -### 58. Resume the worker of a chunk the judge held open with the judge's evidence of what remains. +### 58. Give the worker of a chunk the judge held open the judge's evidence of what remains. -Raised by the product-owner review of PR #211: an unfinished verdict resumes the worker with a generic prompt, so a worker that thinks the chunk done repeats itself, and nothing bounds a run of unfinished verdicts (goal 4.4). +Raised by the product-owner review of PR #211: a verdict that the chunk is unfinished resumes the worker with a generic prompt, so a worker that thinks the chunk done repeats itself, and nothing bounds a run of such verdicts (goal 4.4). ### 55. Make larv-review's comprehension floor readable without opening the panel skill, its scoring-run file and `AGENTS.md` in turn. -- 2.52.0 From d23a2f48376fb205c9a2f2f6a204f8f14e15c9f0 Mon Sep 17 00:00:00 2001 From: Lilleman auf Larv Date: Sat, 3 Oct 2026 21:15:44 +0200 Subject: [PATCH 09/16] Answer product-owner round 3: the places just listed, never CLAUDE.md, land in the prose round 1 commit -- 2.52.0 From 72ad23f7c22887db4aeb52038dce24ee2cc44d99 Mon Sep 17 00:00:00 2001 From: Lilleman auf Larv Date: Sat, 3 Oct 2026 21:17:17 +0200 Subject: [PATCH 10/16] Answer prose round 2: the resume prompt and the judge state the finish rule without a second reading --- bin/loop_claude/cycle/judge_reply.py | 5 +++-- bin/loop_claude/cycle/worker.py | 2 +- bin/test_loop_claude_black_box.py | 2 +- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/bin/loop_claude/cycle/judge_reply.py b/bin/loop_claude/cycle/judge_reply.py index ecc2d378..12cd1507 100644 --- a/bin/loop_claude/cycle/judge_reply.py +++ b/bin/loop_claude/cycle/judge_reply.py @@ -30,8 +30,9 @@ JUDGE_RULES = ( "The chunk is the piece of work the agent is on, shipped as one pull request. " "finished=true when the chunk is complete: merged, or nothing remains that the agent could do on " f"its own. Even then, it is finished only once {ANSWERS_RECORDED}. An answer counts as recorded " - "where README.md or the records above hold it, or where the transcript shows the agent writing it " - "into one of the places just listed, never ~/.claude/CLAUDE.md. finished=false when work remains that a further run can continue: an open PR, a review " + "where README.md or the records above hold it, ~/.claude/CLAUDE.md included. It also counts where " + "the transcript shows the agent writing it into one of the places just listed; writing it into " + "~/.claude/CLAUDE.md does not count. finished=false when work remains that a further run can continue: an open PR, a review " "not yet run, CI not yet reported, an answer not yet recorded." ) diff --git a/bin/loop_claude/cycle/worker.py b/bin/loop_claude/cycle/worker.py index 5fb19187..c4f2961d 100644 --- a/bin/loop_claude/cycle/worker.py +++ b/bin/loop_claude/cycle/worker.py @@ -43,7 +43,7 @@ def worker_args(task: str, session: Session, model: str, resuming: bool, answere if answered is not None: 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: - start = ["-p", f"Continue the task; the previous run stopped before it was finished. The chunk is finished once it is merged, or nothing remains that you could do on your own, and {ANSWERS_RECORDED}.", "--resume", str(session.id)] + start = ["-p", f"Continue the task; the previous run stopped before it was finished. 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/test_loop_claude_black_box.py b/bin/test_loop_claude_black_box.py index 088168fd..0297e37f 100644 --- a/bin/test_loop_claude_black_box.py +++ b/bin/test_loop_claude_black_box.py @@ -344,7 +344,7 @@ class Cycles(unittest.TestCase): self.assertEqual(argument(workers[2], "--session-id"), session) self.assertTrue(argument(workers[0], "-p").startswith(f"{TASK}\n\nContinue any open draft PR")) self.assertNotIn(TASK, argument(workers[1], "-p")) - self.assertIn("The chunk is finished once it is merged, or nothing remains that you could do on your own, and every answer the human typed in it", argument(workers[1], "-p")) + self.assertIn("Even then, it is finished only once every answer the human typed in it", argument(workers[1], "-p")) self.assertEqual({call["cwd"] for call in run.calls}, {str(checkout.root)}) self.assertIn("1. Work.", run.calls[1]["stdin"]) self.assertIn("From docs/decisions.md:\n# Decisions\n\nFrom ~/.claude/CLAUDE.md:\n# Global instructions", run.calls[1]["stdin"]) -- 2.52.0 From 9c6cc055e3aa6f298a1406a35d236158ed199112 Mon Sep 17 00:00:00 2001 From: Lilleman auf Larv Date: Sat, 3 Oct 2026 21:17:32 +0200 Subject: [PATCH 11/16] Answer prose round 3: nothing to change -- 2.52.0 From 1dd5c7bb72b0fa2a33829ef3558c7795f433860b Mon Sep 17 00:00:00 2001 From: Lilleman auf Larv Date: Sun, 4 Oct 2026 11:37:57 +0200 Subject: [PATCH 12/16] Answer stability round 4: nothing to change -- 2.52.0 From 0488189f8aad37e2aef8c5fa4b0204e5aa4a344d Mon Sep 17 00:00:00 2001 From: Lilleman auf Larv Date: Sun, 4 Oct 2026 11:38:40 +0200 Subject: [PATCH 13/16] Answer product-owner round 4: the judge names the places a written answer counts in --- bin/loop_claude/cycle/judge_reply.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/bin/loop_claude/cycle/judge_reply.py b/bin/loop_claude/cycle/judge_reply.py index 12cd1507..cee54be5 100644 --- a/bin/loop_claude/cycle/judge_reply.py +++ b/bin/loop_claude/cycle/judge_reply.py @@ -31,8 +31,8 @@ JUDGE_RULES = ( "finished=true when the chunk is complete: merged, or nothing remains that the agent could do on " f"its own. Even then, it is finished only once {ANSWERS_RECORDED}. An answer counts as recorded " "where README.md or the records above hold it, ~/.claude/CLAUDE.md included. It also counts where " - "the transcript shows the agent writing it into one of the places just listed; writing it into " - "~/.claude/CLAUDE.md does not count. finished=false when work remains that a further run can continue: an open PR, a review " + "the transcript shows the agent writing it into README.md's Goals or Audience, AGENTS.md, " + "docs/decisions.md, todo.md or a comment; writing it into ~/.claude/CLAUDE.md does not count. finished=false when work remains that a further run can continue: an open PR, a review " "not yet run, CI not yet reported, an answer not yet recorded." ) -- 2.52.0 From 970f80a21047a4d2bcddec89e2b424477e26d737 Mon Sep 17 00:00:00 2001 From: Lilleman auf Larv Date: Sun, 4 Oct 2026 12:00:31 +0200 Subject: [PATCH 14/16] Answer stability round 5: one constant holds the places a written answer counts in; the prompts are unchanged --- bin/loop_claude/cycle/judge_reply.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/bin/loop_claude/cycle/judge_reply.py b/bin/loop_claude/cycle/judge_reply.py index cee54be5..266352ac 100644 --- a/bin/loop_claude/cycle/judge_reply.py +++ b/bin/loop_claude/cycle/judge_reply.py @@ -3,7 +3,8 @@ import typing from failure import Failure -ANSWERS_RECORDED = "every answer the human typed in it that a later chunk could need is recorded in README.md's Goals or Audience, AGENTS.md, docs/decisions.md, todo.md or a comment at the one place it governs" +RECORD_PLACES = "README.md's Goals or Audience, AGENTS.md, docs/decisions.md, todo.md or a comment" +ANSWERS_RECORDED = f"every answer the human typed in it that a later chunk could need is recorded in {RECORD_PLACES} at the one place it governs" JUDGE_RULES = ( "Decide whether the human must now be interrupted. interrupt=true when any of these appear:\n" "- the agent asks the human anything, seeks approval, or says a decision is the human's, and neither " @@ -31,9 +32,9 @@ JUDGE_RULES = ( "finished=true when the chunk is complete: merged, or nothing remains that the agent could do on " f"its own. Even then, it is finished only once {ANSWERS_RECORDED}. An answer counts as recorded " "where README.md or the records above hold it, ~/.claude/CLAUDE.md included. It also counts where " - "the transcript shows the agent writing it into README.md's Goals or Audience, AGENTS.md, " - "docs/decisions.md, todo.md or a comment; writing it into ~/.claude/CLAUDE.md does not count. finished=false when work remains that a further run can continue: an open PR, a review " - "not yet run, CI not yet reported, an answer not yet recorded." + f"the transcript shows the agent writing it into {RECORD_PLACES}; writing it into " + "~/.claude/CLAUDE.md does not count. finished=false when work remains that a further run can " + "continue: an open PR, a review not yet run, CI not yet reported, an answer not yet recorded." ) -- 2.52.0 From 44f3e5770843556722d9ecb826a90d9b143df2e1 Mon Sep 17 00:00:00 2001 From: Lilleman auf Larv Date: Sun, 4 Oct 2026 12:00:31 +0200 Subject: [PATCH 15/16] Answer prose round 4: the list is in one constant, landed in the stability round 5 commit -- 2.52.0 From f99588cc456e3bf88cae5cb37371c175d0205eca Mon Sep 17 00:00:00 2001 From: Lilleman auf Larv Date: Sun, 4 Oct 2026 12:00:31 +0200 Subject: [PATCH 16/16] Answer product-owner round 5: nothing to change -- 2.52.0