Restrict Risk Classification flow to run only on MR creation

What does this MR do and why?

The Risk Classification flow runs three times per merge request today: at creation, at approval, and at merge. It should only run once, right after creation. The extra runs on approval and merge waste AI Gateway calls and leave the review widget pointing at a stale or duplicate risk assessment.

This happens because the flow's merge_request trigger has no precondition, so the generic trigger-filter layer treats it as unrestricted and matches every merge request action, not just creation.

This MR adds a precondition to the flow definition restricting it to the created action, following the same pattern the fix_pipeline flow already uses to restrict its own trigger to failed pipelines only. The precondition is evaluated live at trigger time, not stored on individual database rows, so the fix takes effect immediately for projects that already have this flow enabled, with no data migration needed.

References

Resolve #630410 (closed)

Screenshots or screen recordings

Not applicable. This is a backend trigger-configuration change with no UI surface.

How to set up and validate locally

  1. Enable duo_mr_risk_classification feature flag and enable the Risk Classification flow for your testing toplevel group
  2. Create a new merge request
  3. Confirm the flow triggers once: check the sessions section in the MR
  4. Approve the merge request
  5. Confirm the flow does not trigger again: no new agent session note appears after the approval.
  6. Merge the merge request.
  7. Confirm the flow does not trigger again: no new agent session note appears after the merge.

Before this fix, the same steps would show a new agent session note (and a new risk assessment) after both the approval and the merge, not just after creation.

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 Wanderson Policarpo

Merge request reports

Loading
Loading