Stop the judge rather than show it under 50,000 characters of the transcript, read a twice-named record once, test the forge timeout and decide the merge stop from the pull requests found

This commit is contained in:
Lilleman
2026-11-20 00:45:49 +01:00
parent 5ed3a55e3a
commit f3af5e23fd
8 changed files with 56 additions and 19 deletions
+12 -7
View File
@@ -84,8 +84,8 @@ def planned(read: Plan | Failure, cut: LastCut, default: str, branch: str, outsi
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}", awaits_merge=bool(merges))
pulls = awaited_merges(weighed.carried, pick.release)
return NoItem(f"every item of release {version(pick.release)} in {where} waits.{merge_stop(pulls)}", awaits_merge=bool(pulls))
if first is None:
return NoItem(f"{where}'s items table holds no item.")
held = weighed.carried
@@ -100,13 +100,18 @@ def planned(read: Plan | Failure, cut: LastCut, default: str, branch: str, outsi
return NextChunk(held, first, f"{first.tagline}\n\n{first.detail}".strip(), branch, over, item_id is not None)
def awaited_merges(found: list[Item], release: Release) -> str:
"""The sentences that stop the working loop where items of release await a person's merge, naming each pull request with the items it finishes; empty where none does."""
pulls: dict[str, list[str]] = {}
def awaited_merges(found: list[Item], release: Release) -> dict[str, list[int]]:
"""Each pull request, as `#<number> <URL>`, that finishes items of release and awaits a person's merge, with those items' IDs."""
pulls: dict[str, list[int]] = {}
for item in found:
if item.release == release and item.awaits_merge:
pulls.setdefault(item.awaits_merge, []).append(str(item.id))
pulls.setdefault(item.awaits_merge, []).append(item.id)
return pulls
def merge_stop(pulls: dict[str, list[int]]) -> str:
"""The sentences that stop the working loop where pulls await a person's merge, naming each with the items it finishes; empty where none does."""
if not pulls:
return ""
named = "; ".join(f"{pull}, which finishes item{'s' if len(ids) > 1 else ''} {listed(ids, 'and')}" for pull, ids in pulls.items())
named = "; ".join(f"{pull}, which finishes item{'s' if len(ids) > 1 else ''} {listed([str(item_id) for item_id in 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."
@@ -475,4 +475,6 @@ class AwaitingMerge(unittest.TestCase):
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\"`, 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)
later = dataclasses.replace(items[0], id=9, release=(0, 2, 0), awaits_merge="#10 https://github.com/o/r/pull/10")
self.assertEqual(next_chunk.awaited_merges([*items, later], (0, 1, 0)), {"#7 https://github.com/o/r/pull/7": [1], "#8 https://github.com/o/r/pull/8": [2, 3]}, "a pull request that finishes only a later release's items doesn't count")
self.assertFalse(next_chunk.planned(Plan([dataclasses.replace(item, awaits_merge="", exempt="question") for item in items]), held.cut, "main", "item-{id}").awaits_merge)