Skip to content

ci(mergify): require 2 approvals for large PRs#888

Merged
mergify[bot] merged 1 commit intomainfrom
mergify-large-pr-queue
Mar 12, 2026
Merged

ci(mergify): require 2 approvals for large PRs#888
mergify[bot] merged 1 commit intomainfrom
mergify-large-pr-queue

Conversation

@mprpic
Copy link
Copy Markdown
Contributor

@mprpic mprpic commented Mar 12, 2026

Add a separate queue rule for PRs that exceed size thresholds, requiring two approvals instead of one. A PR is considered large if it modifies more than 10 files or adds/deletes more than 500 lines. Normal PRs continue to require only 1 approval.

The thresholds I chose (500 lines, 10 files) are pretty arbitrary and up for discussion.

Add a separate queue rule for PRs that exceed size thresholds, requiring
two approvals instead of one. A PR is considered large if it modifies
more than 10 files or adds/deletes more than 500 lines. Normal PRs
continue to require only 1 approval.

Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
Signed-off-by: Martin Prpič <mprpic@redhat.com>
@mprpic mprpic requested a review from ktdreyer March 12, 2026 15:02
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Mar 12, 2026

Walkthrough

Configuration changes to .mergify.yml that establish PR routing rules. A new large-pr merge queue with specific autoqueue settings and pull_request_rules are added to direct PRs to the appropriate queue based on size thresholds (file count and line changes).

Changes

Cohort / File(s) Summary
Mergify Configuration
.mergify.yml
Added new large-pr queue with autoqueue configuration and merge_method set to squash. Introduced two pull_request_rules that route PRs to either large-pr or default queue based on file count (>10 or ≤10) and line changes (>500 or ≤500 for both additions and deletions).

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately reflects the main change: adding a requirement for 2 approvals for large PRs, which matches the content added to the mergify configuration.
Description check ✅ Passed The description is directly related to the changeset, explaining the purpose of the new queue rule, the size thresholds, and approval requirements.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch mergify-large-pr-queue
📝 Coding Plan for PR comments
  • Generate coding plan

Comment @coderabbitai help to get the list of available commands and usage tips.

- "#files>10"
- "#added-lines>500"
- "#deleted-lines>500"
actions:
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Yeah, we probably needed these action stanzas to make the UI clearer about what it's doing.

@ktdreyer
Copy link
Copy Markdown
Contributor

Let's try it

@ktdreyer
Copy link
Copy Markdown
Contributor

@Mergifyio queue

@mergify
Copy link
Copy Markdown

mergify bot commented Mar 12, 2026

Merge Queue Status

  • 🟠 Waiting for queue conditions
  • ⏳ Enter queue
  • ⏳ Run checks
  • ⏳ Merge
Required conditions to enter a queue
  • -closed [📌 queue requirement]
  • -conflict [📌 queue requirement]
  • -draft [📌 queue requirement]
  • any of [📌 queue -> configuration change requirements]:
    • check-success = Configuration changed
    • -mergify-configuration-changed
  • any of [🔀 queue conditions]:
    • all of [📌 queue conditions of queue default]:
      • #approved-reviews-by >= 1 [🛡 GitHub repository ruleset rule protect-main]
      • #approved-reviews-by>=1
      • #changes-requested-reviews-by = 0 [🛡 GitHub repository ruleset rule protect-main]
      • #changes-requested-reviews-by=0
      • check-success=End-to-End Tests
      • check-success=test-local-dev-simulation
      • check-success=validate-manifests
      • commented-reviews-by=coderabbitai[bot]

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In @.mergify.yml:
- Around line 24-42: The .mergify.yml contains a redundant pull_request_rules
block that duplicates queue routing logic; remove the entire pull_request_rules
section (the "pull_request_rules:" key and its two entries "queue large PRs" and
"queue normal PRs") and rely on the existing queue_rules entries with autoqueue:
true and their queue_conditions to handle queuing; if different size-based
behavior is later required, implement it via distinct queue_rules or refined
queue_conditions rather than reintroducing pull_request_rules.
- Around line 27-30: Replace the per-direction size checks with a total-churn
check: in the rule that uses the "- or:" group containing "#files>10",
"#added-lines>500", and "#deleted-lines>500" change the two conditions
"#added-lines>500" and "#deleted-lines>500" to a single "#changes>500" condition
(so the rule triggers on total added+deleted > 500); likewise update the
corresponding normal-PR rule that currently uses "#added-lines<=500" and
"#deleted-lines<=500" to use "#changes<=500" instead, ensuring both "queue large
PRs" and "queue normal PRs" use `#changes` for the 500-line threshold.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: e6be29ec-ddda-4b11-a9fb-ba6fd8fbdc7c

📥 Commits

Reviewing files that changed from the base of the PR and between 43a5d7d and 92d6da7.

📒 Files selected for processing (1)
  • .mergify.yml

Comment on lines +24 to +42
pull_request_rules:
- name: queue large PRs
conditions:
- or:
- "#files>10"
- "#added-lines>500"
- "#deleted-lines>500"
actions:
queue:
name: large-pr

- name: queue normal PRs
conditions:
- "#files<=10"
- "#added-lines<=500"
- "#deleted-lines<=500"
actions:
queue:
name: default
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🧹 Nitpick | 🔵 Trivial

🧩 Analysis chain

