Skip to content

Restart Mergify backoff when admission is confirmed - #1709

Closed
eowca wants to merge 3 commits into
mainfrom
lean178/1302-reset-queue-backoff
Closed

eowca wants to merge 3 commits into
mainfrom
lean178/1302-reset-queue-backoff

Conversation

@eowca

@eowca eowca commented Nov 26, 2026 •

Copy link
Copy Markdown
Contributor

Restart Mergify backoff when admission is confirmed

Context and goal

  • Goal: Observe a newly admitted PR at the initial poll interval.
  • Problem: A long admission wait leaves the landing phase at its longest backoff even when membership is newly confirmed.
  • Context: Keep the current schedule and total wait budget. Restart the interval on the single transition to confirmed membership.

Closes #1302

Acceptance

  • A fake-clock replay reaches the 120-second backoff before admission. The next landing read uses the initial interval and observes the merge.
  • Steady-state backoff, dequeue and changed-head verdicts, and the wait deadline retain their behavior.
  • Extend the existing replay with zero net new test lines.

Base

Base: 1778ec8

Notes

Supersedes the #1302 slice of #1425. The architecture still applies because the poll schedule has the same deadline and GitHub observations.

Validation

Recorded for 2156b3119513 (unverified, run loopzero check)

  • uv run --group dev ruff check src tests: exit 1

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

Review

Architecture-Review: unchanged; the initial interval resumes after confirmed admission with the same timeout and queue verdicts.
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 primary review by claude on 2156b3119513ac2db0c1934a9402403a857fd4e3, 26.3s: approve (0 critical, 0 important, 1 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.

Comment thread src/loopzero/cli.py
) -> Iterator[None]:
delay = WAIT_INTERVAL
while True:
was_admitted = admitted is not None and admitted()

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: The admission reset relies on a closure seeing a later rebinding of confirmed

_poll_until gets lambda: confirmed, checks it before each yield and checks it again after the yield to spot the transition. This works because Python closures capture variables, not values. When _wait_for_mergify sets confirmed = True inside the loop body, the second call sees the new value. I traced the unconfirmed replay: sleeps come out as [30, 60, 120] while unconfirmed. At t=210, membership is confirmed and delay resets to 30. The landing read at t=240 then sees the merge. Without the fix the sleeps would be [..., 120, 120], so the test does catch the regression. The steady-state, bounded and deadline paths are unchanged for callers that don't pass admitted.

The weak point is that the coupling is implicit. If someone later moves the confirmation into a helper that returns a new value without rebinding the local confirmed, the reset stops firing and nothing complains. A simpler alternative is to have _poll_until accept a value sent back by the caller (gen.send(...)), or to have the caller signal "reset now" directly. Either one makes the transition explicit and removes the second admitted() call. This is not blocking.

