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 anany_merge_requestskip. It does not wait for report ingestion, as it depends on commits only.Ci::SyncReportsToReportApprovalRulesWorker(pipeline id) after alicense_scanningskip. It keeps the same ingestion gate as thescan_findingre-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
- Closes #637375 (closed)
- Related to #627280 (closed) (cause 2 in #627280 (comment 4044720951)).
- Related: !263324 (merged) (head pipeline guard for the same timer).
Screenshots or screen recordings
Not applicable. This change is backend only.
How to set up and validate locally
- Run
bin/rspec ee/spec/workers/security/scan_result_policies/unblock_pending_merge_request_violations_worker_spec.rb. Expect 37 examples, 0 failures. - Create an approval policy with an
any_merge_requestrule and ascan_findingrule. - 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) - Run the timeout inline:
Security::ScanResultPolicies::UnblockPendingMergeRequestViolationsWorker.new.perform(<pipeline_id>). - Check the Sidekiq log:
SyncAnyMergeRequestApprovalRulesWorkerandSyncMergeRequestApprovalsWorkerrun right after the skip, and the violations do not stayskipped.
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.