Answer stability round 1: 0 🔴, 2 🟡 (0 misread); inject home into the goals file lookup and rename readme in ranking

This commit is contained in:
2026-11-13 00:29:22 +01:00
parent ad6118d19f
commit 7b6201cab6
27 changed files with 110 additions and 96 deletions
+25 -14
View File
@@ -43,22 +43,33 @@ def check_failures(todo: pathlib.Path) -> list[str]:
def read_all(todo: pathlib.Path) -> tuple[str, str, str, str] | Failure:
"""todo.md, the goals file its project's config names, and its docs/decisions.md and docs/comprehension-history.md. The last two are empty when missing; a missing todo.md, config or goals file is a Failure."""
goals = goals_file(str(todo.parent))
plan = read(todo, "every project keeps a todo.md, and rank_todo.py --help shows one")
if isinstance(plan, Failure):
return plan
# Looked up after todo.md is read, so a mistyped path fails naming todo.md, not in git's words.
goals = goals_file(str(todo.parent), pathlib.Path.home())
if isinstance(goals, Failure):
return goals
texts = []
for path, missing in ((todo, "every project keeps a todo.md, and rank_todo.py --help shows one"), (goals, "rank_todo.py weighs goals from the file the project's config names as goals-and-audience"), (todo.parent / "docs" / "decisions.md", None), (todo.parent / HISTORY, None)):
try:
texts.append(path.read_text(encoding="utf-8"))
except FileNotFoundError:
if missing:
return Failure(f"{path}: not found; {missing}")
texts.append("")
except OSError as failure:
return Failure(f"{path}: {failure.strerror}")
except UnicodeDecodeError:
return Failure(f"{path}: not UTF-8")
return texts[0], texts[1], texts[2], texts[3]
goals_text, decisions, history = read(goals, "rank_todo.py weighs goals from the file the project's config names as goals-and-audience"), read(todo.parent / "docs" / "decisions.md", None), read(todo.parent / HISTORY, None)
if isinstance(goals_text, Failure):
return goals_text
if isinstance(decisions, Failure):
return decisions
if isinstance(history, Failure):
return history
return plan, goals_text, decisions, history
def read(path: pathlib.Path, missing: str | None) -> str | Failure:
"""path's text; where it is missing, a Failure saying missing, or "" where missing is None."""
try:
return path.read_text(encoding="utf-8")
except FileNotFoundError:
return Failure(f"{path}: not found; {missing}") if missing else ""
except OSError as failure:
return Failure(f"{path}: {failure.strerror}")
except UnicodeDecodeError:
return Failure(f"{path}: not UTF-8")
def write(path: pathlib.Path, text: str) -> Failure | None: