Add service and event for AI flow feedback

What does this MR do and why?

Users need a way to tell us when an AI security flow gets a verdict wrong. This MR adds the backend for that feedback, without storing anything in the database:

  • Vulnerabilities::SecurityAiFlowFeedbacks::CreateService checks that the vulnerability's latest flag came from an AI flow and validates the feedback. It then emits the submit_security_ai_flow_feedback internal event.
  • Feedback is rate limited to 60 per minute per user.
  • Everything is behind the security_ai_flow_feedback feature flag (wip).

The design, event fields and decisions are in #636349 (closed).

References

How to set up and validate locally

  1. In the Rails console, enable the flag: Feature.enable(:security_ai_flow_feedback, project).

  2. Pick a vulnerability whose latest flag has origin ai_sast_fp_detection, and run:

    Vulnerabilities::SecurityAiFlowFeedbacks::CreateService.new(
      current_user: user, vulnerability: vulnerability, sentiment: 'disagree', reasons: %w[verdict_wrong]
    ).execute
  3. Watch for the event with bundle exec rake gitlab:internal_events:monitor[submit_security_ai_flow_feedback].

  4. Try a vulnerability with no AI flag, or sentiment: 'agree' with reasons. Both return an error and emit no event.

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 AJ Biton

Merge request reports

Loading
Loading