Backfill mention trigger for existing Duo Developer installations
Problem
With the merge of !228817 (merged), the mention trigger was added to the developer/v1 foundational flow definition in ee/app/models/ai/catalog/foundational_flow.rb. The SyncFoundationalFlowsService is designed to add missing triggers on the next sync — it only creates triggers for event types that do not already exist.
However, the sync is only triggered when:
- A new project is created
- A group/namespace setting changes (e.g.,
duo_foundational_flows_enabledis toggled) - The
CascadeSyncFoundationalFlowsWorkeris explicitly enqueued
This means existing Duo Developer installations that were set up before !228817 (merged) was merged (2026-04-03) will not automatically receive the mention trigger unless one of the above events occurs for their project/group.
This was discovered when @thomas-schmidt and @mikolaj_wawrzyniak found that a project had only the assign trigger configured, even after the MR was merged. The project had to be manually updated.
Desired Outcome
All existing projects that have Duo Developer (developer/v1) configured should automatically receive the mention trigger added to their ai_flow_triggers records, without requiring any manual intervention or re-configuration.
Proposed Solution
Implement a background migration (batched background migration) or a post-deployment migration that:
-
Identifies all projects that have:
- An
Ai::Catalog::ItemConsumerfor thedeveloper/v1foundational flow - A corresponding
Ai::FlowTriggerwith theassignevent type (event_type value1) - No corresponding
Ai::FlowTriggerwith thementionevent type (event_type value0)
- An
-
For each such project, creates the missing
mentiontrigger by:- Enqueuing
Ai::Catalog::Flows::SyncProjectFoundationalFlowsWorkerfor the project, OR - Enqueuing
Ai::Catalog::Flows::CascadeSyncFoundationalFlowsWorkerfor the root group of each affected project
- Enqueuing
The existing SyncFoundationalFlowsService#fetch_event_type_for_flow already handles deduplication correctly — it only creates triggers for event types that do not already exist — so re-running the sync is safe.
Technical Context
- Foundational flow definition:
ee/app/models/ai/catalog/foundational_flow.rb—developer/v1now has bothassign(value1) andmention(value0) in itstriggersarray - Sync service:
ee/app/services/ai/catalog/flows/sync_foundational_flows_service.rb— handles deduplication viafetch_event_type_for_flow - Flow trigger model:
ee/app/models/ai/flow_trigger.rb—EVENT_TYPES = { mention: 0, assign: 1, ... } - Worker:
ee/app/workers/ai/catalog/flows/cascade_sync_foundational_flows_worker.rb
Related
- Parent issue: #593201 (closed) (Add MR trigger by default for Duo Developer)
- MR that added the mention trigger to the flow definition: !228817 (merged)
- Related work item: #589246 (closed)