Add DAP-powered reviewer suggestion for merge requests

What does this MR do and why?

This MR adds a foundational flow (recommend_reviewers/v1) that recommends reviewers for MRs based on CODEOWNERS approval rules, availability, workload, and current local time based on timezone. This just adds the ability to run the flow, but the automatic trigger will be added later as a follow up MR.

References

How to set up and validate locally

Prerequisites

You need a project with CODEOWNERS and approval rules set up. The example below uses gitlab-duo/test.

GDK setup

  1. Switch the AI gateway to the feature branch:
cd gitlab-development-kit/gitlab-ai-gateway
git checkout dskim/add-recommend-reviewers-flow
  1. Switch GitLab to the feature branch:
cd gitlab-development-kit/gitlab
git checkout dap-powered-reviewer-suggestion
  1. Restart services:
gdk restart rails-web rails-background-jobs duo-workflow-service
  1. Make sure a runner with the gitlab--duo tag is online (Admin Area -> CI/CD -> Runners). The CI pipeline that runs the workflow needs this.

Enable the flow

The foundational flow needs to be enabled at both the group and project levels.

  1. Enable foundational flows at the group level:
  • Go to Group -> Settings -> General -> GitLab Duo features -> Flows
  • Enable Allow Foundational flows
  • Under Available flows, enable Recommend Reviewers
  • Save
  1. Enable foundational flows at the project level:
  • Go to Project -> Settings -> General -> GitLab Duo → Configurations
  • Enable Allow Foundational flows if not already enabled
  • Save

Trigger the flow

Currently there is no automatic trigger so it needs to be manually triggered.

cd gitlab-development-kit/gitlab

bin/rails runner "
mr = MergeRequest.find_by(iid: <MR_IID>, target_project: Project.find_by_full_path('<PROJECT_PATH>'))
user = mr.author

Gitlab::SafeRequestStore.ensure_request_store do
  result = Ai::DuoWorkflows::ReviewerAssignment::RecommendReviewersService.new(
    merge_request: mr, current_user: user
  ).execute
  puts 'Status: ' + result.status.to_s
  puts 'Workflow ID: ' + result.payload[:workflow]&.id.to_s
end
"

The Gitlab::SafeRequestStore.ensure_request_store wrapper is required when running from rails console (not needed when triggered from a Sidekiq worker context).

What to verify

  1. Console output shows Status: success and a workflow ID
  2. CI pipeline at /-/pipelines runs to completion (the duo workflow runner picks it up)
  3. MR comment is posted with:
  • "## Reviewer assignment" table — rule name, status, and reviewer(s)
  • Per-rule reasoning below the table
  1. Reviewers assigned on the MR sidebar match the comment

MR acceptance checklist

Evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.

Edited by Sincheol (David) Kim

Merge request reports

Loading