Repository navigation
Serialize Mergify queue requests and reconcile transient failures - #1951
Conversation
Architecture-Review: unchanged; admission uses the existing worktree lock and the existing marker proof, with confirmed HTTP rate limits preserving the transport diagnostic. Co-Authored-By: Codex <noreply@openai.com>
There was a problem hiding this comment.
loopzero primary review by claude on 5240ad605d39a80c6d5cee33fbac3a253af85f52, 66.1s: approve (0 critical, 0 important, 4 suggestion)
Settings per native call (launch configuration and CLI claims, not backend attestation):
- Call 1: requested model claude-opus-5-5 (effort medium); CLI-reported model claude-opus-5-5 (effort unknown); configured model claude-opus-5-5 (effort medium)
Findings without a file location:
- suggestion: Confirmed-marker writes while polling are still not serialized — The patch serializes the request and the admission-time
mark_confirmed. But_wait_for_mergifystill callsmergify.mark_confirmedwithout the lock or a recheck. Two concurrentmerge --waitinvocations that both started withconfirmed=Falsewill each post a CONFIRMED marker comment once membership appears. The comments are harmless but duplicated, and this is the same defect class the change targets. If you want consistency, take the lock and recheckmarkers()[1]before posting, or document that duplicate confirmed markers are tolerated.
Native Claude output is retained in the restricted local review receipt.
| try: | ||
| github._api(f"repos/{repo}/issues/{number}/comments", {"body": body}) | ||
| except (github.GhError, github.ProcTimeout, OSError) as exc: | ||
| if getattr(exc, "confirmed_rate_limit", False) or not markers(repo, number, head, queue)[0]: |
There was a problem hiding this comment.
suggestion: A failed reconciliation read hides the original POST error
If the POST fails without a confirmed rate limit (a 5xx, ProcTimeout or OSError) and the follow-up markers() read also fails (for example, it is rate-limited or times out), the read's exception replaces the POST's. The POST error only survives as __context__, and the CLI prints str(exc), so the user sees a GET comments failure instead of the failed queue command. Smallest fix: wrap the reconciliation read in try/except (github.GhError, github.ProcTimeout, OSError): raise exc from None. That way an unverifiable reconciliation re-raises the original POST diagnostic.
| if not confirmed and confirmed_marker: | ||
| closed: list[github.GhError] = [] | ||
| if sha := _mergify_departure(config, pr, queue, closed, confirmed=True): | ||
| with worktree.lock_local_state(wt): |
There was a problem hiding this comment.
suggestion: The admission lock covers slow work, waits a fixed 60s and ignores admit_by
lock_local_state waits a fixed 60 seconds and then raises TimeoutError('task state is busy'). Merge now holds this lock for the whole admission phase: GitHub reads, _mergify_departure, and _prequeue_size_budget. The size budget clones, fetches and runs up to two scripts, each with GIT_TIMEOUT=60s. cmd_check also holds the same lock for an entire check run. As a result, a second merge --wait can fail with 'busy' instead of following the queue the first invocation already joined. A merge started during a check also fails after 60s, where it previously went ahead. The 60s wait also ignores admit_by, so a positive --wait can run past its admission budget. This stays safe (no duplicate POST), but users have to retry. Consider one of these: run _prequeue_size_budget before taking the lock, then recheck markers under the lock; or make the lock wait respect admit_by/deadline when one is set.
| else: | ||
| assert "queue configuration is unverified" in err | ||
|
|
||
| @pytest.mark.parametrize(("accepted", "transient"), [(True, False), (False, False), (True, True)]) |
There was a problem hiding this comment.
suggestion: No test covers releasing the lock before queue polling
The new concurrency test only runs merge without --wait, so _wait_for_mergify is never reached. The acceptance item 'Release the existing worktree lock before queue polling' has no test: a later change that moves the with block around the wait would still pass. Add a --wait case that checks the local-state lock can be acquired (for example, with a non-blocking flock) while _wait_for_mergify runs.
|
@Mergifyio queue |
✅ Merged into
|
|
No description provided. |
Serialize Mergify queue requests and reconcile transient failures
Context and goal
Closes #1327
Supersedes #1806. The independent fix review approved the rate-limit correction but was unregistered on that PR.
Acceptance
Base
Base: fef55ed
Validation
Recorded for
c540d2216af6uv run --group dev ruff check src tests: exit 0uv run --group dev tach check: exit 0uv run --python 3.14 python scripts/check_architecture_docs.py: exit 0scripts/size_budget.sh: exit 0uv run --group dev pytest -q: exit 0(filled by loopzero check)
Review
(filled by loopzero review)
Open in [code]smith · Need help on this PR? Tag
@codesmith-botwith what you need.