From 872ffd3f67e2352fa58d276a4bd36abf30db2d2d Mon Sep 17 00:00:00 2001 From: Lilleman auf Larv Date: Fri, 2 Oct 2026 17:22:00 +0200 Subject: [PATCH] Answer the prose review's third round, and file the human's two answers --- CHANGELOG.md | 2 +- bin/loop_claude/claude_code/session.py | 2 +- bin/loop_claude/cycle/run.py | 2 +- bin/loop_claude/loop/main.py | 8 ++++---- todo.md | 3 ++- 5 files changed, 9 insertions(+), 8 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f5a6a651..805952a2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -16,6 +16,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 `.verdict.md` beside it holding the verdict and why the loop stopped. The subagents' transcripts and the session's other files go in its `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 `.verdict.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` 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/claude_code/session.py b/bin/loop_claude/claude_code/session.py index 54d4c73f..a04ff067 100644 --- a/bin/loop_claude/claude_code/session.py +++ b/bin/loop_claude/claude_code/session.py @@ -35,7 +35,7 @@ def session_open(session: Session) -> bool: return transcript_file(session) is not None -# .jsonl, /subagents/, and from older Claude Code versions .superseded-1789290815002/ and .orphaned-*.jsonl +# .jsonl, /subagents/, and from older Claude Code versions .superseded-*/ and .orphaned-*.jsonl def session_files(transcript: str) -> list[str]: return sorted(glob.glob(glob.escape(transcript.removesuffix(".jsonl")) + "*")) diff --git a/bin/loop_claude/cycle/run.py b/bin/loop_claude/cycle/run.py index 2c1eb4cc..d889ec1f 100644 --- a/bin/loop_claude/cycle/run.py +++ b/bin/loop_claude/cycle/run.py @@ -45,7 +45,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 - # A failed archive exits 1 whatever stopped the loop; one that is the stop itself fails the same way again, so say it once. + # 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 diff --git a/bin/loop_claude/loop/main.py b/bin/loop_claude/loop/main.py index 32d88d4e..8939ed85 100644 --- a/bin/loop_claude/loop/main.py +++ b/bin/loop_claude/loop/main.py @@ -16,10 +16,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, .verdict.md -holds the verdict, and why the loop stopped when it did. Claude Code keeps a folder per session -beside its transcript, holding the subagents' transcripts among other files; it and every other file -named after the session 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, 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 +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/todo.md b/todo.md index 85017877..f6d2279c 100644 --- a/todo.md +++ b/todo.md @@ -2,7 +2,7 @@ ## 0.1.0 -- **Copy the transcript archive off the machine, or say in README how it is backed up.** It lives under `~/.claude`, which `.gitignore` keeps from the remote, so a lost disk loses every unattended run's record. Goal 2. +- **Copy the transcript archive off the machine, or say in README how it is backed up.** It lives under `~/.claude`, which `.gitignore` keeps from the remote, so a lost disk loses every unattended run's record. Back it up only to a destination private to me and encrypted at rest: the worker runs with permissions bypassed, so the archived tool results can hold credentials it read. Goals 2 and 3. - **Add a test that `.gitignore` keeps credentials, transcripts and memory files out.** `test_gitignore.py` checks only that every tracked file is allowlisted; a widened negation such as `!*.json` would un-ignore `.credentials.json`. Goal 3. - **Wait out a usage limit and retry however long it lasts, without counting it as a failed run.** Today a worker or judge that hits a usage limit fails three times a minute apart, and the loop exits 1, so an unattended loop dies at every limit. The transcript line Claude Code writes for it, marked `"error":"rate_limit"`, holds the reset time: `You've hit your session limit · resets 7:40pm (Europe/Stockholm)`. Sleep until 2 minutes past it. The judge runs without a transcript, so find what its JSON reply carries on a limit. Where no reset time can be read, retry every 10 minutes: a retry before the reset fails (https://platform.claude.com/docs/en/api/rate-limits), so polling sooner only spends requests. Print when the next try is due, and update `--help`'s exit 1. Goal 4. - **Name each chunk's archive folder by the chunk's start time, so `/` lists chunks in the order they ran.** Today the folder is the SHA-256 of the transcript's first timestamped line, which tells the human nothing; that line carries the start time. Drop the fallback to the first line, which every chunk of a project shares, and give the tests' fake transcripts ISO timestamps. Goal 2. @@ -58,6 +58,7 @@ - Show the judge's stderr when its `claude` exits 0; today `run_judge` drops it. - Find Claude Code's files under `CLAUDE_CONFIG_DIR` when it is set; today `paths_from` reads `~/.claude` alone, so every cycle exits 1 with "claude left no transcript". - Type `decode_handed` for `LoopRun`, its one caller's type, and drop the type variable `T`. +- **Allow stderr in `principles/logging.md` → "Infrastructure": OTLP, stdout or stderr.** A CLI keeps stdout for its output, as `loop-claude` does for the worker's stream; the rule's point is no log files. Goal 4.3. - **Sort `bin/`'s imports on their first binding, and say in `principles/technical-principles.md` → "Deterministic order" how case sorts and which groups Python has.** Today they sort by path, so moving a module reorders unchanged lines. The principle's "host packages" names no Python group. Goal 4.1. - **Clean up the rules, skills, agents, plan and decision log.** Goal 4.1. - `docs/decisions.md`: order the entries and the `AGENTS.md` index by one key.