Read a team's own repo labels as do-epic's picks, and treat an item a person filed sub-tasks under as split
CI / tests (pull_request) Has been cancelled

This commit is contained in:
Lilleman
2026-11-19 15:33:51 +01:00
parent 017cf33611
commit 95535b4fb3
20 changed files with 278 additions and 119 deletions
+17 -12
View File
@@ -7,7 +7,7 @@ import json
from claude_code.reply import Claude, claude_reply, Limited
from do_epic.backend.protocol import EpicIssue, EpicStore
from failure import Failure
from do_epic.repo_pick import label_of, of_label, Repo, REPO_NAME
from do_epic.repo_pick import label_of, of_label, Repo, REPO_NAME, LabelRepos
from model_routing.ladder import Rung
from claude_code.entries import structured_output
@@ -59,22 +59,27 @@ class Split:
tasks: tuple[str, ...]
def split(store: EpicStore, issue: EpicIssue, by_person: bool, rule: str, language: str, checkouts: tuple[str, ...], rung: Rung, claude: Claude, cwd: str) -> Split | Failure | Limited:
"""Splits the epic's child issue into a sub-task per repo it changes, where that is more than one. by_person says a person filed the issue, and checkouts are the epic's repos that claude may read. An item that changes one repo or none is left as it is, for repo_pick, and one already marked SPLIT_LABEL is left alone.
def is_split(item: EpicIssue, issues: list[EpicIssue]) -> bool:
"""Whether the item is worked through its sub-tasks: it is marked SPLIT_LABEL, or a person filed a sub-task under it. A sub-task do-epic filed doesn't count without the mark, since a run that failed between the two leaves the next run to file the lacking ones."""
return SPLIT_LABEL in item.labels or any(task.parent == item.key and not task.by_loop for task in issues)
A sub-task of the item already labelled for a repo counts as that repo's, so a run that failed after filing some sub-tasks, or a person's own sub-task, leaves the next run to file only the lacking ones. The comment on a person's issue is posted once its sub-tasks are filed, just before the item is marked. A failure after the comment but before the mark posts it again on the next run."""
if SPLIT_LABEL in issue.labels:
def split(store: EpicStore, issue: EpicIssue, team: LabelRepos, by_person: bool, rule: str, language: str, checkouts: tuple[str, ...], rung: Rung, claude: Claude, cwd: str) -> Split | Failure | Limited:
"""Splits the epic's child issue into a sub-task per repo it changes, where that is more than one. by_person says a person filed the issue, and checkouts are the epic's repos that claude may read. An item that changes one repo or none is left as it is, for repo_pick, and one already split (is_split) is left alone.
A sub-task of the item already labelled for a repo counts as that repo's, so a run that failed after filing some sub-tasks leaves the next run to file only the lacking ones. The comment on a person's issue is posted once its sub-tasks are filed, just before the item is marked. A failure after the comment but before the mark posts it again on the next run."""
read = store.read()
if isinstance(read, Failure):
return read
if is_split(issue, read):
return Split((), ())
predicted = prediction(issue, by_person, rule, language, checkouts, rung, claude, cwd)
if isinstance(predicted, Failure | Limited):
return predicted
read = store.read()
if isinstance(read, Failure):
return read
have = {pick.name for task in read if task.parent == issue.key for label in task.labels if isinstance(pick := of_label(label), Repo)}
have = {pick.name for task in read if task.parent == issue.key for label in task.labels if isinstance(pick := of_label(label, team), Repo)}
repos = tuple(dict.fromkeys([*sorted(have), *(part.repo for part in predicted.parts)]))
if len(repos) < 2:
# Left as it is even where an earlier, failed run filed one sub-task and this prediction names only that repo: marking the item split would make a person's own sub-task for one repo turn their ordinary issue into a tracking parent. The stray sub-task is labelled for its repo and harmless.
# Left as it is even where an earlier, failed run filed one sub-task and this prediction names only that repo. The stray sub-task is labelled for its repo and harmless.
return Split((), ())
if by_person and not predicted.comment:
return Failure("the repo split gave no comment for the team on a person's issue")
@@ -106,12 +111,12 @@ def task_summary(repo: str, summary: str) -> str:
def finished(issues: list[EpicIssue], key: str) -> bool:
"""Whether the item named key is done. An item marked SPLIT_LABEL that has sub-tasks is done once each of them is, whatever its own status; any other item is done by its own status, and a key no issue has isn't done."""
"""Whether the item named key is done. A split item (is_split) that has sub-tasks is done once each of them is, whatever its own status; any other item is done by its own status, and a key no issue has isn't done."""
item = next((issue for issue in issues if issue.key == key), None)
tasks = [issue for issue in issues if issue.parent == key]
if item is None:
return False
return all(task.done for task in tasks) if SPLIT_LABEL in item.labels and tasks else item.done
return all(task.done for task in tasks) if is_split(item, issues) and tasks else item.done
def prediction(issue: EpicIssue, by_person: bool, rule: str, language: str, checkouts: tuple[str, ...], rung: Rung, claude: Claude, cwd: str) -> Prediction | Failure | Limited: