Loading
Attribute memory distillation sessions to the MR author
What does this MR do and why?
Memory Distillation sessions triggered by a merged merge request used the user who merged the original MR as the actor and commit co-author. This incorrectly attributed commits to the merger, and could also request review from that same user — who then could not approve a merge request assigned to themselves.
This MR makes two changes so attribution lands on the original MR author:
ExecuteMergeRequestMergedWorkflowTriggersWorkernow resolves the session actor (current_user) to the merge request author instead of the user who merged it. The distillation session and its commits are therefore attributed to the author.Ai::Catalog::GoalTemplates::Developer::MergedMergeRequestgoal template:- Renames
merged_by_usernametoreviewer_usernameto match intent. - Implements
resolve_reviewer_usernamewith a three-tier priority to find a reviewer who differs from the author:- The user who merged the MR (when different from the author).
- Any reviewer on the merged MR's reviewer list (excluding the author).
- No reviewer when no suitable candidate exists — the author drives the distilled MR themselves.
- Removes the redundant "acting on behalf of" paragraph (the
--assigneeinstruction already covers attribution).
- Renames
- Shared example fix (
cloud_events_flow_trigger_worker_shared_examples.rb): the "when the user does not exist" test now stubsresolve_current_useron the worker instance, so it correctly covers workers that override the default (e.g. this worker usesmerge_request.authorinstead ofcloud_event.current_user).
References
- Resolves #629547 (closed)
- Feedback: #613978 (comment 3843817749)
Screenshots or screen recordings
Now the MR author will be the author of the distilled MR and reviewer will be requested from the original MR reviewer list.
How to set up and validate locally
The change is covered by specs:
ee/spec/models/ai/catalog/goal_templates/developer_spec.rb— verifies the rendered goal attributes the author, requests review from the merger when they differ, falls back to the MR reviewer list when the author self-merged, and omits the reviewer when no suitable candidate exists.ee/spec/workers/ai/catalog/flows/execute_merge_request_merged_workflow_triggers_worker_spec.rb— verifies the flow runs as the MR author.
bundle exec rspec \
ee/spec/models/ai/catalog/goal_templates/developer_spec.rb \
ee/spec/workers/ai/catalog/flows/execute_merge_request_merged_workflow_triggers_worker_spec.rbMR 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 Junming Huang

