Kill the surviving mutants of the repo pick
CI / tests (pull_request) Failing after 3m43s

This commit is contained in:
2026-11-18 14:49:56 +01:00
parent 29568fab6c
commit 42a6b6533f
4 changed files with 24 additions and 6 deletions
+2 -2
View File
@@ -1,7 +1,7 @@
"""An epic held in memory, for do-epic's tests, held to contract.py like every backend."""
import dataclasses
from do_epic.backend.protocol import EpicIssue, no_child, no_parent, unfit
from do_epic.backend.protocol import EpicIssue, no_child, no_parent, unfit, unfit_label
from failure import Failure
@@ -31,7 +31,7 @@ class MemoryEpic:
def add_label(self, key: str, label: str) -> None | Failure:
if self.fails:
return Failure(self.fails)
if refused := unfit("-", (label,)):
if refused := unfit_label(label):
return refused
child = next((issue for issue in self.issues if issue.key == key and issue.parent == self.epic_key), None)
if child is None:
+2 -2
View File
@@ -6,7 +6,7 @@ import typing
from adf_codec.convert import adfs_to_markdown, markdown_to_adf, Refused
from atlassian.client import basic_auth, Http, jira_json, ToAdf, ToMarkdown
from project_config.settings import Epic
from do_epic.backend.protocol import EpicIssue, no_child, no_parent, unfit
from do_epic.backend.protocol import EpicIssue, no_child, no_parent, unfit, unfit_label
from failure import Failure
from plan_store.jira_epic import ISSUE_KEY, ISSUE_TYPE, project_of, searched
@@ -80,7 +80,7 @@ class JiraEpic:
authorization = basic_auth(self.env_file)
if isinstance(authorization, Failure):
return authorization
if refused := unfit("-", (label,)):
if refused := unfit_label(label):
return refused
above = self.parent_of(key, authorization, "to label it")
if isinstance(above, Failure):
+5
View File
@@ -51,6 +51,11 @@ 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")
return unfit_label(*labels)
def unfit_label(*labels: str) -> Failure | None:
"""Why no tracker can take one of these labels; None where one can."""
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")
return None
+15 -2
View File
@@ -8,7 +8,7 @@ sys.path.insert(0, str(pathlib.Path(__file__).resolve().parents[1]))
from do_epic.backend.protocol import EpicIssue
from do_epic.backend.fake import MemoryEpic
from do_epic.repo_pick import CLAUDE_LABEL, ClaudeWork, HUMAN_LABEL, HumanTask, label_of, picked, recorded, Repo, Unclear
from do_epic.repo_pick import CLAUDE_LABEL, PICK_SCHEMA, ClaudeWork, HUMAN_LABEL, HumanTask, label_of, picked, recorded, Repo, Unclear
from claude_code.reply import Limited
from failure import Failure
from model_routing.ladder import Rung
@@ -50,10 +50,21 @@ class RepoPick(unittest.TestCase):
self.assertEqual(self.pick(claude), Repo("payments-api"))
self.assertEqual(self.issue().labels, ("api", "repo:payments-api"))
args, cwd, prompt = claude.calls[0]
self.assertEqual((cwd, args[:1], "--tools" in args, "claude-sonnet-5-5" in args), ("/rules", ["-p"], True, True))
self.assertEqual(cwd, "/rules")
self.assertEqual(args[:9], ["-p", "--json-schema", json.dumps(PICK_SCHEMA), "--model", "claude-sonnet-5-5", "--effort", "medium", "--tools", ""])
self.assertIn(RULE, prompt)
self.assertIn(f"## Item {self.key}: Count the runs.\n\nLabels: api\n\nWhy it counts.", prompt)
def test_tells_claude_an_items_labels_and_that_it_has_no_description(self) -> None:
store = MemoryEpic("ABC-12")
store.file("ABC-12", "Clean up the docs.", "", ())
claude = says({"pick": "claude"})
picked(store, store.read()[0], RULE, RUNG, claude, "/rules") # type: ignore[index]
self.assertIn("Labels: none\n\n(no description)\n", claude.calls[0][2])
self.store.add_label(self.key, "web")
self.pick(claude)
self.assertIn("Labels: api, web\n", claude.calls[1][2])
def test_records_a_pick_without_a_repo_as_claudes_work_or_a_human_task(self) -> None:
for output, pick, label in (({"pick": "claude"}, ClaudeWork(), CLAUDE_LABEL), ({"pick": "human"}, HumanTask(), HUMAN_LABEL)):
with self.subTest(label=label):
@@ -82,6 +93,8 @@ class RepoPick(unittest.TestCase):
self.assertEqual(self.issue().labels, ("api",))
def test_a_reply_that_is_no_pick_fails_and_records_nothing(self) -> None:
reason = self.pick(says({"pick": "repo", "repo": "two words" * 40}))
self.assertEqual(reason, Failure('the repo pick answered ' + json.dumps({"pick": "repo", "repo": "two words" * 40})[:200] + ', which is not a repo with a name without white space, claude, human, or unclear with a question'))
for output in (None, "repo", {"pick": "repo"}, {"pick": "repo", "repo": "two words"}, {"pick": "unclear"}, {"pick": "unclear", "question": " "}, {"pick": "elsewhere"}):
with self.subTest(output=output):
self.assertIsInstance(self.pick(says(output)), Failure)