Approve a direct Maintainer's merge request on Duo's review

What does this MR do and why?

Adds a maintainer path to ReconcileApproval. On gitlab-org/gitlab, gitlab-bot approves a sample of merge requests written by a direct Maintainer of the project and rated low or medium, once GitLab Duo has approved the rated commit, and the author merges with no second person. This is the Nov 16 slice in item 4 of gitlab-org/gitlab#638236: 10% of Medium-rated merge requests written by maintainers. It is stacked on !4551 (merged), and ships switched off.

  • When it approves. On a flow with maintainer_path, a merge request in its sample is approved at the rated commit 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 after that commit's diff version was created, 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.

    A read that leaves a field out counts against approving: a reviewer whose account is not marked as a bot counts as a person, a merge request that names no source project counts as a fork, and an empty list of commits is refused. The author merges. gitlab-bot never sets these to merge.

  • One switch. The triage-ops CI/CD variable MR_RISK_MAINTAINER_PATH, read every minute, turns the path on and off without a deploy. The path approves only while it is 1. It is read through the reader the RFH lifecycle switch uses, which the two now share: Triage.ci_switch_on?.

    • While it is not, each decision is logged, and nothing is approved on the path.
    • Once the path is off, a merge request's next decision withdraws an approval given on it. Nothing sweeps: an approval on a merge request that sees no further event stands until someone unapproves it, which at this sample is a handful to do by hand.
  • Reads. The checks that read the rating's note and session run only when the low path is open, or the merge request is in the sample with nothing but the switch against it. Any other medium or high rating is refused without them, so a read that fails does not hold up its refusal.

  • The note. gitlab-bot announces the approval in an internal note that opens with "No human has reviewed this change". A withdrawal goes the way a low-path one does. Its note names the failed checks of each path that could have given the approval: the maintainer path's while that path is on, with the low path's as well for a low rating, and the low path's alone while it is off.

  • ReconcileApproval also decides on GitLab Duo's approvals and on reviewer changes, for merge requests in the sample.

  • Config. gitlab-org/gitlab's mr_risk lists maintainer_path with sample: 10. A config that lists enabled is refused.

Expected impact & dry-runs

Nothing is approved on merge: the variable is unset. Merge requests in the sample are decided again on GitLab Duo's approvals and on reviewer changes, and each decision is logged.

Turning the path on takes:

  1. gitlab-org/gitlab rated in live mode, with the conditions of !4549 (merged) and !4551 (merged) holding. Their descriptions list them.
  2. gitlab-bot as a code owner of the product code paths, so that its approval meets the [Maintainers] rule: gitlab-org/gitlab!269372 (merged).
  3. MR_RISK_MAINTAINER_PATH set to 1. It takes no merge request and no deploy.

While the variable is not 1, the logged decisions show which merge requests it would approve.

How to set up and validate locally

SIMPLECOV=0 bundle exec rspec spec/processor/mr_approval_flow 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