Answer stability round 1: 0 🔴, 4 🟡 (0 misread); name each template fault truly and pass the template to split
CI / tests (pull_request) Successful in 2m33s

This commit is contained in:
Lilleman
2026-11-20 10:46:19 +01:00
parent 3e8910f573
commit c39d23a1b3
5 changed files with 54 additions and 44 deletions
+9 -11
View File
@@ -19,8 +19,8 @@ One pair per machine, the same for every epic (docs/decisions.md → `do-epic: d
- `jira-finish-transition` and `jira-finish-status` name the workflow transition that moves a finished chunk's issue and closes a finished epic, such as "Mark as done", and the status it leads to, such as "Done". A project's config names a plan item's the same way. Set both or neither; without them do-epic moves no issue to done and closes no epic.
- `jira-unblocking-statuses` lists the statuses at which an issue's work has landed though Jira doesn't count it done yet, such as `["Release Ready"]`, in upper or lower case. An issue in one of them takes no chunk and no longer blocks the issues it blocks. A status Jira counts as done always does both, listed or not.
- `jira-automation-moves-issues = true` says the team's own automation moves an issue when its pull request merges. do-epic then moves only the issue of a chunk without a repo, which has no pull request, and waits for the automation to move each other. It needs `jira-unblocking-statuses`, which then names the status the automation gives an issue whose pull request merged. false where left out.
- `[label-repos]` has one line for each label of the team's own that names a repo: the label, then that repo's name, such as `twu-4 = "tenant-web-ui-4"`. do-epic reads such a label as it reads its own `repo:<name>`. A team whose label is the repo's name maps the name to itself.
- `sub-task-summary` shapes the summary of each sub-task do-epic files for an issue that changes several repos, such as `"{label}: {Summary}"`. `{label}` is the team's label for the repo, else the repo's name, and `{Summary}` is the issue's summary with a capital first letter. It must hold `{Summary}`. Where left out, a summary is `[<repo>] <the issue's summary>`.
- `[label-repos]` has one line for each label of the team's own that names a repo: the label, then that repo's name, such as `twu-4 = "tenant-web-ui-4"`. do-epic reads such a label as it reads its own `repo:<name>`. A team whose label is the repo's name maps the name to itself. Where several lines name one repo, do-epic writes the label of the first.
- `repo-rule.md` is prose that says how to tell an item's repo, and mustn't be blank."""
import dataclasses
import pathlib
@@ -86,21 +86,19 @@ def label_repo_faults(table: object) -> list[str]:
def summary_template_faults(template: object) -> list[str]:
"""What is wrong with the SUB_TASK_SUMMARY template: a value that isn't one line with `{Summary}` and no other field than `{label}`."""
"""What is wrong with the SUB_TASK_SUMMARY template: a value that isn't one line, that holds a brace Python can't read, a field other than `{label}` and `{Summary}`, a format after a field's name, or no `{Summary}`."""
example = "`\"{label}: {Summary}\"`"
if not isinstance(template, str) or "\n" in template:
return [f"`{SUB_TASK_SUMMARY}` is {template!r}, not one line of text such as {example}"]
try:
fields = list(string.Formatter().parse(template))
except ValueError as failure:
return [f"`{SUB_TASK_SUMMARY}` is {template!r}, {failure}; write a brace that stands for itself twice, as {{{{ or }}}}"]
named = [name for _, name, spec, conversion in fields if name is not None and not spec and not conversion]
faults = [f"`{SUB_TASK_SUMMARY}` names {{{name}}}, and only {{label}} and {{Summary}} are known" for name in dict.fromkeys(named) if name not in ("label", "Summary")]
odd = [name for _, name, spec, conversion in fields if name is not None and (spec or conversion)]
fields = [(name, spec, conversion) for _, name, spec, conversion in string.Formatter().parse(template) if name is not None]
except ValueError:
return [f"`{SUB_TASK_SUMMARY}` is {template!r}, which has a brace that stands alone; write a brace that is plain text as {{{{ or }}}}"]
names = [name for name, _, _ in fields]
return [
*faults,
*([f"`{SUB_TASK_SUMMARY}` holds a field with a format or conversion, which isn't read"] if odd else []),
*([f"`{SUB_TASK_SUMMARY}` lacks {{Summary}}, so every sub-task would get the same summary, such as {example}"] if "Summary" not in named else []),
*(f"`{SUB_TASK_SUMMARY}` names {{{name}}}, and only {{label}} and {{Summary}} are known" for name in dict.fromkeys(names) if name not in ("label", "Summary")),
*(f"`{SUB_TASK_SUMMARY}` writes {{{name}{'!' + conversion if conversion else ''}{':' + spec if spec else ''}}} with something after the name; write {{{name}}} alone" for name, spec, conversion in fields if (spec or conversion) and name in ("label", "Summary")),
*([f"`{SUB_TASK_SUMMARY}` lacks {{Summary}}, so no sub-task's summary would say what changes in it, such as {example}"] if "Summary" not in names else []),
]
+2 -2
View File
@@ -64,7 +64,7 @@ def is_split(item: EpicIssue, issues: list[EpicIssue]) -> bool:
return SPLIT_LABEL in item.labels or any(task.parent == item.key and not task.by_loop for task in issues)
def split(store: EpicStore, issue: EpicIssue, team: LabelRepos, by_person: bool, rule: str, language: str, checkouts: tuple[str, ...], rung: Rung, claude: Claude, cwd: str, summary_template: str | None = None) -> Split | Failure | Limited:
def split(store: EpicStore, issue: EpicIssue, team: LabelRepos, by_person: bool, rule: str, language: str, checkouts: tuple[str, ...], rung: Rung, claude: Claude, cwd: str, summary_template: str | None) -> 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."""
@@ -106,7 +106,7 @@ def sub_tasks_filed(keys: list[str]) -> str:
def task_summary(repo: str, summary: str, team: LabelRepos, template: str | None) -> str:
"""A sub-task's summary: the team's template (config.py) with `{label}` the team's label for the repo, else its name, and `{Summary}` the item's summary with a capital first letter. Without a template, `[<repo>] <the item's summary>`: three readers, seated as a client's team, picked that from four candidates, over `<repo>: …`, `… (<repo>)` and `… — <repo> part`, 3-0."""
"""A sub-task's summary from the team's template, where it has one. Without one, `[<repo>] <the item's summary>`: three readers, seated as a client's team, picked that from four candidates, over `<repo>: …`, `… (<repo>)` and `… — <repo> part`, 3-0."""
if template is None:
return f"[{repo}] {summary}"
return template.format(label=team_label(repo, team) or repo, Summary=summary[:1].upper() + summary[1:])
+18 -16
View File
@@ -1,4 +1,3 @@
import json
import pathlib
import sys
import tempfile
@@ -67,12 +66,6 @@ class ConfigTest(unittest.TestCase):
assert isinstance(found, DoEpicConfig), found
self.assertEqual(found.sub_task_summary, "{label}: {Summary}")
def test_reads_a_template_that_ends_in_plain_text(self) -> None:
self.write(SETTINGS + 'sub-task-summary = "{Summary} for {label} in Jira"\n')
found = load(self.home)
assert isinstance(found, DoEpicConfig), found
self.assertEqual(found.sub_task_summary, "{Summary} for {label} in Jira")
def test_leaves_a_sub_tasks_summary_to_its_default_where_the_config_has_no_template(self) -> None:
self.write()
found = load(self.home)
@@ -80,18 +73,27 @@ class ConfigTest(unittest.TestCase):
self.assertIsNone(found.sub_task_summary)
def test_refuses_a_template_that_is_no_one_line_with_summary_and_only_known_fields(self) -> None:
for template, fault in (
("4", "`sub-task-summary` is 4, not one line of text"),
("a\\nb {Summary}", "not one line of text"),
("{label}", "`sub-task-summary` lacks {Summary}, so every sub-task would get the same summary, such as `\"{label}: {Summary}\"`"),
("{label}: {Summary} {repo}", "`sub-task-summary` names {repo}, and only {label} and {Summary} are known"),
("{Summary:>9}", "`sub-task-summary` holds a field with a format or conversion"),
("{Summary", "`sub-task-summary` is '{Summary'"),
for line, fault in (
("sub-task-summary = 4", "`sub-task-summary` is 4, not one line of text"),
('sub-task-summary = "a\\nb {Summary}"', "not one line of text"),
('sub-task-summary = "{label}"', "`sub-task-summary` lacks {Summary}, so no sub-task's summary would say what changes in it, such as `\"{label}: {Summary}\"`"),
('sub-task-summary = "{label}: {Summary} {repo}"', "`sub-task-summary` names {repo}, and only {label} and {Summary} are known"),
('sub-task-summary = "{Summary:>9}"', "`sub-task-summary` writes {Summary:>9} with something after the name; write {Summary} alone"),
('sub-task-summary = "{Summary} {label!r}"', "`sub-task-summary` writes {label!r} with something after the name; write {label} alone"),
('sub-task-summary = "{Summary"', "`sub-task-summary` is '{Summary', which has a brace that stands alone; write a brace that is plain text as {{ or }}"),
):
with self.subTest(template=template):
self.write(SETTINGS + f"sub-task-summary = {template if template == '4' else json.dumps(template.replace(chr(92) + 'n', chr(10)))}\n")
with self.subTest(line=line):
self.write(SETTINGS + line + "\n")
self.assertIn(fault, self.failure())
def test_reads_a_template_of_plain_text_around_its_fields_and_a_brace_written_twice(self) -> None:
for template in ("{Summary}", "{Summary}{{", "{Summary} for {label} in Jira"):
with self.subTest(template=template):
self.write(SETTINGS + f'sub-task-summary = "{template}"\n')
found = load(self.home)
assert isinstance(found, DoEpicConfig), found
self.assertEqual(found.sub_task_summary, template)
def test_refuses_a_label_repos_that_is_no_table(self) -> None:
self.write('label-repos = "twu-4"\n' + SETTINGS)
self.assertIn("`label-repos` is 'twu-4', not a table of labels, such as `twu-4 = \"tenant-web-ui-4\"` under `[label-repos]`", self.failure())
+16 -9
View File
@@ -170,19 +170,26 @@ class Planning(DoEpicTest):
found, _, _ = self.plan(fake)
self.assertEqual((found, fake.made("input")), ([issue("ABC-20", "backend")], ["The label that says where ABC-20 is worked, `repo:<name>`, `do-epic-claude` or `do-epic-human` (or the team's `backend`), or Enter alone to leave it waiting: "]))
def test_files_sub_tasks_in_the_teams_labels_and_summary_and_names_its_label_for_a_repo_typed_by_name(self) -> None:
with (self.home / ".claude-projects/do-epic/config.toml").open("a", encoding="utf-8") as config:
config.write('\n[label-repos]\nbackend = "api"\n')
text = (self.home / ".claude-projects/do-epic/config.toml").read_text(encoding="utf-8")
(self.home / ".claude-projects/do-epic/config.toml").write_text('sub-task-summary = "{label}: {Summary}"\n' + text, encoding="utf-8")
self.issues = [issue("ABC-20"), issue("ABC-21")]
def configure_team(self, *above: str) -> None:
"""Gives the config the team's label `backend` for api, and the settings in above."""
path = self.home / ".claude-projects/do-epic/config.toml"
path.write_text("".join(f"{line}\n" for line in above) + path.read_text(encoding="utf-8") + '\n[label-repos]\nbackend = "api"\n', encoding="utf-8")
def test_files_sub_tasks_under_the_teams_label_and_summary_template(self) -> None:
self.configure_team('sub-task-summary = "{label}: {Summary}"')
self.issues = [issue("ABC-20")]
parts = says({"parts": [{"repo": "api", "change": "Add the endpoint."}, {"repo": "web", "change": "Call it."}], "comment": "Delat per repo."})
fake = FakeEffects(claude=[parts, says({"parts": []}), says({"pick": "unclear", "question": "api or web?"})], inputs=["api", "backend"])
found, store, _ = self.plan(fake)
found, store, _ = self.plan(FakeEffects(claude=[parts]))
assert not isinstance(found, Failure | Limited), found
self.assertEqual([(each.summary, each.labels) for each in store.issues if each.parent == "ABC-20"], [("backend: Do ABC-20", ("backend",)), ("web: Do ABC-20", ("repo:web",))])
def test_records_the_teams_label_for_a_repo_the_human_types_by_name_and_names_it(self) -> None:
self.configure_team()
self.issues = [issue("ABC-20")]
fake = FakeEffects(claude=[says({"parts": []}), says({"pick": "unclear", "question": "api or web?"})], inputs=["api", "backend"])
found, _, _ = self.plan(fake)
self.assertEqual(found, [issue("ABC-20", "backend")])
self.assertIn("`api` is none of those labels; the repo api's label is `backend`\n", self.asked.getvalue())
self.assertEqual(next(each for each in store.issues if each.key == "ABC-21").labels, ("backend",))
def test_asks_the_human_for_the_label_of_an_issue_the_rule_leaves_unclear_until_one_is_typed(self) -> None:
self.issues = [issue("ABC-20")]
+9 -6
View File
@@ -51,7 +51,7 @@ class Split_(unittest.TestCase):
return [issue for issue in self.issues() if issue.parent == self.key]
def run_split(self, claude: Claude, by_person: bool = False): # type: ignore[no-untyped-def]
return split(self.store, self.issue(), {}, by_person, RULE, "Swedish", ("/repos/api", "/repos/web"), RUNG, claude, "/rules")
return split(self.store, self.issue(), {}, by_person, RULE, "Swedish", ("/repos/api", "/repos/web"), RUNG, claude, "/rules", None)
def test_files_a_sub_task_per_repo_labelled_for_it_and_marks_the_parent(self) -> None:
done = self.run_split(says(TWO))
@@ -69,8 +69,11 @@ class Split_(unittest.TestCase):
def test_a_template_names_the_repo_where_the_table_does_not(self) -> None:
self.assertEqual(task_summary("api", "bygg stöd", {}, "{label}: {Summary}"), "api: Bygg stöd")
def test_a_template_with_the_summary_as_it_is_leaves_its_first_letter(self) -> None:
self.assertEqual((task_summary("api", "bygg stöd", {"core": "api"}, "{Summary} ({label})"), task_summary("api", "", {}, "{Summary}")), ("Bygg stöd (core)", ""))
def test_a_template_names_the_teams_label_where_the_table_names_the_repo(self) -> None:
self.assertEqual(task_summary("api", "bygg stöd", {"core": "api"}, "{Summary} ({label})"), "Bygg stöd (core)")
def test_a_template_leaves_an_empty_summary_empty(self) -> None:
self.assertEqual(task_summary("api", "", {}, "{Summary}"), "")
def test_without_a_template_the_summary_is_the_repo_in_brackets_and_the_item_summary(self) -> None:
self.assertEqual(task_summary("api", "bygg stöd", {"core": "api"}, None), "[api] bygg stöd")
@@ -82,7 +85,7 @@ class Split_(unittest.TestCase):
def test_a_sub_task_with_the_teams_label_counts_as_its_repos_when_a_failed_run_is_taken_up(self) -> None:
self.store.issues.append(EpicIssue("ABC-90", "Serve it.", "", ("backend",), None, "To Do", False, self.key, by_loop=True))
done = split(self.store, self.issue(), {"backend": "api"}, False, RULE, "Swedish", (), RUNG, says(TWO), "/rules")
done = split(self.store, self.issue(), {"backend": "api"}, False, RULE, "Swedish", (), RUNG, says(TWO), "/rules", None)
self.assertEqual((done, [task.labels for task in self.tasks()]), (Split(("api", "web"), (self.tasks()[1].key,)), [("backend",), ("repo:web",)]))
def test_comments_on_a_persons_issue_for_the_team_once_its_sub_tasks_are_filed(self) -> None:
@@ -168,7 +171,7 @@ class Split_(unittest.TestCase):
assert isinstance(key, str)
bare = next(issue for issue in self.issues() if issue.key == key)
claude = says(TWO)
split(self.store, bare, {}, False, RULE, "Swedish", (), RUNG, claude, "/rules")
split(self.store, bare, {}, False, RULE, "Swedish", (), RUNG, claude, "/rules", None)
prompt = claude.calls[0][2]
self.assertIn("checked out at: none. Read them", prompt)
self.assertTrue(prompt.endswith("\nLabels: none\n\n(no description)\n"))
@@ -178,7 +181,7 @@ class Split_(unittest.TestCase):
key = self.store.file("ABC-12", "Two labels.", "Why.", ("api", "urgent"))
assert isinstance(key, str)
claude = says(TWO)
split(self.store, next(issue for issue in self.issues() if issue.key == key), {}, False, RULE, "Swedish", (), RUNG, claude, "/rules")
split(self.store, next(issue for issue in self.issues() if issue.key == key), {}, False, RULE, "Swedish", (), RUNG, claude, "/rules", None)
self.assertIn("\nLabels: api, urgent\n", claude.calls[0][2])
def test_asks_a_persons_issue_for_a_comment(self) -> None: