Move Duo Code Review decisions availability out of models
What does this MR do and why?
This continues moving Duo Code Review logic out of Project, Namespace and ApplicationSetting, which are omniscient classes. It follows !266280 (merged) and !267458 (merged).
Behavior change: same gate as the depth settings
decisions_settings_available? now uses the same checks as depth_settings_available?, and keeps the Duo Code Review availability check:
- GitLab Duo features are on.
- Foundational flows are on. Decisions only happen in the GitLab Duo Agent Platform flow.
- Experiment and beta features are on. Decisions are a beta feature.
- The
duo_code_review_decisionsfeature flag is enabled. - Duo Code Review is available: a Duo Enterprise add-on, or the GitLab Duo Agent Platform flow. This check is unchanged.
The feature flag actors are unchanged: the project, the group, or the instance.
A group or instance with decisions turned on, but with experiment and beta features turned off, no longer gets approvals or change requests from GitLab Duo. This was a bug before.
References
- Related to #636674
Screenshots or screen recordings
Not applicable. The only visible change is that the decisions setting can show as disabled when Duo Code Review is not available.
How to set up and validate locally
- Make sure your GDK has an active Duo Enterprise add-on, GitLab Duo is on for the
gitlab-duogroup, and foundational flows are on. - Enable the flag for the
gitlab-duogroup and thegitlab-duo/testproject:Feature.enable(:duo_code_review_decisions, Group.find_by_full_path('gitlab-duo')) Feature.enable(:duo_code_review_decisions, Project.find_by_full_path('gitlab-duo/test')) - Turn off beta features: in the upper-right corner, select Admin. Select Settings > GitLab Duo, expand Change configuration, clear Turn on experiment and beta GitLab Duo features, and select Save changes.
- Go to
gitlab-duo/test> Settings > Merge requests. The review decisions setting does not show in the Duo Code Review section. - Select Turn on experiment and beta GitLab Duo features again, and select Save changes.
- Reload
gitlab-duo/test> Settings > Merge requests. The review decisions setting shows. Turn it on and save. - Go to the
gitlab-duogroup > Settings > General > Merge requests. The review decisions setting shows. - Check the REST API:
It returns
curl --header "PRIVATE-TOKEN: <token>" "http://gdk.test:3000/api/v4/projects/gitlab-duo%2Ftest" | jq '.duo_code_review_decisions_enabled'true. - Create a merge request in
gitlab-duo/testwith a small, clean change, and wait for Duo to review it. Duo approves the merge request. - Disable the flag for the group and the project:
Reload the pages from steps 6 and 7: the review decisions setting no longer shows, and the API field from step 8 is gone.
Feature.disable(:duo_code_review_decisions, Group.find_by_full_path('gitlab-duo')) Feature.disable(:duo_code_review_decisions, Project.find_by_full_path('gitlab-duo/test'))
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.