Lazy-load mention trigger for foundational flows on first mention

What does this MR do and why?

Implements lazy-loading of the mention flow trigger for foundational flows (e.g. developer/v1) when a service account is mentioned in a comment.

Problem: Projects set up before the mention trigger was added to the developer/v1 foundational flow definition (merged in !228817 (merged) on 2026-04-03) do not have the mention trigger in their ai_flow_triggers records. The sync only runs on specific events (project creation, settings change, explicit worker enqueue), so existing installations are silently missing the trigger.

Solution: In process_ai_flow_triggers (called on every note post-process), before querying for existing mention flow triggers, the system now:

  1. Checks if any mentioned user is a service account linked to a foundational flow that declares mention in its triggers array
  2. If the trigger is supposed to exist but doesn't yet, creates it inline immediately
  3. Then proceeds to look up and run the flow trigger as normal

This is safe and idempotent — the check uses by_service_accounts to avoid duplicates, and only creates the trigger when it's genuinely missing.

Key files changed:

  • ee/app/services/ee/notes/post_process_service.rb — lazy-load logic added to process_ai_flow_triggers
  • ee/spec/services/ee/notes/post_process_service_spec.rb — tests for the new behavior

References

Screenshots or screen recordings

Before After
Mentioning a Duo Developer service account in a project set up before !228817 (merged) does nothing (no trigger exists) Mentioning the service account creates the missing trigger inline and immediately runs the flow

How to set up and validate locally

  1. Set up a project with Duo Developer (developer/v1) configured before the mention trigger was added. see triggers page: http://gdk.test:3000/gitlab-duo/test/-/automate/triggers
  2. Ensure the project has an assign trigger but no mention trigger in ai_flow_triggers

image

  1. Mention the Duo Developer service account in a comment on an issue or MR

image

  1. Verify that the mention trigger is created and the flow is triggered

image

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 Fred de Gier

Merge request reports

Loading