Answer principles round 1: 0 🔴, 4 🟡; have next_release take the plan's items and spell out each expected pick
This commit is contained in:
+32
-20
@@ -25,10 +25,10 @@ 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.
|
||||
release: tuple[int, int, int] | None
|
||||
# Whether it is the plan's earliest release, as it always is without a cut, even where 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
|
||||
# The last cut's version x.y.z, None where the newest v* tag names none.
|
||||
cut: tuple[int, int, int] | None
|
||||
|
||||
|
||||
@dataclasses.dataclass(frozen=True)
|
||||
@@ -102,38 +102,50 @@ def todos_since(tag: str | None | Failure, ref: str, cwd: str) -> list[str] | Fa
|
||||
|
||||
def chunk_item(found: list[Item], cut: LastCut) -> Pick:
|
||||
"""The pick from todo.md's items, weighed against the last cut. Routing and chunk-preflight both pick with it, so they name one item."""
|
||||
earliest = min((item.release for item in found), default=None)
|
||||
upcoming = next_release(cut, earliest)
|
||||
return standing(upcoming, earliest, next_item(found)) if isinstance(upcoming, Upcoming) else upcoming
|
||||
upcoming = next_release(found, cut)
|
||||
return standing(upcoming, next_item(found)) if isinstance(upcoming, Upcoming) else upcoming
|
||||
|
||||
|
||||
def next_release(cut: LastCut, earliest: tuple[int, int, int] | None) -> Upcoming | Cut | Unknown:
|
||||
"""The next release after cut, and whether work has landed towards it. earliest is the plan's earliest release, None where the plan holds no item.
|
||||
def next_release(found: list[Item], cut: LastCut) -> Upcoming | Cut | Unknown:
|
||||
"""The next release after cut, and whether work has landed towards it, for the plan whose items are found.
|
||||
|
||||
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.
|
||||
"""
|
||||
tagged = re.fullmatch(r"v([0-9]+\.[0-9]+\.[0-9]+)", cut.tag) if isinstance(cut.tag, str) else None
|
||||
changes = unreleased_changes(cut)
|
||||
landed = changes if isinstance(changes, Failure) else changes > 0
|
||||
if tagged is None:
|
||||
return Upcoming(earliest, landed, None)
|
||||
cut_version = release_of(tagged[1])
|
||||
earliest = min((item.release for item in found), default=None)
|
||||
cut_version = version_of(cut.tag)
|
||||
if cut_version is None:
|
||||
return Upcoming(earliest, True, landed(cut))
|
||||
if earliest is not None and earliest <= cut_version:
|
||||
return Cut(earliest)
|
||||
named = named_releases(cut.todos_since)
|
||||
if isinstance(named, Failure):
|
||||
return Unknown()
|
||||
after = {release for release in named if release > cut_version} | ({earliest} if earliest is not None else set())
|
||||
return Upcoming(min(after, default=None), landed, cut_version)
|
||||
after = {release for release in named if release > cut_version}
|
||||
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))
|
||||
|
||||
|
||||
def standing(upcoming: Upcoming, earliest: tuple[int, int, int] | None, first: Item | None) -> Next | ReadyToCut | Unplanned | Unknown:
|
||||
"""How the plan stands to the next release, upcoming. earliest is the plan's earliest release, None where the plan holds no item, and first is next_item's pick.
|
||||
def version_of(tag: str | None | Failure) -> tuple[int, int, int] | None:
|
||||
"""The version x.y.z that tag, the newest v* tag, names; None where it names none."""
|
||||
tagged = re.fullmatch(r"v([0-9]+\.[0-9]+\.[0-9]+)", tag) if isinstance(tag, str) else None
|
||||
return None if tagged is None else release_of(tagged[1])
|
||||
|
||||
Without a cut, or where the plan's earliest release is the next, the next chunk takes first. Else the next release holds no item, and is ready to cut once work has landed towards it, or else to plan.
|
||||
|
||||
def landed(cut: LastCut) -> bool | Failure:
|
||||
"""Whether work has landed since cut: one or more changes are unreleased."""
|
||||
changes = unreleased_changes(cut)
|
||||
return changes if isinstance(changes, Failure) else changes > 0
|
||||
|
||||
|
||||
def standing(upcoming: Upcoming, first: Item | None) -> Next | ReadyToCut | Unplanned | Unknown:
|
||||
"""How the plan stands to the next release, upcoming, with first, next_item's pick.
|
||||
|
||||
Where the next release is the plan's earliest, the pick is Next, holding first. Else the next release holds no item: it is ready to cut once work has landed towards it, and else it is to plan.
|
||||
"""
|
||||
if upcoming.cut is None or (earliest is not None and earliest == upcoming.release):
|
||||
return Next(earliest, first)
|
||||
if upcoming.is_earliest:
|
||||
return Next(upcoming.release, first)
|
||||
if isinstance(upcoming.landed, Failure):
|
||||
return Unknown()
|
||||
return ReadyToCut(upcoming.release) if upcoming.landed else Unplanned(upcoming.release)
|
||||
|
||||
Reference in New Issue
Block a user