Answer product-owner round 1: 0 🔴, 3 🟡 (0 misread); count picks, not labels, and name the team's labels where a label is asked for
This commit is contained in:
@@ -6,7 +6,7 @@ import fcntl
|
||||
import pathlib
|
||||
import typing
|
||||
|
||||
from do_epic.repo_pick import CLAUDE_LABEL, HUMAN_LABEL, LabelRepos, of_label, REPO_PREFIX, REVIEW_LABEL
|
||||
from do_epic.repo_pick import also, CLAUDE_LABEL, HUMAN_LABEL, LabelRepos, of_label, REPO_PREFIX, REVIEW_LABEL
|
||||
from do_epic.epic_record import EpicRecord
|
||||
from do_epic.backend.protocol import EpicStore
|
||||
from failure import Failure
|
||||
@@ -73,7 +73,7 @@ def written(epic: str, flag: str, value: str, labels: tuple[str, ...], store: Ep
|
||||
text = piped(stdin)
|
||||
if flag == FILE:
|
||||
if unread := [label for label in labels if of_label(label, team) is None and label != REVIEW_LABEL]:
|
||||
return Failure(f"cannot file the finding in the epic {epic}: do-epic doesn't read the label {unread[0]!r}; write {LABELS}")
|
||||
return Failure(f"cannot file the finding in the epic {epic}: do-epic doesn't read the label {unread[0]!r}; write {LABELS}{also(team)}")
|
||||
if len(picks := [label for label in labels if of_label(label, team)]) > 1:
|
||||
return Failure(f"cannot file the finding in the epic {epic}: {listed(picks, 'and')} each say who works it; write one of them")
|
||||
key = store.file(epic, value, text, labels)
|
||||
|
||||
@@ -125,7 +125,7 @@ def answered(epic: Planned, issue: EpicIssue, question: str) -> repo_pick.Pick |
|
||||
say(f"\n{issue.key}, {issue.summary}: {question}", epic.effects)
|
||||
while True:
|
||||
try:
|
||||
typed = epic.effects.input(f"The label that says where {issue.key} is worked, `{repo_pick.REPO_PREFIX}<name>`, `{repo_pick.CLAUDE_LABEL}` or `{repo_pick.HUMAN_LABEL}`, or Enter alone to leave it waiting: ")
|
||||
typed = epic.effects.input(f"The label that says where {issue.key} is worked, `{repo_pick.REPO_PREFIX}<name>`, `{repo_pick.CLAUDE_LABEL}` or `{repo_pick.HUMAN_LABEL}`{repo_pick.also(epic.config.label_repos)}, or Enter alone to leave it waiting: ")
|
||||
except EOFError:
|
||||
return None
|
||||
label = typed.strip()
|
||||
|
||||
@@ -21,7 +21,7 @@ REVIEW_LABEL = "do-epic-release-review"
|
||||
# A repo's name is a folder name and part of a clone address, so claude's answer or a label a person typed must not hold a slash, a colon or a leading dot.
|
||||
REPO_NAME = re.compile(r"\w[\w.-]*")
|
||||
|
||||
# A team's own label for a repo, mapped to the repo's name: the `[label-repos]` table of do-epic's config (config.py). Three readers, seated as those who write and read that config, picked `label-repos` from four candidates, over `repo-aliases`, `repo-labels` and `team-labels`, 2-1; each would misread `repo-labels` as mapping a repo to its label.
|
||||
# A team's own label for a repo, mapped to the repo's name: the LABEL_REPOS table of do-epic's config (config.py).
|
||||
LabelRepos = typing.Mapping[str, str]
|
||||
|
||||
PICK_SCHEMA = {
|
||||
@@ -69,10 +69,15 @@ def recorded(issue: EpicIssue, team: LabelRepos) -> Pick | None | Failure:
|
||||
"""The pick the issue's labels record; None where they record no pick, a Failure where they record more than one. Two labels that name one repo, such as the team's and `repo:<name>`, record one pick."""
|
||||
picks = {label: pick for label in issue.labels if (pick := of_label(label, team)) is not None}
|
||||
if len(set(picks.values())) > 1:
|
||||
return Failure(f"{issue.key} is labelled with {len(picks)} picks: {', '.join(picks)}; remove all but the right one")
|
||||
return Failure(f"{issue.key} is labelled with {len(set(picks.values()))} picks: {', '.join(picks)}; remove the labels of all but the right one")
|
||||
return next(iter(picks.values()), None)
|
||||
|
||||
|
||||
def also(team: LabelRepos) -> str:
|
||||
"""The team's own labels, to end a list of do-epic's in a prompt or a refusal; empty where the team has none."""
|
||||
return f" (or the team's {', '.join(f'`{label}`' for label in sorted(team))})" if team else ""
|
||||
|
||||
|
||||
def of_label(label: str, team: LabelRepos) -> Pick | None:
|
||||
"""The pick the label records: one of do-epic's own, or one the team's table maps to a repo."""
|
||||
if label in team:
|
||||
|
||||
@@ -6,7 +6,7 @@ import unittest
|
||||
|
||||
sys.path.insert(0, str(pathlib.Path(__file__).resolve().parents[1]))
|
||||
|
||||
from do_epic.repo_pick import 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, recorded, Repo, REPO_PREFIX, Unclear
|
||||
from do_epic.backend.protocol import EpicIssue
|
||||
from failure import Failure
|
||||
from claude_code.reply import Limited
|
||||
@@ -99,7 +99,7 @@ class RepoPick(unittest.TestCase):
|
||||
self.store.add_label(self.key, "repo:log")
|
||||
self.store.add_label(self.key, HUMAN_LABEL)
|
||||
claude = says({"pick": "claude"})
|
||||
self.assertEqual(self.pick(claude), Failure(f"{self.key} is labelled with 2 picks: do-epic-human, repo:log; remove all but the right one"))
|
||||
self.assertEqual(self.pick(claude), Failure(f"{self.key} is labelled with 2 picks: do-epic-human, repo:log; remove the labels of all but the right one"))
|
||||
self.assertEqual(claude.calls, [])
|
||||
|
||||
def test_an_unclear_pick_returns_the_question_and_records_nothing_until_the_human_answers(self) -> None:
|
||||
@@ -150,10 +150,14 @@ class RepoPick(unittest.TestCase):
|
||||
self.store.add_label(self.key, "repo:tenant-web-ui-4")
|
||||
self.assertEqual(recorded(self.issue(), TEAM), Repo("tenant-web-ui-4"))
|
||||
|
||||
def test_the_teams_labels_end_a_list_of_do_epics_only_where_it_has_some(self) -> None:
|
||||
self.assertEqual((also(TEAM), also({})), (" (or the team's `core-4`, `twu-4`)", ""))
|
||||
|
||||
def test_two_of_the_teams_labels_for_different_repos_fail_and_name_both(self) -> None:
|
||||
self.store.add_label(self.key, "twu-4")
|
||||
self.store.add_label(self.key, "core-4")
|
||||
self.assertEqual(recorded(self.issue(), TEAM), Failure(f"{self.key} is labelled with 2 picks: core-4, twu-4; remove all but the right one"))
|
||||
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_label_with_the_prefix_alone_is_no_pick(self) -> None:
|
||||
self.store.add_label(self.key, "repo:")
|
||||
|
||||
Reference in New Issue
Block a user