Skip to content

Shorten waits for Mergify landing and source checks - #1334

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

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

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

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 source cap passes after merging #1272. The test-line gate blocks the full check at 13,522 lines against its 13,500 limit.

Validation

Recorded for 9e32e37e74e2 (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 1

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

Review

  • primary, claude, 1a3f5c9, request_changes
  • delta, claude, f690e5d, request_changes

eowca and others added 4 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>

@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 1a3f5c960157c0141a3e5151ff953027c49d1b68, 43.6s: request_changes (0 critical, 1 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 Resolved
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 variable is unnecessary

polls = _poll_until(...) followed by for _ in polls: adds a name that is used only once. Inline it as for _ in _poll_until(started, timeout, admitted=lambda: confirmed): to keep the diff smaller. The lambda reads the confirmed local through its closure, so the reassignment at line 1469 is still seen and the admission reset behaves as intended.

Architecture-Review: unchanged; the adaptive allowance stays inside the existing source wait deadline.
Co-Authored-By: Codex <noreply@openai.com>
@eowca
eowca force-pushed the lean178/1302-1303-polling branch from 1fdca97 to f690e5d Compare November 26, 2026 01:49

@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 f690e5d5bfad027aba52d6f50e4f656fc6ef448b, 35.6s: request_changes (0 critical, 1 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 tests/test_cli.py
assert wt.exists() and all(c["argv"][:2] != ["pr", "merge"] for c in gh.calls)


@pytest.mark.parametrize("command,timeout,green_at,read_time", [

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

important: Test-line size budget still fails the full check

scripts/size_budget.sh sets TESTS_CAP=13500. It fails when the tree is over that cap and has grown against its base. The tests in this worktree currently count 13,503 lines, and this delta adds about 11 lines to test_source_wait_observes_late_green. The task notes also say the gate blocks the full check (13,522 against 13,500). As things stand, loopzero check and CI fail on the size gate, so this does not meet acceptance. Smallest fix: drop the separate read_time=0 handling and the view = github.pr_view alias by wrapping the original inline, keep the parametrize table on fewer lines, or trim redundant lines elsewhere in this test so the total is back at or under 13,500. Don't raise the cap to get around it.

Comment thread src/loopzero/cli.py
longest_read = 0.0
while True:
was_admitted = admitted is not None and admitted()
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: 'Read latency' counts the whole consumer loop body

read_started/now measure all the time the generator is suspended. That includes work after the read in the consumer: mark_ready, printing, _readiness workflow lookups, and in the Mergify loop, mark_confirmed. That is fine as a conservative estimate. Because the value is a lifetime maximum, though, one slow outlier, such as a retried API call, keeps the final allowance high, up to remaining/2, for the rest of the wait. This is bounded and safe. Consider renaming it to something like longest_pass so the comment matches what is measured. You could also note that longest_read is unused when bounded=False.

@eowca

eowca commented Nov 26, 2026

Copy link
Copy Markdown
Contributor Author

Superseded by #1425. #1352 raised the test-line cap, and the replacement passes the full local check. The two review rounds on this PR are exhausted.

@eowca eowca closed this Nov 26, 2026
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