Draft: Implements merge_request_ready trigger event

What does this MR do and why?

This MR addresses #592454 (closed) and implements merge_request_ready event trigger.

Problem

Code review workflows currently trigger on reviewer assignment, which can happen while a merge request is still in draft. This means AI review runs against WIP code, wasting compute resources and producing feedback on incomplete changes that the author is still actively working on.

Solution

Introduce a configurable merge_request_ready relay event that uses the Event Platform to fire, this is only when a merge request transitions from draft to ready, signalling the author considers the code complete and ready for review. This enables focused review at the right moment in the development workflow.

Key changes

  • Flow trigger: Adds merge_request_ready: 4 to the trigger type enum.
  • Relay dispatcher: Calls execute_flow_triggers in Relay::Dispatchers::Base and adds handle_merge_request_ready to the MergeRequests dispatcher to resolve the event.
  • Event publishing: When the Draft -> Ready transition occurs in ee/app/services/ee/merge_requests/update_service.rb, publish_merge_request_ready_event is called, which triggers the code_review/v1 foundational workflow using the Events Platform.
  • UI configuration: Adds merge_request_ready as a configurable trigger option in the flow trigger UI.

How to set up and validate locally (see screen recording for UI navigation)

Pre-requisites:

  • Duo Enterprise enabled
  • GDK running with all services up
  1. In Rails console: get your duo enterprise enabled project: proj = Project.find(1000000)
  2. Enable the feature flag: Feature.enable(:events_platform_trigger_cloud_events, project)
  3. Start watching logs in your terminal (gdk root) - see script in details below
```shell tail -f gitlab/log/application_json.log | grep -i "relay\|consume\|event_consumption\|merge_requests.merge_request_ready" ```
  1. Create & configure a flow trigger in the GDK UI:

  2. Trigger the event:

    • Create or navigate to an existing draft MR in the project
    • Transition the MR from draft -> ready
  3. Verify:

    • The Duo Code Review flow should trigger, with a system note appearing in the MR timeline (see screenshot)
    • Confirm merge_request_ready event is published and consumed in the logs (see details below for log example)
    • Frontend (feature flag gating)
      • Disable feature flag on the project: Feature.disable(:events_platform_trigger_cloud_events, proj)
      • Confirm that Merge request ready event_type is not available in the configuration UI (http://gdk.test:8080/gitlab-duo/test/-/automate/triggers/new) - see screenshot below.
{"severity":"INFO","time":"2026-04-21T10:14:38.584Z","correlation_id":"01KPQRHSTCA9AQM9E4F6P88G7E","meta.caller_id":"Relay::ConsumeEventsWorker","meta.feature_category":"code_suggestions","meta.organization_id":1,"meta.remote_ip":"172.16.123.1","meta.user":"root","meta.gl_user_id":1,"meta.project":"gitlab-duo/test","meta.root_namespace":"gitlab-duo","meta.client_id":"user/1","meta.root_caller_id":"Projects::MergeRequestsController#update","message":**"Starting event consumption"**,"class":"Relay::ConsumeEventService","event_id":"8d307359-432a-4753-9c41-6322949a7915",**"event_type":"com.gitlab.merge_requests.merge_request_ready"**,"event_source":"/projects/1000000"}

{"severity":"INFO","time":"2026-04-21T10:14:38.585Z","correlation_id":"01KPQRHSTCA9AQM9E4F6P88G7E","meta.caller_id":"Relay::ConsumeEventsWorker","meta.feature_category":"code_suggestions","meta.organization_id":1,"meta.remote_ip":"172.16.123.1","meta.user":"root","meta.gl_user_id":1,"meta.project":"gitlab-duo/test","meta.root_namespace":"gitlab-duo","meta.client_id":"user/1","meta.root_caller_id":"Projects::MergeRequestsController#update","message":**"Processing merge_request_ready"**,"class":"Relay::ConsumeEventService","event_id":"8d307359-432a-4753-9c41-6322949a7915",**"merge_request_id":50,"project_id":1000000**}

{"severity":"INFO","time":"2026-04-21T10:14:46.437Z","correlation_id":"01KPQRHSTCA9AQM9E4F6P88G7E","meta.caller_id":"Relay::ConsumeEventsWorker","meta.feature_category":"code_suggestions","meta.organization_id":1,"meta.remote_ip":"172.16.123.1","meta.user":"root","meta.gl_user_id":1,"meta.project":"gitlab-duo/test","meta.root_namespace":"gitlab-duo","meta.client_id":"user/1","meta.root_caller_id":"Projects::MergeRequestsController#update","meta.scoped_user":"root","meta.scoped_user_id":1,"message":**"Event consumption completed",**"class":"Relay::ConsumeEventService","event_id":"8d307359-432a-4753-9c41-6322949a7915",**"event_type":"com.gitlab.merge_requests.merge_request_ready"**}

Screenshot

  1. MR timeline showing system note after draft -> ready transition triggers the event:

Screenshot_2026-04-21_at_16.14.56

  1. Frontend feature flag gating: Merge request ready event type not available when ff is disabled

Screenshot_2026-04-23_at_15.19.44

Screen recording (GDK UI navigation)

Before After

References

  1. Implement and integrate configurable event trig... (#594482)
  2. Events Platform Phase 1 first iteration (!228912 - closed)
  3. GitLab_Duo_Triggers_and_Agents

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 Shola Quadri

Merge request reports

Loading