Answer product-owner round 1: 0 🔴, 4 🟡 (0 misread); move through the open status, refuse open-epic without a branch, tell a conflict from git's other failures

This commit is contained in:
Lilleman
2026-11-20 20:15:33 +01:00
parent 9f367e90ca
commit ce2e9dc0e5
9 changed files with 143 additions and 21 deletions
+3 -3
View File
@@ -31,12 +31,12 @@ def shipping(config: ProjectConfig) -> str:
def epic_branch_rule(config: ProjectConfig, epic: str) -> str:
"""What a chunk is told where the repo's config sets `epic-branch`, empty where it doesn't: its base, that its merge needs no person, how a later push asks for a review, and which branch its sibling repos are tested at (docs/decisions.md → `epic-branch: an epic's chunks branch off and merge into a working branch …`)."""
"""What a chunk is told where the repo's config sets `epic-branch`, empty where it doesn't: its base, that its merge needs no person, how a later push asks for a review, and which branch the epic's other repos are tested at (docs/decisions.md → `epic-branch: an epic's chunks branch off and merge into a working branch …`)."""
if config.epic_branch is None:
return ""
branch = templates.epic_branch(config.epic_branch, epic)
pushed = " Push each later commit to the open pull request with `chunk-pr push`, which asks the repo's auto-reviewer for a review of the new head, and wait for that review." if config.review_request_comment else ""
return f"The chunk's pull request goes into the epic's working branch `{branch}`, not into the default branch: {DRIVER} has made that branch level with the default branch and recorded it as the base of the chunk's branch, so make the chunk's worktree and branch off `origin/{branch}`. `chunk-pr merge` merges into `{branch}` without waiting for a person.{pushed} Test each sibling repo at its branch `{branch}` where it has one, else at its default branch, and name in the chunk's summary each sibling that ran at its default branch."
pushed = " After `chunk-pr ready`, push each commit with `chunk-pr push`, which asks the repo's auto-reviewer to review the new head, and wait for that review." if config.review_request_comment else ""
return f"The chunk's pull request goes into the epic's working branch `{branch}`, not into the default branch: {DRIVER} has made that branch level with the default branch and recorded it as the base of the chunk's branch, so make the chunk's worktree and branch off `origin/{branch}`. `chunk-pr merge` merges into `{branch}` without waiting for a person.{pushed} Where the chunk's tests run other repos of the epic, run each at its branch `{branch}` where it has one, else at its default branch, and name in the chunk's summary each repo that ran at its default branch."
def task(issue: EpicIssue, epic: str, team: LabelRepos, checkout: str | None, launcher: pathlib.Path, language: str, config: ProjectConfig | None) -> str:
+6 -3
View File
@@ -311,12 +311,12 @@ def chunk_run(key: str, epic: EpicRun) -> Stop:
root, repo = place
if unmade := folder_made(root):
return Stop(1, unmade.reason)
if issue:
issue_started(key, epic)
# The epic's working branch the chunk merges into; None where its repo keeps none, as for a chunk without a repo.
based = epic_based(key, root, epic) if repo is not None else None
if isinstance(based, Stop):
return based
if issue:
issue_started(key, epic)
session = session_named(f"A {epic.key} do-epic {key}", epic.paths.claude_code_transcripts)
loop = Loop(root=root, session=session, window=tmux.Window(epic.session, key, pane), paths=epic.paths, env=epic.env, launcher=epic.launcher, effects=epic.effects)
run = ChunkRun()
@@ -521,13 +521,16 @@ def folder_made(root: str) -> Failure | None:
def handed_on(key: str, epic: EpicRun, in_repo: bool = False, humans: bool = False, to_epic_branch: 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. Where the team's automation moves issues, others move two kinds of issue. The automation moves the issue of a chunk in a repo, which in_repo marks, from its pull request: the stop waits for that move (`moved_by_automation`). The human moves their own task, which humans marks: the stop moves and awaits nothing. A chunk without a repo has no pull request, so its issue moves to done as ever, and so does a split item, once Jira counts each of its sub-tasks done. The automation doesn't see a pull request that merged into an epic's working branch, which to_epic_branch marks: the stop moves that chunk's issue to the status `jira-pull-request-merged-status` names. Where none is named, it moves the issue to done, or stops where the automation moves issues, since nothing would. Its window closes as it exits."""
"""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, others move two kinds of issue. The automation moves the issue of a chunk in a repo, which in_repo marks, from its pull request: the stop waits for that move (`moved_by_automation`). The human moves their own task, which humans marks: the stop doesn't move or await anything. A chunk without a repo has no pull request, so its issue moves to done as ever, and so does a split item, once Jira counts each of its sub-tasks done. The automation doesn't see a pull request that merged into an epic's working branch, which to_epic_branch marks: the stop moves that chunk's issue to the status `jira-pull-request-merged-status` names. Where none is named, it moves the issue to done, or stops where the automation moves issues, since then nobody would move it. do-epic's window closes as it exits."""
automated = epic.config.automation_moves
# The epic's finishing has no issue to move: the epic is closed by `--close-epic`. Nor has a human's task where the human moves it: its window waited until it holds up no issue.
if key == epic.key or (humans and automated):
issues: list[EpicIssue] | Failure = epic.store.read()
elif to_epic_branch and (status := epic.config.pull_merged_status):
moved = epic.store.move_issue(key, status)
# A chunk that never parked left its issue before the open status, from which a workflow may offer no way to the merged one.
if isinstance(moved, Failure) and (opened := epic.config.pull_open_status) and not isinstance(epic.store.move_issue(key, opened), Failure):
moved = epic.store.move_issue(key, status)
if isinstance(moved, Failure):
return Stop(1, f"the chunk finished, but its issue could not move to {status!r}: {moved.reason}; once it has that status in Jira, run `do-epic {epic.key}` to start the chunks it blocks")
issues = epic.store.read()
+37 -1
View File
@@ -7,6 +7,7 @@ import shutil
import subprocess
import sys
import tempfile
import typing
import unittest
sys.path.insert(0, str(pathlib.Path(__file__).resolve().parents[1]))
@@ -983,6 +984,22 @@ class AChunkWhosePullRequestWaitsOnAGate(DoEpicTest):
self.assertIn(f"cannot remove {self.file}: Permission denied", err)
class StepwiseStore:
"""A store whose workflow reaches each status in `after` only from the status it names there; every other call is the wrapped store's."""
def __init__(self, store: typing.Any, after: dict[str, str]) -> None:
self.store, self.after = store, after
def __getattr__(self, name: str) -> typing.Any:
return getattr(self.store, name)
def move_issue(self, key: str, status: str) -> None | Failure:
now = self.store.within(key).status
if status in self.after and now not in (status, self.after[status]):
return Failure(f"{key} has no transition to {status!r} from its status {now!r}")
return self.store.move_issue(key, status)
class AnEpicsWorkingBranch(DoEpicTest):
"""A chunk in a repo whose config sets `epic-branch`, so its pull request goes into the branch ABC-12."""
@@ -1022,7 +1039,7 @@ class AnEpicsWorkingBranch(DoEpicTest):
self.assertEqual(self.git_calls, [])
def test_a_default_branch_that_conflicts_stops_the_loop_for_a_person_and_records_no_base(self) -> None:
stop = main.epic_based("ABC-20", self.checkout, self.epic_run(self.with_git(FakeEffects(), rev_list="1\n", merge_tree=Failure("CONFLICT"))))
stop = main.epic_based("ABC-20", self.checkout, self.epic_run(self.with_git(FakeEffects(), rev_list="1\n", merge_tree=Failure("git merge-tree --write-tree origin/ABC-12 origin/main: "))))
self.assertEqual(stop, main.Stop(1, f"cannot ready the epic's working branch ABC-12 in {self.checkout} for ABC-20: origin/main doesn't merge into origin/ABC-12 cleanly, so a person merges it: check ABC-12 out, run `git merge origin/main`, resolve the conflicts and push; once that is settled, run `do-epic ABC-12` to start the chunk again"))
self.assertNotIn("config", [args[0] for args, _ in self.git_calls])
@@ -1032,6 +1049,12 @@ class AnEpicsWorkingBranch(DoEpicTest):
self.assertIn("no origin/HEAD", stop.reason)
self.assertEqual(len(self.git_calls), 1)
def test_a_chunk_whose_working_branch_cannot_be_readied_leaves_its_issue_unstarted(self) -> None:
code, _, err = self.run_main(["--chunk", "ABC-20", "ABC-12"], self.with_git(FakeEffects(), rev_list="1\n", merge_tree=Failure("git merge-tree --write-tree origin/ABC-12 origin/main: ")), MODELS)
self.assertEqual(code, 1)
self.assertIn("cannot ready the epic's working branch ABC-12", err)
self.assertEqual(self.store.writes, [])
def test_its_issue_moves_as_the_pull_request_opens_and_merges_and_no_person_merges_it(self) -> None:
self.settings('jira-unblocking-statuses = ["Release Ready"]\njira-automation-moves-issues = true\njira-pull-request-open-status = "Code Review"\njira-pull-request-merged-status = "Release Ready"\n')
self.forges = [awaiting(), awaiting(), awaiting(decision="APPROVED")]
@@ -1058,6 +1081,19 @@ class AnEpicsWorkingBranch(DoEpicTest):
self.assertEqual(main.handed_on("ABC-20", self.epic_run(FakeEffects(windows="")), in_repo=True, to_epic_branch=True).code, 0)
self.assertTrue(self.store.issues[0].done)
def test_an_issue_whose_workflow_reaches_the_merged_status_only_through_the_open_status_moves_through_it(self) -> None:
self.settings('jira-unblocking-statuses = ["Release Ready"]\njira-pull-request-open-status = "Code Review"\njira-pull-request-merged-status = "Release Ready"\n')
epic = self.epic_run(FakeEffects(windows=""))
stepwise = StepwiseStore(self.store, {"Release Ready": "Code Review"})
with contextlib.redirect_stdout(io.StringIO()):
stop = main.handed_on("ABC-20", dataclasses.replace(epic, store=stepwise), in_repo=True, to_epic_branch=True)
self.assertEqual(stop.code, 0, stop.reason)
self.assertEqual(self.store.writes, ["move ABC-20 to Code Review", "move ABC-20 to Release Ready"])
# An issue the open status doesn't lead on from stops on the move it asked for.
stuck = StepwiseStore(self.store, {"Release Ready": "QA", "Code Review": "QA"})
stop = main.handed_on("ABC-22", dataclasses.replace(epic, store=stuck), in_repo=True, to_epic_branch=True)
self.assertTrue(stop.reason.startswith("the chunk finished, but its issue could not move to 'Release Ready': ABC-22 has no transition to 'Release Ready'"), stop.reason)
def test_an_issue_that_cannot_move_to_the_merged_status_stops_and_says_what_to_do(self) -> None:
self.settings('jira-unblocking-statuses = ["Release Ready"]\njira-pull-request-merged-status = "Release Ready"\n')
self.store.fails = "Jira answered 503"
+2 -2
View File
@@ -472,13 +472,13 @@ class TheFirstPrompt(unittest.TestCase):
self.assertIn("make the chunk's worktree and branch off `origin/epic/ABC-12`", task)
self.assertIn("`chunk-pr merge` merges into `epic/ABC-12` without waiting for a person", task)
self.assertNotIn("leaves the pull request ready for a person to merge", task)
self.assertIn("Test each sibling repo at its branch `epic/ABC-12` where it has one, else at its default branch, and name in the chunk's summary each sibling that ran at its default branch.", task)
self.assertIn("Where the chunk's tests run other repos of the epic, run each at its branch `epic/ABC-12` where it has one, else at its default branch, and name in the chunk's summary each repo that ran at its default branch.", task)
self.assertNotIn("chunk-pr push", task)
def test_a_repo_whose_reviewer_is_asked_by_a_comment_is_told_to_push_with_chunk_pr(self) -> None:
config = dataclasses.replace(CONFIG, epic_branch="{epic}", review_request_comment="@reviewbot review")
task = chunk_prompt.task(issue("ABC-20"), "ABC-12", {}, "/code/api", pathlib.Path("/b/do-epic"), "Swedish", config)
self.assertIn("Push each later commit to the open pull request with `chunk-pr push`, which asks the repo's auto-reviewer for a review of the new head, and wait for that review.", task)
self.assertIn("After `chunk-pr ready`, push each commit with `chunk-pr push`, which asks the repo's auto-reviewer to review the new head, and wait for that review.", task)
def test_a_repo_without_an_epic_branch_is_told_nothing_of_one(self) -> None:
task = chunk_prompt.task(issue("ABC-20"), "ABC-12", {}, "/code/api", pathlib.Path("/b/do-epic"), "Swedish", dataclasses.replace(CONFIG, merge="human"))