Answer prose round 1: 0 🔴, 15 🟡; say a blocker ranks above every item it blocks, give each pronoun one referent, put the upgrade step first in the changelog, say does not wait throughout

This commit is contained in:
2026-10-15 23:33:42 +02:00
parent 3ed118b3ea
commit c28e72bfc2
11 changed files with 36 additions and 35 deletions
+15 -13
View File
@@ -5,9 +5,9 @@ usage: rank_todo.py [--check] [todo.md]
Reads todo.md (default: ./todo.md), the README.md beside it, and docs/decisions.md when there is
one. Rewrites each item's Score from the formula and sorts the items by release; within a release,
security rows come first, then the rest by score from highest, then by ID. Then it moves each item's
blockers, the items its Blocked by cell names, to just above the first item they block. The table's
order is todo.md's only order. Orders the details to match. Adds the Blocked by column to a table
security rows come first, then the rest by score from highest, then by ID. Then it moves each blocker,
an item another's Blocked by cell names, that ranks below an item it blocks to just above the first
such item. Orders the details to match. Adds the Blocked by column to a table
without it. --check writes nothing and fails when the file is not ranked as it would be.
A valid todo.md; ## Details and each item's detail are optional:
@@ -53,8 +53,8 @@ A valid todo.md; ## Details and each item's detail are optional:
loop. An ID at or above Next ID fails; one below it that the table no longer holds was finished
or deleted, and is dropped.
- ## Items holds the table and nothing else: an order goes in the scores or the Blocked by column.
- The table holds the columns above. A table without Blocked by gains it; one without C fails, and so
does a column this version does not know, rather than be dropped.
- The table holds the columns above. A table without Blocked by gains it. One without C fails, and so
does one with a column this version does not know, since writing it would drop that column.
Exit 1, saying why, on bad arguments, a file that cannot be read or written, a todo.md, README.md or
docs/decisions.md that breaks the rules above, an item that is not exempt scoring under the bar, or
@@ -91,7 +91,7 @@ class Scoring:
class Ranked:
text: str
under_bar: list[str]
# Each blocker ID the ranking dropped because the table no longer holds it, which a typo would look like too.
# Blocker IDs the ranking dropped because the table no longer holds them; printed, since a mistyped ID is dropped the same way.
dropped: list[str]
@@ -206,7 +206,7 @@ def blocked_through(id_: int, items: list[Item]) -> set[int]:
def ordered(items: list[Item], scoring: Scoring) -> list[tuple[Item, float]] | Failure:
"""Each item with its score, by release, then security first, then by score from highest, then by ID; then each blocker just above the first item it blocks."""
"""Each item with its score, by release, then security first, then by score from highest, then by ID; then each blocker above every item it blocks."""
by_score = []
for item in items:
value = score(scoring.formula, item, scoring.weights)
@@ -219,7 +219,7 @@ def ordered(items: list[Item], scoring: Scoring) -> list[tuple[Item, float]] | F
def under_the_bar(item: Item, value: float, bar: float, items: list[Item]) -> str:
blocks = [str(id_) for id_ in sorted(blocked_through(item.id, items))]
blocked = f" and the items it blocks, directly or through another, {', '.join(blocks)}" if blocks else ""
blocked = f" and the items it blocks, directly or through another ({', '.join(blocks)})" if blocks else ""
return f"item {item.id} scores {value:.1f}, under the bar {bar:g}; delete it{blocked}, or mark it with a reason the bar does not apply"
@@ -256,7 +256,7 @@ def read_items(lines: list[str], scoring: Scoring) -> tuple[list[Item], Table] |
return Failure("todo.md's items table has no C column; add one after S, and score each item's C from 1 to 10 per rank_todo.py --help")
# 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; its columns are {', '.join(COLUMNS)}. Rename it, or move this machine to the release that added it")
return Failure(f"todo.md's items table has the column {', '.join(unknown)}, which this rank_todo.py does not know; the columns it knows are {', '.join(COLUMNS)}. Rename it, or move this machine to the release that added it")
if misplaced := outside_items(lines, table):
return misplaced
items = []
@@ -279,8 +279,10 @@ def read_items(lines: list[str], scoring: Scoring) -> tuple[list[Item], Table] |
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")
if heading is None:
return Failure("the items table sits under no ## heading; move it under ## Items")
if lines[heading] != "## Items":
return Failure(f"the items table sits under {lines[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))]
if any(line.strip() for line in lines[heading + 1:table.header] + section):
@@ -289,14 +291,14 @@ def outside_items(lines: list[str], table: Table) -> Failure | None:
def blockers_first(scored: list[tuple[Item, float]]) -> list[tuple[Item, float]] | Failure:
"""scored, each blocker moved up to just above the first item it blocks; a blocker the table no longer holds was finished or deleted, and is dropped."""
"""scored, each blocker that ranks below an item it blocks moved up to just above the first such item; a blocker the table no longer holds was finished or deleted, and is dropped."""
held = {item.id: (item, value) for item, value in scored}
position = {item.id: index for index, (item, _) in enumerate(scored)}
for item, _ in scored:
for blocker in item.blocked_by:
if blocker in held and held[blocker][0].release > item.release:
later, earlier = release_name(held[blocker][0]), release_name(item)
return Failure(f"item {item.id} is blocked by item {blocker}, which release {later} ships after release {earlier}; move item {blocker} to release {earlier} or earlier, or item {item.id} to release {later} or later")
return Failure(f"item {item.id}, in release {earlier}, is blocked by item {blocker}, in later release {later}; move item {blocker} to release {earlier} or earlier, or item {item.id} to release {later} or later")
result: list[tuple[Item, float]] = []
for item, _ in scored:
placed = place(item.id, held, position, {placed.id for placed, _ in result}, [])