Approve gitlab-org/gitlab's low ratings from the rating note

What does this MR do and why?

gitlab-org/gitlab's approvals move from the MR Approval Action Labeler's labels to the MR Risk Labeler's rating, the way !4549 (merged) does it for gitlab-merge-request. This is the "Switch approval and merge triggers" step of item 4 in gitlab-org/gitlab#638236. It builds on !4549 (merged), now merged. It also carries !4550 (merged), the maintainer path, which was merged into this branch and has its own section below.

  • config/mr_approval_flow.yml: gitlab-org/gitlab's mr_risk flow lists low_scopes for the scopes gitlab-bot approves today: docs_only, pipeline_spec_only and bot_dependency. auto_merge keeps setting dependency bumps to merge, and now lists low scopes rather than categories. The Action Labeler leaves the project.

  • Eligibility fits a low rating to a scope. The merge request needs the scope's label or rule, and the rating must name only the areas the scope allows:

    • docs_only: locale and docs-development;
    • pipeline_spec_only: specs;
    • bot_dependency: deps and tooling. The rules rate a pinned CI include under .gitlab/ as tooling, and the dependency bot opens those bumps too.

    Auto-merge follows the project's auto_merge, excluded_auto_merge_authors and ~"automation:prevent-auto-merge", as before.

  • ReconcileApproval:

    • sets auto-merge, pinned to the rated commit;
    • decides again when a scope's label arrives after the rating, as Danger's do;
    • leaves the security mirror's merge requests to SecuritySyncApprove;
    • cancels the auto-merge it set when it withdraws.

    The withdrawal code moves into a Withdrawal module that UnapproveOnDowngrade shares.

  • VerifyBotApprovals and PipelineTierTransitions ask MrApprovalFlow.approval_justified?, which reads the decision afresh, instead of the Action Labeler's labels. A read that fails there is raised rather than answered false, so an approval is not revoked on a failed read. It answers false for a merge request from the security mirror with no read, since ReconcileApproval never approves one.

  • ApproveOnVerdict goes, since no flow approves on categories any more.

The maintainer path

!4550 (merged) was merged into this branch, so this MR ships it too, switched off. Its description has the detail. In short:

  • When it approves. On gitlab-org/gitlab, ReconcileApproval also approves a merge request in a 10% sample by IID when it passes every check !4549 (merged) makes before an approval except the low path's, and also:

    • its author is a direct Maintainer of the project;
    • it is rated low or medium;
    • GitLab Duo approved the rated commit, and nobody has requested changes;
    • no human reviewer is requested;
    • no commit is by gitlab-bot or GitLab Duo, and it does not come from a fork.

    The author merges. gitlab-bot never sets these to merge.

  • One switch. The path approves only while the triage-ops CI/CD variable MR_RISK_MAINTAINER_PATH is 1, read every minute. While it is not, each decision is logged and nothing is approved on the path. Once it is off, a merge request's next decision withdraws an approval given on it.

  • Config. gitlab-org/gitlab's mr_risk lists maintainer_path with sample: 10.

Expected impact & dry-runs

  • This has to deploy together with gitlab-org/gitlab's mode: live in gitlab-merge-request's instructions/278964/, and with the Action Labeler no longer triggered there.
  • Until then, gitlab-bot approves nothing in gitlab-org/gitlab. The flow rates it in test mode until the switch, so that includes the docs-only, spec-only and dependency merge requests it approves today.
  • The Action Labeler leaves in the same change because live labels share its gitlab-bot:: scopes.
  • triage-ops has to receive gitlab-org/gitlab's internal notes. The rating note is internal, and GitLab sends those under a webhook's confidential comments trigger. Whether the webhook that reaches triage-ops from gitlab-org/gitlab has it on is still to confirm: without it no rating note arrives, and gitlab-bot approves nothing there after the switch. !4549 (merged) names the same check for gitlab-merge-request, which is in another group.
  • The dependency scope takes any low tooling rating on the dependency bot's merge request, not only a pinned include. It still needs the bot as the author and both maintenancedependency and automation:bot-authored.
  • The maintainer path approves nothing on merge. Its variable is unset. Turning it on also takes gitlab-org/gitlab rated in live mode, and gitlab-bot as a code owner of the product code paths, which is gitlab-org/gitlab!269372 (merged).

Not in this MR

  • The categories config key and TriggerReview's restart for a category flow's outstanding approval stay. Nothing lists categories after this, so both are inert, and a cleanup MR can take them out.

How to set up and validate locally

SIMPLECOV=0 bundle exec rspec spec/processor/mr_approval_flow spec/processor/mr_approval_flow_spec.rb spec/processor/delivery/verify_bot_approvals_spec.rb spec/processor/pipeline_tier_transitions_spec.rb spec/triage_spec.rb

The full suite passes with gitlab-merge-request's rules and catalog mapping available: 7,884 examples, no failures.

🤖 Generated with Claude Code

Edited by Connor Sanders

Merge request reports

Loading
Loading