diff --git a/CHANGELOG.md b/CHANGELOG.md index 038438fb..9379d07a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,7 @@ ## Unreleased +- do-epic records a repo pick, and the summary of each sub-task it files, in the team's own spelling: a label from the `[label-repos]` table of its config, and a `sub-task-summary` template with `{label}` and `{Summary}`. - Add `do-epic --dry-run`, which prints every Jira write planning would make and each chunk that would start, and makes none of them. - The stability reviewer checks each parser that splits text on a separator or strips a suffix against a value that holds the separator, and reports a row the parse misplaces or drops. diff --git a/README.md b/README.md index 5a3150ec..a132ce19 100644 --- a/README.md +++ b/README.md @@ -158,8 +158,9 @@ The last line prints each setting's path once the config is complete. - `config.toml` fits do-epic to a team whose own automation moves issues, such as a CI job that moves an issue when its pull request merges. Two settings do: - `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, and `--status` names the statuses beside each blocker. A status Jira counts as done always does both. The release reviews, which are the epic's last chunk, still wait until Jira counts every issue done: run `do-epic ` then, to start them. - `jira-automation-moves-issues = true` keeps do-epic from moving the issue of a finished chunk in a repo: the automation moves it, and do-epic waits for that move before it starts what the issue blocks. An issue without a repo has no pull request, so do-epic still moves it, with `jira-finish-transition`. The setting needs `jira-unblocking-statuses`, which names the status the automation gives an issue whose pull request merged. -- `config.toml` may end with a `[label-repos]` table, for a team that already labels its issues by repo. Give it one line for each such label: the label, then the repo's name, such as `twu-4 = "tenant-web-ui-4"`. do-epic reads such a label as it reads its own `repo:`. Where the label is the repo's name, map the name to itself, as in `core-4 = "core-4"`. Write every other setting above the table. -- `repo-rule.md` is prose that says how to tell an item's repo, such as "a label that equals a repo's name names that repo". It may not be blank. `do-epic ` uses it to pick where each open issue without such a label is worked, and records the pick as a label: `repo:` for its repo, `do-epic-claude` for work of Claude's that changes no repo, and `do-epic-human` for a task of yours. Where the rule leaves an issue unclear, do-epic asks you on the terminal. Answer with the label, or with Enter alone to leave the issue waiting. Change a pick by editing the label in Jira. +- `config.toml` may set `sub-task-summary`, which shapes the summary of each sub-task do-epic files for an issue that changes several repos, such as `sub-task-summary = "{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}`. Without it a summary is `[] `. +- `config.toml` may end with a `[label-repos]` table, for a team that already labels its issues by repo. Give it one line for each such label: the label, then the repo's name, such as `twu-4 = "tenant-web-ui-4"`. do-epic reads such a label as it reads its own `repo:`. Where the label is the repo's name, map the name to itself, as in `core-4 = "core-4"`. Where several lines name one repo, do-epic writes the label of the first. Write every other setting above the table. +- `repo-rule.md` is prose that says how to tell an item's repo, such as "a label that equals a repo's name names that repo". It may not be blank. `do-epic ` uses it to pick where each open issue without such a label is worked, and records the pick as a label. For a repo that is the team's own label from `[label-repos]`, else `repo:`; for work of Claude's that changes no repo, `do-epic-claude`; for a task of yours, `do-epic-human`. Where the rule leaves an issue unclear, do-epic asks you on the terminal. Answer with the label, or with Enter alone to leave the issue waiting. Change a pick by editing the label in Jira. An epic's description states the formula that ranks the issues do-epic files in it: once under `## Scoring`, on a line of its own and inside backticks, such as `` `Score = 100 * V / (2**S + 32)` ``. Without that line do-epic says so and leaves the backlog's order as it is. diff --git a/bin/do_epic/config.py b/bin/do_epic/config.py index e1f5f64d..a53ec91e 100644 --- a/bin/do_epic/config.py +++ b/bin/do_epic/config.py @@ -19,11 +19,13 @@ 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:`. 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 `[] `. +- `[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:`. 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 import re +import string import types from project_config.settings import anywhere, CONFIG, DO_EPIC, ENV_FILE, Finish, finish_faults, finish_of, JIRA_FINISH, LANGUAGE, language_fault, lies_in, name_of, parsed, PROJECTS, SITE @@ -45,7 +47,8 @@ LABEL_REPOS = "label-repos" # Three readers, seated as those who write and read this config, picked `jira-unblocking-statuses` from four candidates, 3-0, and `jira-automation-moves-issues` 2-1. `jira-unblock-statuses` reads as statuses do-epic moves an issue to, and `jira-finish-issues = false` as closing no epic either. UNBLOCKING_STATUSES = "jira-unblocking-statuses" AUTOMATION_MOVES = "jira-automation-moves-issues" -OPTIONAL = (CLONE_FOLDER, LANGUAGE, *JIRA_FINISH, UNBLOCKING_STATUSES, AUTOMATION_MOVES, LABEL_REPOS) +SUB_TASK_SUMMARY = "sub-task-summary" +OPTIONAL = (CLONE_FOLDER, LANGUAGE, *JIRA_FINISH, UNBLOCKING_STATUSES, AUTOMATION_MOVES, LABEL_REPOS, SUB_TASK_SUMMARY) LISTED = f"The settings are {', '.join(SETTINGS)}, and optionally {listed(OPTIONAL, 'and')}." @@ -66,6 +69,8 @@ class DoEpicConfig: # The UNBLOCKING_STATUSES list; empty where the config has none. unblocking: tuple[str, ...] = () automation_moves: bool = False + # The SUB_TASK_SUMMARY template; None where the config has none. + sub_task_summary: str | None = None def label_repo_faults(table: object) -> list[str]: @@ -80,6 +85,23 @@ 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, that Python can't read as a template, 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 = [(name, spec, conversion) for _, name, spec, conversion in string.Formatter().parse(template) if name is not None] + except ValueError as failure: + return [f"`{SUB_TASK_SUMMARY}` is {template!r}, which Python can't read as a template ({failure}); write a brace that is plain text as {{{{ or }}}}"] + names = [name for name, _, _ in fields] + return [ + *(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 []), + ] + + def workflow_faults(values: dict[str, object]) -> list[str]: """What is wrong with the UNBLOCKING_STATUSES list and the AUTOMATION_MOVES switch in values.""" statuses, moves = values.get(UNBLOCKING_STATUSES, ["Done"]), values.get(AUTOMATION_MOVES, False) @@ -122,6 +144,7 @@ def load(home: pathlib.Path, ladder_file: pathlib.Path = SHIPPED) -> DoEpicConfi *([f"`{REPOLESS_MODEL}` is {model!r}, not a model on the routing ladder: {', '.join(models)}"] if REPOLESS_MODEL in values and model not in models else []), *finish_faults(values), *workflow_faults(values), + *(summary_template_faults(values[SUB_TASK_SUMMARY]) if SUB_TASK_SUMMARY in values else []), *label_repo_faults(values.get(LABEL_REPOS, {})), *([rule.reason] if isinstance(rule, Failure) else [f"`{REPO_RULE}` is blank"] if not rule.strip() else []), ] @@ -133,4 +156,6 @@ def load(home: pathlib.Path, ladder_file: pathlib.Path = SHIPPED) -> DoEpicConfi assert isinstance(labels, dict) statuses = values.get(UNBLOCKING_STATUSES, []) assert isinstance(statuses, list) - return DoEpicConfig(folder, url, env_file, clone_folder, language, model, rule, finish_of(values), types.MappingProxyType(labels), tuple(statuses), values.get(AUTOMATION_MOVES) is True) + template = values.get(SUB_TASK_SUMMARY) + assert template is None or isinstance(template, str) + return DoEpicConfig(folder, url, env_file, clone_folder, language, model, rule, finish_of(values), types.MappingProxyType(labels), tuple(statuses), values.get(AUTOMATION_MOVES) is True, template) diff --git a/bin/do_epic/planning.py b/bin/do_epic/planning.py index 33b23d3e..6384459c 100644 --- a/bin/do_epic/planning.py +++ b/bin/do_epic/planning.py @@ -88,7 +88,7 @@ def placed(epic: Planned, issues: list[EpicIssue], unplaced: list[EpicIssue], ad checkouts = tuple(str(place.checkout) for place in places.values()) for issue in unplaced: say(f"planning {issue.key}", epic.effects, stdout=True) - parts = split.split(epic.store, issue, epic.config.label_repos, not issue.by_loop, epic.config.repo_rule, language or epic.config.language, checkouts, rung, epic.effects.claude, str(folder)) + parts = split.split(epic.store, issue, epic.config.label_repos, not issue.by_loop, epic.config.repo_rule, language or epic.config.language, checkouts, rung, epic.effects.claude, str(folder), epic.config.sub_task_summary) if isinstance(parts, split.Split) and parts.repos: added[issue.key] = split.SPLIT_LABEL say(f"{issue.key} is split into a sub-task for each of {', '.join(parts.repos)}", epic.effects, stdout=True) @@ -101,7 +101,7 @@ def placed(epic: Planned, issues: list[EpicIssue], unplaced: list[EpicIssue], ad if isinstance(pick, Failure): say(f"{issue.key} is not planned: {pick.reason}", epic.effects, stdout=True) elif pick is not None and not isinstance(pick, repo_pick.Unclear): - added[issue.key] = repo_pick.label_of(pick) + added[issue.key] = repo_pick.label_of(pick, epic.config.label_repos) say(f"{issue.key} is labelled {added[issue.key]}", epic.effects, stdout=True) return None @@ -133,8 +133,8 @@ def answered(epic: Planned, issue: EpicIssue, question: str) -> repo_pick.Pick | return None pick = repo_pick.of_label(label, epic.config.label_repos) if pick is not None: - return repo_pick.record(epic.store, issue, pick) - named = f"; the repo {label}'s label is `{repo_pick.REPO_PREFIX}{label}`" if repo_pick.of_label(repo_pick.REPO_PREFIX + label, {}) else "" + return repo_pick.record(epic.store, issue, pick, epic.config.label_repos) + named = f"; the repo {label}'s label is `{repo_pick.label_of(repo_pick.Repo(label), epic.config.label_repos)}`" if repo_pick.of_label(repo_pick.REPO_PREFIX + label, {}) else "" say(f"`{label}` is none of those labels{named}", epic.effects) diff --git a/bin/do_epic/repo_pick.py b/bin/do_epic/repo_pick.py index 9b0aa3b9..ad2c1ae9 100644 --- a/bin/do_epic/repo_pick.py +++ b/bin/do_epic/repo_pick.py @@ -61,8 +61,16 @@ class Unclear: Pick = Repo | ClaudeWork | HumanTask -def label_of(pick: Pick) -> str: - return f"{REPO_PREFIX}{pick.name}" if isinstance(pick, Repo) else CLAUDE_LABEL if isinstance(pick, ClaudeWork) else HUMAN_LABEL +def team_label(repo: str, team: LabelRepos) -> str | None: + """The label on the table's first line that maps to the repo; None where no line does.""" + return next((label for label, name in team.items() if name == repo), None) + + +def label_of(pick: Pick, team: LabelRepos) -> str: + """The label that records the pick: for a repo the team's own, and `repo:` only where the team's table doesn't name it.""" + if isinstance(pick, Repo): + return team_label(pick.name, team) or f"{REPO_PREFIX}{pick.name}" + return CLAUDE_LABEL if isinstance(pick, ClaudeWork) else HUMAN_LABEL def recorded(issue: EpicIssue, team: LabelRepos) -> Pick | None | Failure: @@ -100,12 +108,12 @@ def picked(store: EpicStore, issue: EpicIssue, team: LabelRepos, rule: str, rung answer = answer_of(structured_output(reply)) if isinstance(answer, Failure | Unclear): return answer - return record(store, issue, answer) + return record(store, issue, answer, team) -def record(store: EpicStore, issue: EpicIssue, pick: Pick) -> Pick | Failure: +def record(store: EpicStore, issue: EpicIssue, pick: Pick, team: LabelRepos) -> Pick | Failure: """pick, once the issue is labelled with it.""" - added = store.add_label(issue.key, label_of(pick)) + added = store.add_label(issue.key, label_of(pick, team)) return added if isinstance(added, Failure) else pick diff --git a/bin/do_epic/split.py b/bin/do_epic/split.py index 22d9e2fb..0b969be3 100644 --- a/bin/do_epic/split.py +++ b/bin/do_epic/split.py @@ -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, LabelRepos, of_label, Repo, REPO_NAME +from do_epic.repo_pick import label_of, LabelRepos, of_label, Repo, REPO_NAME, team_label from model_routing.ladder import Rung from claude_code.entries import structured_output @@ -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) -> 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.""" @@ -87,7 +87,7 @@ def split(store: EpicStore, issue: EpicIssue, team: LabelRepos, by_person: bool, for part in predicted.parts: if part.repo in have: continue - key = store.file(issue.key, task_summary(part.repo, issue.summary), part.change, (label_of(Repo(part.repo)),)) + key = store.file(issue.key, task_summary(part.repo, issue.summary, team, summary_template), part.change, (label_of(Repo(part.repo), team),)) 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 do-epic again to file the rest") filed.append(key) @@ -105,9 +105,11 @@ def sub_tasks_filed(keys: list[str]) -> str: return f"this run filed {', '.join(keys)}" if keys else "this run filed no sub-task" -def task_summary(repo: str, summary: str) -> str: - """A sub-task's summary. Three readers, seated as a client's team, picked `[] ` from four candidates, over `: …`, `… ()` and `… — part`, 3-0.""" - return f"[{repo}] {summary}" +def task_summary(repo: str, summary: str, team: LabelRepos, template: str | None) -> str: + """A sub-task's summary from the team's template, where it has one. Without one, `[] `: three readers, seated as a client's team, picked that from four candidates, over `: …`, `… ()` and `… — 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:]) def finished(issues: list[EpicIssue], key: str) -> bool: diff --git a/bin/do_epic/test_do_epic.py b/bin/do_epic/test_do_epic.py index fbefa73f..4aa33c64 100644 --- a/bin/do_epic/test_do_epic.py +++ b/bin/do_epic/test_do_epic.py @@ -60,6 +60,41 @@ class ConfigTest(unittest.TestCase): self.assertIn(fault, reason) self.assertEqual(reason.count("`label-repos` maps"), 7) + def test_reads_a_template_for_a_sub_tasks_summary(self) -> None: + self.write(SETTINGS + 'sub-task-summary = "{label}: {Summary}"\n') + found = load(self.home) + assert isinstance(found, DoEpicConfig), found + self.assertEqual(found.sub_task_summary, "{label}: {Summary}") + + def test_leaves_a_sub_tasks_summary_to_its_default_where_the_config_has_no_template(self) -> None: + self.write() + found = load(self.home) + assert isinstance(found, DoEpicConfig), found + 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 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}"), + ('sub-task-summary = "{label}: {Summary} {repo}"', "names {repo}, and only {label} and {Summary} are known"), + ('sub-task-summary = "{Summary:>9}"', "writes {Summary:>9} with something after the name; write {Summary} alone"), + ('sub-task-summary = "{Summary} {label!r}"', "writes {label!r} with something after the name; write {label} alone"), + ('sub-task-summary = "{Summary!}"', "`sub-task-summary` is '{Summary!}', which Python can't read as a template ("), + ('sub-task-summary = "{Summary"', "`sub-task-summary` is '{Summary', which Python can't read as a template ("), + ): + 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()) diff --git a/bin/do_epic/test_planning.py b/bin/do_epic/test_planning.py index f6c5eb00..24f32b77 100644 --- a/bin/do_epic/test_planning.py +++ b/bin/do_epic/test_planning.py @@ -168,7 +168,28 @@ class Planning(DoEpicTest): self.issues = [issue("ABC-20")] fake = FakeEffects(claude=[says({"parts": []}), says({"pick": "unclear", "question": "Is the importer in api or in web?"})], inputs=["backend"]) found, _, _ = self.plan(fake) - self.assertEqual((found, fake.made("input")), ([issue("ABC-20", "repo:api")], ["The label that says where ABC-20 is worked, `repo:`, `do-epic-claude` or `do-epic-human` (or the team's `backend`), or Enter alone to leave it waiting: "])) + self.assertEqual((found, fake.made("input")), ([issue("ABC-20", "backend")], ["The label that says where ABC-20 is worked, `repo:`, `do-epic-claude` or `do-epic-human` (or the team's `backend`), or Enter alone to leave it waiting: "])) + + 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."}) + 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("the repo api's label is `backend`", self.asked.getvalue()) 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")] diff --git a/bin/do_epic/test_repo_pick.py b/bin/do_epic/test_repo_pick.py index 8951426a..a34beadd 100644 --- a/bin/do_epic/test_repo_pick.py +++ b/bin/do_epic/test_repo_pick.py @@ -6,7 +6,7 @@ import unittest sys.path.insert(0, str(pathlib.Path(__file__).resolve().parents[1])) -from do_epic.repo_pick import also, CLAUDE_LABEL, ClaudeWork, HUMAN_LABEL, HumanTask, label_of, PICK_SCHEMA, picked, recorded, Repo, REPO_PREFIX, Unclear +from do_epic.repo_pick import also, CLAUDE_LABEL, ClaudeWork, HUMAN_LABEL, HumanTask, label_of, PICK_SCHEMA, picked, record, recorded, Repo, REPO_PREFIX, Unclear from do_epic.backend.protocol import EpicIssue from failure import Failure from claude_code.reply import Limited @@ -137,7 +137,7 @@ class RepoPick(unittest.TestCase): def test_the_label_of_a_pick_reads_back_as_that_pick(self) -> None: for pick in (Repo("payments-api"), ClaudeWork(), HumanTask()): with self.subTest(pick=pick): - self.assertEqual(recorded(EpicIssue(self.key, "s", "", (label_of(pick),), None, "To Do", False, "ABC-12"), {}), pick) + self.assertEqual(recorded(EpicIssue(self.key, "s", "", (label_of(pick, {}),), None, "To Do", False, "ABC-12"), {}), pick) def test_a_label_the_teams_table_maps_records_its_repo_without_asking_claude(self) -> None: self.store.add_label(self.key, "twu-4") @@ -159,6 +159,23 @@ class RepoPick(unittest.TestCase): self.store.add_label(self.key, "repo:core-4") self.assertEqual(recorded(self.issue(), TEAM), Failure(f"{self.key} is labelled with 2 picks: core-4, repo:core-4, twu-4; remove the labels of all but the right one")) + def test_a_repo_the_teams_table_names_is_recorded_as_the_teams_label_and_any_other_as_repo_name(self) -> None: + for pick, label in ((Repo("tenant-web-ui-4"), "twu-4"), (Repo("core-4"), "core-4"), (Repo("api-3"), "repo:api-3"), (ClaudeWork(), CLAUDE_LABEL), (HumanTask(), HUMAN_LABEL)): + with self.subTest(pick=pick): + self.assertEqual(label_of(pick, TEAM), label) + + def test_the_first_line_of_the_table_stands_for_a_repo_it_names_twice(self) -> None: + self.assertEqual(label_of(Repo("core-4"), {"zeta": "core-4", "core-4": "core-4"}), "zeta") + + def test_a_pick_by_claude_is_labelled_with_the_teams_label_and_no_repo_label(self) -> None: + picked(self.store, self.issue(), TEAM, RULE, RUNG, says({"pick": "repo", "repo": "tenant-web-ui-4"}), "/rules") + self.assertEqual(self.issue().labels, ("api", "twu-4")) + + def test_a_recorded_answer_is_labelled_the_same_way(self) -> None: + self.assertEqual((record(self.store, self.issue(), Repo("core-4"), TEAM), self.issue().labels), (Repo("core-4"), ("api", "core-4"))) + self.assertEqual(record(self.store, self.issue(), Repo("api-3"), TEAM), Repo("api-3")) + self.assertEqual(self.issue().labels, ("api", "core-4", "repo:api-3")) + def test_a_label_with_the_prefix_alone_is_no_pick(self) -> None: self.store.add_label(self.key, "repo:") self.assertIsNone(recorded(self.issue(), {})) diff --git a/bin/do_epic/test_split.py b/bin/do_epic/test_split.py index dda5e0ff..f1c24599 100644 --- a/bin/do_epic/test_split.py +++ b/bin/do_epic/test_split.py @@ -9,7 +9,7 @@ sys.path.insert(0, str(pathlib.Path(__file__).resolve().parents[1])) from do_epic.test_repo_pick import Claude, says from do_epic.backend.protocol import EpicIssue from failure import Failure -from do_epic.split import finished, is_split, Split, split, SPLIT_LABEL, SPLIT_SCHEMA +from do_epic.split import finished, is_split, Split, split, SPLIT_LABEL, SPLIT_SCHEMA, task_summary from claude_code.reply import Limited from do_epic.backend.fake import MemoryEpic from model_routing.ladder import Rung @@ -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)) @@ -61,6 +61,23 @@ class Split_(unittest.TestCase): self.assertEqual(self.issue().labels, ("api", SPLIT_LABEL)) self.assertEqual(self.store.comments, {}) + def test_files_each_sub_task_as_the_teams_template_and_label_say(self) -> None: + team = {"twu-4": "web", "core-4": "api"} + done = split(self.store, self.issue(), team, False, RULE, "Swedish", (), RUNG, says(TWO), "/rules", "{label}: {Summary}") + self.assertEqual((done, [(task.summary, task.labels) for task in self.tasks()]), (Split(("api", "web"), tuple(task.key for task in self.tasks())), [("core-4: Count the runs.", ("core-4",)), ("twu-4: Count the runs.", ("twu-4",))])) + + 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_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") + def test_an_item_a_person_filed_a_sub_task_under_is_left_alone_without_asking_claude(self) -> None: self.store.issues.append(EpicIssue("ABC-90", "twu-4: Count them.", "", ("twu-4",), None, "To Do", False, self.key)) claude = says(TWO) @@ -68,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: @@ -154,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")) @@ -164,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: diff --git a/todo.md b/todo.md index 246ca5ef..0c801b01 100644 --- a/todo.md +++ b/todo.md @@ -6,16 +6,16 @@ `Bar = 0.1` -`Next ID = 468` +`Next ID = 469` ## Items | ID | Release | Blocked by | Exempt | Item | L | E | I | R | S | Moves | Score | |---|---|---|---|---|---|---|---|---|---|---|---| -| 449 | 0.15.0 | | | **Record do-epic's repo picks and sub-task summaries in the team's own spelling, such as `core-4` and `core-4: Bygg …`, as its config sets them.** | 2 | 2 | 2 | 4 | 3 | 1.6 by 6 | 2.0 | | 453 | 0.15.0 | | | **Make the issue types that do-epic and `todo-item add` file in Jira settings, since a Jira project such as TW has no Task type.** | 2 | 2 | 1 | 3 | 2 | 1.6 by 5 | 1.8 | | 454 | 0.15.0 | | | **Start a do-epic chunk's issue as the team's board expects, by settings: assigned to the account do-epic works as, moved by a start transition and added to a board's active sprint.** | 3 | 2 | 2 | 5 | 4 | 1.6 by 4 | 1.1 | -| 467 | 0.15.0 | 449, 453, 454 | question | **Cut 0.15.0 as soon as items 449, 450, 453 and 454 have merged, before its release review, and run that review in 0.15.1.** | 1 | 1 | 1 | 1 | 1 | | 0.0 | +| 467 | 0.15.0 | 453, 454 | question | **Cut 0.15.0 as soon as items 449, 450, 453 and 454 have merged, before its release review, and run that review in 0.15.1.** | 1 | 1 | 1 | 1 | 1 | | 0.0 | +| 468 | 0.15.0 | | | **Tell a do-epic worker the team's own label for each repo when it files a finding or a release-review issue, so those issues carry the label the team's board uses.** | 2 | 2 | 2 | 4 | 2 | 1.6 by 4 | 1.4 | | 446 | 0.16.0 | | question | **Kill the process a stuck check names where its verdict is `stuck`, once the human says the recorded verdicts match what they would have done.** | 2 | 2 | 3 | 5 | 3 | 1.5 by 3 | 1.0 | | 462 | 0.16.0 | | | **Run under `mutate-changes` the tests that today fail in mutmut's copy of the tree, so a mutant of a line only they cover is killed.** | 2 | 1 | 2 | 3 | 3 | code health by 3 | 4.7 | | 77 | 0.16.0 | | | **Teach `bin/metric-bench` Go and TypeScript, rerun it once two projects' comprehension histories name places, and bring into review only a metric that tracks the panel.** | 4 | 2 | 1 | 5 | 6 | 1.1 by 7, 1.4 by 7 | 2.1 | @@ -75,24 +75,6 @@ ## Details -### 449. Record do-epic's repo picks and sub-task summaries in the team's own spelling, such as `core-4` and `core-4: Bygg …`, as its config sets them. - -do-epic writes its own spelling into a team's Jira: a pick as `repo:core-4` and a sub-task's summary as `[core-4] `. A team with its own convention, such as TW's label `core-4` and summary `core-4: Bygg …` with a capital after the colon, then finds two labels on each issue and summaries in a shape its board doesn't use. Goal 1.6 asks the loop to fit the tracker's conventions, not change them. - -- do-epic records a repo pick as the team's label for that repo, from the label table item 448 adds, and as `repo:` only for a repo the table doesn't name. -- A summary template in do-epic's config.toml shapes each sub-task's summary, such as `sub-task-summary = "{label}: {Summary}"`, where `{Summary}` is the item's summary with a capital first letter. Without the setting, the summary stays `[] `. -- `do-epic-claude` and `do-epic-human` stay as they are: no team label means either. - -Touches: - -- `bin/do_epic/repo_pick.py`: `label_of`, `record` -- `bin/do_epic/split.py`: `task_summary`, `split` (small) -- `bin/do_epic/planning.py`: `placed` (small), `answered` (small) -- `bin/do_epic/config.py`: `DoEpicConfig`, `load` (small) -- `bin/do_epic/test_repo_pick.py` -- `bin/do_epic/test_split.py` -- `README.md`: `### Set up a project` (small) - ### 453. Make the issue types that do-epic and `todo-item add` file in Jira settings, since a Jira project such as TW has no Task type. do-epic and `todo-item add` file every new issue as a Task, the name `plan_store/jira_epic.py` sets as `ISSUE_TYPE`. A Jira project without a Task type, such as TW, whose types are Feature, Bug, Chore and Investigation, refuses each one. So `do-epic --file` fails there, and so does the epic's finishing, which files a release review for each repo. @@ -138,6 +120,18 @@ Touches: - `CHANGELOG.md`: `## Unreleased` (small) +### 468. Tell a do-epic worker the team's own label for each repo when it files a finding or a release-review issue, so those issues carry the label the team's board uses. + +Item 449 makes do-epic record a repo pick, and each sub-task it files, under the team's own label from the `[label-repos]` table (`repo_pick.label_of(pick, team)`). The instructions do-epic gives a chunk's worker still name only `repo:`: `LABELS` in `bin/do_epic/findings.py` (used in `HELP` at findings.py:31, in `instructions` at :48, and in `written`'s refusal at :99 and its reply at :105) and the `--file ... --label repo: --label do-epic-release-review` command in `finish.task` at `bin/do_epic/finish.py:60`. A team whose board uses its own labels therefore still gets a finding or a release review labelled `repo:core-4` where it expects `core-4`. + +Give both prompts the team's label for each repo of the table where the table names it (`repo_pick.team_label`, `also`), and keep `repo:` for a repo the table doesn't name. `finish.task` already knows each repo that lacks its review, so it can name each one's label outright, as `label_of(Repo(name), team)` gives it. The README states the pick's spelling (`repo-rule.md`'s bullet) but not the finding's, so it needs no change. + +Touches: +- `bin/do_epic/findings.py`: `LABELS`, `instructions` (small), `written` (small) +- `bin/do_epic/finish.py`: `task` (small) +- `bin/do_epic/test_findings.py`: `Instructions` +- `bin/do_epic/test_finish.py`: `TheFinishingChunksTask` + ### 446. Kill the process a stuck check names where its verdict is `stuck`, once the human says the recorded verdicts match what they would have done. Item 422 judges a worker that stalls before its result, but only reports: each verdict goes to the terminal and to `stuck-workers.md` in the project's transcript archive. Question for the human: after a few days of verdicts there, do they match what you would have done? Once you say yes, kill only the process a `stuck` verdict names, and only where the pid is below the worker's claude, never the worker or the loop, and record the call in a decision.