Architecture-Review: unchanged; the iterator reads the same confirmation transition and wait budget.
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 6af5ebf5dcee8dffde9c1bd7bdcbfae0ae8233fd, 12.6s: approve (0 critical, 0 important, 1 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.

Comment thread src/loopzero/cli.py
deferred_landing_read = False
print(f"PR #{pr.number} following Mergify queue {queue}; head {pr.head_sha[:12]}; waiting up to {timeout:g}s")
for _ in _poll_until(started, timeout):
polls = _poll_until(started, timeout, admitted=lambda: confirmed)

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: The polls binding changes nothing and nothing else uses it

for _ in _poll_until(...) already builds the generator once, before the loop starts, so naming it first does not change behavior. The admitted=lambda: confirmed closure reads the same confirmed variable either way, and _poll_until (cli.py:1310/1315) still checks it before and after each yield. polls is not read again in _wait_for_mergify, so there is no send/close or second use that would need the name. The change adds a line and a variable, and the commit title suggests an ordering fix that the code does not need. Smallest fix: revert to the one-line for _ in _poll_until(started, timeout, admitted=lambda: confirmed):. If there is a reason to keep it, say so in a comment.

Architecture-Review: unchanged; Mergify admission backoff and the existing fake-clock coverage are unchanged.
Co-Authored-By: Codex <noreply@openai.com>
@eowca

eowca commented Nov 26, 2026

Copy link
Copy Markdown
Contributor Author

Merged main at a6403fe4 into the approved head 6af5ebf5. The resolution adds no behavior change and adapts the approved regression to main’s shared fake clock.

git range-diff --no-color --diff-merges=remerge 1778ec85..6af5ebf5 a6403fe4..ab6daf76

1:  2156b311 = 1:  2156b311 Restart Mergify poll backoff at queue admission
2:  6af5ebf5 = 2:  6af5ebf5 Construct the admission poll iterator before its loop
-:  -------- > 3:  ab6daf76 Merge origin/main and resolve the conflict for #1709

Conflict resolution from git show --remerge-diff --format= --unified=0 ab6daf76

diff --git a/tests/test_cli.py b/tests/test_cli.py
remerge CONFLICT (content): Merge conflict in tests/test_cli.py
index fac7c537..2c88f694 100644
--- a/tests/test_cli.py
+++ b/tests/test_cli.py
@@ -4354,5 +4354 @@ def test_mergify_confirmed_wait_reads_pr_once_per_steady_poll(wt, gh, monkeypatc
-<<<<<<< 6af5ebf5 (Construct the admission poll iterator before its loop)
-        if confirmed and sum(sleeps) == 60:
-=======
-        if clock.now == 60:
->>>>>>> a6403fe4 (Reuse the PR reads that bracket hosted eligibility (#1766))
+        if confirmed and clock.now == 60:
@@ -4360 +4356 @@ def test_mergify_confirmed_wait_reads_pr_once_per_steady_poll(wt, gh, monkeypatc
-        return mergify.Membership() if confirmed or sum(sleeps) >= 210 else None
+        return mergify.Membership() if confirmed or clock.now >= 210 else None
@@ -4367 +4362,0 @@ def test_mergify_confirmed_wait_reads_pr_once_per_steady_poll(wt, gh, monkeypatc
-<<<<<<< 6af5ebf5 (Construct the admission poll iterator before its loop)
@@ -4369 +4364 @@ def test_mergify_confirmed_wait_reads_pr_once_per_steady_poll(wt, gh, monkeypatc
-    assert sleeps == ([30, 30] if confirmed else [30, 60, 120, 30])
+    assert clock.sleeps == ([30, 30] if confirmed else [30, 60, 120, 30])
@@ -4374,7 +4368,0 @@ def test_mergify_confirmed_wait_reads_pr_once_per_steady_poll(wt, gh, monkeypatc
-=======
-    assert cli._wait_for_mergify(config, pr, 60, confirmed=True) == "e" * 40
-    assert clock.sleeps == [30, 30]
-    assert configurations == [(REPO, "main", "main")] * 3
-    assert reads_at_membership == [1, 2, 3]
-    assert [c["argv"][:2] for c in gh.calls] == [detail] * 4
->>>>>>> a6403fe4 (Reuse the PR reads that bracket hosted eligibility (#1766))

Focused tests passed (82). The size gate passed at 8179/8,250 source lines and 13,784/13,850 test lines, with zero test-line growth. Awaiting your verification and the owner-priority landing order.

@eowca

eowca commented Nov 26, 2026

Copy link
Copy Markdown
Contributor Author

The local size numbers above apply to this PR head. Main advanced to 3f60c7f9 during the refresh. The hosted check tested a clean merge with that newer main and measured 8,251/8,250 source lines (1 over) and 13,815/13,850 test lines. The PR still adds zero test lines against current main. This draft is waiting for source headroom as well as owner verification and the landing order.

@eowca

eowca commented Nov 26, 2026

Copy link
Copy Markdown
Contributor Author

Lean verification of the conflict-only refresh (in place of a third review round): head ab6daf768e2b5621bfa2b7c7e956b056b02b0b97 keeps the approved commits unchanged (range-diff =) and adds one merge commit. I read the remerge diff: the resolution keeps both sides' intent and adds no behaviour change. Verified. This may land at exactly this head once the source cap has room (it is over by the hosted count) and its turn in the #575 landing order comes. Any further head change needs a new verification.

@eowca

eowca commented Nov 26, 2026

Copy link
Copy Markdown
Contributor Author

Superseded by #1813, which carries the verified net change from fresh main and has primary approval on its new head. Both review rounds on this PR were spent before the conflict-resolution merge.

@eowca eowca closed this Nov 26, 2026
mergify Bot pushed a commit that referenced this pull request Nov 26, 2026
Carry the verified net change from #1709.

Architecture-Review: unchanged; Mergify admission backoff and the existing fake-clock coverage are unchanged.

Architecture-Review: unchanged; the iterator reads the same confirmation transition and wait budget.
Architecture-Review: unchanged; the initial interval resumes after confirmed admission with the same timeout and queue verdicts.

Co-authored-by: eowca <4008965+eowca@users.noreply.github.com>
Co-authored-by: Codex <noreply@openai.com>
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.

Reset Mergify poll backoff when queue admission is confirmed

1 participant