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::CreateServicechecks that the vulnerability's latest flag came from an AI flow and validates the feedback. It then emits thesubmit_security_ai_flow_feedbackinternal event.- Feedback is rate limited to 60 per minute per user.
- Everything is behind the
security_ai_flow_feedbackfeature flag (wip).
The design, event fields and decisions are in #636349 (closed).
References
- Issue: #636349 (closed)
- Next in the stack: !265520 (merged) (GraphQL mutation), then !265521 (merged) (frontend)
How to set up and validate locally
-
In the Rails console, enable the flag:
Feature.enable(:security_ai_flow_feedback, project). -
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 -
Watch for the event with
bundle exec rake gitlab:internal_events:monitor[submit_security_ai_flow_feedback]. -
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.