Answer stability round 1: 0 🔴, 1 🟡 (0 misread); check every field a read takes, ask for a parent by its key, and sort labels

This commit is contained in:
2026-11-18 10:46:07 +01:00
parent 080a6a8693
commit a29d2a2315
5 changed files with 103 additions and 66 deletions
+12 -8
View File
@@ -1,6 +1,6 @@
"""What every backend of an epic's plan reads and files: an EpicIssue, and the EpicStore protocol they all meet. do-epic reads an epic only through EpicStore, so another tracker can stand behind it; contract.py holds the tests every backend passes.
It stands apart from plan_store's PlanStore, whose every item names a release, since an epic item has none (`docs/decisions.md` → `do-epic: drives one Jira epic …`) and may be a sub-task."""
EpicStore is not plan_store's PlanStore. A PlanStore item names a release, but an epic item has none (`docs/decisions.md` → `do-epic: drives one Jira epic …`), and it may be a sub-task."""
import dataclasses
import re
import typing
@@ -18,6 +18,7 @@ class EpicIssue:
summary: str
# The description, as markdown; empty where the issue has none.
detail: str
# Sorted by name.
labels: tuple[str, ...]
# The assignee's display name; None where nobody is assigned.
assignee: str | None
@@ -30,11 +31,11 @@ class EpicIssue:
class EpicStore(typing.Protocol):
"""The issues of one epic. A write that fails files nothing, except where its Failure says the tracker may have taken it all the same."""
"""The issues of one epic. A write that fails doesn't file anything, except where its Failure says the tracker may have taken it all the same."""
@property
def epic(self) -> str:
"""The epic's key, the parent of each child issue."""
def epic_key(self) -> str:
"""The parent of each child issue."""
def read(self) -> list[EpicIssue] | Failure:
"""Each child issue, open or done, in the tracker's rank order, each followed by its sub-tasks in theirs."""
@@ -43,12 +44,15 @@ class EpicStore(typing.Protocol):
"""Files an open issue under parent and answers its key: a child issue where parent is the epic, a sub-task where parent is one of its child issues. detail is markdown, and may be empty."""
def unfit(epic: str, children: set[str], parent: str, summary: str, labels: tuple[str, ...]) -> Failure | None:
"""Why an issue with this summary and these labels cannot be filed under parent, where children are the keys of the child issues of the epic named epic; None where it can. Every backend refuses the same filings."""
def unfit(summary: str, labels: tuple[str, ...]) -> Failure | None:
"""Why no tracker can file an issue with this summary and these labels; None where one can."""
if not summary.strip() or "\n" in summary:
return Failure("the summary must be one line of text")
if bad := next((label for label in labels if not LABEL.fullmatch(label)), None):
return Failure(f"the label {bad!r} is empty or holds white space")
if parent != epic and parent not in children:
return Failure(f"{parent} is neither the epic {epic} nor one of its child issues, so nothing can be filed under it")
return None
def no_parent(epic_key: str, parent: str) -> Failure:
"""What every backend says when asked to file under parent, which is neither the epic nor one of its child issues."""
return Failure(f"{parent} is neither the epic {epic_key} nor one of its child issues, so nothing can be filed under it")