Refuse a Touches: list touch-predictions cannot read in todo-item add and edit, and in rank_todo.py --check

This commit is contained in:
2026-11-18 16:17:23 +01:00
parent 2f4442ea13
commit 83714f095c
6 changed files with 90 additions and 9 deletions
+41
View File
@@ -25,6 +25,16 @@ CHANGELOG = "# Changelog\n\n## Unreleased\n\n- Older news.\n\n## 0.1.0\n\n- Firs
# ## Details of the ranked fixture, without the trailing ## Notes.
HEADER = "| ID | Release | Blocked by | Exempt | Item | L | E | I | R | S | Moves |\n|---|---|---|---|---|---|---|---|---|---|---|\n"
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"
# The bullets six items held on 2026-11-18, which touch-predictions cannot read: `(small)` after a bare path, and a part not in backticks.
UNREADABLE_BULLETS = (
"- `bin/judge_replay/main.py` (small)",
"- `bin/do_epic/main.py` (small)",
"- `principles/technical-principles.md`: the tests bullet group, `A valuable test checks behaviour` (small)",
"- `README.md`: loop-claude's section (small)",
"- `bin/rule_hook/rules.py`: the rule table (small)",
"- `settings.json`: the PreToolUse matcher (small)",
)
READABLE_TOUCHES = "Why.\n\nTouches:\n\n- `bin/a.py`: `main`, `Plan.branch` (small)\n- `bin/run.sh`: lines 10-20\n- `docs/new.md`\n"
class Terminal(io.StringIO):
@@ -488,6 +498,37 @@ class Edit(TodoItem):
self.assertEqual(self.todo.read_text(), before)
class UnreadableTouches(TodoItem):
"""A `Touches:` list touch-predictions cannot read is refused when written, since chunk-preflight would silently start no chunk beside the item."""
def test_add_and_edit_refuse_each_bullet_that_stalled_the_loop_and_write_nothing(self):
for bullet in UNREADABLE_BULLETS:
for argv, refusal in ((ADD, "not filed: "), (["edit", "3", "--detail"], "not edited: item 3's detail: ")):
with self.subTest(bullet=bullet, command=argv[0]):
before = self.todo.read_text()
code, out, err = self.run_main(*argv, stdin=f"Why.\n\nTouches:\n\n- `bin/a.py`: `main`\n{bullet}\n")
self.assertEqual((code, out), (1, ""))
self.assertTrue(err.startswith(refusal), err)
self.assertIn(repr(bullet), err)
self.assertEqual(self.todo.read_text(), before)
def test_add_and_edit_take_a_readable_list_and_a_detail_without_one(self):
for detail in (READABLE_TOUCHES, "Why, without a list.\n"):
with self.subTest(detail):
self.assertEqual(self.run_main(*ADD, stdin=detail)[0], 0)
self.assertEqual(self.run_main("edit", "3", "--detail", stdin=detail)[0], 0)
self.assertIn(detail, self.todo.read_text())
def test_a_plan_in_jira_gets_no_unreadable_list_either(self):
self.config.write_text(self.config.read_text().replace('"checkout:todo.md"', f'"{JIRA_PLAN}"') + 'env-file = "~/acme.env"\n' + JIRA_SCORING)
plan = MemoryPlan({3: {"Release": "0.1.0", "Item": "**Count the runs.**", "L": "1", "E": "2", "I": "3", "S": "1"}})
self.enterContext(unittest.mock.patch.object(main, "plan_store", return_value=plan))
detail = f"Touches:\n\n{UNREADABLE_BULLETS[0]}\n"
self.assertEqual(self.run_main(*ADD, stdin=detail)[:2], (1, ""))
self.assertEqual(self.run_main("edit", "3", "--detail", stdin=detail)[:2], (1, ""))
self.assertEqual((list(plan.rows), plan.details), ([3], {}))
class Move(TodoItem):
def test_sets_the_items_release_and_keeps_the_rest(self):
self.assertEqual(self.run_main("move", "3", "--release", "0.2.0"), (0, f"Moved item 3 to release 0.2.0 in {self.todo}.\n", ""))