Finish an epic: a finishing chunk files each repo's release review, has the human confirm each goal, and closes the epic with its summary

This commit is contained in:
2026-11-18 23:59:53 +01:00
parent 382ac99c41
commit fdb942472d
20 changed files with 514 additions and 63 deletions
+10 -4
View File
@@ -38,9 +38,11 @@ class Waits:
@dataclasses.dataclass(frozen=True)
class Started:
# The issues whose chunks started.
# The issues whose chunks started, and the epic's key where its finishing did.
started: list[str]
waits: list[Waits]
# Whether the epic is closed, so that not even its finishing starts.
closed: bool = False
@dataclasses.dataclass(frozen=True)
@@ -106,10 +108,12 @@ def refusal(repo: str, room: RepoRoom) -> str | None:
return None
def start_chunks(epic: Epic, issues: list[EpicIssue], own: str | None, run: tmux.Tmux) -> Started | Failure:
"""Starts a do-epic in a new window for each of the epic's chunks that may start now. own is the issue of the chunk that asks, which has finished: it counts as running nowhere, and no stopped chunk starts again. Where own is None, the human's `do-epic <EPIC-KEY>` asks, and each stopped chunk starts again. A Failure says why a window could not start; those before it run."""
def start_chunks(epic: Epic, issues: list[EpicIssue], finishing: bool, own: str | None, run: tmux.Tmux) -> Started | Failure:
"""Starts a do-epic in a new window for each of the epic's chunks that may start now. Where finishing is set, no issue is open, and the chunk is the epic's finishing (finish.py), in a window named for the epic's key. own is the issue of the chunk that asks, which has finished: it counts as running nowhere, and no stopped chunk starts again. Where own is None, the human's `do-epic <EPIC-KEY>` asks, and each stopped chunk starts again. A Failure says why a window could not start; those before it run."""
session = tmux.session_name(tmux.EPIC, epic.key)
found, waits = chunks(issues)
if finishing:
found.append(Chunk(epic.key, None))
started: list[str] = []
try:
with starting(epic.folder):
@@ -134,7 +138,9 @@ def start_chunks(epic: Epic, issues: list[EpicIssue], own: str | None, run: tmux
started.append(chunk.issue)
except OSError as failure:
return Failure(f"cannot lock {failure.filename or epic.folder / LOCK}: {failure.strerror}")
return Started(started, sorted(waits, key=lambda wait: [issue.key for issue in issues].index(wait.issue)))
# The epic's finishing is no issue, and waits last.
order = [*(issue.key for issue in issues), epic.key]
return Started(started, sorted(waits, key=lambda wait: order.index(wait.issue)))
def start_chunk(epic: Epic, chunk: Chunk, own: str | None, windows: list[tmux.Listed], run: tmux.Tmux) -> list[tmux.Listed] | str | Failure: