diff --git a/bin/claude_code/transcript.py b/bin/claude_code/transcript.py index 42a9cc30..423e492f 100644 --- a/bin/claude_code/transcript.py +++ b/bin/claude_code/transcript.py @@ -17,7 +17,7 @@ class Typed(typing.NamedTuple): def read_transcript(path: str) -> list[Entry] | Failure: - """The entries of the transcript at path, or of its gzip where the archive compressed it.""" + """The entries of the transcript at path, or of its gzip where compress-archives gzipped it.""" try: return [entry for raw in io.BytesIO(read_stored(pathlib.Path(path))) if (entry := parse_entry(raw))] except OSError as failure: diff --git a/bin/review_replay/replay.py b/bin/review_replay/replay.py index be6e764a..230a0197 100644 --- a/bin/review_replay/replay.py +++ b/bin/review_replay/replay.py @@ -152,7 +152,7 @@ def copy_reports(found: Round, folder: pathlib.Path, reports: str) -> None: name = written.name.removesuffix(SUFFIX) if name == written.name: shutil.copy2(written, reports) - # compress-archives gzipped it. A plain file of the same name replaced it later, as it would have replaced the plain file, so only that one is copied, where its time falls before the round. + # A gzipped report. Where a plain report of the same name stands beside it, that one is newer and the gzip is skipped; the plain report is copied only if it was written before the round. elif not (folder / name).is_file(): (pathlib.Path(reports) / name).write_bytes(read_stored(folder / name)) diff --git a/bin/review_replay/test_review_replay.py b/bin/review_replay/test_review_replay.py index 665b525b..bf5b278d 100644 --- a/bin/review_replay/test_review_replay.py +++ b/bin/review_replay/test_review_replay.py @@ -366,7 +366,7 @@ class Main(unittest.TestCase): self.assertIn("claude-opus-5-5 at low effort found 0, 0%, and missed 1 such 🔴: it doesn't qualify.", out) def review_folder_with_round_1(self): - """The chunk's review folder, holding round 1's report, written the second the chunk began at 09:15; that round's own report, written after the replayed round began at 10:00, and a later pass's, written the second it began; and an earlier attempt's report, from before the chunk began.""" + """The chunk's review folder. The chunk began at 09:15 and the replayed round 2 at 10:00. It holds round 1's report, written at 09:15:00; round 2's report, written after 10:00; the prose pass's report, written at 10:00:00; and an earlier attempt's report, from before 09:15.""" folder = self.home / ".local" / "state" / "larv-review" / "code" / "proj-x" folder.mkdir(parents=True) (folder / "stability-round-1.md").write_text("round 1\n") diff --git a/bin/transcript_archive/__init__.py b/bin/transcript_archive/__init__.py index 9b07d9fb..84d3d245 100644 --- a/bin/transcript_archive/__init__.py +++ b/bin/transcript_archive/__init__.py @@ -22,7 +22,7 @@ - judge/ holds each judge run an outcome names on its `Judge run:` line: the prompt the judge read and claude's json reply, named by the hash of that content (judge_run.JudgeRun). judge-replay reads the prompt back. -compress-archives gzips each .jsonl 30 days after it was last written, as .jsonl.gz beside its plain name, +compress-archives gzips each .jsonl 30 days after it last changed, as .jsonl.gz beside its plain name, and every reader reads it by that name (text_files.compressed); a plain file beside its gzip is the newer. write.archive writes the layout, at every interrupt and as every cycle ends. read.py and the tools that diff --git a/bin/transcript_archive/write.py b/bin/transcript_archive/write.py index f5b735a6..683d857b 100644 --- a/bin/transcript_archive/write.py +++ b/bin/transcript_archive/write.py @@ -94,7 +94,7 @@ def files_under(folder: pathlib.Path) -> list[pathlib.Path]: # Claude Code rewrites some files whole, such as custom-title.json, so a copy is replaced only by a file that grew from it. -# A grown copy lands plain beside its gzip, which compress-archives then replaces losing nothing, since the gzip holds a prefix of it. +# A grown copy lands plain beside its gzip, which compress-archives then replaces without losing anything, since the gzip holds a prefix of it. def copy_for(copy: pathlib.Path, data: bytes) -> pathlib.Path | None: if not stored(copy): return copy diff --git a/docs/decisions.md b/docs/decisions.md index 2d013409..10fcc4cd 100644 --- a/docs/decisions.md +++ b/docs/decisions.md @@ -12,7 +12,7 @@ Each project principle states one rule that the decisions below apply; their ent # Decisions no project principle covers -- archives: loop-claude's archive and the review folders keep every file, and gzip each one 30 days after it was last written +- archives: gzip each transcript in loop-claude's archive and each file in the review folders 30 days after it last changed, keeping all of them - bin/: a test parametrizes its cases with `subTest`, since pytest's `parametrize` doesn't reach a unittest `TestCase` - bin/: the tools run on the host's Python, with no container, and so do their tests outside CI - bin/: the tools send no OTLP traces, logs or metrics, and loop-claude's archive holds the trace of each cycle @@ -59,19 +59,20 @@ Settling a call is the human's. The chunk that settles the calls cites, in `docs # Decisions -## archives: loop-claude's archive and the review folders keep every file, and gzip each one 30 days after it was last written +## archives: gzip each transcript in loop-claude's archive and each file in the review folders 30 days after it last changed, keeping all of them -2026-11-17, the worker of todo item 306. Serves goal 3, backing up the transcripts, and goal 1, whose measures read them: the routing figures, `reading-cost`, `score-outcomes` and both replays rest on the whole archive, so nothing is pruned. Measured on 2026-11-11, the archive held 6.3 GB and `~/.local/state/larv-review` 997 MB, both growing with every chunk. +2026-11-17, the worker of todo item 306. Serves goal 3, backing up the transcripts, and goal 1, whose measures read them: the routing figures, `reading-cost`, `score-outcomes` and both replays rest on the whole archive, so nothing is pruned. On 2026-11-17 the archive held 7.9 GB and `~/.local/state/larv-review` 1.1 GB, both growing with every chunk. -- **What.** `compress-archives`, run daily from the crontab line in `README.md` → "Install", gzips each file last written over 30 days ago, as `.gz` beside its plain name with the same times. In the archive it takes the transcripts, `*.jsonl`, which held 7.8 GB of its 7.9 GB on 2026-11-17; the outcomes files stay plain, since loop-claude appends to them every cycle. In the review folders it takes every file, since the probes' build output fills most of them. -- **Safely.** It writes the gzip, reads it back, and removes the plain file only once the gzip reads back the same bytes and the plain file is unchanged since it was read. At the first failure it stops and exits 1, keeping that file plain, as a failed archive stops loop-claude. -- **Readers.** Every tool reads a file by its plain name through `bin/text_files/compressed.py`, and a plain file beside its gzip wins, since it was written later. A session file that grows after its copy was compressed lands plain beside the gzip, which holds a prefix of it, so the next run's gzip loses nothing. A file rewritten whole in a review folder replaces what it held, as it did before. -- **Why gzip.** Python 3.14's `compression.zstd` needs a Python built with libzstd, and this machine's lacks `_zstd`; gzip is in every build (goal 2). On 400 archived transcripts older than 30 days it kept 23% of their 609 MB, at about 29 MB a second. +- **What.** `compress-archives`, run daily from the crontab line in `README.md` → "Install", gzips each file that last changed over 30 days ago. The gzip is `.gz`, beside the plain name, with the same times. In the archive it takes only the transcripts, `*.jsonl`, which held 7.8 GB of the 7.9 GB; the outcomes files stay plain, since loop-claude appends to them every cycle. In the review folders it takes every file, since the probes' build output fills most of them. +- **Last changed.** A file's age is the later of its mtime and its ctime. A copy or an unpacked archive keeps old mtimes, but its ctime is when it landed, so a tree a chunk or a replay unpacks today stays plain while they use it. +- **Safely.** It writes the gzip, reads it back, syncs it to disk, and only then removes the plain file. It removes it only where the gzip read back the same bytes and the plain file didn't change while it was compressed. At the first failure it stops and exits 1, keeping that file plain, as a failed archive stops loop-claude. +- **Readers.** The tools that read old files in either folder, the archive's readers and `review-replay`, read a file by its plain name through `bin/text_files/compressed.py`. A plain file beside its gzip wins, since it was written later. A session file that grows after its copy was compressed lands plain beside the gzip, which holds a prefix of it, so the next run's gzip doesn't lose anything. A report rewritten whole after it was gzipped also lands plain beside its gzip, and the next run's gzip replaces the older one, as rewriting the plain file replaced the older bytes before. +- **Why gzip.** Python 3.14's `compression.zstd` needs a Python built with libzstd, and this machine's lacks `_zstd`; gzip is in every build (goal 2). On 400 archived transcripts older than 30 days, gzip shrank their 609 MB to 23%, at about 29 MB a second. - **Why 30 days.** A chunk's files stop changing once it merges, and chunks run for hours or days. Since every reader reads both forms, the threshold sets only how long a file stays plain. - **Backup.** Both folders sit under `$HOME`, on the filesystem that holds `~/code` and `~/.claude` (ai-sandbox's `/dev/vda3` on 2026-11-17), so backing that volume up, as item 1 waits for, covers both. `README.md` → "Install" names them, since the review folders lie outside `~/.claude`. -- **One writer.** Each file keeps one writer: the plain file the tool that writes it, its gzip `compress-archives`. +- **One writer.** Project principle 3 holds: the tool that writes a plain file stays its only writer, and `compress-archives` is the only writer of its gzip. -Valid while every reader of the two folders reads through `text_files/compressed.py`. +Valid while every tool that reads old files in the two folders reads through `text_files/compressed.py`. ## bin/: a test parametrizes its cases with `subTest`, since pytest's `parametrize` doesn't reach a unittest `TestCase` @@ -199,7 +200,7 @@ Valid while claude takes `--session-id` and resumes by it, and the human runs lo ## loop-claude: the archive keeps the raw transcript and each judge run, and a failed archive stops the loop -2026-09-28, lilleman. Serves goals 1 and 3: saving each transcript locally is the first step of backing it up, and it shows afterwards what an unattended run did. A copy of the `.jsonl`, deduplicated by content hash, with its outcomes beside it; a rendering drops tool results, and a second-resolution stamp names two states within one second as one file. A failed archive exits 1, since a loop that loses its record silently fails the backup goal. The judge's runs are archived too, as `judge/.json` in the chunk's folder: the prompt it read and its json reply. Together they are its whole transcript, since it runs with no tools and one turn. A run is kept whole and deduplicated by hash, and the outcome of the verdict, interrupt or rejected reply it produced names it on a `Judge run:` line. Keeping it whole costs little: a prompt is at most `JUDGE_PROMPT_CHARS`, 400,000 characters. Measured 2026-11-17, the archive's 911 judge lines come to at most 0.36 GB of prompts, against 3.5 GB in its 1,211 transcript copies, the largest 23.4 MB. The judge is still priced from its `Judge cost:` line, which is claude's own total for the run, and the Spent block counts the live reply's tokens; the archived reply keeps its `usage` for a later reader, and nothing reads it back. `judge-replay` replays a verdict on its archived prompt where there is one. Valid while transcripts, and the judge's prompts, stay small enough to copy whole; `archives: loop-claude's archive and the review folders keep every file, and gzip each one 30 days after it was last written` keeps the copies small on disk. +2026-09-28, lilleman. Serves goals 1 and 3: saving each transcript locally is the first step of backing it up, and it shows afterwards what an unattended run did. A copy of the `.jsonl`, deduplicated by content hash, with its outcomes beside it; a rendering drops tool results, and a second-resolution stamp names two states within one second as one file. A failed archive exits 1, since a loop that loses its record silently fails the backup goal. The judge's runs are archived too, as `judge/.json` in the chunk's folder: the prompt it read and its json reply. Together they are its whole transcript, since it runs with no tools and one turn. A run is kept whole and deduplicated by hash, and the outcome of the verdict, interrupt or rejected reply it produced names it on a `Judge run:` line. Keeping it whole costs little: a prompt is at most `JUDGE_PROMPT_CHARS`, 400,000 characters. Measured 2026-11-17, the archive's 911 judge lines come to at most 0.36 GB of prompts, against 3.5 GB in its 1,211 transcript copies, the largest 23.4 MB. The judge is still priced from its `Judge cost:` line, which is claude's own total for the run, and the Spent block counts the live reply's tokens; the archived reply keeps its `usage` for a later reader, and nothing reads it back. `judge-replay` replays a verdict on its archived prompt where there is one. Valid while transcripts, and the judge's prompts, stay small enough to copy whole; `archives: gzip each transcript in loop-claude's archive and each file in the review folders 30 days after it last changed, keeping all of them` keeps the copies small on disk. ## loop-claude: each verdict records the claude-config release and commit that ran it, the raw tokens each thread spent by model and kind since the previous outcome that recorded a spend, and the human's typed answer the judge quotes as reversing a choice the worker took on its own recommendation diff --git a/skills/larv-review/SKILL.md b/skills/larv-review/SKILL.md index fa641660..1eff1474 100644 --- a/skills/larv-review/SKILL.md +++ b/skills/larv-review/SKILL.md @@ -65,7 +65,7 @@ Give a reviewer without Bash `git ls-files`'s output in its prompt, since some h `~/.claude/bin/larv-review` holds this section's mechanical rules: the chunk's review folder, the round count, the paired ruling's base and vote count, the scoring run's trigger; the history's format, its latest places and its count of how often seats agree; and the header of each reviewer's prompt. Run it in the chunk's worktree; `~/.claude/bin/larv-review --help` states each rule. On exit 1, repair what its message names and run it again; when you cannot, ask the user. -**Reports.** Run `~/.claude/bin/larv-review reviewer-header ` in the chunk's worktree, and open each prompt to an agent under `~/.claude/agents/` with what it prints; then say in a few lines what the change does and which files it touches. The command makes the chunk's review folder and writes the branch diff and the plan's listing into it. The header names that diff, the reviewer's full report, `-round-.md`, in the folder, the folders of technical principles and review standards the project's config sets, the listing, and for architecture and stability the places too. For a reviewer whose definition starts it without `CLAUDE.md`, the header's last line names the file that holds the project principles and decision titles, which the reviewer reads first. For a relaunch one rung up, add `--rerun`: the report becomes `-round--rerun.md`, and the header names the report that asked. Before you answer a 🔴 or 🟡, read its entry: Grep the report for the finding's place, with the lines after it, rather than Read the whole report. rule-hook refuses a reviewer's Edit and MultiEdit, and any Write outside `~/.local/state/larv-review/`. Keep the folder after the merge: `review-replay` replays a round from the reports its prompt names, and `compress-archives` gzips each file 30 days after it was last written. +**Reports.** Run `~/.claude/bin/larv-review reviewer-header ` in the chunk's worktree, and open each prompt to an agent under `~/.claude/agents/` with what it prints; then say in a few lines what the change does and which files it touches. The command makes the chunk's review folder and writes the branch diff and the plan's listing into it. The header names that diff, the reviewer's full report, `-round-.md`, in the folder, the folders of technical principles and review standards the project's config sets, the listing, and for architecture and stability the places too. For a reviewer whose definition starts it without `CLAUDE.md`, the header's last line names the file that holds the project principles and decision titles, which the reviewer reads first. For a relaunch one rung up, add `--rerun`: the report becomes `-round--rerun.md`, and the header names the report that asked. Before you answer a 🔴 or 🟡, read its entry: Grep the report for the finding's place, with the lines after it, rather than Read the whole report. rule-hook refuses a reviewer's Edit and MultiEdit, and any Write outside `~/.local/state/larv-review/`. Keep the folder after the merge: `review-replay` replays a round from the reports its prompt names, and `compress-archives` gzips each file 30 days after it last changed. **Precedent, then ask** — for the full scan: