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:
- Checks if any mentioned user is a service account linked to a foundational flow that declares
mentionin itstriggersarray - If the trigger is supposed to exist but doesn't yet, creates it inline immediately
- 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 toprocess_ai_flow_triggersee/spec/services/ee/notes/post_process_service_spec.rb— tests for the new behavior
References
- Issue: #596770 (closed)
- MR that added the mention trigger to the flow definition: !228817 (merged)
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
- Set up a project with Duo Developer (
developer/v1) configured before thementiontrigger was added. see triggers page: http://gdk.test:3000/gitlab-duo/test/-/automate/triggers - Ensure the project has an
assigntrigger but nomentiontrigger inai_flow_triggers
- Mention the Duo Developer service account in a comment on an issue or MR
- Verify that the
mentiontrigger is created and the flow is triggered
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.


