Add Duo Code Review mode resolver

What does this MR do and why?

Extracted from Refactor Duo Code Review mode resolution (!216690)

This MR adds a utility class to find in which mode Duo Code Review should run for a (user, container) pair, where the container can be either a group or a project.

This will help refactor the mode resolution later since we have to keep Classic Duo Code Review alive for the medium/long term.

How to set up and validate locally

Find a user and project that Duo Code Review should run in DAP mode and check:

user = User.find(...)
project = Project.find(...)
Ai::DuoCodeReview.enabled?(user:, container:) # => true
Ai::DuoCodeReview.mode(user:, container:)     # => :dap

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 Wanderson Policarpo

Merge request reports

Loading