diff --git a/CHANGELOG.md b/CHANGELOG.md index efd90df6..9fd4fdd7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,7 @@ ## Unreleased +- `chunk-preflight` now quotes the detail of each item that may join the chunk, so a worker no longer opens `todo.md` to read it. - `command-patterns []` prints a table of the shell command patterns a release's chunks ran. - `deploy-release --cut` reports each step as it finishes, waits for the checks `main`'s protection requires and names them, deletes the merged release branch, and ends on one line saying the release is cut. - CI runs the test suite on every pull request, and `main` merges nothing until it passes. diff --git a/CLAUDE.md b/CLAUDE.md index facbe471..e8c1180b 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 publishes nothing 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 the items that may join it; read further only 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 every decision's title. Read the entry under a title in `docs/decisions.md` only where 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. `AGENTS.md` lists every decision's title. Read the entry under a title in `docs/decisions.md` only where 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/bin/chunk_preflight/choices.py b/bin/chunk_preflight/choices.py index 9cd5e1b5..66428f5c 100644 --- a/bin/chunk_preflight/choices.py +++ b/bin/chunk_preflight/choices.py @@ -50,7 +50,7 @@ def planned(todo: str | Failure, cut: LastCut, default: str) -> Plan | NoItem: return NoItem(f"every item of release {version(pick.release)} in {where} waits." if pick.release is not None else f"{where}'s items table holds no item.") details = item_details(todo) detail = details.get(first.id, "") if isinstance(details, dict) else f"(todo.md's details cannot be read: {details.reason})" - return Plan(found, first, f"{first.tagline}\n\n{detail}".strip()) + return Plan(found, first, f"{first.tagline}\n\n{detail}".strip(), details) def worktree_on(porcelain: str, branch: str) -> pathlib.Path | None: diff --git a/bin/chunk_preflight/facts.py b/bin/chunk_preflight/facts.py index aa438777..4c1f5019 100644 --- a/bin/chunk_preflight/facts.py +++ b/bin/chunk_preflight/facts.py @@ -4,12 +4,16 @@ from chunk_preflight.choices import cut_name, PULLS_LIST from release_plan.release_standing import dated_cut, LastCut, unreleased_entries from failure import Failure from chunk_preflight.gathered import Forge, Gathered, ItemFacts, NamedPath, NoItem, Plan, Ran -from records.markdown_text import quoted +from records.markdown_text import listed, quoted from release_plan.release import version +# CLAUDE.md → "Working loop" lets up to ten tiny items share a chunk, so a worker never needs more. A release with 24 joinable items would otherwise put about 155 lines of detail in every prompt. +JOINING_DETAILS = 10 + + def render(found: Gathered) -> list[str]: - """One `- ` line per fact, then the item's tagline and detail, and what each tool printed.""" + """One `- ` line per fact, then the item's tagline and detail, the detail of each item that may join its chunk, and what each tool printed.""" note = [f"- {found.note}"] if found.note else [] head = [*note, f"- {last_release(found.default, found.cut)}"] if isinstance(found.item, NoItem): @@ -42,10 +46,25 @@ def item_lines(default: str, item: ItemFacts) -> list[str]: *bundled(item.plan), *named_lines(item.named), f"\nItem {first.id}'s tagline and detail:\n\n{quoted(item.plan.text)}", + *joining_details(item.plan), *(f"\n{printed(shown, done)}" for shown, done in item.tools), ] +def joining_details(plan: Plan) -> list[str]: + """The detail of each of the first JOINING_DETAILS items that may join the chunk, in the table's order, and what the worker lacks: an item with no detail, the items left out, or details that cannot be read.""" + joining = bundle_candidates(plan.items, plan.first) + if not joining: + return [] + if isinstance(plan.details, Failure): + return [f"\nThe details of the items that may join cannot be read: {plan.details.reason}"] + shown, left = joining[:JOINING_DETAILS], joining[JOINING_DETAILS:] + lines = [f"\nItem {item.id}'s detail:\n\n{quoted(detail)}" if (detail := plan.details.get(item.id)) else f"\nItem {item.id} has no detail." for item in shown] + if left: + lines.append(f"\nThe details of items {listed([str(item.id) for item in left], 'and')} are not quoted: only the first {JOINING_DETAILS} are. Open `todo.md` for them.") + return lines + + def pulls_text(pulls: tuple[Forge, Ran | Failure] | None, branch: str) -> str: """Each open pull request from branch, by its number and URL, or why none can be listed. No title: on a public forge anyone may open one, and its title would reach the worker's prompt.""" if pulls is None: diff --git a/bin/chunk_preflight/gathered.py b/bin/chunk_preflight/gathered.py index 0b5e59ad..4ef47b60 100644 --- a/bin/chunk_preflight/gathered.py +++ b/bin/chunk_preflight/gathered.py @@ -26,6 +26,8 @@ class Plan: first: Item # first's tagline and detail. text: str + # Every item's detail by its ID, or why todo.md's details cannot be read. + details: dict[int, str] | Failure @property def branch(self) -> str: diff --git a/bin/chunk_preflight/main.py b/bin/chunk_preflight/main.py index 1509084a..760f7f38 100644 --- a/bin/chunk_preflight/main.py +++ b/bin/chunk_preflight/main.py @@ -32,11 +32,12 @@ todo.md as the default branch holds it, the plan loop-claude routes on. It print 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 - questions, that have R 5 or less, and that no item outside the chunk blocks; none where the - item's own R is above 5; +- the items of that release that a chunk taking the item may take too, each with its L, E + I, + S and tagline: those that are not questions, that have R 5 or less, and that no item outside + the chunk blocks; none where the 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; + file's lines or a folder's files, then the item's tagline and detail, then the detail of each + of the first {JOINING_DETAILS} items that may join, or that one has none; - 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 @@ -62,8 +63,8 @@ from release_plan.release_standing import default_plan from failure import Failure from chunk_preflight.gathered import Forge, Gathered, ItemFacts, NamedPath, NoItem, Plan, Ran, Worktree from chunk_preflight.choices import forge_of, planned, pulls_command, worktree_add, worktree_on +from chunk_preflight.facts import JOINING_DETAILS, render from release_plan.named_code import named_paths -from chunk_preflight.facts import render BIN = pathlib.Path(__file__).resolve().parents[1] # Each tool run in the item's worktree, {item} standing for the item's ID. @@ -77,7 +78,7 @@ WORKTREE = "--worktree" def main(argv: list[str], env: typing.Mapping[str, str]) -> int: if argv in (["-h"], ["--help"]): - print(__doc__.strip().format(timeout=TIMEOUT)) + print(__doc__.strip().format(timeout=TIMEOUT, JOINING_DETAILS=JOINING_DETAILS)) return 0 if argv not in ([], [WORKTREE]): print(f"unknown arguments {' '.join(argv)}; usage: chunk-preflight [{WORKTREE}]", file=sys.stderr) diff --git a/bin/chunk_preflight/test_chunk_preflight.py b/bin/chunk_preflight/test_chunk_preflight.py index f5790919..c077f1bf 100644 --- a/bin/chunk_preflight/test_chunk_preflight.py +++ b/bin/chunk_preflight/test_chunk_preflight.py @@ -340,6 +340,29 @@ class Render(unittest.TestCase): self.assertIn("item 7, L 1, E + I 2, S 1: **Do the thing after.**", said) self.assertNotIn("item 8,", said) + def test_quotes_the_detail_of_each_item_that_may_join_the_chunk(self): + said = rendered(item_facts(TODO + "\n### 7. Do the thing after.\n\nTouch `src/other.py`.\n\nRun the e2e leg.\n\n### 8. Do the answered thing.\n\nNot quoted.\n")) + self.assertIn("Item 7's detail:\n\n> Touch `src/other.py`.\n> \n> Run the e2e leg.", said) + self.assertNotIn("Not quoted", said) + + def test_states_that_a_joining_item_has_no_detail(self): + said = rendered(item_facts()) + self.assertIn("Item 7 has no detail.", said) + self.assertNotIn("Item 7's detail", said) + + def test_states_that_the_joining_items_details_cannot_be_read(self): + said = rendered(item_facts(TODO + "\n```\nx\n```\n")) + self.assertIn("The details of the items that may join cannot be read: ## Details holds a fenced code block", said) + self.assertNotIn("has no detail", said) + + def test_quotes_the_details_of_the_first_ten_joining_items_and_names_the_rest(self): + rows = "".join(f"| {id_} | 0.2.0 | | | **Do thing {id_}.** | 1 | 1 | 1 | 1 | 1 | 1 by 1 | 10.0 |\n" for id_ in range(20, 32)) + details = "".join(f"\n### {id_}. Do thing {id_}.\n\nDetail {id_}.\n" for id_ in range(7, 8)) + "".join(f"\n### {id_}. Do thing {id_}.\n\nDetail {id_}.\n" for id_ in range(20, 32)) + said = rendered(item_facts(TODO.replace("\n## Details", rows + "\n## Details") + details)) + self.assertIn("> Detail 28.", said) + self.assertNotIn("Detail 29.", said) + self.assertIn("The details of items 29, 30 and 31 are not quoted: only the first 10 are. Open `todo.md` for them.", said) + def test_states_the_items_worktree_or_why_none_was_made(self): self.assertIn("/c/proj-item-3", rendered(item_facts())) self.assertIn("none made: path taken", rendered(item_facts(worktree=Failure("none made: path taken")))) diff --git a/docs/reading-cost.md b/docs/reading-cost.md index 89b336ab..bbb3c016 100644 --- a/docs/reading-cost.md +++ b/docs/reading-cost.md @@ -1424,3 +1424,15 @@ Read most (opens and searches): - `bin/larv_review/history_commands.py` 2 - `bin/larv_review/reviewer_header.py` 2 - `bin/review_replay/rounds.py` 2 + +## Reading cost, chunk 0d35c9a64c98, finished 2026-11-09T02:21:29Z + +58201 new input tokens before the first commit. + +Read most (opens and searches): + +- `todo.md` 6 +- `skills/larv-review/SKILL.md` 4 +- `docs/decisions.md` 2 +- `README.md` 1 +- `bin/repo_checks/test_types.py` 1 diff --git a/skills/larv-review/SKILL.md b/skills/larv-review/SKILL.md index 67e95957..f5f68619 100644 --- a/skills/larv-review/SKILL.md +++ b/skills/larv-review/SKILL.md @@ -26,7 +26,7 @@ Follow `~/.claude/CLAUDE.md` → "Git, commits, and PRs". Never commit to the de **Work in the worktree.** Enter the chunk's worktree with the `EnterWorktree` tool, `path` set to it, unless the session already works there. A reviewer, a seat and the security pass's skill read the diff of the session's working directory, and a subagent starts there; from the checkout root they find the branch's diff empty. -**Reading cost.** Run `~/.claude/bin/reading-cost` in the chunk's worktree, unless loop-claude's prompt shows that `chunk-preflight` already ran it there, and commit what it appends to `docs/reading-cost.md`; the commit re-enters no pass. Resolve a merge conflict in that file by putting the default branch's figures first and dropping a figure for a chunk the default branch already holds. On `Rising:`, file a plan item titled `**Lower the reading cost of the files a chunk reads most before its first commit.**`, scored per `~/.claude/rules/todo-items.md` with the tool's medians and files as its detail; where the plan already holds it, refresh its detail instead. The item names the next release, or the one after when this chunk ships the next release's last item. On exit 1, repair what its message names and run it again; when the message names no repair, file it as a `question` item, or refresh the question item an earlier run filed, and go on. Leave the plan as it is on any other output. The chunk that ships that item runs the tool with `--reset` instead, so the next rise is measured on chunks that finished after it. +**Reading cost.** Run `~/.claude/bin/reading-cost` in the chunk's worktree, unless loop-claude's prompt shows that `chunk-preflight` already ran it there, and commit what it appends to `docs/reading-cost.md`; the commit re-enters no pass. Resolve a merge conflict in that file by putting the default branch's figures first and dropping a figure for a chunk the default branch already holds. On `Rising:`, file a plan item titled `**Lower the reading cost of the files a chunk reads most before its first commit.**`, scored per `~/.claude/rules/todo-items.md` with the tool's medians and files as its detail; where the plan already holds it, leave it as it is: `docs/reading-cost.md` holds the figures. The item names the next release, or the one after when this chunk ships the next release's last item. On exit 1, repair what its message names and run it again; when the message names no repair, file it as a `question` item, or refresh the question item an earlier run filed, and go on. Leave the plan as it is on any other output. The chunk that ships that item runs the tool with `--reset` instead, so the next rise is measured on chunks that finished after it. ## 3. Passes diff --git a/todo.md b/todo.md index 03b87e29..87d37f74 100644 --- a/todo.md +++ b/todo.md @@ -14,7 +14,6 @@ |---|---|---|---|---|---|---|---|---|---|---|---| | 277 | 0.7.0 | | question | **Map the size of the code an item names onto S, on a scale the human picks, and have `score-outcomes` print that S for the item being scored and for each finished item it lists.** | 3 | 2 | 2 | 5 | 4 | 1.1 by 4, 1.4 by 3 | 2.4 | | 1 | 0.7.0 | | question | **Say in README → Install how the transcript archive is backed up, once bender-infra backs up ai-sandbox's data volume.** | 1 | 2 | 1 | 2 | 1 | | 0.0 | -| 285 | 0.7.0 | | | **Cut a worker's opens and searches of `todo.md` from the median 7 per chunk to at most 3, by finding in the last five chunks' archived transcripts what each read was for and removing its cause.** | 2 | 2 | 3 | 5 | 3 | 1.4 by 4 | 1.6 | | 281 | 0.7.0 | | | **Remove a merged chunk's worktree and branch and fast-forward the main checkout with one command.** | 3 | 2 | 3 | 6 | 3 | 1.4 by 2, 1.5 by 2 | 1.6 | | 274 | 0.7.0 | | | **Let an item name a maintain goal it raises confidence in, such as a test leg that guards it, and weigh that move against the achieve goals in `bin/release_plan/ranking.py`.** | 2 | 2 | 3 | 5 | 4 | 1 by 3 | 1.1 | | 286 | 0.7.0 | | | **Lower the reading cost of the files a chunk reads most before its first commit.** | 3 | 2 | 2 | 5 | 5 | 1.4 by 4 | 1.0 | @@ -71,14 +70,6 @@ It lives under `~/.claude`, which `.gitignore` keeps from the remote, so a lost The README line covers the bench's transcripts in `workflow-bench/logs/` too (goal 3). -### 285. Cut a worker's opens and searches of `todo.md` from the median 7 per chunk to at most 3, by finding in the last five chunks' archived transcripts what each read was for and removing its cause. - -Item 105 compared the five chunks before and after the `worker:` decision, merged 2026-10-13 at 06:49Z in 21b060e, matching chunks to PRs by finish time. Reading cost, the new input tokens before the first commit, rose: median 56,802 before and 136,132 after. The ranges, 46k to 172k and 50k to 140k, overlap. Review rounds per pass did not rise: 2.26 before and 1.52 after, among the five multi-pass chunks on each side. - -Over those chunks the workers opened or searched `todo.md` 11 times before and 31 after, and `docs/decisions.md` 8 and 20. The last five chunks, per `reading-cost`, still opened or searched `todo.md` 34 times, a median of 7 per chunk, and `README.md` 6 times. `chunk-preflight` already puts the item's facts in the worker's prompt. - -Some reads serve an edit, since Edit needs a Read first; items 278 and 279 remove those for removing and adding an item. This item follows them but does not wait for them. Find the rest in the transcripts under `~/.claude/loop-claude-transcripts/`, one `.jsonl` per session. Name what each remaining read was for, and fix that cause, such as in `chunk-preflight` or the worker's prompt. - ### 281. Remove a merged chunk's worktree and branch and fast-forward the main checkout with one command. Audit of release 0.2.0's chunks (item 162): 31 chunks ran `git worktree remove`, `git branch -d` and `git pull --ff-only` by hand, 56 calls and about 5k command tokens. The program refuses a dirty main checkout, as `CLAUDE.md` → "Working with the codebase" says, and reports it. @@ -109,7 +100,7 @@ goal is still redesigned or dropped. `reading-cost` reports Rising: the last five chunks' median is 151,930 new input tokens before the first commit, against 103,215 for the five before them. Those five chunks opened or searched these files most: `todo.md` 42 times, `README.md` 16, `docs/decisions.md` 12, `AGENTS.md` 10, `bin/rank_todo.py` 9, `bin/release_plan/ranking.py` 8, `docs/reading-cost.md` 8, `CHANGELOG.md` 7, `rules/todo-items.md` 7 and `bin/rule_hook/test_rule_hook.py` 6. -Item 285 takes the `todo.md` reads; this item takes the rest. Find why a worker opens each of them before its first commit, and cut that cause, such as a test file too large to read in parts. +Item 285 removed the `todo.md` reads for a joining item's detail; the rest are for edits. Find why a worker opens each of them before its first commit, and cut that cause, such as a test file too large to read in parts. ### 284. Script each step that 0.7.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.