Evaluate legacy approval rules for unenforceable policies

What does this MR do and why?

Security::UnenforceablePolicyRulesNotificationWorker decided whether a merge request has approval policy rules by checking only one link column: with deprecate_scan_result_policies enabled it checked approval_policy_rule_id, with the flag disabled it checked scan_result_policy_id. A rule carrying only the other link was treated as having no policy rule, and the worker returned early.

That skipped Security::UnenforceablePolicyRulesNotificationService, which records an error verdict for a rule whose scans cannot be enforced — the step that moves a violation out of running. Skipping it left the violation stuck in running and the merge request blocked on "All policy rules must be satisfied" with nothing to clear it.

The worker now treats a rule as policy-linked when it carries either column, matching MergeRequests::Mergeability::CheckSecurityPolicyViolationsService, which already counts both links when it decides whether to block.

No feature flag: this restores an evaluation path that was being skipped, and the mergeability check it now matches is already unflagged.

Reviewable LOC: 4 (plus 14 in tests)

Context for LLM agents
  • approval_policy_rule_id and scan_result_policy_id are two eras of the same relationship — the same rule, linked through a different column depending on when it was created.
  • Any future caller that needs to know whether a rule is policy-linked should check both columns with an OR, not either one alone.
  • The spec was collapsed into one shared example (it_behaves_like 'evaluating the approval rule') because both link shapes now behave identically under both flag states.

References

No tracking issue exists for this. Found while investigating #617804.

Screenshots or screen recordings

Backend-only, no UI change.

How to set up and validate locally

This is a narrow fix to worker logic with no separate manual setup beyond the merge request/approval-rule state itself. Validated via the specs below: ee/spec/workers/security/unenforceable_policy_rules_notification_worker_spec.rb and ee/spec/services/security/unenforceable_policy_rules_notification_service_spec.rb — 126 examples, 0 failures.

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.

RuboCop clean on the changed files.

Merge request reports

Loading
Loading