Skip to content

Warn when known queue predecessors put a PR over the size budget - #1781

Merged
mergify[bot] merged 1 commit into
mainfrom
lean178/1295-project-queue-budget
Nov 26, 2026
Merged

mergify[bot] merged 1 commit into
mainfrom
lean178/1295-project-queue-budget

Conversation

@eowca

@eowca eowca commented Nov 26, 2026 •

Copy link
Copy Markdown
Contributor

Warn when known queue predecessors put a PR over the size budget

Acceptance

  • Reuse a single current target and its checker for the source-only and projected integrations.
  • Warn with the budget, projected count, cap and predecessor PR numbers when one known queue order projects a failure.
  • Keep the warning advisory. An empty, ambiguous, unavailable or conflicting snapshot leaves admission unchanged.

Notes

The real checker sees the source fit at 4 lines against a cap of 5. Two known predecessors raise the projected total to 6, and readiness still succeeds. The same test also checks empty, ambiguous and unavailable snapshots and preserves the original admission and resume assertions. Adds 28 net test lines.

Base

main @ 6c58d64

Validation

Recorded for 0c859b2ae9ec

  • 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, 0c859b2, approve

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 0c859b2ae9ece0e3183d024c01c2ead55fc90aa9, 77.5s: 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
) -> None:
assert config.mergify_queue is not None
try:
numbers = mergify.queue_predecessors(config.repo, config.base_branch, config.mergify_queue, pr.number)

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: An advisory snapshot read can stall ready for up to about 97 seconds

_warn_queue_size calls mergify.queue_predecessors, which goes through api_get. That function makes three attempts, each with a 30s urlopen timeout, and sleeps 2s and then 5s between them (mergify.py:95-111). A Mergify outage or throttling can therefore block the warning for about 97 seconds before it gives up silently. Admission is unchanged, but ready stalls during that time. ready --wait=N also projects (cli.py:1343 passes the default project=True), so the stall uses up the same wait budget that the later _wait_with_deadline at cli.py:1347 needs after mark_ready. Smallest fix: give the snapshot read a single attempt with a short timeout, for example an api_get(..., retries=False) variant or a project=args.wait is None guard in cmd_ready. That would also match the ARCHITECTURE wording "without an admission deadline".

Comment thread src/loopzero/mergify.py
raise MergifyError("invalid Mergify queue membership response") from exc


def queue_predecessors(repo: str, branch: str, queue: str, number: int) -> tuple[int, ...]:

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: queue_predecessors has no direct unit tests for its reject paths

The CLI test covers only the ordered, empty, two-roots-ambiguous and unavailable snapshots. It does not exercise these reject branches: a multi-PR batch, a batch with a different queue_rule_name, the requester's own PR appearing in the queue, a non-serial mode or non-empty waiting_pull_requests/forming_batches, a parent id outside the snapshot (dangling parent), a cycle, the container/sub_batch skip, duplicate sources, or more than 32 batches. The acceptance also lists a 'conflicting' snapshot, which here means merge-tree exits non-zero and _git raises CliError, which is then swallowed. No test covers that case. The merge path (merge without --wait, so project=True) is never tested with a queue either. Add a small table-driven test in tests/test_mergify.py that feeds status dicts through a monkeypatched api_get, plus one CLI case where a predecessor conflicts with the PR.

Comment thread src/loopzero/mergify.py
def queue_predecessors(repo: str, branch: str, queue: str, number: int) -> tuple[int, ...]:
"""Identify a single chain of one-PR batches ahead of a new request."""
status = api_get(repo, f"/merge-queue/status?branch={quote(branch, safe='')}")
if (not isinstance(status, dict) or status.get("mode") != "serial"

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 new reader depends on status keys that no existing fixture contains

Admission depends on waiting_pull_requests == [] and forming_batches == []. The existing status fixtures in tests/test_cli.py:2460 and tests/test_mergify.py:97 contain only batches and mode. If the live endpoint leaves out either key, status.get(...) != [] is always true. The projection then silently never runs, and every test still passes because the new CLI fixture adds both keys itself. Before shipping, check these keys against a real /merge-queue/status response or against Mergify's API schema. Recording that response as a fixture would keep the feature from quietly turning into a no-op.

@eowca
eowca marked this pull request as ready for review November 26, 2026 10:14
@eowca

eowca commented Nov 26, 2026

Copy link
Copy Markdown
Contributor Author

@Mergifyio queue

@mergify

mergify Bot commented Nov 26, 2026 •

Copy link
Copy Markdown

✅ Merged into main as 938db96 at 10:20 UTC

6 min in the queue, 5 min of it CI.

So far

  • ✅ Entered the queue Thu 26 Nov, 10:14 · rule main · triggered by @eowca with the @mergifyio queue command
  • ✅ Passed · draft #1799
  • ✅ Merged 10:20 · 938db96 · squash
3 merge conditions met
  • github-review-approved · required by GitHub repository ruleset rule main: PR only, Mergify queue, existing checks required
  • any of · required by GitHub repository ruleset rule main: PR only, Mergify queue, existing checks required:
    • check-success = checks
    • check-neutral = checks
    • check-skipped = checks
  • any of · required by GitHub repository ruleset rule main: PR only, Mergify queue, existing checks required:
    • check-success = Loop-zero Eligibility
    • check-neutral = Loop-zero Eligibility
    • check-skipped = Loop-zero Eligibility

Times in UTC · dashboard · how the merge queue works

@eowca

eowca commented Nov 26, 2026

Copy link
Copy Markdown
Contributor Author

No description provided.

@mergify
mergify Bot merged commit 938db96 into main Nov 26, 2026
18 checks passed
@mergify mergify Bot removed the queued label Nov 26, 2026
@eowca
eowca deleted the lean178/1295-project-queue-budget branch November 26, 2026 10:21
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.

Warn before queueing when predecessors push the candidate over budget

1 participant