Skip to content

Shorten waits for Mergify landing and source checks - #1425

Closed
eowca wants to merge 7 commits into
mainfrom
lean178/1302-1303-polling-v2
Closed

eowca wants to merge 7 commits into
mainfrom
lean178/1302-1303-polling-v2

Conversation

@eowca

@eowca eowca commented Nov 26, 2026 •

Copy link
Copy Markdown
Contributor

Shorten waits for Mergify landing and source checks

Context and goal

  • Goal: Detect a landed PR promptly after Mergify admission and give source checks a later final observation.
  • Problem: The queue poller carries admission backoff into the landing phase. The source waiter can miss a check that passes after its last observation.
  • Context: Both waiters use the same polling schedule. Queue admission resets the interval once. The source waiter reserves time for its last full readiness pass based on measured poll latency inside the existing deadline.

Fixes #1302
Fixes #1303

Replaces #1334, which exhausted its review rounds while the test-line cap blocked delivery. #1352 raised the cap to 13,850.

Acceptance

  • After admission following capped backoff, the next landing observation uses the initial jittered interval. Stable membership keeps backing off, and dequeue, changed heads and the deadline keep their verdicts.
  • Ready and merge observe a green check that arrives after the old midpoint. A read that exhausts the deadline still times out, and a zero budget observes once.

Base

Base: 2ef0b72

Notes

Offline replays failed before the fix. Landing was first detected at 313.5s and is now detected at 228s following admission at 199.5s. Ready and merge both returned timeout before the fix for the late-green cases. The focused tests pass with the fix, including timeout when a read exhausts its remaining allowance and the existing zero-budget and queue verdicts.
The full suite caught a one-second wait that needs 250ms for the final read. The final interval now preserves up to half a second for short waits, bounded by half the remaining time. The short-budget case and audit replays pass together.
The 49 focused offline tests pass, including seven seconds of fake read latency. The replacement merges current main. Its test count is 13,567 against the 13,850 limit.
Short waits also measure the first live readiness read, even when the waiter reuses that result. The ready and merge replays with 1.25 seconds of fake read time failed on the primary-reviewed head and pass with this change.

Validation

Recorded for 7b90ec904918 (not current head) (unverified, run loopzero check)

  • 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, 7b90ec9, request_changes
  • delta, claude, b21c22b, approve

eowca and others added 6 commits November 26, 2026 02:34
Architecture-Review: unchanged; polling cadence changes preserve the wait budget and exact-head checks.
Co-Authored-By: Codex <noreply@openai.com>
Architecture-Review: unchanged; the bounded read retains its original deadline.
Co-Authored-By: Codex <noreply@openai.com>
Architecture-Review: unchanged; the adaptive allowance stays inside the existing source 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 7b90ec90491864282943d3cc17f2a4b1b6fa6025, 41.6s: request_changes (0 critical, 1 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.

Comment thread src/loopzero/cli.py Resolved
Architecture-Review: unchanged; readiness uses the original deadline and checks.
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 b21c22bf53a6948236f3f4e44e581ff83b423a50, 24.1s: 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
mergify.dequeue(config.repo, pr.number)
print(f"requested removal of PR #{pr.number} from Mergify")
return 0
read_started = time.monotonic()

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: Seeded read latency covers more work than a poll read

initial_read_time times all of _pr_readiness. That covers worktree.branch/worktree.head, pr_for_branch, _require_pushed and _readiness(..., announce_receipt=True). A later poll read in _wait_for_checks only runs pr_view, _verify_wait_snapshot and _readiness. When the initial read is the slowest read, 2 * longest_read can overstate the final-read cost. The allowance is capped at remaining / 2, so the final observation still happens. It may just come earlier than it needs to, which works against the late-green goal. If this matters in practice, a cheap fix is to start the timer just before the _readiness call inside _pr_readiness, for example by returning the elapsed time from there. Otherwise, a one-line comment saying the seed is a deliberate overestimate would explain the trade-off. In the test, the initial read path does not call github.pr_view, so the -read_time clock offset correctly charges exactly one read_time to the initial read.

@eowca

eowca commented Nov 26, 2026

Copy link
Copy Markdown
Contributor Author

Parked at the approved head. An offline clean merge into 29a3f882 and the repository size gate measured 13,926 test lines against TESTS_CAP=13,850. Its base already measured 13,850. The full suite and both required hosted checks passed on the source head.

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.

Observe required checks near the end of a bounded source wait Reset Mergify poll backoff when queue admission is confirmed

1 participant