Refactor DuoCodeReviewChatWorker to use intent-based handler classes

What does this MR do and why?

DuoCodeReviewChatWorker previously handled the code_review_request intent inline, with the routing logic spread across two private methods (code_review_intent? returning a boolean, and classify_mention_intent performing the LLM call separately). This made it harder to add new intent-based routing paths.

This MR refactors the worker in preparation for routing additional intents to dedicated handlers:

  • Consolidates intent classification into a single classify_intent(note) method that returns the raw intent string (or nil on failure/blank message), making the result available for any number of routing branches
  • Extracts the code review intent logic out of the worker into Ai::DuoWorkflows::CodeReview::Mention::CodeReviewHandler, following the existing ai/duo_workflows/code_review/ service pattern. A shared BaseHandler provides the common duo_code_review_bot accessor and create_note_on helper
  • Moves INTENT_* constants to the worker (the caller) and removes them from ClassifyCodeReviewMentionIntent, which is now purely the LLM call executor with no ownership of the intent values

No behaviour changes — this is a pure refactor. The follow-up MR (for issue #585237) will add AssistantFlowHandler on top of this structure.

How to set up and validate locally

Validate code_review_request intent (bot added as reviewer)

  1. Set up GDK with a GitLab Duo-enabled instance and a project that has the Duo Code Review bot configured
  2. Open a merge request in that project
  3. Leave a comment mentioning @GitLabDuo with a phrase that should trigger the code review intent, e.g. @GitLabDuo can you review this MR?
  4. Verify that the DuoCodeReviewChatWorker runs (check Sidekiq logs) and that CodeReviewHandler is invoked — the bot should be added as a reviewer on the MR rather than posting a chat reply

Validate a normal @GitLabDuo mention (classic chat reply)

  1. On the same or a different MR, leave a comment that is a general question, e.g. @GitLabDuo what does this method do?
  2. Verify the classifier does not return code_review_request and that the worker falls through to the classic chat path — the bot should post a reply in the discussion thread

Screenshots

code_review_request intent code_review_request intent (re-review) normal @GitLabDuo mention
review re-review classic_chat_case

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.

References

https://gitlab.com/gitlab-org/gitlab/-/work_items/585237+

Edited by Kinshuk Singh (PTO June 4-19)

Merge request reports

Loading