Skip to content

Keep merge queue polling inside the wait budget - #1214

Closed
eowca wants to merge 2 commits into
mainfrom
lean178/1155-queue-wait-budget
Closed

eowca wants to merge 2 commits into
mainfrom
lean178/1155-queue-wait-budget

Conversation

@eowca

@eowca eowca commented Nov 26, 2026 •

Copy link
Copy Markdown
Contributor

Keep merge queue polling inside the wait budget

Context and goal

  • Goal: Queue observers stop at the existing merge wait deadline.
  • Problem: A short merge wait could accept a late landing or exceed its time budget retrying Mergify.
  • Context: Both backends share the monotonic deadline already used for source checks.

Closes #1155

Acceptance

  • Both queue backends cap reads to the remaining positive budget and admit no further poll or diagnostic read at expiry.
  • A landing verified before the deadline proceeds to cleanup. Late responses and exhausted retries exit 3 with a local timeout message.
  • An explicit zero wait makes one observation.

Notes

Keep the existing admission rules and read endpoints. Bound polling with the deadline already used for source checks. Preserve timeout diagnostics that can be rendered using observations already received.

  • Pre-fix: GitHub accepted the fake late response and started with a 120-second read timeout. Mergify raised HTTP 503 after its normal retries. The focused merge and queue regression suite passed after the fixes.

Base

main @ a4fa169

Validation

Recorded for c54f092cf2a1 (not current head)

  • 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

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

Review

  • primary, claude, c54f092, request_changes
  • delta, claude, cd4bf5f, approve

Architecture-Review: unchanged; queue admission and landing verification are unchanged while queue I/O now shares the existing wait 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 primary review by claude on c54f092cf2a1673166c6a140288f2e519b844ea8, 86.5s: request_changes (0 critical, 2 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/github.py Resolved
Comment thread src/loopzero/cli.py Resolved
Comment thread src/loopzero/cli.py
except (LoopZeroError, github.GhError, _proc.ProcTimeout):
github.read_timeout(0)
raise
except github.ReadDeadline:

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: A Mergify timeout hit during a read loses the queue detail already observed

If a read crosses the deadline, _queue_wait prints only the timeout_notice. The "still queued in {queue}. <candidate/dashboard URL>. Unmet candidate conditions: …" detail is dropped, even when state came back from an earlier membership read. That detail needs no further network call.

This is likely in the final bounded tick: it runs _landed, configured (which makes several Mergify and GitHub reads) and membership within remaining/2. It is also likely for short waits; the new test hits exactly this path. The task asks to keep diagnostics that can be built from observations already received.

Fix: have _wait_for_mergify record the last state somewhere _queue_wait's handler can reach (a holder object or a callback). On ReadDeadline, render _mergify_timeout_detail(..., query_report=False) from that state instead of the bare notice.

Architecture-Review: unchanged; the deadline applies to observations and leaves the merge request timeout in place.
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 cd4bf5ff0e2b77e27077957107edae7d524ec55b, 68.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/github.py
_gh(*argv, timeout=300)
except GhError as exc:
raise MergeFailed(exc.command, exc.tail) from exc
budget = (bounded_reads(observation_deadline, token=None, retry=True)

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: observation_deadline adds a parameter and a helper that the caller could replace with one with block

_gh reads _read_scope only for read-only argv (scope = _read_scope.get() if read_only else None, github.py:313). Now that the write uses a fixed timeout=300, wrapping the whole github.merge(...) call in github.bounded_reads(admit_by, token=None, retry=True) inside _merge_and_follow behaves the same way. The write stays uncapped, the verification reads are capped, and a late verification still raises ReadDeadline when the scope exits. So the keyword-only observation_deadline parameter, the nullcontext branch and the _verify_merge_request split are not needed. They also put cli deadline policy inside github.merge. Smallest fix: drop the parameter and the split, and scope the call in _merge_and_follow when admit_by is not None.

@eowca

eowca commented Nov 26, 2026

Copy link
Copy Markdown
Contributor Author

Superseded by #1269, which carries the approved changes and the resolution of the conflicts with main.

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.

Keep merge queue polling inside the existing --wait budget

1 participant