Name the team's label for each repo in do-epic's finding and release-review prompts

This commit is contained in:
Lilleman
2026-11-20 11:18:07 +01:00
parent 88fee92dcb
commit 9f09912a02
4 changed files with 34 additions and 11 deletions
+14 -7
View File
@@ -7,7 +7,7 @@ import fcntl
import pathlib
import typing
from do_epic.repo_pick import also, CLAUDE_LABEL, HUMAN_LABEL, LabelRepos, of_label, REPO_PREFIX, REVIEW_LABEL
from do_epic.repo_pick import CLAUDE_LABEL, HUMAN_LABEL, LabelRepos, of_label, REPO_PREFIX, REVIEW_LABEL, team_label
from do_epic.backend.protocol import EpicIssue, EpicStore
from do_epic.epic_record import EpicRecord
from failure import Failure
@@ -20,15 +20,22 @@ LABEL = "--label"
BLOCKED_BY = "--blocked-by"
PARENT = "--parent"
RECORD_DECISION = "--record-decision"
# The labels that say where an issue is worked, as do-epic's scheduler reads them.
LABELS = f"`{REPO_PREFIX}<name>` for the repo that works it, `{CLAUDE_LABEL}` for work of Claude's that changes no repo, or `{HUMAN_LABEL}` for a task of the human's"
def worked_by(team: LabelRepos) -> str:
"""The labels that say where an issue is worked, as do-epic's scheduler reads them. Each repo the team's table names takes the team's label, and `repo:<name>` stays for any other."""
named = [f"`{label}` for the repo {name}" for name in dict.fromkeys(team.values()) if (label := team_label(name, team))]
repos = ", ".join([*named, f"`{REPO_PREFIX}<name>` for {'any other repo' if named else 'the repo'} that works it"])
return f"{repos}, `{CLAUDE_LABEL}` for work of Claude's that changes no repo, or `{HUMAN_LABEL}` for a task of the human's"
# Under the epic's folder, the file a do-epic holds locked while it appends a decision.
DECISIONS_LOCK = "decisions.lock"
USAGE = f"""do-epic <EPIC-KEY> {FILE} <summary> [{LABEL} <label>]... [{BLOCKED_BY} <KEY>] [{PARENT} <KEY>] [<<'EOF' detail EOF]
do-epic <EPIC-KEY> {RECORD_DECISION} <title> <<'EOF' entry EOF"""
HELP = f"""{FILE} files a finding about one of the epic's goals as an open issue of the epic, with the markdown piped in as its description.
A finding about a repo's own goals goes into that repo's plan instead.
{LABEL} is {LABELS}; without one, the next `do-epic <EPIC-KEY>` you run picks where the issue is worked.
{LABEL} is {worked_by({})}; without one, the next `do-epic <EPIC-KEY>` you run picks where the issue is worked.
A second {LABEL}, `{REVIEW_LABEL}`, marks the issue as a repo's release review, which the epic's finishing files.
{BLOCKED_BY} <KEY> makes the new issue wait for the issue <KEY>, which is a child issue of the epic or a sub-task of one.
{PARENT} <KEY> files the new issue as a sub-task of the child issue <KEY>.
@@ -45,7 +52,7 @@ def instructions(epic: str, launcher: pathlib.Path, language: str, team: LabelRe
next_step = f"Where the repo's rules ask for a change to ship as more than one pull request, finish only this issue's pull request, and file only the next one as an issue that waits for it, with `{launcher} {epic} {FILE} \"<summary>\" {BLOCKED_BY} {issue.key}{parent}{label}` and its detail on stdin. "
return (
f"File a finding about one of the epic's goals in the epic, with `{launcher} {epic} {FILE} \"<summary>\" {LABEL} <label>` and its detail on stdin. "
f"The label is {LABELS}; leave it out where you cannot tell, and the next `do-epic` the human runs picks it. "
f"The label is {worked_by(team)}; leave it out where you cannot tell, and the next `do-epic` the human runs picks it. "
"Where filing fails and says the issue may exist, ask the human to look before you file it again. "
"File a finding about a repo's goals by that repo's rules. Where unsure which, ask the human. "
f"Record a decision that governs the epic, such as an answer the human typed, with `{launcher} {epic} {RECORD_DECISION} \"<title>\"` and its text on stdin. "
@@ -96,13 +103,13 @@ def written(epic: str, write: Write, store: EpicStore, team: LabelRepos, record:
flag, value, labels = write.flag, write.value, write.labels
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}{also(team)}")
return Failure(f"cannot file the finding in the epic {epic}: do-epic doesn't read the label {unread[0]!r}; write {worked_by(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(write.parent or epic, value, text, labels, write.blocked_by)
if isinstance(key, Failure):
return Failure(f"cannot file the finding in the epic {epic}: {key.reason}")
return f"Filed {key} {f'under {write.parent} in ' if write.parent else 'in '}the epic {epic}." + (f" It is blocked by {write.blocked_by}." if write.blocked_by else "") + ("" if any(of_label(label, team) for label in labels) else f" It has no label that says where it is worked, so the next `do-epic {epic}` picks one: {LABELS}.")
return f"Filed {key} {f'under {write.parent} in ' if write.parent else 'in '}the epic {epic}." + (f" It is blocked by {write.blocked_by}." if write.blocked_by else "") + ("" if any(of_label(label, team) for label in labels) else f" It has no label that says where it is worked, so the next `do-epic {epic}` picks one: {worked_by(team)}.")
try:
with decisions_locked(folder):
added = record.append_decision(value, text)
+3 -2
View File
@@ -15,7 +15,7 @@ from do_epic.backend.protocol import EpicIssue, EpicStore
from failure import Failure
from do_epic import findings
from do_epic.split import finished
from do_epic.repo_pick import LabelRepos, recorded, Repo, REPO_PREFIX, REVIEW_LABEL
from do_epic.repo_pick import label_of, LabelRepos, recorded, Repo, REVIEW_LABEL
from text_files.markdown_text import listed
from text_files.piped_text import piped
@@ -57,7 +57,8 @@ def task(epic: str, issues: list[EpicIssue], team: LabelRepos, launcher: pathlib
if lacking := unreviewed(issues, team):
return (
f"{opening} Each repo the epic changed takes a release review first, and {listed(lacking, 'and')} {'has' if len(lacking) == 1 else 'have'} none. "
f"File one issue per such repo, with `{launcher} {epic} {findings.FILE} \"<summary>\" {findings.LABEL} {REPO_PREFIX}<name> {findings.LABEL} {REVIEW_LABEL}` and its detail on stdin, both in {language}, the epic's language. "
f"File one issue per such repo, with `{launcher} {epic} {findings.FILE} \"<summary>\" {findings.LABEL} <label> {findings.LABEL} {REVIEW_LABEL}` and its detail on stdin, both in {language}, the epic's language. "
f"The `<label>` is {listed([f'`{label_of(Repo(name), team)}` for {name}' for name in lacking], 'and')}. "
f"The detail asks for a release review of the whole repo, as the epic's issues left it: the one `~/.claude/skills/larv-review/SKILL.md` → \"Release review\" describes. The epic's key stands in place of the release there, so the review's branch opens with an empty commit titled `Release review of {epic}`. "
"Where filing fails and says the issue may exist, ask the human to look before you file it again. "
f"The chunk is finished once each issue is filed: {DRIVER} works them, and starts this chunk again once the epic holds no open issue."
+9 -1
View File
@@ -93,7 +93,9 @@ class FilingAFinding(FindingsTest):
code, _, err, _ = self.run_with(["ABC-12", "--file", "Retry", "--label", "twu-4", "--label", "repo:api"])
self.assertEqual((code, err), (1, "cannot file the finding in the epic ABC-12: twu-4 and repo:api each say who works it; write one of them\n"))
_, _, err, _ = self.run_with(["ABC-12", "--file", "Retry", "--label", "twu"])
self.assertTrue(err.endswith("or `do-epic-human` for a task of the human's (or the team's `twu-4`)\n"), err)
self.assertTrue(err.endswith("write `twu-4` for the repo tenant-web-ui-4, `repo:<name>` for any other repo that works it, `do-epic-claude` for work of Claude's that changes no repo, or `do-epic-human` for a task of the human's\n"), err)
_, out, _, _ = self.run_with(["ABC-12", "--file", "Retry"])
self.assertTrue(out.endswith("picks one: `twu-4` for the repo tenant-web-ui-4, `repo:<name>` for any other repo that works it, `do-epic-claude` for work of Claude's that changes no repo, or `do-epic-human` for a task of the human's.\n"), out)
def test_a_release_review_takes_its_label_beside_its_repo(self) -> None:
code, out, _, _ = self.run_with(["ABC-12", "--file", "Review api", "--label", "repo:api", "--label", "do-epic-release-review"])
@@ -154,6 +156,12 @@ class Instructions(unittest.TestCase):
told = findings.instructions("ABC-12", pathlib.Path("/b/do-epic"), "Swedish", {})
self.assertTrue(told.endswith("its text on stdin. Write the issue and the decision in Swedish, the epic's language."), told)
self.assertNotIn("--blocked-by", told)
self.assertIn("The label is `repo:<name>` for the repo that works it, `do-epic-claude`", told)
def test_name_the_teams_label_for_each_repo_its_table_names_and_repo_name_for_any_other(self) -> None:
told = findings.instructions("ABC-12", pathlib.Path("/b/do-epic"), "Swedish", {"core": "core-4", "twu-4": "tenant-web-ui-4", "c4": "core-4"})
self.assertIn("The label is `core` for the repo core-4, `twu-4` for the repo tenant-web-ui-4, `repo:<name>` for any other repo that works it, `do-epic-claude`", told)
self.assertNotIn("`c4`", told)
class RecordingADecision(FindingsTest):
+8 -1
View File
@@ -54,11 +54,18 @@ class TheFinishingChunksTask(DoEpicTest):
self.assertIn("Finish the epic ABC-12", task)
self.assertIn("first, and api and web have none. ", task)
self.assertIn("first, and api has none. ", finish.task("ABC-12", [issue("ABC-20", "repo:api", done=True)], {}, LAUNCHER, "Swedish"))
self.assertIn('`/b/do-epic ABC-12 --file "<summary>" --label repo:<name> --label do-epic-release-review`', task)
self.assertIn('`/b/do-epic ABC-12 --file "<summary>" --label <label> --label do-epic-release-review`', task)
self.assertIn("The `<label>` is `repo:api` for api and `repo:web` for web. ", task)
self.assertIn("`Release review of ABC-12`", task)
self.assertIn("in Swedish", task)
self.assertNotIn("--close-epic", task)
def test_names_each_lacking_repos_label_as_the_team_has_it_and_repo_name_for_one_the_table_lacks(self) -> None:
done = [issue("ABC-20", "twu-4", done=True), issue("ABC-21", "repo:web", done=True)]
task = finish.task("ABC-12", done, {"twu-4": "tenant-web-ui-4"}, LAUNCHER, "Swedish")
self.assertIn("The `<label>` is `twu-4` for tenant-web-ui-4 and `repo:web` for web. ", task)
self.assertIn("The `<label>` is `twu-4` for tenant-web-ui-4. ", finish.task("ABC-12", done[:1], {"twu-4": "tenant-web-ui-4", "web": "tenant-web-ui-4"}, LAUNCHER, "Swedish"))
def test_then_has_the_human_confirm_each_goal_before_the_summary_and_the_closing(self) -> None:
task = finish.task("ABC-12", REVIEWED, {}, LAUNCHER, "Swedish")
self.assertIn("Finish the epic ABC-12", task)