Answer architecture round 3: 0 🔴, 1 🟡; pick the next chunk's item in one function, todo_table.chunk_item, which routing and the preflight both call, so routing names no item where the release after the last cut has none

This commit is contained in:
2026-10-17 02:19:11 +02:00
parent 45004e1b0b
commit 4cf3c2bd8c
9 changed files with 130 additions and 95 deletions
+24
View File
@@ -17,6 +17,9 @@ BLOCKED_BY = "Blocked by"
MOVES = "Moves"
# How the items table's header opens, which tells it from any other table in todo.md.
HEADER_START = "| ID | Release |"
# How the plan's earliest release stands to the version x.y.z the newest tag names. "next": it is x.y.z+1, x.y+1.0 or x+1.0.0, or no tag names a version. "cut": it is x.y.z or earlier.
# Else the release after the tag holds no item: "finished" where commits followed the tag, "unplanned" where none did, and "unknown" where they cannot be counted.
Standing = typing.Literal["next", "cut", "finished", "unplanned", "unknown"]
# todo.md's ## Details section, its body the first group.
DETAILS = re.compile(r"^## Details\n(.*?)(?=^## |\Z)", re.M | re.S)
# Each goal an item names, in its order, with how far the item moves it; None in OLD_SHAPE, whose Goals cell names no move.
@@ -173,6 +176,27 @@ def next_item(found: list[Item]) -> Item | None:
return next((item for item in found if item.release == release and item.id not in waits), None)
def standing(tag: str | None | Failure, commits: int | Failure, earliest: tuple[int, int, int] | None) -> Standing:
"""How the plan's earliest release, None where the plan holds no item, stands to the newest v* tag, as Standing says; commits counts those after the tag."""
cut = re.fullmatch(r"v([0-9]+)\.([0-9]+)\.([0-9]+)", tag) if isinstance(tag, str) else None
if cut is None:
return "next"
major, minor, patch = (int(part) for part in cut.groups())
if earliest in ((major, minor, patch + 1), (major, minor + 1, 0), (major + 1, 0, 0)):
return "next"
if earliest is not None and earliest <= (major, minor, patch):
return "cut"
if isinstance(commits, Failure):
return "unknown"
return "finished" if commits else "unplanned"
def chunk_item(found: list[Item], tag: str | None | Failure, commits: int | Failure) -> tuple[Standing, Item | None]:
"""The item the next chunk takes first, next_item's pick, where standing finds the plan's earliest release the next; else None. Routing and chunk-preflight both pick with it, so they name one item; standing comes with it, so a caller can say why there is none."""
stands = standing(tag, commits, min((item.release for item in found), default=None))
return stands, next_item(found) if stands == "next" else None
def bundle_candidates(found: list[Item], first: Item) -> list[Item]:
"""The items of first's release, in the table's order, that a chunk taking first may take too: those that do not wait once the chunk's own items count as done."""
chunk = {item.id for item in found if item.release == first.release}