🌐 Web query:

In Mergify, does a pull_request_rulesrule withactions: { queue: ... }automatically enqueue every matching pull request, or only route pull requests after a user has explicitly requested merge/queue? How does this interact withautoqueue: trueinqueue_rules?

💡 Result:

  • A pull_request_rules rule with actions: {queue: ...} will enqueue automatically as soon as the rule’s conditions match (it’s not gated on a user “requesting merge/queue”). The docs’ own example says “any pull request that has the label queue-me will be automatically queued.” However, the PR still must satisfy the target queue’s queue_conditions to actually enter the queue. [1]

  • autoqueue: true in a queue_rules entry is a separate, more direct mechanism: as soon as a PR matches that queue rule’s queue_conditions, Mergify automatically adds it to the queueno pull_request_rules queue action and no manual “queue” command is required. [2][3]

  • Interaction:

    • If autoqueue: true for the relevant queue, you usually don’t need an actions: queue rule at all (it becomes redundant unless you want extra gating/logic beyond what you can express in queue_conditions). [1][3]
    • If autoqueue: false (default), then PRs won’t be enqueued just by matching queue_conditions; they must be queued explicitly (e.g., via an actions: queue rule or a manual queue command). [2][3]

Sources: Mergify docs on the queue action [1], queue rules / autoqueue behavior [2], and the autoqueue changelog announcement [3].


🏁 Script executed:

cat .mergify.yml

Repository: ambient-code/platform

Length of output: 1128


Remove the redundant pull_request_rules and rely on queue_rules with autoqueue: true.

These pull_request_rules are unnecessary—both queues already have autoqueue: true enabled, which will automatically queue PRs as soon as queue_conditions are met. The size-based routing (large vs. normal) is duplicating that behavior. The queue_conditions (approvals, checks, CodeRabbit comment) provide the actual gating, so queued PRs won't merge until those are satisfied.

Simplify by removing the pull_request_rules entirely. If different size-based logic is needed beyond what queue_conditions can express, reconsider whether separate queues are the right design. Otherwise, a single queue with appropriate conditions is cleaner.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In @.mergify.yml around lines 24 - 42, The .mergify.yml contains a redundant
pull_request_rules block that duplicates queue routing logic; remove the entire
pull_request_rules section (the "pull_request_rules:" key and its two entries
"queue large PRs" and "queue normal PRs") and rely on the existing queue_rules
entries with autoqueue: true and their queue_conditions to handle queuing; if
different size-based behavior is later required, implement it via distinct
queue_rules or refined queue_conditions rather than reintroducing
pull_request_rules.

Comment on lines +27 to +30
- or:
- "#files>10"
- "#added-lines>500"
- "#deleted-lines>500"
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

🧩 Analysis chain

🌐 Web query:

What Mergify condition should be used to match a pull request whose total line churn (additions + deletions) exceeds 500? Please check the current Mergify condition syntax for pull request rules.

💡 Result:

Use the #changes condition and compare it numerically:

conditions:
  - "#changes > 500"

This matches pull requests whose total “lines changed” (line churn) exceeds 500. [1][2]


🏁 Script executed:

cat -n .mergify.yml | sed -n '20,45p'

Repository: ambient-code/platform

Length of output: 738


Use #changes to enforce a single 500-line threshold instead of separate per-direction checks.

Lines 27–30 trigger "queue large PRs" only if additions or deletions individually exceed 500 lines. A PR with 300 added and 300 deleted lines (600 total churn) will match lines 37–39 instead, routing to the "default" queue. Replace the separate #added-lines and #deleted-lines conditions with #changes > 500 to catch all PRs exceeding the intended total-churn threshold.

Also applies to: 37–39 (use #changes <= 500 in the "queue normal PRs" rule).

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In @.mergify.yml around lines 27 - 30, Replace the per-direction size checks
with a total-churn check: in the rule that uses the "- or:" group containing
"#files>10", "#added-lines>500", and "#deleted-lines>500" change the two
conditions "#added-lines>500" and "#deleted-lines>500" to a single
"#changes>500" condition (so the rule triggers on total added+deleted > 500);
likewise update the corresponding normal-PR rule that currently uses
"#added-lines<=500" and "#deleted-lines<=500" to use "#changes<=500" instead,
ensuring both "queue large PRs" and "queue normal PRs" use `#changes` for the
500-line threshold.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

No such things as a #changes condition. Get a hold of yourself, rabbit!

There is modified-lines, but it's not clear how that's computed (is it added+deleted?).

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Whenever this thing goes wrong, I always give it a 👎. Feel free to do the same. Best part of my day

@mergify mergify bot added the queued label Mar 12, 2026
@mergify mergify bot merged commit 538ccbd into main Mar 12, 2026
10 checks passed
@mergify mergify bot deleted the mergify-large-pr-queue branch March 12, 2026 15:15
@mergify
Copy link
Copy Markdown

mergify bot commented Mar 12, 2026

Merge Queue Status

  • Entered queue2026-03-12 15:15 UTC · Rule: default
  • Checks passed · in-place
  • Merged2026-03-12 15:15 UTC · at 92d6da7e0dd6e384bc7131a0ac4c345cb4f4e36e

This pull request spent 10 seconds in the queue, with no time running CI.

Required conditions to merge

@mergify mergify bot removed the queued label Mar 12, 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.

2 participants