Start an epic's issues in order of score, scoring each that holds none

This commit is contained in:
Lilleman
2026-11-20 14:30:30 +01:00
parent abaf54bc46
commit 5f2a4b6385
19 changed files with 615 additions and 83 deletions
+10 -1
View File
@@ -74,6 +74,8 @@ class Epic:
env: typing.Mapping[str, str]
# The team's own labels for its repos.
team: LabelRepos
# The keys of the scored issues, in the order they start (`planning.start_order`).
order: tuple[str, ...]
# The statuses `jira-unblocking-statuses` names; `settled` says what they do.
unblocking: tuple[str, ...] = ()
@@ -134,6 +136,12 @@ def chunks(issues: list[EpicIssue], team: LabelRepos, unblocking: tuple[str, ...
return found, waits
def in_start_order(found: list[Chunk], order: tuple[str, ...]) -> list[Chunk]:
"""found, with the chunks of the issues order names first, in its sequence. The others, which hold no score, follow in the tracker's rank order, as found lists them."""
place = {key: at for at, key in enumerate(order)}
return sorted(found, key=lambda chunk: place.get(chunk.issue, len(place)))
def turn_of(issue: EpicIssue, pick: Pick | None | Failure, blocking: list[str], by_key: dict[str, EpicIssue], holds: bool, unblocking: tuple[str, ...] = ()) -> Chunk | Waits:
"""The open issue's chunk, or why it waits. blocking are its open blockers, and holds says it holds up another open issue. A human's task gets a window only while it holds up another issue and nothing holds it up; that window waits for the human. A blocker outside the epic blocks until the human removes the link, since its state is unknown."""
if isinstance(pick, Failure):
@@ -162,9 +170,10 @@ def refusal(repo: str, room: RepoRoom) -> str | None:
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 one chunk to start is the epic's finishing (finish.py), in a window named for the epic's key. own is the key of the chunk that asks, which has finished or parked: 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 parked chunk waits in its window; one without a live window, as after a reboot, starts again as a stopped chunk does, whatever the limits, since it goes on parked. A Failure says why a window could not start; those before it run."""
"""Starts a do-epic in a new window for each of the epic's chunks that may start now, in the epic's start order, so the issue with the highest score takes the first free slot. Where finishing is set, no issue is open, and the one chunk to start is the epic's finishing (finish.py), in a window named for the epic's key. own is the key of the chunk that asks, which has finished or parked: 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 parked chunk waits in its window; one without a live window, as after a reboot, starts again as a stopped chunk does, whatever the limits, since it goes on parked. 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, epic.team, epic.unblocking)
found = in_start_order(found, epic.order)
if finishing:
found.append(Chunk(epic.key, None))
started: list[str] = []