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
- #597374
- Related MR(ai_gateway): gitlab-org/modelops/applied-ml/code-suggestions/ai-assist!5210 (merged)
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
- Switch the AI gateway to the feature branch:
cd gitlab-development-kit/gitlab-ai-gateway
git checkout dskim/add-recommend-reviewers-flow- Switch GitLab to the feature branch:
cd gitlab-development-kit/gitlab
git checkout dap-powered-reviewer-suggestion- Restart services:
gdk restart rails-web rails-background-jobs duo-workflow-service- Make sure a runner with the
gitlab--duotag 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.
- 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
- 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
- Console output shows Status: success and a workflow ID
- CI pipeline at /-/pipelines runs to completion (the duo workflow runner picks it up)
- MR comment is posted with:
- "## Reviewer assignment" table — rule name, status, and reviewer(s)
- Per-rule reasoning below the table
- 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.