Answer stability round 1: 0 🔴, 5 🟡; test blockers in score order, Next ID itself, every place text can sit beside the table, an empty table and the bar itself; require the table under ## Items and refuse a repeated column

This commit is contained in:
2026-10-15 23:20:08 +02:00
parent a0d4fc3d15
commit 1956fb45f4
3 changed files with 40 additions and 12 deletions
+12 -8
View File
@@ -220,7 +220,7 @@ def under_the_bar(item: Item, value: float, bar: float, items: list[Item]) -> st
def read_scoring(text: str, lines: list[str], readme: str) -> Scoring | Failure:
if "## Items" not in lines and items_table(lines) is None:
if "## Items" not in lines:
return Failure("todo.md is not in the scored-table format; rank_todo.py --help shows a valid one")
goals = readme_goals(readme)
if isinstance(goals, Failure):
@@ -253,8 +253,8 @@ def read_items(lines: list[str], scoring: Scoring) -> tuple[list[Item], Table] |
# Ranking writes COLUMNS, so it would drop a column it does not know.
if unknown := [column for column in table.columns if column not in COLUMNS]:
return Failure(f"todo.md's items table has the column {', '.join(unknown)}, which this rank_todo.py does not know; move this machine to the release that added it")
if beside_table(lines, table.header, table.start + len(table.rows)):
return Failure(f"## Items holds text beside its table; an order goes in the scores or the {BLOCKED_BY} column, and a note in the item's detail")
if misplaced := outside_items(lines, table):
return misplaced
items = []
for row in table.rows:
item = parse_item(row, scoring.weights, table.columns)
@@ -272,12 +272,16 @@ def read_items(lines: list[str], scoring: Scoring) -> tuple[list[Item], Table] |
return items, table
def beside_table(lines: list[str], header: int, end: int) -> bool:
"""Whether ## Items holds anything but its table, which starts at the header line and ends before end: the table's order is todo.md's only order."""
heading = max((index for index in range(header) if lines[index].startswith("## ")), default=-1)
after = lines[end:]
def outside_items(lines: list[str], table: Table) -> Failure | None:
"""Why the table does not stand alone under ## Items: the table's order is todo.md's only order."""
heading = max((index for index in range(table.header) if lines[index].startswith("## ")), default=None)
if heading is None or lines[heading] != "## Items":
return Failure(f"the items table sits under {lines[heading] if heading is not None else 'no ## heading'}, not ## Items; move it under ## Items")
after = lines[table.start + len(table.rows):]
section = after[:next((index for index, line in enumerate(after) if line.startswith("## ")), len(after))]
return any(line.strip() for line in lines[heading + 1:header] + section)
if any(line.strip() for line in lines[heading + 1:table.header] + section):
return Failure(f"## Items holds text beside its table; an order goes in the scores or the {BLOCKED_BY} column, and a note in the item's detail")
return None
def blockers_first(scored: list[tuple[Item, float]]) -> list[tuple[Item, float]] | Failure: