Introduce PolicyConfigurationAssignedEvent and bulk sync flag
What does this MR do and why?
Introduce PolicyConfigurationAssignedEvent and a feature flag that suppresses individual per-policy events when a security policy configuration is assigned to a project or group.
When a policy project is assigned, SyncScanPoliciesWorker triggers PersistSecurityPoliciesWorker, which currently publishes individual PolicyCreatedEvent / PolicyUpdatedEvent / PolicyDeletedEvent events for every policy. For large configurations this fans out into many small jobs. This MR lays the groundwork for replacing that with a single bulk event that fans out once per project.
Behind the sync_policies_in_bulk_on_policy_configuration_assign flag (disabled by default):
PersistPolicyServiceskipsEventPublisher#publish(individual policy events) whentriggered_by_assign: truePersistSecurityPoliciesWorkerinstead publishes a singlePolicyConfigurationAssignedEventSyncPolicyConfigurationWorkeris registered as the subscriber (no-op stub; fan-out logic in the follow-up MR)
When the flag is disabled, all existing behavior is unchanged.
References
Issue: #600265
This MR is part of a series:
👉 IntroducePolicyConfigurationAssignedEventand bulk sync flag (this MR)- Sync policies on policy configuration assign (follow-up MR, targets this one)
How to set up and validate locally
-
Enable the feature flag:
bin/rails runner "Feature.enable(:sync_policies_in_bulk_on_policy_configuration_assign)" -
Assign a security policy project to a project via Settings > Security and compliance > Security policies.
-
In Sidekiq logs, verify
PolicyCreatedEvent/PolicyUpdatedEventare not published during the assign flow, andPolicyConfigurationAssignedEventis published. -
Disable the flag and repeat — individual policy events should fire as before.
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.