Re-evaluate every skipped approval rule type after the policy timeout

What does this MR do and why?

When the approval policy evaluation timeout fires, Security::ScanResultPolicies::UnblockPendingMergeRequestViolationsWorker marks running violations as skipped and requires approvals. It then re-runs the evaluation so a late result still lands.

That re-run only covered scan_finding rules. A skipped any_merge_request or license_scanning rule stayed skipped until a manual approval or a new pipeline.

This MR re-runs those rules too. In a production sample on 2026-10-19, 18 of 75 blocked merge requests (24%) had one of them skipped.

Details

The worker now also enqueues:

  • Security::ScanResultPolicies::SyncAnyMergeRequestApprovalRulesWorker (merge request id) after an any_merge_request skip. It does not wait for report ingestion, as it depends on commits only.
  • Ci::SyncReportsToReportApprovalRulesWorker (pipeline id) after a license_scanning skip. It keeps the same ingestion gate as the scan_finding re-run.

Both workers deduplicate repeated enqueues. There is no feature flag, because this only re-runs idempotent workers.

Reviewable LOC: 12 (plus 38 in tests)

References

Screenshots or screen recordings

Not applicable. This change is backend only.

How to set up and validate locally

  1. Run bin/rspec ee/spec/workers/security/scan_result_policies/unblock_pending_merge_request_violations_worker_spec.rb. Expect 37 examples, 0 failures.
  2. Create an approval policy with an any_merge_request rule and a scan_finding rule.
  3. Open a merge request and let its pipeline finish. In a Rails console, set its violations back to running: MergeRequest.find(<id>).scan_result_policy_violations.update_all(status: :running)
  4. Run the timeout inline: Security::ScanResultPolicies::UnblockPendingMergeRequestViolationsWorker.new.perform(<pipeline_id>).
  5. Check the Sidekiq log: SyncAnyMergeRequestApprovalRulesWorker and SyncMergeRequestApprovalsWorker run right after the skip, and the violations do not stay skipped.

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.

🤖 Generated with Claude Code

Merge request reports

Loading
Loading