Answer product-owner round 1: 1 🔴, 2 🟡 (0 misread); move a chunk's issue where no pull request carries it, wait for the automation's move, and match statuses in any case

This commit is contained in:
Lilleman
2026-11-19 22:32:53 +01:00
parent 18d28fa472
commit 24bcb9060b
7 changed files with 90 additions and 31 deletions
+3 -4
View File
@@ -17,8 +17,8 @@ One pair per machine, the same for every epic (docs/decisions.md → `do-epic: d
- `clone-folder` is the folder a missing repo is cloned into: a path that starts with / or ~/. `~/code` where left out.
- `language` is the default language of Jira text, by its English name. English where left out.
- `jira-finish-transition` and `jira-finish-status` name the workflow transition that moves a finished chunk's issue and closes a finished epic, such as "Mark as done", and the status it leads to, such as "Done". A project's config names a plan item's the same way. Set both or neither; without them do-epic moves no issue to done and closes no epic.
- `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", "Done"]`. 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 each issue through the workflow, as from a pull request's merge. do-epic then moves no finished chunk's issue, and `jira-finish-transition` only closes the epic. It needs `jira-unblocking-statuses`, which then names the status the automation gives an issue whose pull request merged. false where left out.
- `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 any 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.
- `repo-rule.md` is prose that says how to tell an item's repo, and mustn't be blank."""
import dataclasses
@@ -65,7 +65,6 @@ class DoEpicConfig:
label_repos: LabelRepos = types.MappingProxyType({})
# The UNBLOCKING_STATUSES list; empty where the config has none.
unblocking: tuple[str, ...] = ()
# The AUTOMATION_MOVES switch.
automation_moves: bool = False
@@ -87,7 +86,7 @@ def workflow_faults(values: dict[str, object]) -> list[str]:
return [
*([f"`{UNBLOCKING_STATUSES}` is {statuses!r}, not a list of the status names Jira shows, such as [\"Release Ready\", \"Done\"]"] if not (isinstance(statuses, list) and statuses and all(name_of(status) for status in statuses)) else []),
*([f"`{AUTOMATION_MOVES}` is {moves!r}, not true or false"] if not isinstance(moves, bool) else []),
# Without such a status, an issue whose pull request merged would read as open, and its chunk would start again.
# With no status listed, an issue whose pull request merged would read as open, and its chunk would start again.
*([f"`{AUTOMATION_MOVES}` is set, so `{UNBLOCKING_STATUSES}` must name the status the automation gives an issue whose pull request merged"] if moves is True and UNBLOCKING_STATUSES not in values else []),
]
+32 -12
View File
@@ -27,6 +27,7 @@ from agent_cycle.verdicts import Finished, TakenIn
from atlassian.jira import ISSUE_KEY
from do_epic.backend.jira import JiraEpic
from claude_code.reply import Limited
from text_files.markdown_text import listed
from do_epic.repos import locate
from chunk_driver.this_loop import Loop
from chunk_driver.project.model_choice import Models, overridden
@@ -249,7 +250,7 @@ def chunk_run(key: str, epic: EpicRun) -> Stop:
return issue
if issue and isinstance(recorded(issue, epic.config.label_repos), HumanTask):
human_tasks.awaited(issue, epic.key, epic.store, epic.config.label_repos, epic.config.unblocking, tmux.Window(epic.session, key, pane), POLL_SECONDS, epic.paths.home, epic.effects)
return handed_on(key, epic)
return handed_on(key, epic, by_others=True)
place = chunk_root(key, issue, epic)
if isinstance(place, Stop):
return place
@@ -281,7 +282,7 @@ def chunk_run(key: str, epic: EpicRun) -> Stop:
news = parked_through(repo, loop, epic, told=news, finished=isinstance(concluded.verdict, Finished)) if repo is not None else ""
# A chunk that was parked has work again, whatever the judge ruled before its pull request passed the gate.
if isinstance(concluded.verdict, Finished) and news == "":
return handed_on(key, epic)
return handed_on(key, epic, repo is not None)
def parked_through(repo: str, loop: Loop, epic: EpicRun, told: str | None, finished: bool) -> str | Stop:
@@ -423,19 +424,22 @@ def folder_made(root: str) -> Failure | None:
return None
def handed_on(key: str, epic: EpicRun) -> Stop:
"""The stop of a do-epic whose chunk finished. It first moves the chunk's issue to done (the epic's finishing has none), and its split item too where that was the last of the item's sub-tasks, so that no finished chunk starts again and what they block may start, then starts each chunk that may start now. Where the team's automation moves issues, it leaves the chunk's issue to the automation, and the issue counts as in the first unblocking status; a split item still moves, once Jira counts each of its sub-tasks done. Its window closes as it exits."""
automated = epic.config.automation_moves
def handed_on(key: str, epic: EpicRun, by_others: bool = False) -> Stop:
"""The stop of a do-epic whose chunk finished. It first moves the chunk's issue to done (the epic's finishing has none), and its split item too where that was the last of the item's sub-tasks, so that no finished chunk starts again and what they block may start, then starts each chunk that may start now. by_others says someone else moves the issue where the team's automation moves issues: the automation from a chunk's pull request, or the human whose task it is. There it waits for that move (`moved_by_automation`) and moves only a split item, once Jira counts each of its sub-tasks done; a chunk without a repo has no pull request, so its issue moves to done as ever. Its window closes as it exits."""
# The epic's finishing has no issue to move: the epic is closed by `--close-epic`.
moved = None if key == epic.key or automated else epic.store.finish_issue(key)
if isinstance(moved, Failure):
return Stop(1, f"the chunk finished, but its issue could not move to done: {moved.reason}; once it is done in Jira, run `do-epic {epic.key}` to start the chunks it blocks")
issues = epic.store.read()
if key == epic.key:
issues = epic.store.read()
elif by_others and epic.config.automation_moves:
issues = moved_by_automation(key, epic)
else:
moved = epic.store.finish_issue(key)
if isinstance(moved, Failure):
return Stop(1, f"the chunk finished, but its issue could not move to done: {moved.reason}; once it is done in Jira, run `do-epic {epic.key}` to start the chunks it blocks")
issues = epic.store.read()
# A search may not show the move yet, so the issue counts as done here whatever the read says.
issues = issues if isinstance(issues, Failure) else [dataclasses.replace(each, done=True) if each.key == key else each for each in issues]
if isinstance(issues, Failure):
return Stop(1, f"the chunk finished, but the next could not start: {issues.reason}")
# A search may not show the move yet, nor has the team's automation always made it, so the issue counts as moved here whatever the read says.
moved_as: dict[str, typing.Any] = {"status": epic.config.unblocking[0]} if automated else {"done": True}
issues = [dataclasses.replace(each, **moved_as) if each.key == key else each for each in issues]
closed = split_items_closed(epic, issues)
if isinstance(closed, Stop):
return closed
@@ -446,6 +450,22 @@ def handed_on(key: str, epic: EpicRun) -> Stop:
return Stop(0, "")
def moved_by_automation(key: str, epic: EpicRun) -> list[EpicIssue] | Failure:
"""The epic's issues once the issue called key no longer holds up another: read every POLL_SECONDS until the team's automation, or a person, has moved it. Until then a read would show it open, and its chunk would start again."""
told = False
while True:
issues = epic.store.read()
if isinstance(issues, Failure):
return issues
by_key = {each.key: each for each in issues}
if key not in by_key or scheduler.settled(by_key[key], by_key, epic.config.unblocking):
return issues
if not told:
say(f"{key} is {by_key[key].status}: it waits for the team's automation to move it to {listed(epic.config.unblocking, 'or')}; move it in Jira if the automation doesn't", epic.effects, stdout=True)
told = True
epic.effects.sleep(POLL_SECONDS)
def split_items_closed(epic: EpicRun, issues: list[EpicIssue]) -> list[EpicIssue] | Stop:
"""The issues, with each item split by repo whose sub-tasks are all done moved to done in the tracker and read as done; the stop where one cannot move. Its last sub-task to finish closes it, and one an earlier run left open closes with it."""
for item in issues:
+12 -5
View File
@@ -82,10 +82,15 @@ class Epic:
return self.home / STATE / self.key
def unblocks(status: str, unblocking: tuple[str, ...]) -> bool:
"""Whether status is one of the unblocking statuses, whatever its case, so a name typed in another case than Jira shows still matches."""
return status.casefold() in {name.casefold() for name in unblocking}
def settled(issue: EpicIssue, by_key: dict[str, EpicIssue], unblocking: tuple[str, ...]) -> bool:
"""Whether the issue's work has landed, so that it takes no chunk and unblocks what it blocks: the tracker counts it done, or its status is one of unblocking, such as one the team's automation gives an issue whose pull request merged. An item marked SPLIT_LABEL has landed once each of its sub-tasks has, since nobody moves it before they are done."""
tasks = [task for task in by_key.values() if task.parent == issue.key] if SPLIT_LABEL in issue.labels else []
return issue.done or issue.status in unblocking or bool(tasks) and all(settled(task, by_key, unblocking) for task in tasks)
return issue.done or unblocks(issue.status, unblocking) or bool(tasks) and all(settled(task, by_key, unblocking) for task in tasks)
def open_blockers(issue: EpicIssue, by_key: dict[str, EpicIssue], unblocking: tuple[str, ...] = ()) -> list[str]:
@@ -106,7 +111,7 @@ def held_up(issues: list[EpicIssue], unblocking: tuple[str, ...] = ()) -> dict[s
def chunks(issues: list[EpicIssue], team: LabelRepos, unblocking: tuple[str, ...] = ()) -> tuple[list[Chunk], list[Waits]]:
"""The open issues to work as chunks, in the tracker's rank order, and those that wait. A split item is worked through its sub-tasks, and what blocks it blocks them. An issue in one of the unblocking statuses is worked already, and waits only to be done."""
"""The open issues to work as chunks, in the tracker's rank order, and those that wait. A split item is worked through its sub-tasks, and what blocks it blocks them. An issue in one of the unblocking statuses is worked already: it waits until Jira counts it done."""
by_key = {issue.key: issue for issue in issues}
holding = held_up(issues, unblocking)
found: list[Chunk] = []
@@ -114,8 +119,8 @@ def chunks(issues: list[EpicIssue], team: LabelRepos, unblocking: tuple[str, ...
for issue in issues:
if issue.done:
continue
if issue.status in unblocking:
waits.append(Waits(issue.key, f"its work is merged: it is {issue.status}, and the epic's finishing waits until Jira counts it done"))
if unblocks(issue.status, unblocking):
waits.append(Waits(issue.key, f"its work has landed: it is {issue.status}, and the epic's finishing waits until Jira counts it done"))
continue
if is_split(issue, issues):
if all(task.done for task in issues if task.parent == issue.key) and not finished(issues, issue.key):
@@ -140,7 +145,9 @@ def turn_of(issue: EpicIssue, pick: Pick | None | Failure, blocking: list[str],
if blocking:
outside = [key for key in blocking if key not in by_key]
unseen = f"; do-epic cannot see {' and '.join(outside)}, outside the epic, finish: remove such a link in Jira once its issue is done" if outside else ""
until = f", until {'it' if len(blocking) == 1 else 'each'} is {listed(unblocking, 'or')}" if unblocking else ""
inside = [key for key in blocking if key in by_key]
whom = ("it is" if len(blocking) == 1 else "each is") if not outside else f"{' and '.join(inside)} {'is' if len(inside) == 1 else 'are'}"
until = f", until {whom} {listed((*unblocking, 'done'), 'or')}" if unblocking and inside else ""
return Waits(issue.key, f"{' and '.join(blocking)} block{'s' if len(blocking) == 1 else ''} it{until}{unseen}")
return Chunk(issue.key, pick.name if isinstance(pick, Repo) else None)
+22 -2
View File
@@ -449,7 +449,7 @@ class AChunksRun(DoEpicTest):
self.assertEqual(code, 0, err)
self.assertIn("the chunk finished; started ABC-22\n", out)
def test_where_the_teams_automation_moves_issues_a_finished_chunk_moves_none_and_starts_what_it_blocks(self) -> None:
def test_where_the_teams_automation_moves_issues_a_finished_chunk_without_a_repo_still_moves_its_own(self) -> None:
(self.home / ".claude-projects" / "do-epic" / "config.toml").write_text(SETTINGS + 'jira-unblocking-statuses = ["Release Ready"]\njira-automation-moves-issues = true\n', encoding="utf-8")
parent = issue("ABC-23", "split-by-repo")
store = MemoryEpic("ABC-12", [self.issues[0], parent, issue("ABC-21", "do-epic-claude", parent="ABC-23"), issue("ABC-22", "do-epic-claude", blockers=("ABC-23",))])
@@ -457,7 +457,8 @@ class AChunksRun(DoEpicTest):
fake = FakeEffects(streams=[self.worker()], claude=[judged("finished")], git=UNREAD, windows="ABC-21\t0\t@9\n")
code, out, err = self.run_main(["--chunk", "ABC-21", "ABC-12"], fake, MODELS)
self.assertEqual(code, 0, err)
self.assertEqual({each.key: (each.status, each.done) for each in store.issues}, dict.fromkeys(("ABC-20", "ABC-23", "ABC-21", "ABC-22"), ("To Do", False)))
# No pull request carries ABC-21, so do-epic moves it; its split item, then all done, closes as ever.
self.assertEqual({each.key: each.done for each in store.issues}, {"ABC-20": False, "ABC-23": True, "ABC-21": True, "ABC-22": False})
self.assertIn("the chunk finished; started ABC-22\n", out)
def test_the_last_sub_task_of_a_split_item_to_finish_moves_the_item_to_done_and_starts_what_it_blocks(self) -> None:
@@ -774,6 +775,25 @@ class AChunkWhosePullRequestWaitsOnAGate(DoEpicTest):
code, _, err, prompts = self.parked_run(fake)
self.assertEqual((code, len(prompts)), (0, 1), err)
def test_where_the_teams_automation_moves_issues_a_finished_chunk_in_a_repo_moves_none_and_waits_for_the_move(self) -> None:
(self.home / ".claude-projects" / "do-epic" / "config.toml").write_text(SETTINGS + 'jira-unblocking-statuses = ["Release Ready"]\njira-automation-moves-issues = true\n', encoding="utf-8")
store = MemoryEpic("ABC-12", [*self.issues[:-1], issue("ABC-22", "do-epic-claude", blockers=("ABC-20",))])
self.backend = lambda config, key: (store, EpicRecord(Description(self.description))) # type: ignore[method-assign,arg-type]
self.forges = [awaiting(pulls="")]
fake = FakeEffects(streams=[self.worker()], claude=[judged("finished")], git=UNREAD, windows=PARKED_WINDOW)
slept: list[float] = []
def sleep(seconds: float) -> None:
slept.append(seconds)
if len(slept) == 2:
store.change("ABC-20", status="Release Ready")
fake.effects = lambda made=fake.effects(): dataclasses.replace(made, sleep=sleep) # type: ignore[method-assign]
code, out, err, _ = self.parked_run(fake)
self.assertEqual((code, slept), (0, [60, 60]), err)
self.assertEqual([(each.status, each.done) for each in store.issues if each.key == "ABC-20"], [("Release Ready", False)])
self.assertEqual(out.count("ABC-20 is To Do: it waits for the team's automation to move it to Release Ready; move it in Jira if the automation doesn't\n"), 1, out)
self.assertIn("the chunk finished; started ABC-22\n", out)
def test_where_the_chunk_merges_an_approved_pull_request_parks_no_chunk(self) -> None:
self.forges = [awaiting(decision="APPROVED")]
fake = FakeEffects(streams=[self.worker()], claude=[judged("finished")], git=UNREAD, windows=PARKED_WINDOW)
+16 -3
View File
@@ -123,13 +123,26 @@ class WhichIssuesAreChunks(unittest.TestCase):
def test_an_issue_in_an_unblocking_status_unblocks_what_it_blocks_and_waits_to_be_done_itself(self) -> None:
issues = [issue("ABC-19", "repo:api", status="Release Ready"), issue("ABC-20", "repo:api", blockers=("ABC-19",)), issue("ABC-21", "repo:api", status="Code Review"), issue("ABC-22", "repo:api", blockers=("ABC-21",)), issue("ABC-23", "repo:api", done=True), issue("ABC-24", "repo:api", blockers=("ABC-23", "ABC-21", "ABC-22"))]
self.assertEqual(chunks(issues, {}, ("Release Ready", "Shipped")), ([Chunk("ABC-20", "api"), Chunk("ABC-21", "api")], [
Waits("ABC-19", "its work is merged: it is Release Ready, and the epic's finishing waits until Jira counts it done"),
Waits("ABC-22", "ABC-21 blocks it, until it is Release Ready or Shipped"),
Waits("ABC-24", "ABC-21 and ABC-22 block it, until each is Release Ready or Shipped"),
Waits("ABC-19", "its work has landed: it is Release Ready, and the epic's finishing waits until Jira counts it done"),
Waits("ABC-22", "ABC-21 blocks it, until it is Release Ready, Shipped or done"),
Waits("ABC-24", "ABC-21 and ABC-22 block it, until each is Release Ready, Shipped or done"),
]))
self.assertEqual(chunks(issues[:2], {}), ([Chunk("ABC-19", "api")], [Waits("ABC-20", "ABC-19 blocks it")]))
self.assertEqual(held_up(issues, ("Release Ready", "Shipped")), {"ABC-21": ["ABC-22", "ABC-24"], "ABC-22": ["ABC-24"]})
def test_an_unblocking_status_matches_whatever_its_case(self) -> None:
issues = [issue("ABC-19", "repo:api", status="Release Ready"), issue("ABC-20", "repo:api", blockers=("ABC-19",))]
self.assertEqual(chunks(issues, {}, ("release ready",)), ([Chunk("ABC-20", "api")], [Waits("ABC-19", "its work has landed: it is Release Ready, and the epic's finishing waits until Jira counts it done")]))
def test_names_an_unblocking_status_only_for_a_blocker_inside_the_epic(self) -> None:
unseen = "outside the epic, finish: remove such a link in Jira once its issue is done"
issues = [issue("ABC-19", "repo:api"), issue("ABC-20", "repo:api", blockers=("XYZ-1",)), issue("ABC-21", "repo:api", blockers=("ABC-19", "XYZ-1")), issue("ABC-22", "repo:api", blockers=("ABC-19", "ABC-20", "XYZ-1"))]
self.assertEqual(chunks(issues, {}, ("Release Ready",))[1], [
Waits("ABC-20", f"XYZ-1 blocks it; do-epic cannot see XYZ-1, {unseen}"),
Waits("ABC-21", f"ABC-19 and XYZ-1 block it, until ABC-19 is Release Ready or done; do-epic cannot see XYZ-1, {unseen}"),
Waits("ABC-22", f"ABC-19 and ABC-20 and XYZ-1 block it, until ABC-19 and ABC-20 are Release Ready or done; do-epic cannot see XYZ-1, {unseen}"),
])
def test_a_split_item_unblocks_what_it_blocks_once_each_sub_task_is_in_an_unblocking_status(self) -> None:
issues = [issue("ABC-20", "split-by-repo"), issue("ABC-23", "repo:api", parent="ABC-20", status="Release Ready"), issue("ABC-24", "repo:web", parent="ABC-20", done=True), issue("ABC-21", "repo:api", blockers=("ABC-20",))]
self.assertEqual(chunks(issues, {}, ("Release Ready",))[0], [Chunk("ABC-21", "api")])
+2 -2
View File
@@ -33,9 +33,9 @@ class TheStatusLines(unittest.TestCase):
def test_names_the_status_a_blocker_must_reach_and_the_one_a_merged_issue_is_in(self) -> None:
found = self.lines([issue("ABC-20", "repo:api", status="Release Ready"), issue("ABC-21", "repo:api", status="Code Review"), issue("ABC-22", "repo:api", blockers=("ABC-21",))], (EPIC, "ABC-21", False, ""), unblocking=("Release Ready",))
self.assertEqual(found, [
"ABC-20 waits: its work is merged: it is Release Ready, and the epic's finishing waits until Jira counts it done",
"ABC-20 waits: its work has landed: it is Release Ready, and the epic's finishing waits until Jira counts it done",
"ABC-21 runs",
"ABC-22 waits: ABC-21 blocks it, until it is Release Ready",
"ABC-22 waits: ABC-21 blocks it, until it is Release Ready or done",
])
def test_a_parked_chunk_says_what_it_awaits_and_since_when(self) -> None: