Name the next release's items without a Touches list, and warn of them in rank_todo.py --check
CI / tests (pull_request) Successful in 4m24s

This commit is contained in:
2026-11-27 20:50:24 +01:00
parent 541ad8988d
commit 3db4b77121
10 changed files with 106 additions and 8 deletions
+16 -1
View File
@@ -1,5 +1,5 @@
"""The lines the preflight prints, stated from what it gathered."""
from plan.todo_table import bundle_candidates, BUNDLE_MAX_R, Item, ships_alone
from plan.todo_table import bundle_candidates, BUNDLE_MAX_R, Item, next_item, ships_alone
from touch_predictions.beside import chunks_beside
from release_plan.next_chunk import cut_name, NextChunk, NoItem
from release_plan.release_standing import dated_cut, LastCut, unreleased_entries, UNSEEN_RELEASES
@@ -9,6 +9,7 @@ from chunk_preflight.gathered import Gathered, ItemFacts, NamedPath, Ran
from text_files.markdown_text import listed, quoted
from chunk_preflight.choices import PULLS_LIST
from chunk_preflight.indentation import SpaceIndented
from plan.touches import unpredicted
from plan.release import version
@@ -73,6 +74,7 @@ def item_lines(plan: str, item: ItemFacts) -> list[str]:
f"- Open pull requests from {item.plan.branch}: {pulls_text(item.pulls, item.plan.branch)}",
*bundled(item.plan),
*beside(item.plan),
*unpredicted_lines(item.plan),
*named_lines(item.named),
f"\nItem {first.id}'s tagline and detail:\n\n{quoted(item.plan.text)}",
*joining_details(item.plan),
@@ -147,6 +149,19 @@ def beside(plan: NextChunk) -> list[str]:
return [f"- The items of release {version(first.release)} that may start chunks beside item {first.id}'s: {', '.join(map(str, found.picked))}. None is predicted to touch a part that item {first.id} touches, or that an item earlier in this list touches. An item this chunk takes doesn't start a chunk of its own.{refused}"]
def unpredicted_lines(plan: NextChunk) -> list[str]:
"""The items of first's release without a `Touches:` list, for the worker to have a subagent write; no line where each holds one or first is alone in its release, where no chunk could start beside its.
Only the chunk of the plan's next item gets the line: a chunk that starts beside it would have a second subagent write the same lists."""
first = plan.first
missing = unpredicted(plan.items, first.release)
alone = sum(item.release == first.release for item in plan.items) < 2
if not missing or alone or next_item(plan.items) != first:
return []
them = "them" if missing.startswith("items") else "it"
return [f'- {missing[0].upper()}{missing[1:]}. Before the chunk, have one subagent write {them}, as `~/.claude/CLAUDE.md` → "Working loop" says.']
def named_lines(named: list[NamedPath] | Failure) -> list[str]:
if isinstance(named, Failure):
return [f"- The files the item names: cannot be listed: {named.reason}"]
+4
View File
@@ -71,6 +71,10 @@ and prints that the release reviews and the cuts are the human's to call. It pri
it in the plan's order. A part either prediction marks (small) doesn't count. This line is left
out where no item of the release that doesn't wait holds a prediction. The plan and the records
belong in no prediction, since every chunk writes them;
- the items of that release whose details hold no `Touches:` list, for the worker to have a
subagent write, as `~/.claude/CLAUDE.md` → "Working loop" says. This line is left out where
the item is alone in its release, and where it is not the plan's next item: the chunk of the
next item gets the line, so the lists are written once;
- 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, 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;
@@ -2,6 +2,7 @@ import contextlib
import dataclasses
import os
import pathlib
import re
import shutil
import subprocess
import sys
@@ -867,6 +868,34 @@ class BesideTest(unittest.TestCase):
self.assertEqual(self.said(TODO), [])
class UnpredictedTest(unittest.TestCase):
"""The fact that names the next release's items whose details hold no `Touches:` list."""
LIST = "\nTouches:\n\n- `src/app.py`: `run`\n"
# Item 3's detail ends TODO, so the first list is item 3's.
LISTED = TODO + LIST + f"\n### 5. Do it.\n{LIST}\n### 7. Do it.\n{LIST}\n### 8. Do it.\n{LIST}"
def said(self, todo, *named):
return [line for line in rendered(item_facts(todo, plan=planned(todo, CUT, "origin/main", BRANCH, None, *named))).splitlines() if "have no `Touches:` list" in line or "has no `Touches:` list" in line]
def test_says_nothing_where_every_item_of_the_release_holds_a_list(self):
self.assertEqual(self.said(self.LISTED), [])
def test_names_each_item_without_a_list_where_other_items_of_the_release_wait(self):
self.assertEqual(self.said(self.LISTED.replace(f"\n### 7. Do it.\n{self.LIST}", "")), ['- Item 7 of release 0.2.0 has no `Touches:` list. Before the chunk, have one subagent write it, as `~/.claude/CLAUDE.md` → "Working loop" says.'])
self.assertEqual(self.said(TODO), ['- Items 5, 3, 7 and 8 of release 0.2.0 have no `Touches:` list. Before the chunk, have one subagent write them, as `~/.claude/CLAUDE.md` → "Working loop" says.'])
def test_says_nothing_of_an_item_alone_in_its_release(self):
alone = "\n".join(line for line in TODO.splitlines() if not re.match(r"\| [578] \|", line)) + "\n"
self.assertEqual(self.said(alone), [])
def test_leaves_alone_a_list_an_edit_of_its_item_made_stale(self):
# Item 3's detail names `src/app.py`'s `run`, and its list another file: only a missing list is written.
self.assertEqual(self.said(self.LISTED.replace("- `src/app.py`: `run`", "- `src/old.py`", 1)), [])
def test_says_it_only_to_the_chunk_of_the_plans_next_item(self):
# Item 8's chunk starts beside item 3's, whose worker writes the lists: two subagents would write them twice.
self.assertEqual(self.said(TODO.replace("| 8 | 0.2.0 | 5 |", "| 8 | 0.2.0 | |"), 8), [])
if __name__ == "__main__":
unittest.main()
+11
View File
@@ -17,6 +17,9 @@ import dataclasses
import re
from failure import Failure
from plan.todo_table import Item
from text_files.markdown_text import listed
from plan.release import Release, version
LABEL = "Touches:"
SMALL = " (small)"
@@ -146,3 +149,11 @@ def same_part(one: Part, other: Part) -> bool:
if spans[0] or spans[1]:
return True
return one.name == other.name or one.name.startswith(f"{other.name}.") or other.name.startswith(f"{one.name}.")
def unpredicted(found: list[Item], release: Release) -> str | None:
"""Which of release's items hold no `Touches:` list in their details, in found's order, as a clause such as ``items 3 and 7 of release 0.2.0 have no `Touches:` list``; None where each holds one. A list that cannot be read is not missing: `rank_todo.py --check` fails on that one. Nor is one its item's later edit made stale, so a list is written once."""
missing = [str(item.id) for item in found if item.release == release and predicted(item.detail) is None]
if not missing:
return None
return f"item{'s' if len(missing) > 1 else ''} {listed(missing, 'and')} of release {version(release)} ha{'ve' if len(missing) > 1 else 's'} no `{LABEL}` list"
+9 -1
View File
@@ -7,7 +7,7 @@ from plan_store.plans import cells, Plan, Written
from failure import Failure
from plan.todo_table import item_details, items, NoItemsTable, renames
from plan_store import markdown_edits
from plan.touches import predicted
from plan.touches import predicted, unpredicted
from plan import ranking
from record_store.stores import RecordStore
from text_files.file_writes import replace_file
@@ -95,6 +95,14 @@ class FilePlan:
unranked = [] if ranked.text == texts[0] else [f"{self.path}: not ranked; run rank_todo.py on it"]
return unranked + [f"{self.path}: {line}" for line in ranked.under_bar + unreadable_touches(texts[0])]
def warnings(self) -> list[str]:
"""What `rank_todo.py --check` says of the file without failing on it: which items of its earliest release hold no `Touches:` list."""
plan = self.read()
if isinstance(plan, Failure) or not plan.items:
return []
missing = unpredicted(plan.items, min(item.release for item in plan.items))
return [f"{self.path}: warning: {missing}; write each as `~/.claude/rules/todo-items.md` says"] if missing else []
def reported(self, ranked: ranking.Ranked) -> list[str]:
"""Ranking's notes and under-bar lines, each prefixed with the file's path, as a tool prints them on stderr."""
return [f"{self.path}: {line}" for line in ranked.notes + ranked.under_bar]
+3 -2
View File
@@ -12,7 +12,8 @@ then by ID. Then it moves each blocker, an item another's Blocked by cell names,
an item it blocks to just above the first such item. Orders the details to match. Writes each
item's R, and adds the Blocked by and R columns to a table without them. --check doesn't write
anything and fails when the file is not ranked as it would be, or when an item's detail holds a
`Touches:` list not spelt as `touch-predictions --help` shows.
`Touches:` list not spelt as `touch-predictions --help` shows. On a file that passes, it warns on
stderr, still exiting 0, where items of the earliest release hold no `Touches:` list, naming them.
A valid todo.md; ## Details and each item's detail are optional:
@@ -120,7 +121,7 @@ def main(argv: list[str], home: pathlib.Path) -> int:
plan = file_plan(config, todo)
if check:
failures = plan.check()
for line in failures:
for line in failures or plan.warnings():
print(line, file=sys.stderr)
return 1 if failures else 0
ranked = plan.rank()
+23 -3
View File
@@ -14,6 +14,9 @@ from plan import goals_file, ranking
import rank_todo
from todo_item.doubles import READABLE_TOUCHES, UNREADABLE_BULLETS
# What --check says of plan.doubles' TODO, none of whose items of the next release, 0.1.0, holds a list. The order is the ranked table's.
UNPREDICTED = "items 4, 3, 2 and 5 of release 0.1.0 have no `Touches:` list; write each as `~/.claude/rules/todo-items.md` says"
class Main(unittest.TestCase):
# The home of a test that writes no config.
@@ -41,7 +44,7 @@ class Main(unittest.TestCase):
self.assertEqual(self.run_main("--check", str(todo))[0], 1)
self.assertEqual(todo.read_text(), TODO)
self.assertEqual(self.run_main(str(todo)), (0, ""))
self.assertEqual(self.run_main("--check", str(todo)), (0, ""))
self.assertEqual(self.run_main("--check", str(todo)), (0, f"{todo}: warning: {UNPREDICTED}\n"))
pathlib.Path(temp, "README.md").write_bytes(b"\xff")
self.assertEqual(self.run_main(str(todo)), (1, f"cannot read {temp}/README.md: not UTF-8 on line 1\n"))
pathlib.Path(temp, "README.md").unlink()
@@ -62,7 +65,7 @@ class Main(unittest.TestCase):
(folder / "decisions.md").write_text(DECISIONS)
self.assertEqual(self.run_main("--check")[0], 1, "the plan in the config's folder is not ranked yet")
self.assertEqual(self.run_main(), (0, ""))
self.assertEqual(self.run_main("--check"), (0, ""))
self.assertEqual(self.run_main("--check"), (0, f"{folder / 'todo.md'}: warning: {UNPREDICTED}\n"))
self.assertEqual(pathlib.Path(temp, "todo.md").read_text(), "the project owners' own notes\n")
(folder / "decisions.md").write_bytes(b"\xff")
self.assertEqual(self.run_main(), (1, f"cannot read {folder}/decisions.md: not UTF-8 on line 1\n"))
@@ -111,6 +114,23 @@ class Main(unittest.TestCase):
self.assertEqual(self.run_main(str(todo)), (1, f"{todo}: {under}\n"))
self.assertEqual(self.run_main("--check", str(todo)), (1, f"{todo}: {under}\n"))
def test_check_warns_without_failing_on_the_next_releases_items_without_a_touches_list(self):
with tempfile.TemporaryDirectory() as temp:
todo = pathlib.Path(temp, "todo.md")
self.configured(temp)
self.enterContext(contextlib.chdir(temp))
pathlib.Path(temp, "README.md").write_text(README)
pathlib.Path(temp, "docs").mkdir()
pathlib.Path(temp, "docs", "decisions.md").write_text(DECISIONS)
# Item 3 of the next release, 0.1.0, holds a list; item 1 of 0.2.0 holds none, and is not named.
todo.write_text(TODO.replace("Fast detail.", READABLE_TOUCHES))
self.assertEqual(self.run_main(str(todo))[0], 0)
self.assertEqual(self.run_main("--check", str(todo)), (0, f"{todo}: warning: {UNPREDICTED.replace('3, ', '')}\n"))
every = "".join(f"### {id_}. Do it.\n\n{READABLE_TOUCHES}\n" for id_ in (2, 4, 5))
todo.write_text(todo.read_text().replace("## Notes", f"{every}## Notes"))
self.assertEqual(self.run_main(str(todo))[0], 0)
self.assertEqual(self.run_main("--check", str(todo)), (0, ""))
def test_check_fails_on_each_item_whose_touches_list_it_cannot_read(self):
with tempfile.TemporaryDirectory() as temp:
todo = pathlib.Path(temp, "todo.md")
@@ -140,7 +160,7 @@ class Main(unittest.TestCase):
pathlib.Path(temp, "docs").mkdir()
pathlib.Path(temp, "docs", "decisions.md").write_text(DECISIONS)
self.assertEqual(self.run_main(str(todo)), (0, f"{todo}: {ranking.RESHAPE}\n"))
self.assertEqual(self.run_main("--check", str(todo)), (0, ""))
self.assertEqual(self.run_main("--check", str(todo))[0], 0)
def test_shows_a_valid_file_in_help_and_names_arguments_it_cannot_read(self):
self.assertEqual(self.run_main("--help")[0], 0)