From 4557dced589fb20af289045983d19e777d3f3a2a Mon Sep 17 00:00:00 2001 From: Lilleman Date: Fri, 20 Nov 2026 15:14:14 +0100 Subject: [PATCH] =?UTF-8?q?Answer=20product-owner=20round=201:=200=20?= =?UTF-8?q?=F0=9F=94=B4,=203=20=F0=9F=9F=A1=20(0=20misread);=20comment=20b?= =?UTF-8?q?efore=20the=20scores=20are=20set,=20score=20no=20issue=20whose?= =?UTF-8?q?=20work=20has=20landed,=20and=20say=20after=20which=20issues=20?= =?UTF-8?q?one=20starts?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- bin/do_epic/backend/jira.py | 9 +++++---- bin/do_epic/backend/test_jira.py | 11 +++++++---- bin/do_epic/main.py | 4 +++- bin/do_epic/planning.py | 6 +++--- bin/do_epic/status.py | 11 +++++------ bin/do_epic/test_main.py | 6 ++++++ bin/do_epic/test_planning.py | 12 ++++++++++++ bin/do_epic/test_status.py | 8 ++++---- 8 files changed, 45 insertions(+), 22 deletions(-) diff --git a/bin/do_epic/backend/jira.py b/bin/do_epic/backend/jira.py index f3d2b503..e9e0c89c 100644 --- a/bin/do_epic/backend/jira.py +++ b/bin/do_epic/backend/jira.py @@ -188,11 +188,12 @@ class JiraEpic: body = fields if isinstance(fields, Failure) else self.to_adf(comment) if isinstance(body, Failure): return Failure(f"cannot score {key}: {body.reason}") - put = self.http("PUT", f"{self.epic.site}/rest/api/3/issue/{key}", authorization, {"properties": [{"key": PROPERTY, "value": held | scores | {MOVES: moves}}]}) - if isinstance(put, Failure): - return Failure(f"cannot score {key}: {put.reason}") + # The comment goes first: an issue that holds scores is never scored again, so scores set without it would leave the team untold for good. posted = self.http("POST", f"{self.epic.site}/rest/api/3/issue/{key}/comment", authorization, {"body": body}) - return Failure(f"{key} is scored, but the comment that tells its team could not be posted: {posted.reason}") if isinstance(posted, Failure) else None + if isinstance(posted, Failure): + return Failure(f"cannot comment on {key} to tell its team the scores: {posted.reason}") + put = self.http("PUT", f"{self.epic.site}/rest/api/3/issue/{key}", authorization, {"properties": [{"key": PROPERTY, "value": held | scores | {MOVES: moves}}]}) + return Failure(f"the comment on {key} tells its team the scores, but they could not be set, so the next run scores it again: {put.reason}") if isinstance(put, Failure) else None def finish_issue(self, key: str) -> None | Failure: authorization = basic_auth(self.env_file) diff --git a/bin/do_epic/backend/test_jira.py b/bin/do_epic/backend/test_jira.py index 83f5ccea..ad2df90d 100644 --- a/bin/do_epic/backend/test_jira.py +++ b/bin/do_epic/backend/test_jira.py @@ -232,11 +232,14 @@ class Jira(Case): self.jira.answers[("GET", read)] = {"fields": {"parent": {"key": "ABC-12"}}, "properties": {"plan-item": "L 2"}} self.assertEqual(store.set_scores(key, scores, "", "Scored."), Failure(f"{key}'s issue property plan-item is not a JSON object")) del self.jira.answers[("GET", read)] - self.jira.answers[("PUT", f"{ISSUES}/{key}")] = Failure("Jira answered 503") - self.assertEqual(store.set_scores(key, scores, "", "Scored."), Failure(f"cannot score {key}: Jira answered 503")) - del self.jira.answers[("PUT", f"{ISSUES}/{key}")] self.jira.answers[("POST", f"{ISSUES}/{key}/comment")] = Failure("Jira answered 503") - self.assertEqual(store.set_scores(key, scores, "", "Scored."), Failure(f"{key} is scored, but the comment that tells its team could not be posted: Jira answered 503")) + self.assertEqual(store.set_scores(key, scores, "", "Scored."), Failure(f"cannot comment on {key} to tell its team the scores: Jira answered 503")) + del self.jira.answers[("POST", f"{ISSUES}/{key}/comment")] + self.jira.answers[("PUT", f"{ISSUES}/{key}")] = Failure("Jira answered 503") + self.assertEqual(store.set_scores(key, scores, "", "Scored."), Failure(f"the comment on {key} tells its team the scores, but they could not be set, so the next run scores it again: Jira answered 503")) + del self.jira.answers[("PUT", f"{ISSUES}/{key}")] + # No scores were set while the comment failed, so the issue is still scored once Jira answers. + self.assertIsNone(store.set_scores(key, scores, "", "Scored.")) def test_says_why_the_epics_status_cannot_be_read(self) -> None: for answer, reason in ((Failure("Jira answered 503"), "cannot read ABC-12's status: Jira answered 503"), ({"fields": {}}, "ABC-12's status is not in the shape Jira Cloud's REST API version 3 documents: its status category has no key that is text"), (["ABC-12"], "ABC-12's status is not in the shape Jira Cloud's REST API version 3 documents: its status category has no key that is text"), ({"fields": {"status": {"statusCategory": {"key": 3}}}}, "ABC-12's status is not in the shape Jira Cloud's REST API version 3 documents: its status category has no key that is text")): diff --git a/bin/do_epic/main.py b/bin/do_epic/main.py index c2a21ad6..557f6632 100644 --- a/bin/do_epic/main.py +++ b/bin/do_epic/main.py @@ -151,7 +151,9 @@ def run(argv: list[str], env: typing.Mapping[str, str], paths: Paths, launcher: def status_printed(epic: EpicRun) -> Stop: """What `do-epic --status` does: prints a line per open issue, and doesn't start anything.""" issues = epic.store.read() - lines = issues if isinstance(issues, Failure) else status.lines(epic.key, epic.paths.home, issues, epic.config.label_repos, epic.config.unblocking, epic.effects.tmux) + order = issues if isinstance(issues, Failure) else planning.start_order(planned_epic(epic), issues) + # Where the issues cannot be put in order of score, they start in the backlog's order, as a run says. + lines = issues if isinstance(issues, Failure) else status.lines(epic.key, epic.paths.home, issues, epic.config.label_repos, epic.config.unblocking, epic.effects.tmux, () if isinstance(order, Failure) else tuple(order)) return Stop(1, lines.reason) if isinstance(lines, Failure) else Stop(0, "\n".join(lines) or f"the epic {epic.key} has no open issue") diff --git a/bin/do_epic/planning.py b/bin/do_epic/planning.py index 05097d17..f7a50cd9 100644 --- a/bin/do_epic/planning.py +++ b/bin/do_epic/planning.py @@ -21,7 +21,7 @@ from claude_code.reply import Limited from plan_store.jira_epic import number from model_routing.ladder_file import read_ladder, SHIPPED from model_routing.ladder import Rung -from do_epic.scheduler import STATE +from do_epic.scheduler import STATE, unblocks from plan_store.scoring import weighing_texts # The epic's formula, stated under its `## Scoring` as a todo.md states its own. @@ -158,8 +158,8 @@ def located(epic: Planned, picks: list[repo_pick.Repo]) -> dict[str, repos.Locat def chunk_issues(epic: Planned, issues: list[EpicIssue]) -> list[EpicIssue]: - """The open issues that may become a chunk: a child issue or a sub-task with one pick. Not an item split by repo, which is worked through its sub-tasks.""" - return [issue for issue in issues if not issue.done and not split.is_split(issue, issues) and (pick := repo_pick.recorded(issue, epic.config.label_repos)) is not None and not isinstance(pick, Failure)] + """The open issues that may become a chunk: a child issue or a sub-task with one pick. Not an item split by repo, which is worked through its sub-tasks, and not an issue in one of the unblocking statuses, whose work has landed.""" + return [issue for issue in issues if not issue.done and not unblocks(issue.status, epic.config.unblocking) and not split.is_split(issue, issues) and (pick := repo_pick.recorded(issue, epic.config.label_repos)) is not None and not isinstance(pick, Failure)] def repo_of(epic: Planned, issue: EpicIssue) -> str | None: diff --git a/bin/do_epic/status.py b/bin/do_epic/status.py index b4f4739a..bd9899ca 100644 --- a/bin/do_epic/status.py +++ b/bin/do_epic/status.py @@ -9,7 +9,7 @@ from do_epic.parked import file_of, Parked, parked_chunks, SLOT from do_epic.repo_pick import LabelRepos from agent_cycle import tmux -UNSCORED = ", after each issue that holds scores, since it holds none" +UNSCORED = ", after each issue that holds every score, since it doesn't" def since(folder: pathlib.Path, chunk: Parked) -> str: @@ -20,8 +20,8 @@ def since(folder: pathlib.Path, chunk: Parked) -> str: return "" -def lines(key: str, home: pathlib.Path, issues: list[EpicIssue], team: LabelRepos, unblocking: tuple[str, ...], run: tmux.Tmux) -> list[str] | Failure: - """A line per open issue of the epic called key, in the tracker's rank order: that its chunk runs or asks the human, or why it waits. It doesn't start anything or check any limit, so the line of a chunk that has yet to start doesn't say which limit holds it back.""" +def lines(key: str, home: pathlib.Path, issues: list[EpicIssue], team: LabelRepos, unblocking: tuple[str, ...], run: tmux.Tmux, order: tuple[str, ...] = ()) -> list[str] | Failure: + """A line per open issue of the epic called key, in the tracker's rank order: that its chunk runs or asks the human, or why it waits. order holds the keys of the issues that start by score, as planning.start_order puts them; a chunk it leaves out says that it starts after them. It doesn't start anything or check any limit, so the line of a chunk that has yet to start doesn't say which limit holds it back.""" found, waits = chunks(issues, team, unblocking) folder = home / STATE / key parked = parked_chunks(folder) @@ -32,9 +32,8 @@ def lines(key: str, home: pathlib.Path, issues: list[EpicIssue], team: LabelRepo live = {window.name: window for window in windows if not window.dead} again = f"run `do-epic {key}` to start it again" reasons = {wait.issue: wait.reason for wait in waits} - # Where no chunk's issue holds scores, each starts in the tracker's rank order, and no line says more. - scored = {issue.key for issue in issues if issue.scores} - bare = {chunk.issue for chunk in found if chunk.issue not in scored} if any(chunk.issue in scored for chunk in found) else set() + # Where no issue starts by score, each starts in the tracker's rank order, which needs no reason. + bare = {chunk.issue for chunk in found if chunk.issue not in order} if order else set() for chunk in found: if chunk.issue in parked: shown = live[chunk.issue].awaits if chunk.issue in live else "" diff --git a/bin/do_epic/test_main.py b/bin/do_epic/test_main.py index 5c302f49..8412a663 100644 --- a/bin/do_epic/test_main.py +++ b/bin/do_epic/test_main.py @@ -965,6 +965,12 @@ class TheStatus(DoEpicTest): self.assertEqual({args[0] for args in fake.tmux_calls}, {"-V", "list-windows"}) self.assertTrue(all("epic-ABC-12" in " ".join(args) for args in fake.tmux_calls if args[0] == "list-windows"), fake.tmux_calls) + def test_says_which_issue_starts_after_those_that_start_by_score(self) -> None: + self.issues = [issue("ABC-21", "do-epic-claude"), dataclasses.replace(issue("ABC-24", "do-epic-claude"), scores={"L": 1, "E": 1, "I": 1, "S": 1})] + room = "it has not started; `do-epic ABC-12` starts it once the epic and its repo have room" + out = self.run_main(["ABC-12", "--status"], FakeEffects())[1] + self.assertEqual(out.replace("<1790000000> ", "").splitlines(), [f"ABC-21 waits: {room}, after each issue that holds every score, since it doesn't", f"ABC-24 waits: {room}"]) + def test_says_so_where_no_issue_is_open_or_the_epic_cannot_be_read(self) -> None: self.issues = [issue("ABC-20", "repo:api", done=True)] self.assertIn("the epic ABC-12 has no open issue\n", self.run_main(["ABC-12", "--status"], FakeEffects())[1]) diff --git a/bin/do_epic/test_planning.py b/bin/do_epic/test_planning.py index 2e7f22da..002f5730 100644 --- a/bin/do_epic/test_planning.py +++ b/bin/do_epic/test_planning.py @@ -376,6 +376,18 @@ class Planning(DoEpicTest): found, store, out = self.plan(fake) self.assertEqual((found, store.writes, out, fake.made("claude")), (self.issues, [], "", [])) + def test_scores_no_issue_whose_work_has_landed(self) -> None: + with (self.home / ".claude-projects/do-epic/config.toml").open("a", encoding="utf-8") as config: + config.write('\njira-unblocking-statuses = ["Release Ready"]\n') + self.rule() + self.description = RANKED + self.issues = [issue("ABC-20", "do-epic-claude", status="release ready"), issue("ABC-21", "do-epic-claude"), scored("ABC-22", "epic 1 by 2", "do-epic-claude")] + fake = FakeEffects(claude=[says(ANSWER)]) + found, store, _ = self.plan(fake) + assert not isinstance(found, Failure | Limited), found + self.assertEqual([write.split(" L ")[0] for write in store.writes], ["score ABC-21"]) + self.assertEqual(planning.start_order(self.epic, found), ["ABC-21", "ABC-22"]) + def test_names_an_issue_whose_scoring_fails_and_scores_the_next(self) -> None: self.rule() self.description = RANKED diff --git a/bin/do_epic/test_status.py b/bin/do_epic/test_status.py index 29f3e3fb..0c1cc853 100644 --- a/bin/do_epic/test_status.py +++ b/bin/do_epic/test_status.py @@ -54,10 +54,10 @@ class TheStatusLines(unittest.TestCase): def test_an_issue_without_scores_says_that_it_starts_after_each_that_holds_them(self) -> None: held = dataclasses.replace(issue("ABC-21", "repo:api"), scores={"L": 1, "E": 1, "I": 1, "S": 1}) room = "it has not started; `do-epic ABC-12` starts it once the epic and its repo have room" - found = self.lines([issue("ABC-20", "repo:api"), held]) - self.assertEqual(found, [f"ABC-20 waits: {room}, after each issue that holds scores, since it holds none", f"ABC-21 waits: {room}"]) - # Where no issue holds scores, each starts in the tracker's rank order. - self.assertEqual(self.lines([issue("ABC-20", "repo:api")]), [f"ABC-20 waits: {room}"]) + found = status.lines("ABC-12", self.home, [issue("ABC-20", "repo:api"), held], {}, (), Tmux(), ("ABC-21",)) + self.assertEqual(found, [f"ABC-20 waits: {room}, after each issue that holds every score, since it doesn't", f"ABC-21 waits: {room}"]) + # Where no issue starts by score, each starts in the tracker's rank order. + self.assertEqual(self.lines([issue("ABC-20", "repo:api"), held]), [f"ABC-20 waits: {room}", f"ABC-21 waits: {room}"]) def test_a_stopped_chunk_and_one_not_started_say_so(self) -> None: found = self.lines([issue("ABC-20", "repo:api"), issue("ABC-21", "repo:api")], (EPIC, "ABC-20", True, ""))