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.