Answer product-owner round 1: 0 🔴, 2 🟡 (0 misread); let the planner compare Scores in the file, name finish --no-changelog for a dropped item, name the plan's path in every refusal and exit 2 on a bad --release

This commit is contained in:
2026-11-14 16:01:50 +01:00
parent 812badf8b4
commit 0cb2cbabcd
9 changed files with 72 additions and 64 deletions
+13 -13
View File
@@ -9,7 +9,7 @@ from release_plan.ranking import stated
HEADING = re.compile(r"^#{2,3} ", re.M)
def added(todo: str, named: dict[str, str], detail: str) -> tuple[int, str] | Failure:
def added(todo: str, named: dict[str, str], detail: str, label: str) -> tuple[int, str] | Failure:
"""todo with an item filed under Next ID, and that ID; named holds its cells by column name, its Item cell the tagline, bold or not."""
next_id = stated(todo, "Next ID")
if isinstance(next_id, Failure):
@@ -21,7 +21,7 @@ def added(todo: str, named: dict[str, str], detail: str) -> tuple[int, str] | Fa
return unfit
id_ = int(next_id)
lines = re.sub(r"^`Next ID = [0-9]+`$", f"`Next ID = {id_ + 1}`", todo, count=1, flags=re.M).split("\n")
table = held_table(lines)
table = held_table(lines, label)
if isinstance(table, Failure):
return table
row = {**named, "ID": str(id_), "Item": bold_cell(tagline)}
@@ -29,13 +29,13 @@ def added(todo: str, named: dict[str, str], detail: str) -> tuple[int, str] | Fa
return id_, with_detail("\n".join(lines), id_, tagline, detail)
def edited(todo: str, id_: int, named: dict[str, str], detail: str | None) -> str | Failure:
"""todo with item id_'s cells set to those named holds, by column name, and its detail to detail unless None; an empty detail removes it."""
def edited(todo: str, id_: int, named: dict[str, str], detail: str | None, label: str) -> str | Failure:
"""todo with item id_'s cells set from named, which holds each new value by its column's name, and its detail set to detail unless None; an empty detail removes it. label is what a message calls the file."""
lines = todo.split("\n")
table = held_table(lines)
table = held_table(lines, label)
if isinstance(table, Failure):
return table
at = row_index(table, id_)
at = row_index(table, id_, label)
if isinstance(at, Failure):
return at
if absent := [column for column in named if column not in table.columns]:
@@ -56,13 +56,13 @@ def edited(todo: str, id_: int, named: dict[str, str], detail: str | None) -> st
return with_detail(without_detail("\n".join(lines), id_), id_, tagline, kept)
def finished(todo: str, id_: int) -> str | Failure:
def finished(todo: str, id_: int, label: str) -> str | Failure:
"""todo without item id_'s row and its detail."""
lines = todo.split("\n")
table = held_table(lines)
table = held_table(lines, label)
if isinstance(table, Failure):
return table
at = row_index(table, id_)
at = row_index(table, id_, label)
if isinstance(at, Failure):
return at
del lines[at]
@@ -105,7 +105,7 @@ def without_detail(text: str, id_: int) -> str:
return text[:section.start(1)] + body + text[section.end(1):]
def row_index(table: Table, id_: int) -> int | Failure:
def row_index(table: Table, id_: int, label: str) -> int | Failure:
"""The index in the file's lines of item id_'s row."""
for at, row in enumerate(table.rows, table.start):
found = cells(row, len(table.columns))
@@ -113,9 +113,9 @@ def row_index(table: Table, id_: int) -> int | Failure:
return found
if found[0] == str(id_):
return at
return Failure(f"todo.md holds no item {id_}")
return Failure(f"{label} holds no item {id_}")
def held_table(lines: list[str]) -> Table | Failure:
def held_table(lines: list[str], label: str) -> Table | Failure:
table = items_table(lines)
return Failure("todo.md holds no items table; rank_todo.py --help shows one") if table is None else table
return Failure(f"{label} holds no items table; rank_todo.py --help shows one") if table is None else table
+8 -9
View File
@@ -1,8 +1,8 @@
"""The one way a tool reads or writes a project's plan: through the store its config names.
The config's `plan` setting names the backend. A path names a markdown file, todo.md, the only backend so far. `todo-item` is the same door for an agent.
The config's `plan` setting names the backend. A path names a markdown file, todo.md, the only backend so far. An agent reads and changes the plan with `todo-item`, which works through the same store.
A tool that reads what a past commit held, such as `score-outcomes`, parses that commit's todo.md with `plan_of`: only the markdown backend has commits, and todo.md's items 365, 366 and 368 port those tools to the other backends."""
A tool that reads what a past commit held, such as `score-outcomes`, still parses that commit's todo.md itself, with `release_plan.todo_table`: only the markdown backend has commits, and todo.md's items 365, 366 and 368 port those tools to the other backends."""
import dataclasses
import pathlib
import typing
@@ -29,16 +29,15 @@ MISSING = "every project keeps a todo.md, and rank_todo.py --help shows one"
@dataclasses.dataclass(frozen=True)
class Plan:
"""A plan as one read found it."""
# Each item with its detail, in the order the backend supplies: by score for a markdown file, by backlog rank for a tracker.
# Each item with its detail, in the order the backend supplies: by release and then by rank for a markdown file, by backlog rank for a tracker.
items: list[Item]
# The releases the plan marks renamed, so never finished.
# The releases the plan marks renamed. Such a release holds no item because its items moved, not because it is finished.
renamed: frozenset[Release] = frozenset()
@dataclasses.dataclass(frozen=True)
class Written:
"""A write that landed."""
# The item written.
id: int
# What the backend says of the plan after the write, for stderr, such as an item now under the bar.
notes: tuple[str, ...] = ()
@@ -91,14 +90,14 @@ class FilePlan:
texts = self.texts()
if isinstance(texts, Failure):
return texts
filed = markdown_edits.added(texts[0], cells(fields), detail)
filed = markdown_edits.added(texts[0], cells(fields), detail, self.label)
return filed if isinstance(filed, Failure) else self.kept(*filed, texts)
def edit(self, id_: int, fields: dict[str, str], detail: str | None) -> Written | Failure:
texts = self.texts()
if isinstance(texts, Failure):
return texts
text = markdown_edits.edited(texts[0], id_, cells(fields), detail)
text = markdown_edits.edited(texts[0], id_, cells(fields), detail, self.label)
return text if isinstance(text, Failure) else self.kept(id_, text, texts)
def kept(self, id_: int, text: str, texts: tuple[str, str, str, str]) -> Written | Failure:
@@ -106,7 +105,7 @@ class FilePlan:
ranked = ranking.rank(text, *texts[1:])
if isinstance(ranked, Failure):
return ranked
# The write may lower another item under the bar, which the notes then say; only the item written refuses the write.
# The write may lower another item under the bar, which the notes then say; the write is refused only where the written item itself scores under the bar.
if under := [line for line in ranked.under_bar if line.startswith(f"item {id_} ")]:
return Failure(under[0])
return self.written(id_, ranked)
@@ -115,7 +114,7 @@ class FilePlan:
texts = self.texts()
if isinstance(texts, Failure):
return texts
text = markdown_edits.finished(texts[0], id_)
text = markdown_edits.finished(texts[0], id_, self.label)
if isinstance(text, Failure):
return text
ranked = ranking.rank(text, *texts[1:])