Add worker that runs flow triggers for a webhook event

What does this MR do and why?

This is MR 3 of 5 for the issue below. It adds Ai::FlowTriggers::WebhookEventWorker. The worker gets one webhook event (project, user, hook scope, payload) and runs the matching flow triggers through Ai::FlowTriggers::EventTriggerService.

Webhooks often fire inside a web request. The filters and flow starts should not run there, so a Sidekiq job runs them.

Nothing enqueues the worker yet, so nothing changes for users.

The worker follows the rules of the EventStore flow trigger workers in Ai::CloudEventsFlowTriggerWorker:

  1. It returns early for an unknown hook scope, or a missing project or user.
  2. It returns when the ai_flow_trigger_webhook_events flag is off for the project. The flag can change between enqueue and run.
  3. It returns when no active trigger is registered for the scope.
  4. An event caused by a flow runs only when ai_flow_trigger_chaining is on and the parent workflow is authorized for the user (CallerContext.authorized_parent_workflow). Otherwise the job logs the skip.

EventTriggerService now takes a parent_workflow and passes it to RunService. The pipeline_hooks caller does not change.

The worker is not idempotent, so one failing trigger must not make the job retry and start the earlier triggers again. It relies on the rescue in EventTriggerService from !269865 (merged), which tracks the error and goes on with the other triggers.

The job carries the full payload, like WebHookWorker does. We can't rebuild it from IDs later, because filters read fields such as changes that exist only at event time. To keep the Redis load low, the next MR enqueues the job only when the project has an active trigger for that scope. Only the IDs and the hook scope go to the job log.

This MR depends on these MRs, in this order:

  1. !274364 (merged)
  2. !274450 (merged)

Next MRs:

  • MR 4 enqueues the worker from EE::Project#execute_hooks.
  • MR 5 adds the new event types to GraphQL.

References

Screenshots or screen recordings

Not needed. There is no UI change.

How to set up and validate locally

No user-facing change. Nothing enqueues the worker yet, and the specs cover it.

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 Vitali Tatarintev

Merge request reports

Loading
Loading