Draft: [Stack 2/3] Refactor mention template, CreateNoteService, and FlowTrigger

What does this MR do and why?

Preparatory refactors for the GitlabNote messaging adapter (!235039 (closed)). These changes are independently useful improvements that make no behavior changes visible to users.

Changes

Mention goal template (developer/mention.rb):

  • Adds %{note_url} variable — direct link to the specific note where the agent was mentioned
  • Adds %{source_context} variable with <gitlab_context> tags for richer context
  • Wraps user input in <conversation> tags for structured parsing
  • Path-neutral wording that works for both current RunService and future adapter paths

CreateNoteService (create_note_service.rb):

  • Extracts create_note, mark_started, mark_failed as public methods (previously only accessible through the #execute block orchestration)
  • mark_failed now sanitizes error messages with html_escape + truncate(200) to prevent Markdown injection and info leakage

FlowTrigger model (flow_trigger.rb):

  • Adds foundational_flow? predicate to encapsulate the ai_catalog_item_consumer&.item&.foundational_flow_reference.present? chain

PostProcessService (post_process_service.rb):

  • Passes source_context with reply-in-thread guidance to all RunService mention callers

MR acceptance checklist

This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.

Edited by Thomas Schmidt

Merge request reports

Loading