Items 250, 253, 256, 258 - Move repeat-read's reads into repeat_read.py, split waiting.py by role, name an untagged release's review, fix release-review findings in-release

This commit is contained in:
2026-10-30 12:41:48 +01:00
parent 36b38cc133
commit 59697806ee
25 changed files with 468 additions and 372 deletions
+10 -8
View File
@@ -16,7 +16,7 @@ class LastCut:
changelog: str | Failure
# How many commits follow the tag, or make up the branch where it has none.
commits: int | Failure
# todo.md's text at the tag and at each later commit that changed it, oldest first, as named_releases reads them; empty without a tag.
# todo.md's text at the tag and at each later commit that changed it, oldest first, as named_releases reads them; where the branch has no tag, at each commit that changed it. Empty where the tags cannot be read.
todos_since: list[str] | Failure
# Whether a release review has landed since the tag, as release_reviewed reads it.
reviewed: bool | Failure = False
@@ -25,9 +25,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 plan's earliest. 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 ever 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 always is, even where the plan holds no item.
# 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.
is_earliest: bool
# Whether work has landed towards it: one or more changes are unreleased, as unreleased_changes counts them.
landed: bool | Failure
@@ -102,13 +102,13 @@ def release_reviewed(tag: str | None, ref: str, cwd: str) -> bool | Failure:
def todos_since(tag: str | None | Failure, ref: str, cwd: str) -> list[str] | Failure:
"""LastCut.todos_since, read from ref in cwd. A pull request's own commits do not count, only the merge that landed it: --first-parent."""
if not isinstance(tag, str):
if isinstance(tag, Failure):
return []
changed = git("log", "--first-parent", "--reverse", "--format=%H", f"{tag}..{ref}", "--", "todo.md", cwd=cwd)
changed = git("log", "--first-parent", "--reverse", "--format=%H", f"{tag}..{ref}" if tag else ref, "--", "todo.md", cwd=cwd)
if isinstance(changed, Failure):
return changed
texts = []
for commit in [tag, *changed.split()]:
for commit in [*([tag] if tag else []), *changed.split()]:
text = file_at(commit, "todo.md", cwd)
if isinstance(text, Failure):
return text
@@ -126,9 +126,11 @@ 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.
"""
earliest = min((item.release for item in found), default=None)
cut_version = version_of(cut.tag)
untagged = cut.tag is None
cut_version = (0, 0, 0) 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:
@@ -140,7 +142,7 @@ def next_release(found: list[Item], cut: LastCut) -> Upcoming | Cut | Unknown:
if earliest is not None:
after.add(earliest)
release = min(after, default=None)
return Upcoming(release, earliest is not None and earliest == release, landed(cut))
return Upcoming(release, earliest == release and (earliest is not None or untagged), landed(cut))
def version_of(tag: str | None | Failure) -> tuple[int, int, int] | None: