diff --git a/CHANGELOG.md b/CHANGELOG.md index fb15e14e..26ba4e83 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,8 @@ ## Unreleased +- `command-patterns [] --calls ` saves each Bash call of the release's chunks as a JSON line, with its chunk, pattern, seconds, sizes and text. +- `todo-item show ` prints an item's table row and detail from `todo.md`. - A reviewer under `agents/` can start without `CLAUDE.md`: `omitClaudeMd: true` in its frontmatter drops the file, a `SubagentStart` hook hands it the "Shared goal", "Prose" and "Vocabulary" sections, and `larv-review reviewer-header` names the project's principles file. `review-replay --omit-claude-md` tests whether a pass's reviewer finds as much without it; principles-auditor is the first to pass. - Add `workflow-bench/advisor_bench.py`, a bench of the advisor tool on six archived L 1 and L 2 chunks. Sonnet 5.5 alone passed all six, as Opus 5.5 at medium did, for 41% less, and its advisor ran in one of six runs, so workers stay without it. - loop-claude's judge on an Opus 5.5 project now runs on Opus 5.5 at xhigh in every chunk, never at medium: in replays medium sometimes closed a chunk whose worker had asked a question the README or records answer, where xhigh quoted the answer. The judge never runs on Fable 5.2 either, since each Fable 5.2 rung replayed missed an interrupt. `judge-replay` now also replays each rung above the project's that a review climbs to, and reports what each misses. diff --git a/CLAUDE.md b/CLAUDE.md index 02d21d5f..af7e65f8 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -10,7 +10,7 @@ How work proceeds in any repo, unless the repo's `AGENTS.md` says otherwise. The - **When the next release has no items left and work has landed towards it, its release review is the chunk** (`larv-review` §3 → "Release review"). **Once that has merged and the release holds no item, the release is finished: stop.** Report what it holds and that it is ready to cut. Under `/loop`, this ends the loop. Until the human cuts it, only a security fix, or an item its release review filed, lands, into that release; never start a later release's items or plan a new one. - **Open every chunk with one line:** the last version cut, how many changes are unreleased (the entries under `CHANGELOG.md` → `## Unreleased`, or else the commits since the last tag), and the release this chunk ships into. A repo that doesn't publish anything says so once. - **Read the README's `## Goals` and `## Audience` before starting a chunk, unless your prompt quotes them.** The chunk's items set its scope. The goals choose between ways to deliver those items, and never add to them. -- **Read the plan and the decisions only as far as the chunk needs.** Where your prompt quotes `chunk-preflight`'s facts, they hold the next item's L, E + I, tagline and detail, and each item that may join it with its L, E + I, S, tagline and detail; open `todo.md` only for what they leave out. Otherwise run `grep -n '^## Details' todo.md`, then read `todo.md` with the Read tool up to the line it prints, or whole when it prints none. Then read the details of only the items the chunk takes. `AGENTS.md` lists the project principles and the title of each decision no project principle covers. Read an entry in `docs/decisions.md` only where the project principle or the title leaves open what the chunk or the review needs. +- **Read the plan and the decisions only as far as the chunk needs.** Where your prompt quotes `chunk-preflight`'s facts, they hold the next item's L, E + I, tagline and detail, and each item that may join it with its L, E + I, S, tagline and detail; open `todo.md` only for what they leave out. Otherwise run `grep -n '^## Details' todo.md`, then read `todo.md` with the Read tool up to the line it prints, or whole when it prints none. Then read the details of only the items the chunk takes, with `~/.claude/bin/todo-item show `, which prints an item's row and detail. `AGENTS.md` lists the project principles and the title of each decision no project principle covers. Read an entry in `docs/decisions.md` only where the project principle or the title leaves open what the chunk or the review needs. - **Work one chunk at a time, and put every item that can share its review into it.** Every review has a fixed cost, so a chunk takes the next plan item plus every other item for which three things hold: they name one release; they fire the same review passes (`larv-review` §3); and no item outside the chunk blocks one of them. The items need not share a purpose. An item whose risk R, in `todo.md`, is above 5 ships alone: it joins no chunk, and none joins it. The next plan item is the first that does not wait: an item waits while it is marked `question`, until the human answers, or while an item that blocks it is still in the plan. Tiny items, a few lines of change each, need not fire the same passes: bundle up to ten that name one release, and that no item outside the chunk blocks, into one chunk. Split a milestone into items in `todo.md` before starting it. Fix a finding in the chunk's own change within the chunk. File a finding about anything else in `todo.md`. - **Ask, don't guess.** Three choices are always the human's: a goal; a release, meaning the items planned into it and when it is cut; and a change to loop-claude's routing ladder, its rungs included. Any other rule that asks the human's approval reserves that choice too. Ask about a reserved choice. For any other choice, first check whether the goals already answer it. If they nearly do, propose a change to the goals and show how it answers this case: an answer settles one question, a goal settles every question like it. Otherwise take the option you would recommend, and record it with its reason: in the item's detail, or, where it governs later work, as the next sentence says. A recommendation you can give a reason for is not a guess. Ask only where you have no recommendation. Write every answer once, where it belongs, never only in chat: a goal in `README.md`, a working rule in `AGENTS.md`, a standing choice in a comment at the one place it governs, or in `docs/decisions.md` once made in more than one place. When an answer holds a goal and a choice, write the goal in the README, and record as a choice only what the goal leaves open. - **Bench a syntax with the people who write it.** Before a new or changed spelling of something users read or write ships — markdown, HTML, a config key, a CLI flag — a panel of fresh-context readers, seated as those users from the README's `## Audience`, picks it. diff --git a/README.md b/README.md index 6e888a9d..e1bfcc66 100644 --- a/README.md +++ b/README.md @@ -99,7 +99,7 @@ Install puts only `loop-claude` and `loop-inbox` on `PATH`; call the others by t - `chunk-pr open|ready|merge|clean` opens a chunk's pull request as a draft, marks it ready and merges it, with `gh` on a GitHub origin and `tea` elsewhere; once it is merged, `clean` removes the chunk's worktree and branch and fast-forwards the main checkout. `chunk-pr --help` states the steps. - `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. -- `command-patterns []` prints a table of the shell command patterns a release's archived chunks ran, such as `tea pr create`, for an audit of the release; `command-patterns --help` states its columns. +- `command-patterns [] [--calls ]` prints a table of the shell command patterns a release's archived chunks ran, such as `tea pr create`, for an audit of the release, and with `--calls ` saves each call as a JSON line; `command-patterns --help` states the columns and the line's keys. - `deploy-release [--cut] []` moves `~/.claude`, or the checkout named, to the newest release, as Update says; with `--cut`, run in the development clone, it first cuts the next release, as Release says. - `judge-replay ` replays loop-claude's judge on archived verdicts of the projects run on the model, and prints what each rung a review climbs to misses, and the lowest rung below them that, like each candidate 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; the comprehension history's format, its latest places and its count of how often seats agree; and each reviewer's prompt header. `larv-review --help` states them. `settings.json` → `hooks` runs `larv-review reviewer-context` as each subagent starts. A reviewer under `agents/` whose frontmatter has `omitClaudeMd: true` starts without `CLAUDE.md`, and the command hands it that file's "Shared goal", "Prose" and "Vocabulary" sections. @@ -117,7 +117,7 @@ Install puts only `loop-claude` and `loop-inbox` on `PATH`; call the others by t - `settings_filter.py` is git's clean filter for `settings.json`: it drops `"model"` and sorts the keys. `.gitattributes` sets the filter `settings` on `settings.json`, and Install's `git config` line makes this script that filter. - `statusline.py` renders Claude Code's status line; `settings.json` → `statusLine` runs it. - `subagent-rung [--plan] ` prints the Agent tool's model and effort for a subagent's task, picked by its L from the project's model, and with `--plan` never below the project's rung; `subagent-rung --help` states the rule. -- `todo-item add …` files an item in a project's `todo.md`, taking `Next ID` as the item's ID, and `todo-item finish ` removes a finished item and adds the bullet passed with `--changelog` to `CHANGELOG.md`; both rank the file, and `todo-item --help` states the flags. +- `todo-item add …` files an item in a project's `todo.md`, taking `Next ID` as the item's ID, and `todo-item finish ` removes a finished item and adds the bullet passed with `--changelog` to `CHANGELOG.md`; both rank the file. `todo-item show ` prints an item's row and detail. `todo-item --help` states the flags. `bin/` is the import root: each launcher puts it on `sys.path`, so a module imports another by its path under `bin/`, such as `from claude_code.entries import parse_entry`. Each tool's package holds its tests. Beside the packages, `bin/`'s root holds only the launchers, the tools of one file with their tests, `test_env.py`, `failure.py` and `setup.cfg`. `failure.py`'s `Failure`, which modules across `bin/` return for a failed step, belongs to no single package. `branch_chunks/`, `claude_code/`, `command_lines/`, `git_cli/`, `loop_effects/`, `loop_state/`, `machine_load/`, `mattermost_dm/`, `model_routing/`, `records/`, `release_plan/`, `review_rules/`, `rung_replay/` and `transcript_archive/` serve more than one tool. diff --git a/bin/command_patterns/main.py b/bin/command_patterns/main.py index 3937ba40..b90e5c7a 100644 --- a/bin/command_patterns/main.py +++ b/bin/command_patterns/main.py @@ -1,6 +1,6 @@ """Print a table of the shell command patterns a release's chunks ran. -usage: command-patterns [] +usage: command-patterns [] [--calls ] Run it inside a project checkout or one of its worktrees. It reads loop-claude's archive of the project, as reading-cost does, and takes each chunk that finished in the release's window: after @@ -17,9 +17,18 @@ The table has one row per pattern, most calls first. Its columns are the chunks pattern, its calls, and the tokens of its commands and of their results. Tokens are estimated at four characters each. The last column sums the seconds from each call to its result. -Exit 1, saying why, on unknown arguments, a version no tag names, or when git cannot start or finds -no checkout, or the archive cannot be read. +With --calls , it first writes the file, replacing any it holds, with one line per Bash call: +a JSON object with `chunk` (the chunk's number in the window, from 1, in the order the archive lists +the chunks), `pattern` (as above), `seconds` (as in the table), `command_characters`, +`result_characters` and `command`, the command's text. Lines follow the chunks in that order, and each +chunk's threads. The file is readable by its owner alone. Commands may carry a secret, so write it +outside any folder git tracks. Where it cannot be written, no table is printed. + +Exit 1, saying why, on unknown arguments or --calls without a file; on a version no tag names; when git +cannot start or finds no checkout; when the archive cannot be read; and when the --calls file cannot +be written. """ +import json import os import pathlib import sys @@ -28,23 +37,31 @@ from failure import Failure from transcript_archive.read import finished_chunks, read_threads from git_cli.git_repo import git from transcript_archive.location import project_archive +from command_patterns.tally import records, table, tally from records.utc_stamp import seconds -from command_patterns.tally import table, tally -USAGE = "usage: command-patterns []" +USAGE = "usage: command-patterns [] [--calls ]" def main(argv: list[str]) -> int: if argv in (["-h"], ["--help"]): print(__doc__.strip()) return 0 + calls_file = None + if "--calls" in argv: + at = argv.index("--calls") + if at + 1 == len(argv) or argv[at + 1].startswith("-"): + print(f"command-patterns: --calls needs a file; {USAGE}", file=sys.stderr) + return 1 + calls_file = pathlib.Path(argv[at + 1]) + argv = argv[:at] + argv[at + 2:] if any(word.startswith("-") for word in argv): print(f"command-patterns: unknown option in {' '.join(argv)}; {USAGE}", file=sys.stderr) return 1 if len(argv) > 1: print(f"command-patterns: takes one version at most, not {' '.join(argv)}; {USAGE}", file=sys.stderr) return 1 - printed = report(argv[0] if argv else None) + printed = report(argv[0] if argv else None, calls_file) if isinstance(printed, Failure): print(f"command-patterns: {printed.reason}", file=sys.stderr) return 1 @@ -52,7 +69,7 @@ def main(argv: list[str]) -> int: return 0 -def report(version: str | None) -> str | Failure: +def report(version: str | None, calls_file: pathlib.Path | None) -> str | Failure: common = git("rev-parse", "--path-format=absolute", "--git-common-dir") if isinstance(common, Failure): return common @@ -72,10 +89,25 @@ def report(version: str | None) -> str | Failure: if isinstance(read, Failure): return read threads.append(read) + if calls_file is not None: + saved = save_calls(calls_file, "".join(json.dumps(each) + "\n" for each in records(threads))) + if saved: + return saved named = f"v{version}" if version else "the release not yet cut" return f"Shell command patterns of {len(threads)} chunk{'' if len(threads) == 1 else 's'} in {named}:\n\n{table(tally(threads))}" +def save_calls(path: pathlib.Path, text: str) -> Failure | None: + """Write text to path for its owner alone, since a command may carry a secret; path keeps no wider mode it already had.""" + try: + with open(os.open(path, os.O_WRONLY | os.O_CREAT | os.O_TRUNC, 0o600), "w", encoding="utf-8") as file: + os.fchmod(file.fileno(), 0o600) + file.write(text) + except OSError as failure: + return Failure(f"{path}: {failure.strerror}") + return None + + def window(version: str | None, cwd: str) -> tuple[int | None, int | None] | Failure: """The release's window as tag dates in seconds since the epoch: after the tag before it, up to its own; None where it is open.""" listed = git("-c", "versionsort.suffix=-", "tag", "--list", "v*", "--sort=-v:refname", "--format=%(refname:short) %(creatordate:unix)", cwd=cwd) diff --git a/bin/command_patterns/tally.py b/bin/command_patterns/tally.py index 580c8828..e21d9211 100644 --- a/bin/command_patterns/tally.py +++ b/bin/command_patterns/tally.py @@ -70,13 +70,21 @@ def elapsed(start: str, end: str) -> float: return 0.0 +def each_call(chunks: list[list[bytes]]) -> list[tuple[int, Call]]: + """Every Bash call, with its chunk's number from 1: chunks gives each chunk as the list of its threads, and the calls follow in that order.""" + return [(index, each) for index, threads in enumerate(chunks, 1) for thread in threads for each in calls(thread)] + + +def records(chunks: list[list[bytes]]) -> list[dict[str, str | int | float]]: + """One record per Bash call, for `command-patterns --calls`: its chunk's number, pattern, seconds, command's and result's characters, and command's text.""" + return [{"chunk": index, "pattern": pattern(each.command), "seconds": each.seconds, "command_characters": len(each.command), "result_characters": len(each.result), "command": each.command} for index, each in each_call(chunks)] + + def tally(chunks: list[list[bytes]]) -> list[Row]: """One row per pattern over the chunks, each given as its threads, most calls first.""" found: dict[str, list[tuple[int, Call]]] = {} - for index, threads in enumerate(chunks): - for thread in threads: - for each in calls(thread): - found.setdefault(pattern(each.command), []).append((index, each)) + for index, each in each_call(chunks): + found.setdefault(pattern(each.command), []).append((index, each)) rows = [Row(name, len({index for index, _ in made}), len(made), sum(len(each.command) for _, each in made) // CHARACTERS_PER_TOKEN, sum(len(each.result) for _, each in made) // CHARACTERS_PER_TOKEN, round(sum(each.seconds for _, each in made))) for name, made in found.items()] return sorted(rows, key=lambda row: (-row.calls, row.pattern)) diff --git a/bin/command_patterns/test_command_patterns.py b/bin/command_patterns/test_command_patterns.py index 4532cbfa..8832f8a4 100644 --- a/bin/command_patterns/test_command_patterns.py +++ b/bin/command_patterns/test_command_patterns.py @@ -9,7 +9,7 @@ import unittest sys.path.insert(0, str(pathlib.Path(__file__).resolve().parents[1])) from test_env import isolated_env -from command_patterns.tally import pattern, Row, tally +from command_patterns.tally import pattern, records, Row, tally TOOL = pathlib.Path(__file__).resolve().parents[1] / "command-patterns" @@ -60,6 +60,20 @@ class Tally(unittest.TestCase): self.assertEqual(rows, [Row("ls", chunks=1, calls=1, command_tokens=0, result_tokens=1, seconds=1)]) +class Records(unittest.TestCase): + def test_gives_each_call_its_chunk_pattern_seconds_sizes_and_text(self): + first = [thread(call("a", "cd /x && git status --short", "2026-11-01T10:00:00Z"), result("a", "x" * 7, "2026-11-01T10:00:03Z"))] + second = [thread(call("b", "ls", "2026-11-02T10:00:00Z"))] + self.assertEqual(records([first, second]), [ + {"chunk": 1, "pattern": "git status", "seconds": 3.0, "command_characters": 27, "result_characters": 7, "command": "cd /x && git status --short"}, + {"chunk": 2, "pattern": "ls", "seconds": 0.0, "command_characters": 2, "result_characters": 0, "command": "ls"}, + ]) + + def test_keeps_a_chunks_calls_from_each_of_its_threads_under_its_number(self): + both = [thread(call("a", "ls", "2026-11-01T10:00:00Z")), thread(call("b", "pwd", "2026-11-01T11:00:00Z"))] + self.assertEqual([(each["chunk"], each["command"]) for each in records([both])], [(1, "ls"), (1, "pwd")]) + + class Main(unittest.TestCase): """A checkout tagged v0.1.0 at 2026-11-01 and v0.2.0 at 2026-11-05, and three archived chunks, finished before, between and after them.""" @@ -108,6 +122,37 @@ class Main(unittest.TestCase): self.assertIn("| make old | 1 | 1 |", ran.stdout) self.assertNotIn("tea pr create", ran.stdout) + def test_writes_each_call_as_a_json_line_beside_the_table(self): + saved = self.home / "calls.jsonl" + ran = self.run_tool("0.2.0", "--calls", str(saved)) + self.assertEqual(ran.returncode, 0, ran.stderr) + self.assertIn("| tea pr create | 1 | 1 |", ran.stdout) + self.assertEqual([json.loads(line) for line in saved.read_text().splitlines()], [{"chunk": 1, "pattern": "tea pr create", "seconds": 0.0, "command_characters": 13, "result_characters": 2, "command": "tea pr create"}]) + + def test_makes_the_calls_file_readable_by_its_owner_alone_even_where_it_existed(self): + saved = self.home / "calls.jsonl" + saved.write_text("old") + saved.chmod(0o644) + self.assertEqual(self.run_tool("0.2.0", "--calls", str(saved)).returncode, 0) + self.assertEqual(saved.stat().st_mode & 0o777, 0o600) + self.assertNotIn("old", saved.read_text()) + + def test_takes_the_calls_flag_before_the_version_too(self): + saved = self.home / "calls.jsonl" + self.assertEqual(self.run_tool("--calls", str(saved), "0.2.0").returncode, 0) + self.assertEqual(len(saved.read_text().splitlines()), 1) + + def test_refuses_a_calls_flag_without_a_file(self): + ran = self.run_tool("--calls") + self.assertEqual(ran.returncode, 1) + self.assertIn("--calls", ran.stderr) + + def test_fails_where_the_calls_file_cannot_be_written(self): + ran = self.run_tool("--calls", str(self.home / "no-such-folder" / "calls.jsonl")) + self.assertEqual(ran.returncode, 1) + self.assertIn("no-such-folder", ran.stderr) + self.assertEqual(ran.stdout, "") + def test_refuses_a_release_no_tag_names(self): ran = self.run_tool("0.9.0") self.assertEqual(ran.returncode, 1) diff --git a/bin/todo_item/edits.py b/bin/todo_item/edits.py index 696782c3..5370f55f 100644 --- a/bin/todo_item/edits.py +++ b/bin/todo_item/edits.py @@ -1,7 +1,7 @@ """The text edits behind todo-item: filing an item in todo.md, removing a finished one, and adding a bullet to CHANGELOG.md. Each returns new text; ranking.rank then orders the table and details and writes the derived cells.""" import re -from release_plan.todo_table import cells, DETAILS, items_table, Table +from release_plan.todo_table import cells, DETAILS, item_details, items_table, Table from failure import Failure from release_plan.ranking import stated @@ -47,15 +47,10 @@ def finished(todo: str, id_: int) -> str | Failure: table = held_table(lines) if isinstance(table, Failure): return table - for at, row in enumerate(table.rows, table.start): - found = cells(row, len(table.columns)) - if isinstance(found, Failure): - return found - if found[0] == str(id_): - del lines[at] - break - else: - return Failure(f"todo.md holds no item {id_}") + at = row_index(table, id_) + if isinstance(at, Failure): + return at + del lines[at] text = "\n".join(lines) section = DETAILS.search(text) if section is None: @@ -64,6 +59,37 @@ def finished(todo: str, id_: int) -> str | Failure: return text[:section.start(1)] + body + text[section.end(1):] +def shown(todo: str, id_: int) -> str | Failure: + """The table's header and divider, item id_'s row, then its detail with its heading, sub-headings included; the row alone where the item has no detail.""" + lines = todo.split("\n") + table = held_table(lines) + if isinstance(table, Failure): + return table + at = row_index(table, id_) + if isinstance(at, Failure): + return at + details = item_details(todo) + if isinstance(details, Failure): + return details + shown_table = "\n".join([*lines[table.header:table.start], lines[at]]) + if id_ not in details: + return shown_table + heading = re.search(rf"^### {id_}\. .*$", todo, re.M) + assert heading is not None # item_details found the detail by this heading + return f"{shown_table}\n\n{heading.group()}\n\n{details[id_]}" + + +def row_index(table: Table, id_: int) -> int | Failure: + """The index in the file's lines of item id_'s row.""" + for at, row in enumerate(table.rows, table.start): + found = cells(row, len(table.columns)) + if isinstance(found, Failure): + return found + if found[0] == str(id_): + return at + return Failure(f"todo.md holds no item {id_}") + + def with_bullet(changelog: str, bullet: str) -> str | Failure: """changelog with bullet first under its UNRELEASED_SECTION, adding ## Unreleased above the first release heading where it has none; a new changelog where changelog is empty. Failure where that section holds ### subsections, since the bullet belongs under one of them.""" text = bullet.strip().removeprefix("- ").strip() diff --git a/bin/todo_item/main.py b/bin/todo_item/main.py index 83a1e9ad..1c007441 100644 --- a/bin/todo_item/main.py +++ b/bin/todo_item/main.py @@ -1,11 +1,12 @@ -"""File an item in todo.md, or finish one, and rank the file as rank_todo.py does. +"""File an item in todo.md or finish one, ranking the file as rank_todo.py does, or show one. usage: todo-item add --release --l --e --i --s [--moves ] [--blocked-by ] [--exempt ] [<<'EOF' detail EOF] todo-item finish [--changelog | --no-changelog] + todo-item show -Works on the todo.md in the current folder and the CHANGELOG.md beside it, and reads the README.md -and docs/decisions.md beside todo.md. +All three work on the todo.md in the current folder. add and finish also use the CHANGELOG.md beside it, +and read the README.md and docs/decisions.md beside todo.md. The cells take the format rank_todo.py --help states; the letter flags take upper case too, as --L. add takes Next ID as the item's ID and raises Next ID by one. It writes the row, with the tagline @@ -19,6 +20,10 @@ file, where missing. It refuses where that section holds ### subsections: add th Where CHANGELOG.md exists, finish needs --changelog or --no-changelog, so no bullet is left out by mistake. It prints `Finished item .` It writes nothing while docs/decisions.md cites the item. +show reads only todo.md. It prints the items table's header and divider, item 's row, and its detail +from its ### heading to the next item's, sub-headings included. It fails, saying so, where todo.md has +no row for . + Exit 2 on bad arguments, and 1, saying why, on any other failure. A message opening `not filed:` or `not finished:` means it wrote nothing. """ @@ -27,7 +32,7 @@ import pathlib import sys import typing -from todo_item.edits import added, finished, with_bullet +from todo_item.edits import added, finished, shown, with_bullet from release_plan.todo_table import BLOCKED_BY, MOVES from failure import Failure from release_plan import plan_file, ranking @@ -41,7 +46,10 @@ def main(argv: list[str], folder: pathlib.Path = pathlib.Path(), stdin: typing.T print(__doc__.strip()) return 0 args = parser().parse_args(argv) - done = add(args, folder, stdin) if args.command == "add" else finish(args, folder) + if args.command == "show": + done = show(args, folder) + else: + done = add(args, folder, stdin) if args.command == "add" else finish(args, folder) if isinstance(done, Failure): print(done.reason, file=sys.stderr) return 1 @@ -65,9 +73,21 @@ def parser() -> argparse.ArgumentParser: bullet = finishing.add_mutually_exclusive_group() bullet.add_argument("--changelog") bullet.add_argument("--no-changelog", action="store_true") + showing = commands.add_parser("show") + showing.add_argument("id", type=int) return parsed +def show(args: argparse.Namespace, folder: pathlib.Path) -> str | Failure: + todo = folder / "todo.md" + try: + return shown(todo.read_text(encoding="utf-8"), args.id) + except OSError as failure: + return Failure(f"{todo}: {failure.strerror}") + except UnicodeDecodeError: + return Failure(f"{todo}: not UTF-8") + + def add(args: argparse.Namespace, folder: pathlib.Path, stdin: typing.TextIO) -> str | Failure: todo = folder / "todo.md" texts = plan_file.read_all(todo) diff --git a/bin/todo_item/test_todo_item.py b/bin/todo_item/test_todo_item.py index 4f15eacf..231bc4d7 100644 --- a/bin/todo_item/test_todo_item.py +++ b/bin/todo_item/test_todo_item.py @@ -72,7 +72,7 @@ class Help(TodoItem): class BadArguments(TodoItem): def test_exit_2(self): - for argv in ([], ADD[:1] + ADD[3:], ["finish"]): + for argv in ([], ADD[:1] + ADD[3:], ["finish"], ["show"]): with self.subTest(argv): self.assertEqual(self.exit_code(*argv), 2) @@ -247,6 +247,67 @@ class Finish(TodoItem): self.assertEqual(self.todo.read_text(), before) +class Show(TodoItem): + HEADER = "| ID | Release | Blocked by | Exempt | Item | L | E | I | R | S | Moves | Score |\n|---|---|---|---|---|---|---|---|---|---|---|---|\n" + + def test_prints_the_header_the_row_and_the_detail(self): + row = next(line for line in self.todo.read_text().split("\n") if line.startswith("| 3 |")) + self.assertEqual(self.run_main("show", "3"), (0, f"{self.HEADER}{row}\n\n### 3. Make it fast, `a | b`.\n\nFast detail.\n", "")) + + def test_prints_the_row_alone_where_the_item_has_no_detail(self): + code, out, err = self.run_main("show", "4") + self.assertEqual((code, err), (0, "")) + self.assertEqual(out.split("\n")[2:], ["| 4 | 0.1.0 | | security | **Rotate the leaked key.** | 3 | 3 | 5 | 9 | 2 | 2.1 by 1 | 12.3 |", ""]) + + def test_prints_a_detail_with_a_sub_heading_whole_and_no_other_detail(self): + self.todo.write_text(self.todo.read_text().replace("Fast detail.\n", "Fast detail.\n\n### Why\n\nFast tail.\n")) + _, out, _ = self.run_main("show", "3") + self.assertTrue(out.endswith("Fast detail.\n\n### Why\n\nFast tail.\n"), out) + + def test_fails_where_the_id_has_no_row(self): + self.assertEqual(self.run_main("show", "99"), (1, "", "todo.md holds no item 99\n")) + + def test_prints_the_row_where_todo_md_has_no_details_section(self): + text = self.todo.read_text() + self.todo.write_text(text[:text.index("## Details")] + text[text.index("## Notes"):]) + code, out, _ = self.run_main("show", "3") + self.assertEqual(code, 0) + self.assertTrue(out.endswith("| 2.1 by 8, 1 by 6 | 5.5 |\n"), out) + + def test_fails_where_todo_md_cannot_be_read(self): + self.todo.unlink() + code, out, err = self.run_main("show", "3") + self.assertEqual((code, out), (1, "")) + self.assertIn("todo.md", err) + + def test_fails_where_todo_md_is_not_utf_8(self): + self.todo.write_bytes(b"# todo\n\n\xff\n") + code, out, err = self.run_main("show", "3") + self.assertEqual((code, out), (1, "")) + self.assertEqual(err, f"{self.todo}: not UTF-8\n") + + def test_reads_todo_md_alone(self): + (self.folder / "README.md").unlink() + self.assertEqual(self.run_main("show", "3")[0], 0) + + def test_fails_where_a_detail_holds_a_fenced_block(self): + self.todo.write_text(self.todo.read_text().replace("Fast detail.\n", "Fast detail.\n\n```\n## Goals\n```\n")) + code, out, err = self.run_main("show", "3") + self.assertEqual((code, out), (1, "")) + self.assertIn("fenced", err) + + def test_takes_a_whole_number_as_the_id(self): + self.assertEqual(self.exit_code("show", "three"), 2) + + def test_changes_no_file(self): + before = self.todo.read_text() + self.run_main("show", "3") + self.assertEqual(self.todo.read_text(), before) + + def test_is_a_command_of_its_own_in_the_docstring(self): + self.assertIn("todo-item show ", main.__doc__) + + class WithBullet(unittest.TestCase): def test_keeps_a_blank_line_before_prose_under_unreleased(self): self.assertEqual(edits.with_bullet("# Changelog\n\n## Unreleased\n\nSome note.\n", "New."), "# Changelog\n\n## Unreleased\n\n- New.\n\nSome note.\n") diff --git a/docs/reading-cost.md b/docs/reading-cost.md index 08167e0a..b5b0c380 100644 --- a/docs/reading-cost.md +++ b/docs/reading-cost.md @@ -1742,3 +1742,15 @@ Read most (opens and searches): - `.gitignore` 1 - `CHANGELOG.md` 1 - `bin/branch_chunks/cut.py` 1 + +## Reading cost, chunk 4588d58235a7, finished 2026-11-12T07:01:48Z + +86934 new input tokens before the first commit. + +Read most (opens and searches): + +- `todo.md` 6 +- `rules/todo-items.md` 3 +- `bin/review_replay/main.py` 2 +- `docs/score-anchors.md` 2 +- `agents/prose-reviewer.md` 1 diff --git a/todo.md b/todo.md index f7a1fb3b..95b304ee 100644 --- a/todo.md +++ b/todo.md @@ -6,7 +6,7 @@ `Bar = 0.1` -`Next ID = 341` +`Next ID = 343` ## Items @@ -14,10 +14,8 @@ |---|---|---|---|---|---|---|---|---|---|---|---| | 340 | 0.9.0 | | question | **Decide whether a reviewer may start without `CLAUDE.md` where its replay misses no more findings than an unchanged replay does.** | 2 | 2 | 3 | 5 | 4 | 1.4 by 5 | 1.7 | | 331 | 0.9.0 | | question | **Reword four decisions to expire when the rungs their replays tested change, not whenever a model joins the ladder.** | 1 | 1 | 1 | 1 | 2 | 1.4 by 2 | 0.9 | -| 312 | 0.9.0 | | | **Research the tooling agents read, search and run commands with, and file an item for each tool that cuts tokens a replay shows keep quality.** | 1 | 2 | 1 | 2 | 3 | 1.4 by 3, 1.5 by 2 | 2.0 | | 325 | 0.9.0 | | | **Give this repo's test suite one command that runs it as README → Test says, prints the failing tests and pytest's summary line, and saves the whole log to a file whose path it prints.** | 3 | 2 | 2 | 5 | 3 | 1.4 by 3, 1.5 by 2 | 2.0 | | 305 | 0.9.0 | | | **Record with each archived verdict the claude-config commit that ran it, the raw tokens each model spent by kind, and each choice of the worker's that the human reversed, so a change to the setup can be judged before and after.** | 3 | 2 | 3 | 6 | 5 | 1.4 by 4, 1.2 by 3 | 1.8 | -| 335 | 0.9.0 | | | **Print an item's row and detail with `todo-item show `.** | 1 | 1 | 2 | 2 | 2 | 1.4 by 3, 1.5 by 1 | 1.8 | | 318 | 0.9.0 | | | **Let `review-replay` qualify a rung whose recall is no lower than the project's rung's own replay, and replay Opus 5.5 at low effort on the prose pass.** | 3 | 2 | 3 | 6 | 4 | 1.4 by 5 | 1.7 | | 308 | 0.9.0 | | | **Skip a stability round 2 whose every must-fix finding named a surviving mutant or a failing test, both of which the worker now checks before review.** | 3 | 2 | 3 | 6 | 4 | 1.4 by 3, 1.5 by 2 | 1.6 | | 295 | 0.9.0 | | | **Have `chunk-pr merge` wait for the forge's required checks itself, and give workers one command that waits for a background log or report file.** | 2 | 2 | 3 | 5 | 3 | 1.4 by 2, 1.5 by 2 | 1.6 | @@ -27,10 +25,10 @@ | 311 | 0.9.0 | | | **Hand each worker's claude a Bash output ceiling that saves longer output to a file, and refuse a Read of a session transcript under `~/.claude/projects`.** | 2 | 2 | 3 | 5 | 3 | 1.4 by 3 | 1.2 | | 316 | 0.9.0 | | | **Launch comprehension seats as an agent type of their own under `agents/`, without `CLAUDE.md` and the skill and agent listings a general-purpose subagent carries.** | 2 | 2 | 2 | 4 | 3 | 1.4 by 3 | 1.2 | | 339 | 0.9.0 | | | **Lower the reading cost of the files a chunk reads most before its first commit.** | 2 | 2 | 1 | 3 | 3 | 1.4 by 3 | 1.2 | +| 341 | 0.9.0 | | | **Hand each worker's claude a lower Read limit through `CLAUDE_CODE_FILE_READ_MAX_OUTPUT_TOKENS`, kept only where replays of the archived review rounds find what two unchanged replays find.** | 2 | 2 | 3 | 5 | 3 | 1.4 by 3 | 1.2 | | 310 | 0.9.0 | | | **Compact a waiting worker's session shortly before its prompt cache expires, only when the human has not answered an interrupt by then.** | 3 | 2 | 3 | 6 | 4 | 1.4 by 3 | 1.0 | | 298 | 0.9.0 | | | **Send the judge only the decision entries and the transcript tail a verdict needs, and keep the cut only where `judge-replay` changes no verdict kind.** | 3 | 3 | 3 | 7 | 4 | 1.4 by 2, 1.5 by 1 | 1.0 | | 326 | 0.9.0 | | | **Let `chunk-pr ready` take the pull request's final title and set it as it marks the pull request ready.** | 2 | 1 | 3 | 4 | 2 | 1.4 by 1, 1.5 by 1 | 0.9 | -| 337 | 0.9.0 | | | **Write each Bash call of a release's chunks to a file of JSON lines with `command-patterns --calls `.** | 1 | 1 | 1 | 1 | 2 | 1.4 by 1, 1.5 by 1 | 0.9 | | 332 | 0.9.0 | | defect | **Let `deploy-release` move a checkout whose `settings.json` differs from the release only by a `/model` pick or the key order Claude Code writes.** | 2 | 2 | 2 | 4 | 2 | 1.5 by 2 | 0.9 | | 336 | 0.9.0 | | | **Bring a chunk's branch level with origin's default branch, and print the rank check, with one `chunk-pr sync`.** | 2 | 2 | 3 | 5 | 3 | 1.4 by 1, 1.5 by 1 | 0.8 | | 334 | 0.9.0 | | | **Set up a scoring run with one `larv-review` command that makes the scoring worktree, writes each seat's prompt file, and removes both once `record-scoring` has run.** | 3 | 2 | 2 | 5 | 5 | 1.4 by 2, 1.5 by 1 | 0.7 | @@ -50,6 +48,7 @@ | 300 | 0.10.0 | | owner | **Restructure the places the comprehension seats found hardest to follow, so the project reads at 7.0 or above on every dimension, Locality first: today the comprehension floor run at 52da15e scored Locality 6.00, Shape 6.25, Self-sufficiency 6.38 and Overall 6.38.** | 4 | 2 | 3 | 7 | 8 | code health by 8 | 2.0 | | 264 | 0.10.0 | | | **Report the comprehension seats and the escalated subagents as subagent types of their own in `routing-figures.md`, with their dollars.** | 2 | 2 | 1 | 3 | 3 | 1.4 by 5 | 2.0 | | 323 | 0.10.0 | | | **Count a release review as landed once its pull request has merged, whatever its commits are titled.** | 3 | 2 | 3 | 6 | 3 | 1.4 by 3, 1.5 by 2 | 2.0 | +| 342 | 0.10.0 | | | **Research the tooling agents read, search and run commands with once more, and file an item for each tool that cuts tokens a replay shows keep quality.** | 1 | 2 | 1 | 2 | 3 | 1.4 by 3, 1.5 by 2 | 2.0 | | 149 | 0.10.0 | | decision | **Fill each release by priority up to a capacity it states, in place of the bar, and move what does not fit to a later release.** | 4 | 2 | 3 | 7 | 5 | 1.1 by 7 | 1.8 | | 165 | 0.10.0 | | | **Make this repo's tests assert the facts a prompt or help text carries in place of its sentences, and drop the tests that scan source or assert a constant.** | 3 | 2 | 1 | 4 | 5 | 1.1 by 4, 1.4 by 3 | 1.8 | | 151 | 0.10.0 | | decision | **Keep 10 to 20 settled decisions per project as its goals' test set, and rerun them after a goal changes.** | 3 | 2 | 2 | 5 | 5 | 1.2 by 7 | 1.8 | @@ -97,14 +96,6 @@ The architect's 🔀 answer on PR #493 (item 292): four decisions expire "when a Recommendation: reword all four as above. They are decisions the repo held before item 292, so the rewording is lilleman's call. -### 312. Research the tooling agents read, search and run commands with, and file an item for each tool that cuts tokens a replay shows keep quality. - -lilleman, 2026-11-11: besides an output ceiling, keep evaluating better tooling. The token research of that day found tool results carried in context cost about 21% of spend, reads by subagents the most, and that the tools themselves move fast: deferred tool loading, output saved to files, code-execution over tools, LSP and repo-map navigation, structured test output. Item 231 tried a scout, an outline script and LSP in October and none kept every finding. - -Run a research round like that of 2026-11-11: a lead on the project's rung plans the searches, cheaper subagents search and distil sourced findings, and the lead checks every claim it relies on against this archive's measured spend. File an item for each tool that a replay could test. lilleman, 2026-11-11: repeat the round once per claude-config release, not per project. When this item's chunk finishes, file the next round into the next claude-config release with items left, so the check comes back periodically. - -The 0.8.0 audit (item 284) measured: over the 35 chunks that shipped 0.7.0, workers made 36 Edit calls but about 250 `python3` heredocs that replace a string in a file and write it back, about 120k command tokens of the 135k that all 375 `python3` calls took. They read files with `sed` in 493 Bash calls and `cat` in 188, for 351k and 328k result tokens, beside 691 Read calls. Edit refuses a file not read with the Read tool, so a worker that read a file with `sed` or `cat` probably edits it through python. Check that cause, and whether reading through Read, or an Edit that accepts such a file, cuts tokens and keeps quality. - ### 325. Give this repo's test suite one command that runs it as README → Test says, prints the failing tests and pytest's summary line, and saves the whole log to a file whose path it prints. The 0.8.0 audit (item 284) measured, over the 35 chunks that shipped 0.7.0: 163 to 176 Bash calls ran pytest, mutation runs excluded, in 29 chunks, for about 32k command tokens and 3,000 to 3,500 s of wall time. Each worker typed README → Test's incantation, with its pins, and cut the output with its own `| tail -N`: 14 spellings (tail sizes 1, 2, 3, 4, 5, 6, 8, 12, 15, 20, 25, 30 and 70, or no tail in 44 calls). A short tail cuts a failing run's evidence, and a long run without one floods the context. @@ -123,14 +114,6 @@ Three records the archive lacks, asked for by lilleman on 2026-11-11 after the t Build on item 303's archive layout for the judge's part. -### 335. Print an item's row and detail with `todo-item show `. - -Found by item 328's audit of release 0.8.0. All 9 of its chunks looked items up in `todo.md` by hand: `grep -n '^### N'`, `awk '/^### N\./,/^### [0-9]+\./'` ranges, `sed -n` offsets computed from a grep, and several retries to find the `## Details` line first. About 29 calls did only that, costing 1.3k command tokens and 15.9k result tokens; a looser grep over the audit's calls finds 40 such calls in all 9 chunks, many of them compound with other reads. Most of the result tokens went on reading far more than the one item, such as `sed -n 1,140p todo.md`. - -`todo-item show ` prints the item's table row, under the table's header line, and its detail, from `### .` to the next heading, and fails, saying so, where the ID has no row. It reads only `todo.md`, so it fits beside `add` and `finish` in `bin/todo_item/main.py`. `CLAUDE.md` → "Working loop" tells a worker to read the details of the items its chunk takes; that line names the command once it ships. - -Left with the model: reading the item and judging what it asks. - ### 318. Let `review-replay` qualify a rung whose recall is no lower than the project's rung's own replay, and replay Opus 5.5 at low effort on the prose pass. Today a rung qualifies only if it re-finds every finding the project's rung found. The project's rung itself re-finds only 69 to 73% of its own findings on a replay (29 of 40, 27 of 39, 20 of 29), so even a reviewer exactly as good would fail, and "no pass has such a rung" says less than it seems. Qualify a rung when its share of the archived findings is no lower than the project's rung's own replay share, within a margin, over enough rounds, and it misses no 🔴 that both project-rung runs found. Then replay Opus 5.5 at low effort on the prose pass first, the pass whose misses cost least; the `effort` frontmatter key sets it per reviewer. @@ -167,7 +150,7 @@ The judge's LLM still decides three things: the verdict kind, the escalation it ### 311. Hand each worker's claude a Bash output ceiling that saves longer output to a file, and refuse a Read of a session transcript under `~/.claude/projects`. -Workers took 7,870 Bash results over 3,000 characters, $305 of carried context, against the reading rule in their prompt; stability reviewers another $145. `BASH_MAX_OUTPUT_LENGTH` (or `bashOutputMaxChars`) makes Claude Code save a longer result to a file and hand the model its path and the first 2,000 characters. loop-claude can hand it as it hands `CLAUDE_CODE_AUTO_COMPACT_WINDOW`. A ceiling of 6,000 characters would have removed $228 of carried output, 10,000 characters $122. Reads of old session transcripts cost $46; a rule-hook rule can refuse them. +Workers took 7,870 Bash results over 3,000 characters, $305 of carried context, against the reading rule in their prompt; stability reviewers another $145. `BASH_MAX_OUTPUT_LENGTH` (or `bashOutputMaxChars`) makes Claude Code save a longer result to a file and hand the model its path and the first 2,000 characters. loop-claude can hand it as it hands `CLAUDE_CODE_AUTO_COMPACT_WINDOW`. A ceiling of 6,000 characters would have removed $228 of carried output, 10,000 characters $122. Reads of old session transcripts cost $46; a rule-hook rule can refuse them, but not a Read of the files Claude Code saves a long Bash result to: they sit under `~/.claude/projects///tool-results/`, the archive holds 85 of them (item 312's round, 2026-11-12), and the saved-to-file ceiling hands the model their path to read. Subagents inherit the variable, and the decision of 2026-10-27 found a 12k cap cost stability reviewers a finding (3 of 6 against 4 of 6). That cap left no file to read, and the difference is inside the noise that decision reports. So keep the ceiling only where a replay of the archived stability rounds finds what two baseline replays find, and join item 260's comparison. @@ -179,6 +162,16 @@ Seats run as general-purpose subagents, so each starts with the skill and agent `reading-cost` printed `Rising:` on 2026-11-12: the last 5 chunks' median is 128,199 new input tokens before their first commit, the 5 before them 101,795. Read most over the last 5, as opens and searches: `todo.md` 34, `docs/decisions.md` 26, `README.md` 19, `skills/larv-review/SKILL.md` 13, `bin/loop_claude/routing.py` 8, `CHANGELOG.md` 6. The chunk that ships this runs `reading-cost --reset`. +### 341. Hand each worker's claude a lower Read limit through `CLAUDE_CODE_FILE_READ_MAX_OUTPUT_TOKENS`, kept only where replays of the archived review rounds find what two unchanged replays find. + +Raised by item 312's research round, 2026-11-12. Over the 53 chunks archived since 2026-09-30, Read results held about 3.17M tokens (characters / 4) in 1,617 reads. Results over 20,000 characters, about 5,000 tokens, held 479k tokens beyond that size in 115 reads: prose reviewers 144k, stability reviewers 119k, product-owner reviewers 102k, general-purpose subagents 65k, principles auditors 28k, architects 21k. Workers had none, under the reading rule in their prompt. Measured with a script over loop-claude's archive that sums each Read tool_result's characters by the subagent's `agentType`. The decision of 2026-10-27 found Read results out of a PostToolUse hook's reach; this variable reaches them. + +`CLAUDE_CODE_FILE_READ_MAX_OUTPUT_TOKENS` overrides the Read tool's default limit of 25,000 tokens (https://code.claude.com/docs/en/env-vars, read 2026-11-12: "Override the default token limit for file reads, which is 25,000 tokens."). Claude Code 2.1.322's binary holds the name. A read over the limit fails and asks for an offset and a limit, so an agent may page through the same file and save nothing; the replay measures that. + +loop-claude can hand it as it hands `CLAUDE_CODE_AUTO_COMPACT_WINDOW`, and subagents inherit it, the principles auditors included. The choice of 2026-10-27 that the principles audit reads the project whole holds as long as it pages through what it reads. + +The replay: give `review-replay` a way to set the variable, then replay the archived prose, stability, product-owner and principles rounds at 5,000 tokens, beside two unchanged replays of the same rounds. Keeps quality where each pass finds every finding the two unchanged replays both find, or meets item 340's control where that has landed. Keep it only where the replays' Read characters also fall; item 311's stability replay can share the baseline runs. + ### 310. Compact a waiting worker's session shortly before its prompt cache expires, only when the human has not answered an interrupt by then. 281 worker resumes after the 1-hour cache expired rewrote a whole context, $379 of the $9,154 measured from 2026-09-30 to 2026-11-11 (4.1%). A compaction while the cache is warm reads the context at a twentieth of the input price and leaves about 20k tokens to rewrite later. @@ -199,14 +192,6 @@ Let `chunk-pr ready` take an optional final title and set it as it marks the pul Left with the model: wording the title. -### 337. Write each Bash call of a release's chunks to a file of JSON lines with `command-patterns --calls `. - -Found by item 328's audit of release 0.8.0. `command-patterns ` prints only a table of patterns, so an audit that must read the calls behind a pattern writes its own script. This audit wrote a 20-line Python script over `read_threads` and `calls` to dump 0.8.0's 2,317 calls, one per line, with the chunk, the pattern, the seconds, the command's and the result's sizes, and the command's text. Item 284's chunk, the 0.7.0 audit, wrote `/tmp/audit284/calls.jsonl` the same way. Each audit pays for writing and checking that script again, and item 328 recurs every release. - -`--calls ` writes one JSON object per Bash call to ``, besides printing the table: the chunk's number in the window, the pattern `pattern` in `bin/command_patterns/tally.py` gives it, its seconds, its command's and its result's characters, and the command's text. It needs `Call` to carry its pattern and its chunk, or `main.py` to pair them as it tallies. `command-patterns --help` and item 328's recurring detail name the flag. - -Left with the model: reading the calls and judging which steps a program computes the same way each time. - ### 332. Let `deploy-release` move a checkout whose `settings.json` differs from the release only by a `/model` pick or the key order Claude Code writes. On 2026-11-12, moving `~/.claude` from v0.7.0 to v0.8.0, `deploy-release` failed at `git checkout --quiet --detach v0.8.0`: "Your local changes to the following files would be overwritten by checkout: settings.json". Claude Code had rewritten the file with `"model": "opus"` and its keys in another order. The `settings` clean filter drops the model and sorts the keys, so `git diff` showed no change and the tool's own check passed, but checkout compares the file as it is on disk. `deploy-release --help` says a model picked with `/model` doesn't block the move. @@ -279,7 +264,7 @@ Put the seven helpers in a folder named by what it holds, such as `bin/forge/`, ### 338. Script each step that 0.9.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. -lilleman asked, on 2026-10-16, for a standing audit each release, so the loop keeps moving work a program does as well from the model to scripts (goals 1.4 and 1.5). This audit reads the archived transcripts of the chunks that shipped release 0.9.0 for every step that chunks repeated by hand, before, during or after review. It keeps the steps whose answer a program computes the same way each time, such as a lookup, a check, a prompt assembled for a reviewer, a cleanup. File one item per such step, with the time and tokens it cost, into the next release with items left. Leave a step that needs judgement with the model. Run `command-patterns 0.9.0` first; its table names the patterns, and `read_threads` and `calls` in `bin/command_patterns/tally.py` open the calls of one pattern, or `--calls ` dumps them once item 337 ships. The 0.7.0 audit found that most steps its chunks repeated were already scripted by that release's own tools, so a step a shipped item already covers is not filed. +lilleman asked, on 2026-10-16, for a standing audit each release, so the loop keeps moving work a program does as well from the model to scripts (goals 1.4 and 1.5). This audit reads the archived transcripts of the chunks that shipped release 0.9.0 for every step that chunks repeated by hand, before, during or after review. It keeps the steps whose answer a program computes the same way each time, such as a lookup, a check, a prompt assembled for a reviewer, a cleanup. File one item per such step, with the time and tokens it cost, into the next release with items left. Leave a step that needs judgement with the model. Run `command-patterns 0.9.0` first; its table names the patterns, and `read_threads` and `calls` in `bin/command_patterns/tally.py` open the calls of one pattern, or `command-patterns 0.9.0 --calls ` dumps them all as JSON lines. The 0.7.0 audit found that most steps its chunks repeated were already scripted by that release's own tools, so a step a shipped item already covers is not filed. The 0.8.0 audit filed four steps, items 334, 335, 336 and 337, and found most other repeated steps already covered by items 295, 312, 325, 326 and 327. @@ -374,6 +359,23 @@ Seats launch as `general-purpose`, so they hide inside that type: $301.24 of the `release_reviewed` in `bin/release_plan/release_standing.py` counts a release review only by a commit titled `Release review of ` on the default branch. In a replay of archived interrupts (`judge-field-trials/`), in two projects whose release review had merged, the default branch held no such commit, so `chunk-preflight` and routing read ReviewDue, and the next loop would run the release review again. `skills/larv-review/SKILL.md` opens the review's branch with an empty commit of that title, but a worker may skip it, and a rebase or squash merge, which `chunk-pr` uses where the forge allows no merge commit, may drop it. Detect the review by something every merge method keeps, and check the fix against both projects' histories. Until then the judge keeps `release_ready` (docs/decisions.md → `routing: loop-claude reads the items a chunk takes …`). +### 342. Research the tooling agents read, search and run commands with once more, and file an item for each tool that cuts tokens a replay shows keep quality. + +The next round of item 312's research, filed when 312's round ran on 2026-11-12. lilleman, 2026-11-11: repeat the round once per claude-config release, not per project. When this item's chunk finishes, file the next round into the next claude-config release with items left. + +Run it as 312's ran: a lead on the project's rung plans 6 to 10 searches where the archive's spend is, cheaper subagents with web access only return sourced findings, and the lead checks each claim against the archive's measured spend before filing. + +Sources that proved useful in 312's round: Claude Code's environment variable reference (https://code.claude.com/docs/en/env-vars), its subagent reference (https://code.claude.com/docs/en/sub-agents), its CHANGELOG (https://github.com/anthropics/claude-code/blob/main/CHANGELOG.md), the API's context editing and tool search pages (https://platform.claude.com/docs/en/build-with-claude/context-editing, https://platform.claude.com/docs/en/agents-and-tools/tool-search-tool), and Anthropic's post on code execution with MCP (https://www.anthropic.com/engineering/code-execution-with-mcp). Check a variable a source names with a grep of the installed Claude Code binary; issue mirrors and blogs gave leads but no figure to rely on. The archive counts that decided: `command-patterns --calls`, and scripts in /tmp over loop-claude's archive summing tool results by agent type, cache writes by lifetime and request gaps, and each subagent's first request. + +Dropped in 312's round, and why; look again only where the reason has changed: +- Editing through Edit in place of `python3` heredocs: Edit already accepts a file read with `sed` or `cat` on Claude Code 2.1.319 to 2.1.322, 27 such Edits in 0.7.0 and 0.8.0 and no "not read yet" refusal in the archive, and an Edit would have saved about 2,300 command tokens per chunk. +- Forcing 5-minute caches on the worker or 1-hour ones on subagents (`FORCE_PROMPT_CACHING_5M`, `ENABLE_PROMPT_CACHING_1H`): over 53 chunks, the worker's 1-hour writes cost $217 at list prices against $233 for 5-minute ones, and subagents' 5-minute writes cost $226 against $289 for 1-hour ones. +- A security-pass agent type with fewer tools: its 49 runs started at a median 30k tokens and cost $14 in all. +- Deferred tool loading: already on, since `ENABLE_TOOL_SEARCH` defaults on and saves MCP tool definitions only. +- Context editing and programmatic tool calling: API features that Claude Code doesn't expose as a setting. +- LSP, repo maps and outline scripts: item 231's trial lost findings and agents didn't call them; the only figures found since are a vendor's and a blog's. +- Compact test reporters and output filters such as rtk: this archive's test output is a few thousand tokens per release, and the filters' figures are their own; trimming read output is item 311's ceiling. + ### 149. Fill each release by priority up to a capacity it states, in place of the bar, and move what does not fit to a later release. A release's capacity is a sum of its items' cost, as the formula counts it. Each project states its own; the human sets the first value per project. Nothing is deleted by score.