Answer stability round 1: 1 🔴, 2 🟡 (0 misread); post a person's comment once the sub-tasks exist, count filed sub-tasks towards the split, and refuse a blank change
CI / tests (pull_request) Successful in 3m20s
CI / tests (pull_request) Successful in 3m20s
This commit is contained in:
+17
-16
@@ -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, Repo, REPO_NAME
|
||||
from do_epic.repo_pick import label_of, of_label, Repo, REPO_NAME
|
||||
from model_routing.ladder import Rung
|
||||
from claude_code.entries import structured_output
|
||||
|
||||
@@ -62,35 +62,36 @@ class Split:
|
||||
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.
|
||||
|
||||
A run that failed after filing some sub-tasks is finished by the next run, which files the sub-tasks that are lacking. The comment on a person's issue is posted when the issue has no sub-task yet, before the first is filed. Where the comment fails, nothing is filed; where the first filing fails after the comment posted, the next run posts the comment again."""
|
||||
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:
|
||||
return Split((), ())
|
||||
predicted = prediction(issue, by_person, rule, language, checkouts, rung, claude, cwd)
|
||||
if isinstance(predicted, Failure | Limited) or len(predicted.parts) < 2:
|
||||
return Split((), ()) if isinstance(predicted, Prediction) else predicted
|
||||
if isinstance(predicted, Failure | Limited):
|
||||
return predicted
|
||||
read = store.read()
|
||||
if isinstance(read, Failure):
|
||||
return read
|
||||
own = [task for task in read if task.parent == issue.key]
|
||||
if by_person and not own:
|
||||
if not predicted.comment:
|
||||
return Failure("the repo split gave no comment for the team on a person's issue")
|
||||
posted = store.comment(issue.key, predicted.comment)
|
||||
if isinstance(posted, Failure):
|
||||
return posted
|
||||
have = {label for task in own for label in task.labels}
|
||||
have = {pick.name for task in read if task.parent == issue.key for label in task.labels if isinstance(pick := of_label(label), Repo)}
|
||||
repos = tuple(dict.fromkeys([*have, *(part.repo for part in predicted.parts)]))
|
||||
if len(repos) < 2:
|
||||
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")
|
||||
filed: list[str] = []
|
||||
for part in predicted.parts:
|
||||
if label_of(Repo(part.repo)) in have:
|
||||
if part.repo in have:
|
||||
continue
|
||||
key = store.file(issue.key, task_summary(part.repo, issue.summary), part.change, (label_of(Repo(part.repo)),))
|
||||
if isinstance(key, Failure):
|
||||
return Failure(f"cannot file the sub-task for {part.repo} under {issue.key}: {key.reason}; {sub_tasks_filed(filed)}; run split again to file the rest")
|
||||
filed.append(key)
|
||||
posted = store.comment(issue.key, predicted.comment) if by_person else None
|
||||
if isinstance(posted, Failure):
|
||||
return Failure(f"cannot comment on {issue.key}: {posted.reason}; {sub_tasks_filed(filed)}; run split again to post it")
|
||||
marked = store.add_label(issue.key, SPLIT_LABEL)
|
||||
if isinstance(marked, Failure):
|
||||
return Failure(f"cannot mark {issue.key} as split: {marked.reason}; {sub_tasks_filed(filed)}; run split again to mark it")
|
||||
return Split(tuple(part.repo for part in predicted.parts), tuple(filed))
|
||||
return Split(repos, tuple(filed))
|
||||
|
||||
|
||||
def sub_tasks_filed(keys: list[str]) -> str:
|
||||
@@ -126,8 +127,8 @@ def answer_of(output: object) -> Prediction | Failure:
|
||||
parts: dict[str, Part] = {}
|
||||
for each in raw if isinstance(raw, list) else [None]:
|
||||
repo, change = (each.get("repo"), each.get("change")) if isinstance(each, dict) else (None, None)
|
||||
if not (isinstance(repo, str) and REPO_NAME.fullmatch(repo) and isinstance(change, str)):
|
||||
return Failure(f"the repo split answered {json.dumps(output)[:200]}; expected parts, each with a repo name of letters, digits, dots, hyphens and underscores and a change")
|
||||
if not (isinstance(repo, str) and REPO_NAME.fullmatch(repo) and isinstance(change, str) and change.strip()):
|
||||
return Failure(f"the repo split answered {json.dumps(output)[:200]}; expected parts, each with a repo name of letters, digits, dots, hyphens and underscores and a change that holds text")
|
||||
parts.setdefault(repo, Part(repo, change.strip()))
|
||||
return Prediction(tuple(parts.values()), comment.strip() if isinstance(comment, str) else "")
|
||||
|
||||
|
||||
Reference in New Issue
Block a user