Record do-epic's repo picks and sub-task summaries in the team's own spelling
CI / tests (pull_request) Failing after 2m33s
CI / tests (pull_request) Failing after 2m33s
This commit is contained in:
@@ -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 <EPIC-KEY>` 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:<name>`. 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 <EPIC-KEY>` uses it to pick where each open issue without such a label is worked, and records the pick as a label: `repo:<name>` 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 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:<name>`. 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. do-epic records a pick of such a repo as the team's label, and as `repo:<name>` only for a repo the table doesn't name.
|
||||
- `sub-task-summary` 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 `[<repo>] <the issue's summary>`.
|
||||
- `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 <EPIC-KEY>` uses it to pick where each open issue without such a label is worked, and records the pick as a label: the team's label for its repo, else `repo:<name>`, `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.
|
||||
|
||||
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.
|
||||
|
||||
|
||||
+27
-2
@@ -20,10 +20,12 @@ One pair per machine, the same for every epic (docs/decisions.md → `do-epic: d
|
||||
- `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>`.
|
||||
- `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,25 @@ 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}`."""
|
||||
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)]
|
||||
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 []),
|
||||
]
|
||||
|
||||
|
||||
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 +146,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 +158,4 @@ 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)
|
||||
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, values.get(SUB_TASK_SUMMARY))
|
||||
|
||||
@@ -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)
|
||||
|
||||
|
||||
|
||||
@@ -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 team's label for the repo: the first by name where the table maps several labels to it, None where it names none."""
|
||||
return min((label for label, name in team.items() if name == repo), default=None)
|
||||
|
||||
|
||||
def label_of(pick: Pick, team: LabelRepos) -> str:
|
||||
"""The label that records the pick: for a repo the team's own, and `repo:<name>` 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
|
||||
|
||||
|
||||
|
||||
@@ -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 = 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 `[<repo>] <the item's summary>` from four candidates, over `<repo>: …`, `… (<repo>)` and `… — <repo> 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: 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."""
|
||||
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:
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import json
|
||||
import pathlib
|
||||
import sys
|
||||
import tempfile
|
||||
@@ -60,6 +61,31 @@ 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 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}"),
|
||||
("{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'"),
|
||||
):
|
||||
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")
|
||||
self.assertIn(fault, self.failure())
|
||||
|
||||
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())
|
||||
|
||||
@@ -168,7 +168,21 @@ 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:<name>`, `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:<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")]
|
||||
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)
|
||||
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",))])
|
||||
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")]
|
||||
|
||||
@@ -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_label_by_name_stands_for_a_repo_the_table_names_twice(self) -> None:
|
||||
self.assertEqual(label_of(Repo("core-4"), {"core": "core-4", "core-4": "core-4"}), "core")
|
||||
|
||||
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(), {}))
|
||||
|
||||
@@ -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
|
||||
@@ -61,6 +61,20 @@ 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_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_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)
|
||||
|
||||
Reference in New Issue
Block a user