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
+11 -2
View File
@@ -11,6 +11,7 @@ from plan import ranking
from record_store.stores import RecordStore
from text_files.file_writes import replace_file
from plan_store.scoring import weighing_texts
from touch_predictions.prediction import predicted
# What the reader of a missing todo.md is told.
MISSING = "every project keeps a todo.md, and rank_todo.py --help shows one"
@@ -84,7 +85,7 @@ class FilePlan:
return ranked
def check(self) -> list[str]:
"""Why `rank_todo.py --check` fails on the file, empty when it passes: the file is not ranked, or an item scores under the bar."""
"""Why `rank_todo.py --check` fails on the file, empty when it passes: the file is not ranked, an item scores under the bar, or an item's `Touches:` list is one touch-predictions cannot read."""
texts = self.texts()
if isinstance(texts, Failure):
return [texts.reason]
@@ -92,7 +93,7 @@ class FilePlan:
if isinstance(ranked, Failure):
return [ranked.reason]
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]
return unranked + [f"{self.path}: {line}" for line in ranked.under_bar + unreadable_touches(texts[0])]
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."""
@@ -115,6 +116,14 @@ class FilePlan:
return weighing if isinstance(weighing, Failure) else (plan, *weighing)
def unreadable_touches(todo: str) -> list[str]:
"""Why touch-predictions cannot read each item's `Touches:` list that it cannot. Every item is read, not only the next release's: a later item moves into the next release with its detail, and the list is fixed most cheaply where it was written."""
details = item_details(todo)
if isinstance(details, Failure):
return [details.reason]
return [f"item {id_}: {read.reason}" for id_, detail in details.items() if isinstance(read := predicted(detail), Failure)]
def plan_of(todo: str) -> Plan | Failure:
"""The plan a todo.md's text holds."""
found = items(todo)