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
+10 -3
View File
@@ -40,6 +40,8 @@ class NextChunk:
class NoItem:
"""Why the plan names no item for the next chunk, as a sentence the worker reads."""
why: str
# Whether why names pull requests that await a person's merge, so that no chunk starts until one is merged.
awaits_merge: bool = False
def cut_name(cut: LastCut) -> str | None:
@@ -81,8 +83,11 @@ def planned(read: Plan | Failure, cut: LastCut, default: str, branch: str, outsi
return NoItem(f"{where} holds no item for {upcoming}, and changes are unreleased, and its release review has landed, so that release is finished and ready to cut. The working loop stops here. If todo.md renamed that release instead, add `- <old release> renamed to <new release>` to todo.md's `## Renamed` section.")
return NoItem(f"{where} holds no item for {upcoming}, and no change is unreleased, so that release is to be planned first.")
first = pick.item
if first is None and pick.release is not None:
merges = awaited_merges(weighed.carried, pick.release)
return NoItem(f"every item of release {version(pick.release)} in {where} waits.{merges}", bool(merges))
if first is None:
return NoItem(f"every item of release {version(pick.release)} in {where} waits.{awaited_merges(weighed.carried, pick.release)}" if pick.release is not None else f"{where}'s items table holds no item.")
return NoItem(f"{where}'s items table holds no item.")
held = weighed.carried
# Every carried item takes one release, the next.
over = CarriedOver(next(item.release for item in held if item.id == weighed.moved[0]), weighed.moved) if weighed.moved else None
@@ -90,6 +95,8 @@ def planned(read: Plan | Failure, cut: LastCut, default: str, branch: str, outsi
first = next((item for item in held if item.id == item_id), None)
if first is None:
return NoItem(f"{where} holds no item {item_id}, the one --item names; it may have shipped.")
if first.awaits_merge:
return NoItem(f"item {item_id}, the one --item names, is finished on the branch of pull request {first.awaits_merge}, which awaits a person's merge.")
return NextChunk(held, first, f"{first.tagline}\n\n{first.detail}".strip(), branch, over, item_id is not None)
@@ -101,5 +108,5 @@ def awaited_merges(found: list[Item], release: Release) -> str:
pulls.setdefault(item.awaits_merge, []).append(str(item.id))
if not pulls:
return ""
named = listed([f"{pull}, which finishes item{'s' if len(ids) > 1 else ''} {listed(ids, 'and')}" for pull, ids in pulls.items()], "and")
return f" Under `merge = \"human\"`, a person's merge is awaited of pull request {named}. The working loop stops here until one is merged."
named = "; ".join(f"{pull}, which finishes item{'s' if len(ids) > 1 else ''} {listed(ids, 'and')}" for pull, ids in pulls.items())
return f" Under `merge = \"human\"`, these pull requests await a person's merge: {named}. The working loop stops here. Once a person has merged one, or turned one back into a draft, run loop-claude again."
+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)