Skip to content

Keep merge queue polling inside the wait budget - #1269

Closed
eowca wants to merge 4 commits into
mainfrom
lean178/1155-queue-budget-replacement
Closed

eowca wants to merge 4 commits into
mainfrom
lean178/1155-queue-budget-replacement

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

  • Supersedes Keep merge queue polling inside the wait budget #1214. Carries the approved diff from cd4bf5ff0e2b plus the merge resolution in the CLI tests.
    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 cd4bf5ff0e2b (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, 8ae6e30, approve

eowca and others added 3 commits November 26, 2026 01:10
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>
Architecture-Review: unchanged; the deadline applies to observations and leaves the merge request timeout in place.
Co-Authored-By: Codex <noreply@openai.com>
Architecture-Review: unchanged; the resolution preserves both branches’ CLI tests.
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 8ae6e30e0c806fb9b5fb424528f61c619562f7c5, 66.6s: approve (0 critical, 0 important, 3 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
return poll(0)
reported_timeout = False
try:
with github.bounded_reads(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: A landing verified just before the deadline can still be dropped when the budget scope closes

_landed calls read_timeout(0) after merged_sha, so a returned SHA was verified before the deadline. That SHA then goes back through poll, and the exit of github.bounded_reads (github.py:135) calls read_timeout(0) again. If the deadline passes in that short gap, ReadDeadline is raised and _queue_wait returns None. The command then exits 3 even though the landing was verified in time, which goes against the acceptance rule that a landing verified before the deadline proceeds to cleanup. github.merge(..., observation_deadline=...) has the same race, because _verify_merge_request returns a SHA inside bounded_reads. The window is only microseconds, so this is unlikely in practice. Smallest fix: in _queue_wait, keep sha and return it when it is truthy even if the scope exit raises ReadDeadline. Make the same change in merge(), or move the final check so it only runs on the None path.

Comment thread src/loopzero/cli.py
try:
sha = github.merge(config.repo, pr.number, config.merge_strategy, pr.head_sha, observation_deadline=admit_by)
except github.ReadDeadline:
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: A deadline during direct-merge verification is reported as a merge-queue timeout

_merge_and_follow maps any ReadDeadline from merge()'s post-write verification to None. cmd_merge then prints timed out waiting for the merge queue to land PR #N. On a branch without a merge queue, the PR may already be merged directly. The user then sees a queue message and exit 3 with no cleanup. A rerun recovers, but the message is misleading. Consider a neutral message such as timed out verifying the merge of PR #N; rerun to verify and clean up.

Comment thread src/loopzero/cli.py
def _landed(config: Config, pr: github.PR, closed: list[github.GhError]) -> str | None:
"""Merge SHA if landed; a closed-unmerged read is held as not final (GitHub lags a
queue merge) and re-raised by the caller only if it persists to the deadline."""
"""Merge SHA if landed; a closed-unmerged read is held as not final."""

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: _landed docstring lost the reason closed-unmerged reads are held

The old docstring explained that GitHub lags a queue merge, so a closed-unmerged read is held and only re-raised if it persists to the deadline. With _report_closed_observation, it is now re-raised, or printed as the last queue observation when the budget is spent. Keep a short note of this here or on _report_closed_observation so the double read_timeout(0) guards and the held-error handling stay understandable.

Architecture-Review: unchanged; existing wait semantics now bound queue observations while retaining current merge verification and transport behavior.

Co-Authored-By: Codex <noreply@openai.com>
@eowca

eowca commented Nov 26, 2026

Copy link
Copy Markdown
Contributor Author

Closed as superseded while refreshing the merge-queue wait fix for #1155. Merging current main required conflict resolution, and the installed reviewer refused the delta across that merge. The follow-up work is in #1780. Its current merge projection exceeds both size caps, and its full check found an upstream test stub that rejects the deadline keyword. #1155 remains open.

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