Answer stability round 1: 1 🔴, 8 🟡 (0 misread); finish a release only once it holds no item, say no cut yet on an untagged branch, move tagged to ask.py, add three missing tests

This commit is contained in:
2026-10-30 13:01:58 +01:00
parent fd19b90f07
commit 10f10df3e9
13 changed files with 54 additions and 28 deletions
+9 -5
View File
@@ -7,6 +7,10 @@ from failure import Failure
from todo_table import Item, items, next_item, release_of, renames
from markdown_text import sections
# The version a branch with no v* tag counts as cut, so that every release todo.md names comes after it.
BEFORE_FIRST_RELEASE = (0, 0, 0)
@dataclasses.dataclass(frozen=True)
class LastCut:
"""What the default branch holds about its last release, which chunk_item weighs the plan against."""
@@ -25,9 +29,9 @@ class LastCut:
@dataclasses.dataclass(frozen=True)
class Upcoming:
"""The next release, and whether work has landed towards it, as `~/.claude/CLAUDE.md` → "Working loop" uses both."""
# The earliest release after the last cut that todo.md has named since that cut or the plan holds; without a cut, the earliest todo.md has ever named or the plan holds. None where there is none.
# The earliest release after the last cut that todo.md has named since that cut or the plan holds; without a cut, the earliest todo.md has named or the plan holds. None where there is none.
release: tuple[int, int, int] | None
# Whether it is the plan's earliest release. Without a cut, it also is where todo.md never named a release, even though the plan holds no item.
# Whether it is the plan's earliest release. Also True without a cut where todo.md has never named a release and the plan holds no item.
is_earliest: bool
# Whether work has landed towards it: one or more changes are unreleased, as unreleased_changes counts them.
landed: bool | Failure
@@ -126,14 +130,14 @@ def next_release(found: list[Item], cut: LastCut) -> Upcoming | Cut | Unknown:
"""The next release after cut, and whether work has landed towards it. found holds the plan's items.
Cut where the plan files items under the last cut's version or earlier, and Unknown where todo.md's texts since the cut cannot be read.
Where the branch has no tag, every release todo.md named is after the cut, so one whose items are all done still reads as the next release and gets its release review.
Where the branch has no tag, the cut counts as BEFORE_FIRST_RELEASE, so a release todo.md named whose items are all done still reads as the next release.
"""
earliest = min((item.release for item in found), default=None)
untagged = cut.tag is None
cut_version = (0, 0, 0) if untagged else version_of(cut.tag)
cut_version = BEFORE_FIRST_RELEASE if untagged else version_of(cut.tag)
if cut_version is None:
return Upcoming(earliest, True, landed(cut))
if earliest is not None and earliest <= cut_version:
if earliest is not None and earliest <= cut_version and not untagged:
return Cut(earliest)
named = named_releases(cut.todos_since)
if isinstance(named, Failure):