From 69ffd6c1a1e2b00773d340b020a543886bdb151d Mon Sep 17 00:00:00 2001 From: Lilleman auf Larv Date: Sat, 3 Oct 2026 20:44:36 +0200 Subject: [PATCH 1/9] Archive each verdict's evidence, and stamp each outcome with its UTC time --- CHANGELOG.md | 1 + bin/loop_claude/cycle/archive.py | 8 +++++--- bin/loop_claude/cycle/run.py | 6 +++--- bin/loop_claude/loop/main.py | 7 ++++--- bin/test_loop_claude.py | 16 ++++++++-------- bin/test_loop_claude_black_box.py | 13 +++++++------ todo.md | 10 ---------- 7 files changed, 28 insertions(+), 33 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9ddc3fe1..9b64e671 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,7 @@ ## Unreleased +- `loop-claude`'s `.outcomes.md` gives each verdict the transcript passage the judge rested it on, and stamps each outcome with 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/archive.py b/bin/loop_claude/cycle/archive.py index 404ce080..f78b07d0 100644 --- a/bin/loop_claude/cycle/archive.py +++ b/bin/loop_claude/cycle/archive.py @@ -2,6 +2,7 @@ import hashlib import os import pathlib import sys +import time from failure import Failure from loop_claude.claude_code.transcript import first_timestamped_line @@ -10,7 +11,7 @@ from loop_claude.paths import Paths from loop_claude.claude_code.session import session_files -def archive(project_key: str, path: str, task: str, outcome: str, paths: Paths) -> Failure | None: +def archive(project_key: str, path: str, task: str, outcome: str, at: float, paths: Paths) -> Failure | None: try: with open(path, "rb") as handle: raw = handle.read() @@ -24,10 +25,11 @@ def archive(project_key: str, path: str, task: str, outcome: str, paths: Paths) return unkept copy = folder / f"{hashlib.sha256(raw).hexdigest()}.jsonl" outcomes = copy.with_suffix(".outcomes.md") + stamped = f"{time.strftime('%Y-%m-%dT%H:%M:%SZ', time.gmtime(at))} {outcome}" if copy.exists() and outcomes.exists(): - return add_outcome(outcomes, outcome) + return add_outcome(outcomes, stamped) # The copy lands last, so a copy on disk always has its outcomes and its session's files beside it. - for dest, data in ((outcomes, f"Task: {task}\n\n{outcome}\n".encode()), (copy, raw)): + for dest, data in ((outcomes, f"Task: {task}\n\n{stamped}\n".encode()), (copy, raw)): if unwritten := replace_file(dest, data): return unarchived(dest, unwritten.reason) print(f"transcript: {copy}", file=sys.stderr) diff --git a/bin/loop_claude/cycle/run.py b/bin/loop_claude/cycle/run.py index 7fdc4a90..1cdb29f7 100644 --- a/bin/loop_claude/cycle/run.py +++ b/bin/loop_claude/cycle/run.py @@ -46,7 +46,7 @@ def run_cycle(cycle: Cycle) -> Stop | None: def stopped(cycle: Cycle, stop: Stop, why: str) -> Stop: path = transcript_file(cycle.session) - failure = archive(cycle.project_key, path, cycle.task, f"Stopped: {why}", cycle.paths) if path else None + failure = archive(cycle.project_key, path, cycle.task, f"Stopped: {why}", cycle.effects.now(), cycle.paths) if path else None # A failed archive exits 1 whatever the stop; when the stop was this archive failing, its reason is said once. return Stop(1, f"{failure.reason}\n{stop.reason}".rstrip()) if failure and failure.reason != stop.reason else stop @@ -86,7 +86,7 @@ def rule(cycle: Cycle, transcript_path: str) -> Ruled | Stop: def ask(cycle: Cycle, transcript_path: str, ruling: Interrupt | QuotedAnswer) -> HumanAnswered | Stop: question = question_for(ruling) # Archived now, so the transcript the question was asked on is kept with it; the human's answer then grows the transcript. - if failure := archive(cycle.project_key, transcript_path, cycle.task, f"Verdict: interrupt\n\n{question}", cycle.paths): + if failure := archive(cycle.project_key, transcript_path, cycle.task, f"Verdict: interrupt\n\n{question}\n\nEvidence:\n{ruling.evidence}", cycle.effects.now(), cycle.paths): return Stop(1, failure.reason) return interrupt(cycle.root, cycle.session.id, cycle.models.worker, transcript_path, question, cycle.paths, cycle.effects) or HumanAnswered() @@ -99,7 +99,7 @@ def question_for(ruling: Interrupt | QuotedAnswer) -> str: def close(cycle: Cycle, transcript_path: str, verdict: Finished | Unfinished) -> Archived | Stop: finished = isinstance(verdict, Finished) - if failure := archive(cycle.project_key, transcript_path, cycle.task, f"Verdict: {'finished' if finished else 'unfinished'}", cycle.paths): + if failure := archive(cycle.project_key, transcript_path, cycle.task, f"Verdict: {'finished' if finished else 'unfinished'}\n\nEvidence:\n{verdict.evidence}", cycle.effects.now(), cycle.paths): return Stop(1, failure.reason) if finished and (failure := delete_session(cycle.session)): return Stop(1, failure.reason) diff --git a/bin/loop_claude/loop/main.py b/bin/loop_claude/loop/main.py index 70b91729..6753e776 100644 --- a/bin/loop_claude/loop/main.py +++ b/bin/loop_claude/loop/main.py @@ -22,9 +22,10 @@ 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, and why the loop stopped. 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 +holds the verdict with the transcript passage the judge rested it on, and why the loop stopped, each +after 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 .. diff --git a/bin/test_loop_claude.py b/bin/test_loop_claude.py index ff7f8dfd..e9ad5351 100644 --- a/bin/test_loop_claude.py +++ b/bin/test_loop_claude.py @@ -179,7 +179,7 @@ class Cycles(unittest.TestCase): def test_a_finished_chunk_is_archived_and_its_session_deleted(self): fake = FakeEffects(streams=[Worker(self.paths.claude_code_transcripts.parent)], claude=[judged("finished")]) self.assertIsNone(run.run_cycle(self.cycle(fake))) - self.assertEqual(self.archived_outcomes(), ["Task: Do it.\n\nVerdict: finished\n"]) + self.assertEqual(self.archived_outcomes(), ["Task: Do it.\n\n2026-09-21T14:13:20Z Verdict: finished\n\nEvidence:\nworking\n"]) self.assertIsNone(session.transcript_file(self.session)) def test_an_unfinished_chunks_transcript_is_archived_and_the_next_cycle_resumes_its_session(self): @@ -190,14 +190,14 @@ class Cycles(unittest.TestCase): workers = fake.made("stream_claude") self.assertIn("--session-id", workers[0]) self.assertIn("--resume", workers[1]) - self.assertEqual(self.archived_outcomes(), ["Task: Do it.\n\nVerdict: unfinished\n"] * 2) + self.assertEqual(self.archived_outcomes(), ["Task: Do it.\n\n2026-09-21T14:13:20Z Verdict: unfinished\n\nEvidence:\nworking\n"] * 2) def test_a_cycle_stopped_by_a_failure_or_ctrl_c_archives_what_its_session_holds(self): fake = FakeEffects(streams=[Worker(self.paths.claude_code_transcripts.parent)], claude=[ran(code=1)] * 3) self.assertEqual(run.run_cycle(self.cycle(fake)).code, 1) fake = FakeEffects(streams=[Worker(self.paths.claude_code_transcripts.parent)], claude=[KeyboardInterrupt()]) self.assertEqual(run.run_cycle(self.cycle(fake)), Stop(130, "")) - self.assertEqual(self.archived_outcomes(), ["Task: Do it.\n\nStopped: Ctrl-C\n", "Task: Do it.\n\nStopped: the judge failed three times running: the judge exited 1\n"]) + self.assertEqual(self.archived_outcomes(), ["Task: Do it.\n\n2026-09-21T14:13:20Z Stopped: Ctrl-C\n", "Task: Do it.\n\n2026-09-21T14:13:20Z Stopped: the judge failed three times running: the judge exited 1\n"]) def test_archives_each_chunks_session_folder_replacing_a_copy_only_with_what_grew_from_it(self): folder = self.paths.claude_code_transcripts / "-fake" / str(self.session.id) @@ -243,7 +243,7 @@ class Cycles(unittest.TestCase): return 0 fake = FakeEffects(streams=[Worker(self.paths.claude_code_transcripts.parent)], claude=[judged("interrupt"), judged("unfinished")], on_terminal_claude=[answer], git=[ran()]) self.assertIsNone(run.run_cycle(self.cycle(fake))) - self.assertEqual(self.archived_outcomes(), ["Task: Do it.\n\nVerdict: interrupt\n\nWhich one?\n", "Task: Do it.\n\nVerdict: unfinished\n"]) + self.assertEqual(self.archived_outcomes(), ["Task: Do it.\n\n2026-09-21T14:13:20Z Verdict: interrupt\n\nWhich one?\n\nEvidence:\nworking\n", "Task: Do it.\n\n2026-09-21T14:13:20Z Verdict: unfinished\n\nEvidence:\nworking\n"]) self.assertIn(str(self.session.id), fake.made("claude_on_terminal")[0]) prompts = [stdin for args, stdin in fake.made("claude")] self.assertEqual(len(prompts), 2) @@ -279,7 +279,7 @@ class Cycles(unittest.TestCase): stop = run.run_cycle(self.cycle(fake)) self.assertEqual(stop, Stop(1, f"could not delete {folder}: Permission denied; delete every file and folder matching {folder}*, then rerun loop-claude; a rerun before that resumes the finished chunk's session")) self.assertTrue(session.session_open(self.session)) - self.assertEqual(self.archived_outcomes(), [f"Task: Do it.\n\nVerdict: finished\n\nStopped: {stop.reason}\n"]) + self.assertEqual(self.archived_outcomes(), [f"Task: Do it.\n\n2026-09-21T14:13:20Z Verdict: finished\n\nEvidence:\nworking\n\n2026-09-21T14:13:20Z Stopped: {stop.reason}\n"]) def test_stops_when_the_worker_leaves_no_transcript(self): fake = FakeEffects(streams=[Streamed(0)]) @@ -423,11 +423,11 @@ class Archive(unittest.TestCase): transcript = pathlib.Path(root, "t.jsonl") transcript.write_text('{"timestamp": "2026-10-03T00:00:00Z"}\n') with contextlib.redirect_stderr(io.StringIO()): - self.assertIsNone(archive.archive("proj", str(transcript), "Do it.", "Verdict: unfinished", kept)) + self.assertIsNone(archive.archive("proj", str(transcript), "Do it.", "Verdict: unfinished", NOW, kept)) (outcomes,) = kept.transcript_archive.glob("proj/*/*.outcomes.md") outcomes.unlink() - self.assertIsNone(archive.archive("proj", str(transcript), "Do it.", "Stopped: Ctrl-C", kept)) - self.assertEqual(outcomes.read_text(), "Task: Do it.\n\nStopped: Ctrl-C\n") + self.assertIsNone(archive.archive("proj", str(transcript), "Do it.", "Stopped: Ctrl-C", NOW, kept)) + self.assertEqual(outcomes.read_text(), "Task: Do it.\n\n2026-09-21T14:13:20Z Stopped: Ctrl-C\n") class CopyFor(unittest.TestCase): diff --git a/bin/test_loop_claude_black_box.py b/bin/test_loop_claude_black_box.py index 884221b2..ff1c7f5b 100644 --- a/bin/test_loop_claude_black_box.py +++ b/bin/test_loop_claude_black_box.py @@ -5,6 +5,7 @@ import json import os import pathlib import pty +import re import select import shutil import stat @@ -250,7 +251,7 @@ class Checkout: return pathlib.Path(self.env.get("LOOP_CLAUDE_TRANSCRIPTS", self.home / ".claude" / "loop-claude-transcripts")) def archived(self): - """Each archived transcript's outcomes, after checking the copy is named by its content hash.""" + """Each archived transcript's outcomes, each UTC stamp read as , after checking the copy is named by its content hash.""" outcomes = {} for folder in (self.archive(), self.archive() / "proj", *(self.archive() / "proj").iterdir()): self.test.assertEqual(stat.S_IMODE(folder.stat().st_mode), 0o700, folder) @@ -259,7 +260,7 @@ class Checkout: kept = copy.with_suffix(".outcomes.md") for archived in (copy, kept): self.test.assertEqual(stat.S_IMODE(archived.stat().st_mode), 0o600) - outcomes[copy.read_text()] = kept.read_text() + outcomes[copy.read_text()] = re.sub(r"^\d{4}-\d\d-\d\dT\d\d:\d\d:\d\dZ ", " ", kept.read_text(), flags=re.MULTILINE) return outcomes @@ -351,9 +352,9 @@ class Cycles(unittest.TestCase): self.assertEqual([path.name for path in checkout.transcripts()[0].parent.iterdir()], [checkout.transcripts()[0].name]) self.assertIn("=== cycle 3 ===", run.stdout) copies = {verdict.removeprefix(f"Task: {TASK}\n\n"): copy for copy, verdict in checkout.archived().items()} - self.assertEqual(sorted(copies), ["Stopped: Ctrl-C\n", "Verdict: finished\n", "Verdict: unfinished\n"]) - self.assertIn('"text": "landed-it"', copies["Verdict: finished\n"]) - self.assertIn('"text": "next chunk"', copies["Stopped: Ctrl-C\n"]) + self.assertEqual(sorted(copies), [" Stopped: Ctrl-C\n", " Verdict: finished\n\nEvidence:\nlanded-it\n", " Verdict: unfinished\n\nEvidence:\nstarted\n"]) + self.assertIn('"text": "landed-it"', copies[" Verdict: finished\n\nEvidence:\nlanded-it\n"]) + self.assertIn('"text": "next chunk"', copies[" Stopped: Ctrl-C\n"]) self.assertEqual(len(list(checkout.archive().glob(f"proj/*/session/{session}.orphaned-1-ab.jsonl"))), 1) def test_exits_1_when_the_transcript_cannot_be_archived_and_resumes_on_the_next_run(self): @@ -478,7 +479,7 @@ class Interrupt(unittest.TestCase): self.assertEqual(run.stderr.strip().splitlines()[-2:], ["A or B?", "the human is needed to answer the question above, but stdin or stdout is not a terminal; rerun loop-claude on a terminal"]) [(copy, verdict)] = checkout.archived().items() self.assertEqual(copy, (checkout.transcripts()[0]).read_text()) - self.assertEqual(verdict, f"Task: {TASK}\n\nVerdict: interrupt\n\nA or B?\n\nStopped: the human is needed to answer the question above, but stdin or stdout is not a terminal; rerun loop-claude on a terminal\n") + self.assertEqual(verdict, f"Task: {TASK}\n\n Verdict: interrupt\n\nA or B?\n\nEvidence:\nShall I use A or B?\n\n Stopped: the human is needed to answer the question above, but stdin or stdout is not a terminal; rerun loop-claude on a terminal\n") self.assertEqual(stat.S_IMODE((checkout.temp / "deep").stat().st_mode), 0o700) self.assertIn(f"transcript: {checkout.archive() / 'proj'}/", run.stderr) session = argument(run.calls[0], "--session-id") diff --git a/todo.md b/todo.md index d79e8244..da85b963 100644 --- a/todo.md +++ b/todo.md @@ -25,12 +25,10 @@ | 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 | -| 47 | 0.1.0 | | **Archive the judge's evidence with each verdict, so a wrong finish shows what it rested on.** | 1 | 1 | 6 | 6 | 2, 4 | 21.4 | | 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 | | 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 | -| 48 | 0.1.0 | | **Stamp each archived outcome with its UTC time.** | 1 | 1 | 4 | 4 | 2 | 13.9 | | 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 | | 49 | 0.1.0 | principle | **Check that `AGENTS.md` lists exactly the titles of `docs/decisions.md`.** | 1 | 2 | 5 | 6 | 4.3 | 12.5 | @@ -54,10 +52,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). -### 47. Archive the judge's evidence with each verdict, so a wrong finish shows what it rested on. - -The judge runs without session persistence, and `close` and `ask` archive only the verdict and the question. A wrong `finished` deletes the session, and nothing then shows the passage the judge quoted. - ### 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). @@ -74,10 +68,6 @@ Named under Shape by the PR #208 scoring runs: "Count" keys on `Answer ro Named under Self-sufficiency by the PR #208 scoring runs, as the worst of the skills' leans on other documents. -### 48. Stamp each archived outcome with its UTC time. - -After an overnight exit 1, `.outcomes.md` holds each outcome without saying when it happened. - ### 23. Launch a principles auditor only for a principles file the project shows applies, and rerun only the reviewer whose finding a fix answers. On this repo the frontend, REST and logging auditors each read the whole project to report "does not apply", and one 🟢 fix reruns ten whole-project reads. -- 2.52.0 From 47347ad0b094a291446051b75c98a21842579524 Mon Sep 17 00:00:00 2001 From: Lilleman auf Larv Date: Sat, 3 Oct 2026 20:47:33 +0200 Subject: [PATCH 2/9] Answer security round 1: nothing to change -- 2.52.0 From 915b9683d2246a5b017d985e6262b898924324f8 Mon Sep 17 00:00:00 2001 From: Lilleman auf Larv Date: Sat, 3 Oct 2026 20:47:33 +0200 Subject: [PATCH 3/9] Answer prose round 1: the help text says what opens with the UTC time, the evidence reads as a blockquote --- CHANGELOG.md | 3 +-- bin/loop_claude/cycle/run.py | 9 +++++++-- bin/loop_claude/loop/main.py | 10 +++++----- bin/test_loop_claude.py | 13 +++++++++---- bin/test_loop_claude_black_box.py | 8 ++++---- todo.md | 7 ++++++- 6 files changed, 32 insertions(+), 18 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9b64e671..004498c3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,7 +2,6 @@ ## Unreleased -- `loop-claude`'s `.outcomes.md` gives each verdict the transcript passage the judge rested it on, and stamps each outcome with 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. @@ -28,6 +27,6 @@ - `loop-claude` retries a failed worker within its cycle. - `loop-claude` counts an interrupt reply starting with `<` as typed. - `loop-claude`'s judge sees a reply the human types while claude works, and an interrupt counts one as typed. -- `loop-claude` archives the raw `.jsonl` transcript at every interrupt and as every cycle ends, Ctrl-C and failures included, in one folder per chunk. Each distinct transcript is kept once, named by its SHA-256, with `.outcomes.md` beside it holding the verdict and why the loop stopped. The subagents' transcripts and the session's other files go in the chunk folder's `session/` subfolder. `loop-claude` exits 1 when it cannot archive. +- `loop-claude` archives the raw `.jsonl` transcript at every interrupt and as every cycle ends, Ctrl-C and failures included, in one folder per chunk. Each distinct transcript is kept once, named by its SHA-256, with `.outcomes.md` beside it holding 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. The subagents' transcripts and the session's other files go in the chunk folder's `session/` subfolder. `loop-claude` exits 1 when it cannot archive. - `loop-claude` exits 1 when it cannot delete a finished chunk's session, naming what to delete before rerunning; the next chunk would otherwise resume it. - `loop-claude` keeps the mode of `~/.claude.json` and of its models file when it rewrites them, and creates the models file 0600. diff --git a/bin/loop_claude/cycle/run.py b/bin/loop_claude/cycle/run.py index 1cdb29f7..5d972f07 100644 --- a/bin/loop_claude/cycle/run.py +++ b/bin/loop_claude/cycle/run.py @@ -86,7 +86,7 @@ def rule(cycle: Cycle, transcript_path: str) -> Ruled | Stop: def ask(cycle: Cycle, transcript_path: str, ruling: Interrupt | QuotedAnswer) -> HumanAnswered | Stop: question = question_for(ruling) # Archived now, so the transcript the question was asked on is kept with it; the human's answer then grows the transcript. - if failure := archive(cycle.project_key, transcript_path, cycle.task, f"Verdict: interrupt\n\n{question}\n\nEvidence:\n{ruling.evidence}", cycle.effects.now(), cycle.paths): + if failure := archive(cycle.project_key, transcript_path, cycle.task, f"Verdict: interrupt\n\n{question}\n\nEvidence:\n{quoted(ruling.evidence)}", cycle.effects.now(), cycle.paths): return Stop(1, failure.reason) return interrupt(cycle.root, cycle.session.id, cycle.models.worker, transcript_path, question, cycle.paths, cycle.effects) or HumanAnswered() @@ -99,8 +99,13 @@ def question_for(ruling: Interrupt | QuotedAnswer) -> str: def close(cycle: Cycle, transcript_path: str, verdict: Finished | Unfinished) -> Archived | Stop: finished = isinstance(verdict, Finished) - if failure := archive(cycle.project_key, transcript_path, cycle.task, f"Verdict: {'finished' if finished else 'unfinished'}\n\nEvidence:\n{verdict.evidence}", cycle.effects.now(), cycle.paths): + if failure := archive(cycle.project_key, transcript_path, cycle.task, f"Verdict: {'finished' if finished else 'unfinished'}\n\nEvidence:\n{quoted(verdict.evidence)}", cycle.effects.now(), cycle.paths): return Stop(1, failure.reason) if finished and (failure := delete_session(cycle.session)): return Stop(1, failure.reason) return Archived() + + +# A Markdown blockquote, so the evidence reads as one passage and ends where the next outcome starts. +def quoted(passage: str) -> str: + return "\n".join(f"> {line}" for line in passage.splitlines()) diff --git a/bin/loop_claude/loop/main.py b/bin/loop_claude/loop/main.py index 6753e776..222c63fd 100644 --- a/bin/loop_claude/loop/main.py +++ b/bin/loop_claude/loop/main.py @@ -22,11 +22,11 @@ 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, each -after 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 +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 .. Every claude loop-claude starts runs the project's model, saved per in diff --git a/bin/test_loop_claude.py b/bin/test_loop_claude.py index e9ad5351..9604a58d 100644 --- a/bin/test_loop_claude.py +++ b/bin/test_loop_claude.py @@ -162,6 +162,11 @@ class QuestionFor(unittest.TestCase): 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.") +class Quoted(unittest.TestCase): + def test_quotes_every_line_of_a_passage_blank_ones_included(self): + self.assertEqual(run.quoted("merged\n\nPR #1"), "> merged\n> \n> PR #1") + + class Cycles(unittest.TestCase): def setUp(self): temp = tempfile.TemporaryDirectory() @@ -179,7 +184,7 @@ class Cycles(unittest.TestCase): def test_a_finished_chunk_is_archived_and_its_session_deleted(self): fake = FakeEffects(streams=[Worker(self.paths.claude_code_transcripts.parent)], claude=[judged("finished")]) self.assertIsNone(run.run_cycle(self.cycle(fake))) - self.assertEqual(self.archived_outcomes(), ["Task: Do it.\n\n2026-09-21T14:13:20Z Verdict: finished\n\nEvidence:\nworking\n"]) + self.assertEqual(self.archived_outcomes(), ["Task: Do it.\n\n2026-09-21T14:13:20Z Verdict: finished\n\nEvidence:\n> working\n"]) self.assertIsNone(session.transcript_file(self.session)) def test_an_unfinished_chunks_transcript_is_archived_and_the_next_cycle_resumes_its_session(self): @@ -190,7 +195,7 @@ class Cycles(unittest.TestCase): workers = fake.made("stream_claude") self.assertIn("--session-id", workers[0]) self.assertIn("--resume", workers[1]) - self.assertEqual(self.archived_outcomes(), ["Task: Do it.\n\n2026-09-21T14:13:20Z Verdict: unfinished\n\nEvidence:\nworking\n"] * 2) + self.assertEqual(self.archived_outcomes(), ["Task: Do it.\n\n2026-09-21T14:13:20Z Verdict: unfinished\n\nEvidence:\n> working\n"] * 2) def test_a_cycle_stopped_by_a_failure_or_ctrl_c_archives_what_its_session_holds(self): fake = FakeEffects(streams=[Worker(self.paths.claude_code_transcripts.parent)], claude=[ran(code=1)] * 3) @@ -243,7 +248,7 @@ class Cycles(unittest.TestCase): return 0 fake = FakeEffects(streams=[Worker(self.paths.claude_code_transcripts.parent)], claude=[judged("interrupt"), judged("unfinished")], on_terminal_claude=[answer], git=[ran()]) self.assertIsNone(run.run_cycle(self.cycle(fake))) - self.assertEqual(self.archived_outcomes(), ["Task: Do it.\n\n2026-09-21T14:13:20Z Verdict: interrupt\n\nWhich one?\n\nEvidence:\nworking\n", "Task: Do it.\n\n2026-09-21T14:13:20Z Verdict: unfinished\n\nEvidence:\nworking\n"]) + self.assertEqual(self.archived_outcomes(), ["Task: Do it.\n\n2026-09-21T14:13:20Z Verdict: interrupt\n\nWhich one?\n\nEvidence:\n> working\n", "Task: Do it.\n\n2026-09-21T14:13:20Z Verdict: unfinished\n\nEvidence:\n> working\n"]) self.assertIn(str(self.session.id), fake.made("claude_on_terminal")[0]) prompts = [stdin for args, stdin in fake.made("claude")] self.assertEqual(len(prompts), 2) @@ -279,7 +284,7 @@ class Cycles(unittest.TestCase): stop = run.run_cycle(self.cycle(fake)) self.assertEqual(stop, Stop(1, f"could not delete {folder}: Permission denied; delete every file and folder matching {folder}*, then rerun loop-claude; a rerun before that resumes the finished chunk's session")) self.assertTrue(session.session_open(self.session)) - self.assertEqual(self.archived_outcomes(), [f"Task: Do it.\n\n2026-09-21T14:13:20Z Verdict: finished\n\nEvidence:\nworking\n\n2026-09-21T14:13:20Z Stopped: {stop.reason}\n"]) + self.assertEqual(self.archived_outcomes(), [f"Task: Do it.\n\n2026-09-21T14:13:20Z Verdict: finished\n\nEvidence:\n> working\n\n2026-09-21T14:13:20Z Stopped: {stop.reason}\n"]) def test_stops_when_the_worker_leaves_no_transcript(self): fake = FakeEffects(streams=[Streamed(0)]) diff --git a/bin/test_loop_claude_black_box.py b/bin/test_loop_claude_black_box.py index ff1c7f5b..caee0b24 100644 --- a/bin/test_loop_claude_black_box.py +++ b/bin/test_loop_claude_black_box.py @@ -251,7 +251,7 @@ class Checkout: return pathlib.Path(self.env.get("LOOP_CLAUDE_TRANSCRIPTS", self.home / ".claude" / "loop-claude-transcripts")) def archived(self): - """Each archived transcript's outcomes, each UTC stamp read as , after checking the copy is named by its content hash.""" + """Each archived transcript's outcomes, with every UTC stamp replaced by , after checking the copy is named by its content hash.""" outcomes = {} for folder in (self.archive(), self.archive() / "proj", *(self.archive() / "proj").iterdir()): self.test.assertEqual(stat.S_IMODE(folder.stat().st_mode), 0o700, folder) @@ -352,8 +352,8 @@ class Cycles(unittest.TestCase): self.assertEqual([path.name for path in checkout.transcripts()[0].parent.iterdir()], [checkout.transcripts()[0].name]) self.assertIn("=== cycle 3 ===", run.stdout) copies = {verdict.removeprefix(f"Task: {TASK}\n\n"): copy for copy, verdict in checkout.archived().items()} - self.assertEqual(sorted(copies), [" Stopped: Ctrl-C\n", " Verdict: finished\n\nEvidence:\nlanded-it\n", " Verdict: unfinished\n\nEvidence:\nstarted\n"]) - self.assertIn('"text": "landed-it"', copies[" Verdict: finished\n\nEvidence:\nlanded-it\n"]) + self.assertEqual(sorted(copies), [" Stopped: Ctrl-C\n", " Verdict: finished\n\nEvidence:\n> landed-it\n", " Verdict: unfinished\n\nEvidence:\n> started\n"]) + self.assertIn('"text": "landed-it"', copies[" Verdict: finished\n\nEvidence:\n> landed-it\n"]) self.assertIn('"text": "next chunk"', copies[" Stopped: Ctrl-C\n"]) self.assertEqual(len(list(checkout.archive().glob(f"proj/*/session/{session}.orphaned-1-ab.jsonl"))), 1) @@ -479,7 +479,7 @@ class Interrupt(unittest.TestCase): self.assertEqual(run.stderr.strip().splitlines()[-2:], ["A or B?", "the human is needed to answer the question above, but stdin or stdout is not a terminal; rerun loop-claude on a terminal"]) [(copy, verdict)] = checkout.archived().items() self.assertEqual(copy, (checkout.transcripts()[0]).read_text()) - self.assertEqual(verdict, f"Task: {TASK}\n\n Verdict: interrupt\n\nA or B?\n\nEvidence:\nShall I use A or B?\n\n Stopped: the human is needed to answer the question above, but stdin or stdout is not a terminal; rerun loop-claude on a terminal\n") + self.assertEqual(verdict, f"Task: {TASK}\n\n Verdict: interrupt\n\nA or B?\n\nEvidence:\n> Shall I use A or B?\n\n Stopped: the human is needed to answer the question above, but stdin or stdout is not a terminal; rerun loop-claude on a terminal\n") self.assertEqual(stat.S_IMODE((checkout.temp / "deep").stat().st_mode), 0o700) self.assertIn(f"transcript: {checkout.archive() / 'proj'}/", run.stderr) session = argument(run.calls[0], "--session-id") diff --git a/todo.md b/todo.md index da85b963..624e1426 100644 --- a/todo.md +++ b/todo.md @@ -6,7 +6,7 @@ `Bar = 9` -`Next ID = 57` +`Next ID = 58` | Goal | W | |---|---| @@ -27,6 +27,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 | | 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 | @@ -60,6 +61,10 @@ The README line covers the bench's transcripts in `workflow-bench/logs/` too (go 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 aec15ccca733aac72ad0f8229b2af724e566a616 Mon Sep 17 00:00:00 2001 From: Lilleman auf Larv Date: Sat, 3 Oct 2026 20:47:33 +0200 Subject: [PATCH 4/9] Answer stability round 1: fixed in the prose round 1 commit -- 2.52.0 From f75408fba25679ee33101ee1fff7e9588e427948 Mon Sep 17 00:00:00 2001 From: Lilleman auf Larv Date: Sat, 3 Oct 2026 20:47:33 +0200 Subject: [PATCH 5/9] Answer product-owner round 1: fixed in the prose round 1 commit; quoted answers filed as item 57 -- 2.52.0 From f60d646dfd58be3c5b13466fb606ed0d70236a62 Mon Sep 17 00:00:00 2001 From: Lilleman auf Larv Date: Sat, 3 Oct 2026 20:48:59 +0200 Subject: [PATCH 6/9] Answer prose round 2: the changelog bullet takes one idea a sentence --- CHANGELOG.md | 2 +- bin/loop_claude/cycle/run.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 004498c3..52e66790 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -27,6 +27,6 @@ - `loop-claude` retries a failed worker within its cycle. - `loop-claude` counts an interrupt reply starting with `<` as typed. - `loop-claude`'s judge sees a reply the human types while claude works, and an interrupt counts one as typed. -- `loop-claude` archives the raw `.jsonl` transcript at every interrupt and as every cycle ends, Ctrl-C and failures included, in one folder per chunk. Each distinct transcript is kept once, named by its SHA-256, with `.outcomes.md` beside it holding 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. The subagents' transcripts and the session's other files go in the chunk folder's `session/` subfolder. `loop-claude` exits 1 when it cannot archive. +- `loop-claude` archives the raw `.jsonl` transcript at every interrupt and as every cycle ends, Ctrl-C and failures included, in one folder per chunk. Each distinct transcript is kept once, named by its SHA-256. Beside it, `.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. The subagents' transcripts and the session's other files go in the chunk folder's `session/` subfolder. `loop-claude` exits 1 when it cannot archive. - `loop-claude` exits 1 when it cannot delete a finished chunk's session, naming what to delete before rerunning; the next chunk would otherwise resume it. - `loop-claude` keeps the mode of `~/.claude.json` and of its models file when it rewrites them, and creates the models file 0600. diff --git a/bin/loop_claude/cycle/run.py b/bin/loop_claude/cycle/run.py index 5d972f07..195643d0 100644 --- a/bin/loop_claude/cycle/run.py +++ b/bin/loop_claude/cycle/run.py @@ -106,6 +106,6 @@ def close(cycle: Cycle, transcript_path: str, verdict: Finished | Unfinished) -> return Archived() -# A Markdown blockquote, so the evidence reads as one passage and ends where the next outcome starts. +# Blockquoted, so evidence holding blank lines still ends visibly where the next outcome starts. def quoted(passage: str) -> str: return "\n".join(f"> {line}" for line in passage.splitlines()) -- 2.52.0 From eb65cef4664339dfe78250b7975056ac97a02f36 Mon Sep 17 00:00:00 2001 From: Lilleman auf Larv Date: Sat, 3 Oct 2026 20:48:59 +0200 Subject: [PATCH 7/9] Answer stability round 2: nothing to change -- 2.52.0 From 3b5ddd145c2f1a0ac45706d55e6739b4f6a980e1 Mon Sep 17 00:00:00 2001 From: Lilleman auf Larv Date: Sat, 3 Oct 2026 20:48:59 +0200 Subject: [PATCH 8/9] Answer product-owner round 2: nothing to change -- 2.52.0 From 2e046a976fc0547084cfd95f9866e120ba6cad9d Mon Sep 17 00:00:00 2001 From: Lilleman auf Larv Date: Sat, 3 Oct 2026 20:49:22 +0200 Subject: [PATCH 9/9] Answer prose round 3: nothing to change -- 2.52.0