Answer stability round 2: 0 🔴, 4 🟡 (0 misread); each survivor it named has a test that kills it
This commit is contained in:
@@ -53,15 +53,16 @@ merge merges the pull request in its turn: the chunks of one project on this
|
||||
ruling, since that ruling read a head that no longer merges;
|
||||
- where a check fails, or, on Gitea, where the checks have not all passed within 30
|
||||
minutes; on GitHub, gh watches them until they end;
|
||||
- where another pull request still holds the turn after 30 minutes, naming it;
|
||||
- where other pull requests still hold the turn after 30 minutes, naming the last;
|
||||
- with `wait-for-approval`: where a reviewer requested changes, where the protection
|
||||
requires no review, on Gitea, where it cannot read the config, and after 90 minutes
|
||||
without an approval;
|
||||
- with `wait-for-approval`, approved or not: where a reviewer's comment waits for an
|
||||
answer, which is a review thread nobody resolved whose last comment is not the pull
|
||||
request author's. Answer it in its thread and push any fix.
|
||||
A run can last the 30 minutes in the queue, the checks and the 90 minutes together. One
|
||||
killed before that left the branch pushed, so run it again.
|
||||
A run that waits for an approval takes two turns, so it can last the 90 minutes and,
|
||||
twice, the 30 minutes in the queue and the checks. One killed before that left the
|
||||
branch pushed, so run it again.
|
||||
clean acts once the forge reports the branch's pull request merged at the commit checked out,
|
||||
by any merge method. It fetches origin, fast-forwards the main checkout to origin's
|
||||
default branch, removes the chunk's worktree, then deletes the local branch; origin's
|
||||
@@ -337,7 +338,7 @@ def merged(run: Run, sleep: typing.Callable[[float], None] = time.sleep, finishe
|
||||
if ready:
|
||||
return done if isinstance(done, Failure) else f"Merged pull request #{number} ({method.removeprefix('--')}).{absent}"
|
||||
except Held as held:
|
||||
return Failure(f"pull request #{held.args[0] or '?'} has held the merge queue for {QUEUE_SECONDS // 60} minutes, so this one took no turn; run chunk-pr merge again")
|
||||
return Failure(f"the merge queue stayed held for {QUEUE_SECONDS // 60} minutes, last by pull request #{held.args[0] or '?'}, so this one took no turn; run chunk-pr merge again")
|
||||
except OSError as failure:
|
||||
return Failure(f"cannot take a turn in the merge queue, {file}: {failure.strerror}")
|
||||
waited = approved(number, run, sleep)
|
||||
@@ -357,7 +358,7 @@ def unplanned(run: Run, finishes: typing.Sequence[list[str]]) -> str | Failure:
|
||||
|
||||
|
||||
class Held(Exception):
|
||||
"""Another pull request, whose number is the argument, kept the merge queue for QUEUE_SECONDS."""
|
||||
"""Other merges kept the queue for QUEUE_SECONDS; the argument is the number of the pull request that held it last."""
|
||||
|
||||
|
||||
@contextlib.contextmanager
|
||||
|
||||
@@ -612,6 +612,20 @@ class MergeQueue(unittest.TestCase):
|
||||
self.assertEqual([command[3] for command in changes(checkout)[:-1]], ["add", "commit", "origin"])
|
||||
self.assertEqual(changes(checkout)[-1], ["gh", "pr", "merge", "12", "--merge", "--match-head-commit", "f00d"])
|
||||
|
||||
def test_each_item_the_plan_no_longer_holds_is_named(self):
|
||||
checkout, _ = self.with_plan(Checkout(GITHUB, open=True), held=False)
|
||||
checkout.answers[(self.TODO_ITEM, "show", "8")] = Failure("todo-item show 8: todo.md holds no item 8")
|
||||
self.assertIn("The plan held no item 7, 8 when merge began", str(merged(checkout.__call__, finishes=[["7"], ["8"]])))
|
||||
|
||||
def test_a_plan_that_turns_unreadable_inside_the_turn_leaves_it_unmerged(self):
|
||||
checkout, _ = self.with_plan(Checkout(GITHUB, open=True))
|
||||
run, shows = checkout.__call__, []
|
||||
def run_whose_second_show_fails(command: list[str]) -> str | Failure:
|
||||
shows.extend([command] if command[1:2] == ["show"] else [])
|
||||
return Failure("todo-item show 7: unreadable") if command[1:2] == ["show"] and len(shows) == 2 else run(command)
|
||||
self.assertEqual(merged(run_whose_second_show_fails, finishes=[["7"]]), Failure("todo-item show 7: unreadable"))
|
||||
self.assertNotIn([self.TODO_ITEM, "finish", "7"], checkout.ran)
|
||||
|
||||
def test_a_finish_that_changes_no_file_commits_and_pushes_nothing(self):
|
||||
for clean in ("status", "records"):
|
||||
with self.subTest(clean):
|
||||
@@ -732,7 +746,7 @@ class MergeQueue(unittest.TestCase):
|
||||
checkout.answers[(self.CONFIG, "comprehension-history")] = "/elsewhere/history.md\n"
|
||||
self.assertEqual(merged(checkout.__call__), "Merged pull request #12 (merge).")
|
||||
self.assertNotIn("log", [command[1] for command in checkout.ran])
|
||||
for failing in (ruled, ("git", "rev-list", "--count", "bead..origin/main")):
|
||||
for failing in (ruled, ("git", "rev-list", "--count", "bead..origin/main"), ("git", "rev-parse", "--show-toplevel")):
|
||||
with self.subTest(failing):
|
||||
checkout = Checkout(GITHUB, open=True)
|
||||
checkout.answers.update({(self.CONFIG, "comprehension-history"): "/checkout/history.md\n", ruled: "bead\n"})
|
||||
@@ -749,9 +763,11 @@ class MergeQueue(unittest.TestCase):
|
||||
def test_a_queue_another_pull_request_holds_for_half_an_hour_leaves_it_unmerged_naming_the_holder(self):
|
||||
checkout = Checkout(GITHUB, open=True)
|
||||
slept: list[float] = []
|
||||
with turn(pathlib.Path(GIT_FOLDER.name) / QUEUE, "1234", lambda seconds: None):
|
||||
pass
|
||||
with turn(pathlib.Path(GIT_FOLDER.name) / QUEUE, "31", lambda seconds: None):
|
||||
failed = merged(checkout, slept.append)
|
||||
self.assertEqual(failed, Failure("pull request #31 has held the merge queue for 30 minutes, so this one took no turn; run chunk-pr merge again"))
|
||||
self.assertEqual(failed, Failure("the merge queue stayed held for 30 minutes, last by pull request #31, so this one took no turn; run chunk-pr merge again"))
|
||||
self.assertEqual((sum(slept), set(slept), changes(checkout)), (30 * 60, {10}, []))
|
||||
|
||||
def test_a_queue_freed_while_it_waits_gives_it_the_turn(self):
|
||||
|
||||
+1
-1
@@ -84,7 +84,7 @@ Valid while the archive's file names, the Vocabulary and the panel keep these wo
|
||||
2026-11-15, lilleman's call of 2026-11-13 in item 374, which split item 361. Serves goals 1.5 and 1.4: with several chunks open, every chunk removed its item from `todo.md` and added a bullet to `CHANGELOG.md` in its branch, so each merge left the others a conflict, a gate rerun and often a review round. `chunk-pr merge --finish <ID>` now makes those edits in the chunk's turn, on top of every chunk merged before. The worker's choices follow. The first differs from the call, and the rest settle what it left open:
|
||||
|
||||
- **A merge of the default branch, where the call said rebase.** A rebase rewrites commits the pull request already shows. The forge then drops the approval and the review threads' places. rule-hook counts a pass's rounds by the branch's commit titles, and a rebase gives each of those commits a new hash. `chunk-pr sync` already merges, and the turn reuses it.
|
||||
- **The queue is a file in the git folder the checkout's worktrees share**, held with flock for the turn (`bin/chunk_pr/main.py` → `QUEUE`). Every chunk of the project on the machine finds it without a config or a key. Two machines don't share it: there the second chunk merges without the first one's changes in its head, unless the branch protection requires an up-to-date branch. A turn lasts as long as its checks, which chunk-pr waits 30 minutes for on Gitea. So a merge waits 30 minutes for its turn, then fails naming the pull request that holds the queue, whose number the holder writes into the file.
|
||||
- **The queue is a file in the git folder the checkout's worktrees share**, held with flock for the turn (`bin/chunk_pr/main.py` → `QUEUE`). Every chunk of the project on the machine finds it without a config or a key. Two machines don't share it: there the second chunk merges without the first one's changes in its head, unless the branch protection requires an up-to-date branch. A turn lasts as long as its checks, which chunk-pr waits 30 minutes for on Gitea. So a merge waits 30 minutes for its turn, then fails naming the pull request that held the queue last, whose number the holder writes into the file.
|
||||
- **The turn holds the queue through the checks**, so what merges is what the checks ran on. A project without forge checks waits the minute `chunk-pr --help` names.
|
||||
- **The wait for an approval is outside the turn.** The first turn pushes the finished branch, so the approver reads what merges. Once approved, the pull request takes a new turn. Where the default branch moved meanwhile, that turn merges it in, and a branch protection that dismisses approvals on a push asks the approver again. A finish that fails is pushed with whatever the turn merged in, so the pull request's head stays the commit checked out. `larv-review scoring-run-owed` runs after the finish is committed, since it counts as shipped the items the committed plan no longer holds.
|
||||
- **A reviewer's comment ends the wait, in place of the loop watching for one.** `chunk-pr merge` runs in the worker's own session, so its failure is what resumes the worker, which answers and runs it again. A comment that waits is a review thread nobody resolved whose last comment someone other than the pull request's author wrote: the worker answers as that author, so an answered thread waits for the reviewer again. A comment outside a thread doesn't end the wait, since bots write those too. An approved pull request with such a thread stays unmerged too: a client's reviewer who approves and asks for one more thing gets an answer first.
|
||||
|
||||
Reference in New Issue
Block a user