File and finish todo.md items with todo-item add and todo-item finish #446

Merged
lilleman merged 10 commits from item-279 into main 2026-11-09 01:53:44 +01:00
12 changed files with 526 additions and 12 deletions
+3
View File
@@ -89,6 +89,9 @@
!bin/subagent_rung/
!bin/subagent_rung/*.py
!bin/test_*.py
!bin/todo-item
!bin/todo_item/
!bin/todo_item/*.py
!bin/transcript_archive/
!bin/transcript_archive/*.py
!docs/
+2
View File
@@ -2,6 +2,8 @@
## Unreleased
- `todo-item add` now files an item in `todo.md` with one command. It takes `Next ID` as the item's ID, raises `Next ID`, writes the row and the detail it reads from stdin, and ranks the file.
- `todo-item finish <ID>` now removes a finished item's row and detail from `todo.md`. With `--changelog <bullet>`, it also adds that bullet first under `CHANGELOG.md` → `## Unreleased`. Where a `CHANGELOG.md` exists, it refuses to run without `--changelog <bullet>` or `--no-changelog`, so no bullet is left out by mistake.
- A worker whose review rules its work below standard now fixes it on its own rung where the fix changes only prose, a comment or docstring included. It hands the fix to a higher rung only where code, config or tests change.
- `loop-claude`'s judge now sends a question you answered earlier in the chunk back to the worker, quoting your answer, unless the question ends with the words of your answer that leave it open. You are asked only about what your answer left open.
- `score-outcomes` now shows, beside what each finished item's chunk measured, the size of the files and folders its tagline or detail names in backticks: how many files, and how many lines, as they stood before its chunk.
+1 -1
View File
@@ -15,7 +15,7 @@ How work proceeds in any repo, unless the repo's `AGENTS.md` says otherwise. The
- **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.
- **Implement the simplest change that solves the item, and ship it with `/larv-review`.** Whenever a test can check the change, write that test first and see it fail. Take its expected values from the item, never from the code. larv-review's reviewers hold the change to the technical principles, and a finding against one names it. Read a file under `~/.claude/principles/` only when the item changes it, a finding or a record you write names it, or you decline a finding.
- **Remove a finished item's row and detail from `todo.md`, and revise any decision that cites it.** If the repo publishes something others consume — a package, an image, an API — reword the item for them and move it to `CHANGELOG.md` under `## Unreleased`. A changelog is for the public, never for the next agent. Otherwise delete it; git history is the record.
- **Remove a finished item's row and detail from `todo.md`, and revise any decision that cites it.** If the repo publishes something others consume — a package, an image, an API — reword the item for them and move it to `CHANGELOG.md` under `## Unreleased`. A changelog is for the public, never for the next agent. Otherwise delete it; git history is the record. `~/.claude/bin/todo-item finish <ID>` removes the row and detail, and adds the bullet you pass with `--changelog <bullet>`; it refuses while a decision cites the item.
- **Releases are the human's.** The version bump and the publishing credentials are theirs, whatever another rule says. Prepare everything else, so cutting a release is one decision.
- **Open each `todo.md` item or ticket with a bold one-sentence tagline**, so the taglines alone say what a release holds. The tagline states the target state, checkable when done: an imperative verb plus what holds afterwards. A present-tense fact reads as the current state and says nothing about what to do. Add "today X" only where the direction is otherwise ambiguous. GOOD: `**Accept undefined in MetadataValue and drop such keys on output.**` BANNED: `MetadataValue accepts undefined; such keys are dropped on output`.
- **File a security finding the moment it is found.** A security finding — a leaked credential, secret or PII, an auth bypass, an injection — goes under the next release, marked `security`, naming the exposure and the path it reaches. `~/.claude/bin/rank_todo.py` ranks it first in its release, after only the open questions, which wait for me. Never among additive or nice-to-have items, never only in a chunk's summary, and never as a question about where it belongs: file it, say you did, and I will unmark it if I disagree. Fixing it inside an unrelated change is a separate call — say whether it is in the blast radius.
+2 -1
View File
@@ -109,6 +109,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] <model> <L>` 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 <ID>` 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.
Test on the host with `uvx --python "$(command -v python3)" --with pytest-xdist==3.8.0 pytest==9.2.0 -n 4 bin`. It needs `uv` on `PATH`, which fetches pytest, pytest-xdist and mypy. pytest-xdist runs the tests in four workers, one heavy slot's CPUs (`docs/decisions.md` → `bin/: the tools support only the latest stable Python, …`). `python3 -m unittest discover -s bin -p 'test_*.py'` runs the same tests one at a time. Test the bench's scripts with `python3 -m unittest discover -s workflow-bench -p 'test_*.py'`.
@@ -138,7 +139,7 @@ Then, in the copy: `uvx --with pytest==9.2.0 'mutmut>=3,<4' run && uvx --with py
- `model_routing/` holds the routing ladder, which loop-claude, `rule_hook`, both replay tools and `subagent-rung` read.
- `rank_todo.py`, `settings_filter.py` and `statusline.py` are tools of one file each, tested beside them.
- `records/` reads a Markdown file's `##` sections, quotes a passage and joins names into a list, stamps times in UTC, and replaces a file in one step, private where it is new.
- `release_plan/` reads `todo.md`'s items table and release versions, says which release is next and whether it is ready to cut (`release_standing.py`), and ranks the plan (`ranking.py`, which `rank_todo.py`, `larv_review` and `rule_hook` import).
- `release_plan/` reads `todo.md`'s items table and release versions, says which release is next and whether it is ready to cut (`release_standing.py`), and ranks the plan (`ranking.py`, which `larv_review`, `rank_todo.py`, `rule_hook` and `todo_item` import).
- `repo_checks/` tests the repo itself.
- `review_rules/` holds the larv-review rules that several tools apply: its passes, its review folder, its round commit titles and the comprehension history's format.
- `routing_figures/` measures loop-claude's archive, and each of its projects' default branches, for loop-claude's routing calls.
Executable
+9
View File
@@ -0,0 +1,9 @@
#!/usr/bin/env python3
import pathlib
import sys
sys.path.insert(0, str(pathlib.Path(__file__).resolve().parent))
from todo_item import main
sys.exit(main.main(sys.argv[1:]))
View File
+89
View File
@@ -0,0 +1,89 @@
"""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 failure import Failure
from release_plan.ranking import stated
# A line that would end ## Details (##) or could open another item's detail (###).
HEADING = re.compile(r"^#{2,3} ", re.M)
UNRELEASED = "## Unreleased"
# The changelog's section for news not yet released: ## Unreleased, or a release heading such as `## 0.6.0 (unreleased)`.
UNRELEASED_SECTION = re.compile(r"^## .*unreleased.*\n+", re.M | re.I)
def added(todo: str, named: dict[str, str], detail: str) -> tuple[int, str] | Failure:
"""todo with an item filed under Next ID, and that ID; named holds its cells by column name, its Item cell the tagline, bold or not."""
next_id = stated(todo, "Next ID")
if isinstance(next_id, Failure):
return next_id
if not next_id.isdigit():
return Failure(f"Next ID {next_id!r} is not a whole number")
tagline = named["Item"].strip().removeprefix("**").removesuffix("**")
if "\n" in tagline:
return Failure("the tagline holds a line break; keep it on one line")
if HEADING.search(detail):
return Failure("the detail holds a ## or ### heading, which would split ## Details; use #### or drop the #s")
id_ = int(next_id)
lines = re.sub(r"^`Next ID = [0-9]+`$", f"`Next ID = {id_ + 1}`", todo, count=1, flags=re.M).split("\n")
table = held_table(lines)
if isinstance(table, Failure):
return table
row = {**named, "ID": str(id_), "Item": "**" + re.sub(r"(?<!\\)\|", r"\\|", tagline) + "**"}
lines.insert(table.start + len(table.rows), "| " + " | ".join(row.get(column, "") for column in table.columns) + " |")
text = "\n".join(lines)
if not detail.strip():
return id_, text
entry = f"### {id_}. {tagline}\n\n{detail.strip()}\n"
section = DETAILS.search(text)
if section is None:
return id_, text.rstrip("\n") + f"\n\n## Details\n\n{entry}"
return id_, text[:section.start(1)] + f"\n{entry}" + text[section.start(1):]
def finished(todo: str, id_: int) -> str | Failure:
"""todo without item id_'s row and its detail."""
lines = todo.split("\n")
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_}")
text = "\n".join(lines)
section = DETAILS.search(text)
if section is None:
return text
body = re.sub(rf"^### {id_}\. .*?(?=^### \d+\. |\Z)", "", section.group(1), count=1, flags=re.M | re.S)
return text[:section.start(1)] + body + text[section.end(1):]
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()
if not text:
return Failure("the changelog bullet is empty")
if "\n" in text:
return Failure("the changelog bullet holds a line break; keep it on one line")
line = f"- {text}"
if not changelog.strip():
return f"# Changelog\n\n{UNRELEASED}\n\n{line}\n"
if section := UNRELEASED_SECTION.search(changelog):
rest = changelog[section.end():]
if re.search(r"^### ", re.split(r"^## ", rest, maxsplit=1, flags=re.M)[0], re.M):
return Failure(f"CHANGELOG.md's {section.group().strip()} holds ### subsections; add the bullet under the right one by hand, then finish with --no-changelog")
return changelog[:section.end()] + line + "\n" + ("" if rest.startswith("- ") or not rest else "\n") + rest
if release := re.search(r"^## ", changelog, re.M):
return changelog[:release.start()] + f"{UNRELEASED}\n\n{line}\n\n" + changelog[release.start():]
return changelog.rstrip("\n") + f"\n\n{UNRELEASED}\n\n{line}\n"
def held_table(lines: list[str]) -> Table | Failure:
table = items_table(lines)
return Failure("todo.md holds no items table; rank_todo.py --help shows one") if table is None else table
+134
View File
@@ -0,0 +1,134 @@
"""File an item in todo.md, or finish one, and rank the file as rank_todo.py does.
usage: todo-item add --release <version> --l <L> --e <E> --i <I> --s <S> [--moves <moves>]
[--blocked-by <IDs>] [--exempt <reason>] <tagline> [<<'EOF' detail EOF]
todo-item finish <ID> [--changelog <bullet> | --no-changelog]
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.
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
in bold and each | in it escaped, and the detail it reads from stdin, if any, under ## Details.
The detail may hold no ## or ### heading.
It prints `Filed item <ID>.` It writes nothing where ranking fails or scores the item under the bar.
finish removes the item's row and its detail. With --changelog it adds the bullet first under
CHANGELOG.md's ## Unreleased, or a ## heading that says unreleased, creating the section, or the
file, where missing. It refuses where that section holds ### subsections: add the bullet by hand.
Where CHANGELOG.md exists, finish needs --changelog or --no-changelog, so no bullet is left out by
mistake. It prints `Finished item <ID>.` It writes nothing while docs/decisions.md cites the item.
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.
"""
import argparse
import pathlib
import sys
import typing
from todo_item.edits import added, finished, with_bullet
from release_plan.todo_table import BLOCKED_BY, MOVES
from failure import Failure
from release_plan import ranking
# Each score flag, as --l or --L, and the column it fills.
LETTERS = ("L", "E", "I", "S")
def main(argv: list[str], folder: pathlib.Path = pathlib.Path(), stdin: typing.TextIO = sys.stdin) -> int:
if argv[:1] in (["-h"], ["--help"]):
print(__doc__.strip())
return 0
args = parser().parse_args(argv)
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
print(done)
return 0
def parser() -> argparse.ArgumentParser:
parsed = argparse.ArgumentParser(prog="todo-item")
commands = parsed.add_subparsers(dest="command", required=True)
adding = commands.add_parser("add")
adding.add_argument("--release", required=True)
for letter in LETTERS:
adding.add_argument(f"--{letter.lower()}", f"--{letter}", dest=letter, required=True)
adding.add_argument("--moves", default="")
adding.add_argument("--blocked-by", default="")
adding.add_argument("--exempt", default="")
adding.add_argument("tagline")
finishing = commands.add_parser("finish")
finishing.add_argument("id", type=int)
bullet = finishing.add_mutually_exclusive_group()
bullet.add_argument("--changelog")
bullet.add_argument("--no-changelog", action="store_true")
return parsed
def add(args: argparse.Namespace, folder: pathlib.Path, stdin: typing.TextIO) -> str | Failure:
todo = folder / "todo.md"
texts = ranking.read_all(todo)
if isinstance(texts, Failure):
return texts
named = {"Release": args.release, BLOCKED_BY: args.blocked_by, "Exempt": args.exempt, "Item": args.tagline, MOVES: args.moves}
# Claude Code's Bash tool gives a command /dev/null as stdin (readlink /proc/self/fd/0 shows it), so without a heredoc read() returns "" at once.
filed = added(texts[0], named | {letter: getattr(args, letter) for letter in LETTERS}, "" if stdin.isatty() else stdin.read())
if isinstance(filed, Failure):
return Failure(f"not filed: {filed.reason}")
id_, text = filed
ranked = ranking.rank(text, *texts[1:])
if isinstance(ranked, Failure):
return Failure(f"not filed: {ranked.reason}")
if under := [line for line in ranked.under_bar if line.startswith(f"item {id_} ")]:
return Failure(f"not filed: {under[0]}")
if unwritten := ranking.write(todo, ranked.text):
return unwritten
report(todo, ranked)
return f"Filed item {id_}."
def finish(args: argparse.Namespace, folder: pathlib.Path) -> str | Failure:
todo, changelog = folder / "todo.md", folder / "CHANGELOG.md"
texts = finish_texts(args, todo, changelog)
if isinstance(texts, Failure):
return Failure(f"not finished: {texts.reason}")
ranked, news = texts
if unwritten := ranking.write(todo, ranked.text):
return Failure(f"not finished: {unwritten.reason}")
if news is not None and (unwritten := ranking.write(changelog, news)):
return Failure(f"{unwritten.reason}; todo.md no longer holds item {args.id}, so add its bullet by hand")
report(todo, ranked)
return f"Finished item {args.id}."
def finish_texts(args: argparse.Namespace, todo: pathlib.Path, changelog: pathlib.Path) -> tuple[ranking.Ranked, str | None] | Failure:
"""What finish writes: todo ranked without item args.id, and changelog's new text, None where finish leaves it as is."""
if changelog.exists() and args.changelog is None and not args.no_changelog:
return Failure("CHANGELOG.md exists beside todo.md; pass --changelog <bullet>, or --no-changelog where the repo publishes nothing")
texts = ranking.read_all(todo)
if isinstance(texts, Failure):
return texts
text = finished(texts[0], args.id)
if isinstance(text, Failure):
return text
ranked = ranking.rank(text, *texts[1:])
if isinstance(ranked, Failure):
return ranked
if args.changelog is None:
return ranked, None
try:
news = with_bullet(changelog.read_text(encoding="utf-8") if changelog.exists() else "", args.changelog)
except OSError as failure:
return Failure(f"{changelog}: {failure.strerror}")
except UnicodeDecodeError:
return Failure(f"{changelog}: not UTF-8")
return news if isinstance(news, Failure) else (ranked, news)
def report(todo: pathlib.Path, ranked: ranking.Ranked) -> None:
"""Print ranking's notes and under-bar lines on stderr, each prefixed with todo.md's path, as rank_todo.py does."""
for line in ranked.notes + ranked.under_bar:
print(f"{todo}: {line}", file=sys.stderr)
+271
View File
@@ -0,0 +1,271 @@
import contextlib
import io
import pathlib
import sys
import tempfile
import unittest
sys.path.insert(0, str(pathlib.Path(__file__).resolve().parent.parent))
from release_plan.test_ranking import DECISIONS, README, TODO
from todo_item import edits, main
from failure import Failure
from release_plan import ranking
ADD = ["add", "--release", "0.1.0", "--l", "1", "--e", "1", "--i", "1", "--s", "1", "--moves", "1 by 9", "Count the `a | b` runs."]
CHANGELOG = "# Changelog\n\n## Unreleased\n\n- Older news.\n\n## 0.1.0\n\n- First.\n"
# ## Details of the ranked fixture, without the trailing ## Notes.
DETAILS = "## Details\n\n### 3. Make it fast, `a | b`.\n\nFast detail.\n\n### 1. Ship the later thing.\n\nLater detail.\n\n"
class Terminal(io.StringIO):
"""A stdin that reads as a terminal, so add must not read it."""
def isatty(self):
return True
class TodoItem(unittest.TestCase):
def setUp(self):
temp = tempfile.TemporaryDirectory()
self.addCleanup(temp.cleanup)
self.folder = pathlib.Path(temp.name)
self.todo = self.folder / "todo.md"
self.changelog = self.folder / "CHANGELOG.md"
(self.folder / "README.md").write_text(README)
(self.folder / "docs").mkdir()
(self.folder / "docs" / "decisions.md").write_text(DECISIONS)
ranked = ranking.rank(TODO, README, DECISIONS, "")
assert not isinstance(ranked, ranking.Failure)
self.todo.write_text(ranked.text)
def run_main(self, *argv, stdin: str | io.StringIO = ""):
with contextlib.redirect_stdout(io.StringIO()) as out, contextlib.redirect_stderr(io.StringIO()) as err:
code = main.main(list(argv), self.folder, io.StringIO(stdin) if isinstance(stdin, str) else stdin)
return code, out.getvalue(), err.getvalue()
def exit_code(self, *argv):
with contextlib.redirect_stdout(io.StringIO()), contextlib.redirect_stderr(io.StringIO()), self.assertRaises(SystemExit) as raised:
main.main(list(argv), self.folder, io.StringIO())
return raised.exception.code
def assert_ranked(self):
self.assertEqual(ranking.check_failures(self.todo), [])
def details(self):
text = self.todo.read_text()
return text[text.index("## Details"):text.index("## Notes")]
def lower_item_2_under_the_bar(self):
self.todo.write_text(self.todo.read_text().replace("**Tighten the tests.** | 1 | 2 | 1 | 2 | 4 |", "**Tighten the tests.** | 1 | 2 | 1 | 2 | 9 |"))
class Help(TodoItem):
def test_prints_the_whole_docstring_and_exits_0(self):
for flag in ("-h", "--help"):
with self.subTest(flag):
code, out, err = self.run_main(flag)
self.assertEqual((code, out, err), (0, main.__doc__.strip() + "\n", ""))
for fact in ("stdin", "--changelog", "--no-changelog", "Exit 2"):
self.assertIn(fact, out)
class BadArguments(TodoItem):
def test_exit_2(self):
for argv in ([], ADD[:1] + ADD[3:], ["finish"]):
with self.subTest(argv):
self.assertEqual(self.exit_code(*argv), 2)
class Add(TodoItem):
def test_takes_next_id_and_raises_it(self):
self.assertEqual(self.run_main(*ADD)[:2], (0, "Filed item 6.\n"))
self.assertIn("`Next ID = 7`", self.todo.read_text())
def test_writes_the_row_with_the_tagline_bold_and_its_pipes_escaped(self):
self.run_main(*ADD)
self.assertIn("| 6 | 0.1.0 | | | **Count the `a \\| b` runs.** | 1 | 1 | 1 | 1 | 1 | 1 by 9 |", self.todo.read_text())
def test_takes_a_bold_tagline_upper_case_letters_blockers_and_exempt(self):
argv = ["add", "--release", "0.1.0", "--blocked-by", "2", "--exempt", "owner", "--L", "1", "--E", "1", "--I", "1", "--S", "1", "**Count the runs.**"]
self.assertEqual(self.run_main(*argv)[0], 0)
self.assertIn("| 6 | 0.1.0 | 2 | owner | **Count the runs.** | 1 | 1 | 1 | 1 | 1 | |", self.todo.read_text())
def test_writes_the_detail_from_stdin_into_the_one_details_section(self):
self.run_main(*ADD, stdin="What the tagline leaves out.\n")
self.assertEqual(self.details(), DETAILS.replace("### 3.", "### 6. Count the `a | b` runs.\n\nWhat the tagline leaves out.\n\n### 3."))
def test_leaves_the_file_ranked(self):
self.run_main(*ADD, stdin="Detail.")
self.assert_ranked()
def test_files_no_detail_from_empty_stdin(self):
self.assertEqual(self.run_main(*ADD)[0], 0)
self.assertEqual(self.details(), DETAILS)
def test_reads_no_detail_from_a_terminal(self):
self.assertEqual(self.run_main(*ADD, stdin=Terminal("Detail."))[0], 0)
self.assertEqual(self.details(), DETAILS)
def test_creates_details_where_todo_has_none(self):
self.todo.write_text(self.todo.read_text().split("## Details")[0].rstrip("\n") + "\n")
self.assertEqual(self.run_main(*ADD, stdin="Detail.")[0], 0)
self.assertTrue(self.todo.read_text().endswith("| 1 by 9 | 228.4 |\n\n## Details\n\n### 6. Count the `a | b` runs.\n\nDetail.\n"))
self.assert_ranked()
def test_takes_a_detail_holding_a_one_or_four_hash_line(self):
self.assertEqual(self.run_main(*ADD, stdin="Run it so:\n\n# run as root\n\n#### Why\n\nBecause.")[0], 0)
self.assertIn("### 6. Count the `a | b` runs.\n\nRun it so:\n\n# run as root\n\n#### Why\n\nBecause.\n", self.todo.read_text())
def test_reports_ranking_lines_on_stderr_prefixed_with_todo_md(self):
self.lower_item_2_under_the_bar()
_, _, err = self.run_main(*ADD)
self.assertTrue(err.startswith(f"{self.todo}: item 2 "), err)
def test_writes_nothing_where_it_refuses(self):
refused = {
"under the bar": ADD[:-3] + ["Count the runs."],
"a score ranking rejects": ADD[:4] + ["9"] + ADD[5:],
"a tagline with a line break": ADD[:-1] + ["Count\nthe runs."],
}
for case, argv in refused.items():
with self.subTest(case):
before = self.todo.read_text()
code, out, err = self.run_main(*argv)
self.assertEqual((code, out), (1, ""))
self.assertTrue(err.startswith("not filed: "), err)
self.assertEqual(self.todo.read_text(), before)
self.assertIn("item 6", self.run_main(*refused["under the bar"])[2])
def test_writes_nothing_for_a_detail_holding_a_two_or_three_hash_line(self):
for detail in ("## Goals", "### Why", "### 2. Other"):
with self.subTest(detail):
before = self.todo.read_text()
code, _, err = self.run_main(*ADD, stdin=f"Detail.\n\n{detail}\n")
self.assertEqual(code, 1)
self.assertTrue(err.startswith("not filed: "), err)
self.assertEqual(self.todo.read_text(), before)
class Finish(TodoItem):
def test_removes_the_row(self):
self.assertEqual(self.run_main("finish", "3", "--no-changelog"), (0, "Finished item 3.\n", ""))
self.assertNotRegex(self.todo.read_text(), r"(?m)^\| 3 \|")
def test_removes_the_detail_and_keeps_the_others(self):
self.run_main("finish", "3", "--no-changelog")
self.assertEqual(self.details(), "## Details\n\n### 1. Ship the later thing.\n\nLater detail.\n\n")
def test_removes_a_detail_holding_a_sub_heading_whole(self):
self.todo.write_text(self.todo.read_text().replace("Fast detail.\n", "Fast detail.\n\n### Why\n\nFast tail.\n").replace("Later detail.\n", "Later detail.\n\n### Why\n\nLater tail.\n"))
self.assertEqual(self.run_main("finish", "3", "--no-changelog")[0], 0)
self.assertEqual(self.details(), "## Details\n\n### 1. Ship the later thing.\n\nLater detail.\n\n### Why\n\nLater tail.\n\n")
def test_leaves_the_file_ranked(self):
self.run_main("finish", "3", "--no-changelog")
self.assert_ranked()
def test_adds_the_bullet_first_under_unreleased(self):
self.changelog.write_text(CHANGELOG)
self.assertEqual(self.run_main("finish", "3", "--changelog", "Runs are fast."), (0, "Finished item 3.\n", ""))
self.assertEqual(self.changelog.read_text(), "# Changelog\n\n## Unreleased\n\n- Runs are fast.\n- Older news.\n\n## 0.1.0\n\n- First.\n")
def test_creates_unreleased_above_the_first_release(self):
self.changelog.write_text("# Changelog\n\n## 0.1.0\n\n- First.\n")
self.assertEqual(self.run_main("finish", "3", "--changelog", "- Runs are fast.")[0], 0)
self.assertEqual(self.changelog.read_text(), "# Changelog\n\n## Unreleased\n\n- Runs are fast.\n\n## 0.1.0\n\n- First.\n")
def test_creates_the_changelog_where_missing(self):
self.assertEqual(self.run_main("finish", "2", "--changelog", "Tests are tight.")[0], 0)
self.assertEqual(self.changelog.read_text(), "# Changelog\n\n## Unreleased\n\n- Tests are tight.\n")
def test_needs_a_changelog_choice_where_a_changelog_exists(self):
self.changelog.write_text(CHANGELOG)
before = self.todo.read_text()
code, _, err = self.run_main("finish", "2")
self.assertEqual(code, 1)
self.assertTrue(err.startswith("not finished: "), err)
for fact in ("CHANGELOG.md", "--changelog", "--no-changelog"):
self.assertIn(fact, err)
self.assertEqual(self.todo.read_text(), before)
def test_leaves_the_changelog_as_is_with_no_changelog(self):
self.changelog.write_text(CHANGELOG)
self.assertEqual(self.run_main("finish", "2", "--no-changelog")[0], 0)
self.assertEqual(self.changelog.read_text(), CHANGELOG)
def test_reports_ranking_lines_on_stderr_prefixed_with_todo_md(self):
self.lower_item_2_under_the_bar()
_, _, err = self.run_main("finish", "3", "--no-changelog")
self.assertTrue(err.startswith(f"{self.todo}: item 2 "), err)
def test_writes_nothing_for_an_item_a_decision_cites(self):
before = self.todo.read_text()
code, _, err = self.run_main("finish", "5", "--changelog", "Writes moved out.")
self.assertEqual(code, 1)
self.assertTrue(err.startswith("not finished: "), err)
self.assertIn("item 5", err)
self.assertEqual(self.todo.read_text(), before)
self.assertFalse(self.changelog.exists())
def test_fails_on_an_item_the_table_does_not_hold(self):
code, out, err = self.run_main("finish", "9", "--no-changelog")
self.assertEqual((code, out), (1, ""))
self.assertTrue(err.startswith("not finished: "), err)
self.assertIn("9", err)
def test_fails_on_a_todo_md_without_an_items_table(self):
self.todo.write_text("# todo\n")
code, _, err = self.run_main("finish", "3", "--no-changelog")
self.assertEqual(code, 1)
self.assertIn("no items table", err)
self.assertEqual(self.todo.read_text(), "# todo\n")
def test_writes_neither_file_for_a_bullet_it_refuses(self):
changelogs = {
"an empty bullet": (CHANGELOG, ""),
"a whitespace bullet": (CHANGELOG, " \t "),
"a bullet with a line break": (CHANGELOG, "Runs\nare fast."),
"an Unreleased section with ### subsections": ("# Changelog\n\n## Unreleased\n\n### Security\n\n- Older news.\n", "Runs are fast."),
}
for case, (changelog, bullet) in changelogs.items():
with self.subTest(case):
self.changelog.write_text(changelog)
before = self.todo.read_text()
code, _, err = self.run_main("finish", "3", "--changelog", bullet)
self.assertEqual(code, 1)
self.assertTrue(err.startswith("not finished: "), err)
self.assertEqual((self.todo.read_text(), self.changelog.read_text()), (before, changelog))
def test_fails_on_a_changelog_that_is_not_utf_8(self):
self.changelog.write_bytes(b"# Changelog\n\n\xff\n")
before = self.todo.read_text()
code, _, err = self.run_main("finish", "3", "--changelog", "Runs are fast.")
self.assertEqual(code, 1)
self.assertTrue(err.startswith("not finished: "), err)
self.assertIn(str(self.changelog), err)
self.assertEqual(self.todo.read_text(), before)
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")
def test_appends_unreleased_to_a_changelog_without_a_release(self):
self.assertEqual(edits.with_bullet("# Changelog\n", "New."), "# Changelog\n\n## Unreleased\n\n- New.\n")
def test_takes_a_release_heading_marked_unreleased_as_the_section(self):
self.assertEqual(edits.with_bullet("# Changelog\n\n## 0.6.0 (Unreleased)\n\n- Old.\n\n## 0.5.0\n", "New."), "# Changelog\n\n## 0.6.0 (Unreleased)\n\n- New.\n- Old.\n\n## 0.5.0\n")
def test_refuses_an_unreleased_section_with_subsections_and_says_to_add_by_hand(self):
refused = edits.with_bullet("# Changelog\n\n## Unreleased\n\n### Security\n\n- Old.\n\n## 0.5.0\n", "New.")
self.assertIsInstance(refused, Failure)
assert isinstance(refused, Failure)
self.assertIn("by hand", refused.reason)
def test_takes_subsections_of_a_release_below_unreleased(self):
self.assertEqual(edits.with_bullet("## Unreleased\n\n- Old.\n\n## 0.5.0\n\n### Security\n", "New."), "## Unreleased\n\n- New.\n- Old.\n\n## 0.5.0\n\n### Security\n")
if __name__ == "__main__":
unittest.main()
+14
View File
@@ -1347,3 +1347,17 @@ Read most (opens and searches):
- `bin/judge_replay/main.py` 3
- `bin/review_replay/test_review_replay.py` 3
- `bin/score_outcomes/main.py` 3
## Reading cost, chunk 7e1292c4ef5d, finished 2026-11-09T00:31:46Z
58849 new input tokens before the first commit.
Read most (opens and searches):
- `todo.md` 7
- `skills/larv-review/SKILL.md` 3
- `AGENTS.md` 2
- `CHANGELOG.md` 2
- `CLAUDE.md` 2
- `docs/decisions.md` 2
- `README.md` 1
+1
View File
@@ -6,6 +6,7 @@ paths:
# Todo items (`todo.md`)
- **`todo.md` is mandatory in every project, in the shape `rank_todo.py --help` shows**, which `~/.claude/bin/rank_todo.py` checks and ranks; its `--help` shows a valid file. `## Scoring` holds the formula and the bar; `## Items` is one table of every item; `## Details` holds each item's detail under its ID. `## Renamed` marks each renamed release with a line such as `- 0.2.1 renamed to 0.3.0`; `rank_todo.py --help` says what a mark does. Cite an item by its ID. The formula and bar are the project's own to tune.
- **File an item with `~/.claude/bin/todo-item add`.** It reads the item's detail from stdin and ranks the file; `todo-item --help` shows the flags.
- **Order items only by score and the Blocked by column.** An item's Blocked by cell lists the IDs of the items that must be done before it starts, such as `12, 14`; `rank_todo.py --help` says how it ranks them. No text in `todo.md` outside the table orders items: where an item must go first, score it so, and say why in its detail.
- **Plan only on the project's rung or above.** loop-claude's prompt tells you when you run below it. Below it, never score or re-score an item, move it between releases, split a milestone into items, delete an item under the bar, rewrite a filed item's tagline or detail, or choose or replace an item in `docs/score-anchors.md`. Draft each new item, each change to a filed item, and each change to the anchors, instead. Before your next commit, launch one subagent to apply the drafts, score them and set their release. Launch it on the rung `CLAUDE.md`'s delegation rule gives a subagent that files or scores items. Keep the scores and releases it writes. For a security finding, launch it at once. Any rung may remove a finished item's row and detail, and score a delegated task's L. A subagent launched for another task leaves `todo.md` alone.
- **An item's release allows the bump that semver read strictly asks for.** An item that changes what exists needs a major, or before 1.0.0 a minor. One that only adds needs a minor, and a fix a patch.
-10
View File
@@ -14,12 +14,10 @@
|---|---|---|---|---|---|---|---|---|---|---|---|
| 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 |
| 279 | 0.7.0 | | | **Add an item to `todo.md` with one command that reads `Next ID`, bumps it, and inserts the row and its detail.** | 3 | 1 | 3 | 5 | 3 | 1.4 by 3, 1.5 by 3 | 2.3 |
| 116 | 0.7.0 | | | **Report L by the share of chunks with a 🔴, once 10 chunks that each shipped one item record finding counts and most record no 🔴.** | 1 | 1 | 2 | 2 | 2 | 1.1 by 5 | 2.3 |
| 280 | 0.7.0 | | | **Open the chunk's pull request as a draft, mark it ready and merge it with one command per step that picks `tea` or `gh` from the remote, so no worker looks up `tea`'s or `gh`'s flags.** | 3 | 2 | 3 | 6 | 4 | 1.4 by 4, 1.5 by 3 | 2.3 |
| 282 | 0.7.0 | | | **Write the branch diff and what `larv-review places` prints into the chunk's review folder, and print each reviewer's prompt header, with one `larv-review` command.** | 3 | 2 | 3 | 6 | 4 | 1.4 by 4, 1.5 by 3 | 2.3 |
| 12 | 0.7.0 | | | **Run the test suite in CI on every PR, or record in `docs/decisions.md` why the local run is enough.** | 3 | 2 | 1 | 4 | 4 | 1.1 by 6 | 2.1 |
| 278 | 0.7.0 | | | **Remove a finished item's row and detail from `todo.md` and add its changelog bullet under `## Unreleased` with one command, given the item's ID and the bullet.** | 3 | 1 | 3 | 5 | 3 | 1.4 by 3, 1.5 by 2 | 2.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 |
| 283 | 0.7.0 | | | **Print, for the archived chunks of a release, a table of its shell command patterns, such as `tea pr create`: the chunks that ran each, its calls, command tokens, result tokens and tool time, so an audit reads one table.** | 3 | 2 | 1 | 4 | 3 | 1.4 by 2, 1.5 by 2 | 1.6 |
@@ -79,10 +77,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).
### 279. Add an item to `todo.md` with one command that reads `Next ID`, bumps it, and inserts the row and its detail.
Audit of release 0.2.0's chunks (item 162): 22 chunks filed items with a Python heredoc written by hand, 55 calls, about 11k command tokens and 8 minutes of tool time. The model supplies the tagline, scores and detail; the program allocates the ID, writes the row and the detail in place, and ranks the table with `rank_todo.py`.
### 116. Report L by the share of chunks with a 🔴, once 10 chunks that each shipped one item record finding counts and most record no 🔴.
`score-outcomes` reports the median 🔴 count at each guessed R, and how well L orders chunks by 🔴 findings; the part of R a 🔴 tests is L. Where most chunks have no 🔴, every median reads 0 and the rank correlation rests on the few that have one, which tells a scorer little. No round title held counts before PR #254, so how often a chunk has a 🔴 is not yet known.
@@ -101,10 +95,6 @@ The repo has no CI, so larv-review's gate is the local run, and larv-review's Ga
When CI runs a rule check, such as one of `bin/rule-hook`'s, let `<!-- rule-override <rule>: <reason> -->` in the PR body override it.
### 278. Remove a finished item's row and detail from `todo.md` and add its changelog bullet under `## Unreleased` with one command, given the item's ID and the bullet.
Audit of release 0.2.0's chunks (item 162): 16 chunks edited `CHANGELOG.md` and at least 10 deleted an item's row and its `### <ID>.` detail from `todo.md`, each time with a Python heredoc written by hand. The CHANGELOG edits alone were 33 calls, about 9k command tokens and 6 minutes of tool time. The program removes the row and the detail, creates `## Unreleased` when it is missing, and inserts the bullet; the bullet's wording stays with the model.
### 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.