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.