Answer product-owner round 1: 0 🔴, 1 🟡 (0 misread); stop loop-claude where every item left awaits a person's merge
CI / tests (pull_request) Successful in 3m23s

This commit is contained in:
Lilleman
2026-11-19 22:20:43 +01:00
parent 470be28759
commit 56c579bd54
8 changed files with 74 additions and 21 deletions
+29 -3
View File
@@ -402,7 +402,7 @@ class AwaitingMerge(unittest.TestCase):
def setUp(self):
self.repo = tempfile.mkdtemp()
self.addCleanup(subprocess.run, ["rm", "-rf", self.repo])
run = lambda *args: subprocess.run(["git", "-c", "user.name=t", "-c", "user.email=t@t", *args], capture_output=True, check=True, cwd=self.repo, env=isolated_env(), text=True).stdout.strip()
run = self.run = lambda *args: subprocess.run(["git", "-c", "user.name=t", "-c", "user.email=t@t", *args], capture_output=True, check=True, cwd=self.repo, env=isolated_env(), text=True).stdout.strip()
rows = lambda *ids: HEADER + "".join(ROW.format(id=id_, release="0.1.0") for id_ in ids)
run("init", "-q", "-b", "main")
run("remote", "add", "origin", "https://github.com/o/r")
@@ -426,6 +426,15 @@ class AwaitingMerge(unittest.TestCase):
def test_names_none_for_a_pull_request_whose_head_the_checkout_lacks_and_fails_where_the_forge_does(self):
unfetched = f"7\thttps://github.com/o/r/pull/7\t{'b' * 40}\tfalse\tfalse\n"
self.assertEqual(awaiting_merge.awaiting("main", plan_in(self.repo), self.repo, "gh", lambda command: unfetched), {})
self.assertEqual(awaiting_merge.awaiting("main", plan_in(self.repo), self.repo, "gh", lambda command: unfetched + self.listed), {1: "#7 https://github.com/o/r/pull/7"}, "the pull request listed after it still counts")
def test_names_none_for_a_pull_request_whose_head_holds_no_plan(self):
self.run("checkout", "-q", "-b", "planless")
self.run("rm", "-q", "todo.md")
self.run("commit", "-q", "-m", "Drop the plan")
planless = f"9\thttps://github.com/o/r/pull/9\t{self.run('rev-parse', 'HEAD')}\tfalse\tfalse\n"
self.run("checkout", "-q", "main")
self.assertEqual(awaiting_merge.awaiting("main", plan_in(self.repo), self.repo, "gh", lambda command: planless), {})
self.assertEqual(awaiting_merge.awaiting("main", plan_in(self.repo), self.repo, "gh", lambda command: Failure("gh: no network")).reason, "gh: no network")
def test_the_projects_plan_passes_over_an_item_that_awaits_a_persons_merge(self):
@@ -433,6 +442,8 @@ class AwaitingMerge(unittest.TestCase):
self.assertEqual([(item.id, item.awaits_merge) for item in held.plan.items], [(1, "#7 https://github.com/o/r/pull/7"), (2, ""), (3, ""), (4, "")])
self.assertIsNone(held.merges_unread)
self.assertEqual(release_standing.chunk_item(held.plan.items, held.cut).item.id, 2)
self.assertEqual(next_chunk.planned(held.plan, held.cut, "main", "item-{id}", item_id=1), next_chunk.NoItem("item 1, the one --item names, is finished on the branch of pull request #7 https://github.com/o/r/pull/7, which awaits a person's merge."))
self.assertEqual(next_chunk.planned(held.plan, held.cut, "main", "item-{id}", item_id=2).first.id, 2)
self.assertEqual([item.id for item in todo_table.bundle_candidates(held.plan.items, held.plan.items[1])], [3, 4])
def test_the_projects_plan_asks_no_forge_where_the_chunk_merges_or_no_forge_is_given(self):
@@ -441,12 +452,27 @@ class AwaitingMerge(unittest.TestCase):
self.assertEqual((asked, [item.awaits_merge for item in chunk.plan.items]), ([], [""] * 4))
self.assertEqual([item.awaits_merge for item in release_standing.project_plan(self.config, "main", self.repo).plan.items], [""] * 4)
def test_the_projects_plan_asks_no_forge_about_a_plan_kept_outside_the_checkout(self):
outside = pathlib.Path(tempfile.mkdtemp())
self.addCleanup(subprocess.run, ["rm", "-rf", str(outside)])
(outside / "todo.md").write_text(pathlib.Path(self.repo, "todo.md").read_text())
asked: list[list[str]] = []
held = release_standing.project_plan(dataclasses.replace(self.config, paths=self.config.paths | {"plan": outside / "todo.md"}), "main", self.repo, forge_run=lambda command: asked.append(command) or self.listed)
self.assertEqual((asked, [item.awaits_merge for item in held.plan.items]), ([], [""] * 4))
def test_the_projects_plan_says_why_where_the_forge_cannot_list_the_pull_requests(self):
held = release_standing.project_plan(self.config, "main", self.repo, forge_run=lambda command: Failure("gh: no network"))
self.assertEqual(([item.awaits_merge for item in held.plan.items], held.merges_unread.reason), ([""] * 4, "gh: no network"))
self.run("remote", "remove", "origin")
remoteless = release_standing.project_plan(self.config, "main", self.repo, forge_run=lambda command: self.listed)
self.assertEqual([item.awaits_merge for item in remoteless.plan.items], [""] * 4)
self.assertIsInstance(remoteless.merges_unread, Failure)
def test_says_which_pull_requests_await_a_merge_where_every_item_left_waits(self):
held = release_standing.project_plan(self.config, "main", self.repo, forge_run=lambda command: self.listed)
items = [dataclasses.replace(item, awaits_merge="#8 https://github.com/o/r/pull/8" if item.id != 1 else item.awaits_merge) for item in held.plan.items]
items = [dataclasses.replace(item, awaits_merge="#8 https://github.com/o/r/pull/8" if item.id in (2, 3) else item.awaits_merge) for item in held.plan.items]
items[3] = dataclasses.replace(items[3], exempt="question")
none = next_chunk.planned(Plan(items), held.cut, "main", "item-{id}")
self.assertEqual(none.why, "every item of release 0.1.0 in main's todo.md waits. Under `merge = \"human\"`, a person's merge is awaited of pull request #7 https://github.com/o/r/pull/7, which finishes item 1 and #8 https://github.com/o/r/pull/8, which finishes items 2, 3 and 4. The working loop stops here until one is merged.")
self.assertEqual(none.why, "every item of release 0.1.0 in main's todo.md waits. Under `merge = \"human\"`, these pull requests await a person's merge: #7 https://github.com/o/r/pull/7, which finishes item 1; #8 https://github.com/o/r/pull/8, which finishes items 2 and 3. The working loop stops here. Once a person has merged one, or turned one back into a draft, run loop-claude again.")
self.assertTrue(none.awaits_merge)
self.assertFalse(next_chunk.planned(Plan([dataclasses.replace(item, awaits_merge="", exempt="question") for item in items]), held.cut, "main", "item-{id}").awaits_merge)