From f2e239d111d9cb5d06a841c6522d6839da365f67 Mon Sep 17 00:00:00 2001 From: Lilleman auf Larv Date: Tue, 27 Oct 2026 00:13:08 +0100 Subject: [PATCH 01/14] Compact the worker's context above 200k tokens, from item 231's evaluation of context cost, and file items 235 and 236 --- AGENTS.md | 1 + CHANGELOG.md | 1 + CLAUDE.md | 4 ++++ bin/loop_claude/cycle/run.py | 6 +++--- bin/loop_claude/cycle/worker.py | 3 +++ bin/loop_claude/loop/main.py | 4 ++++ bin/loop_claude/test_loop_claude.py | 2 +- docs/decisions.md | 21 +++++++++++++++++++++ todo.md | 18 ++++++++++++++---- 9 files changed, 52 insertions(+), 8 deletions(-) diff --git a/AGENTS.md b/AGENTS.md index b09427d3..0b3970d9 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -15,6 +15,7 @@ Decisions live in `docs/decisions.md`: - loop-claude: every claude it starts bypasses permissions inside its sandbox - loop-claude: one session per project, its id derived from the checkout's path relative to `~/code`, or to `/` outside it - loop-claude: the archive keeps the raw transcript, and a failed archive stops the loop +- loop-claude: the worker's claude compacts its context above 200k tokens, and `CLAUDE.md` β†’ "Compact instructions" says what the summary keeps - machine load: a heavy command waits for one of the machine's heavy slots, one for every 4 CPUs, which every session shares, and loop-claude starts a worker only while at least a quarter of the machine's memory is available - machine load: every container a session starts has a memory limit and a swap limit as large as its work needs; rule-hook's `docker-run-memory` blocks a `docker run` or `docker create` without them outside run-heavy, under which a container that lacks them gets the slot's share of three quarters of the memory; and no daemon-wide cap limits all containers together - principles: about seven things per level, four or five where they act on each other, more where a reader finds them by name; crossing a limit asks for a grouping or a recorded reason diff --git a/CHANGELOG.md b/CHANGELOG.md index c6fbe3a3..94f346d8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,7 @@ ## Unreleased +- loop-claude's worker now compacts its context once it passes 200k tokens, handed as `CLAUDE_CODE_AUTO_COMPACT_WINDOW`; Claude Code compacted it at about 967k before. Since 2026-10-21, a worker's turns above 200k were 55% of what workers cost, and the chunks that compacted took no more review rounds per message than those that did not. `CLAUDE.md` has a new section, "Compact instructions", saying what the summary keeps. - On Linux, `run-heavy` now caps the memory of a container its command makes with `docker run` or `docker create`. A container that sets no limit gets a memory limit and a swap limit, both the slot's share: three quarters of the machine's memory, split across the heavy slots. A container that sets one of the two limits keeps it, and gets the other as large. This covers containers a project's own scripts start, which rule-hook can't see. A `docker compose` service, and a docker named by its full path, get no cap. rule-hook's `docker-run-memory` now lets a `docker run` under run-heavy pass. - rule-hook has a new rule, `docker-run-memory`. It blocks a `docker run` or `docker create` that lacks a memory limit or a swap limit, such as `--memory 4g --memory-swap 4g`, sized to what the work needs. `--memory-swap -1`, unlimited swap, counts as none. `CLAUDE.md` asks for the same limits on a container a script or a compose file starts, which rule-hook can't see. rule-hook's `run-heavy` rule also now reads docker's `--tlscacert`, `--tlscert`, `--tlskey` and buildx's `--builder` as options that take a value, and reads `docker container run` as a run: `docker --tlscacert ca.pem build .` was not blocked outside run-heavy before. - Reviewers now mark a πŸ”΄ or 🟑 `[misread]` where it arose because the implementer misread code that had already shipped. A round's commit title now counts the marked findings, as in `Answer stability round 1: 1 πŸ”΄, 2 🟑 (1 misread); …`, and rule-hook's `round-title-counts` blocks a round title without that count. `score-outcomes` shows the count on each finished item, and lists it after the medians for each chunk whose round titles carry it, newest first. A chunk whose round titles predate this change reads as unknown. diff --git a/CLAUDE.md b/CLAUDE.md index ac1b89b3..0d4e2af4 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -104,6 +104,10 @@ The rules only reviewers apply, for quality, comments, READMEs and prose, live i - **A list or threshold a consumer relies on is sourced.** Deny-lists, defaults, limits: follow a published standard or a widely deployed tool, and cite it in the decision recording the choice; where none exists, ask. Never assemble one from names that seem plausible. - When a page renders client-side and comes back empty/blocked, use the Playwright renderer at `~/code/playwright-for-agents/` β€” `./pw [options]` (see its README). Don't use claude-in-chrome for this. +## Compact instructions + +When you compact, keep in the summary: the task loop-claude gave and each `todo.md` item the chunk takes, with its L and E + I; the worktree, branch and PR; the rung loop-claude named for each review launch, rerun and escalated subagent; each review pass's rounds so far, each open πŸ”΄ and 🟑, and how the answered ones were answered; every question the human answered, with the answer; each escalation trigger that fired; and what remains before the chunk is finished. + ## Vocabulary - **chunk** β€” the unit of work, shipped as one PR; "Working loop" says what it holds. diff --git a/bin/loop_claude/cycle/run.py b/bin/loop_claude/cycle/run.py index cf65353b..d7b9ba77 100644 --- a/bin/loop_claude/cycle/run.py +++ b/bin/loop_claude/cycle/run.py @@ -5,6 +5,7 @@ import typing from loop_claude.cycle.states import Active, Archived, Closing, Ended, Event, HumanTalked, HumanTyped, Interrupting, Judging, QUOTED_ANSWERS_PER_CYCLE, Ruled, State, TalkChosen, Talking, transition, TypedAnswer, WorkerRan, Working from loop_claude.routing import after_ruling, judge_rung from transcript_archive.write import archive +from loop_claude.cycle.worker import AUTO_COMPACT_WINDOW, COMPACT_ABOVE, run_worker, worker_args from claude_code.session import delete_session, Session, session_open, transcript_file from loop_claude.effects import Effects from failure import Failure @@ -17,7 +18,6 @@ from loop_claude.cycle.interrupt import put_question, talk, Talk from claude_code.transcript import read_transcript from loop_claude.cycle.retry import retried from model_routing.route import Route -from loop_claude.cycle.worker import run_worker, worker_args from model_routing.ladder import Rung from loop_claude.escalation_mark import StepUp from loop_claude.stop import Stop @@ -116,8 +116,8 @@ def work(cycle: Cycle, answered: QuotedAnswer | TypedAnswer | None, step_up: Ste def worker_environment(cycle: Cycle) -> dict[str, str]: - """The rungs the worker's claude is handed, which rule-hook holds its review launches to.""" - return worker_rungs.environment(cycle.project, cycle.route) + """The rungs the worker's claude is handed, which rule-hook holds its review launches to, and the context size above which it compacts.""" + return {**worker_rungs.environment(cycle.project, cycle.route), AUTO_COMPACT_WINDOW: str(COMPACT_ABOVE)} def worker_start(cycle: Cycle, answered: QuotedAnswer | TypedAnswer | None, step_up: StepUp | None) -> list[str]: diff --git a/bin/loop_claude/cycle/worker.py b/bin/loop_claude/cycle/worker.py index 2a63b85f..8587ef38 100644 --- a/bin/loop_claude/cycle/worker.py +++ b/bin/loop_claude/cycle/worker.py @@ -12,6 +12,9 @@ from claude_code.session import Session PRINTED_TOOL_INPUT = 160 # Seconds between reads of the machine's memory while too little of it is available to start a worker. MEMORY_POLL = 60 +# The context size, in tokens, above which the worker's claude compacts, handed to it in this variable: docs/decisions.md β†’ `loop-claude: the worker's claude compacts its context above 200k tokens`. +AUTO_COMPACT_WINDOW = "CLAUDE_CODE_AUTO_COMPACT_WINDOW" +COMPACT_ABOVE = 200_000 def run_worker(root: str, args: list[str], env: dict[str, str], effects: Effects) -> Failure | Limited | None: diff --git a/bin/loop_claude/loop/main.py b/bin/loop_claude/loop/main.py index 909ed5ec..6bc6c9ea 100644 --- a/bin/loop_claude/loop/main.py +++ b/bin/loop_claude/loop/main.py @@ -47,6 +47,10 @@ time. The layout, and when a copy is replaced, are in bin/transcript_archive/__i Before each worker starts, loop-claude waits until at least a quarter of the machine's memory is available (bin/machine_load/memory.py). +Each worker's claude, and the session /talk opens, compacts its context once it passes 200k tokens, +handed as CLAUDE_CODE_AUTO_COMPACT_WINDOW (bin/loop_claude/cycle/worker.py), so a long chunk +re-reads less each turn; ~/.claude/CLAUDE.md β†’ "Compact instructions" says what the summary keeps. + Every claude loop-claude starts runs the project's model, saved per in ~/.claude/loop-claude-models.json and read each cycle, unless routing, below, puts the worker, the session /talk opens and the judge on another rung, a model at an effort. A project without an diff --git a/bin/loop_claude/test_loop_claude.py b/bin/loop_claude/test_loop_claude.py index e330fc82..c55a5bca 100644 --- a/bin/loop_claude/test_loop_claude.py +++ b/bin/loop_claude/test_loop_claude.py @@ -256,7 +256,7 @@ class Cycles(unittest.TestCase): fake = FakeEffects(streams=[Worker(self.paths.claude_code_transcripts.parent)], claude=[judged("finished")]) cycle = dataclasses.replace(self.cycle(fake), project=Rung("claude-opus-5-5", "medium"), route=Route(Rung("claude-haiku-5-5", "max"), 163, 1, 5)) self.assertEqual(run.run_cycle(cycle).verdict, Finished("working")) - self.assertEqual(fake.worker_environments, [{"LOOP_CLAUDE_PROJECT_RUNG": "claude-opus-5-5 at medium effort", "LOOP_CLAUDE_WORKER_RUNG": "claude-haiku-5-5 at max effort", "LOOP_CLAUDE_ESCAPE_AND_IMPACT": "5"}]) + self.assertEqual(fake.worker_environments, [{"LOOP_CLAUDE_PROJECT_RUNG": "claude-opus-5-5 at medium effort", "LOOP_CLAUDE_WORKER_RUNG": "claude-haiku-5-5 at max effort", "LOOP_CLAUDE_ESCAPE_AND_IMPACT": "5", "CLAUDE_CODE_AUTO_COMPACT_WINDOW": "200000"}]) def test_the_claude_an_interrupt_resumes_is_handed_the_same_rungs_as_the_worker(self): def answer(args): diff --git a/docs/decisions.md b/docs/decisions.md index b2b44cd7..ffba8260 100644 --- a/docs/decisions.md +++ b/docs/decisions.md @@ -72,6 +72,27 @@ The cap is 5, `bin/todo_table.py`'s `BUNDLE_MAX_R`, from the same chunks: by the 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. Valid while transcripts stay small enough to copy whole. +## loop-claude: the worker's claude compacts its context above 200k tokens, and `CLAUDE.md` β†’ "Compact instructions" says what the summary keeps + +2026-10-27, claude through todo item 231, awaiting lilleman's yes. Serves goal 1.4, under goal 1.1's counter-signal. Item 231 asked for the best means to lower what a chunk spends on context, in dollars, then hours, with no loss of quality. + +Measured from loop-claude's archive over the 90 chunks with messages after the routing figures' reset of 2026-10-21, at the list prices read on 2026-10-26 (Opus 5.5: $4 per million input tokens, $5 and $8 for 5-minute and 1-hour cache writes, $0.20 for cache reads, $20 for output; no model but Haiku 5.5 charges more above 200k): $1,215, which is 0.86 of what the chunks' `cost-state` entries sum to, since some chunks' subagent transcripts are not in the archive. Worker main threads cost $375 (31%): 1-hour cache writes $149, cache reads $153, output $74. Subagents cost $840: 5-minute cache writes $379, output $274, cache reads $187, with the principles auditors at $274 over 342 runs, the stability reviewers $179 and general-purpose subagents $192. A worker starts at 41k tokens of context and peaks at a median 167k, one in ten past 358k, the largest at 848k: Claude Code compacts a model with a native 1M window at about 967k. The worker's messages above 200k were 32% of its messages and 55% of its cost. + +Each option item 231 named, on those chunks: + +- Compaction. Compacting the worker above 200k saves $78 of the workers' $375, 6% of all spend, at 0.5 compactions per chunk; above 150k $75 at 1.0; above 300k $54 at 0.2. It also bounds at 200k the 36 re-writes of a whole context, up to 785k tokens, after a gap longer than the cache's hour or a change of rung, which cost $62. Compacting subagents above 150k costs more than it saves, since a compaction reads the context once more and writes a summary, and subagents are short. A 200k window through `CLAUDE_CODE_DISABLE_1M_CONTEXT` would compact at the same point and also narrow every interactive session. +- A fresh context for the review phase, handed 60k tokens of facts, saves $39, which compaction covers, and loop-claude would need a second session per chunk. +- Read with an offset and a limit, or Grep, in place of `cat`, `sed` and `head`: the worker's tool results were 13.2M characters, 65% of them Bash reads, but only 13% whole files; the rest were ranges. A character a worker reads costs about $8 per million tokens to write to the 1-hour cache and $0.20 per million at each later turn, so all the worker's reads cost about $45 and the whole-file ones about $6. A rule would change the tool, not how much is read. +- Code-intelligence tooling: the `LSP` tool, with a language server per language on PATH, replaces a grep and the reads of candidate files with one lookup. Its ceiling is the same $45, and each machine would need a server per language (goal 2). Not tried. +- What a reviewer reads: the auditors read the project whole by design. Of their πŸ”΄ and 🟑 findings since the reset, 47% named a file the chunk edited and 51% another file, so reading only the change would drop half of them; item 236 asks lilleman about that scope, and item 233 has one auditor read the project once per round. +- The base context: every thread starts with `~/.claude/CLAUDE.md` (19k characters), `~/.claude/AGENTS.md` (11k, this repo's decisions, which Claude Code loads as user instructions into every project's sessions; item 52), the project's `AGENTS.md`, and, for the worker and general-purpose subagents, the skill listing (18k) and the agent listing (12k). Subagents' first messages wrote $97 of it; trimming the listings would save about $20. + +Quality. 19 chunks compacted between 2026-10-10 and 2026-10-22, at 214k to 972k tokens, the windows Claude Code tuned then. Per 100 worker messages they took a median 3.6 review rounds past each pass's first against 4.0 for the 68 uncompacted chunks of 100 messages or more, and 13.9 πŸ”΄ and 🟑 findings against 16.6. 4 of 19 had an unfinished verdict against 3 of 68, each 8 to 10 hours after the compaction and followed by a finished verdict within minutes. Two summaries read whole kept the chunk's intent, files, errors and next step in 12k to 20k characters, and the worker resumed without re-reading. A compaction takes 51 to 83 seconds, under a minute per chunk at 0.5 each. + +The window is handed to the worker, and the session /talk opens, as `CLAUDE_CODE_AUTO_COMPACT_WINDOW` (`bin/loop_claude/cycle/worker.py`), not set in `settings.json`: the archive measured loop-claude's workers, and interactive sessions are lilleman's. Subagents inherit it, and at 200k almost none compacts. A probe on 2026-10-27 showed that a `Compact instructions` section in a CLAUDE.md shapes the summary: a session whose CLAUDE.md asked the summary to end with its secret word did. So `CLAUDE.md` β†’ "Compact instructions" names what a worker's summary keeps. Path-scoped rules leave the context at a compaction and return at the next matching read, and rule-hook holds each review launch to its rung whatever the summary keeps. Item 235 compares the first 20 chunks under the window with the 20 before. + +Valid while cache reads cost a twentieth of input and Claude Code's compaction keeps the worker's task. + ## machine load: a heavy command waits for one of the machine's heavy slots, one for every 4 CPUs, which every session shares, and loop-claude starts a worker only while at least a quarter of the machine's memory is available 2026-10-23, lilleman. Serves goal 1.5. On 2026-10-22 ai-sandbox, with 8 CPUs and 16 GiB, thrashed for hours: four to six loops ran mutation tests, full gates, `docker build`s and QEMU-booting e2e tests at once, and nothing told one loop how busy the machine was. lilleman chose both limits; no standard sets either, and GNU parallel's `--memfree`, which does the memory wait's job, has no default. A slot is a file lock, so a session that dies frees its slot. The memory wait reads `/proc/meminfo` only, and off Linux a worker starts at once. `bin/machine_load/` holds the slots and the memory share, `bin/run-heavy` takes a slot, `CLAUDE.md` β†’ "Working with the codebase" has every session use it, and loop-claude's worker waits for the share. rule-hook's rule `run-heavy` blocks a `docker build`, and a run of a mutation tool stability-reviewer names, outside run-heavy, whether direct or inside a container. No program can tell a gate script from a light one, so only `CLAUDE.md` asks a session to run a gate under run-heavy. Valid while one machine runs several loops at once. diff --git a/todo.md b/todo.md index ad25c17d..73dab6af 100644 --- a/todo.md +++ b/todo.md @@ -6,7 +6,7 @@ `Bar = 0.1` -`Next ID = 235` +`Next ID = 237` ## Items @@ -16,7 +16,9 @@ | 232 | 0.4.0 | 231 | | **Launch a round's review passes in one message, except a pass that must wait for another's findings, so a round lasts about as long as its slowest reviewers, not their sum.** | 3 | 2 | 3 | 6 | 3 | 1.5 by 6 | 5.8 | | 233 | 0.4.0 | 231 | | **Run one principles-auditor per round that checks the goals and every principles file that applies, in place of one auditor for each, so the principles pass reads the project once per round.** | 3 | 2 | 3 | 6 | 3 | 1.4 by 3, 1.5 by 2 | 4.9 | | 234 | 0.4.0 | 231 | | **Report the routing figures in dollars, cache reads included, from the cost each archived run records.** | 2 | 2 | 2 | 4 | 3 | 1.4 by 3 | 3.0 | +| 236 | 0.5.0 | | question | **Answer whether the principles audit keeps reading the whole project, or reads only the files the chunk changed and their callers, now that half of its πŸ”΄ and 🟑 findings name a file the chunk did not edit.** | 1 | 1 | 1 | 1 | 1 | 1.4 by 4 | 6.4 | | 226 | 0.5.0 | | question | **Answer whether rule-hook's `run-heavy` rule should also catch a mutation run or docker build behind `uv run`, `poetry run`, `python3 -m`, `sudo`, `docker image build` and `docker compose up --build`, or narrow the `machine load:` decision's wording.** | 2 | 2 | 3 | 5 | 3 | 1.2 by 2, 1.5 by 2 | 4.0 | +| 235 | 0.5.0 | | | **Compare review rounds past each pass's first, unfinished verdicts, πŸ”΄, 🟑 and misread findings, and dollars per chunk, for the first 20 chunks whose worker ran under the 200k compaction window against the 20 before them, and file an item where any rose.** | 1 | 2 | 1 | 2 | 2 | 1.1 by 2, 1.4 by 3 | 6.8 | | 59 | 0.5.0 | | | **Bound a run of unfinished verdicts on one chunk, so a worker and judge that disagree cannot cycle unattended without end.** | 2 | 1 | 3 | 4 | 3 | 1.4 by 6 | 6.0 | | 167 | 0.5.0 | | | **Refuse a `/security-review` or `/claude-security` Skill call below the project's rung, as rule-hook refuses such an Agent call.** | 3 | 2 | 3 | 6 | 2 | 1.1 by 4 | 5.6 | | 6 | 0.5.0 | | decision | **Move what `loop-claude` writes out of `~/.claude.json`, and ask the human about each write that must stay.** | 3 | 3 | 3 | 7 | 3 | 1.1 by 5 | 5.3 | @@ -96,7 +98,7 @@ Evaluate at least these options, ambitiously, measuring each one's cost, hours a - A fresh context for the review phase, handed only the chunk's facts and the reviewers' verdicts. - What a reviewer reads: the diff and the places it touches, in place of the whole project. -Judge quality by these figures per chunk, before and after: review rounds, unfinished verdicts, πŸ”΄ and 🟑 findings, and findings that a later change fixes. Replay archived rounds with `review-replay` where it applies. Record each choice where `~/.claude/CLAUDE.md` β†’ "Ask, don't guess" puts it, and file an item for each option worth doing later. +Judge quality by these figures per chunk, before and after: review rounds, unfinished verdicts, πŸ”΄ and 🟑 findings, and findings that a later change fixes. Replay archived rounds with `review-replay` where it applies. Record each choice where `~/.claude/CLAUDE.md` β†’ "Working loop", "Ask, don't guess" puts it, and file an item for each option worth doing later. Items 232, 233 and 234 wait for this item. Item 233 changes what a reviewer reads, which this item evaluates; items 232 and 234 wait on lilleman's call alone. @@ -106,16 +108,24 @@ Since 2026-10-21, all 1,372 Agent calls in workers' transcripts were one per mes ### 233. Run one principles-auditor per round that checks the goals and every principles file that applies, in place of one auditor for each, so the principles pass reads the project once per round. -Since 2026-10-21, 253 principles-auditor runs cost about $304, 16% of all, and each read the project anew. Today larv-review Β§3 β†’ "Principles" launches one auditor for the README's goals and code health, and one per file in `~/.claude/principles/` that applies. The merged auditor must find what the separate ones found: replay archived rounds with `review-replay`, and keep separate auditors where the merged one misses a πŸ”΄ or 🟑. Rename the report files, `principles--round-.md` today (Β§3 β†’ "Reports"), to one per round. +Since 2026-10-21, 342 principles-auditor runs cost $274 at list prices, 23% of all spend and 3.8 runs per chunk, and each read the project anew: $129 of 5-minute cache writes, $92 of output and $53 of cache reads. Today larv-review Β§3 β†’ "Principles" launches one auditor for the README's goals and code health, and one per file in `~/.claude/principles/` that applies. The merged auditor must find what the separate ones found: replay archived rounds with `review-replay`, and keep separate auditors where the merged one misses a πŸ”΄ or 🟑. Rename the report files, `principles--round-.md` today (Β§3 β†’ "Reports"), to one per round. ### 234. Report the routing figures in dollars, cache reads included, from the cost each archived run records. The routing figures count input, cache-written and output tokens, and leave out cache reads, which were 51% of the cost since 2026-10-21. So their tables rank the principles auditor above the worker, while in dollars the worker cost three times as much. Each archived worker transcript ends with a `cost-state` entry holding `totalCostUSD` and each model's cost, and each message's usage attributes the cost to a subagent type. The judge's runs record no cost in the archive: count them too, or say why not. The change touches `bin/routing_figures/measure.py`, which the comprehension seats found hard (item 139): make the places it touches easier to read. +### 236. Answer whether the principles audit keeps reading the whole project, or reads only the files the chunk changed and their callers, now that half of its πŸ”΄ and 🟑 findings name a file the chunk did not edit. + +Since 2026-10-21, 342 principles-auditor runs cost $274 at list prices, 23% of all spend, and 176 of their πŸ”΄ and 🟑 findings named a file: 83 a file the chunk edited, 90 another. `docs/decisions.md` β†’ `review: the principles audit runs on every chunk…` holds the whole-project audit valid while its findings are drift a chunk would otherwise merge, and calls a repeat a question on the audit's scope for the human. Reading only the changed files and their callers would cut most of the auditors' $129 of cache writes and drop the findings elsewhere, unless those repeat chunk after chunk: read a sample of the 90 before answering. Item 233 merges the auditors either way. + ### 226. Answer whether rule-hook's `run-heavy` rule should also catch a mutation run or docker build behind `uv run`, `poetry run`, `python3 -m`, `sudo`, `docker image build` and `docker compose up --build`, or narrow the `machine load:` decision's wording. Found by review of PR #370. Today `uv run mutmut run`, `poetry run mutmut run`, `python3 -m mutmut run`, `sudo docker build .`, `docker image build .` and `docker compose up --build` pass the rule, which `docs/decisions.md` β†’ `machine load: …` and `RULES["run-heavy"]` describe as blocking docker builds and mutation runs. The rule's own text says a gate script isn't checked since no program can tell it from a light one, so the human decides where the line sits. Say what the rule's "checked" text promises either way. Where the answer widens the rule, the change touches `heavy` in `bin/rule_hook/heavy_command.py`, which the comprehension seats found hard: make it easier to read. +### 235. Compare review rounds past each pass's first, unfinished verdicts, πŸ”΄, 🟑 and misread findings, and dollars per chunk, for the first 20 chunks whose worker ran under the 200k compaction window against the 20 before them, and file an item where any rose. + +`docs/decisions.md` β†’ `loop-claude: the worker's claude compacts its context above 200k tokens…` expects a saving of about 6% of all spend with no rise in these figures. Measure from loop-claude's archive as that decision did: rounds past each pass's first and the πŸ”΄, 🟑 and misread counts from the round commit titles, unfinished verdicts from the outcomes files, and dollars from each message's usage at list prices, cache reads included, which item 234 puts into the routing figures. A chunk ran under the window when its first worker started after that decision merged. + ### 59. Bound a run of unfinished verdicts on one chunk, so a worker and judge that disagree cannot cycle unattended without end. Raised by the product-owner review of PR #211. The resumed worker gets the judge's quote of the work remaining, but a worker that still thinks the chunk done can answer each cycle the same way, and each cycle costs a worker and a judge run (goal 1.4). @@ -386,7 +396,7 @@ The principles pass of PR #301 found that only `routed_by` in `bin/loop_claude/c ### 52. Record why this checkout lives in Claude Code's own directory, or move it out and link it in. -"One owner per value" and "Prefer the vendor-neutral option", in `principles/technical-principles.md`: git, Claude Code and loop-claude all write `~/.claude`, kept apart only by the `.gitignore` allowlist, and the repo's records live in a vendor directory. +"One owner per value" and "Prefer the vendor-neutral option", in `principles/technical-principles.md`: git, Claude Code and loop-claude all write `~/.claude`, kept apart only by the `.gitignore` allowlist, and the repo's records live in a vendor directory. Claude Code also loads `~/.claude/AGENTS.md`, this checkout's decision titles, as the user's instructions into every session of every project: 10.7k characters, about 2.7k tokens, in each of the 1,084 threads since 2026-10-21, about $25 of cache writes and reads at list prices, and a worker on another project reads this repo's decisions as if they held there. ### 170. Re-tune `WORKER_STEPS` and `REVIEW_STEPS` once 50 chunks have shipped under them, from how well L, E and I order their review rounds and πŸ”΄ findings. -- 2.52.0 From 14736e8e6e1f4aec9bd3764aecf29bb94b59deed Mon Sep 17 00:00:00 2001 From: Lilleman auf Larv Date: Tue, 27 Oct 2026 00:32:10 +0100 Subject: [PATCH 02/14] =?UTF-8?q?Answer=20principles=20round=201:=200=20?= =?UTF-8?q?=F0=9F=94=B4,=209=20=F0=9F=9F=A1=20(0=20misread);=20name=20the?= =?UTF-8?q?=20200k=20window's=20compaction=20point,=20read=20a=20compactio?= =?UTF-8?q?n=20summary=20as=20Claude=20Code's,=20remove=20item=20231,=20re?= =?UTF-8?q?fresh=20items=20234,=20235,=2052=20and=20102,=20file=20item=202?= =?UTF-8?q?37?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- AGENTS.md | 2 +- CHANGELOG.md | 2 +- CLAUDE.md | 2 +- bin/claude_code/entries.py | 3 +- bin/claude_code/test_claude_code.py | 1 + bin/loop_claude/cycle/run.py | 6 +-- bin/loop_claude/cycle/worker.py | 4 +- bin/loop_claude/loop/main.py | 7 +-- bin/loop_claude/test_loop_claude.py | 2 +- docs/decisions.md | 16 ++++--- todo.md | 66 ++++++++++------------------- 11 files changed, 48 insertions(+), 63 deletions(-) diff --git a/AGENTS.md b/AGENTS.md index 0b3970d9..aa6f454d 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -15,7 +15,7 @@ Decisions live in `docs/decisions.md`: - loop-claude: every claude it starts bypasses permissions inside its sandbox - loop-claude: one session per project, its id derived from the checkout's path relative to `~/code`, or to `/` outside it - loop-claude: the archive keeps the raw transcript, and a failed archive stops the loop -- loop-claude: the worker's claude compacts its context above 200k tokens, and `CLAUDE.md` β†’ "Compact instructions" says what the summary keeps +- loop-claude: the worker's claude compacts its context before it fills a 200k window, at about 170k tokens, and `CLAUDE.md` β†’ "Compact instructions" says what the summary keeps - machine load: a heavy command waits for one of the machine's heavy slots, one for every 4 CPUs, which every session shares, and loop-claude starts a worker only while at least a quarter of the machine's memory is available - machine load: every container a session starts has a memory limit and a swap limit as large as its work needs; rule-hook's `docker-run-memory` blocks a `docker run` or `docker create` without them outside run-heavy, under which a container that lacks them gets the slot's share of three quarters of the memory; and no daemon-wide cap limits all containers together - principles: about seven things per level, four or five where they act on each other, more where a reader finds them by name; crossing a limit asks for a grouping or a recorded reason diff --git a/CHANGELOG.md b/CHANGELOG.md index 94f346d8..ce5f87b3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,7 +2,7 @@ ## Unreleased -- loop-claude's worker now compacts its context once it passes 200k tokens, handed as `CLAUDE_CODE_AUTO_COMPACT_WINDOW`; Claude Code compacted it at about 967k before. Since 2026-10-21, a worker's turns above 200k were 55% of what workers cost, and the chunks that compacted took no more review rounds per message than those that did not. `CLAUDE.md` has a new section, "Compact instructions", saying what the summary keeps. +- loop-claude's worker now runs with a 200k auto-compact window, handed as `CLAUDE_CODE_AUTO_COMPACT_WINDOW`, so Claude Code compacts its context at about 170k tokens; before, at about 967k. Since 2026-10-21, a worker's turns above 200k were 55% of what workers cost. The 19 chunks that compacted before took no more review rounds or findings per message than those that did not, but 4 of them had an unfinished verdict against 3 of 68; `todo.md` item 235 measures the first 20 chunks under the window. loop-claude's judge no longer reads a compaction summary as words the human typed. `CLAUDE.md` has a new section, "Compact instructions", saying what the summary keeps. - On Linux, `run-heavy` now caps the memory of a container its command makes with `docker run` or `docker create`. A container that sets no limit gets a memory limit and a swap limit, both the slot's share: three quarters of the machine's memory, split across the heavy slots. A container that sets one of the two limits keeps it, and gets the other as large. This covers containers a project's own scripts start, which rule-hook can't see. A `docker compose` service, and a docker named by its full path, get no cap. rule-hook's `docker-run-memory` now lets a `docker run` under run-heavy pass. - rule-hook has a new rule, `docker-run-memory`. It blocks a `docker run` or `docker create` that lacks a memory limit or a swap limit, such as `--memory 4g --memory-swap 4g`, sized to what the work needs. `--memory-swap -1`, unlimited swap, counts as none. `CLAUDE.md` asks for the same limits on a container a script or a compose file starts, which rule-hook can't see. rule-hook's `run-heavy` rule also now reads docker's `--tlscacert`, `--tlscert`, `--tlskey` and buildx's `--builder` as options that take a value, and reads `docker container run` as a run: `docker --tlscacert ca.pem build .` was not blocked outside run-heavy before. - Reviewers now mark a πŸ”΄ or 🟑 `[misread]` where it arose because the implementer misread code that had already shipped. A round's commit title now counts the marked findings, as in `Answer stability round 1: 1 πŸ”΄, 2 🟑 (1 misread); …`, and rule-hook's `round-title-counts` blocks a round title without that count. `score-outcomes` shows the count on each finished item, and lists it after the medians for each chunk whose round titles carry it, newest first. A chunk whose round titles predate this change reads as unknown. diff --git a/CLAUDE.md b/CLAUDE.md index 0d4e2af4..d8453073 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -106,7 +106,7 @@ The rules only reviewers apply, for quality, comments, READMEs and prose, live i ## Compact instructions -When you compact, keep in the summary: the task loop-claude gave and each `todo.md` item the chunk takes, with its L and E + I; the worktree, branch and PR; the rung loop-claude named for each review launch, rerun and escalated subagent; each review pass's rounds so far, each open πŸ”΄ and 🟑, and how the answered ones were answered; every question the human answered, with the answer; each escalation trigger that fired; and what remains before the chunk is finished. +Claude Code reads this section by its heading when it compacts a conversation. When you compact, keep in the summary: the task loop-claude gave and each `todo.md` item the chunk takes, with its L and E + I; the worktree, branch and PR; the rung loop-claude named for each review launch, rerun and escalated subagent; each review pass's rounds so far, each open πŸ”΄ and 🟑, and how the answered ones were answered; every question the human answered, with the answer; each escalation trigger that fired; and what remains before the chunk is finished. ## Vocabulary diff --git a/bin/claude_code/entries.py b/bin/claude_code/entries.py index bea76c7a..7bbfee5c 100644 --- a/bin/claude_code/entries.py +++ b/bin/claude_code/entries.py @@ -36,8 +36,9 @@ def written_by_human(entry: dict) -> bool: # {"type": "user", "isMeta": true, "message": {"content": "Caveat: ..."}} # {"type": "user", "promptSource": "sdk", "message": {"content": "Continue the task; ..."}} # {"type": "user", "promptSource": "system", "message": {"content": "..."}} +# {"type": "user", "isCompactSummary": true, "message": {"content": "This session is being continued from a previous conversation that ran out of context. ..."}} def tagged_as_injected(entry: dict) -> bool: - return bool(entry.get("isMeta")) or entry.get("promptSource") in ("sdk", "system") + return bool(entry.get("isMeta")) or bool(entry.get("isCompactSummary")) or entry.get("promptSource") in ("sdk", "system") # {"type": "user", "promptSource": "typed", "message": {"content": "merge it"}} diff --git a/bin/claude_code/test_claude_code.py b/bin/claude_code/test_claude_code.py index 9ba7db64..ebc8537d 100644 --- a/bin/claude_code/test_claude_code.py +++ b/bin/claude_code/test_claude_code.py @@ -66,6 +66,7 @@ class HumanTurns(unittest.TestCase): {**human([{"type": "text", "text": "done"}]), "promptSource": "system"}, {**human("peer message"), "isMeta": True}, {**human("the loop's own prompt"), "promptSource": "sdk"}, + {**human("This session is being continued from a previous conversation that ran out of context. The summary below covers the earlier portion of the conversation."), "isCompactSummary": True}, human([{"type": "text", "text": "[Request interrupted by user]"}]), human([]), queued("typed while claude worked", "human"), diff --git a/bin/loop_claude/cycle/run.py b/bin/loop_claude/cycle/run.py index d7b9ba77..2020178b 100644 --- a/bin/loop_claude/cycle/run.py +++ b/bin/loop_claude/cycle/run.py @@ -5,7 +5,7 @@ import typing from loop_claude.cycle.states import Active, Archived, Closing, Ended, Event, HumanTalked, HumanTyped, Interrupting, Judging, QUOTED_ANSWERS_PER_CYCLE, Ruled, State, TalkChosen, Talking, transition, TypedAnswer, WorkerRan, Working from loop_claude.routing import after_ruling, judge_rung from transcript_archive.write import archive -from loop_claude.cycle.worker import AUTO_COMPACT_WINDOW, COMPACT_ABOVE, run_worker, worker_args +from loop_claude.cycle.worker import AUTO_COMPACT_WINDOW, COMPACT_WINDOW, run_worker, worker_args from claude_code.session import delete_session, Session, session_open, transcript_file from loop_claude.effects import Effects from failure import Failure @@ -116,8 +116,8 @@ def work(cycle: Cycle, answered: QuotedAnswer | TypedAnswer | None, step_up: Ste def worker_environment(cycle: Cycle) -> dict[str, str]: - """The rungs the worker's claude is handed, which rule-hook holds its review launches to, and the context size above which it compacts.""" - return {**worker_rungs.environment(cycle.project, cycle.route), AUTO_COMPACT_WINDOW: str(COMPACT_ABOVE)} + """The rungs the worker's claude is handed, which rule-hook holds its review launches to, and the auto-compact window of its context.""" + return {**worker_rungs.environment(cycle.project, cycle.route), AUTO_COMPACT_WINDOW: str(COMPACT_WINDOW)} def worker_start(cycle: Cycle, answered: QuotedAnswer | TypedAnswer | None, step_up: StepUp | None) -> list[str]: diff --git a/bin/loop_claude/cycle/worker.py b/bin/loop_claude/cycle/worker.py index 8587ef38..728a80df 100644 --- a/bin/loop_claude/cycle/worker.py +++ b/bin/loop_claude/cycle/worker.py @@ -12,9 +12,9 @@ from claude_code.session import Session PRINTED_TOOL_INPUT = 160 # Seconds between reads of the machine's memory while too little of it is available to start a worker. MEMORY_POLL = 60 -# The context size, in tokens, above which the worker's claude compacts, handed to it in this variable: docs/decisions.md β†’ `loop-claude: the worker's claude compacts its context above 200k tokens`. +# The auto-compact window, in tokens, handed to the worker's claude in this variable. Claude Code compacts before the window fills, at about 170k: docs/decisions.md β†’ `loop-claude: the worker's claude compacts its context before it fills a 200k window`. AUTO_COMPACT_WINDOW = "CLAUDE_CODE_AUTO_COMPACT_WINDOW" -COMPACT_ABOVE = 200_000 +COMPACT_WINDOW = 200_000 def run_worker(root: str, args: list[str], env: dict[str, str], effects: Effects) -> Failure | Limited | None: diff --git a/bin/loop_claude/loop/main.py b/bin/loop_claude/loop/main.py index 6bc6c9ea..c9997b93 100644 --- a/bin/loop_claude/loop/main.py +++ b/bin/loop_claude/loop/main.py @@ -47,9 +47,10 @@ time. The layout, and when a copy is replaced, are in bin/transcript_archive/__i Before each worker starts, loop-claude waits until at least a quarter of the machine's memory is available (bin/machine_load/memory.py). -Each worker's claude, and the session /talk opens, compacts its context once it passes 200k tokens, -handed as CLAUDE_CODE_AUTO_COMPACT_WINDOW (bin/loop_claude/cycle/worker.py), so a long chunk -re-reads less each turn; ~/.claude/CLAUDE.md β†’ "Compact instructions" says what the summary keeps. +Each worker's claude, and the session /talk opens, runs with a 200k auto-compact window, handed as +CLAUDE_CODE_AUTO_COMPACT_WINDOW (bin/loop_claude/cycle/worker.py), so it compacts its context at +about 170k tokens and a long chunk re-reads less each turn. +~/.claude/CLAUDE.md β†’ "Compact instructions" says what the summary keeps. Every claude loop-claude starts runs the project's model, saved per in ~/.claude/loop-claude-models.json and read each cycle, unless routing, below, puts the worker, diff --git a/bin/loop_claude/test_loop_claude.py b/bin/loop_claude/test_loop_claude.py index c55a5bca..3e536840 100644 --- a/bin/loop_claude/test_loop_claude.py +++ b/bin/loop_claude/test_loop_claude.py @@ -252,7 +252,7 @@ class Cycles(unittest.TestCase): self.assertIn("- A preflight fact.", fresh) self.assertNotIn("- A preflight fact.", resumed) - def test_a_worker_is_handed_the_projects_rung_its_own_and_its_reviews_e_plus_i_in_its_environment(self): + def test_a_worker_is_handed_the_projects_rung_its_own_its_reviews_e_plus_i_and_its_compaction_window_in_its_environment(self): fake = FakeEffects(streams=[Worker(self.paths.claude_code_transcripts.parent)], claude=[judged("finished")]) cycle = dataclasses.replace(self.cycle(fake), project=Rung("claude-opus-5-5", "medium"), route=Route(Rung("claude-haiku-5-5", "max"), 163, 1, 5)) self.assertEqual(run.run_cycle(cycle).verdict, Finished("working")) diff --git a/docs/decisions.md b/docs/decisions.md index ffba8260..15716777 100644 --- a/docs/decisions.md +++ b/docs/decisions.md @@ -72,24 +72,26 @@ The cap is 5, `bin/todo_table.py`'s `BUNDLE_MAX_R`, from the same chunks: by the 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. Valid while transcripts stay small enough to copy whole. -## loop-claude: the worker's claude compacts its context above 200k tokens, and `CLAUDE.md` β†’ "Compact instructions" says what the summary keeps +## loop-claude: the worker's claude compacts its context before it fills a 200k window, at about 170k tokens, and `CLAUDE.md` β†’ "Compact instructions" says what the summary keeps -2026-10-27, claude through todo item 231, awaiting lilleman's yes. Serves goal 1.4, under goal 1.1's counter-signal. Item 231 asked for the best means to lower what a chunk spends on context, in dollars, then hours, with no loss of quality. +2026-10-27, claude through todo item 231, awaiting lilleman's yes before the merge. Serves goal 1.4, under goal 1.1's counter-signal. Item 231 asked for the best means to lower what a chunk spends on context, in dollars, then hours, with no loss of quality. Measured from loop-claude's archive over the 90 chunks with messages after the routing figures' reset of 2026-10-21, at the list prices read on 2026-10-26 (Opus 5.5: $4 per million input tokens, $5 and $8 for 5-minute and 1-hour cache writes, $0.20 for cache reads, $20 for output; no model but Haiku 5.5 charges more above 200k): $1,215, which is 0.86 of what the chunks' `cost-state` entries sum to, since some chunks' subagent transcripts are not in the archive. Worker main threads cost $375 (31%): 1-hour cache writes $149, cache reads $153, output $74. Subagents cost $840: 5-minute cache writes $379, output $274, cache reads $187, with the principles auditors at $274 over 342 runs, the stability reviewers $179 and general-purpose subagents $192. A worker starts at 41k tokens of context and peaks at a median 167k, one in ten past 358k, the largest at 848k: Claude Code compacts a model with a native 1M window at about 967k. The worker's messages above 200k were 32% of its messages and 55% of its cost. Each option item 231 named, on those chunks: -- Compaction. Compacting the worker above 200k saves $78 of the workers' $375, 6% of all spend, at 0.5 compactions per chunk; above 150k $75 at 1.0; above 300k $54 at 0.2. It also bounds at 200k the 36 re-writes of a whole context, up to 785k tokens, after a gap longer than the cache's hour or a change of rung, which cost $62. Compacting subagents above 150k costs more than it saves, since a compaction reads the context once more and writes a summary, and subagents are short. A 200k window through `CLAUDE_CODE_DISABLE_1M_CONTEXT` would compact at the same point and also narrow every interactive session. +- Compaction. Compacting the worker at 167k to 180k saves $77 to $78 of the workers' $375, 6% of all spend, at 0.7 to 0.8 compactions per chunk; at 150k $75 at 1.0, at 200k $78 at 0.5, at 300k $54 at 0.2. It also caps the 36 re-writes of a whole context after a gap longer than the cache's hour or a change of rung, $61 at up to 785k tokens each, at about $34. Compacting subagents at 150k costs more than it saves, since a compaction reads the context once more and writes a summary, and subagents are short. A 200k window through `CLAUDE_CODE_DISABLE_1M_CONTEXT` would compact at the same point and also narrow every interactive session. - A fresh context for the review phase, handed 60k tokens of facts, saves $39, which compaction covers, and loop-claude would need a second session per chunk. - Read with an offset and a limit, or Grep, in place of `cat`, `sed` and `head`: the worker's tool results were 13.2M characters, 65% of them Bash reads, but only 13% whole files; the rest were ranges. A character a worker reads costs about $8 per million tokens to write to the 1-hour cache and $0.20 per million at each later turn, so all the worker's reads cost about $45 and the whole-file ones about $6. A rule would change the tool, not how much is read. -- Code-intelligence tooling: the `LSP` tool, with a language server per language on PATH, replaces a grep and the reads of candidate files with one lookup. Its ceiling is the same $45, and each machine would need a server per language (goal 2). Not tried. +- Code-intelligence tooling: the `LSP` tool, with a language server per language on PATH, replaces a grep and the reads of candidate files with one lookup. Its ceiling is the same $45, and each machine would need a server per language (goal 2). Not tried, and not worth an item while the worker's reads stay under 4% of spend. - What a reviewer reads: the auditors read the project whole by design. Of their πŸ”΄ and 🟑 findings since the reset, 47% named a file the chunk edited and 51% another file, so reading only the change would drop half of them; item 236 asks lilleman about that scope, and item 233 has one auditor read the project once per round. -- The base context: every thread starts with `~/.claude/CLAUDE.md` (19k characters), `~/.claude/AGENTS.md` (11k, this repo's decisions, which Claude Code loads as user instructions into every project's sessions; item 52), the project's `AGENTS.md`, and, for the worker and general-purpose subagents, the skill listing (18k) and the agent listing (12k). Subagents' first messages wrote $97 of it; trimming the listings would save about $20. +- The base context: every thread starts with `~/.claude/CLAUDE.md` (19k characters), `~/.claude/AGENTS.md` (11k, this repo's decisions, which Claude Code loads as user instructions into every project's sessions; item 52), the project's `AGENTS.md`, and, for the worker and general-purpose subagents, the skill listing (18k) and the agent listing (12k). Subagents' first messages wrote $97 of it; trimming the listings would save about $20, 2%, and is not worth an item: `disableBundledSkills` would also drop `/security-review`, the security pass of record. -Quality. 19 chunks compacted between 2026-10-10 and 2026-10-22, at 214k to 972k tokens, the windows Claude Code tuned then. Per 100 worker messages they took a median 3.6 review rounds past each pass's first against 4.0 for the 68 uncompacted chunks of 100 messages or more, and 13.9 πŸ”΄ and 🟑 findings against 16.6. 4 of 19 had an unfinished verdict against 3 of 68, each 8 to 10 hours after the compaction and followed by a finished verdict within minutes. Two summaries read whole kept the chunk's intent, files, errors and next step in 12k to 20k characters, and the worker resumed without re-reading. A compaction takes 51 to 83 seconds, under a minute per chunk at 0.5 each. +Quality. 19 chunks compacted between 2026-10-10 and 2026-10-22, at 214k to 972k tokens, the windows Claude Code tuned then. Per 100 worker messages they took a median 3.6 review rounds past each pass's first against 4.0 for the 68 uncompacted chunks of 100 messages or more, and 13.9 πŸ”΄ and 🟑 findings against 16.6. 4 of 19 had an unfinished verdict against 3 of 68, each 8 to 10 hours after the compaction and followed by a finished verdict within minutes; the judge quoted the worker's own passages and the human's typed answers in them, never a summary. One cause was possible and is closed here: Claude Code writes the summary as a user entry, which `bin/claude_code/entries.py` read as the human's words, so the judge would see a `[human]` line of thousands of words and `/talk` would count it as typed; it now reads as Claude Code's. Whether compaction raises unfinished verdicts stays open until item 235 measures it. Two summaries read whole kept the chunk's intent, files, errors and next step in 12k to 20k characters, and the worker resumed without re-reading. -The window is handed to the worker, and the session /talk opens, as `CLAUDE_CODE_AUTO_COMPACT_WINDOW` (`bin/loop_claude/cycle/worker.py`), not set in `settings.json`: the archive measured loop-claude's workers, and interactive sessions are lilleman's. Subagents inherit it, and at 200k almost none compacts. A probe on 2026-10-27 showed that a `Compact instructions` section in a CLAUDE.md shapes the summary: a session whose CLAUDE.md asked the summary to end with its secret word did. So `CLAUDE.md` β†’ "Compact instructions" names what a worker's summary keeps. Path-scoped rules leave the context at a compaction and return at the next matching read, and rule-hook holds each review launch to its rung whatever the summary keeps. Item 235 compares the first 20 chunks under the window with the 20 before. +Hours. A chunk ran a median 0.7 hours from its first message to its last, one in ten past 12 hours, mostly waiting for the human or a usage limit. No option here changes that: a compaction takes 51 to 83 seconds, under a minute per chunk at 0.7 each, and a smaller context makes a turn no faster to notice. The hours lever is item 232, since waiting on subagents took 66% of a worker's active time. + +The window is handed to the worker, and the session /talk opens, as `CLAUDE_CODE_AUTO_COMPACT_WINDOW=200000` (`bin/loop_claude/cycle/worker.py`), not set in `settings.json`: the archive measured loop-claude's workers, and interactive sessions are lilleman's. Claude Code compacts before a window fills: a 1M window at about 967k, and in a probe on 2026-10-27 a 100k window at 65k and 80k, so a 200k window compacts at about 170k. Subagents inherit it, and at 170k few compact. Another probe that day showed that a `Compact instructions` section in a CLAUDE.md shapes the summary: a session whose CLAUDE.md asked the summary to end with its secret word did. So `CLAUDE.md` β†’ "Compact instructions" names what a worker's summary keeps. Path-scoped rules leave the context at a compaction and return at the next matching read, and rule-hook holds each review launch to its rung whatever the summary keeps. Item 235 compares the first 20 chunks under the window with the 20 before. Valid while cache reads cost a twentieth of input and Claude Code's compaction keeps the worker's task. diff --git a/todo.md b/todo.md index 73dab6af..a761d7a2 100644 --- a/todo.md +++ b/todo.md @@ -6,19 +6,18 @@ `Bar = 0.1` -`Next ID = 237` +`Next ID = 238` ## Items | ID | Release | Blocked by | Exempt | Item | L | E | I | R | S | Moves | Score | |---|---|---|---|---|---|---|---|---|---|---|---| -| 231 | 0.4.0 | | owner | **Lower what each chunk spends on context in dollars, then its hours, by the best means an ambitious evaluation finds, such as tooling that pinpoints what an agent reads and fresh or compacted contexts, with no loss of quality.** | 4 | 2 | 3 | 7 | 8 | 1.4 by 8, 1.5 by 4 | 0.7 | -| 232 | 0.4.0 | 231 | | **Launch a round's review passes in one message, except a pass that must wait for another's findings, so a round lasts about as long as its slowest reviewers, not their sum.** | 3 | 2 | 3 | 6 | 3 | 1.5 by 6 | 5.8 | -| 233 | 0.4.0 | 231 | | **Run one principles-auditor per round that checks the goals and every principles file that applies, in place of one auditor for each, so the principles pass reads the project once per round.** | 3 | 2 | 3 | 6 | 3 | 1.4 by 3, 1.5 by 2 | 4.9 | -| 234 | 0.4.0 | 231 | | **Report the routing figures in dollars, cache reads included, from the cost each archived run records.** | 2 | 2 | 2 | 4 | 3 | 1.4 by 3 | 3.0 | +| 232 | 0.4.0 | | | **Launch a round's review passes in one message, except a pass that must wait for another's findings, so a round lasts about as long as its slowest reviewers, not their sum.** | 3 | 2 | 3 | 6 | 3 | 1.5 by 6 | 5.8 | +| 233 | 0.4.0 | | | **Run one principles-auditor per round that checks the goals and every principles file that applies, in place of one auditor for each, so the principles pass reads the project once per round.** | 3 | 2 | 3 | 6 | 3 | 1.4 by 3, 1.5 by 2 | 4.9 | +| 234 | 0.4.0 | | | **Report the routing figures in dollars, cache reads included, from the cost each archived run records.** | 2 | 2 | 2 | 4 | 3 | 1.4 by 3 | 3.0 | | 236 | 0.5.0 | | question | **Answer whether the principles audit keeps reading the whole project, or reads only the files the chunk changed and their callers, now that half of its πŸ”΄ and 🟑 findings name a file the chunk did not edit.** | 1 | 1 | 1 | 1 | 1 | 1.4 by 4 | 6.4 | | 226 | 0.5.0 | | question | **Answer whether rule-hook's `run-heavy` rule should also catch a mutation run or docker build behind `uv run`, `poetry run`, `python3 -m`, `sudo`, `docker image build` and `docker compose up --build`, or narrow the `machine load:` decision's wording.** | 2 | 2 | 3 | 5 | 3 | 1.2 by 2, 1.5 by 2 | 4.0 | -| 235 | 0.5.0 | | | **Compare review rounds past each pass's first, unfinished verdicts, πŸ”΄, 🟑 and misread findings, and dollars per chunk, for the first 20 chunks whose worker ran under the 200k compaction window against the 20 before them, and file an item where any rose.** | 1 | 2 | 1 | 2 | 2 | 1.1 by 2, 1.4 by 3 | 6.8 | +| 235 | 0.5.0 | | | **Compare review rounds past each pass's first, unfinished verdicts, πŸ”΄, 🟑 and misread findings, dollars and hours per chunk, for the first 20 chunks whose worker ran under the 200k compaction window against the 20 before them, and file an item where any rose.** | 1 | 2 | 1 | 2 | 2 | 1.1 by 2, 1.4 by 3 | 6.8 | | 59 | 0.5.0 | | | **Bound a run of unfinished verdicts on one chunk, so a worker and judge that disagree cannot cycle unattended without end.** | 2 | 1 | 3 | 4 | 3 | 1.4 by 6 | 6.0 | | 167 | 0.5.0 | | | **Refuse a `/security-review` or `/claude-security` Skill call below the project's rung, as rule-hook refuses such an Agent call.** | 3 | 2 | 3 | 6 | 2 | 1.1 by 4 | 5.6 | | 6 | 0.5.0 | | decision | **Move what `loop-claude` writes out of `~/.claude.json`, and ask the human about each write that must stay.** | 3 | 3 | 3 | 7 | 3 | 1.1 by 5 | 5.3 | @@ -30,6 +29,7 @@ | 139 | 0.6.0 | | | **Split `bin/routing_figures/measure.py` by concern, and keep the figures' measured cycle and each raised call as fields loop-claude reads back, not as the prose it renders.** | 3 | 1 | 2 | 4 | 5 | code health by 5, 1.4 by 5 | 11.0 | | 158 | 0.6.0 | | decision | **Measure the fixed cost of a chunk from loop-claude's archive, in tokens and hours against its items' S, and set F in `Score = 100 * V / (2**S + F)` to it.** | 2 | 2 | 1 | 3 | 3 | 1.1 by 5, 1.4 by 5 | 10.3 | | 215 | 0.6.0 | | | **Decode a reload's handed JSON with a decoder for `LoopRun` and its `Route`, in place of `decoded_as`'s generic one with its two sentinels and `Route.fits` hook.** | 2 | 1 | 3 | 4 | 3 | code health by 2 | 9.0 | +| 237 | 0.6.0 | | principle | **Give `judge` and `judge_once` in `bin/loop_claude/cycle/judge.py` a record of the inputs they share, in place of nine and eight parameters, or record why they stay.** | 2 | 1 | 2 | 3 | 3 | code health by 2 | 9.0 | | 49 | 0.6.0 | | principle | **Check that `AGENTS.md` lists exactly the titles of `docs/decisions.md`.** | 1 | 1 | 1 | 1 | 2 | 1.1 by 6 | 8.4 | | 105 | 0.6.0 | | decision | **Compare review rounds per pass and reading cost for the five chunks before and after the `worker:` decision moved the principles out of the worker's context, and file an item if either rose.** | 1 | 2 | 1 | 2 | 2 | 1.4 by 6 | 8.0 | | 162 | 0.6.0 | | owner | **Script each step that 0.2.0's chunks repeated by hand and a program can compute, filing one item per step, and file this audit again for the next release.** | 2 | 2 | 1 | 3 | 3 | 1.4 by 4, 1.5 by 4 | 7.8 | @@ -43,11 +43,11 @@ | 112 | 0.6.0 | | | **Count an item as shipped only where its chunk built it, so an item a chunk dropped from the plan gets no outcome.** | 3 | 2 | 2 | 5 | 3 | 1.1 by 6 | 6.3 | | 124 | 0.6.0 | | decision | **Group the shared modules at `bin/`'s root into packages named by purpose, so the root holds only launchers and stand-alone tools.** | 4 | 1 | 3 | 6 | 6 | code health by 5, 1.4 by 3 | 5.7 | | 81 | 0.6.0 | | principle | **Have `workflow-bench/bench.py` return each run's failure as a value, so one failed clone does not hide the later runs' results.** | 1 | 2 | 1 | 2 | 2 | 1.1 by 4 | 5.6 | -| 102 | 0.6.0 | | | **Give loop-claude's retry delay an environment override, so the black-box test stops replacing `time.sleep` through `sitecustomize`.** | 1 | 1 | 2 | 2 | 2 | 1.1 by 4 | 5.6 | | 173 | 0.6.0 | | | **Have rule-hook's `todo-rank-check` run a worktree's own `bin/rank_todo.py` when the worktree is of this repo, so a branch that changes `todo.md`'s shape commits without an override.** | 2 | 1 | 3 | 4 | 2 | 1.1 by 2, 1.4 by 2 | 5.5 | | 101 | 0.6.0 | | principle | **Have `larv_review/history_commands.py`'s `read_seats` take the time, the commit check and the history as inputs, so it parses and decides without effects.** | 2 | 1 | 2 | 3 | 3 | 1.1 by 5 | 5.3 | | 110 | 0.6.0 | | decision | **Count, for each finished chunk, the later changes that fixed code it wrote, and show them beside its guessed E.** | 3 | 2 | 2 | 5 | 5 | 1.1 by 6, 1.4 by 6 | 4.9 | | 12 | 0.6.0 | | | **Run the test suite in CI on every PR, or record in `docs/decisions.md` why the local run is enough.** | 3 | 2 | 1 | 4 | 4 | 1.1 by 6 | 4.2 | +| 102 | 0.6.0 | | | **Give loop-claude's retry delay and its memory read environment overrides, so the black-box test stops replacing `time.sleep` and `machine_load.memory.MEMINFO` through `sitecustomize`.** | 1 | 1 | 2 | 2 | 3 | 1.1 by 4 | 4.2 | | 135 | 0.6.0 | | | **Fingerprint only the modules loop-claude imports, so editing another tool's code no longer reloads a running loop.** | 2 | 2 | 3 | 5 | 3 | 1.1 by 4 | 4.2 | | 171 | 0.6.0 | | decision | **Group the routing figures' review rounds by the reviewers' rung as well as the worker's, so a call blames a rung only for rounds its own reviews raised.** | 3 | 2 | 2 | 5 | 4 | 1.2 by 3, 1.4 by 3 | 4.0 | | 196 | 0.6.0 | | decision | **Replay the architecture, principles, overrides and product-owner passes with `review-replay` on Opus 5.5 projects, record each run in the review-replay routing decision, and add any rung a run qualifies to `REPLAYED`.** | 2 | 2 | 3 | 5 | 2 | 1.4 by 3 | 4.0 | @@ -71,37 +71,13 @@ | 51 | 0.6.0 | | principle | **Hand loop-claude's terminal output to an injected effect, so no storage or retry function prints.** | 2 | 1 | 3 | 4 | 5 | 1.1 by 5 | 2.1 | | 169 | 0.6.0 | | | **Have rule-hook's `todo-rank-check` catch a `todo.md` that the same Bash call edits and then commits.** | 3 | 1 | 3 | 5 | 3 | 1.1 by 2 | 2.1 | | 174 | 0.6.0 | | | **In a chunk no item routed, ask the worker to name each todo.md item it takes, with its L and E + I, so loop-claude can route on an item it takes in.** | 1 | 2 | 3 | 4 | 1 | 1.1 by 1 | 1.7 | +| 52 | 0.6.0 | | principle | **Move this checkout out of Claude Code's own directory, or record why it stays, since Claude Code loads its `AGENTS.md` as the user's instructions into every project's sessions.** | 4 | 3 | 4 | 9 | 6 | 1.1 by 4, 1.4 by 2 | 1.4 | | 197 | 0.6.0 | | | **Let the human edit what they type at loop-claude's terminal questions with the arrow keys, so Left moves the cursor in place of printing `^[[D`.** | 2 | 2 | 3 | 5 | 2 | 1.5 by 1 | 1.3 | -| 52 | 0.6.0 | | principle | **Record why this checkout lives in Claude Code's own directory, or move it out and link it in.** | 4 | 3 | 4 | 9 | 6 | 1.1 by 4 | 0.9 | | 170 | 0.7.0 | | decision | **Re-tune `WORKER_STEPS` and `REVIEW_STEPS` once 50 chunks have shipped under them, from how well L, E and I order their review rounds and πŸ”΄ findings.** | 2 | 2 | 3 | 5 | 2 | 1.1 by 3, 1.4 by 5 | 10.9 | | 218 | 0.7.0 | 170 | | **Drop `LEGACY_WORKER` from `bin/model_routing/route.py`, so `route_from` reads only JSON worker lines.** | 1 | 2 | 1 | 2 | 1 | code health by 2 | 14.4 | ## Details -### 231. Lower what each chunk spends on context in dollars, then its hours, by the best means an ambitious evaluation finds, such as tooling that pinpoints what an agent reads and fresh or compacted contexts, with no loss of quality. - -lilleman's call, 2026-10-26: this is the plan's most important item, and it goes first. It runs on Fable 5.1 at max. An L of 4 routes the worker at most to Opus 5.5 at high, so the worker hands the evaluation and every edit to one subagent launched with `model fable, effort max`. The priorities, in order: context cost, then speed, and never at a loss of quality. Where the effect on quality is hard to tell, or very close, ask lilleman. - -Measured on 2026-10-26 from loop-claude's archive, over the 104 worker runs and about 720 subagent runs since the routing figures' last reset on 2026-10-21, priced at list prices: - -- The runs cost about $1,940, and cache reads, the context each turn reads again, are $985 of it. The routing figures leave cache reads out (item 234). -- Worker main threads are 53% of the cost. A worker starts at about 40k tokens of context and peaks at a median 189k, one in ten past 490k, the largest at 850k. Its turns above 200k are 64% of what workers cost. -- Bash output is 70% of the tool output a worker reads, most of it `cat`, `sed` and `head` of whole files. Principles auditors read 24M characters of files, each auditor reading the project anew. - -loop-claude starts each chunk in a fresh session, which lilleman meant to keep context small (`docs/decisions.md` β†’ `loop-claude: one session per project`). The context grows within a chunk, so that decision doesn't block any option below. - -Evaluate at least these options, ambitiously, measuring each one's cost, hours and quality on comparable chunks: - -- Code-structure tooling in place of Bash reads: Claude Code's LSP tool, a code-intelligence MCP server, a symbol or outline lookup. -- Tools that pinpoint lines, such as Read with an offset and a limit and Grep with context, in place of `cat`, `sed` and `head` of whole files, with a rule or hook that steers agents to those tools. -- Compaction: Claude Code's auto-compact at a lower threshold, or a smaller context window. -- A fresh context for the review phase, handed only the chunk's facts and the reviewers' verdicts. -- What a reviewer reads: the diff and the places it touches, in place of the whole project. - -Judge quality by these figures per chunk, before and after: review rounds, unfinished verdicts, πŸ”΄ and 🟑 findings, and findings that a later change fixes. Replay archived rounds with `review-replay` where it applies. Record each choice where `~/.claude/CLAUDE.md` β†’ "Working loop", "Ask, don't guess" puts it, and file an item for each option worth doing later. - -Items 232, 233 and 234 wait for this item. Item 233 changes what a reviewer reads, which this item evaluates; items 232 and 234 wait on lilleman's call alone. - ### 232. Launch a round's review passes in one message, except a pass that must wait for another's findings, so a round lasts about as long as its slowest reviewers, not their sum. Since 2026-10-21, all 1,372 Agent calls in workers' transcripts were one per message, 94% of them in the foreground, and waiting on subagents took 66% of a worker's active time. larv-review Β§3 orders the passes so no polish goes into code the architect restructures or the security pass rewrites. Keep that: a pass waits only for a pass whose findings could make its review a waste. Launch the rest of the round's passes, the principles auditors among them, in one message. Do the same for the passes a fix reruns, per Β§3 β†’ "Re-entry". @@ -112,7 +88,7 @@ Since 2026-10-21, 342 principles-auditor runs cost $274 at list prices, 23% of a ### 234. Report the routing figures in dollars, cache reads included, from the cost each archived run records. -The routing figures count input, cache-written and output tokens, and leave out cache reads, which were 51% of the cost since 2026-10-21. So their tables rank the principles auditor above the worker, while in dollars the worker cost three times as much. Each archived worker transcript ends with a `cost-state` entry holding `totalCostUSD` and each model's cost, and each message's usage attributes the cost to a subagent type. The judge's runs record no cost in the archive: count them too, or say why not. The change touches `bin/routing_figures/measure.py`, which the comprehension seats found hard (item 139): make the places it touches easier to read. +The routing figures count input, cache-written and output tokens, and leave out cache reads, which were 28% of the cost since 2026-10-21, $340 of $1,215 at list prices. So their tables rank the principles auditor above the worker, while in dollars the worker cost 1.4 times as much, $375 against $274. Each archived worker transcript ends with a `cost-state` entry holding `totalCostUSD` and each model's cost, and each message's usage attributes the cost to a subagent type. The judge's runs record no cost in the archive: count them too, or say why not. The change touches `bin/routing_figures/measure.py`, which the comprehension seats found hard (item 139): make the places it touches easier to read. ### 236. Answer whether the principles audit keeps reading the whole project, or reads only the files the chunk changed and their callers, now that half of its πŸ”΄ and 🟑 findings name a file the chunk did not edit. @@ -122,9 +98,9 @@ Since 2026-10-21, 342 principles-auditor runs cost $274 at list prices, 23% of a Found by review of PR #370. Today `uv run mutmut run`, `poetry run mutmut run`, `python3 -m mutmut run`, `sudo docker build .`, `docker image build .` and `docker compose up --build` pass the rule, which `docs/decisions.md` β†’ `machine load: …` and `RULES["run-heavy"]` describe as blocking docker builds and mutation runs. The rule's own text says a gate script isn't checked since no program can tell it from a light one, so the human decides where the line sits. Say what the rule's "checked" text promises either way. Where the answer widens the rule, the change touches `heavy` in `bin/rule_hook/heavy_command.py`, which the comprehension seats found hard: make it easier to read. -### 235. Compare review rounds past each pass's first, unfinished verdicts, πŸ”΄, 🟑 and misread findings, and dollars per chunk, for the first 20 chunks whose worker ran under the 200k compaction window against the 20 before them, and file an item where any rose. +### 235. Compare review rounds past each pass's first, unfinished verdicts, πŸ”΄, 🟑 and misread findings, dollars and hours per chunk, for the first 20 chunks whose worker ran under the 200k compaction window against the 20 before them, and file an item where any rose. -`docs/decisions.md` β†’ `loop-claude: the worker's claude compacts its context above 200k tokens…` expects a saving of about 6% of all spend with no rise in these figures. Measure from loop-claude's archive as that decision did: rounds past each pass's first and the πŸ”΄, 🟑 and misread counts from the round commit titles, unfinished verdicts from the outcomes files, and dollars from each message's usage at list prices, cache reads included, which item 234 puts into the routing figures. A chunk ran under the window when its first worker started after that decision merged. +`docs/decisions.md` β†’ `loop-claude: the worker's claude compacts its context before it fills a 200k window…` expects a saving of about 6% of all spend with no rise in the other figures. Measure from loop-claude's archive as that decision did: rounds past each pass's first and the πŸ”΄, 🟑 and misread counts from the round commit titles, unfinished verdicts from the outcomes files, hours from the worker's first message to its last, and dollars at list prices, cache reads included, from the chunk's `cost-state` entry, which counts the compaction calls that no message's usage records; item 234 puts such dollars into the routing figures. A chunk ran under the window when its first worker started after that decision merged. ### 59. Bound a run of unfinished verdicts on one chunk, so a worker and judge that disagree cannot cycle unattended without end. @@ -174,6 +150,10 @@ F is 8 until then, about one S 3 change, lilleman's call in PR #283. A chunk cos Release 0.3.0's Mid A (PR #324 at c713910) named `bin/loop_claude/loop/reload.py:43` `decoded_as`: "a generic decoder with two sentinels and a duck-typed fits hook defined on Route". This lowers Shape: `decoded_as` is generic over any type, yet `decode_handed` calls it with one dataclass, `LoopRun`. Keep what it does today: a field added since the running script started may be missing, and a handed dataclass holding a field its `RETIRED` names decodes as None where its type allows None, and is rejected otherwise. Make `decoded_as` easier to read. +### 237. Give `judge` and `judge_once` in `bin/loop_claude/cycle/judge.py` a record of the inputs they share, in place of nine and eight parameters, or record why they stay. + +Found by the principles audit of PR #376. "About seven things per level" in `principles/technical-principles.md`: `judge` takes nine parameters and `judge_once` eight, past the four or five for things that act on each other, with no recorded reason. Both take root, task, premises, records, entries, escalated_at, rung and effects, which one record could carry. + ### 49. Check that `AGENTS.md` lists exactly the titles of `docs/decisions.md`. DRY, in `principles/technical-principles.md`: the list is copied by hand, and sessions work from the copy. @@ -238,10 +218,6 @@ Shape scored 6.25 in PR #257's run. `bin/` held about 30 entries then: 6 launche "Errors as values", in `principles/technical-principles.md`, raised by the principles audit of PR #224: `bench.py` raises `KeyError` and `CalledProcessError`, and `pool.map` re-raises the first while the other threads run on unreported. -### 102. Give loop-claude's retry delay an environment override, so the black-box test stops replacing `time.sleep` through `sitecustomize`. - -Found by the principles audit of PR #242. `bin/loop_claude/test_black_box.py:113-114` swaps the global `time.sleep`, the shape "Functional core, imperative shell" bans. An override of the delay lets the test run the code as production runs it. - ### 173. Have rule-hook's `todo-rank-check` run a worktree's own `bin/rank_todo.py` when the worktree is of this repo, so a branch that changes `todo.md`'s shape commits without an override. Raised by the overrides pass of PR #296. The hook imports the main checkout's `rank_todo.py`, so while a branch of this repo changes the table's shape, every commit touching `todo.md` needs a `todo-rank-check` override: 33 log lines across four branches, the score-outcomes, plan-136, plan-148 and item-146 ones. The hook then checks nothing, and the rule rests on the worker chaining the branch's own check. Run another repo's `bin/rank_todo.py` never: that would run its code before every commit. @@ -260,6 +236,10 @@ The repo has no CI, so larv-review's gate is the local run, and larv-review's Ga When CI runs a rule check, such as one of `bin/rule-hook`'s, let `` in the PR body override it. +### 102. Give loop-claude's retry delay and its memory read environment overrides, so the black-box test stops replacing `time.sleep` and `machine_load.memory.MEMINFO` through `sitecustomize`. + +Found by the principles audit of PR #242. `bin/loop_claude/test_black_box.py:113-114` swaps the global `time.sleep`, the shape "Functional core, imperative shell" bans, and the audit of PR #376 found the same block swapping `machine_load.memory.MEMINFO` at lines 119-123. An override of each lets the test run the code as production runs it. + ### 135. Fingerprint only the modules loop-claude imports, so editing another tool's code no longer reloads a running loop. The maintainability senior and the inherited architect of PR #257's scoring run named `bin/loop_claude/loop/reload.py:38` `fingerprint` and `:50` `exec_if_edited`: the fingerprint covers every `bin/**/*.py`, so editing `statusline.py` or `rank_todo.py` re-execs a running loop. Make `fingerprint` easier to read. @@ -390,14 +370,14 @@ The hook judges a call before it runs, and `changed` in `bin/rule_hook/todo_chec The principles pass of PR #301 found that only `routed_by` in `bin/loop_claude/cycle/prompts.py` asks the worker to name each item it takes with its L and E + I, and `fresh` uses it only where an item routed the chunk. In an unrouted chunk the judge has no levels to report, so neither the taken-in L nor the taken-in E + I lifts the worker or the judge. +### 52. Move this checkout out of Claude Code's own directory, or record why it stays, since Claude Code loads its `AGENTS.md` as the user's instructions into every project's sessions. + +"One owner per value" and "Prefer the vendor-neutral option", in `principles/technical-principles.md`: git, Claude Code and loop-claude all write `~/.claude`, kept apart only by the `.gitignore` allowlist, and the repo's records live in a vendor directory. Claude Code also loads `~/.claude/AGENTS.md`, this checkout's decision titles, as the user's instructions into every session of every project: 10.7k characters, about 2.7k tokens, in each of the 1,084 threads since 2026-10-21, about $25 of cache writes and reads at list prices, and a worker on another project reads this repo's decisions as if they held there. + ### 197. Let the human edit what they type at loop-claude's terminal questions with the arrow keys, so Left moves the cursor in place of printing `^[[D`. `bin/loop_claude/effects.py` hands loop-claude Python's builtin `input`, and nothing under `bin/` imports `readline`, so the terminal gets no line editing: fixing a typo means erasing back to it. `effects.input` reads the answer to both of loop-claude's questions: the interrupt, in `cycle/interrupt.py`'s `put_question`, and the pick of the project's model, in `project/model_choice.py`'s `ask_for_model`. Importing `readline` in `effects.py` gives both line editing, at two costs. It moves the prompt from stderr to stdout, while the question above it stays on stderr. `test_black_box.py` waits for the prompt on stderr. `readline`'s bracketed paste takes a pasted block whole, so an answer can hold several lines. `prompts.typed_answer` ends the answer at its first blank line, so the judge would read the rest of such a paste as loop-claude's words. The product-owner review of PR #308 raised the interrupt's case. lilleman, 2026-10-18: "Not super-important, but a bit irritating." -### 52. Record why this checkout lives in Claude Code's own directory, or move it out and link it in. - -"One owner per value" and "Prefer the vendor-neutral option", in `principles/technical-principles.md`: git, Claude Code and loop-claude all write `~/.claude`, kept apart only by the `.gitignore` allowlist, and the repo's records live in a vendor directory. Claude Code also loads `~/.claude/AGENTS.md`, this checkout's decision titles, as the user's instructions into every session of every project: 10.7k characters, about 2.7k tokens, in each of the 1,084 threads since 2026-10-21, about $25 of cache writes and reads at list prices, and a worker on another project reads this repo's decisions as if they held there. - ### 170. Re-tune `WORKER_STEPS` and `REVIEW_STEPS` once 50 chunks have shipped under them, from how well L, E and I order their review rounds and πŸ”΄ findings. `docs/decisions.md` β†’ `routing: one ladder…` calls the steps a first guess. Start this item once 50 chunks have merged since PR #339 set today's steps, each shipping one item scored with L, E and I. By 2026-10-23, 15 had: those of items 117, 126, 122, 207, 130, 154, 186, 66, 121, 213, 137, 212, 214, 210 and 216. Then read `score-outcomes`' rank correlations for L, E and I and the routed-chunks table of `routing-figures.md`, and propose new steps to lilleman, whose call they are. -- 2.52.0 From 23fbf853d88c93b47d3bc4aeb69dc58941eb89bd Mon Sep 17 00:00:00 2001 From: Lilleman auf Larv Date: Tue, 27 Oct 2026 00:35:37 +0100 Subject: [PATCH 03/14] =?UTF-8?q?Answer=20principles=20round=202:=200=20?= =?UTF-8?q?=F0=9F=94=B4,=200=20=F0=9F=9F=A1=20(0=20misread)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit -- 2.52.0 From 78837aabc6adf31329f42a257366f9209d4132ef Mon Sep 17 00:00:00 2001 From: Lilleman auf Larv Date: Tue, 27 Oct 2026 00:38:12 +0100 Subject: [PATCH 04/14] =?UTF-8?q?Answer=20security=20round=201:=200=20?= =?UTF-8?q?=F0=9F=94=B4,=200=20=F0=9F=9F=A1=20(0=20misread);=20file=20item?= =?UTF-8?q?=20238,=20since=20the=20skill=20scans=20nothing=20when=20a=20su?= =?UTF-8?q?bagent=20runs=20it=20outside=20the=20worktree?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- todo.md | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/todo.md b/todo.md index a761d7a2..b5d9992d 100644 --- a/todo.md +++ b/todo.md @@ -6,7 +6,7 @@ `Bar = 0.1` -`Next ID = 238` +`Next ID = 239` ## Items @@ -21,6 +21,7 @@ | 59 | 0.5.0 | | | **Bound a run of unfinished verdicts on one chunk, so a worker and judge that disagree cannot cycle unattended without end.** | 2 | 1 | 3 | 4 | 3 | 1.4 by 6 | 6.0 | | 167 | 0.5.0 | | | **Refuse a `/security-review` or `/claude-security` Skill call below the project's rung, as rule-hook refuses such an Agent call.** | 3 | 2 | 3 | 6 | 2 | 1.1 by 4 | 5.6 | | 6 | 0.5.0 | | decision | **Move what `loop-claude` writes out of `~/.claude.json`, and ask the human about each write that must stay.** | 3 | 3 | 3 | 7 | 3 | 1.1 by 5 | 5.3 | +| 238 | 0.5.0 | | defect | **Run the security pass's skill in the chunk's worktree, so it scans the branch's diff: invoked from a subagent, it runs in the session's working directory, the main checkout, and scans nothing.** | 2 | 2 | 3 | 5 | 3 | 1.1 by 5 | 5.3 | | 1 | 0.6.0 | | question | **Say in README β†’ Install how the transcript archive is backed up, once bender-infra backs up ai-sandbox's data volume.** | 1 | 2 | 1 | 2 | 1 | | 0.0 | | 229 | 0.6.0 | | | **Keep the rule for which commands reach run-heavy's docker beside that docker in `bin/run_heavy/capped_docker.py`, so rule-hook's `docker-run-memory` asks it instead of repeating run-heavy's PATH rules.** | 2 | 1 | 3 | 4 | 2 | code health by 3 | 18.0 | | 219 | 0.6.0 | | | **Name the project's rung `project` in `bin/judge_replay/main.py`, `bin/subagent_rung/main.py` and `bin/review_replay/main.py`, in place of `anchor`, as `bin/model_routing/ladder.py` and `bin/loop_claude` name it.** | 1 | 1 | 3 | 3 | 2 | code health by 2 | 12.0 | @@ -114,6 +115,10 @@ rule-hook checks Agent calls (item 163) but no Skill calls. A worker that invoke Claude Code owns that file and writes it. `trust` reads it, changes it and writes it back, so a write that lands in between is lost. +### 238. Run the security pass's skill in the chunk's worktree, so it scans the branch's diff: invoked from a subagent, it runs in the session's working directory, the main checkout, and scans nothing. + +Found while reviewing PR #376. larv-review Β§3 β†’ "Security" launches a general-purpose subagent that invokes `/security-review` through the Skill tool. The skill runs its git commands in the session's working directory, the checkout root, where the branch's diff is empty, and the subagent then reads the worktree's diff itself, which the skill's own text forbids as a substitute. The archived security subagents of items 198 and 223 and of this chunk all report it. Until it is fixed, run `claude -p /security-review` with the worktree as its working directory, on the project's rung, as PR #376 did. A fix may run the skill as a process in the worktree from larv-review, or have the worker enter the worktree with Claude Code's `EnterWorktree` tool so every subagent runs there. + ### 1. Say in README β†’ Install how the transcript archive is backed up, once bender-infra backs up ai-sandbox's data volume. 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. -- 2.52.0 From 56b9077e4c3b3c76a88712b76a1ebb25a65b7a19 Mon Sep 17 00:00:00 2001 From: Lilleman auf Larv Date: Tue, 27 Oct 2026 00:45:38 +0100 Subject: [PATCH 05/14] =?UTF-8?q?Answer=20stability=20round=201:=200=20?= =?UTF-8?q?=F0=9F=94=B4,=202=20=F0=9F=9F=A1=20(0=20misread);=20cut=20the?= =?UTF-8?q?=20help=20paragraph=20to=20one=20sentence=20and=20tie=20its=202?= =?UTF-8?q?00k=20to=20COMPACT=5FWINDOW?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- bin/loop_claude/loop/main.py | 7 +++---- bin/loop_claude/test_loop_claude.py | 1 + 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/bin/loop_claude/loop/main.py b/bin/loop_claude/loop/main.py index c9997b93..3b3c2bf1 100644 --- a/bin/loop_claude/loop/main.py +++ b/bin/loop_claude/loop/main.py @@ -47,10 +47,9 @@ time. The layout, and when a copy is replaced, are in bin/transcript_archive/__i Before each worker starts, loop-claude waits until at least a quarter of the machine's memory is available (bin/machine_load/memory.py). -Each worker's claude, and the session /talk opens, runs with a 200k auto-compact window, handed as -CLAUDE_CODE_AUTO_COMPACT_WINDOW (bin/loop_claude/cycle/worker.py), so it compacts its context at -about 170k tokens and a long chunk re-reads less each turn. -~/.claude/CLAUDE.md β†’ "Compact instructions" says what the summary keeps. +Each worker's claude, and the session /talk opens, runs with a 200k auto-compact window +(CLAUDE_CODE_AUTO_COMPACT_WINDOW, bin/loop_claude/cycle/worker.py), so it compacts its context at +about 170k tokens. Every claude loop-claude starts runs the project's model, saved per in ~/.claude/loop-claude-models.json and read each cycle, unless routing, below, puts the worker, diff --git a/bin/loop_claude/test_loop_claude.py b/bin/loop_claude/test_loop_claude.py index 3e536840..40b7a64c 100644 --- a/bin/loop_claude/test_loop_claude.py +++ b/bin/loop_claude/test_loop_claude.py @@ -1516,6 +1516,7 @@ class HelpLimits(unittest.TestCase): self.assertIn(f"retried {retry.PAST_RESET // 60} minutes after the limit resets, or every {retry.UNKNOWN_RESET_POLL // 60} minutes", said) self.assertIn(f"still running after {PYTHON_TIMEOUT} s", said) self.assertIn(f"Once {measure.CYCLES_PER_CHECK} cycles have closed across all projects", said) + self.assertIn(f"runs with a {worker.COMPACT_WINDOW // 1000}k auto-compact window", said) class ExitContract(unittest.TestCase): -- 2.52.0 From 9abc5f4781d583874484abb2d730f2cd091636bf Mon Sep 17 00:00:00 2001 From: Lilleman auf Larv Date: Tue, 27 Oct 2026 00:46:53 +0100 Subject: [PATCH 06/14] =?UTF-8?q?Answer=20principles=20round=203:=200=20?= =?UTF-8?q?=F0=9F=94=B4,=200=20=F0=9F=9F=A1=20(0=20misread)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit -- 2.52.0 From 2b2e18ec6d04e5af154bd2c7d36e2c234f0c83ff Mon Sep 17 00:00:00 2001 From: Lilleman auf Larv Date: Tue, 27 Oct 2026 00:51:39 +0100 Subject: [PATCH 07/14] =?UTF-8?q?Answer=20stability=20round=202:=200=20?= =?UTF-8?q?=F0=9F=94=B4,=200=20=F0=9F=9F=A1=20(0=20misread)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit -- 2.52.0 From 34c13f97cd63ceac6f5c1fc7bf0dd9253e0b2fd2 Mon Sep 17 00:00:00 2001 From: Lilleman auf Larv Date: Tue, 27 Oct 2026 00:57:56 +0100 Subject: [PATCH 08/14] =?UTF-8?q?Answer=20product-owner=20round=201:=200?= =?UTF-8?q?=20=F0=9F=94=B4,=200=20=F0=9F=9F=A1=20(0=20misread);=20say=20su?= =?UTF-8?q?bagents=20inherit=20the=20window=20and=20how=20many=20compact,?= =?UTF-8?q?=20keep=20a=20reviewer's=20drafted=20findings=20through=20a=20c?= =?UTF-8?q?ompaction,=20move=20item=20238=20into=200.4.0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CHANGELOG.md | 2 +- CLAUDE.md | 2 +- bin/loop_claude/loop/main.py | 6 +++--- bin/loop_claude/test_loop_claude.py | 2 +- docs/decisions.md | 2 +- todo.md | 10 +++++----- 6 files changed, 12 insertions(+), 12 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ce5f87b3..47624424 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,7 +2,7 @@ ## Unreleased -- loop-claude's worker now runs with a 200k auto-compact window, handed as `CLAUDE_CODE_AUTO_COMPACT_WINDOW`, so Claude Code compacts its context at about 170k tokens; before, at about 967k. Since 2026-10-21, a worker's turns above 200k were 55% of what workers cost. The 19 chunks that compacted before took no more review rounds or findings per message than those that did not, but 4 of them had an unfinished verdict against 3 of 68; `todo.md` item 235 measures the first 20 chunks under the window. loop-claude's judge no longer reads a compaction summary as words the human typed. `CLAUDE.md` has a new section, "Compact instructions", saying what the summary keeps. +- loop-claude's worker, and every subagent it launches, now runs with a 200k auto-compact window, handed as `CLAUDE_CODE_AUTO_COMPACT_WINDOW`, so Claude Code compacts its context at about 170k tokens; before, at about 967k. Since 2026-10-21, a worker's turns above 200k were 55% of what workers cost. The 19 chunks that compacted before took no more review rounds or findings per message than those that did not, but 4 of them had an unfinished verdict against 3 of 68; `todo.md` item 235 measures the first 20 chunks under the window. loop-claude's judge no longer reads a compaction summary as words the human typed. `CLAUDE.md` has a new section, "Compact instructions", saying what the summary keeps. - On Linux, `run-heavy` now caps the memory of a container its command makes with `docker run` or `docker create`. A container that sets no limit gets a memory limit and a swap limit, both the slot's share: three quarters of the machine's memory, split across the heavy slots. A container that sets one of the two limits keeps it, and gets the other as large. This covers containers a project's own scripts start, which rule-hook can't see. A `docker compose` service, and a docker named by its full path, get no cap. rule-hook's `docker-run-memory` now lets a `docker run` under run-heavy pass. - rule-hook has a new rule, `docker-run-memory`. It blocks a `docker run` or `docker create` that lacks a memory limit or a swap limit, such as `--memory 4g --memory-swap 4g`, sized to what the work needs. `--memory-swap -1`, unlimited swap, counts as none. `CLAUDE.md` asks for the same limits on a container a script or a compose file starts, which rule-hook can't see. rule-hook's `run-heavy` rule also now reads docker's `--tlscacert`, `--tlscert`, `--tlskey` and buildx's `--builder` as options that take a value, and reads `docker container run` as a run: `docker --tlscacert ca.pem build .` was not blocked outside run-heavy before. - Reviewers now mark a πŸ”΄ or 🟑 `[misread]` where it arose because the implementer misread code that had already shipped. A round's commit title now counts the marked findings, as in `Answer stability round 1: 1 πŸ”΄, 2 🟑 (1 misread); …`, and rule-hook's `round-title-counts` blocks a round title without that count. `score-outcomes` shows the count on each finished item, and lists it after the medians for each chunk whose round titles carry it, newest first. A chunk whose round titles predate this change reads as unknown. diff --git a/CLAUDE.md b/CLAUDE.md index d8453073..58886075 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -106,7 +106,7 @@ The rules only reviewers apply, for quality, comments, READMEs and prose, live i ## Compact instructions -Claude Code reads this section by its heading when it compacts a conversation. When you compact, keep in the summary: the task loop-claude gave and each `todo.md` item the chunk takes, with its L and E + I; the worktree, branch and PR; the rung loop-claude named for each review launch, rerun and escalated subagent; each review pass's rounds so far, each open πŸ”΄ and 🟑, and how the answered ones were answered; every question the human answered, with the answer; each escalation trigger that fired; and what remains before the chunk is finished. +Claude Code reads this section by its heading when it compacts a conversation. When you compact, keep in the summary: the task loop-claude gave and each `todo.md` item the chunk takes, with its L and E + I; the worktree, branch and PR; the rung loop-claude named for each review launch, rerun and escalated subagent; each review pass's rounds so far, each open πŸ”΄ and 🟑, and how the answered ones were answered; every question the human answered, with the answer; each escalation trigger that fired; and what remains before the chunk is finished. A reviewer or comprehension seat keeps every finding and place it has drafted. ## Vocabulary diff --git a/bin/loop_claude/loop/main.py b/bin/loop_claude/loop/main.py index 3b3c2bf1..ed704ec8 100644 --- a/bin/loop_claude/loop/main.py +++ b/bin/loop_claude/loop/main.py @@ -47,9 +47,9 @@ time. The layout, and when a copy is replaced, are in bin/transcript_archive/__i Before each worker starts, loop-claude waits until at least a quarter of the machine's memory is available (bin/machine_load/memory.py). -Each worker's claude, and the session /talk opens, runs with a 200k auto-compact window -(CLAUDE_CODE_AUTO_COMPACT_WINDOW, bin/loop_claude/cycle/worker.py), so it compacts its context at -about 170k tokens. +Each worker's claude, the session /talk opens and the subagents either launches run with a 200k +auto-compact window (CLAUDE_CODE_AUTO_COMPACT_WINDOW, bin/loop_claude/cycle/worker.py), so each +compacts its context at about 170k tokens. Every claude loop-claude starts runs the project's model, saved per in ~/.claude/loop-claude-models.json and read each cycle, unless routing, below, puts the worker, diff --git a/bin/loop_claude/test_loop_claude.py b/bin/loop_claude/test_loop_claude.py index 40b7a64c..04d93599 100644 --- a/bin/loop_claude/test_loop_claude.py +++ b/bin/loop_claude/test_loop_claude.py @@ -1516,7 +1516,7 @@ class HelpLimits(unittest.TestCase): self.assertIn(f"retried {retry.PAST_RESET // 60} minutes after the limit resets, or every {retry.UNKNOWN_RESET_POLL // 60} minutes", said) self.assertIn(f"still running after {PYTHON_TIMEOUT} s", said) self.assertIn(f"Once {measure.CYCLES_PER_CHECK} cycles have closed across all projects", said) - self.assertIn(f"runs with a {worker.COMPACT_WINDOW // 1000}k auto-compact window", said) + self.assertIn(f"run with a {worker.COMPACT_WINDOW // 1000}k auto-compact window", said) class ExitContract(unittest.TestCase): diff --git a/docs/decisions.md b/docs/decisions.md index 15716777..cf61331e 100644 --- a/docs/decisions.md +++ b/docs/decisions.md @@ -91,7 +91,7 @@ Quality. 19 chunks compacted between 2026-10-10 and 2026-10-22, at 214k to 972k Hours. A chunk ran a median 0.7 hours from its first message to its last, one in ten past 12 hours, mostly waiting for the human or a usage limit. No option here changes that: a compaction takes 51 to 83 seconds, under a minute per chunk at 0.7 each, and a smaller context makes a turn no faster to notice. The hours lever is item 232, since waiting on subagents took 66% of a worker's active time. -The window is handed to the worker, and the session /talk opens, as `CLAUDE_CODE_AUTO_COMPACT_WINDOW=200000` (`bin/loop_claude/cycle/worker.py`), not set in `settings.json`: the archive measured loop-claude's workers, and interactive sessions are lilleman's. Claude Code compacts before a window fills: a 1M window at about 967k, and in a probe on 2026-10-27 a 100k window at 65k and 80k, so a 200k window compacts at about 170k. Subagents inherit it, and at 170k few compact. Another probe that day showed that a `Compact instructions` section in a CLAUDE.md shapes the summary: a session whose CLAUDE.md asked the summary to end with its secret word did. So `CLAUDE.md` β†’ "Compact instructions" names what a worker's summary keeps. Path-scoped rules leave the context at a compaction and return at the next matching read, and rule-hook holds each review launch to its rung whatever the summary keeps. Item 235 compares the first 20 chunks under the window with the 20 before. +The window is handed to the worker, and the session /talk opens, as `CLAUDE_CODE_AUTO_COMPACT_WINDOW=200000` (`bin/loop_claude/cycle/worker.py`), not set in `settings.json`: the archive measured loop-claude's workers, and interactive sessions are lilleman's. Claude Code compacts before a window fills: a 1M window at about 967k, and in a probe on 2026-10-27 a 100k window at 65k and 80k, so a 200k window compacts at about 170k. Subagents inherit it: 68 of the 994 subagent runs since the reset, 7%, passed 170k, 24 of them principles auditors, so about one in fourteen compacts once, and `CLAUDE.md` β†’ "Compact instructions" has a reviewer keep the findings it has drafted. Another probe that day showed that a `Compact instructions` section in a CLAUDE.md shapes the summary: a session whose CLAUDE.md asked the summary to end with its secret word did. So `CLAUDE.md` β†’ "Compact instructions" names what a worker's summary keeps. Path-scoped rules leave the context at a compaction and return at the next matching read, and rule-hook holds each review launch to its rung whatever the summary keeps. Item 235 compares the first 20 chunks under the window with the 20 before. Valid while cache reads cost a twentieth of input and Claude Code's compaction keeps the worker's task. diff --git a/todo.md b/todo.md index b5d9992d..e2bebc99 100644 --- a/todo.md +++ b/todo.md @@ -13,6 +13,7 @@ | ID | Release | Blocked by | Exempt | Item | L | E | I | R | S | Moves | Score | |---|---|---|---|---|---|---|---|---|---|---|---| | 232 | 0.4.0 | | | **Launch a round's review passes in one message, except a pass that must wait for another's findings, so a round lasts about as long as its slowest reviewers, not their sum.** | 3 | 2 | 3 | 6 | 3 | 1.5 by 6 | 5.8 | +| 238 | 0.4.0 | | defect | **Run the security pass's skill in the chunk's worktree, so it scans the branch's diff: invoked from a subagent, it runs in the session's working directory, the main checkout, and scans nothing.** | 2 | 2 | 3 | 5 | 3 | 1.1 by 5 | 5.3 | | 233 | 0.4.0 | | | **Run one principles-auditor per round that checks the goals and every principles file that applies, in place of one auditor for each, so the principles pass reads the project once per round.** | 3 | 2 | 3 | 6 | 3 | 1.4 by 3, 1.5 by 2 | 4.9 | | 234 | 0.4.0 | | | **Report the routing figures in dollars, cache reads included, from the cost each archived run records.** | 2 | 2 | 2 | 4 | 3 | 1.4 by 3 | 3.0 | | 236 | 0.5.0 | | question | **Answer whether the principles audit keeps reading the whole project, or reads only the files the chunk changed and their callers, now that half of its πŸ”΄ and 🟑 findings name a file the chunk did not edit.** | 1 | 1 | 1 | 1 | 1 | 1.4 by 4 | 6.4 | @@ -21,7 +22,6 @@ | 59 | 0.5.0 | | | **Bound a run of unfinished verdicts on one chunk, so a worker and judge that disagree cannot cycle unattended without end.** | 2 | 1 | 3 | 4 | 3 | 1.4 by 6 | 6.0 | | 167 | 0.5.0 | | | **Refuse a `/security-review` or `/claude-security` Skill call below the project's rung, as rule-hook refuses such an Agent call.** | 3 | 2 | 3 | 6 | 2 | 1.1 by 4 | 5.6 | | 6 | 0.5.0 | | decision | **Move what `loop-claude` writes out of `~/.claude.json`, and ask the human about each write that must stay.** | 3 | 3 | 3 | 7 | 3 | 1.1 by 5 | 5.3 | -| 238 | 0.5.0 | | defect | **Run the security pass's skill in the chunk's worktree, so it scans the branch's diff: invoked from a subagent, it runs in the session's working directory, the main checkout, and scans nothing.** | 2 | 2 | 3 | 5 | 3 | 1.1 by 5 | 5.3 | | 1 | 0.6.0 | | question | **Say in README β†’ Install how the transcript archive is backed up, once bender-infra backs up ai-sandbox's data volume.** | 1 | 2 | 1 | 2 | 1 | | 0.0 | | 229 | 0.6.0 | | | **Keep the rule for which commands reach run-heavy's docker beside that docker in `bin/run_heavy/capped_docker.py`, so rule-hook's `docker-run-memory` asks it instead of repeating run-heavy's PATH rules.** | 2 | 1 | 3 | 4 | 2 | code health by 3 | 18.0 | | 219 | 0.6.0 | | | **Name the project's rung `project` in `bin/judge_replay/main.py`, `bin/subagent_rung/main.py` and `bin/review_replay/main.py`, in place of `anchor`, as `bin/model_routing/ladder.py` and `bin/loop_claude` name it.** | 1 | 1 | 3 | 3 | 2 | code health by 2 | 12.0 | @@ -83,6 +83,10 @@ Since 2026-10-21, all 1,372 Agent calls in workers' transcripts were one per message, 94% of them in the foreground, and waiting on subagents took 66% of a worker's active time. larv-review Β§3 orders the passes so no polish goes into code the architect restructures or the security pass rewrites. Keep that: a pass waits only for a pass whose findings could make its review a waste. Launch the rest of the round's passes, the principles auditors among them, in one message. Do the same for the passes a fix reruns, per Β§3 β†’ "Re-entry". +### 238. Run the security pass's skill in the chunk's worktree, so it scans the branch's diff: invoked from a subagent, it runs in the session's working directory, the main checkout, and scans nothing. + +Found while reviewing PR #376. larv-review Β§3 β†’ "Security" launches a general-purpose subagent that invokes `/security-review` through the Skill tool. The skill runs its git commands in the session's working directory, the checkout root, where the branch's diff is empty, and the subagent then reads the worktree's diff itself, which the skill's own text forbids as a substitute. The archived security subagents of items 198 and 223 and of this chunk all report it. It sits in 0.4.0 so the release's remaining chunks get a scan that reads their diff; until it is fixed, run `claude -p /security-review` with the worktree as its working directory, on the project's rung, as PR #376 did. A fix may run the skill as a process in the worktree from larv-review, or have the worker enter the worktree with Claude Code's `EnterWorktree` tool so every subagent runs there. + ### 233. Run one principles-auditor per round that checks the goals and every principles file that applies, in place of one auditor for each, so the principles pass reads the project once per round. Since 2026-10-21, 342 principles-auditor runs cost $274 at list prices, 23% of all spend and 3.8 runs per chunk, and each read the project anew: $129 of 5-minute cache writes, $92 of output and $53 of cache reads. Today larv-review Β§3 β†’ "Principles" launches one auditor for the README's goals and code health, and one per file in `~/.claude/principles/` that applies. The merged auditor must find what the separate ones found: replay archived rounds with `review-replay`, and keep separate auditors where the merged one misses a πŸ”΄ or 🟑. Rename the report files, `principles--round-.md` today (Β§3 β†’ "Reports"), to one per round. @@ -115,10 +119,6 @@ rule-hook checks Agent calls (item 163) but no Skill calls. A worker that invoke Claude Code owns that file and writes it. `trust` reads it, changes it and writes it back, so a write that lands in between is lost. -### 238. Run the security pass's skill in the chunk's worktree, so it scans the branch's diff: invoked from a subagent, it runs in the session's working directory, the main checkout, and scans nothing. - -Found while reviewing PR #376. larv-review Β§3 β†’ "Security" launches a general-purpose subagent that invokes `/security-review` through the Skill tool. The skill runs its git commands in the session's working directory, the checkout root, where the branch's diff is empty, and the subagent then reads the worktree's diff itself, which the skill's own text forbids as a substitute. The archived security subagents of items 198 and 223 and of this chunk all report it. Until it is fixed, run `claude -p /security-review` with the worktree as its working directory, on the project's rung, as PR #376 did. A fix may run the skill as a process in the worktree from larv-review, or have the worker enter the worktree with Claude Code's `EnterWorktree` tool so every subagent runs there. - ### 1. Say in README β†’ Install how the transcript archive is backed up, once bender-infra backs up ai-sandbox's data volume. 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. -- 2.52.0 From b569f638ac914c0e5426257b225251a995ea0d7d Mon Sep 17 00:00:00 2001 From: Lilleman auf Larv Date: Tue, 27 Oct 2026 01:06:24 +0100 Subject: [PATCH 09/14] =?UTF-8?q?Answer=20prose=20round=201:=200=20?= =?UTF-8?q?=F0=9F=94=B4,=2012=20=F0=9F=9F=A1=20(0=20misread);=20put=20the?= =?UTF-8?q?=20decision=20first=20in=20its=20entry,=20list=20the=20compact?= =?UTF-8?q?=20instructions,=20write=20the=20changelog=20for=20the=20public?= =?UTF-8?q?,=20and=20restate=20items=2052,=20102,=20233,=20235,=20236=20an?= =?UTF-8?q?d=20238?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CHANGELOG.md | 2 +- CLAUDE.md | 11 ++++++++++- bin/loop_claude/cycle/worker.py | 2 +- docs/decisions.md | 22 +++++++++++----------- todo.md | 22 +++++++++++----------- 5 files changed, 34 insertions(+), 25 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 47624424..3f436cb9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,7 +2,7 @@ ## Unreleased -- loop-claude's worker, and every subagent it launches, now runs with a 200k auto-compact window, handed as `CLAUDE_CODE_AUTO_COMPACT_WINDOW`, so Claude Code compacts its context at about 170k tokens; before, at about 967k. Since 2026-10-21, a worker's turns above 200k were 55% of what workers cost. The 19 chunks that compacted before took no more review rounds or findings per message than those that did not, but 4 of them had an unfinished verdict against 3 of 68; `todo.md` item 235 measures the first 20 chunks under the window. loop-claude's judge no longer reads a compaction summary as words the human typed. `CLAUDE.md` has a new section, "Compact instructions", saying what the summary keeps. +- loop-claude's worker, and every subagent it launches, now run with a 200k auto-compact window, handed as `CLAUDE_CODE_AUTO_COMPACT_WINDOW`: Claude Code compacts their context at about 170k tokens, where it used to let it grow to about 967k. loop-claude's judge no longer reads a compaction summary as words you typed. `CLAUDE.md` has a new section, "Compact instructions", saying what a summary keeps. - On Linux, `run-heavy` now caps the memory of a container its command makes with `docker run` or `docker create`. A container that sets no limit gets a memory limit and a swap limit, both the slot's share: three quarters of the machine's memory, split across the heavy slots. A container that sets one of the two limits keeps it, and gets the other as large. This covers containers a project's own scripts start, which rule-hook can't see. A `docker compose` service, and a docker named by its full path, get no cap. rule-hook's `docker-run-memory` now lets a `docker run` under run-heavy pass. - rule-hook has a new rule, `docker-run-memory`. It blocks a `docker run` or `docker create` that lacks a memory limit or a swap limit, such as `--memory 4g --memory-swap 4g`, sized to what the work needs. `--memory-swap -1`, unlimited swap, counts as none. `CLAUDE.md` asks for the same limits on a container a script or a compose file starts, which rule-hook can't see. rule-hook's `run-heavy` rule also now reads docker's `--tlscacert`, `--tlscert`, `--tlskey` and buildx's `--builder` as options that take a value, and reads `docker container run` as a run: `docker --tlscacert ca.pem build .` was not blocked outside run-heavy before. - Reviewers now mark a πŸ”΄ or 🟑 `[misread]` where it arose because the implementer misread code that had already shipped. A round's commit title now counts the marked findings, as in `Answer stability round 1: 1 πŸ”΄, 2 🟑 (1 misread); …`, and rule-hook's `round-title-counts` blocks a round title without that count. `score-outcomes` shows the count on each finished item, and lists it after the medians for each chunk whose round titles carry it, newest first. A chunk whose round titles predate this change reads as unknown. diff --git a/CLAUDE.md b/CLAUDE.md index 58886075..4c6871a4 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -106,7 +106,16 @@ The rules only reviewers apply, for quality, comments, READMEs and prose, live i ## Compact instructions -Claude Code reads this section by its heading when it compacts a conversation. When you compact, keep in the summary: the task loop-claude gave and each `todo.md` item the chunk takes, with its L and E + I; the worktree, branch and PR; the rung loop-claude named for each review launch, rerun and escalated subagent; each review pass's rounds so far, each open πŸ”΄ and 🟑, and how the answered ones were answered; every question the human answered, with the answer; each escalation trigger that fired; and what remains before the chunk is finished. A reviewer or comprehension seat keeps every finding and place it has drafted. +Claude Code reads this section by its heading when it compacts a conversation. Keep in the summary: + +- what remains before the chunk is finished; +- the task loop-claude gave, and each `todo.md` item the chunk takes with its L and E + I; +- the worktree, branch and PR; +- the rung loop-claude named for each review launch, rerun and escalated subagent; +- each review pass's rounds so far, each open πŸ”΄ and 🟑, and how the answered ones were answered; +- every question the human answered, with the answer; +- each escalation trigger that fired; +- for a reviewer or comprehension seat, every finding and place it has drafted. ## Vocabulary diff --git a/bin/loop_claude/cycle/worker.py b/bin/loop_claude/cycle/worker.py index 728a80df..02f051c4 100644 --- a/bin/loop_claude/cycle/worker.py +++ b/bin/loop_claude/cycle/worker.py @@ -12,7 +12,7 @@ from claude_code.session import Session PRINTED_TOOL_INPUT = 160 # Seconds between reads of the machine's memory while too little of it is available to start a worker. MEMORY_POLL = 60 -# The auto-compact window, in tokens, handed to the worker's claude in this variable. Claude Code compacts before the window fills, at about 170k: docs/decisions.md β†’ `loop-claude: the worker's claude compacts its context before it fills a 200k window`. +# The auto-compact window, in tokens, handed to the worker's claude in the environment variable AUTO_COMPACT_WINDOW names. Claude Code compacts before the window fills, at about 170k: docs/decisions.md β†’ `loop-claude: the worker's claude compacts its context before it fills a 200k window`. AUTO_COMPACT_WINDOW = "CLAUDE_CODE_AUTO_COMPACT_WINDOW" COMPACT_WINDOW = 200_000 diff --git a/docs/decisions.md b/docs/decisions.md index cf61331e..17a52653 100644 --- a/docs/decisions.md +++ b/docs/decisions.md @@ -74,24 +74,24 @@ The cap is 5, `bin/todo_table.py`'s `BUNDLE_MAX_R`, from the same chunks: by the ## loop-claude: the worker's claude compacts its context before it fills a 200k window, at about 170k tokens, and `CLAUDE.md` β†’ "Compact instructions" says what the summary keeps -2026-10-27, claude through todo item 231, awaiting lilleman's yes before the merge. Serves goal 1.4, under goal 1.1's counter-signal. Item 231 asked for the best means to lower what a chunk spends on context, in dollars, then hours, with no loss of quality. +2026-10-27, lilleman, through todo item 231; claude measured and implemented. Serves goal 1.4; its counter-signal, review rounds and unfinished verdicts per chunk, is the check. -Measured from loop-claude's archive over the 90 chunks with messages after the routing figures' reset of 2026-10-21, at the list prices read on 2026-10-26 (Opus 5.5: $4 per million input tokens, $5 and $8 for 5-minute and 1-hour cache writes, $0.20 for cache reads, $20 for output; no model but Haiku 5.5 charges more above 200k): $1,215, which is 0.86 of what the chunks' `cost-state` entries sum to, since some chunks' subagent transcripts are not in the archive. Worker main threads cost $375 (31%): 1-hour cache writes $149, cache reads $153, output $74. Subagents cost $840: 5-minute cache writes $379, output $274, cache reads $187, with the principles auditors at $274 over 342 runs, the stability reviewers $179 and general-purpose subagents $192. A worker starts at 41k tokens of context and peaks at a median 167k, one in ten past 358k, the largest at 848k: Claude Code compacts a model with a native 1M window at about 967k. The worker's messages above 200k were 32% of its messages and 55% of its cost. +loop-claude hands each worker's claude `CLAUDE_CODE_AUTO_COMPACT_WINDOW=200000` (`bin/loop_claude/cycle/worker.py`), and the session /talk opens gets it too. Claude Code compacts before a window fills: a 1M window at about 967k tokens, and in a probe on 2026-10-27 a 100k window at 65k and 80k, so a 200k window compacts at about 170k. The window is not set in `settings.json`, since the archive measured loop-claude's workers and interactive sessions are lilleman's. Subagents inherit the variable, which reaches every process of the session: 68 of the 994 subagent runs since 2026-10-21, 7%, passed 170k, 24 of them principles auditors, so about one in fourteen compacts once. Compacting subagents by choice would cost more than it saves, as below, but the variable cannot leave them out, and `CLAUDE.md` β†’ "Compact instructions" has a reviewer keep the findings it has drafted. That section shapes the summary: in another probe that day, a session whose CLAUDE.md asked for its summary to end with a secret word got a summary ending with that word. Path-scoped rules leave the context at a compaction and return at the next matching read, and rule-hook holds each review launch to its rung whatever the summary keeps. `CLAUDE_CODE_DISABLE_1M_CONTEXT=1`, handed the same way, would compact at the same point but also cap the window at 200k, so a run that Claude Code stops compacting, as it does when one tool result refills the context each time, would hit the limit instead of going on. -Each option item 231 named, on those chunks: +Why 200k. Item 231 asked for the best means to lower what a chunk spends on context, in dollars, then hours, with no loss of quality. Measured from loop-claude's archive, the 90 chunks with messages after the routing figures' reset of 2026-10-21 cost $1,215 at the list prices read on 2026-10-26 (Opus 5.5: $4 per million input tokens, $5 and $8 for 5-minute and 1-hour cache writes, $0.20 for cache reads, $20 for output; no model but Haiku 5.5 charges more above 200k). That is 0.86 of what the chunks' `cost-state` entries sum to, since some chunks' subagent transcripts are not in the archive. Worker main threads cost $375 (31%): 1-hour cache writes $149, cache reads $153, output $74. Subagents cost $840: 5-minute cache writes $379, output $274, cache reads $187, with the principles auditors at $274 over 342 runs, the stability reviewers $179 and general-purpose subagents $192. A worker starts at 41k tokens of context and peaks at a median 167k, one in ten past 358k, the largest at 848k. The worker's messages above 200k were 32% of its messages and 55% of its cost. -- Compaction. Compacting the worker at 167k to 180k saves $77 to $78 of the workers' $375, 6% of all spend, at 0.7 to 0.8 compactions per chunk; at 150k $75 at 1.0, at 200k $78 at 0.5, at 300k $54 at 0.2. It also caps the 36 re-writes of a whole context after a gap longer than the cache's hour or a change of rung, $61 at up to 785k tokens each, at about $34. Compacting subagents at 150k costs more than it saves, since a compaction reads the context once more and writes a summary, and subagents are short. A 200k window through `CLAUDE_CODE_DISABLE_1M_CONTEXT` would compact at the same point and also narrow every interactive session. -- A fresh context for the review phase, handed 60k tokens of facts, saves $39, which compaction covers, and loop-claude would need a second session per chunk. -- Read with an offset and a limit, or Grep, in place of `cat`, `sed` and `head`: the worker's tool results were 13.2M characters, 65% of them Bash reads, but only 13% whole files; the rest were ranges. A character a worker reads costs about $8 per million tokens to write to the 1-hour cache and $0.20 per million at each later turn, so all the worker's reads cost about $45 and the whole-file ones about $6. A rule would change the tool, not how much is read. +The options item 231 named, simulated on those chunks: + +- Compaction of the worker. The saving and the compactions per chunk, by the point it compacts at: 150k saves $75 at 1.0 compactions; 167k to 180k, where a 200k window compacts, $77 to $78 at 0.8 to 0.7; 200k $78 at 0.5; 300k $54 at 0.2. $78 is 21% of the workers' $375 and 6% of all spend. Compaction also caps the 36 re-writes of a whole context after a gap longer than the cache's hour or a change of rung: they cost $61, up to 785k tokens each, and would cost about $34. Compacting subagents at 150k costs more than it saves, since a compaction reads the context once more and writes a summary, and subagents are short. +- A fresh context for the review phase, handed 60k tokens of facts, saves $39. A compaction at 170k saves that too, and loop-claude would need a second session per chunk. +- Read with an offset and a limit, or Grep, in place of `cat`, `sed` and `head`. The worker's tool results were 13.2M characters, 65% of them Bash reads, and 13% of those characters came from whole files; the rest were ranges. A token a worker reads costs about $8 per million to write to the 1-hour cache and $0.20 per million at each later turn, so all the worker's reads cost about $45 and the whole-file ones about $6. A rule would change the tool, not how much is read. - Code-intelligence tooling: the `LSP` tool, with a language server per language on PATH, replaces a grep and the reads of candidate files with one lookup. Its ceiling is the same $45, and each machine would need a server per language (goal 2). Not tried, and not worth an item while the worker's reads stay under 4% of spend. - What a reviewer reads: the auditors read the project whole by design. Of their πŸ”΄ and 🟑 findings since the reset, 47% named a file the chunk edited and 51% another file, so reading only the change would drop half of them; item 236 asks lilleman about that scope, and item 233 has one auditor read the project once per round. -- The base context: every thread starts with `~/.claude/CLAUDE.md` (19k characters), `~/.claude/AGENTS.md` (11k, this repo's decisions, which Claude Code loads as user instructions into every project's sessions; item 52), the project's `AGENTS.md`, and, for the worker and general-purpose subagents, the skill listing (18k) and the agent listing (12k). Subagents' first messages wrote $97 of it; trimming the listings would save about $20, 2%, and is not worth an item: `disableBundledSkills` would also drop `/security-review`, the security pass of record. +- The base context: every thread starts with `~/.claude/CLAUDE.md` (19k characters), `~/.claude/AGENTS.md` (11k, this repo's decisions, which Claude Code loads as user instructions into every project's sessions; item 52), the project's `AGENTS.md`, and, for the worker and general-purpose subagents, the skill listing (18k) and the agent listing (12k). Subagents' first messages wrote $97 of it. Trimming the listings would save about $20, 2%, and is not worth an item: `disableBundledSkills` would also drop `/security-review`, the security pass of record. -Quality. 19 chunks compacted between 2026-10-10 and 2026-10-22, at 214k to 972k tokens, the windows Claude Code tuned then. Per 100 worker messages they took a median 3.6 review rounds past each pass's first against 4.0 for the 68 uncompacted chunks of 100 messages or more, and 13.9 πŸ”΄ and 🟑 findings against 16.6. 4 of 19 had an unfinished verdict against 3 of 68, each 8 to 10 hours after the compaction and followed by a finished verdict within minutes; the judge quoted the worker's own passages and the human's typed answers in them, never a summary. One cause was possible and is closed here: Claude Code writes the summary as a user entry, which `bin/claude_code/entries.py` read as the human's words, so the judge would see a `[human]` line of thousands of words and `/talk` would count it as typed; it now reads as Claude Code's. Whether compaction raises unfinished verdicts stays open until item 235 measures it. Two summaries read whole kept the chunk's intent, files, errors and next step in 12k to 20k characters, and the worker resumed without re-reading. +Quality. 19 chunks compacted between 2026-10-10 and 2026-10-22, at the compaction points Claude Code set then, 214k to 972k tokens. Per 100 worker messages they took a median 3.6 review rounds past each pass's first against 4.0 for the 68 uncompacted chunks of 100 messages or more, and 13.9 πŸ”΄ and 🟑 findings against 16.6. 4 of 19 had an unfinished verdict against 3 of 68, each 8 to 10 hours after the compaction and followed by a finished verdict within minutes; in those four verdicts the judge quoted the worker's own passages and the human's typed answers, never a summary. One cause was possible and is closed here: Claude Code writes the summary as a user entry, which `bin/claude_code/entries.py` read as the human's words, so the judge would see a `[human]` line of thousands of words and `/talk` would count it as typed; it now reads as Claude Code's. Whether compaction raises unfinished verdicts stays open until item 235 measures it. Two summaries read whole kept the chunk's intent, files, errors and next step in 12k to 20k characters, and the worker resumed without re-reading. -Hours. A chunk ran a median 0.7 hours from its first message to its last, one in ten past 12 hours, mostly waiting for the human or a usage limit. No option here changes that: a compaction takes 51 to 83 seconds, under a minute per chunk at 0.7 each, and a smaller context makes a turn no faster to notice. The hours lever is item 232, since waiting on subagents took 66% of a worker's active time. - -The window is handed to the worker, and the session /talk opens, as `CLAUDE_CODE_AUTO_COMPACT_WINDOW=200000` (`bin/loop_claude/cycle/worker.py`), not set in `settings.json`: the archive measured loop-claude's workers, and interactive sessions are lilleman's. Claude Code compacts before a window fills: a 1M window at about 967k, and in a probe on 2026-10-27 a 100k window at 65k and 80k, so a 200k window compacts at about 170k. Subagents inherit it: 68 of the 994 subagent runs since the reset, 7%, passed 170k, 24 of them principles auditors, so about one in fourteen compacts once, and `CLAUDE.md` β†’ "Compact instructions" has a reviewer keep the findings it has drafted. Another probe that day showed that a `Compact instructions` section in a CLAUDE.md shapes the summary: a session whose CLAUDE.md asked the summary to end with its secret word did. So `CLAUDE.md` β†’ "Compact instructions" names what a worker's summary keeps. Path-scoped rules leave the context at a compaction and return at the next matching read, and rule-hook holds each review launch to its rung whatever the summary keeps. Item 235 compares the first 20 chunks under the window with the 20 before. +Hours. A chunk ran a median 0.7 hours from its first message to its last, one in ten past 12 hours, mostly waiting for the human or a usage limit. No option here changes that: a compaction takes 51 to 83 seconds, under a minute per chunk at 0.7 each, and a smaller context saves seconds per turn at most. The hours lever is item 232, since waiting on subagents took 66% of a worker's active time. Valid while cache reads cost a twentieth of input and Claude Code's compaction keeps the worker's task. diff --git a/todo.md b/todo.md index e2bebc99..0a9af5f6 100644 --- a/todo.md +++ b/todo.md @@ -18,7 +18,7 @@ | 234 | 0.4.0 | | | **Report the routing figures in dollars, cache reads included, from the cost each archived run records.** | 2 | 2 | 2 | 4 | 3 | 1.4 by 3 | 3.0 | | 236 | 0.5.0 | | question | **Answer whether the principles audit keeps reading the whole project, or reads only the files the chunk changed and their callers, now that half of its πŸ”΄ and 🟑 findings name a file the chunk did not edit.** | 1 | 1 | 1 | 1 | 1 | 1.4 by 4 | 6.4 | | 226 | 0.5.0 | | question | **Answer whether rule-hook's `run-heavy` rule should also catch a mutation run or docker build behind `uv run`, `poetry run`, `python3 -m`, `sudo`, `docker image build` and `docker compose up --build`, or narrow the `machine load:` decision's wording.** | 2 | 2 | 3 | 5 | 3 | 1.2 by 2, 1.5 by 2 | 4.0 | -| 235 | 0.5.0 | | | **Compare review rounds past each pass's first, unfinished verdicts, πŸ”΄, 🟑 and misread findings, dollars and hours per chunk, for the first 20 chunks whose worker ran under the 200k compaction window against the 20 before them, and file an item where any rose.** | 1 | 2 | 1 | 2 | 2 | 1.1 by 2, 1.4 by 3 | 6.8 | +| 235 | 0.5.0 | | | **Compare the first 20 chunks whose worker ran under the 200k compaction window with the 20 before them, on review rounds past each pass's first, unfinished verdicts, πŸ”΄, 🟑 and misread findings, dollars and hours per chunk, and file an item where any rose.** | 1 | 2 | 1 | 2 | 2 | 1.1 by 2, 1.4 by 3 | 6.8 | | 59 | 0.5.0 | | | **Bound a run of unfinished verdicts on one chunk, so a worker and judge that disagree cannot cycle unattended without end.** | 2 | 1 | 3 | 4 | 3 | 1.4 by 6 | 6.0 | | 167 | 0.5.0 | | | **Refuse a `/security-review` or `/claude-security` Skill call below the project's rung, as rule-hook refuses such an Agent call.** | 3 | 2 | 3 | 6 | 2 | 1.1 by 4 | 5.6 | | 6 | 0.5.0 | | decision | **Move what `loop-claude` writes out of `~/.claude.json`, and ask the human about each write that must stay.** | 3 | 3 | 3 | 7 | 3 | 1.1 by 5 | 5.3 | @@ -48,7 +48,7 @@ | 101 | 0.6.0 | | principle | **Have `larv_review/history_commands.py`'s `read_seats` take the time, the commit check and the history as inputs, so it parses and decides without effects.** | 2 | 1 | 2 | 3 | 3 | 1.1 by 5 | 5.3 | | 110 | 0.6.0 | | decision | **Count, for each finished chunk, the later changes that fixed code it wrote, and show them beside its guessed E.** | 3 | 2 | 2 | 5 | 5 | 1.1 by 6, 1.4 by 6 | 4.9 | | 12 | 0.6.0 | | | **Run the test suite in CI on every PR, or record in `docs/decisions.md` why the local run is enough.** | 3 | 2 | 1 | 4 | 4 | 1.1 by 6 | 4.2 | -| 102 | 0.6.0 | | | **Give loop-claude's retry delay and its memory read environment overrides, so the black-box test stops replacing `time.sleep` and `machine_load.memory.MEMINFO` through `sitecustomize`.** | 1 | 1 | 2 | 2 | 3 | 1.1 by 4 | 4.2 | +| 102 | 0.6.0 | | | **Give loop-claude's retry delay, and the file it reads the machine's memory from, environment overrides, so the black-box test stops replacing `time.sleep` and `machine_load.memory.MEMINFO` through `sitecustomize`.** | 1 | 1 | 2 | 2 | 3 | 1.1 by 4 | 4.2 | | 135 | 0.6.0 | | | **Fingerprint only the modules loop-claude imports, so editing another tool's code no longer reloads a running loop.** | 2 | 2 | 3 | 5 | 3 | 1.1 by 4 | 4.2 | | 171 | 0.6.0 | | decision | **Group the routing figures' review rounds by the reviewers' rung as well as the worker's, so a call blames a rung only for rounds its own reviews raised.** | 3 | 2 | 2 | 5 | 4 | 1.2 by 3, 1.4 by 3 | 4.0 | | 196 | 0.6.0 | | decision | **Replay the architecture, principles, overrides and product-owner passes with `review-replay` on Opus 5.5 projects, record each run in the review-replay routing decision, and add any rung a run qualifies to `REPLAYED`.** | 2 | 2 | 3 | 5 | 2 | 1.4 by 3 | 4.0 | @@ -72,7 +72,7 @@ | 51 | 0.6.0 | | principle | **Hand loop-claude's terminal output to an injected effect, so no storage or retry function prints.** | 2 | 1 | 3 | 4 | 5 | 1.1 by 5 | 2.1 | | 169 | 0.6.0 | | | **Have rule-hook's `todo-rank-check` catch a `todo.md` that the same Bash call edits and then commits.** | 3 | 1 | 3 | 5 | 3 | 1.1 by 2 | 2.1 | | 174 | 0.6.0 | | | **In a chunk no item routed, ask the worker to name each todo.md item it takes, with its L and E + I, so loop-claude can route on an item it takes in.** | 1 | 2 | 3 | 4 | 1 | 1.1 by 1 | 1.7 | -| 52 | 0.6.0 | | principle | **Move this checkout out of Claude Code's own directory, or record why it stays, since Claude Code loads its `AGENTS.md` as the user's instructions into every project's sessions.** | 4 | 3 | 4 | 9 | 6 | 1.1 by 4, 1.4 by 2 | 1.4 | +| 52 | 0.6.0 | | principle | **Move this checkout out of Claude Code's own directory, or record why it stays, since Claude Code loads the checkout's `AGENTS.md` as the user's instructions into every project's sessions.** | 4 | 3 | 4 | 9 | 6 | 1.1 by 4, 1.4 by 2 | 1.4 | | 197 | 0.6.0 | | | **Let the human edit what they type at loop-claude's terminal questions with the arrow keys, so Left moves the cursor in place of printing `^[[D`.** | 2 | 2 | 3 | 5 | 2 | 1.5 by 1 | 1.3 | | 170 | 0.7.0 | | decision | **Re-tune `WORKER_STEPS` and `REVIEW_STEPS` once 50 chunks have shipped under them, from how well L, E and I order their review rounds and πŸ”΄ findings.** | 2 | 2 | 3 | 5 | 2 | 1.1 by 3, 1.4 by 5 | 10.9 | | 218 | 0.7.0 | 170 | | **Drop `LEGACY_WORKER` from `bin/model_routing/route.py`, so `route_from` reads only JSON worker lines.** | 1 | 2 | 1 | 2 | 1 | code health by 2 | 14.4 | @@ -85,11 +85,11 @@ Since 2026-10-21, all 1,372 Agent calls in workers' transcripts were one per mes ### 238. Run the security pass's skill in the chunk's worktree, so it scans the branch's diff: invoked from a subagent, it runs in the session's working directory, the main checkout, and scans nothing. -Found while reviewing PR #376. larv-review Β§3 β†’ "Security" launches a general-purpose subagent that invokes `/security-review` through the Skill tool. The skill runs its git commands in the session's working directory, the checkout root, where the branch's diff is empty, and the subagent then reads the worktree's diff itself, which the skill's own text forbids as a substitute. The archived security subagents of items 198 and 223 and of this chunk all report it. It sits in 0.4.0 so the release's remaining chunks get a scan that reads their diff; until it is fixed, run `claude -p /security-review` with the worktree as its working directory, on the project's rung, as PR #376 did. A fix may run the skill as a process in the worktree from larv-review, or have the worker enter the worktree with Claude Code's `EnterWorktree` tool so every subagent runs there. +Found while reviewing PR #376. larv-review Β§3 β†’ "Security" launches a general-purpose subagent that invokes `/security-review` through the Skill tool. The skill runs its git commands in the session's working directory, the checkout root, where the branch's diff is empty, and the subagent then reads the worktree's diff itself, which the skill's own text forbids as a substitute. The archived security subagents of items 198 and 223 and of PR #376 all report it. It sits in 0.4.0 so the release's remaining chunks get a scan that reads their diff; until it is fixed, run `claude -p /security-review` with the worktree as its working directory, on the project's rung, as PR #376 did. A fix may run the skill as a process in the worktree from larv-review, or have the worker enter the worktree with Claude Code's `EnterWorktree` tool so every subagent runs there. ### 233. Run one principles-auditor per round that checks the goals and every principles file that applies, in place of one auditor for each, so the principles pass reads the project once per round. -Since 2026-10-21, 342 principles-auditor runs cost $274 at list prices, 23% of all spend and 3.8 runs per chunk, and each read the project anew: $129 of 5-minute cache writes, $92 of output and $53 of cache reads. Today larv-review Β§3 β†’ "Principles" launches one auditor for the README's goals and code health, and one per file in `~/.claude/principles/` that applies. The merged auditor must find what the separate ones found: replay archived rounds with `review-replay`, and keep separate auditors where the merged one misses a πŸ”΄ or 🟑. Rename the report files, `principles--round-.md` today (Β§3 β†’ "Reports"), to one per round. +Since 2026-10-21, 342 principles-auditor runs, 3.8 per chunk, cost $274 at list prices, 23% of all spend: $129 of 5-minute cache writes, $92 of output and $53 of cache reads. Each read the project anew. Today larv-review Β§3 β†’ "Principles" launches one auditor for the README's goals and code health, and one per file in `~/.claude/principles/` that applies. The merged auditor must find what the separate ones found: replay archived rounds with `review-replay`, and keep separate auditors where the merged one misses a πŸ”΄ or 🟑. Rename the report files, `principles--round-.md` today (Β§3 β†’ "Reports"), to one per round. ### 234. Report the routing figures in dollars, cache reads included, from the cost each archived run records. @@ -97,13 +97,13 @@ The routing figures count input, cache-written and output tokens, and leave out ### 236. Answer whether the principles audit keeps reading the whole project, or reads only the files the chunk changed and their callers, now that half of its πŸ”΄ and 🟑 findings name a file the chunk did not edit. -Since 2026-10-21, 342 principles-auditor runs cost $274 at list prices, 23% of all spend, and 176 of their πŸ”΄ and 🟑 findings named a file: 83 a file the chunk edited, 90 another. `docs/decisions.md` β†’ `review: the principles audit runs on every chunk…` holds the whole-project audit valid while its findings are drift a chunk would otherwise merge, and calls a repeat a question on the audit's scope for the human. Reading only the changed files and their callers would cut most of the auditors' $129 of cache writes and drop the findings elsewhere, unless those repeat chunk after chunk: read a sample of the 90 before answering. Item 233 merges the auditors either way. +Since 2026-10-21, 342 principles-auditor runs cost $274 at list prices, 23% of all spend, and 176 of their πŸ”΄ and 🟑 findings named a file: 83 a file the chunk edited, 90 another. `docs/decisions.md` β†’ `review: the principles audit runs on every chunk…` holds the whole-project audit valid while its findings are drift a chunk would otherwise merge, and calls a repeat a question on the audit's scope for the human. Reading only the changed files and their callers would cut most of the auditors' $129 of cache writes and drop the findings elsewhere, unless the same findings come back chunk after chunk: read a sample of the 90 before answering. Item 233 merges the auditors either way. ### 226. Answer whether rule-hook's `run-heavy` rule should also catch a mutation run or docker build behind `uv run`, `poetry run`, `python3 -m`, `sudo`, `docker image build` and `docker compose up --build`, or narrow the `machine load:` decision's wording. Found by review of PR #370. Today `uv run mutmut run`, `poetry run mutmut run`, `python3 -m mutmut run`, `sudo docker build .`, `docker image build .` and `docker compose up --build` pass the rule, which `docs/decisions.md` β†’ `machine load: …` and `RULES["run-heavy"]` describe as blocking docker builds and mutation runs. The rule's own text says a gate script isn't checked since no program can tell it from a light one, so the human decides where the line sits. Say what the rule's "checked" text promises either way. Where the answer widens the rule, the change touches `heavy` in `bin/rule_hook/heavy_command.py`, which the comprehension seats found hard: make it easier to read. -### 235. Compare review rounds past each pass's first, unfinished verdicts, πŸ”΄, 🟑 and misread findings, dollars and hours per chunk, for the first 20 chunks whose worker ran under the 200k compaction window against the 20 before them, and file an item where any rose. +### 235. Compare the first 20 chunks whose worker ran under the 200k compaction window with the 20 before them, on review rounds past each pass's first, unfinished verdicts, πŸ”΄, 🟑 and misread findings, dollars and hours per chunk, and file an item where any rose. `docs/decisions.md` β†’ `loop-claude: the worker's claude compacts its context before it fills a 200k window…` expects a saving of about 6% of all spend with no rise in the other figures. Measure from loop-claude's archive as that decision did: rounds past each pass's first and the πŸ”΄, 🟑 and misread counts from the round commit titles, unfinished verdicts from the outcomes files, hours from the worker's first message to its last, and dollars at list prices, cache reads included, from the chunk's `cost-state` entry, which counts the compaction calls that no message's usage records; item 234 puts such dollars into the routing figures. A chunk ran under the window when its first worker started after that decision merged. @@ -241,9 +241,9 @@ The repo has no CI, so larv-review's gate is the local run, and larv-review's Ga When CI runs a rule check, such as one of `bin/rule-hook`'s, let `` in the PR body override it. -### 102. Give loop-claude's retry delay and its memory read environment overrides, so the black-box test stops replacing `time.sleep` and `machine_load.memory.MEMINFO` through `sitecustomize`. +### 102. Give loop-claude's retry delay, and the file it reads the machine's memory from, environment overrides, so the black-box test stops replacing `time.sleep` and `machine_load.memory.MEMINFO` through `sitecustomize`. -Found by the principles audit of PR #242. `bin/loop_claude/test_black_box.py:113-114` swaps the global `time.sleep`, the shape "Functional core, imperative shell" bans, and the audit of PR #376 found the same block swapping `machine_load.memory.MEMINFO` at lines 119-123. An override of each lets the test run the code as production runs it. +Found by the principles audit of PR #242. `bin/loop_claude/test_black_box.py:117-118` swaps the global `time.sleep`, the shape "Functional core, imperative shell" bans, and the audit of PR #376 found the same block swapping `machine_load.memory.MEMINFO` at lines 120-123. An override of each lets the test run the code as production runs it. ### 135. Fingerprint only the modules loop-claude imports, so editing another tool's code no longer reloads a running loop. @@ -375,9 +375,9 @@ The hook judges a call before it runs, and `changed` in `bin/rule_hook/todo_chec The principles pass of PR #301 found that only `routed_by` in `bin/loop_claude/cycle/prompts.py` asks the worker to name each item it takes with its L and E + I, and `fresh` uses it only where an item routed the chunk. In an unrouted chunk the judge has no levels to report, so neither the taken-in L nor the taken-in E + I lifts the worker or the judge. -### 52. Move this checkout out of Claude Code's own directory, or record why it stays, since Claude Code loads its `AGENTS.md` as the user's instructions into every project's sessions. +### 52. Move this checkout out of Claude Code's own directory, or record why it stays, since Claude Code loads the checkout's `AGENTS.md` as the user's instructions into every project's sessions. -"One owner per value" and "Prefer the vendor-neutral option", in `principles/technical-principles.md`: git, Claude Code and loop-claude all write `~/.claude`, kept apart only by the `.gitignore` allowlist, and the repo's records live in a vendor directory. Claude Code also loads `~/.claude/AGENTS.md`, this checkout's decision titles, as the user's instructions into every session of every project: 10.7k characters, about 2.7k tokens, in each of the 1,084 threads since 2026-10-21, about $25 of cache writes and reads at list prices, and a worker on another project reads this repo's decisions as if they held there. +"One owner per value" and "Prefer the vendor-neutral option", in `principles/technical-principles.md`: git, Claude Code and loop-claude all write `~/.claude`, kept apart only by the `.gitignore` allowlist, and the repo's records live in a vendor directory. Claude Code also loads `~/.claude/AGENTS.md`, this checkout's decision titles, as the user's instructions into every session of every project, so a worker on another project reads this repo's decisions as if they held there. That cost about $25 of cache writes and reads at list prices since 2026-10-21: 10.7k characters, about 2.7k tokens, in each of 1,084 threads. ### 197. Let the human edit what they type at loop-claude's terminal questions with the arrow keys, so Left moves the cursor in place of printing `^[[D`. -- 2.52.0 From 34a623e26112a7cef14d0b73d00baae4300efadc Mon Sep 17 00:00:00 2001 From: Lilleman auf Larv Date: Tue, 27 Oct 2026 01:30:34 +0100 Subject: [PATCH 10/14] File item 239, lilleman's call: block a re-read of a file range already in context while the file is unchanged --- todo.md | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/todo.md b/todo.md index 0a9af5f6..aca2051c 100644 --- a/todo.md +++ b/todo.md @@ -6,7 +6,7 @@ `Bar = 0.1` -`Next ID = 239` +`Next ID = 240` ## Items @@ -16,6 +16,7 @@ | 238 | 0.4.0 | | defect | **Run the security pass's skill in the chunk's worktree, so it scans the branch's diff: invoked from a subagent, it runs in the session's working directory, the main checkout, and scans nothing.** | 2 | 2 | 3 | 5 | 3 | 1.1 by 5 | 5.3 | | 233 | 0.4.0 | | | **Run one principles-auditor per round that checks the goals and every principles file that applies, in place of one auditor for each, so the principles pass reads the project once per round.** | 3 | 2 | 3 | 6 | 3 | 1.4 by 3, 1.5 by 2 | 4.9 | | 234 | 0.4.0 | | | **Report the routing figures in dollars, cache reads included, from the cost each archived run records.** | 2 | 2 | 2 | 4 | 3 | 1.4 by 3 | 3.0 | +| 239 | 0.4.0 | | owner | **Block a Read, `cat`, `sed` or `head` of a file range the session already read while the file is unchanged, with a note that the content is in context, and let it through after a compaction or a change to the file.** | 3 | 2 | 3 | 6 | 4 | 1.4 by 3 | 2.0 | | 236 | 0.5.0 | | question | **Answer whether the principles audit keeps reading the whole project, or reads only the files the chunk changed and their callers, now that half of its πŸ”΄ and 🟑 findings name a file the chunk did not edit.** | 1 | 1 | 1 | 1 | 1 | 1.4 by 4 | 6.4 | | 226 | 0.5.0 | | question | **Answer whether rule-hook's `run-heavy` rule should also catch a mutation run or docker build behind `uv run`, `poetry run`, `python3 -m`, `sudo`, `docker image build` and `docker compose up --build`, or narrow the `machine load:` decision's wording.** | 2 | 2 | 3 | 5 | 3 | 1.2 by 2, 1.5 by 2 | 4.0 | | 235 | 0.5.0 | | | **Compare the first 20 chunks whose worker ran under the 200k compaction window with the 20 before them, on review rounds past each pass's first, unfinished verdicts, πŸ”΄, 🟑 and misread findings, dollars and hours per chunk, and file an item where any rose.** | 1 | 2 | 1 | 2 | 2 | 1.1 by 2, 1.4 by 3 | 6.8 | @@ -95,6 +96,10 @@ Since 2026-10-21, 342 principles-auditor runs, 3.8 per chunk, cost $274 at list The routing figures count input, cache-written and output tokens, and leave out cache reads, which were 28% of the cost since 2026-10-21, $340 of $1,215 at list prices. So their tables rank the principles auditor above the worker, while in dollars the worker cost 1.4 times as much, $375 against $274. Each archived worker transcript ends with a `cost-state` entry holding `totalCostUSD` and each model's cost, and each message's usage attributes the cost to a subagent type. The judge's runs record no cost in the archive: count them too, or say why not. The change touches `bin/routing_figures/measure.py`, which the comprehension seats found hard (item 139): make the places it touches easier to read. +### 239. Block a Read, `cat`, `sed` or `head` of a file range the session already read while the file is unchanged, with a note that the content is in context, and let it through after a compaction or a change to the file. + +lilleman's call, 2026-10-27, filed from PR #376's measurement of loop-claude's archive since 2026-10-21: a read of a file the agent read earlier in the thread, more than three messages before and without editing it in between, is 13% of the worker's reading, about $6 of the $45 its reads cost, and 1 to 2% of a reviewer's. A hook on `Read` and on the Bash reads `cat`, `sed` and `head` blocks such a read with a short note that the content is already in context and unchanged. It lets the read through after a compaction, when the content has left the context, or when the file changed since the read; a PreToolUse hook gets the session's `transcript_path`, which holds the earlier reads and each `compact_boundary`, so it needs no state of its own. If scouts ship (item 231's decision records the trial), the same idea applies to scout answers, cached by file and content hash: a scout only cheapens these re-reads and doesn't remove them, which is why this is a separate item. + ### 236. Answer whether the principles audit keeps reading the whole project, or reads only the files the chunk changed and their callers, now that half of its πŸ”΄ and 🟑 findings name a file the chunk did not edit. Since 2026-10-21, 342 principles-auditor runs cost $274 at list prices, 23% of all spend, and 176 of their πŸ”΄ and 🟑 findings named a file: 83 a file the chunk edited, 90 another. `docs/decisions.md` β†’ `review: the principles audit runs on every chunk…` holds the whole-project audit valid while its findings are drift a chunk would otherwise merge, and calls a repeat a question on the audit's scope for the human. Reading only the changed files and their callers would cut most of the auditors' $129 of cache writes and drop the findings elsewhere, unless the same findings come back chunk after chunk: read a sample of the 90 before answering. Item 233 merges the auditors either way. -- 2.52.0 From d96e5c35ef675ca1830fc6e1aa2d3b3cc889352d Mon Sep 17 00:00:00 2001 From: Lilleman auf Larv Date: Tue, 27 Oct 2026 02:11:05 +0100 Subject: [PATCH 11/14] Record the read pricing, precision and tool trials in item 231's decision, and file questions 240 and 241 --- docs/decisions.md | 8 ++++++++ todo.md | 12 +++++++++++- 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/docs/decisions.md b/docs/decisions.md index 17a52653..48bc305c 100644 --- a/docs/decisions.md +++ b/docs/decisions.md @@ -93,6 +93,14 @@ Quality. 19 chunks compacted between 2026-10-10 and 2026-10-22, at the compactio Hours. A chunk ran a median 0.7 hours from its first message to its last, one in ten past 12 hours, mostly waiting for the human or a usage limit. No option here changes that: a compaction takes 51 to 83 seconds, under a minute per chunk at 0.7 each, and a smaller context saves seconds per turn at most. The hours lever is item 232, since waiting on subagents took 66% of a worker's active time. +Reads and tools, measured the same day at lilleman's ask, on the same 90 chunks: + +- What reads cost. The messages that took in tool results carried $537 of the $1,215, 44%: the worker's $190 (Bash reads $115, Read $12), the principles auditors' $139 (Read $109, Grep $22), the stability reviewers' $106 (Bash reads $79), general-purpose subagents' $97, the prose reviewers' $34, the architects' $31 and the product-owner reviewers' $23. These figures charge a message's new input tokens to the results it took in, so they include what arrives beside a result, such as the agent's own previous reply; the 93M characters read alone are about 27M tokens. +- Precision. Of the characters a principles auditor read, 13% were in a file its report names; a stability reviewer 8%; the worker 4% in a file it later edited; a prose reviewer 18%; an architect 11%. Reading is mostly to find things and to learn what a project holds, as lilleman read it. The worker's `sed` ranges are small, median 25 lines, one in ten over 80. Of the worker's read characters, 49% were of a file it had read earlier in the thread: 36% within three messages, paging through it, and 13% later and unchanged, about $6 of the $45 its reads cost; reviewers 1 to 2% (item 239). +- Tool results. Claude Code caps a Bash result at about 30k characters. Subagents' Read results, 59.9M characters, have 58% of their characters in results over 12k. +- Trials on this repo. Four stability rounds and five principles rounds archived on 2026-10-23, each holding πŸ”΄ or 🟑 findings, replayed on the project's rung as `review-replay` replays them, with the reviewer's definition changed through `--agents`; and three worker-like tasks, a search, a rename and an explanation, run on fresh clones at the project's rung. The baseline reviewers found 4 of their own 6 archived findings in each pass, the spread a sample this small sits in. The LSP tool, through a pyright plugin built from the marketplace manifest with `pyright-langserver` on PATH, answers a file's symbols, a definition or the references in a few hundred characters; the stability reviewers and the workers never called it under a rule telling them to, and the auditors who did read as much or more and missed the one πŸ”΄ (0 of 1 against the baseline's 1 of 1). An `outline` script printing a file's symbols with line ranges: never called by workers; stability reviewers under its rule found 2 of 6 findings. A PostToolUse hook capping a Bash result at 12k characters: 3 of 6, two lost in one round. A scout, Haiku 5.5 reading raw content and returning facts and line ranges: as an in-session agent its first request writes 37k tokens, $0.005, and a read of a 38KB file costs $0.008 in 8 seconds; as a slim headless `claude -p` with its own system prompt, no setting sources and no dynamic sections, 6k tokens, $0.0003 and 3 to 5 seconds of startup, its prefix cached across calls, and the same read $0.004 in 7 seconds. Stability reviewers with the agent scout found 5 of 6 findings and read 29% fewer characters at 6% less cost and 14% more time; with the CLI scout 4 of 6, 38% fewer characters, 17% less cost and 39% more time; the auditors with the agent scout 3 of 6 at the same cost and twice the time. Workers offered the scout never called it, but its reading rule alone, never read more than 80 lines of a file yourself, cut their reading 45% to 60% at the same or lower cost, with all three tasks done as well. +- What follows. On this sample no tool cuts a reviewer's reading without losing a finding, except the scout, whose saving sits within the baseline's own spread; so none of them ships here. lilleman decides two trials: a reading rule for workers (item 240) and a scout for reviewers (item 241). A direct API call and `claude --bare` are out, since both need an API key where lilleman's login is a subscription. + Valid while cache reads cost a twentieth of input and Claude Code's compaction keeps the worker's task. ## machine load: a heavy command waits for one of the machine's heavy slots, one for every 4 CPUs, which every session shares, and loop-claude starts a worker only while at least a quarter of the machine's memory is available diff --git a/todo.md b/todo.md index aca2051c..77cb605f 100644 --- a/todo.md +++ b/todo.md @@ -6,7 +6,7 @@ `Bar = 0.1` -`Next ID = 240` +`Next ID = 242` ## Items @@ -18,7 +18,9 @@ | 234 | 0.4.0 | | | **Report the routing figures in dollars, cache reads included, from the cost each archived run records.** | 2 | 2 | 2 | 4 | 3 | 1.4 by 3 | 3.0 | | 239 | 0.4.0 | | owner | **Block a Read, `cat`, `sed` or `head` of a file range the session already read while the file is unchanged, with a note that the content is in context, and let it through after a compaction or a change to the file.** | 3 | 2 | 3 | 6 | 4 | 1.4 by 3 | 2.0 | | 236 | 0.5.0 | | question | **Answer whether the principles audit keeps reading the whole project, or reads only the files the chunk changed and their callers, now that half of its πŸ”΄ and 🟑 findings name a file the chunk did not edit.** | 1 | 1 | 1 | 1 | 1 | 1.4 by 4 | 6.4 | +| 240 | 0.5.0 | | question | **Answer whether workers get a reading rule in `CLAUDE.md`, never reading more than 80 lines of a file at once, which cut three worker tasks' reading 45% to 60% at the same quality.** | 1 | 2 | 3 | 4 | 1 | 1.4 by 3 | 4.8 | | 226 | 0.5.0 | | question | **Answer whether rule-hook's `run-heavy` rule should also catch a mutation run or docker build behind `uv run`, `poetry run`, `python3 -m`, `sudo`, `docker image build` and `docker compose up --build`, or narrow the `machine load:` decision's wording.** | 2 | 2 | 3 | 5 | 3 | 1.2 by 2, 1.5 by 2 | 4.0 | +| 241 | 0.5.0 | | question | **Answer whether reviewers hand a read over 80 lines to a Haiku scout, which cut a stability reviewer's reading 29% to 38% and its cost 6% to 17% on four replayed rounds, at 14% to 39% more time and findings within the baseline's own spread.** | 2 | 2 | 3 | 5 | 3 | 1.4 by 3 | 3.0 | | 235 | 0.5.0 | | | **Compare the first 20 chunks whose worker ran under the 200k compaction window with the 20 before them, on review rounds past each pass's first, unfinished verdicts, πŸ”΄, 🟑 and misread findings, dollars and hours per chunk, and file an item where any rose.** | 1 | 2 | 1 | 2 | 2 | 1.1 by 2, 1.4 by 3 | 6.8 | | 59 | 0.5.0 | | | **Bound a run of unfinished verdicts on one chunk, so a worker and judge that disagree cannot cycle unattended without end.** | 2 | 1 | 3 | 4 | 3 | 1.4 by 6 | 6.0 | | 167 | 0.5.0 | | | **Refuse a `/security-review` or `/claude-security` Skill call below the project's rung, as rule-hook refuses such an Agent call.** | 3 | 2 | 3 | 6 | 2 | 1.1 by 4 | 5.6 | @@ -104,10 +106,18 @@ lilleman's call, 2026-10-27, filed from PR #376's measurement of loop-claude's a Since 2026-10-21, 342 principles-auditor runs cost $274 at list prices, 23% of all spend, and 176 of their πŸ”΄ and 🟑 findings named a file: 83 a file the chunk edited, 90 another. `docs/decisions.md` β†’ `review: the principles audit runs on every chunk…` holds the whole-project audit valid while its findings are drift a chunk would otherwise merge, and calls a repeat a question on the audit's scope for the human. Reading only the changed files and their callers would cut most of the auditors' $129 of cache writes and drop the findings elsewhere, unless the same findings come back chunk after chunk: read a sample of the 90 before answering. Item 233 merges the auditors either way. +### 240. Answer whether workers get a reading rule in `CLAUDE.md`, never reading more than 80 lines of a file at once, which cut three worker tasks' reading 45% to 60% at the same quality. + +lilleman's question, from PR #376's trials (`docs/decisions.md` β†’ `loop-claude: the worker's claude compacts its context before it fills a 200k window…`, "Reads and tools"). Three worker-like tasks on this repo, a search, a rename and an explanation, run under the rule "never read more than 80 lines of a file yourself, and never take a tool output you expect to exceed 3,000 characters into your context" read 45% to 60% fewer characters at the same or lower cost and answered as well; the rename under it was the only one that also kept the import names sorted. Only 4% of what a worker reads is in a file it later edits. The rule is one line in `CLAUDE.md` that every session loads, so its effect on real chunks, misread findings above all, is unmeasured: a yes trials it and item 235's figures over the next 20 chunks measure it. + ### 226. Answer whether rule-hook's `run-heavy` rule should also catch a mutation run or docker build behind `uv run`, `poetry run`, `python3 -m`, `sudo`, `docker image build` and `docker compose up --build`, or narrow the `machine load:` decision's wording. Found by review of PR #370. Today `uv run mutmut run`, `poetry run mutmut run`, `python3 -m mutmut run`, `sudo docker build .`, `docker image build .` and `docker compose up --build` pass the rule, which `docs/decisions.md` β†’ `machine load: …` and `RULES["run-heavy"]` describe as blocking docker builds and mutation runs. The rule's own text says a gate script isn't checked since no program can tell it from a light one, so the human decides where the line sits. Say what the rule's "checked" text promises either way. Where the answer widens the rule, the change touches `heavy` in `bin/rule_hook/heavy_command.py`, which the comprehension seats found hard: make it easier to read. +### 241. Answer whether reviewers hand a read over 80 lines to a Haiku scout, which cut a stability reviewer's reading 29% to 38% and its cost 6% to 17% on four replayed rounds, at 14% to 39% more time and findings within the baseline's own spread. + +lilleman's question, from PR #376's trials (`docs/decisions.md` β†’ `loop-claude: the worker's claude compacts its context before it fills a 200k window…`, "Reads and tools"). A scout is Haiku 5.5 reading raw content, whole files or long output, and returning facts as path:line and the ranges worth reading. In session, as an agent under `agents/`, its first request writes 37k tokens, $0.005, and a read of a 38KB file costs $0.008 in 8 seconds; as a slim headless `claude -p --model claude-haiku-5-5 --system-prompt … --tools "" --setting-sources "" --no-session-persistence`, which keeps the subscription login, 6k tokens, $0.0003, 3 to 5 seconds of startup with its prefix cached across calls, and the same read $0.004 in 7 seconds. On four replayed stability rounds the agent scout found 5 of 6 archived findings against the baseline's 4 and read 29% fewer characters at 6% less cost and 14% more time; the CLI scout 4 of 6, 38% fewer, 17% less, 39% more; the auditors with the agent scout 3 of 6 at the same cost and twice the time. The reviewers' spend is $840 of $1,215, so a 10% cut is about $85 per 90 chunks. `AGENTS.md` makes a change to the delegation rule lilleman's call. A yes names the shape, agent or CLI, and which reviewers; item 235's figures then measure it. + ### 235. Compare the first 20 chunks whose worker ran under the 200k compaction window with the 20 before them, on review rounds past each pass's first, unfinished verdicts, πŸ”΄, 🟑 and misread findings, dollars and hours per chunk, and file an item where any rose. `docs/decisions.md` β†’ `loop-claude: the worker's claude compacts its context before it fills a 200k window…` expects a saving of about 6% of all spend with no rise in the other figures. Measure from loop-claude's archive as that decision did: rounds past each pass's first and the πŸ”΄, 🟑 and misread counts from the round commit titles, unfinished verdicts from the outcomes files, hours from the worker's first message to its last, and dollars at list prices, cache reads included, from the chunk's `cost-state` entry, which counts the compaction calls that no message's usage records; item 234 puts such dollars into the routing figures. A chunk ran under the window when its first worker started after that decision merged. -- 2.52.0 From 172e72ae070b44221b0afabca5d6bac5e0407be1 Mon Sep 17 00:00:00 2001 From: Lilleman auf Larv Date: Tue, 27 Oct 2026 02:17:30 +0100 Subject: [PATCH 12/14] =?UTF-8?q?Answer=20prose=20round=202:=200=20?= =?UTF-8?q?=F0=9F=94=B4,=2012=20=F0=9F=9F=A1=20(0=20misread);=20pair=20eac?= =?UTF-8?q?h=20option=20with=20its=20trial=20and=20put=20the=20conclusion?= =?UTF-8?q?=20first,=20tell=20the=20two=20read=20measures=20apart,=20move?= =?UTF-8?q?=20the=20security=20workaround=20into=20the=20skill,=20and=20re?= =?UTF-8?q?state=20items=20238=20to=20241?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docs/decisions.md | 18 +++++++----------- skills/larv-review/SKILL.md | 2 +- todo.md | 20 ++++++++++---------- 3 files changed, 18 insertions(+), 22 deletions(-) diff --git a/docs/decisions.md b/docs/decisions.md index 48bc305c..6cbce885 100644 --- a/docs/decisions.md +++ b/docs/decisions.md @@ -80,12 +80,16 @@ loop-claude hands each worker's claude `CLAUDE_CODE_AUTO_COMPACT_WINDOW=200000` Why 200k. Item 231 asked for the best means to lower what a chunk spends on context, in dollars, then hours, with no loss of quality. Measured from loop-claude's archive, the 90 chunks with messages after the routing figures' reset of 2026-10-21 cost $1,215 at the list prices read on 2026-10-26 (Opus 5.5: $4 per million input tokens, $5 and $8 for 5-minute and 1-hour cache writes, $0.20 for cache reads, $20 for output; no model but Haiku 5.5 charges more above 200k). That is 0.86 of what the chunks' `cost-state` entries sum to, since some chunks' subagent transcripts are not in the archive. Worker main threads cost $375 (31%): 1-hour cache writes $149, cache reads $153, output $74. Subagents cost $840: 5-minute cache writes $379, output $274, cache reads $187, with the principles auditors at $274 over 342 runs, the stability reviewers $179 and general-purpose subagents $192. A worker starts at 41k tokens of context and peaks at a median 167k, one in ten past 358k, the largest at 848k. The worker's messages above 200k were 32% of its messages and 55% of its cost. -The options item 231 named, simulated on those chunks: +What reads cost, and whether a tool cuts them, measured at lilleman's ask after those figures: no tool cut a reviewer's reading without losing a finding, except a scout, whose findings stayed within what the same reviewer finds twice; so none of them ships here, and items 240 and 241 ask lilleman about two trials. Two measures of reading: the characters a thread read, 93M in all, about 27M tokens; and the new input tokens of the messages that took results in, charged to those results, which also count what arrives beside a result, such as the agent's own previous reply. By the second measure tool results caused $620 of the $1,215, and reads (Read, Bash reads, Grep, Glob and git's diff, show and log) $537 of that: the worker's reads $140 (Bash reads $115, Read $12) of its $190 of results, the principles auditors' $133 (Read $109, Grep $22) of $139, the stability reviewers' $97 (Bash reads $79) of $106, general-purpose subagents' $84 of $97, the prose reviewers' $32, the architects' $30 and the product-owner reviewers' $21. By the first measure the worker's reads are about $45. Precision is low everywhere: of the characters a principles auditor read, 13% were in a file its report names; a stability reviewer 8%; a prose reviewer 18%; an architect 11%; the worker 4% in a file it later edited. Reading is mostly to find things and to learn what a project holds. The worker's `sed` ranges are small, median 25 lines, one in ten over 80. Of the worker's read characters, 49% were of a file it had read earlier in the thread: 36% within three messages, paging through it, and 13% later, with the file unchanged, about $6 of the $45; a reviewer's later reads of an unchanged file it had read are 1 to 2% (item 239). + +The trials: four stability rounds and five principles rounds archived on 2026-10-23, each holding πŸ”΄ or 🟑 findings, replayed on the project's rung as `review-replay` replays them, with the reviewer's definition changed through `--agents`; and three worker-like tasks, a search, a rename and an explanation, run on fresh clones at the project's rung. The baseline, the reviewer as it is, found 4 of its own 6 archived findings in each pass, so a variant that finds 4 or 5 of 6 does what the same reviewer does twice. The options item 231 named, each simulated on the 90 chunks and, where lilleman asked, tried: - Compaction of the worker. The saving and the compactions per chunk, by the point it compacts at: 150k saves $75 at 1.0 compactions; 167k to 180k, where a 200k window compacts, $77 to $78 at 0.8 to 0.7; 200k $78 at 0.5; 300k $54 at 0.2. $78 is 21% of the workers' $375 and 6% of all spend. Compaction also caps the 36 re-writes of a whole context after a gap longer than the cache's hour or a change of rung: they cost $61, up to 785k tokens each, and would cost about $34. Compacting subagents at 150k costs more than it saves, since a compaction reads the context once more and writes a summary, and subagents are short. - A fresh context for the review phase, handed 60k tokens of facts, saves $39. A compaction at 170k saves that too, and loop-claude would need a second session per chunk. -- Read with an offset and a limit, or Grep, in place of `cat`, `sed` and `head`. The worker's tool results were 13.2M characters, 65% of them Bash reads, and 13% of those characters came from whole files; the rest were ranges. A token a worker reads costs about $8 per million to write to the 1-hour cache and $0.20 per million at each later turn, so all the worker's reads cost about $45 and the whole-file ones about $6. A rule would change the tool, not how much is read. -- Code-intelligence tooling: the `LSP` tool, with a language server per language on PATH, replaces a grep and the reads of candidate files with one lookup. Its ceiling is the same $45, and each machine would need a server per language (goal 2). Not tried, and not worth an item while the worker's reads stay under 4% of spend. +- Read with an offset and a limit, or Grep, in place of `cat`, `sed` and `head`. Steering the tool would not change how much is read: the worker's `sed` ranges are small already, and only 13% of its Bash-read characters came from whole files. A rule on how much to read did change it: under "never read more than 80 lines of a file at once, nor take a tool output over 3,000 characters into your context", the three worker tasks read 45% to 60% fewer characters at the same or lower cost, every task done as well, and the rename was the one run of four that also kept the import names sorted; item 240 asks whether workers get the rule. A stability reviewer under the same rule with an `outline` script on PATH, which prints a file's symbols with their line ranges, read 4% less and found 2 of 6 findings, and the workers never ran the script. +- Code-intelligence tooling: the `LSP` tool, through a pyright plugin built from the marketplace manifest with `pyright-langserver` on PATH, answers a file's symbols, a definition or the references in a few hundred characters. Under a rule telling them to use it, the stability reviewers and the workers never called it; the auditors did, read as much or more, and missed the one πŸ”΄, 0 of 1 against the baseline's 1 of 1. Each machine would also need a server per language (goal 2). Not worth an item. +- A cap on tool results. Claude Code caps a Bash result at about 30k characters already. A PostToolUse hook capping it at 12k, which `updatedToolOutput` allows, left the stability reviewers 3 of 6 findings, two lost in one round. Read results, 59.9M characters in subagents' threads with 58% of their characters in results over 12k, are out of such a hook's reach. Not worth an item. +- A scout: Haiku 5.5 reading raw content, whole files or long output, and returning facts as path:line and the ranges worth reading, so the agent's own context holds the summary and the chosen lines. In session, as an agent under `agents/`, its first request writes 37k tokens, $0.005, and a read of a 38KB file costs $0.008 in 8 seconds. As a slim headless `claude -p` with its own system prompt, no setting sources and no dynamic sections, which keeps the subscription login, it starts at 6k tokens and $0.0003 in 3 to 5 seconds, its prefix cached across calls, and the same read costs $0.004 in 7 seconds; a direct API call and `claude --bare` need an API key, so they are out. Stability reviewers with the agent scout found 5 of 6 findings and read 29% fewer characters at 6% less cost and 14% more time; with the CLI scout 4 of 6, 38% fewer, 17% less and 39% more; the auditors with the agent scout 3 of 6, the πŸ”΄ among the lost, at the same cost and twice the time. Workers offered the scout never called it. Item 241 asks whether reviewers get one; `AGENTS.md` makes a change to the delegation rule lilleman's call. - What a reviewer reads: the auditors read the project whole by design. Of their πŸ”΄ and 🟑 findings since the reset, 47% named a file the chunk edited and 51% another file, so reading only the change would drop half of them; item 236 asks lilleman about that scope, and item 233 has one auditor read the project once per round. - The base context: every thread starts with `~/.claude/CLAUDE.md` (19k characters), `~/.claude/AGENTS.md` (11k, this repo's decisions, which Claude Code loads as user instructions into every project's sessions; item 52), the project's `AGENTS.md`, and, for the worker and general-purpose subagents, the skill listing (18k) and the agent listing (12k). Subagents' first messages wrote $97 of it. Trimming the listings would save about $20, 2%, and is not worth an item: `disableBundledSkills` would also drop `/security-review`, the security pass of record. @@ -93,14 +97,6 @@ Quality. 19 chunks compacted between 2026-10-10 and 2026-10-22, at the compactio Hours. A chunk ran a median 0.7 hours from its first message to its last, one in ten past 12 hours, mostly waiting for the human or a usage limit. No option here changes that: a compaction takes 51 to 83 seconds, under a minute per chunk at 0.7 each, and a smaller context saves seconds per turn at most. The hours lever is item 232, since waiting on subagents took 66% of a worker's active time. -Reads and tools, measured the same day at lilleman's ask, on the same 90 chunks: - -- What reads cost. The messages that took in tool results carried $537 of the $1,215, 44%: the worker's $190 (Bash reads $115, Read $12), the principles auditors' $139 (Read $109, Grep $22), the stability reviewers' $106 (Bash reads $79), general-purpose subagents' $97, the prose reviewers' $34, the architects' $31 and the product-owner reviewers' $23. These figures charge a message's new input tokens to the results it took in, so they include what arrives beside a result, such as the agent's own previous reply; the 93M characters read alone are about 27M tokens. -- Precision. Of the characters a principles auditor read, 13% were in a file its report names; a stability reviewer 8%; the worker 4% in a file it later edited; a prose reviewer 18%; an architect 11%. Reading is mostly to find things and to learn what a project holds, as lilleman read it. The worker's `sed` ranges are small, median 25 lines, one in ten over 80. Of the worker's read characters, 49% were of a file it had read earlier in the thread: 36% within three messages, paging through it, and 13% later and unchanged, about $6 of the $45 its reads cost; reviewers 1 to 2% (item 239). -- Tool results. Claude Code caps a Bash result at about 30k characters. Subagents' Read results, 59.9M characters, have 58% of their characters in results over 12k. -- Trials on this repo. Four stability rounds and five principles rounds archived on 2026-10-23, each holding πŸ”΄ or 🟑 findings, replayed on the project's rung as `review-replay` replays them, with the reviewer's definition changed through `--agents`; and three worker-like tasks, a search, a rename and an explanation, run on fresh clones at the project's rung. The baseline reviewers found 4 of their own 6 archived findings in each pass, the spread a sample this small sits in. The LSP tool, through a pyright plugin built from the marketplace manifest with `pyright-langserver` on PATH, answers a file's symbols, a definition or the references in a few hundred characters; the stability reviewers and the workers never called it under a rule telling them to, and the auditors who did read as much or more and missed the one πŸ”΄ (0 of 1 against the baseline's 1 of 1). An `outline` script printing a file's symbols with line ranges: never called by workers; stability reviewers under its rule found 2 of 6 findings. A PostToolUse hook capping a Bash result at 12k characters: 3 of 6, two lost in one round. A scout, Haiku 5.5 reading raw content and returning facts and line ranges: as an in-session agent its first request writes 37k tokens, $0.005, and a read of a 38KB file costs $0.008 in 8 seconds; as a slim headless `claude -p` with its own system prompt, no setting sources and no dynamic sections, 6k tokens, $0.0003 and 3 to 5 seconds of startup, its prefix cached across calls, and the same read $0.004 in 7 seconds. Stability reviewers with the agent scout found 5 of 6 findings and read 29% fewer characters at 6% less cost and 14% more time; with the CLI scout 4 of 6, 38% fewer characters, 17% less cost and 39% more time; the auditors with the agent scout 3 of 6 at the same cost and twice the time. Workers offered the scout never called it, but its reading rule alone, never read more than 80 lines of a file yourself, cut their reading 45% to 60% at the same or lower cost, with all three tasks done as well. -- What follows. On this sample no tool cuts a reviewer's reading without losing a finding, except the scout, whose saving sits within the baseline's own spread; so none of them ships here. lilleman decides two trials: a reading rule for workers (item 240) and a scout for reviewers (item 241). A direct API call and `claude --bare` are out, since both need an API key where lilleman's login is a subscription. - Valid while cache reads cost a twentieth of input and Claude Code's compaction keeps the worker's task. ## machine load: a heavy command waits for one of the machine's heavy slots, one for every 4 CPUs, which every session shares, and loop-claude starts a worker only while at least a quarter of the machine's memory is available diff --git a/skills/larv-review/SKILL.md b/skills/larv-review/SKILL.md index efb530f9..d15ba69a 100644 --- a/skills/larv-review/SKILL.md +++ b/skills/larv-review/SKILL.md @@ -136,7 +136,7 @@ The comprehension check records how hard the project is for its contributor to r ### Security -`/security-review` over the branch diff is the pass of record, except where the full scan runs on the same change and replaces it. Where the full scan fires but does not run β€” skipped on a precedent, declined at its cost prompt, or unavailable β€” `/security-review` runs. Launch a general-purpose subagent that invokes it through the Skill tool, edits nothing, and replies with the skill's report, or that the skill is unavailable. Invoked in your own context, the skill ends your turn on that report. Open its prompt, and that of any subagent that runs the full scan, with `You are the security pass for this chunk.`: rule-hook reads that sentence as a security launch. +`/security-review` over the branch diff is the pass of record, except where the full scan runs on the same change and replaces it. Where the full scan fires but does not run β€” skipped on a precedent, declined at its cost prompt, or unavailable β€” `/security-review` runs. Launch a general-purpose subagent that invokes it through the Skill tool, edits nothing, and replies with the skill's report, or that the skill is unavailable. The skill runs in the session's working directory, so where the chunk's worktree is another directory, run `claude -p /security-review` in the worktree on the project's rung instead (`todo.md` item 238 fixes the launch). Invoked in your own context, the skill ends your turn on that report. Open its prompt, and that of any subagent that runs the full scan, with `You are the security pass for this chunk.`: rule-hook reads that sentence as a security launch. A verified HIGH inside this chunk's blast radius is fixed here, outside it on its own branch and PR with this chunk waiting behind it. Say which. diff --git a/todo.md b/todo.md index 77cb605f..a8cee2d5 100644 --- a/todo.md +++ b/todo.md @@ -16,11 +16,11 @@ | 238 | 0.4.0 | | defect | **Run the security pass's skill in the chunk's worktree, so it scans the branch's diff: invoked from a subagent, it runs in the session's working directory, the main checkout, and scans nothing.** | 2 | 2 | 3 | 5 | 3 | 1.1 by 5 | 5.3 | | 233 | 0.4.0 | | | **Run one principles-auditor per round that checks the goals and every principles file that applies, in place of one auditor for each, so the principles pass reads the project once per round.** | 3 | 2 | 3 | 6 | 3 | 1.4 by 3, 1.5 by 2 | 4.9 | | 234 | 0.4.0 | | | **Report the routing figures in dollars, cache reads included, from the cost each archived run records.** | 2 | 2 | 2 | 4 | 3 | 1.4 by 3 | 3.0 | -| 239 | 0.4.0 | | owner | **Block a Read, `cat`, `sed` or `head` of a file range the session already read while the file is unchanged, with a note that the content is in context, and let it through after a compaction or a change to the file.** | 3 | 2 | 3 | 6 | 4 | 1.4 by 3 | 2.0 | +| 239 | 0.4.0 | | owner | **Block a Read, `cat`, `sed` or `head` of a file range already in the session's context, with a note saying so, and let it through once a compaction dropped the range or the file changed.** | 3 | 2 | 3 | 6 | 4 | 1.4 by 3 | 2.0 | | 236 | 0.5.0 | | question | **Answer whether the principles audit keeps reading the whole project, or reads only the files the chunk changed and their callers, now that half of its πŸ”΄ and 🟑 findings name a file the chunk did not edit.** | 1 | 1 | 1 | 1 | 1 | 1.4 by 4 | 6.4 | -| 240 | 0.5.0 | | question | **Answer whether workers get a reading rule in `CLAUDE.md`, never reading more than 80 lines of a file at once, which cut three worker tasks' reading 45% to 60% at the same quality.** | 1 | 2 | 3 | 4 | 1 | 1.4 by 3 | 4.8 | +| 240 | 0.5.0 | | question | **Answer whether workers get a reading rule in `CLAUDE.md`: never read more than 80 lines of a file at once, nor take a tool output over 3,000 characters into your context.** | 1 | 2 | 3 | 4 | 1 | 1.4 by 3 | 4.8 | | 226 | 0.5.0 | | question | **Answer whether rule-hook's `run-heavy` rule should also catch a mutation run or docker build behind `uv run`, `poetry run`, `python3 -m`, `sudo`, `docker image build` and `docker compose up --build`, or narrow the `machine load:` decision's wording.** | 2 | 2 | 3 | 5 | 3 | 1.2 by 2, 1.5 by 2 | 4.0 | -| 241 | 0.5.0 | | question | **Answer whether reviewers hand a read over 80 lines to a Haiku scout, which cut a stability reviewer's reading 29% to 38% and its cost 6% to 17% on four replayed rounds, at 14% to 39% more time and findings within the baseline's own spread.** | 2 | 2 | 3 | 5 | 3 | 1.4 by 3 | 3.0 | +| 241 | 0.5.0 | | question | **Answer whether reviewers hand a read over 80 lines to a Haiku scout, which on four replayed stability rounds cut the reviewer's reading by a third and its cost by a tenth, slowed it, and found as many findings as the reviewer finds on its own.** | 2 | 2 | 3 | 5 | 3 | 1.4 by 3 | 3.0 | | 235 | 0.5.0 | | | **Compare the first 20 chunks whose worker ran under the 200k compaction window with the 20 before them, on review rounds past each pass's first, unfinished verdicts, πŸ”΄, 🟑 and misread findings, dollars and hours per chunk, and file an item where any rose.** | 1 | 2 | 1 | 2 | 2 | 1.1 by 2, 1.4 by 3 | 6.8 | | 59 | 0.5.0 | | | **Bound a run of unfinished verdicts on one chunk, so a worker and judge that disagree cannot cycle unattended without end.** | 2 | 1 | 3 | 4 | 3 | 1.4 by 6 | 6.0 | | 167 | 0.5.0 | | | **Refuse a `/security-review` or `/claude-security` Skill call below the project's rung, as rule-hook refuses such an Agent call.** | 3 | 2 | 3 | 6 | 2 | 1.1 by 4 | 5.6 | @@ -88,7 +88,7 @@ Since 2026-10-21, all 1,372 Agent calls in workers' transcripts were one per mes ### 238. Run the security pass's skill in the chunk's worktree, so it scans the branch's diff: invoked from a subagent, it runs in the session's working directory, the main checkout, and scans nothing. -Found while reviewing PR #376. larv-review Β§3 β†’ "Security" launches a general-purpose subagent that invokes `/security-review` through the Skill tool. The skill runs its git commands in the session's working directory, the checkout root, where the branch's diff is empty, and the subagent then reads the worktree's diff itself, which the skill's own text forbids as a substitute. The archived security subagents of items 198 and 223 and of PR #376 all report it. It sits in 0.4.0 so the release's remaining chunks get a scan that reads their diff; until it is fixed, run `claude -p /security-review` with the worktree as its working directory, on the project's rung, as PR #376 did. A fix may run the skill as a process in the worktree from larv-review, or have the worker enter the worktree with Claude Code's `EnterWorktree` tool so every subagent runs there. +Found while reviewing PR #376. larv-review Β§3 β†’ "Security" launches a general-purpose subagent that invokes `/security-review` through the Skill tool. The skill runs its git commands in the session's working directory, the checkout root, where the branch's diff is empty, and the subagent then reads the worktree's diff itself, which the skill's own text forbids as a substitute. The archived security subagents of items 198 and 223 and of PR #376 all report it. It sits in 0.4.0 so the release's remaining chunks get a scan that reads their diff; until then larv-review Β§3 β†’ "Security" says to run the skill in the worktree. A fix may run the skill as a process in the worktree from larv-review, or have the worker enter the worktree with Claude Code's `EnterWorktree` tool so every subagent runs there. ### 233. Run one principles-auditor per round that checks the goals and every principles file that applies, in place of one auditor for each, so the principles pass reads the project once per round. @@ -98,25 +98,25 @@ Since 2026-10-21, 342 principles-auditor runs, 3.8 per chunk, cost $274 at list The routing figures count input, cache-written and output tokens, and leave out cache reads, which were 28% of the cost since 2026-10-21, $340 of $1,215 at list prices. So their tables rank the principles auditor above the worker, while in dollars the worker cost 1.4 times as much, $375 against $274. Each archived worker transcript ends with a `cost-state` entry holding `totalCostUSD` and each model's cost, and each message's usage attributes the cost to a subagent type. The judge's runs record no cost in the archive: count them too, or say why not. The change touches `bin/routing_figures/measure.py`, which the comprehension seats found hard (item 139): make the places it touches easier to read. -### 239. Block a Read, `cat`, `sed` or `head` of a file range the session already read while the file is unchanged, with a note that the content is in context, and let it through after a compaction or a change to the file. +### 239. Block a Read, `cat`, `sed` or `head` of a file range already in the session's context, with a note saying so, and let it through once a compaction dropped the range or the file changed. -lilleman's call, 2026-10-27, filed from PR #376's measurement of loop-claude's archive since 2026-10-21: a read of a file the agent read earlier in the thread, more than three messages before and without editing it in between, is 13% of the worker's reading, about $6 of the $45 its reads cost, and 1 to 2% of a reviewer's. A hook on `Read` and on the Bash reads `cat`, `sed` and `head` blocks such a read with a short note that the content is already in context and unchanged. It lets the read through after a compaction, when the content has left the context, or when the file changed since the read; a PreToolUse hook gets the session's `transcript_path`, which holds the earlier reads and each `compact_boundary`, so it needs no state of its own. If scouts ship (item 231's decision records the trial), the same idea applies to scout answers, cached by file and content hash: a scout only cheapens these re-reads and doesn't remove them, which is why this is a separate item. +lilleman's call, 2026-10-27, filed from PR #376's measurement of loop-claude's archive since 2026-10-21: a read of a file the agent read earlier in the thread, more than three messages before and without editing it in between, is 13% of the worker's reading, about $6 of the $45 its reads cost, and 1 to 2% of a reviewer's. How many of those repeat a range exactly is unmeasured, so the figures are a ceiling. A hook on `Read` and on the Bash reads `cat`, `sed` and `head` blocks such a read with a short note that the content is already in context and unchanged. It lets the read through after a compaction, when the content has left the context, or when the file changed since the read. A PreToolUse hook gets a `transcript_path`, which holds the earlier reads and each `compact_boundary`, so it may need no state of its own; check whether a hook inside a subagent gets the subagent's own transcript. A scout only cheapens these re-reads and doesn't remove them, which is why this is a separate item. If scouts ship (`docs/decisions.md` β†’ `loop-claude: the worker's claude compacts its context before it fills a 200k window…` records the trial, and item 241 asks), the same idea applies to scout answers, cached by file and content hash. ### 236. Answer whether the principles audit keeps reading the whole project, or reads only the files the chunk changed and their callers, now that half of its πŸ”΄ and 🟑 findings name a file the chunk did not edit. Since 2026-10-21, 342 principles-auditor runs cost $274 at list prices, 23% of all spend, and 176 of their πŸ”΄ and 🟑 findings named a file: 83 a file the chunk edited, 90 another. `docs/decisions.md` β†’ `review: the principles audit runs on every chunk…` holds the whole-project audit valid while its findings are drift a chunk would otherwise merge, and calls a repeat a question on the audit's scope for the human. Reading only the changed files and their callers would cut most of the auditors' $129 of cache writes and drop the findings elsewhere, unless the same findings come back chunk after chunk: read a sample of the 90 before answering. Item 233 merges the auditors either way. -### 240. Answer whether workers get a reading rule in `CLAUDE.md`, never reading more than 80 lines of a file at once, which cut three worker tasks' reading 45% to 60% at the same quality. +### 240. Answer whether workers get a reading rule in `CLAUDE.md`: never read more than 80 lines of a file at once, nor take a tool output over 3,000 characters into your context. -lilleman's question, from PR #376's trials (`docs/decisions.md` β†’ `loop-claude: the worker's claude compacts its context before it fills a 200k window…`, "Reads and tools"). Three worker-like tasks on this repo, a search, a rename and an explanation, run under the rule "never read more than 80 lines of a file yourself, and never take a tool output you expect to exceed 3,000 characters into your context" read 45% to 60% fewer characters at the same or lower cost and answered as well; the rename under it was the only one that also kept the import names sorted. Only 4% of what a worker reads is in a file it later edits. The rule is one line in `CLAUDE.md` that every session loads, so its effect on real chunks, misread findings above all, is unmeasured: a yes trials it and item 235's figures over the next 20 chunks measure it. +lilleman's question, from PR #376's trials, recorded in `docs/decisions.md` β†’ `loop-claude: the worker's claude compacts its context before it fills a 200k window…`. Three worker-like tasks on this repo, a search, a rename and an explanation, each ran once as workers run today and once under the rule. Under the rule each task read 45% to 60% fewer characters, cost the same or less, and came out as well; of the four runs of the rename, the one under the rule was the only one that also kept the import names sorted. Only 4% of what a worker reads is in a file it later edits. Three tasks say little about real chunks, where a worker that reads less may misread more, and the rule is one line in `CLAUDE.md` that every session loads. A yes ships the line and measures the 20 chunks after it against the 20 before, as item 235 measures the compaction window: review rounds, unfinished verdicts, πŸ”΄, 🟑 and misread findings, dollars and hours per chunk. ### 226. Answer whether rule-hook's `run-heavy` rule should also catch a mutation run or docker build behind `uv run`, `poetry run`, `python3 -m`, `sudo`, `docker image build` and `docker compose up --build`, or narrow the `machine load:` decision's wording. Found by review of PR #370. Today `uv run mutmut run`, `poetry run mutmut run`, `python3 -m mutmut run`, `sudo docker build .`, `docker image build .` and `docker compose up --build` pass the rule, which `docs/decisions.md` β†’ `machine load: …` and `RULES["run-heavy"]` describe as blocking docker builds and mutation runs. The rule's own text says a gate script isn't checked since no program can tell it from a light one, so the human decides where the line sits. Say what the rule's "checked" text promises either way. Where the answer widens the rule, the change touches `heavy` in `bin/rule_hook/heavy_command.py`, which the comprehension seats found hard: make it easier to read. -### 241. Answer whether reviewers hand a read over 80 lines to a Haiku scout, which cut a stability reviewer's reading 29% to 38% and its cost 6% to 17% on four replayed rounds, at 14% to 39% more time and findings within the baseline's own spread. +### 241. Answer whether reviewers hand a read over 80 lines to a Haiku scout, which on four replayed stability rounds cut the reviewer's reading by a third and its cost by a tenth, slowed it, and found as many findings as the reviewer finds on its own. -lilleman's question, from PR #376's trials (`docs/decisions.md` β†’ `loop-claude: the worker's claude compacts its context before it fills a 200k window…`, "Reads and tools"). A scout is Haiku 5.5 reading raw content, whole files or long output, and returning facts as path:line and the ranges worth reading. In session, as an agent under `agents/`, its first request writes 37k tokens, $0.005, and a read of a 38KB file costs $0.008 in 8 seconds; as a slim headless `claude -p --model claude-haiku-5-5 --system-prompt … --tools "" --setting-sources "" --no-session-persistence`, which keeps the subscription login, 6k tokens, $0.0003, 3 to 5 seconds of startup with its prefix cached across calls, and the same read $0.004 in 7 seconds. On four replayed stability rounds the agent scout found 5 of 6 archived findings against the baseline's 4 and read 29% fewer characters at 6% less cost and 14% more time; the CLI scout 4 of 6, 38% fewer, 17% less, 39% more; the auditors with the agent scout 3 of 6 at the same cost and twice the time. The reviewers' spend is $840 of $1,215, so a 10% cut is about $85 per 90 chunks. `AGENTS.md` makes a change to the delegation rule lilleman's call. A yes names the shape, agent or CLI, and which reviewers; item 235's figures then measure it. +lilleman's question, from PR #376's trials, recorded with the scout's shapes and costs in `docs/decisions.md` β†’ `loop-claude: the worker's claude compacts its context before it fills a 200k window…`. A scout is Haiku 5.5 reading raw content, whole files or long output, and returning facts as path:line and the ranges worth reading; in session it is an agent under `agents/`, and as a slim headless `claude -p` on the subscription login it starts at 6k tokens in 3 to 5 seconds. On four replayed stability rounds the agent scout found 5 of 6 archived findings against the baseline's 4 and read 29% fewer characters at 6% less cost and 14% more time; the CLI scout 4 of 6, 38% fewer, 17% less and 39% more; the auditors with the agent scout 3 of 6, the πŸ”΄ among the lost, at the same cost and twice the time. The reviewers under `agents/` spent $646 of the $1,215 since 2026-10-21, so a tenth off is about $65 per 90 chunks. `AGENTS.md` makes a change to the delegation rule lilleman's call. A yes names the shape, agent or CLI, and which reviewers, and measures the 20 chunks after it against the 20 before, as item 235 measures the compaction window. ### 235. Compare the first 20 chunks whose worker ran under the 200k compaction window with the 20 before them, on review rounds past each pass's first, unfinished verdicts, πŸ”΄, 🟑 and misread findings, dollars and hours per chunk, and file an item where any rose. -- 2.52.0 From b46d5374ff95e19bc2e33c593416bd7f6e2e093d Mon Sep 17 00:00:00 2001 From: Lilleman auf Larv Date: Tue, 27 Oct 2026 09:08:18 +0100 Subject: [PATCH 13/14] Record lilleman's answers: merge the window, trial the reading rule as item 240, no scout for reviewers, and the audit keeps reading the project whole --- docs/decisions.md | 12 +++++++----- todo.md | 20 +++++--------------- 2 files changed, 12 insertions(+), 20 deletions(-) diff --git a/docs/decisions.md b/docs/decisions.md index 6cbce885..28e1cada 100644 --- a/docs/decisions.md +++ b/docs/decisions.md @@ -74,23 +74,23 @@ The cap is 5, `bin/todo_table.py`'s `BUNDLE_MAX_R`, from the same chunks: by the ## loop-claude: the worker's claude compacts its context before it fills a 200k window, at about 170k tokens, and `CLAUDE.md` β†’ "Compact instructions" says what the summary keeps -2026-10-27, lilleman, through todo item 231; claude measured and implemented. Serves goal 1.4; its counter-signal, review rounds and unfinished verdicts per chunk, is the check. +2026-10-27, lilleman's yes, typed that day, to the evaluation claude made through todo item 231. Serves goal 1.4; its counter-signal, review rounds and unfinished verdicts per chunk, is the check. loop-claude hands each worker's claude `CLAUDE_CODE_AUTO_COMPACT_WINDOW=200000` (`bin/loop_claude/cycle/worker.py`), and the session /talk opens gets it too. Claude Code compacts before a window fills: a 1M window at about 967k tokens, and in a probe on 2026-10-27 a 100k window at 65k and 80k, so a 200k window compacts at about 170k. The window is not set in `settings.json`, since the archive measured loop-claude's workers and interactive sessions are lilleman's. Subagents inherit the variable, which reaches every process of the session: 68 of the 994 subagent runs since 2026-10-21, 7%, passed 170k, 24 of them principles auditors, so about one in fourteen compacts once. Compacting subagents by choice would cost more than it saves, as below, but the variable cannot leave them out, and `CLAUDE.md` β†’ "Compact instructions" has a reviewer keep the findings it has drafted. That section shapes the summary: in another probe that day, a session whose CLAUDE.md asked for its summary to end with a secret word got a summary ending with that word. Path-scoped rules leave the context at a compaction and return at the next matching read, and rule-hook holds each review launch to its rung whatever the summary keeps. `CLAUDE_CODE_DISABLE_1M_CONTEXT=1`, handed the same way, would compact at the same point but also cap the window at 200k, so a run that Claude Code stops compacting, as it does when one tool result refills the context each time, would hit the limit instead of going on. Why 200k. Item 231 asked for the best means to lower what a chunk spends on context, in dollars, then hours, with no loss of quality. Measured from loop-claude's archive, the 90 chunks with messages after the routing figures' reset of 2026-10-21 cost $1,215 at the list prices read on 2026-10-26 (Opus 5.5: $4 per million input tokens, $5 and $8 for 5-minute and 1-hour cache writes, $0.20 for cache reads, $20 for output; no model but Haiku 5.5 charges more above 200k). That is 0.86 of what the chunks' `cost-state` entries sum to, since some chunks' subagent transcripts are not in the archive. Worker main threads cost $375 (31%): 1-hour cache writes $149, cache reads $153, output $74. Subagents cost $840: 5-minute cache writes $379, output $274, cache reads $187, with the principles auditors at $274 over 342 runs, the stability reviewers $179 and general-purpose subagents $192. A worker starts at 41k tokens of context and peaks at a median 167k, one in ten past 358k, the largest at 848k. The worker's messages above 200k were 32% of its messages and 55% of its cost. -What reads cost, and whether a tool cuts them, measured at lilleman's ask after those figures: no tool cut a reviewer's reading without losing a finding, except a scout, whose findings stayed within what the same reviewer finds twice; so none of them ships here, and items 240 and 241 ask lilleman about two trials. Two measures of reading: the characters a thread read, 93M in all, about 27M tokens; and the new input tokens of the messages that took results in, charged to those results, which also count what arrives beside a result, such as the agent's own previous reply. By the second measure tool results caused $620 of the $1,215, and reads (Read, Bash reads, Grep, Glob and git's diff, show and log) $537 of that: the worker's reads $140 (Bash reads $115, Read $12) of its $190 of results, the principles auditors' $133 (Read $109, Grep $22) of $139, the stability reviewers' $97 (Bash reads $79) of $106, general-purpose subagents' $84 of $97, the prose reviewers' $32, the architects' $30 and the product-owner reviewers' $21. By the first measure the worker's reads are about $45. Precision is low everywhere: of the characters a principles auditor read, 13% were in a file its report names; a stability reviewer 8%; a prose reviewer 18%; an architect 11%; the worker 4% in a file it later edited. Reading is mostly to find things and to learn what a project holds. The worker's `sed` ranges are small, median 25 lines, one in ten over 80. Of the worker's read characters, 49% were of a file it had read earlier in the thread: 36% within three messages, paging through it, and 13% later, with the file unchanged, about $6 of the $45; a reviewer's later reads of an unchanged file it had read are 1 to 2% (item 239). +What reads cost, and whether a tool cuts them, measured at lilleman's ask after those figures: no tool cut a reviewer's reading without losing a finding, except a scout, whose findings stayed within what the same reviewer finds twice; so none of them ships here. lilleman chose on 2026-10-27: workers trial a reading rule (item 240), and reviewers get no scout. Two measures of reading: the characters a thread read, 93M in all, about 27M tokens; and the new input tokens of the messages that took results in, charged to those results, which also count what arrives beside a result, such as the agent's own previous reply. By the second measure tool results caused $620 of the $1,215, and reads (Read, Bash reads, Grep, Glob and git's diff, show and log) $537 of that: the worker's reads $140 (Bash reads $115, Read $12) of its $190 of results, the principles auditors' $133 (Read $109, Grep $22) of $139, the stability reviewers' $97 (Bash reads $79) of $106, general-purpose subagents' $84 of $97, the prose reviewers' $32, the architects' $30 and the product-owner reviewers' $21. By the first measure the worker's reads are about $45. Precision is low everywhere: of the characters a principles auditor read, 13% were in a file its report names; a stability reviewer 8%; a prose reviewer 18%; an architect 11%; the worker 4% in a file it later edited. Reading is mostly to find things and to learn what a project holds. The worker's `sed` ranges are small, median 25 lines, one in ten over 80. Of the worker's read characters, 49% were of a file it had read earlier in the thread: 36% within three messages, paging through it, and 13% later, with the file unchanged, about $6 of the $45; a reviewer's later reads of an unchanged file it had read are 1 to 2% (item 239). The trials: four stability rounds and five principles rounds archived on 2026-10-23, each holding πŸ”΄ or 🟑 findings, replayed on the project's rung as `review-replay` replays them, with the reviewer's definition changed through `--agents`; and three worker-like tasks, a search, a rename and an explanation, run on fresh clones at the project's rung. The baseline, the reviewer as it is, found 4 of its own 6 archived findings in each pass, so a variant that finds 4 or 5 of 6 does what the same reviewer does twice. The options item 231 named, each simulated on the 90 chunks and, where lilleman asked, tried: - Compaction of the worker. The saving and the compactions per chunk, by the point it compacts at: 150k saves $75 at 1.0 compactions; 167k to 180k, where a 200k window compacts, $77 to $78 at 0.8 to 0.7; 200k $78 at 0.5; 300k $54 at 0.2. $78 is 21% of the workers' $375 and 6% of all spend. Compaction also caps the 36 re-writes of a whole context after a gap longer than the cache's hour or a change of rung: they cost $61, up to 785k tokens each, and would cost about $34. Compacting subagents at 150k costs more than it saves, since a compaction reads the context once more and writes a summary, and subagents are short. - A fresh context for the review phase, handed 60k tokens of facts, saves $39. A compaction at 170k saves that too, and loop-claude would need a second session per chunk. -- Read with an offset and a limit, or Grep, in place of `cat`, `sed` and `head`. Steering the tool would not change how much is read: the worker's `sed` ranges are small already, and only 13% of its Bash-read characters came from whole files. A rule on how much to read did change it: under "never read more than 80 lines of a file at once, nor take a tool output over 3,000 characters into your context", the three worker tasks read 45% to 60% fewer characters at the same or lower cost, every task done as well, and the rename was the one run of four that also kept the import names sorted; item 240 asks whether workers get the rule. A stability reviewer under the same rule with an `outline` script on PATH, which prints a file's symbols with their line ranges, read 4% less and found 2 of 6 findings, and the workers never ran the script. +- Read with an offset and a limit, or Grep, in place of `cat`, `sed` and `head`. Steering the tool would not change how much is read: the worker's `sed` ranges are small already, and only 13% of its Bash-read characters came from whole files. A rule on how much to read did change it: under "never read more than 80 lines of a file at once, nor take a tool output over 3,000 characters into your context", the three worker tasks read 45% to 60% fewer characters at the same or lower cost, every task done as well, and the rename was the one run of four that also kept the import names sorted; item 240 trials the rule on workers. A stability reviewer under the same rule with an `outline` script on PATH, which prints a file's symbols with their line ranges, read 4% less and found 2 of 6 findings, and the workers never ran the script. - Code-intelligence tooling: the `LSP` tool, through a pyright plugin built from the marketplace manifest with `pyright-langserver` on PATH, answers a file's symbols, a definition or the references in a few hundred characters. Under a rule telling them to use it, the stability reviewers and the workers never called it; the auditors did, read as much or more, and missed the one πŸ”΄, 0 of 1 against the baseline's 1 of 1. Each machine would also need a server per language (goal 2). Not worth an item. - A cap on tool results. Claude Code caps a Bash result at about 30k characters already. A PostToolUse hook capping it at 12k, which `updatedToolOutput` allows, left the stability reviewers 3 of 6 findings, two lost in one round. Read results, 59.9M characters in subagents' threads with 58% of their characters in results over 12k, are out of such a hook's reach. Not worth an item. -- A scout: Haiku 5.5 reading raw content, whole files or long output, and returning facts as path:line and the ranges worth reading, so the agent's own context holds the summary and the chosen lines. In session, as an agent under `agents/`, its first request writes 37k tokens, $0.005, and a read of a 38KB file costs $0.008 in 8 seconds. As a slim headless `claude -p` with its own system prompt, no setting sources and no dynamic sections, which keeps the subscription login, it starts at 6k tokens and $0.0003 in 3 to 5 seconds, its prefix cached across calls, and the same read costs $0.004 in 7 seconds; a direct API call and `claude --bare` need an API key, so they are out. Stability reviewers with the agent scout found 5 of 6 findings and read 29% fewer characters at 6% less cost and 14% more time; with the CLI scout 4 of 6, 38% fewer, 17% less and 39% more; the auditors with the agent scout 3 of 6, the πŸ”΄ among the lost, at the same cost and twice the time. Workers offered the scout never called it. Item 241 asks whether reviewers get one; `AGENTS.md` makes a change to the delegation rule lilleman's call. -- What a reviewer reads: the auditors read the project whole by design. Of their πŸ”΄ and 🟑 findings since the reset, 47% named a file the chunk edited and 51% another file, so reading only the change would drop half of them; item 236 asks lilleman about that scope, and item 233 has one auditor read the project once per round. +- A scout: Haiku 5.5 reading raw content, whole files or long output, and returning facts as path:line and the ranges worth reading, so the agent's own context holds the summary and the chosen lines. In session, as an agent under `agents/`, its first request writes 37k tokens, $0.005, and a read of a 38KB file costs $0.008 in 8 seconds. As a slim headless `claude -p` with its own system prompt, no setting sources and no dynamic sections, which keeps the subscription login, it starts at 6k tokens and $0.0003 in 3 to 5 seconds, its prefix cached across calls, and the same read costs $0.004 in 7 seconds; a direct API call and `claude --bare` need an API key, so they are out. Stability reviewers with the agent scout found 5 of 6 findings and read 29% fewer characters at 6% less cost and 14% more time; with the CLI scout 4 of 6, 38% fewer, 17% less and 39% more; the auditors with the agent scout 3 of 6, the πŸ”΄ among the lost, at the same cost and twice the time. Workers offered the scout never called it. On 2026-10-27 lilleman said no to a scout for reviewers: the saving sits within the reviewer's own spread, the auditors lost the πŸ”΄, and every round ran slower. The delegation rule stands as `routing: a worker delegates a task only where it needs just the task's conclusion…` records. +- What a reviewer reads: the auditors read the project whole by design. Of their πŸ”΄ and 🟑 findings since the reset, 47% named a file the chunk edited and 51% another file, so reading only the change would drop half of them; on 2026-10-27 lilleman kept the whole-project reading (`review: the principles audit runs on every chunk that changes code, config or tests, and on no other chunk`), and item 233 has one auditor read the project once per round. - The base context: every thread starts with `~/.claude/CLAUDE.md` (19k characters), `~/.claude/AGENTS.md` (11k, this repo's decisions, which Claude Code loads as user instructions into every project's sessions; item 52), the project's `AGENTS.md`, and, for the worker and general-purpose subagents, the skill listing (18k) and the agent listing (12k). Subagents' first messages wrote $97 of it. Trimming the listings would save about $20, 2%, and is not worth an item: `disableBundledSkills` would also drop `/security-review`, the security pass of record. Quality. 19 chunks compacted between 2026-10-10 and 2026-10-22, at the compaction points Claude Code set then, 214k to 972k tokens. Per 100 worker messages they took a median 3.6 review rounds past each pass's first against 4.0 for the 68 uncompacted chunks of 100 messages or more, and 13.9 πŸ”΄ and 🟑 findings against 16.6. 4 of 19 had an unfinished verdict against 3 of 68, each 8 to 10 hours after the compaction and followed by a finished verdict within minutes; in those four verdicts the judge quoted the worker's own passages and the human's typed answers, never a summary. One cause was possible and is closed here: Claude Code writes the summary as a user entry, which `bin/claude_code/entries.py` read as the human's words, so the judge would see a `[human]` line of thousands of words and `/talk` would count it as typed; it now reads as Claude Code's. Whether compaction raises unfinished verdicts stays open until item 235 measures it. Two summaries read whole kept the chunk's intent, files, errors and next step in 12k to 20k characters, and the worker resumed without re-reading. @@ -227,6 +227,8 @@ The base is the last measured commit: the default branch's newest merged change 2026-10-16, lilleman, answering the question on the audit's trigger that the plan held. Serves goal 1.1: a principle that no chunk checks drifts, as the stability reviewer's own copy of the principles drifted from them, until it applied `principles/technical-principles.md` as written. It costs goal 1.4: a chunk that changes code, config or tests launches one auditor for the goals and one per applicable principles file, and a code fix re-enters them. The human accepted that cost. The cost shows in tokens per finished chunk and in review rounds per chunk. Valid while the audit's findings are drift a chunk would otherwise merge, not the same whole-project findings repeated chunk after chunk: a repeat is a question on the audit's scope for the human. +2026-10-27, lilleman, asked through PR #376: the audit keeps reading the project whole. Since 2026-10-21, 342 auditor runs cost $274 at list prices, and of their 176 πŸ”΄ and 🟑 findings that named a file, 90 named one the chunk did not edit; reading only the changed files and their callers would have dropped those, and lilleman keeps them. Item 233 still has one auditor read the project once per round. + ## review: the stability pass mutation-tests the lines a chunk changes, in place of measuring test coverage 2026-10-13, lilleman through todo item 108, implemented by claude. Serves goals 1.1 and 1.4. Coverage counts the lines a test runs, so a test without a meaningful assertion still raises it. A surviving mutant shows a test that would let behaviour break. Every mutant of an untested changed line survives, so mutation testing of the changed lines also shows what a coverage drop on them would. Coverage would also catch a deleted test; the stability reviewer sees one in the diff without it. Measuring coverage beside it would add cost without raising quality, so todo item 69 was dropped and `principles/technical-principles.md` replaced "Test coverage should not decline" with the mutant rule. diff --git a/todo.md b/todo.md index a8cee2d5..b9f8bf9c 100644 --- a/todo.md +++ b/todo.md @@ -17,14 +17,12 @@ | 233 | 0.4.0 | | | **Run one principles-auditor per round that checks the goals and every principles file that applies, in place of one auditor for each, so the principles pass reads the project once per round.** | 3 | 2 | 3 | 6 | 3 | 1.4 by 3, 1.5 by 2 | 4.9 | | 234 | 0.4.0 | | | **Report the routing figures in dollars, cache reads included, from the cost each archived run records.** | 2 | 2 | 2 | 4 | 3 | 1.4 by 3 | 3.0 | | 239 | 0.4.0 | | owner | **Block a Read, `cat`, `sed` or `head` of a file range already in the session's context, with a note saying so, and let it through once a compaction dropped the range or the file changed.** | 3 | 2 | 3 | 6 | 4 | 1.4 by 3 | 2.0 | -| 236 | 0.5.0 | | question | **Answer whether the principles audit keeps reading the whole project, or reads only the files the chunk changed and their callers, now that half of its πŸ”΄ and 🟑 findings name a file the chunk did not edit.** | 1 | 1 | 1 | 1 | 1 | 1.4 by 4 | 6.4 | -| 240 | 0.5.0 | | question | **Answer whether workers get a reading rule in `CLAUDE.md`: never read more than 80 lines of a file at once, nor take a tool output over 3,000 characters into your context.** | 1 | 2 | 3 | 4 | 1 | 1.4 by 3 | 4.8 | | 226 | 0.5.0 | | question | **Answer whether rule-hook's `run-heavy` rule should also catch a mutation run or docker build behind `uv run`, `poetry run`, `python3 -m`, `sudo`, `docker image build` and `docker compose up --build`, or narrow the `machine load:` decision's wording.** | 2 | 2 | 3 | 5 | 3 | 1.2 by 2, 1.5 by 2 | 4.0 | -| 241 | 0.5.0 | | question | **Answer whether reviewers hand a read over 80 lines to a Haiku scout, which on four replayed stability rounds cut the reviewer's reading by a third and its cost by a tenth, slowed it, and found as many findings as the reviewer finds on its own.** | 2 | 2 | 3 | 5 | 3 | 1.4 by 3 | 3.0 | | 235 | 0.5.0 | | | **Compare the first 20 chunks whose worker ran under the 200k compaction window with the 20 before them, on review rounds past each pass's first, unfinished verdicts, πŸ”΄, 🟑 and misread findings, dollars and hours per chunk, and file an item where any rose.** | 1 | 2 | 1 | 2 | 2 | 1.1 by 2, 1.4 by 3 | 6.8 | | 59 | 0.5.0 | | | **Bound a run of unfinished verdicts on one chunk, so a worker and judge that disagree cannot cycle unattended without end.** | 2 | 1 | 3 | 4 | 3 | 1.4 by 6 | 6.0 | | 167 | 0.5.0 | | | **Refuse a `/security-review` or `/claude-security` Skill call below the project's rung, as rule-hook refuses such an Agent call.** | 3 | 2 | 3 | 6 | 2 | 1.1 by 4 | 5.6 | | 6 | 0.5.0 | | decision | **Move what `loop-claude` writes out of `~/.claude.json`, and ask the human about each write that must stay.** | 3 | 3 | 3 | 7 | 3 | 1.1 by 5 | 5.3 | +| 240 | 0.5.0 | | | **Add a reading rule for workers to `CLAUDE.md` β†’ "Working with the codebase", never read more than 80 lines of a file at once nor take a tool output over 3,000 characters into your context, and compare the 20 chunks after it with the 20 before on review rounds, unfinished verdicts, πŸ”΄, 🟑 and misread findings, dollars and hours per chunk.** | 1 | 2 | 3 | 4 | 2 | 1.4 by 3 | 4.0 | | 1 | 0.6.0 | | question | **Say in README β†’ Install how the transcript archive is backed up, once bender-infra backs up ai-sandbox's data volume.** | 1 | 2 | 1 | 2 | 1 | | 0.0 | | 229 | 0.6.0 | | | **Keep the rule for which commands reach run-heavy's docker beside that docker in `bin/run_heavy/capped_docker.py`, so rule-hook's `docker-run-memory` asks it instead of repeating run-heavy's PATH rules.** | 2 | 1 | 3 | 4 | 2 | code health by 3 | 18.0 | | 219 | 0.6.0 | | | **Name the project's rung `project` in `bin/judge_replay/main.py`, `bin/subagent_rung/main.py` and `bin/review_replay/main.py`, in place of `anchor`, as `bin/model_routing/ladder.py` and `bin/loop_claude` name it.** | 1 | 1 | 3 | 3 | 2 | code health by 2 | 12.0 | @@ -102,22 +100,10 @@ The routing figures count input, cache-written and output tokens, and leave out lilleman's call, 2026-10-27, filed from PR #376's measurement of loop-claude's archive since 2026-10-21: a read of a file the agent read earlier in the thread, more than three messages before and without editing it in between, is 13% of the worker's reading, about $6 of the $45 its reads cost, and 1 to 2% of a reviewer's. How many of those repeat a range exactly is unmeasured, so the figures are a ceiling. A hook on `Read` and on the Bash reads `cat`, `sed` and `head` blocks such a read with a short note that the content is already in context and unchanged. It lets the read through after a compaction, when the content has left the context, or when the file changed since the read. A PreToolUse hook gets a `transcript_path`, which holds the earlier reads and each `compact_boundary`, so it may need no state of its own; check whether a hook inside a subagent gets the subagent's own transcript. A scout only cheapens these re-reads and doesn't remove them, which is why this is a separate item. If scouts ship (`docs/decisions.md` β†’ `loop-claude: the worker's claude compacts its context before it fills a 200k window…` records the trial, and item 241 asks), the same idea applies to scout answers, cached by file and content hash. -### 236. Answer whether the principles audit keeps reading the whole project, or reads only the files the chunk changed and their callers, now that half of its πŸ”΄ and 🟑 findings name a file the chunk did not edit. - -Since 2026-10-21, 342 principles-auditor runs cost $274 at list prices, 23% of all spend, and 176 of their πŸ”΄ and 🟑 findings named a file: 83 a file the chunk edited, 90 another. `docs/decisions.md` β†’ `review: the principles audit runs on every chunk…` holds the whole-project audit valid while its findings are drift a chunk would otherwise merge, and calls a repeat a question on the audit's scope for the human. Reading only the changed files and their callers would cut most of the auditors' $129 of cache writes and drop the findings elsewhere, unless the same findings come back chunk after chunk: read a sample of the 90 before answering. Item 233 merges the auditors either way. - -### 240. Answer whether workers get a reading rule in `CLAUDE.md`: never read more than 80 lines of a file at once, nor take a tool output over 3,000 characters into your context. - -lilleman's question, from PR #376's trials, recorded in `docs/decisions.md` β†’ `loop-claude: the worker's claude compacts its context before it fills a 200k window…`. Three worker-like tasks on this repo, a search, a rename and an explanation, each ran once as workers run today and once under the rule. Under the rule each task read 45% to 60% fewer characters, cost the same or less, and came out as well; of the four runs of the rename, the one under the rule was the only one that also kept the import names sorted. Only 4% of what a worker reads is in a file it later edits. Three tasks say little about real chunks, where a worker that reads less may misread more, and the rule is one line in `CLAUDE.md` that every session loads. A yes ships the line and measures the 20 chunks after it against the 20 before, as item 235 measures the compaction window: review rounds, unfinished verdicts, πŸ”΄, 🟑 and misread findings, dollars and hours per chunk. - ### 226. Answer whether rule-hook's `run-heavy` rule should also catch a mutation run or docker build behind `uv run`, `poetry run`, `python3 -m`, `sudo`, `docker image build` and `docker compose up --build`, or narrow the `machine load:` decision's wording. Found by review of PR #370. Today `uv run mutmut run`, `poetry run mutmut run`, `python3 -m mutmut run`, `sudo docker build .`, `docker image build .` and `docker compose up --build` pass the rule, which `docs/decisions.md` β†’ `machine load: …` and `RULES["run-heavy"]` describe as blocking docker builds and mutation runs. The rule's own text says a gate script isn't checked since no program can tell it from a light one, so the human decides where the line sits. Say what the rule's "checked" text promises either way. Where the answer widens the rule, the change touches `heavy` in `bin/rule_hook/heavy_command.py`, which the comprehension seats found hard: make it easier to read. -### 241. Answer whether reviewers hand a read over 80 lines to a Haiku scout, which on four replayed stability rounds cut the reviewer's reading by a third and its cost by a tenth, slowed it, and found as many findings as the reviewer finds on its own. - -lilleman's question, from PR #376's trials, recorded with the scout's shapes and costs in `docs/decisions.md` β†’ `loop-claude: the worker's claude compacts its context before it fills a 200k window…`. A scout is Haiku 5.5 reading raw content, whole files or long output, and returning facts as path:line and the ranges worth reading; in session it is an agent under `agents/`, and as a slim headless `claude -p` on the subscription login it starts at 6k tokens in 3 to 5 seconds. On four replayed stability rounds the agent scout found 5 of 6 archived findings against the baseline's 4 and read 29% fewer characters at 6% less cost and 14% more time; the CLI scout 4 of 6, 38% fewer, 17% less and 39% more; the auditors with the agent scout 3 of 6, the πŸ”΄ among the lost, at the same cost and twice the time. The reviewers under `agents/` spent $646 of the $1,215 since 2026-10-21, so a tenth off is about $65 per 90 chunks. `AGENTS.md` makes a change to the delegation rule lilleman's call. A yes names the shape, agent or CLI, and which reviewers, and measures the 20 chunks after it against the 20 before, as item 235 measures the compaction window. - ### 235. Compare the first 20 chunks whose worker ran under the 200k compaction window with the 20 before them, on review rounds past each pass's first, unfinished verdicts, πŸ”΄, 🟑 and misread findings, dollars and hours per chunk, and file an item where any rose. `docs/decisions.md` β†’ `loop-claude: the worker's claude compacts its context before it fills a 200k window…` expects a saving of about 6% of all spend with no rise in the other figures. Measure from loop-claude's archive as that decision did: rounds past each pass's first and the πŸ”΄, 🟑 and misread counts from the round commit titles, unfinished verdicts from the outcomes files, hours from the worker's first message to its last, and dollars at list prices, cache reads included, from the chunk's `cost-state` entry, which counts the compaction calls that no message's usage records; item 234 puts such dollars into the routing figures. A chunk ran under the window when its first worker started after that decision merged. @@ -134,6 +120,10 @@ rule-hook checks Agent calls (item 163) but no Skill calls. A worker that invoke Claude Code owns that file and writes it. `trust` reads it, changes it and writes it back, so a write that lands in between is lost. +### 240. Add a reading rule for workers to `CLAUDE.md` β†’ "Working with the codebase", never read more than 80 lines of a file at once nor take a tool output over 3,000 characters into your context, and compare the 20 chunks after it with the 20 before on review rounds, unfinished verdicts, πŸ”΄, 🟑 and misread findings, dollars and hours per chunk. + +lilleman's call, 2026-10-27, answering PR #376's trials, recorded in `docs/decisions.md` β†’ `loop-claude: the worker's claude compacts its context before it fills a 200k window…`. Three worker-like tasks on this repo, a search, a rename and an explanation, each ran once as workers run today and once under the rule: under it each task read 45% to 60% fewer characters, cost the same or less, and came out as well, and of the four runs of the rename, the one under the rule was the only one that also kept the import names sorted. Only 4% of what a worker reads is in a file it later edits. The line goes to `CLAUDE.md` β†’ "Working with the codebase", which every session loads, so a worker that reads less may misread more: measure the 20 chunks after the line merges against the 20 before, as item 235 measures the compaction window, and drop the line where any of those figures rose. + ### 1. Say in README β†’ Install how the transcript archive is backed up, once bender-infra backs up ai-sandbox's data volume. 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. -- 2.52.0 From c36d7a2f9c352a299b33ea1780c0bf9cd291e44a Mon Sep 17 00:00:00 2001 From: Lilleman auf Larv Date: Tue, 27 Oct 2026 09:13:00 +0100 Subject: [PATCH 14/14] =?UTF-8?q?Answer=20prose=20round=203:=200=20?= =?UTF-8?q?=F0=9F=94=B4,=208=20=F0=9F=9F=A1=20(0=20misread);=20put=20the?= =?UTF-8?q?=20reading=20rule=20in=20the=20worker's=20prompt,=20quote=20it,?= =?UTF-8?q?=20mark=20the=20items=20the=20decision=20cites,=20name=20the=20?= =?UTF-8?q?whole-project=20reading=20in=20the=20audit=20decision's=20title?= =?UTF-8?q?,=20and=20state=20each=20answer=20once?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- AGENTS.md | 2 +- docs/decisions.md | 22 +++++++++++----------- todo.md | 14 +++++++------- 3 files changed, 19 insertions(+), 19 deletions(-) diff --git a/AGENTS.md b/AGENTS.md index aa6f454d..2cf8cb51 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -35,7 +35,7 @@ Decisions live in `docs/decisions.md`: - review: stability and product-owner report only a defect, a broken requirement of the plan or the goals, a breach of a technical principle, or for stability a hard place the change touches; each architect finding names a later change the PR makes harder; prose runs only on a chunk that changes prose - review: the comprehension check records how hard a project is to read and blocks no merge: a paired ruling against the last measured commit where the architecture pass ran, and the four-seat scoring run, once when an item names the floor and twice on one head when a release's items run out - review: the premises chunk's whole review is the human's approval -- review: the principles audit runs on every chunk that changes code, config or tests, and on no other chunk +- review: the principles audit runs on every chunk that changes code, config or tests, reads the project whole, and runs on no other chunk - review: the stability pass mutation-tests the lines a chunk changes, in place of measuring test coverage - routing: a chunk's worker runs on the rung its item's L picks, below the project's rung too; its reviewers run on the highest of the worker's rung, the project's and the one picked by the highest E + I among the chunk's items, unless a replay lowered their pass; the seats and the security pass always on the project's - routing: a review pass runs below the project's rung only on a rung that a replay of its rounds shows finding every πŸ”΄ and 🟑 the project's rung finds, and only where the E + I steps no review up and the worker runs no higher than the project's rung, then even below the worker's; no pass has such a rung diff --git a/docs/decisions.md b/docs/decisions.md index 28e1cada..73072a3f 100644 --- a/docs/decisions.md +++ b/docs/decisions.md @@ -74,28 +74,28 @@ The cap is 5, `bin/todo_table.py`'s `BUNDLE_MAX_R`, from the same chunks: by the ## loop-claude: the worker's claude compacts its context before it fills a 200k window, at about 170k tokens, and `CLAUDE.md` β†’ "Compact instructions" says what the summary keeps -2026-10-27, lilleman's yes, typed that day, to the evaluation claude made through todo item 231. Serves goal 1.4; its counter-signal, review rounds and unfinished verdicts per chunk, is the check. +2026-10-27, lilleman's yes to claude's evaluation through todo todo item 231. Serves goal 1.4; its counter-signal, review rounds and unfinished verdicts per chunk, is the check. loop-claude hands each worker's claude `CLAUDE_CODE_AUTO_COMPACT_WINDOW=200000` (`bin/loop_claude/cycle/worker.py`), and the session /talk opens gets it too. Claude Code compacts before a window fills: a 1M window at about 967k tokens, and in a probe on 2026-10-27 a 100k window at 65k and 80k, so a 200k window compacts at about 170k. The window is not set in `settings.json`, since the archive measured loop-claude's workers and interactive sessions are lilleman's. Subagents inherit the variable, which reaches every process of the session: 68 of the 994 subagent runs since 2026-10-21, 7%, passed 170k, 24 of them principles auditors, so about one in fourteen compacts once. Compacting subagents by choice would cost more than it saves, as below, but the variable cannot leave them out, and `CLAUDE.md` β†’ "Compact instructions" has a reviewer keep the findings it has drafted. That section shapes the summary: in another probe that day, a session whose CLAUDE.md asked for its summary to end with a secret word got a summary ending with that word. Path-scoped rules leave the context at a compaction and return at the next matching read, and rule-hook holds each review launch to its rung whatever the summary keeps. `CLAUDE_CODE_DISABLE_1M_CONTEXT=1`, handed the same way, would compact at the same point but also cap the window at 200k, so a run that Claude Code stops compacting, as it does when one tool result refills the context each time, would hit the limit instead of going on. Why 200k. Item 231 asked for the best means to lower what a chunk spends on context, in dollars, then hours, with no loss of quality. Measured from loop-claude's archive, the 90 chunks with messages after the routing figures' reset of 2026-10-21 cost $1,215 at the list prices read on 2026-10-26 (Opus 5.5: $4 per million input tokens, $5 and $8 for 5-minute and 1-hour cache writes, $0.20 for cache reads, $20 for output; no model but Haiku 5.5 charges more above 200k). That is 0.86 of what the chunks' `cost-state` entries sum to, since some chunks' subagent transcripts are not in the archive. Worker main threads cost $375 (31%): 1-hour cache writes $149, cache reads $153, output $74. Subagents cost $840: 5-minute cache writes $379, output $274, cache reads $187, with the principles auditors at $274 over 342 runs, the stability reviewers $179 and general-purpose subagents $192. A worker starts at 41k tokens of context and peaks at a median 167k, one in ten past 358k, the largest at 848k. The worker's messages above 200k were 32% of its messages and 55% of its cost. -What reads cost, and whether a tool cuts them, measured at lilleman's ask after those figures: no tool cut a reviewer's reading without losing a finding, except a scout, whose findings stayed within what the same reviewer finds twice; so none of them ships here. lilleman chose on 2026-10-27: workers trial a reading rule (item 240), and reviewers get no scout. Two measures of reading: the characters a thread read, 93M in all, about 27M tokens; and the new input tokens of the messages that took results in, charged to those results, which also count what arrives beside a result, such as the agent's own previous reply. By the second measure tool results caused $620 of the $1,215, and reads (Read, Bash reads, Grep, Glob and git's diff, show and log) $537 of that: the worker's reads $140 (Bash reads $115, Read $12) of its $190 of results, the principles auditors' $133 (Read $109, Grep $22) of $139, the stability reviewers' $97 (Bash reads $79) of $106, general-purpose subagents' $84 of $97, the prose reviewers' $32, the architects' $30 and the product-owner reviewers' $21. By the first measure the worker's reads are about $45. Precision is low everywhere: of the characters a principles auditor read, 13% were in a file its report names; a stability reviewer 8%; a prose reviewer 18%; an architect 11%; the worker 4% in a file it later edited. Reading is mostly to find things and to learn what a project holds. The worker's `sed` ranges are small, median 25 lines, one in ten over 80. Of the worker's read characters, 49% were of a file it had read earlier in the thread: 36% within three messages, paging through it, and 13% later, with the file unchanged, about $6 of the $45; a reviewer's later reads of an unchanged file it had read are 1 to 2% (item 239). +What reads cost, and whether a tool cuts them, measured at lilleman's ask after those figures: no tool cut a reviewer's reading without losing a finding, except a scout, which kept the stability reviewers' findings but lost the auditors' πŸ”΄ and slowed every round; so none of them ships here. lilleman chose on 2026-10-27: workers trial a reading rule (`todo.md` item 240), reviewers get no scout, and the principles audit keeps reading the project whole. Two measures of reading: the characters a thread read, 93M in all, about 27M tokens; and the new input tokens of the messages that took results in, charged to those results, which also count what arrives beside a result, such as the agent's own previous reply. By the second measure tool results caused $620 of the $1,215, and reads (Read, Bash reads, Grep, Glob and git's diff, show and log) $537 of that: the worker's reads $140 (Bash reads $115, Read $12) of its $190 of results, the principles auditors' $133 (Read $109, Grep $22) of $139, the stability reviewers' $97 (Bash reads $79) of $106, general-purpose subagents' $84 of $97, the prose reviewers' $32, the architects' $30 and the product-owner reviewers' $21. By the first measure the worker's reads are about $45. Precision is low everywhere: of the characters a principles auditor read, 13% were in a file its report names; a stability reviewer 8%; a prose reviewer 18%; an architect 11%; the worker 4% in a file it later edited. Reading is mostly to find things and to learn what a project holds. The worker's `sed` ranges are small, median 25 lines, one in ten over 80. Of the worker's read characters, 49% were of a file it had read earlier in the thread: 36% within three messages, paging through it, and 13% later, with the file unchanged, about $6 of the $45; a reviewer's later reads of an unchanged file it had read are 1 to 2% (`todo.md` item 239). -The trials: four stability rounds and five principles rounds archived on 2026-10-23, each holding πŸ”΄ or 🟑 findings, replayed on the project's rung as `review-replay` replays them, with the reviewer's definition changed through `--agents`; and three worker-like tasks, a search, a rename and an explanation, run on fresh clones at the project's rung. The baseline, the reviewer as it is, found 4 of its own 6 archived findings in each pass, so a variant that finds 4 or 5 of 6 does what the same reviewer does twice. The options item 231 named, each simulated on the 90 chunks and, where lilleman asked, tried: +The trials: four stability rounds and five principles rounds archived on 2026-10-23, each holding πŸ”΄ or 🟑 findings, replayed on the project's rung as `review-replay` replays them, with the reviewer's definition changed through `--agents`; and three worker-like tasks, a search, a rename and an explanation, run on fresh clones at the project's rung. The baseline, the reviewer as it is, found 4 of its own 6 archived findings in each pass, so a variant that finds 4 or 5 of 6 does what the same reviewer does twice. The options todo item 231 named, each simulated on the 90 chunks and, where lilleman asked, tried: - Compaction of the worker. The saving and the compactions per chunk, by the point it compacts at: 150k saves $75 at 1.0 compactions; 167k to 180k, where a 200k window compacts, $77 to $78 at 0.8 to 0.7; 200k $78 at 0.5; 300k $54 at 0.2. $78 is 21% of the workers' $375 and 6% of all spend. Compaction also caps the 36 re-writes of a whole context after a gap longer than the cache's hour or a change of rung: they cost $61, up to 785k tokens each, and would cost about $34. Compacting subagents at 150k costs more than it saves, since a compaction reads the context once more and writes a summary, and subagents are short. - A fresh context for the review phase, handed 60k tokens of facts, saves $39. A compaction at 170k saves that too, and loop-claude would need a second session per chunk. -- Read with an offset and a limit, or Grep, in place of `cat`, `sed` and `head`. Steering the tool would not change how much is read: the worker's `sed` ranges are small already, and only 13% of its Bash-read characters came from whole files. A rule on how much to read did change it: under "never read more than 80 lines of a file at once, nor take a tool output over 3,000 characters into your context", the three worker tasks read 45% to 60% fewer characters at the same or lower cost, every task done as well, and the rename was the one run of four that also kept the import names sorted; item 240 trials the rule on workers. A stability reviewer under the same rule with an `outline` script on PATH, which prints a file's symbols with their line ranges, read 4% less and found 2 of 6 findings, and the workers never ran the script. +- Read with an offset and a limit, or Grep, in place of `cat`, `sed` and `head`. Steering the tool would not change how much is read: the worker's `sed` ranges are small already, and only 13% of its Bash-read characters came from whole files. A rule on how much to read did change it: under "never read more than 80 lines of a file at once, nor take a tool output over 3,000 characters into your context", the three worker tasks read 45% to 60% fewer characters at the same or lower cost, every task done as well, and the rename was the one run of four that also kept the import names sorted (`todo.md` item 240). A stability reviewer under the same rule with an `outline` script on PATH, which prints a file's symbols with their line ranges, read 4% less and found 2 of 6 findings, and the workers never ran the script. - Code-intelligence tooling: the `LSP` tool, through a pyright plugin built from the marketplace manifest with `pyright-langserver` on PATH, answers a file's symbols, a definition or the references in a few hundred characters. Under a rule telling them to use it, the stability reviewers and the workers never called it; the auditors did, read as much or more, and missed the one πŸ”΄, 0 of 1 against the baseline's 1 of 1. Each machine would also need a server per language (goal 2). Not worth an item. - A cap on tool results. Claude Code caps a Bash result at about 30k characters already. A PostToolUse hook capping it at 12k, which `updatedToolOutput` allows, left the stability reviewers 3 of 6 findings, two lost in one round. Read results, 59.9M characters in subagents' threads with 58% of their characters in results over 12k, are out of such a hook's reach. Not worth an item. -- A scout: Haiku 5.5 reading raw content, whole files or long output, and returning facts as path:line and the ranges worth reading, so the agent's own context holds the summary and the chosen lines. In session, as an agent under `agents/`, its first request writes 37k tokens, $0.005, and a read of a 38KB file costs $0.008 in 8 seconds. As a slim headless `claude -p` with its own system prompt, no setting sources and no dynamic sections, which keeps the subscription login, it starts at 6k tokens and $0.0003 in 3 to 5 seconds, its prefix cached across calls, and the same read costs $0.004 in 7 seconds; a direct API call and `claude --bare` need an API key, so they are out. Stability reviewers with the agent scout found 5 of 6 findings and read 29% fewer characters at 6% less cost and 14% more time; with the CLI scout 4 of 6, 38% fewer, 17% less and 39% more; the auditors with the agent scout 3 of 6, the πŸ”΄ among the lost, at the same cost and twice the time. Workers offered the scout never called it. On 2026-10-27 lilleman said no to a scout for reviewers: the saving sits within the reviewer's own spread, the auditors lost the πŸ”΄, and every round ran slower. The delegation rule stands as `routing: a worker delegates a task only where it needs just the task's conclusion…` records. -- What a reviewer reads: the auditors read the project whole by design. Of their πŸ”΄ and 🟑 findings since the reset, 47% named a file the chunk edited and 51% another file, so reading only the change would drop half of them; on 2026-10-27 lilleman kept the whole-project reading (`review: the principles audit runs on every chunk that changes code, config or tests, and on no other chunk`), and item 233 has one auditor read the project once per round. -- The base context: every thread starts with `~/.claude/CLAUDE.md` (19k characters), `~/.claude/AGENTS.md` (11k, this repo's decisions, which Claude Code loads as user instructions into every project's sessions; item 52), the project's `AGENTS.md`, and, for the worker and general-purpose subagents, the skill listing (18k) and the agent listing (12k). Subagents' first messages wrote $97 of it. Trimming the listings would save about $20, 2%, and is not worth an item: `disableBundledSkills` would also drop `/security-review`, the security pass of record. +- A scout: Haiku 5.5 reading raw content, whole files or long output, and returning facts as path:line and the ranges worth reading, so the agent's own context holds the summary and the chosen lines. In session, as an agent under `agents/`, its first request writes 37k tokens, $0.005, and a read of a 38KB file costs $0.008 in 8 seconds. As a slim headless `claude -p` with its own system prompt, no setting sources and no dynamic sections, which keeps the subscription login, it starts at 6k tokens and $0.0003 in 3 to 5 seconds, its prefix cached across calls, and the same read costs $0.004 in 7 seconds; a direct API call and `claude --bare` need an API key, so they are out. Stability reviewers with the agent scout found 5 of 6 findings and read 29% fewer characters at 6% less cost and 14% more time; with the CLI scout 4 of 6, 38% fewer, 17% less and 39% more; the auditors with the agent scout 3 of 6, the πŸ”΄ among the lost, at the same cost and twice the time. Workers offered the scout never called it. +- What a reviewer reads: the auditors read the project whole by design. Of their πŸ”΄ and 🟑 findings since the reset, 47% named a file the chunk edited and 51% another file, so reading only the change would drop half of them (`review: the principles audit runs on every chunk that changes code, config or tests, reads the project whole, and runs on no other chunk`); `todo.md` item 233 has one auditor read the project once per round. +- The base context: every thread starts with `~/.claude/CLAUDE.md` (19k characters), `~/.claude/AGENTS.md` (11k, this repo's decisions, which Claude Code loads as user instructions into every project's sessions; `todo.md` item 52), the project's `AGENTS.md`, and, for the worker and general-purpose subagents, the skill listing (18k) and the agent listing (12k). Subagents' first messages wrote $97 of it. Trimming the listings would save about $20, 2%, and is not worth an item: `disableBundledSkills` would also drop `/security-review`, the security pass of record. -Quality. 19 chunks compacted between 2026-10-10 and 2026-10-22, at the compaction points Claude Code set then, 214k to 972k tokens. Per 100 worker messages they took a median 3.6 review rounds past each pass's first against 4.0 for the 68 uncompacted chunks of 100 messages or more, and 13.9 πŸ”΄ and 🟑 findings against 16.6. 4 of 19 had an unfinished verdict against 3 of 68, each 8 to 10 hours after the compaction and followed by a finished verdict within minutes; in those four verdicts the judge quoted the worker's own passages and the human's typed answers, never a summary. One cause was possible and is closed here: Claude Code writes the summary as a user entry, which `bin/claude_code/entries.py` read as the human's words, so the judge would see a `[human]` line of thousands of words and `/talk` would count it as typed; it now reads as Claude Code's. Whether compaction raises unfinished verdicts stays open until item 235 measures it. Two summaries read whole kept the chunk's intent, files, errors and next step in 12k to 20k characters, and the worker resumed without re-reading. +Quality. 19 chunks compacted between 2026-10-10 and 2026-10-22, at the compaction points Claude Code set then, 214k to 972k tokens. Per 100 worker messages they took a median 3.6 review rounds past each pass's first against 4.0 for the 68 uncompacted chunks of 100 messages or more, and 13.9 πŸ”΄ and 🟑 findings against 16.6. 4 of 19 had an unfinished verdict against 3 of 68, each 8 to 10 hours after the compaction and followed by a finished verdict within minutes; in those four verdicts the judge quoted the worker's own passages and the human's typed answers, never a summary. One cause was possible and is closed here: Claude Code writes the summary as a user entry, which `bin/claude_code/entries.py` read as the human's words, so the judge would see a `[human]` line of thousands of words and `/talk` would count it as typed; it now reads as Claude Code's. Whether compaction raises unfinished verdicts stays open until `todo.md` item 235 measures it. Two summaries read whole kept the chunk's intent, files, errors and next step in 12k to 20k characters, and the worker resumed without re-reading. -Hours. A chunk ran a median 0.7 hours from its first message to its last, one in ten past 12 hours, mostly waiting for the human or a usage limit. No option here changes that: a compaction takes 51 to 83 seconds, under a minute per chunk at 0.7 each, and a smaller context saves seconds per turn at most. The hours lever is item 232, since waiting on subagents took 66% of a worker's active time. +Hours. A chunk ran a median 0.7 hours from its first message to its last, one in ten past 12 hours, mostly waiting for the human or a usage limit. No option here changes that: a compaction takes 51 to 83 seconds, under a minute per chunk at 0.7 each, and a smaller context saves seconds per turn at most. The hours lever is `todo.md` item 232, since waiting on subagents took 66% of a worker's active time. Valid while cache reads cost a twentieth of input and Claude Code's compaction keeps the worker's task. @@ -223,11 +223,11 @@ The base is the last measured commit: the default branch's newest merged change 2026-09-20, lilleman. Serves goal 1.1. A reviewer's finding on that chunk could only be declined by citing the goals the chunk exists to write. Valid while every decline must name a goal or a technical principle. -## review: the principles audit runs on every chunk that changes code, config or tests, and on no other chunk +## review: the principles audit runs on every chunk that changes code, config or tests, reads the project whole, and runs on no other chunk 2026-10-16, lilleman, answering the question on the audit's trigger that the plan held. Serves goal 1.1: a principle that no chunk checks drifts, as the stability reviewer's own copy of the principles drifted from them, until it applied `principles/technical-principles.md` as written. It costs goal 1.4: a chunk that changes code, config or tests launches one auditor for the goals and one per applicable principles file, and a code fix re-enters them. The human accepted that cost. The cost shows in tokens per finished chunk and in review rounds per chunk. Valid while the audit's findings are drift a chunk would otherwise merge, not the same whole-project findings repeated chunk after chunk: a repeat is a question on the audit's scope for the human. -2026-10-27, lilleman, asked through PR #376: the audit keeps reading the project whole. Since 2026-10-21, 342 auditor runs cost $274 at list prices, and of their 176 πŸ”΄ and 🟑 findings that named a file, 90 named one the chunk did not edit; reading only the changed files and their callers would have dropped those, and lilleman keeps them. Item 233 still has one auditor read the project once per round. +2026-10-27, lilleman, answering the question PR #376 raised: the audit keeps reading the project whole. Since 2026-10-21, 342 auditor runs cost $274 at list prices, and of their 176 πŸ”΄ and 🟑 findings that named a file, 90 named one the chunk did not edit, which reading only the change would drop; lilleman keeps them. ## review: the stability pass mutation-tests the lines a chunk changes, in place of measuring test coverage diff --git a/todo.md b/todo.md index b9f8bf9c..022f0307 100644 --- a/todo.md +++ b/todo.md @@ -12,17 +12,17 @@ | ID | Release | Blocked by | Exempt | Item | L | E | I | R | S | Moves | Score | |---|---|---|---|---|---|---|---|---|---|---|---| -| 232 | 0.4.0 | | | **Launch a round's review passes in one message, except a pass that must wait for another's findings, so a round lasts about as long as its slowest reviewers, not their sum.** | 3 | 2 | 3 | 6 | 3 | 1.5 by 6 | 5.8 | +| 232 | 0.4.0 | | decision | **Launch a round's review passes in one message, except a pass that must wait for another's findings, so a round lasts about as long as its slowest reviewers, not their sum.** | 3 | 2 | 3 | 6 | 3 | 1.5 by 6 | 5.8 | | 238 | 0.4.0 | | defect | **Run the security pass's skill in the chunk's worktree, so it scans the branch's diff: invoked from a subagent, it runs in the session's working directory, the main checkout, and scans nothing.** | 2 | 2 | 3 | 5 | 3 | 1.1 by 5 | 5.3 | -| 233 | 0.4.0 | | | **Run one principles-auditor per round that checks the goals and every principles file that applies, in place of one auditor for each, so the principles pass reads the project once per round.** | 3 | 2 | 3 | 6 | 3 | 1.4 by 3, 1.5 by 2 | 4.9 | +| 233 | 0.4.0 | | decision | **Run one principles-auditor per round that checks the goals and every principles file that applies, in place of one auditor for each, so the principles pass reads the project once per round.** | 3 | 2 | 3 | 6 | 3 | 1.4 by 3, 1.5 by 2 | 4.9 | | 234 | 0.4.0 | | | **Report the routing figures in dollars, cache reads included, from the cost each archived run records.** | 2 | 2 | 2 | 4 | 3 | 1.4 by 3 | 3.0 | | 239 | 0.4.0 | | owner | **Block a Read, `cat`, `sed` or `head` of a file range already in the session's context, with a note saying so, and let it through once a compaction dropped the range or the file changed.** | 3 | 2 | 3 | 6 | 4 | 1.4 by 3 | 2.0 | | 226 | 0.5.0 | | question | **Answer whether rule-hook's `run-heavy` rule should also catch a mutation run or docker build behind `uv run`, `poetry run`, `python3 -m`, `sudo`, `docker image build` and `docker compose up --build`, or narrow the `machine load:` decision's wording.** | 2 | 2 | 3 | 5 | 3 | 1.2 by 2, 1.5 by 2 | 4.0 | -| 235 | 0.5.0 | | | **Compare the first 20 chunks whose worker ran under the 200k compaction window with the 20 before them, on review rounds past each pass's first, unfinished verdicts, πŸ”΄, 🟑 and misread findings, dollars and hours per chunk, and file an item where any rose.** | 1 | 2 | 1 | 2 | 2 | 1.1 by 2, 1.4 by 3 | 6.8 | +| 235 | 0.5.0 | | decision | **Compare the first 20 chunks whose worker ran under the 200k compaction window with the 20 before them, on review rounds past each pass's first, unfinished verdicts, πŸ”΄, 🟑 and misread findings, dollars and hours per chunk, and file an item where any rose.** | 1 | 2 | 1 | 2 | 2 | 1.1 by 2, 1.4 by 3 | 6.8 | | 59 | 0.5.0 | | | **Bound a run of unfinished verdicts on one chunk, so a worker and judge that disagree cannot cycle unattended without end.** | 2 | 1 | 3 | 4 | 3 | 1.4 by 6 | 6.0 | | 167 | 0.5.0 | | | **Refuse a `/security-review` or `/claude-security` Skill call below the project's rung, as rule-hook refuses such an Agent call.** | 3 | 2 | 3 | 6 | 2 | 1.1 by 4 | 5.6 | | 6 | 0.5.0 | | decision | **Move what `loop-claude` writes out of `~/.claude.json`, and ask the human about each write that must stay.** | 3 | 3 | 3 | 7 | 3 | 1.1 by 5 | 5.3 | -| 240 | 0.5.0 | | | **Add a reading rule for workers to `CLAUDE.md` β†’ "Working with the codebase", never read more than 80 lines of a file at once nor take a tool output over 3,000 characters into your context, and compare the 20 chunks after it with the 20 before on review rounds, unfinished verdicts, πŸ”΄, 🟑 and misread findings, dollars and hours per chunk.** | 1 | 2 | 3 | 4 | 2 | 1.4 by 3 | 4.0 | +| 240 | 0.5.0 | | decision | **Give loop-claude's worker prompt the reading rule "never read more than 80 lines of a file at once, nor take a tool output over 3,000 characters into your context", and keep it only where the 20 chunks after it hold the 20 before's review rounds, unfinished verdicts, πŸ”΄, 🟑 and misread findings, dollars and hours per chunk.** | 1 | 2 | 3 | 4 | 2 | 1.4 by 3 | 4.0 | | 1 | 0.6.0 | | question | **Say in README β†’ Install how the transcript archive is backed up, once bender-infra backs up ai-sandbox's data volume.** | 1 | 2 | 1 | 2 | 1 | | 0.0 | | 229 | 0.6.0 | | | **Keep the rule for which commands reach run-heavy's docker beside that docker in `bin/run_heavy/capped_docker.py`, so rule-hook's `docker-run-memory` asks it instead of repeating run-heavy's PATH rules.** | 2 | 1 | 3 | 4 | 2 | code health by 3 | 18.0 | | 219 | 0.6.0 | | | **Name the project's rung `project` in `bin/judge_replay/main.py`, `bin/subagent_rung/main.py` and `bin/review_replay/main.py`, in place of `anchor`, as `bin/model_routing/ladder.py` and `bin/loop_claude` name it.** | 1 | 1 | 3 | 3 | 2 | code health by 2 | 12.0 | @@ -98,7 +98,7 @@ The routing figures count input, cache-written and output tokens, and leave out ### 239. Block a Read, `cat`, `sed` or `head` of a file range already in the session's context, with a note saying so, and let it through once a compaction dropped the range or the file changed. -lilleman's call, 2026-10-27, filed from PR #376's measurement of loop-claude's archive since 2026-10-21: a read of a file the agent read earlier in the thread, more than three messages before and without editing it in between, is 13% of the worker's reading, about $6 of the $45 its reads cost, and 1 to 2% of a reviewer's. How many of those repeat a range exactly is unmeasured, so the figures are a ceiling. A hook on `Read` and on the Bash reads `cat`, `sed` and `head` blocks such a read with a short note that the content is already in context and unchanged. It lets the read through after a compaction, when the content has left the context, or when the file changed since the read. A PreToolUse hook gets a `transcript_path`, which holds the earlier reads and each `compact_boundary`, so it may need no state of its own; check whether a hook inside a subagent gets the subagent's own transcript. A scout only cheapens these re-reads and doesn't remove them, which is why this is a separate item. If scouts ship (`docs/decisions.md` β†’ `loop-claude: the worker's claude compacts its context before it fills a 200k window…` records the trial, and item 241 asks), the same idea applies to scout answers, cached by file and content hash. +lilleman's call, 2026-10-27, filed from PR #376's measurement of loop-claude's archive since 2026-10-21: a read of a file the agent read earlier in the thread, more than three messages before and without editing it in between, is 13% of the worker's reading, about $6 of the $45 its reads cost, and 1 to 2% of a reviewer's. How many of those repeat a range exactly is unmeasured, so the figures are a ceiling. A hook on `Read` and on the Bash reads `cat`, `sed` and `head` blocks such a read with a short note that the content is already in context and unchanged. It lets the read through after a compaction, when the content has left the context, or when the file changed since the read. A PreToolUse hook gets a `transcript_path`, which holds the earlier reads and each `compact_boundary`, so it may need no state of its own; check whether a hook inside a subagent gets the subagent's own transcript. ### 226. Answer whether rule-hook's `run-heavy` rule should also catch a mutation run or docker build behind `uv run`, `poetry run`, `python3 -m`, `sudo`, `docker image build` and `docker compose up --build`, or narrow the `machine load:` decision's wording. @@ -120,9 +120,9 @@ rule-hook checks Agent calls (item 163) but no Skill calls. A worker that invoke Claude Code owns that file and writes it. `trust` reads it, changes it and writes it back, so a write that lands in between is lost. -### 240. Add a reading rule for workers to `CLAUDE.md` β†’ "Working with the codebase", never read more than 80 lines of a file at once nor take a tool output over 3,000 characters into your context, and compare the 20 chunks after it with the 20 before on review rounds, unfinished verdicts, πŸ”΄, 🟑 and misread findings, dollars and hours per chunk. +### 240. Give loop-claude's worker prompt the reading rule "never read more than 80 lines of a file at once, nor take a tool output over 3,000 characters into your context", and keep it only where the 20 chunks after it hold the 20 before's review rounds, unfinished verdicts, πŸ”΄, 🟑 and misread findings, dollars and hours per chunk. -lilleman's call, 2026-10-27, answering PR #376's trials, recorded in `docs/decisions.md` β†’ `loop-claude: the worker's claude compacts its context before it fills a 200k window…`. Three worker-like tasks on this repo, a search, a rename and an explanation, each ran once as workers run today and once under the rule: under it each task read 45% to 60% fewer characters, cost the same or less, and came out as well, and of the four runs of the rename, the one under the rule was the only one that also kept the import names sorted. Only 4% of what a worker reads is in a file it later edits. The line goes to `CLAUDE.md` β†’ "Working with the codebase", which every session loads, so a worker that reads less may misread more: measure the 20 chunks after the line merges against the 20 before, as item 235 measures the compaction window, and drop the line where any of those figures rose. +lilleman's call, 2026-10-27, answering PR #376's trials, recorded in `docs/decisions.md` β†’ `loop-claude: the worker's claude compacts its context before it fills a 200k window…`: three worker-like tasks each ran four ways, as workers run today, with an outline tool, with the LSP tool and under the rule, and only the rule cut reading, by 45% to 60%, at the same or lower cost and with the tasks done as well. The rule is for workers, so it goes into the prompt loop-claude gives a chunk's worker (`bin/loop_claude/cycle/prompts.py`), not into `CLAUDE.md`, which reviewers load too and where the one reviewer run under a like rule found 2 of 6 findings. A worker that reads less may misread more, so measure the 20 chunks after the rule merges against the 20 before, as item 235 measures the compaction window, and drop the rule where any of those figures rose. ### 1. Say in README β†’ Install how the transcript archive is backed up, once bender-infra backs up ai-sandbox's data volume. -- 2.52.0