Stop choose_thread adopting a thread a person opened by quoting its note
What does this MR do and why?
Closes #25. Part of #19: #35 lists it among the items to land before approvals turn on for the pilots.
ChooseThread.ours? took a thread as the flow's own when its first note carried the footer link (MARKER). A quote reply copies the note whole, footer included. So a person who opened a thread by quoting the flow's note got a thread the flow treated as its own: it replied there, and under gitlab-botauto-approve it could resolve their question.
The opening note now also has to be by the flow's own service account. Each template passes its account to the step:
| Flow | Account |
|---|---|
src/flow (MR Approval Action Labeler) |
ai-mr-approval-action-labeler-gitlab-org (user 41776263) |
src/deps (MR Dependency Risk Labeler) |
ai-mr-dependency-risk-labeler-gitlab-org (user 43339445) |
This is option 1 from #25.
How it works
- The
choose_threadcommand ends with the account, after the packed script.bin/compilepacks the script intoARGV[0], so the account arrives asARGV[1].main(account = ARGV[1])passes it tothread_idandthread, andours?requiresopener["author"] == accountas well as the marker. - The marker check stays, because the same account also opens the "started session" and "completed session" threads.
- A missing or empty account matches nothing. The run then opens a thread instead of falling back to the marker alone.
route_forandours_alone?are unchanged.
It also closes a second case. Both flows write the same footer, so with the marker alone one flow could adopt, and resolve, the other's thread. .ai-catalog-mapping.json still holds a deps consumer on gitlab-org/gitlab (ItemConsumer/12585004), so a mention of the deps account there could have done that. Each flow now finds only threads its own account opened.
Options not taken
-
Reading the account from the run:
context:inputs.agent_platform_standard_context.service_account_namepassed intolist_mr_discussions'only_from_author.- Nothing has proven it works end to end on a custom catalog flow.
- It fails open when the context envelope is missing.
- The filter runs inside the tool, where no spec can reach it.
It is worth revisiting once #19 adds a consumer in another group.
-
An HTML-comment marker: a quote drops it, but every viewer receives the raw note, so it does not stop a deliberate copy. Both flows would also still share it.
Checked against real merge requests
Read-only checks, run on 2026-10-30:
- Existing threads keep working. Every open MR with a flow thread was checked: 100 in gitlab-org/gitlab and 9 across the three pilots. On each one, the thread's first note is by the right account, and the old and new logic choose the same thread and route.
- No open MR gets a second thread from this change.
- No note written by a person carries the marker, so the bug has not been hit on a live MR yet.
A differential run over 200,000 generated discussion lists agrees with the old logic on every list where each marker-carrying opener is the account. Every difference needs a marker-carrying opener by someone else.
Size
flows/flow.yml grows by 93 bytes to 40,180, which is 780 under the catalog's 40,960 limit.
Not in this MR
- Consumers in other groups. A consumer in another top-level group runs as another account, so it would open a thread on every run. The flow specs pin both flows' consumers to group 9970, so adding one fails
make checkuntil its account is handled. - Local runs.
glab duo cli runandbin/live_testpost as the token owner, so on a fixture they open a thread on every run and never reachreply_noteorresolve_thread. Replacing the trailing account with the token owner inbin/live_test'spinned_configwould bring that back. It is left out because it can't be checked without a live run. - The leftover deps consumer on gitlab-org/gitlab. A Maintainer needs to delete
ItemConsumer/12585004in the AI Catalog.
After merge
The next tag (0.27.0) syncs both flows, together with !94 (merged), which merged after 0.26.0.
How to set up and validate locally
make checkgit diff origin/main -- flows/shows only the twochoose_threadcommands.