Plan an epic's open issues before do-epic starts chunks
This commit is contained in:
@@ -34,6 +34,11 @@ from do_epic.test_do_epic import SETTINGS
|
||||
DESCRIPTION = "**Max parallel chunks:** 2\n\n## Goals\nShip the import.\n\n## Audience\nThe client's team.\n"
|
||||
|
||||
|
||||
def structured(output: object, key: str | None = "structured_output") -> subprocess.CompletedProcess[str]:
|
||||
"""claude's reply that holds output as its structured answer; as the whole result event where key is None."""
|
||||
return subprocess.CompletedProcess([], 0, json.dumps({"type": "result", key: output} if key else output), "")
|
||||
|
||||
|
||||
@dataclasses.dataclass(frozen=True)
|
||||
class Description:
|
||||
"""Stands in for an epic's description in Jira."""
|
||||
@@ -52,7 +57,7 @@ class DoEpicTest(unittest.TestCase):
|
||||
folder.mkdir(parents=True)
|
||||
(folder / "config.toml").write_text(SETTINGS, encoding="utf-8")
|
||||
(folder / "repo-rule.md").write_text("A label that equals a repo's name names that repo.\n", encoding="utf-8")
|
||||
self.issues = [issue("ABC-20"), dataclasses.replace(issue("ABC-21", "do-epic-claude"), detail="Tidy the docs.", scores={"L": 3, "E": 2, "I": 3})]
|
||||
self.issues = [issue("ABC-20", "do-epic-human"), dataclasses.replace(issue("ABC-21", "do-epic-claude"), detail="Tidy the docs.", scores={"L": 3, "E": 2, "I": 3})]
|
||||
self.description: str | Failure = DESCRIPTION
|
||||
# What the forge answers each read of a chunk's gate, in turn; the last answers every later read. No worktree has the chunk's branch, so no chunk parks.
|
||||
self.forges = [Forge(worktrees="worktree /code/api\nbranch refs/heads/main\n")]
|
||||
@@ -126,12 +131,34 @@ class TheCommand(DoEpicTest):
|
||||
code, out, _ = self.run_main(["ABC-12"], fake, {"LOOP_CLAUDE_WORKER_MODEL": "m"})
|
||||
self.assertEqual(code, 0)
|
||||
self.assertIn("started ABC-21 in the tmux session epic-ABC-12\n", out)
|
||||
self.assertIn("ABC-20 waits: no label names its repo\n", out)
|
||||
self.assertIn("ABC-20 waits: it is a human's task\n", out)
|
||||
started = [args for args in fake.tmux_calls if args[0] == "new-session"]
|
||||
self.assertEqual(started, [["new-session", "-d", "-s", "epic-ABC-12", "-n", "ABC-21", "-c", str(self.home / ".local/state/do-epic/ABC-12"), "-e", "LOOP_CLAUDE_WORKER_MODEL=m", "-e", "CHUNK_PR_PARKS=1", "-P", "-F", "#{window_id}", "--", "/b/do-epic", "--chunk", "ABC-21", "ABC-12"]])
|
||||
# The session is no checkout's, so nothing marks it as one's.
|
||||
self.assertNotIn(tmux.OWNER, [args[3] for args in fake.tmux_calls if args[0] == "set-option"])
|
||||
|
||||
def test_plans_an_issue_no_label_places_before_it_starts_the_chunks(self) -> None:
|
||||
self.issues = [issue("ABC-20")]
|
||||
fake = FakeEffects(on_terminal=False, claude=[structured({"parts": []}), structured({"pick": "claude"})])
|
||||
code, out, err = self.run_main(["ABC-12"], fake)
|
||||
self.assertEqual(code, 0, err)
|
||||
self.assertLess(out.index("ABC-20 is labelled do-epic-claude\n"), out.index("started ABC-20 in the tmux session epic-ABC-12\n"))
|
||||
|
||||
def test_starts_no_chunk_where_a_usage_limit_ends_the_planning(self) -> None:
|
||||
self.issues.append(issue("ABC-22"))
|
||||
limit = {"type": "result", "is_error": True, "api_error_status": 429, "result": "You've hit your limit"}
|
||||
fake = FakeEffects(claude=[structured(limit, None)])
|
||||
code, _, err = self.run_main(["ABC-12"], fake)
|
||||
self.assertEqual(code, 1)
|
||||
self.assertIn("the epic is not planned, so no chunk started: You've hit your limit\n", err)
|
||||
self.assertEqual([args for args in fake.tmux_calls if args[0] == "new-session"], [])
|
||||
|
||||
def test_stops_where_the_epic_cannot_be_planned(self) -> None:
|
||||
self.issues = [dataclasses.replace(issue(key, "do-epic-claude"), scores={"L": 1, "E": 1, "I": 1, "S": 1}, by_loop=True) for key in ("ABC-20", "ABC-21")]
|
||||
code, _, err = self.run_main(["ABC-12"], FakeEffects())
|
||||
self.assertEqual(code, 1)
|
||||
self.assertIn("states `Score = ...` 0 times under ## Scoring", err)
|
||||
|
||||
def test_stops_on_an_epic_it_cannot_read(self) -> None:
|
||||
self.description = Failure("Jira answered 401")
|
||||
code, _, err = self.run_main(["ABC-12"], FakeEffects())
|
||||
@@ -298,6 +325,15 @@ class TheHumansRun(DoEpicTest):
|
||||
|
||||
class AChunksRun(DoEpicTest):
|
||||
|
||||
def test_a_finished_chunk_starts_the_next_without_planning_again(self) -> None:
|
||||
self.issues.append(issue("ABC-22"))
|
||||
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.assertIn("the chunk finished; started no other\n", out)
|
||||
# The one claude call is the judge's: ABC-22, which no label places, waits for the human's do-epic.
|
||||
self.assertEqual(len(fake.made("claude")), 1)
|
||||
|
||||
def test_runs_cycles_until_the_judge_rules_it_finished_then_starts_the_next_chunk(self) -> None:
|
||||
self.issues.append(issue("ABC-22", "do-epic-claude"))
|
||||
self.description = DESCRIPTION.replace("2", "1")
|
||||
|
||||
Reference in New Issue
Block a user