Skip to content

Honor Retry-After on Mergify queue observations - #1757

Merged
mergify[bot] merged 4 commits into
mainfrom
lean178/1499-mergify-retry-after-v2
Nov 26, 2026
Merged

mergify[bot] merged 4 commits into
mainfrom
lean178/1499-mergify-retry-after-v2

Conversation

@eowca

@eowca eowca commented Nov 26, 2026 •

Copy link
Copy Markdown
Contributor

Context and goal

Honor Retry-After on Mergify queue reads and make at most one automatic retry. Carry the merge deadline through the initial configuration observations and stop when the delay cannot fit.

Closes #1499. Supersedes #1563 after main added distinct transport and JSON diagnostics. The replacement preserves both diagnostics.

Validation

Recorded for 10614414ecec

  • uv run --group dev ruff check src tests: exit 0
  • uv run --group dev tach check: exit 0
  • uv run --python 3.14 python scripts/check_architecture_docs.py: exit 0
  • scripts/size_budget.sh: exit 0
  • uv run --group dev pytest -q: exit 0

Focused Mergify API and CLI replays passed after resolving the conflict. They cover persistent throttling, an absent deadline, an insufficient deadline, terminal transport errors, and retry counts. Python source +23 lines, tests −1.


Open in [code]smith · Need help on this PR? Tag @codesmith-bot with what you need.

Review

eowca and others added 2 commits November 26, 2026 10:21
Co-Authored-By: Codex <noreply@openai.com>
…retry-after-v2

# Conflicts:
#	src/loopzero/cli.py
#	tests/test_mergify.py

@loopzero-feder-positronics loopzero-feder-positronics Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

loopzero primary review by claude on d3973c45f04e37674707fb645b6f973105f3631c, 51.8s: 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: ready --wait doesn't pass the wait deadline to its first readiness read, but merge --wait does — cmd_merge now computes deadline before calling _pr_readiness and passes it as mergify_deadline. With --wait=0, that means the first mergify.configured read happens once and is not retried. cmd_ready calls _pr_readiness without mergify_deadline, so its first Mergify configuration read falls back to the no-deadline path, which allows a 2s backoff, even for ready --wait=0. Its later polls in _wait_for_checks do use started + timeout. So the same --wait budget gives different retry behavior depending on the command, which doesn't match the requirement to use the caller's wait deadline for retry admission. Smallest fix: move started = time.monotonic() above the _pr_readiness call in cmd_ready and pass mergify_deadline=None if args.wait is None else started + args.wait, as cmd_merge does.

Native Claude output is retained in the restricted local review receipt.

Comment thread src/loopzero/mergify.py
except (OSError, json.JSONDecodeError, UnicodeDecodeError, http.client.IncompleteRead) as exc:
detail, transient = _queue_read_failure(exc)
if not retry or not transient:
raise MergifyError(detail)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

suggestion: Queue read errors no longer keep the original exception

The old code raised MergifyError(...) from exc. The new code raises MergifyError(detail) after the except block has ended, so the error has neither __cause__ nor __context__. HTTP, socket and TLS tracebacks for a failed queue read are lost. Smallest fix: keep the caught exception (for example, error = exc in both handlers) and raise MergifyError(detail) from error at both raise sites (lines 125 and 127).

Comment thread src/loopzero/mergify.py
raise MergifyError(detail)
if not _wait_to_retry(delay, deadline):
raise MergifyError(f"{detail}; retry delay exceeds the wait budget")
return None

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

suggestion: Removed blank line leaves only one blank line between top-level functions

The diff deletes one of the two blank lines between api_get and _unmet_conditions. Ruff doesn't fail on this because the configured rule set doesn't include E3. It's still inconsistent with the rest of the module. Fix: restore the second blank line.

Comment thread src/loopzero/mergify.py
if not retry or not transient:
raise MergifyError(detail)
if not _wait_to_retry(delay, deadline):
raise MergifyError(f"{detail}; retry delay exceeds the wait budget")

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

suggestion: Over-budget message mentions a wait budget that may not exist

Without a deadline (plain merge, status, or the hosted api_get callers), the 5s cap is internal. A 429 with Retry-After: 40 then reports "retry delay exceeds the wait budget", even though the user gave no wait budget. When deadline is None, consider wording such as "exceeds the unattended retry limit", so the explanation points the user to --wait as the remedy.

eowca and others added 2 commits November 26, 2026 13:28
Architecture-Review: unchanged; conflict resolution preserves the existing deadline and readiness documentation alongside main’s receipt and polling behavior.
Co-Authored-By: Codex <noreply@openai.com>
Architecture-Review: unchanged; the merged readiness helper preserves receipt reporting and forwards the existing retry deadline.
Co-Authored-By: Codex <noreply@openai.com>

@loopzero-feder-positronics loopzero-feder-positronics Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

loopzero delta review by claude on 10614414ecec4b900392b776e1b2df7052e5efd9, 17.9s: approve (0 critical, 0 important, 0 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)

Native Claude output is retained in the restricted local review receipt.

@eowca

eowca commented Nov 26, 2026

Copy link
Copy Markdown
Contributor Author

@Mergifyio queue

@mergify

mergify Bot commented Nov 26, 2026 •

Copy link
Copy Markdown

✅ Merged into main as 3360004 at 12:49 UTC

Less than a minute in the queue, with no time running CI.

So far

  • ✅ Entered the queue Thu 26 Nov, 12:48 · rule main · triggered by @eowca with the @mergifyio queue command
  • ✅ Checks skipped · PR is already up-to-date
  • ✅ Merged 12:49 · 3360004 · squash
3 merge conditions met
  • github-review-approved · required by GitHub repository ruleset rule main: PR only, Mergify queue, existing checks required
  • any of · required by GitHub repository ruleset rule main: PR only, Mergify queue, existing checks required:
    • check-success = checks
    • check-neutral = checks
    • check-skipped = checks
  • any of · required by GitHub repository ruleset rule main: PR only, Mergify queue, existing checks required:
    • check-success = Loop-zero Eligibility
    • check-neutral = Loop-zero Eligibility
    • check-skipped = Loop-zero Eligibility

Times in UTC · dashboard · how the merge queue works

@mergify mergify Bot added the queued label Nov 26, 2026
@mergify
mergify Bot merged commit 3360004 into main Nov 26, 2026
14 checks passed
@mergify mergify Bot removed the queued label Nov 26, 2026
@eowca
eowca deleted the lean178/1499-mergify-retry-after-v2 branch November 26, 2026 12:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Honor Retry-After on Mergify queue reads

1 participant