Draft: Trigger Recommend Reviewers flow on mention
What does this MR do?
First step of migrating DAP Reviewer Assignment off its bespoke trigger and onto the standard DAP Trigger platform (issue #603494).
This MR wires the recommend_reviewers/v1 foundational flow to the existing mention event so it runs through the normal trigger platform — the same way other foundational flows (e.g. security_review/v1) are triggered — instead of the bespoke MergeRequests::AutoAssignReviewersWorker path.
The problem this solves
The flow picks reviewers using each eligible approver's availability, workload, timezone, pending reviews and last activity. That data is not reachable through the flow's tools — the bespoke Ai::DuoWorkflows::RecommendReviewers::ExecuteService injected it as additional_context["reviewer_data"] (built by ReviewerDataBuilder).
The standard Ai::FlowTriggers::RunService only injected additional_context for Ci::Pipeline resources, so simply adding the trigger would silently strip the data the flow depends on.
Approach
- Add an optional
additional_context_buildercallable toAi::Catalog::FoundationalFlowdefinitions (mirrors the existing per-flowresolve_noteable/goal_templateslambdas), invoked via#additional_context_for(resource:). RunService#additional_contextnow delegates to the flow's hook for non-pipeline resources (pipeline behaviour unchanged, extracted topipeline_additional_context).recommend_reviewers/v1gainstriggers: [mention]and anadditional_context_builderthat injects the existingReviewerDataBuilderoutput for the merge request.
ReviewerDataBuilder is intentionally kept — only the bespoke invocation path is being removed.
Follow-up (separate MR)
Removal of the bespoke path: the DAP branch in AutoAssignReviewersWorker, RecommendReviewers::ExecuteService, the dap_powered reviewer_assignment_strategy value, the dap_powered_recommend_reviewers feature flag, the settings UI radio and the API value, plus a data migration. The non-DAP code_owners strategy is untouched.
Testing
ee/spec/models/ai/catalog/foundational_flow_spec.rb—#additional_context_forand therecommend_reviewers/v1mention trigger.ee/spec/services/ai/flow_triggers/run_service_spec.rb— context injection for a foundational flow that declares the builder.
Both pass locally; RuboCop clean.
Note for reviewers
The new mention trigger rides on the existing beta / catalog-consumer availability gating rather than a dedicated feature flag. Flagging in case we want an explicit flag while the broader migration is in progress.
Related to #603494