From 610cd63ba6e2aa1063a2625ffe8b5c1ad3b365fe Mon Sep 17 00:00:00 2001 From: Lilleman auf Larv Date: Sat, 31 Oct 2026 01:27:34 +0100 Subject: [PATCH 1/6] Make chunk-preflight create the item's worktree only with --worktree, which loop-claude passes --- CHANGELOG.md | 1 + README.md | 2 +- bin/chunk_preflight/main.py | 48 +++++++++++---------- bin/chunk_preflight/test_chunk_preflight.py | 42 ++++++++++++------ bin/loop_claude/loop/main.py | 14 +++--- bin/loop_claude/test_loop_claude.py | 4 +- docs/reading-cost.md | 17 ++++++++ todo.md | 5 --- 8 files changed, 84 insertions(+), 49 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9d3edcb0..6798be52 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,7 @@ ## Unreleased +- A bare run of `chunk-preflight` now only prints the facts: it makes no worktree or branch for the item and runs no tool in one. `chunk-preflight --worktree` makes them and runs the tools, as `loop-claude` now asks for each chunk. Before, every run that found an item added the worktree `-item-` and the branch `item-`, which a run for the facts alone left to remove. - A release review now fixes the findings of its architecture and principles passes in the release it reviews. Before, it filed each one in `todo.md`, so the release held the drift the review had found. It files only three kinds of finding, each under the release being reviewed: one whose fix needs a human answer, marked `question`; one whose fix adds a feature; and one whose fix the five rounds cannot finish. Until each is done, the release isn't ready to cut. - In a repo with no tag yet, `chunk-preflight` now calls a release finished once `todo.md` files no item under it: its release review is due, and no later release's item is taken. Before, it lost sight of such a release. - In a run `loop-claude` started, `rule-hook` now refuses a `/security-review` or `/claude-security` Skill call that the worker makes in its own context on a rung below the project's. It also refuses one from any subagent whose prompt doesn't open with `You are the security pass for this chunk.`, since that subagent's rung is unchecked. The refusal says to invoke the skill from a subagent on the project's rung, its prompt opening with that sentence. Before, only an Agent call that launched the security pass was held to that rung. diff --git a/README.md b/README.md index b8f30e02..ab1ce17e 100644 --- a/README.md +++ b/README.md @@ -87,7 +87,7 @@ In `~/code/claude-config`, rename `## Unreleased` in `CHANGELOG.md` to the versi Install puts only `loop-claude` and `loop-inbox` on `PATH`; call the others by their path, such as `~/.claude/bin/metric-bench`, from the project's checkout. Those under `~/.claude` are the release's; test a change to one from `~/code/claude-config/bin`. -- `chunk-preflight` finds the mechanical facts a chunk starts from and makes its worktree; `loop-claude` runs it before it routes each chunk, and `chunk-preflight --help` lists the facts. +- `chunk-preflight` finds the mechanical facts a chunk starts from, and with `--worktree` makes its worktree; `loop-claude` runs it with `--worktree` before it routes each chunk, and `chunk-preflight --help` lists the facts. - `deploy-release []` moves `~/.claude`, or the checkout named, to the newest release, as Update says. - `judge-replay ` replays loop-claude's judge on archived verdicts of the projects run on the model, and prints the lowest rung that, like each rung above it, returns them; `judge-replay --help` states the replay. - `larv-review ` holds larv-review's mechanical rules: the chunk's review folder, the paired ruling's base and vote count, each pass's round count, the scoring run's trigger, and the comprehension history's format and latest places, and its count of how often seats agree; `larv-review --help` states them. diff --git a/bin/chunk_preflight/main.py b/bin/chunk_preflight/main.py index 87327a73..8eb6c425 100644 --- a/bin/chunk_preflight/main.py +++ b/bin/chunk_preflight/main.py @@ -1,8 +1,9 @@ -"""Find the mechanical facts a chunk starts from, and make its worktree, so its worker starts from them. +"""Find the mechanical facts a chunk starts from, and, with --worktree, make its worktree, so its worker starts from them. -usage: chunk-preflight +usage: chunk-preflight [--worktree] -Run it inside a project checkout. loop-claude runs it at the checkout root before each chunk's +Run it inside a project checkout. A bare run only reads, so a run for the facts alone leaves +nothing to remove. loop-claude runs it with --worktree at the checkout root before each chunk's first worker, before it routes the chunk, and quotes what it prints in the worker's prompt. It fetches origin, when the checkout has that remote, and takes origin's default branch, or else the local main or master. It leaves the checkout as it is, and reads todo.md as the default branch @@ -21,9 +22,10 @@ holds it, the plan loop-claude routes on. It prints: finished and ready to cut once one did, and else to be planned first. Where todo.md's earliest release is x.y.z or earlier, it says todo.md files items under a release already cut; -- the item's worktree: a sibling of the checkout named -item-, on the branch - item-. It continues a worktree already on that branch; else it adds one on the local branch, - else on a new branch tracking origin's, else on a new branch off the default branch; +- with --worktree, the item's worktree: a sibling of the checkout named -item-, on + the branch item-; without it, that none was made. It continues a worktree already on that + branch; else it adds one on the local branch, else on a new branch tracking origin's, else on a + new branch off the default branch; - the open pull requests whose head is the item's branch, each by its number and URL, as gh lists them on a github.com origin, and else as tea does. No title reaches the output; - the items of that release that a chunk taking the item may take too: those that are not @@ -31,17 +33,17 @@ holds it, the plan loop-claude routes on. It prints: item's own R is above 5; - each file or folder git tracks that the item's tagline or detail names in backticks, with a file's lines or a folder's files, and the item's tagline and detail; -- what `rank_todo.py --check todo.md`, `larv-review needs-scoring-run `, `reading-cost` and - `larv-review places` print in the worktree, each with its exit code. reading-cost appends to the - worktree's docs/reading-cost.md, for the chunk to commit. +- with the worktree, what `rank_todo.py --check todo.md`, `larv-review needs-scoring-run `, + `reading-cost` and `larv-review places` print in it, each with its exit code. reading-cost + appends to the worktree's docs/reading-cost.md, for the chunk to commit. A fact it cannot find it says it cannot, and why, and goes on. A fetch, forge CLI or tool still running after {timeout} seconds, or after the seconds CHUNK_PREFLIGHT_TIMEOUT sets, is stopped; a stopped fetch reads origin as last fetched. With no item, it makes no worktree and runs none of -those four tools. +those four tools, --worktree or not. -Exit 1, saying why, on any argument, on a CHUNK_PREFLIGHT_TIMEOUT that is no number of seconds -above 0, or when git cannot start or finds no checkout or no default branch. +Exit 1, saying why, on any argument other than --worktree, on a CHUNK_PREFLIGHT_TIMEOUT that is no +number of seconds above 0, or when git cannot start or finds no checkout or no default branch. """ import pathlib import re @@ -62,16 +64,18 @@ TOOLS = (("rank_todo.py", "--check", "todo.md"), ("larv-review", "needs-scoring- # Seconds before a fetch, forge CLI or tool is stopped, so a hung one cannot keep the rest from printing; TIMEOUT_SETTING overrides it. TIMEOUT = 60 TIMEOUT_SETTING = "CHUNK_PREFLIGHT_TIMEOUT" +# The flag that makes the item's worktree and runs TOOLS in it. Three readers seated as lilleman picked it 2-1 over --start; --make-worktree misreads where the worktree is continued. +WORKTREE = "--worktree" def main(argv: list[str], env: typing.Mapping[str, str]) -> int: if argv in (["-h"], ["--help"]): print(__doc__.strip().format(timeout=TIMEOUT)) return 0 - if argv: - print(f"unknown arguments {' '.join(argv)}; usage: chunk-preflight", file=sys.stderr) + if argv not in ([], [WORKTREE]): + print(f"unknown arguments {' '.join(argv)}; usage: chunk-preflight [{WORKTREE}]", file=sys.stderr) return 1 - printed = run(env.get(TIMEOUT_SETTING)) + printed = run(env.get(TIMEOUT_SETTING), argv == [WORKTREE]) if isinstance(printed, Failure): print(printed.reason, file=sys.stderr) return 1 @@ -79,13 +83,13 @@ def main(argv: list[str], env: typing.Mapping[str, str]) -> int: return 0 -def run(setting: str | None) -> list[str] | Failure: - """The preflight's lines, given what TIMEOUT_SETTING holds; a Failure where that is no number of seconds, or git finds no checkout or no default branch.""" +def run(setting: str | None, make: bool) -> list[str] | Failure: + """The preflight's lines, given what TIMEOUT_SETTING holds and whether to make the item's worktree; a Failure where that is no number of seconds, or git finds no checkout or no default branch.""" timeout = seconds(setting) if isinstance(timeout, Failure): return timeout root = top() - return root if isinstance(root, Failure) else preflight(pathlib.Path(root), timeout) + return root if isinstance(root, Failure) else preflight(pathlib.Path(root), timeout, make) def seconds(setting: str | None) -> float | Failure: @@ -97,7 +101,7 @@ def seconds(setting: str | None) -> float | Failure: return Failure(f"{TIMEOUT_SETTING}={setting!r} is no number of seconds above 0") -def preflight(root: pathlib.Path, timeout: float) -> list[str] | Failure: +def preflight(root: pathlib.Path, timeout: float, make: bool) -> list[str] | Failure: """Gathers the facts step by step, each step taking what the ones before it found, and renders them; a Failure where the checkout has no default branch.""" default = default_branch(stale_ok=True, timeout=timeout) if isinstance(default, Failure): @@ -105,12 +109,12 @@ def preflight(root: pathlib.Path, timeout: float) -> list[str] | Failure: ref, note = default held = default_plan(str(root), ref) plan = planned(held.todo, held.cut, ref) - item = plan if isinstance(plan, NoItem) else item_facts(root, ref, plan, timeout) + item = plan if isinstance(plan, NoItem) else item_facts(root, ref, plan, timeout, make) return render(Gathered(ref, note, held.cut, item)) -def item_facts(root: pathlib.Path, default: str, plan: Plan, timeout: float) -> ItemFacts: - worktree = item_worktree(root, plan.branch, default) +def item_facts(root: pathlib.Path, default: str, plan: Plan, timeout: float, make: bool) -> ItemFacts: + worktree = item_worktree(root, plan.branch, default) if make else Failure(f"none made, as it ran without {WORKTREE}.") path = worktree.path if isinstance(worktree, Worktree) else None return ItemFacts(plan, worktree, pull_listing(root, plan.branch, timeout), named_files(plan.text, path or root), tools_run(plan.first.id, path, timeout) if path else []) diff --git a/bin/chunk_preflight/test_chunk_preflight.py b/bin/chunk_preflight/test_chunk_preflight.py index 23970740..f195e8e7 100644 --- a/bin/chunk_preflight/test_chunk_preflight.py +++ b/bin/chunk_preflight/test_chunk_preflight.py @@ -119,8 +119,8 @@ class Repo: stub.write_text(f'#!/bin/sh\ncase "$*" in\n{arm}\nesac\nexec {shutil.which("git")} "$@"\n') stub.chmod(0o755) - def preflight(self, **env): - return subprocess.run([sys.executable, str(BIN / "chunk-preflight")], capture_output=True, cwd=self.root, env={**self.env, **env}, text=True, timeout=120) + def preflight(self, *args, **env): + return subprocess.run([sys.executable, str(BIN / "chunk-preflight"), *args], capture_output=True, cwd=self.root, env={**self.env, **env}, text=True, timeout=120) class ChunkPreflightTool(unittest.TestCase): @@ -130,7 +130,7 @@ class ChunkPreflightTool(unittest.TestCase): # Claude Code rewrites tracked files, such as settings.json, so a checkout behind origin often holds changes. repo.write(repo.root, "todo.md", TODO + "\nA change of the checkout's own.\n") head = repo.git(repo.root, "rev-parse", "HEAD") - done = repo.preflight() + done = repo.preflight("--worktree") self.assertEqual(done.returncode, 0, done.stderr) self.assertEqual(repo.git(repo.root, "rev-parse", "HEAD"), head) worktree = repo.temp / "proj-item-7" @@ -163,7 +163,7 @@ class ChunkPreflightTool(unittest.TestCase): if reviewed: repo.git(repo.root, "commit", "--quiet", "--allow-empty", "-m", "Release review of 0.2.0") repo.git(repo.root, "push", "--quiet", "origin", "main") - done = repo.preflight() + done = repo.preflight("--worktree") self.assertEqual(done.returncode, 0, done.stderr) self.assertIn(fact, done.stdout) self.assertNotIn("item 9", done.stdout) @@ -214,9 +214,9 @@ class ChunkPreflightTool(unittest.TestCase): def test_continues_the_items_worktree_and_else_its_pushed_branch(self): repo = Repo(self) - repo.preflight() + repo.preflight("--worktree") worktree = repo.temp / "proj-item-3" - continued = repo.preflight().stdout + continued = repo.preflight("--worktree").stdout self.assertIn(str(worktree), continued) self.assertIn("continued", continued) (worktree / "work.txt").write_text("work\n") @@ -225,7 +225,7 @@ class ChunkPreflightTool(unittest.TestCase): repo.git(worktree, "push", "--quiet", "origin", "item-3") repo.git(repo.root, "worktree", "remove", "--force", str(worktree)) repo.git(repo.root, "branch", "--quiet", "-D", "item-3") - pushed = repo.preflight().stdout + pushed = repo.preflight("--worktree").stdout self.assertIn(str(worktree), pushed) self.assertIn("made off origin/item-3", pushed) self.assertTrue((worktree / "work.txt").exists()) @@ -233,7 +233,7 @@ class ChunkPreflightTool(unittest.TestCase): def test_makes_no_worktree_where_its_path_holds_something_else_and_runs_no_tool(self): repo = Repo(self) (repo.temp / "proj-item-3").mkdir() - done = repo.preflight() + done = repo.preflight("--worktree") self.assertIn(f"none made, since {repo.temp / 'proj-item-3'} exists", done.stdout) self.assertNotIn("`reading-cost`", done.stdout) @@ -241,7 +241,7 @@ class ChunkPreflightTool(unittest.TestCase): repo = Repo(self) repo.temp.chmod(0o555) self.addCleanup(repo.temp.chmod, 0o755) - done = repo.preflight() + done = repo.preflight("--worktree") self.assertEqual(done.returncode, 0, done.stderr) self.assertIn("Worktree: none made: git worktree add", done.stdout) self.assertNotIn("`reading-cost`", done.stdout) @@ -250,7 +250,7 @@ class ChunkPreflightTool(unittest.TestCase): def test_makes_no_worktree_and_runs_no_tool_where_git_cannot_list_the_worktrees(self): repo = Repo(self) repo.stub_git('"worktree list --porcelain") echo "listing broke" >&2; exit 1;;') - done = repo.preflight() + done = repo.preflight("--worktree") self.assertEqual(done.returncode, 0, done.stderr) self.assertIn("listing broke", done.stdout) self.assertNotIn("`reading-cost`", done.stdout) @@ -259,19 +259,37 @@ class ChunkPreflightTool(unittest.TestCase): def test_reads_origin_as_last_fetched_where_the_fetch_stalls_and_still_states_the_other_facts(self): repo = Repo(self) repo.stub_git(f'"fetch --quiet origin") exec {shutil.which("sleep")} 10;;') - done = repo.preflight(CHUNK_PREFLIGHT_TIMEOUT="1") + done = repo.preflight("--worktree", CHUNK_PREFLIGHT_TIMEOUT="1") self.assertEqual(done.returncode, 0, done.stderr) self.assertIn("as last fetched", done.stdout) self.assertIn("item 3, L 2, E + I 5", done.stdout) self.assertIn("`reading-cost` exited 0", done.stdout) + def test_without_worktree_states_the_items_facts_and_makes_no_worktree_and_runs_no_tool(self): + repo = Repo(self) + done = repo.preflight() + self.assertEqual(done.returncode, 0, done.stderr) + self.assertIn("item 3, L 2, E + I 5", done.stdout) + self.assertIn("Worktree: none made, as it ran without --worktree.", done.stdout) + self.assertIn("Open pull requests from item-3: none.", done.stdout) + self.assertIn("`src/app.py`: 3 lines", done.stdout) + self.assertNotIn("`reading-cost`", done.stdout) + self.assertFalse((repo.temp / "proj-item-3").exists()) + self.assertNotIn("item-3", repo.git(repo.root, "branch", "--list")) + + def test_exits_1_on_an_argument_other_than_worktree(self): + done = Repo(self).preflight("--start") + self.assertEqual(done.returncode, 1) + self.assertIn("unknown arguments --start", done.stderr) + self.assertEqual(done.stdout, "") + def test_lists_the_open_pull_requests_with_gh_on_a_github_origin(self): repo = Repo(self, origin="github.com/o/r.git") self.assertIn("#12 https://github.com/o/r/pull/12", repo.preflight().stdout) def test_without_a_plan_states_the_release_facts_and_makes_no_worktree(self): repo = Repo(self, todo="") - done = repo.preflight() + done = repo.preflight("--worktree") self.assertEqual(done.returncode, 0, done.stderr) self.assertIn("v0.1.0", done.stdout) self.assertIn("no items table", done.stdout) diff --git a/bin/loop_claude/loop/main.py b/bin/loop_claude/loop/main.py index a772cbbc..a4f2a3cd 100644 --- a/bin/loop_claude/loop/main.py +++ b/bin/loop_claude/loop/main.py @@ -35,11 +35,11 @@ loop-inbox lists it too. While claude is open, Ctrl-C reaches it alone, and the While it runs, loop-claude also lists itself in loop-inbox, with the todo.md items its chunk takes, as bin/loop_claude/running_loops.py describes. -As a chunk starts, before it is routed, loop-claude runs bin/chunk-preflight (bin/chunk_preflight/), -which finds the chunk's facts and makes its worktree; chunk-preflight --help lists them, and -prompts.preflight_facts in bin/loop_claude/cycle/prompts.py quotes them in the first prompt. A -preflight that fails, or is still running after 600 s and is stopped, leaves the worker to find the -facts itself. +As a chunk starts, before it is routed, loop-claude runs bin/chunk-preflight --worktree +(bin/chunk_preflight/), which finds the chunk's facts and makes its worktree; chunk-preflight +--help lists them, and prompts.preflight_facts in bin/loop_claude/cycle/prompts.py quotes them in +the first prompt. A preflight that fails, or is still running after 600 s and is stopped, leaves +the worker to find the facts itself. Each project has one session, named "A loop-claude", where is the checkout's path relative to ~/code, or to / outside it. The session is deleted when its chunk finishes. At every @@ -295,8 +295,8 @@ def chunk_start(session: Session, preflight: pathlib.Path, root: str, effects: E def chunk_facts(preflight: pathlib.Path, root: str, effects: Effects) -> str: - """What chunk-preflight printed at the checkout root, for a fresh worker's prompt, or why it could not run.""" - done = effects.python([str(preflight)], root) + """What chunk-preflight printed at the checkout root, its worktree made, for a fresh worker's prompt, or why it could not run.""" + done = effects.python([str(preflight), "--worktree"], root) if done.returncode: return prompts.preflight_failed(done.stderr.strip() or f"it exited {done.returncode}") return prompts.preflight_facts(done.stdout.strip()) diff --git a/bin/loop_claude/test_loop_claude.py b/bin/loop_claude/test_loop_claude.py index f5c05ce8..4d7adeeb 100644 --- a/bin/loop_claude/test_loop_claude.py +++ b/bin/loop_claude/test_loop_claude.py @@ -1277,7 +1277,7 @@ class ChunkFacts(unittest.TestCase): def test_runs_the_preflight_at_the_checkout_root_and_quotes_what_it_printed(self): fake = FakeEffects(python=[ran("- A fact.\n")]) said = main.chunk_facts(self.PREFLIGHT, "/r", fake.effects()) - self.assertEqual(fake.made("python"), [(["/b/chunk-preflight"], "/r")]) + self.assertEqual(fake.made("python"), [(["/b/chunk-preflight", "--worktree"], "/r")]) self.assertIn("\n\n- A fact.", said) self.assertNotIn("yourself", said) @@ -1293,7 +1293,7 @@ class ChunkFacts(unittest.TestCase): opened = session.session_named("A proj loop-claude", pathlib.Path(home, "projects")) fresh = FakeEffects(python=[ran("- A fact.\n")]) facts, _ = main.chunk_start(opened, self.PREFLIGHT, "/r", fresh.effects()) - self.assertEqual((fresh.made("python"), "- A fact." in facts), ([(["/b/chunk-preflight"], "/r")], True)) + self.assertEqual((fresh.made("python"), "- A fact." in facts), ([(["/b/chunk-preflight", "--worktree"], "/r")], True)) transcript = pathlib.Path(home, "projects", "-fake", f"{opened.id}.jsonl") transcript.parent.mkdir(parents=True) transcript.write_text("") diff --git a/docs/reading-cost.md b/docs/reading-cost.md index eb85f763..3ebf5a21 100644 --- a/docs/reading-cost.md +++ b/docs/reading-cost.md @@ -957,3 +957,20 @@ Read most (opens and searches): - `bin/model_routing/ladder.py` 1 - `bin/model_routing/worker_rungs.py` 1 - `bin/rule_hook/call.py` 1 + +## Reading cost, chunk 3325f37cc7be, finished 2026-10-31T00:23:38Z + +173944 new input tokens before the first commit. + +Read most (opens and searches): + +- `bin/loop_claude/test_black_box.py` 5 +- `README.md` 4 +- `bin/claude_code/test_claude_code.py` 3 +- `bin/loop_claude/hand_over.py` 3 +- `bin/loop_claude/project/checkout.py` 2 +- `docs/decisions.md` 2 +- `todo.md` 2 +- `AGENTS.md` 1 +- `CHANGELOG.md` 1 +- `bin/claude_code/__init__.py` 1 diff --git a/todo.md b/todo.md index 519483e6..9293938d 100644 --- a/todo.md +++ b/todo.md @@ -12,7 +12,6 @@ | ID | Release | Blocked by | Exempt | Item | L | E | I | R | S | Moves | Score | |---|---|---|---|---|---|---|---|---|---|---|---| -| 257 | 0.5.0 | | | **Make `chunk-preflight` create the item's worktree and branch only when loop-claude starts a worker on it, so a run for the facts alone leaves nothing to remove.** | 3 | 2 | 3 | 6 | 4 | 1.5 by 2 | 1.3 | | 226 | 0.6.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 | | 248 | 0.6.0 | | question | **Answer whether the `rule-hook:` decision should name every rule that takes no override, `repeat-read`, `reviewer-report` and `reviewer-rung`, with each one's reason.** | 1 | 2 | 1 | 2 | 1 | 1.2 by 2 | 3.3 | | 235 | 0.6.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 | @@ -75,10 +74,6 @@ ## Details -### 257. Make `chunk-preflight` create the item's worktree and branch only when loop-claude starts a worker on it, so a run for the facts alone leaves nothing to remove. - -Found in fejkdata.dev on 2026-10-29 and 2026-10-30. Two runs of `chunk-preflight` by hand, made to read its facts and not to start a chunk, each added the sibling worktree `fejkdata.dev-item-20` and the branch `item-20` at `origin/main`, and the session had to remove both. `bin/chunk_preflight/main.py` makes the worktree whenever the plan has an item, since loop-claude runs it as a chunk starts (`bin/loop_claude/loop/main.py` → `chunk_start`) and the worker then works in that worktree. It takes no argument and exits 1 on one, so a caller cannot ask for the facts alone. Make the worktree, `reading-cost`, `larv-review places` and the other tools it runs in the worktree opt-in, loop-claude's call asking for them; a bare run prints the facts and says no worktree was made. Update `--help`, the docstring and the worker prompt that tells the worker its worktree exists. Item 256 removes the case that made most of these worktrees, a pick the worker must not take. - ### 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. -- 2.52.0 From deddb39d86408b128abd4ed42277e67480f39ca5 Mon Sep 17 00:00:00 2001 From: Lilleman auf Larv Date: Sat, 31 Oct 2026 01:28:00 +0100 Subject: [PATCH 2/6] =?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);=20clean?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit -- 2.52.0 From 533b54c4bbaa1effe9959e7e0ab9e8be7bd3aa5e Mon Sep 17 00:00:00 2001 From: Lilleman auf Larv Date: Sat, 31 Oct 2026 01:34:45 +0100 Subject: [PATCH 3/6] =?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);=20keep=20only?= =?UTF-8?q?=20what=20loop-claude=20owns=20in=20its=20preflight=20paragraph?= =?UTF-8?q?,=20say=20a=20bare=20run=20still=20fetches;=20this=20commit=20a?= =?UTF-8?q?lso=20holds=20prose=20round=201's=20fixes?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CHANGELOG.md | 2 +- bin/chunk_preflight/main.py | 38 +++++++++++---------- bin/chunk_preflight/test_chunk_preflight.py | 2 +- bin/loop_claude/loop/main.py | 11 +++--- 4 files changed, 27 insertions(+), 26 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6798be52..b9c5aa3a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,7 +2,7 @@ ## Unreleased -- A bare run of `chunk-preflight` now only prints the facts: it makes no worktree or branch for the item and runs no tool in one. `chunk-preflight --worktree` makes them and runs the tools, as `loop-claude` now asks for each chunk. Before, every run that found an item added the worktree `-item-` and the branch `item-`, which a run for the facts alone left to remove. +- A bare run of `chunk-preflight` now only prints the facts. It no longer adds the worktree `-item-` and the branch `item-`, or runs `reading-cost`, `larv-review places` and its other checks in that worktree. `chunk-preflight --worktree` does all that, and `loop-claude` now passes it. Before, every run that found an item added the worktree and branch, and you had to remove them after a run made only to read the facts. - A release review now fixes the findings of its architecture and principles passes in the release it reviews. Before, it filed each one in `todo.md`, so the release held the drift the review had found. It files only three kinds of finding, each under the release being reviewed: one whose fix needs a human answer, marked `question`; one whose fix adds a feature; and one whose fix the five rounds cannot finish. Until each is done, the release isn't ready to cut. - In a repo with no tag yet, `chunk-preflight` now calls a release finished once `todo.md` files no item under it: its release review is due, and no later release's item is taken. Before, it lost sight of such a release. - In a run `loop-claude` started, `rule-hook` now refuses a `/security-review` or `/claude-security` Skill call that the worker makes in its own context on a rung below the project's. It also refuses one from any subagent whose prompt doesn't open with `You are the security pass for this chunk.`, since that subagent's rung is unchecked. The refusal says to invoke the skill from a subagent on the project's rung, its prompt opening with that sentence. Before, only an Agent call that launched the security pass was held to that rung. diff --git a/bin/chunk_preflight/main.py b/bin/chunk_preflight/main.py index 8eb6c425..bec6a1f4 100644 --- a/bin/chunk_preflight/main.py +++ b/bin/chunk_preflight/main.py @@ -1,13 +1,13 @@ -"""Find the mechanical facts a chunk starts from, and, with --worktree, make its worktree, so its worker starts from them. +"""Find the mechanical facts a chunk starts from, so its worker starts from them; with --worktree, also make its worktree. usage: chunk-preflight [--worktree] -Run it inside a project checkout. A bare run only reads, so a run for the facts alone leaves -nothing to remove. loop-claude runs it with --worktree at the checkout root before each chunk's -first worker, before it routes the chunk, and quotes what it prints in the worker's prompt. It -fetches origin, when the checkout has that remote, and takes origin's default branch, or else the -local main or master. It leaves the checkout as it is, and reads todo.md as the default branch -holds it, the plan loop-claude routes on. It prints: +Run it inside a project checkout. It fetches origin, when the checkout has that remote, and takes +origin's default branch, or else the local main or master. Without --worktree, it still fetches, +but it doesn't make a worktree or a branch, and doesn't run any tool in one. loop-claude runs it +with --worktree at the checkout root before each chunk's first worker, before it routes the chunk, +and quotes what it prints in the worker's prompt. It leaves the checkout as it is, and reads +todo.md as the default branch holds it, the plan loop-claude routes on. It prints: - the newest v* tag on the default branch, and how many entries the default branch's CHANGELOG.md holds under ## Unreleased, or else how many commits followed the tag; @@ -23,9 +23,9 @@ holds it, the plan loop-claude routes on. It prints: Where todo.md's earliest release is x.y.z or earlier, it says todo.md files items under a release already cut; - with --worktree, the item's worktree: a sibling of the checkout named -item-, on - the branch item-; without it, that none was made. It continues a worktree already on that - branch; else it adds one on the local branch, else on a new branch tracking origin's, else on a - new branch off the default branch; + the branch item-. It continues a worktree already on that branch; else it adds one on the + local branch, else on a new branch tracking origin's, else on a new branch off the default + branch. Without --worktree, it prints that none was made; - the open pull requests whose head is the item's branch, each by its number and URL, as gh lists them on a github.com origin, and else as tea does. No title reaches the output; - the items of that release that a chunk taking the item may take too: those that are not @@ -33,17 +33,19 @@ holds it, the plan loop-claude routes on. It prints: item's own R is above 5; - each file or folder git tracks that the item's tagline or detail names in backticks, with a file's lines or a folder's files, and the item's tagline and detail; -- with the worktree, what `rank_todo.py --check todo.md`, `larv-review needs-scoring-run `, - `reading-cost` and `larv-review places` print in it, each with its exit code. reading-cost - appends to the worktree's docs/reading-cost.md, for the chunk to commit. +- where it made or continued the worktree, what `rank_todo.py --check todo.md`, + `larv-review needs-scoring-run `, `reading-cost` and `larv-review places` print in it, each + with its exit code. reading-cost appends to the worktree's docs/reading-cost.md, for the chunk to + commit. A fact it cannot find it says it cannot, and why, and goes on. A fetch, forge CLI or tool still running after {timeout} seconds, or after the seconds CHUNK_PREFLIGHT_TIMEOUT sets, is stopped; a stopped fetch reads origin as last fetched. With no item, it makes no worktree and runs none of those four tools, --worktree or not. -Exit 1, saying why, on any argument other than --worktree, on a CHUNK_PREFLIGHT_TIMEOUT that is no -number of seconds above 0, or when git cannot start or finds no checkout or no default branch. +Exit 1, saying why, on any argument other than --worktree, -h or --help, on a +CHUNK_PREFLIGHT_TIMEOUT that is no number of seconds above 0, or when git cannot start or finds no +checkout or no default branch. """ import pathlib import re @@ -64,7 +66,7 @@ TOOLS = (("rank_todo.py", "--check", "todo.md"), ("larv-review", "needs-scoring- # Seconds before a fetch, forge CLI or tool is stopped, so a hung one cannot keep the rest from printing; TIMEOUT_SETTING overrides it. TIMEOUT = 60 TIMEOUT_SETTING = "CHUNK_PREFLIGHT_TIMEOUT" -# The flag that makes the item's worktree and runs TOOLS in it. Three readers seated as lilleman picked it 2-1 over --start; --make-worktree misreads where the worktree is continued. +# The flag that makes the item's worktree and runs TOOLS in it. Three readers seated as the README's audience picked it 2-1 over --start. WORKTREE = "--worktree" @@ -84,7 +86,7 @@ def main(argv: list[str], env: typing.Mapping[str, str]) -> int: def run(setting: str | None, make: bool) -> list[str] | Failure: - """The preflight's lines, given what TIMEOUT_SETTING holds and whether to make the item's worktree; a Failure where that is no number of seconds, or git finds no checkout or no default branch.""" + """The preflight's lines, given the setting TIMEOUT_SETTING holds and whether to make the item's worktree; a Failure where the setting is no number of seconds above 0, or git finds no checkout or no default branch.""" timeout = seconds(setting) if isinstance(timeout, Failure): return timeout @@ -114,7 +116,7 @@ def preflight(root: pathlib.Path, timeout: float, make: bool) -> list[str] | Fai def item_facts(root: pathlib.Path, default: str, plan: Plan, timeout: float, make: bool) -> ItemFacts: - worktree = item_worktree(root, plan.branch, default) if make else Failure(f"none made, as it ran without {WORKTREE}.") + worktree = item_worktree(root, plan.branch, default) if make else Failure(f"none made, since it ran without {WORKTREE}.") path = worktree.path if isinstance(worktree, Worktree) else None return ItemFacts(plan, worktree, pull_listing(root, plan.branch, timeout), named_files(plan.text, path or root), tools_run(plan.first.id, path, timeout) if path else []) diff --git a/bin/chunk_preflight/test_chunk_preflight.py b/bin/chunk_preflight/test_chunk_preflight.py index f195e8e7..d40cf24b 100644 --- a/bin/chunk_preflight/test_chunk_preflight.py +++ b/bin/chunk_preflight/test_chunk_preflight.py @@ -270,7 +270,7 @@ class ChunkPreflightTool(unittest.TestCase): done = repo.preflight() self.assertEqual(done.returncode, 0, done.stderr) self.assertIn("item 3, L 2, E + I 5", done.stdout) - self.assertIn("Worktree: none made, as it ran without --worktree.", done.stdout) + self.assertIn("Worktree: none made, since it ran without --worktree.", done.stdout) self.assertIn("Open pull requests from item-3: none.", done.stdout) self.assertIn("`src/app.py`: 3 lines", done.stdout) self.assertNotIn("`reading-cost`", done.stdout) diff --git a/bin/loop_claude/loop/main.py b/bin/loop_claude/loop/main.py index a4f2a3cd..4ed47ac5 100644 --- a/bin/loop_claude/loop/main.py +++ b/bin/loop_claude/loop/main.py @@ -35,11 +35,10 @@ loop-inbox lists it too. While claude is open, Ctrl-C reaches it alone, and the While it runs, loop-claude also lists itself in loop-inbox, with the todo.md items its chunk takes, as bin/loop_claude/running_loops.py describes. -As a chunk starts, before it is routed, loop-claude runs bin/chunk-preflight --worktree -(bin/chunk_preflight/), which finds the chunk's facts and makes its worktree; chunk-preflight ---help lists them, and prompts.preflight_facts in bin/loop_claude/cycle/prompts.py quotes them in -the first prompt. A preflight that fails, or is still running after 600 s and is stopped, leaves -the worker to find the facts itself. +As a chunk starts, before it is routed, loop-claude runs bin/chunk-preflight --worktree and quotes +what it prints in the first prompt (prompts.preflight_facts in bin/loop_claude/cycle/prompts.py); +chunk-preflight --help says what it finds and makes. A preflight that fails, or is still running +after 600 s and is stopped, leaves the worker to find the facts itself. Each project has one session, named "A loop-claude", where is the checkout's path relative to ~/code, or to / outside it. The session is deleted when its chunk finishes. At every @@ -295,7 +294,7 @@ def chunk_start(session: Session, preflight: pathlib.Path, root: str, effects: E def chunk_facts(preflight: pathlib.Path, root: str, effects: Effects) -> str: - """What chunk-preflight printed at the checkout root, its worktree made, for a fresh worker's prompt, or why it could not run.""" + """What `chunk-preflight --worktree` printed at the checkout root, for a fresh worker's prompt, or why it could not run.""" done = effects.python([str(preflight), "--worktree"], root) if done.returncode: return prompts.preflight_failed(done.stderr.strip() or f"it exited {done.returncode}") -- 2.52.0 From 8f61a65ffb41ecaa01aa662d34b71b33b2052800 Mon Sep 17 00:00:00 2001 From: Lilleman auf Larv Date: Sat, 31 Oct 2026 01:34:45 +0100 Subject: [PATCH 4/6] =?UTF-8?q?Answer=20prose=20round=201:=200=20?= =?UTF-8?q?=F0=9F=94=B4,=203=20=F0=9F=9F=A1=20(0=20misread);=20fixed=20in?= =?UTF-8?q?=20the=20stability=20round's=20commit:=20the=20worktree=20bulle?= =?UTF-8?q?t=20states=20the=20--worktree=20case=20first,=20chunk=5Ffacts?= =?UTF-8?q?=20names=20the=20flag,=20the=20help=20no=20longer=20says=20a=20?= =?UTF-8?q?bare=20run=20only=20reads?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit -- 2.52.0 From 9b0c70fb8a55b1e736507c9389e6e1fdd4bfe0b7 Mon Sep 17 00:00:00 2001 From: Lilleman auf Larv Date: Sat, 31 Oct 2026 01:34:45 +0100 Subject: [PATCH 5/6] =?UTF-8?q?Answer=20product-owner=20round=201:=200=20?= =?UTF-8?q?=F0=9F=94=B4,=200=20=F0=9F=9F=A1=20(0=20misread);=20its=20?= =?UTF-8?q?=F0=9F=9F=A2=20on=20a=20bare=20run=20counting=20named=20files?= =?UTF-8?q?=20in=20the=20checkout=20is=20declined=20in=20the=20PR=20summar?= =?UTF-8?q?y?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit -- 2.52.0 From 21640bda3402f12987e241c6019186c4cc2c5b5b Mon Sep 17 00:00:00 2001 From: Lilleman auf Larv Date: Sat, 31 Oct 2026 01:35:47 +0100 Subject: [PATCH 6/6] Put the chunk-preflight entry under Unreleased after the merge of 0.4.1 --- CHANGELOG.md | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 20de7f45..b57073f5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,8 +1,11 @@ # Changelog +## Unreleased + +- A bare run of `chunk-preflight` now only prints the facts. It no longer adds the worktree `-item-` and the branch `item-`, or runs `reading-cost`, `larv-review places` and its other checks in that worktree. `chunk-preflight --worktree` does all that, and `loop-claude` now passes it. Before, every run that found an item added the worktree and branch, and you had to remove them after a run made only to read the facts. + ## 0.4.1 -- A bare run of `chunk-preflight` now only prints the facts. It no longer adds the worktree `-item-` and the branch `item-`, or runs `reading-cost`, `larv-review places` and its other checks in that worktree. `chunk-preflight --worktree` does all that, and `loop-claude` now passes it. Before, every run that found an item added the worktree and branch, and you had to remove them after a run made only to read the facts. - A release review now fixes the findings of its architecture and principles passes in the release it reviews. Before, it filed each one in `todo.md`, so the release held the drift the review had found. It files only three kinds of finding, each under the release being reviewed: one whose fix needs a human answer, marked `question`; one whose fix adds a feature; and one whose fix the five rounds cannot finish. Until each is done, the release isn't ready to cut. - In a repo with no tag yet, `chunk-preflight` now calls a release finished once `todo.md` files no item under it: its release review is due, and no later release's item is taken. Before, it lost sight of such a release. - In a run `loop-claude` started, `rule-hook` now refuses a `/security-review` or `/claude-security` Skill call that the worker makes in its own context on a rung below the project's. It also refuses one from any subagent whose prompt doesn't open with `You are the security pass for this chunk.`, since that subagent's rung is unchecked. The refusal says to invoke the skill from a subagent on the project's rung, its prompt opening with that sentence. Before, only an Agent call that launched the security pass was held to that rung. -- 2.52.0