Repository navigation
Warn when known queue predecessors put a PR over the size budget - #1781
Conversation
Co-Authored-By: Codex <noreply@openai.com>
There was a problem hiding this comment.
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.
| ) -> None: | ||
| assert config.mergify_queue is not None | ||
| try: | ||
| numbers = mergify.queue_predecessors(config.repo, config.base_branch, config.mergify_queue, pr.number) |
There was a problem hiding this comment.
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".
| raise MergifyError("invalid Mergify queue membership response") from exc | ||
|
|
||
|
|
||
| def queue_predecessors(repo: str, branch: str, queue: str, number: int) -> tuple[int, ...]: |
There was a problem hiding this comment.
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.
| 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" |
There was a problem hiding this comment.
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.
|
@Mergifyio queue |
✅ Merged into
|
|
No description provided. |
Warn when known queue predecessors put a PR over the size budget
Acceptance
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
0c859b2ae9ecuv run --group dev ruff check src tests: exit 0uv run --group dev tach check: exit 0uv run --python 3.14 python scripts/check_architecture_docs.py: exit 0scripts/size_budget.sh: exit 0uv run --group dev pytest -q: exit 0Open in [code]smith · Need help on this PR? Tag
@codesmith-botwith what you need.Review