Skip to content

Shared task board where people and AI coding agents work as teammates. Source-available, self-hostable.

Go

MUL-7072 fix(github): retire reference-only PR links (#8245)

Bohan Jiang116761e505a0
diff --git a/apps/docs/content/docs/github-integration.ja.mdx b/apps/docs/content/docs/github-integration.ja.mdx
index cea83db4dd..89ca19b51b 100644
--- a/apps/docs/content/docs/github-integration.ja.mdx
+++ b/apps/docs/content/docs/github-integration.ja.mdx
@@ -36,7 +36,7 @@ GitHub 連携が読み取るのは、インストール時に許可されたリ
| GitHub 連携 | メインスイッチ。無効にすると下の 3 項目は機能しなくなりますが、GitHub App の接続は解除されません。 |
| PR サイドバー | 紐づいた pull request をタスクの詳細画面に表示します。 |
| Co-authored-by | エージェントが作成する commit に `Co-authored-by: multica-agent <[email protected]>` を追加します。 |
-| PR の自動紐づけ | PR のブランチ名、タイトル、本文からタスク番号を検出します。 |
+| PR の自動紐づけ | PR のブランチ名とタイトルからタスク番号を検出します。本文では closing keyword の直後にある番号だけを検出します。 |
| **PR カード → CI とマージ可否** | 紐づいた各 PR について、Multica は認証済みの GitHub API スナップショットを取得し、その **CI ステータス**と**マージ可否**をカードにミラーリングします(下記の **PR カードに表示される内容** を参照)。 |
@@ -54,7 +54,7 @@ MUL-123 ログイン後のリダイレクトを修正
Multica は大文字と小文字を区別せず、現在のワークスペースのタスク接頭辞だけを照合します。1 つの PR を複数のタスクに紐づけることもできます。
-タスク番号を PR 本文だけに書く場合は、GitHub の closing keyword を使ってください。
+タスク番号を PR 本文だけに書く場合は、GitHub の closing keyword を必ず使ってください。
```text
Closes MUL-123
@@ -62,7 +62,7 @@ Fixes MUL-123
Resolves MUL-123
```
-本文に `Related to MUL-123` のような通常の参照を書いただけでは、そのタスクの作業 PR として表示されません。Commit message と PR コメントも紐づけの対象外です。
+本文に `Related to MUL-123` のような通常の参照を書いただけでは、そのタスクへまったく紐づきません。Commit message と PR コメントも紐づけの対象外です。
## タスクから PR を確認する
@@ -83,7 +83,7 @@ CI の状態とマージ可能性は、Multica が GitHub API から取得した
PR がマージされても、必ずしもタスクが完了するわけではありません。Multica がタスクを `Done` に変更するのは、次の条件をすべて満たす場合だけです。
1. 紐づいたマージ済み PR のうち少なくとも 1 つで、`Closes MUL-123` のように closing keyword の直後にタスク番号を指定している。`Closes login MUL-123` のように間に別の単語がある形式は無効です。
-2. そのタスクに、`Open` または `Draft` の作業 PR がほかに残っていない。本文中の通常の参照は作業 PR に含みません。
+2. そのタスクに、`Open` または `Draft` の紐づいた PR がほかに残っていない。
3. タスクの現在の状態が `done` または `cancelled` ではない。
そのため、ブランチ名やタイトルに `MUL-123` を含めるだけで紐づけは作成されますが、それだけではタスクを完了にしません。PR をマージせずにクローズした場合も、タスクは完了しません。
@@ -175,7 +175,7 @@ API サービスを再起動し、**設定 → GitHub** から接続します。
- **接続ボタンを使用できない**: `GITHUB_APP_SLUG` と `GITHUB_WEBHOOK_SECRET` が API プロセスに設定されていることを確認します。
- **Webhook が 401 を返す**: GitHub App と API が同じ Webhook secret を使っていることを確認し、GitHub の **Recent Deliveries** から再配信します。
- **PR が紐づかない**: リポジトリが App の許可範囲にあること、PR の自動紐づけが有効であること、番号が現在のワークスペースのものかを確認します。
-- **本文に番号を書いても表示されない**: `Closes MUL-123` を使うか、番号をブランチ名または PR タイトルに入れます。
+- **本文に番号を書いても紐づかない**: `Closes MUL-123` を使うか、番号をブランチ名または PR タイトルに入れます。
- **CI の状態がない**: `GITHUB_APP_ID` と `GITHUB_APP_PRIVATE_KEY` が設定済みで、App に Contents、Checks、Commit statuses の read-only 権限があり、関連イベントを購読していることを確認します。Contents が欠けるとスナップショット全体が失敗し、PR カードには CI もマージ状態も表示されません。インストール済み App に権限を追加した場合は、各 installation の所有者が GitHub 上で承認するまで有効になりません。
- **PR のマージ後もタスクが完了しない**: PR で closing keyword を使っていることと、`Open` または `Draft` の関連 PR がほかに残っていないことを確認します。
diff --git a/apps/docs/content/docs/github-integration.ko.mdx b/apps/docs/content/docs/github-integration.ko.mdx
index c5d94a831b..f8b34e8c4c 100644
--- a/apps/docs/content/docs/github-integration.ko.mdx
+++ b/apps/docs/content/docs/github-integration.ko.mdx
@@ -36,7 +36,7 @@ GitHub 연동은 설치할 때 승인한 저장소만 읽으며 코드, 댓글,
| GitHub 연동 | 전체 스위치입니다. 끄면 아래 세 기능이 작동하지 않지만 GitHub App 연결은 해제되지 않습니다. |
| PR 사이드바 | 태스크 상세 화면에 연결된 pull request를 표시합니다. |
| Co-authored-by | 에이전트가 만든 commit에 `Co-authored-by: multica-agent <[email protected]>`를 추가합니다. |
-| PR 자동 연결 | PR의 브랜치 이름, 제목, 본문에서 태스크 번호를 찾습니다. |
+| PR 자동 연결 | PR의 브랜치 이름과 제목에서 태스크 번호를 찾고, 본문에서는 종료 문구 바로 뒤에 있는 번호만 찾습니다. |
| **PR 카드 → CI와 머지 가능 여부** | 연결된 각 PR에 대해 Multica는 인증된 GitHub API 스냅샷을 가져와, 그 **CI 상태**와 **머지 가능 여부**를 카드에 미러링합니다(아래 **PR 카드에 표시되는 것** 참조). |
@@ -62,7 +62,7 @@ Fixes MUL-123
Resolves MUL-123
```
-본문의 `Related to MUL-123` 같은 일반 언급은 해당 태스크의 작업 PR로 표시되지 않습니다. Commit message와 PR 댓글도 연결을 트리거하지 않습니다.
+본문의 `Related to MUL-123` 같은 일반 언급은 해당 태스크에 전혀 연결되지 않습니다. Commit message와 PR 댓글도 연결을 트리거하지 않습니다.
## 태스크에서 PR 확인
@@ -83,7 +83,7 @@ CI 상태와 merge 가능 여부는 Multica가 GitHub API에서 가져온 snapsh
PR이 merge되었다고 태스크가 반드시 완료된 것은 아닙니다. Multica는 다음 조건이 모두 충족될 때만 태스크를 `Done`으로 바꿉니다.
1. merge된 연결 PR이 하나 이상 있고, `Closes MUL-123`처럼 종료 문구 바로 뒤에 번호가 있습니다(`Closes login MUL-123`처럼 중간에 다른 단어가 있으면 적용되지 않음).
-2. 해당 태스크에 `Open` 또는 `Draft` 상태인 다른 작업 PR이 없습니다. 본문의 일반 언급은 작업 PR에 포함되지 않습니다.
+2. 해당 태스크에 `Open` 또는 `Draft` 상태인 다른 연결 PR이 없습니다.
3. 태스크의 현재 상태가 `done` 또는 `cancelled`가 아닙니다.
따라서 브랜치 이름이나 제목에 `MUL-123`만 넣으면 연결은 되지만 그것만으로 완료를 트리거하지 않습니다. PR을 merge하지 않고 닫아도 태스크가 완료되지 않습니다.
@@ -175,7 +175,7 @@ API 서비스를 다시 시작한 뒤 **설정 → GitHub**에서 연결을 완
- **연결 버튼을 사용할 수 없음**: `GITHUB_APP_SLUG`와 `GITHUB_WEBHOOK_SECRET`이 API 프로세스에 전달되었는지 확인합니다.
- **Webhook이 401을 반환함**: GitHub App과 API가 같은 Webhook secret을 사용하는지 확인하고 GitHub의 **Recent Deliveries**에서 다시 전달합니다.
- **PR이 연결되지 않음**: 저장소가 App 승인 범위에 있는지, 자동 연결이 켜져 있는지, 번호가 현재 워크스페이스에 속하는지 확인합니다.
-- **본문에 번호를 썼지만 표시되지 않음**: `Closes MUL-123`을 사용하거나 번호를 브랜치 이름 또는 PR 제목에 넣습니다.
+- **본문에 번호를 썼지만 연결되지 않음**: `Closes MUL-123`을 사용하거나 번호를 브랜치 이름 또는 PR 제목에 넣습니다.
- **CI 상태가 없음**: `GITHUB_APP_ID`와 `GITHUB_APP_PRIVATE_KEY`가 설정되었는지, App에 Contents, Checks 및 Commit statuses 읽기 권한이 있고 관련 이벤트를 구독했는지 확인합니다. Contents가 없으면 snapshot 전체가 실패해 PR 카드에 CI도 머지 상태도 표시되지 않습니다. 설치된 App에 권한을 추가한 뒤에는 각 installation owner가 GitHub에서 승인해야 적용됩니다.
- **PR merge 후 태스크가 완료되지 않음**: PR에 종료 문구가 있는지 확인하고 다른 연결 PR이 Open 또는 Draft 상태로 남아 있는지 확인합니다.
diff --git a/apps/docs/content/docs/github-integration.mdx b/apps/docs/content/docs/github-integration.mdx
index 173064e0f7..a50eb0fb44 100644
--- a/apps/docs/content/docs/github-integration.mdx
+++ b/apps/docs/content/docs/github-integration.mdx
@@ -36,7 +36,7 @@ The **GitHub connection** decides which repositories Multica receives PR events
| GitHub integration | Master switch. When off, the three below stop working, but the GitHub App stays connected. |
| PR sidebar | Shows linked pull requests in issue detail. |
| Co-authored-by | Adds `Co-authored-by: multica-agent <[email protected]>` to commits created by agents. |
-| Auto-link PRs | Detects issue identifiers in a PR's branch name, title, and body. |
+| Auto-link PRs | Detects issue identifiers in a PR's branch name or title, and in the body when they follow a close intent. |
| **PR card → CI & mergeability** | For each linked PR, Multica fetches an authenticated GitHub API snapshot and mirrors its **CI status** and **mergeability** onto the card (see **What the PR card shows** below). |
@@ -55,7 +55,7 @@ MUL-123 Fix the redirect after login
Multica ignores case and only matches the current workspace's issue prefix. One PR can link to multiple issues.
-If the identifier appears only in the PR body, use one of GitHub's close intents:
+If the identifier appears only in the PR body, you must use one of GitHub's close intents:
```text
Closes MUL-123
@@ -63,7 +63,7 @@ Fixes MUL-123
Resolves MUL-123
```
-A reference-only mention in the body, such as `Related to MUL-123`, is not shown as a working PR for that issue. Commit messages and PR comments don't trigger linking either.
+A bare mention in the body, such as `Related to MUL-123`, doesn't link the PR to that issue at all. Commit messages and PR comments don't trigger linking either.
## View PRs on an issue
@@ -84,7 +84,7 @@ Click an entry to open the PR on GitHub. Turning off the **PR sidebar** only hid
A merged PR doesn't necessarily mean the issue is finished. Multica only moves an issue to `Done` when all of the following hold:
1. at least one merged linked PR used a close intent immediately followed by the identifier, such as `Closes MUL-123` (forms with words in between, like `Closes login MUL-123`, don't count);
-2. the issue has no other working PR still `Open` or `Draft` (reference-only mentions in the body don't count);
+2. the issue has no other linked PR still `Open` or `Draft`;
3. the issue is not currently `done` or `cancelled`.
So writing `MUL-123` only in the branch name or title establishes the link but doesn't by itself trigger completion. A PR closed without merging doesn't complete the issue either.
@@ -176,7 +176,7 @@ Restart the API server, then complete the connection in **Settings → GitHub**.
- **Connect button disabled**: check that `GITHUB_APP_SLUG` and `GITHUB_WEBHOOK_SECRET` reached the API process.
- **Webhook returns 401**: confirm the GitHub App and the API use the same webhook secret, then redeliver from GitHub's **Recent Deliveries**.
- **PR not linked**: check that the repository is in the App's authorized scope, auto-linking is on, and the identifier belongs to the current workspace.
-- **Identifier in the body but not shown**: switch to `Closes MUL-123`, or put the identifier in the branch name or PR title.
+- **Identifier in the body but not linked**: switch to `Closes MUL-123`, or put the identifier in the branch name or PR title.
- **No CI status**: confirm `GITHUB_APP_ID` and `GITHUB_APP_PRIVATE_KEY` are configured, and that the App has read-only Contents, Checks, and Commit statuses permissions with the matching events subscribed. Without Contents the whole snapshot fails, so the PR card shows neither CI nor merge state. After adding permissions to an installed App, each installation's owner must also approve them on GitHub before they take effect.
- **Issue not completed after the PR merged**: confirm the PR used a close intent, and check whether other linked PRs are still Open or Draft.
diff --git a/apps/docs/content/docs/github-integration.zh.mdx b/apps/docs/content/docs/github-integration.zh.mdx
index 4953bc866f..68f7d927ee 100644
--- a/apps/docs/content/docs/github-integration.zh.mdx
+++ b/apps/docs/content/docs/github-integration.zh.mdx
@@ -36,7 +36,7 @@ GitHub 集成只读取安装时授权的仓库,不会提交代码、评论或
| GitHub 集成 | 总开关。关闭后,下面三项不再生效,但不会断开 GitHub App。 |
| PR 侧栏 | 在任务详情中显示关联的 pull request。 |
| Co-authored-by | 在智能体创建的 commit 中加入 `Co-authored-by: multica-agent <[email protected]>`。 |
-| 自动关联 PR | 从 PR 的分支名、标题和正文中识别任务编号。 |
+| 自动关联 PR | 从 PR 的分支名和标题中识别任务编号;正文中只识别紧跟关闭语句的编号。 |
| **PR 卡片 → CI 与可合并性** | 对每个关联的 PR,Multica 从 GitHub API 拉取一份经鉴权的快照,把它的 **CI 状态**和**可合并性**镜像到卡片上(见下方 **PR 卡片展示什么**)。 |
@@ -63,7 +63,7 @@ Fixes MUL-123
Resolves MUL-123
```
-正文中的普通提及,例如 `Related to MUL-123`,不会作为该任务的工作 PR 显示。Commit message 和 PR 评论也不会触发关联。
+正文中的普通提及,例如 `Related to MUL-123`,根本不会与该任务建立关联。Commit message 和 PR 评论也不会触发关联。
## 在任务中查看 PR
@@ -84,7 +84,7 @@ CI 状态和可合并性来自 Multica 从 GitHub API 拉取的快照,两者
PR 合并不一定代表任务已完成。Multica 只有在以下条件同时成立时,才把任务改为 `Done`:
1. 至少一个已合并的关联 PR 使用了紧跟编号的关闭语句,例如 `Closes MUL-123`(`Closes login MUL-123` 这类中间隔词的写法不生效);
-2. 该任务没有其他仍为 `Open` 或 `Draft` 的工作 PR(正文中的普通提及不算);
+2. 该任务没有其他仍为 `Open` 或 `Draft` 的关联 PR;
3. 任务当前不是 `done` 或 `cancelled`。
因此,仅在分支名或标题中写 `MUL-123` 会建立关联,但不会单独触发完成。PR 关闭但没有合并,也不会完成任务。
@@ -176,7 +176,7 @@ make migrate-up
- **连接按钮不可用**:检查 `GITHUB_APP_SLUG` 和 `GITHUB_WEBHOOK_SECRET` 是否已进入 API 进程。
- **Webhook 返回 401**:确认 GitHub App 与 API 使用同一个 Webhook secret,然后在 GitHub 的 **Recent Deliveries** 中重新投递。
- **PR 没有关联**:检查仓库是否在 App 授权范围内、自动关联是否开启,以及编号是否属于当前工作区。
-- **正文写了编号但没显示**:改用 `Closes MUL-123`,或把编号放到分支名、PR 标题中。
+- **正文写了编号但没关联**:改用 `Closes MUL-123`,或把编号放到分支名、PR 标题中。
- **没有 CI 状态**:确认 `GITHUB_APP_ID` 和 `GITHUB_APP_PRIVATE_KEY` 已配置,App 具有 Contents、Checks 与 Commit statuses 的只读权限并订阅了对应事件。缺少 Contents 会让整个快照失败,PR 卡片既没有 CI 也没有合并状态。给已安装的 App 补加权限后,还需要各 installation 的所有者在 GitHub 上批准才会生效。
- **PR 合并后任务没完成**:确认 PR 使用了关闭语句,并检查是否还有其他关联 PR 处于 Open 或 Draft。
diff --git a/apps/docs/content/docs/vcs-integration.ja.mdx b/apps/docs/content/docs/vcs-integration.ja.mdx
index 60145a1dbf..30f692925e 100644
--- a/apps/docs/content/docs/vcs-integration.ja.mdx
+++ b/apps/docs/content/docs/vcs-integration.ja.mdx
@@ -1,6 +1,6 @@
---
title: セルフホスト Git ホスティング
-description: ワークスペースごとにセルフホストの Forgejo、Gitea、GitLab インスタンスを接続し、タスク番号を参照する Pull Request / Merge Request を対応するタスクへ自動的に紐づけ、マージ時に「完了」へ移動して CI ステータスを表示します。
+description: ワークスペースごとにセルフホストの Forgejo、Gitea、GitLab インスタンスを接続し、ブランチ名かタイトルにタスク番号を含む、または本文で終了キーワードの直後にタスク番号を置いた Pull Request / Merge Request を対応するタスクへ自動的に紐づけ、マージ時に「完了」へ移動して CI ステータスを表示します。
---
import { Callout } from "fumadocs-ui/components/callout";
@@ -9,7 +9,7 @@ import { Callout } from "fumadocs-ui/components/callout";
**セルフホスト版 Multica 専用です。** この連携は Multica を**自分でデプロイしている**場合のみ利用でき、Multica Cloud では提供されません。ここでの「セルフホスト」は **Multica 自体**のセルフホストを意味します。通常は独自ネットワーク内の Git インスタンスへアクセスするために使用します。サーバー運用者が `MULTICA_VCS_INTEGRATION_ENABLED=true` を設定して機能を有効にし、`MULTICA_VCS_SECRET_KEY` も設定する必要があります。それまでは、設定 → 連携にこのセクションは表示されません。
</Callout>
-Multica はワークスペースごとにセルフホストの Git ホスティング、**Forgejo**、**Gitea**、**GitLab** のいずれかへ接続します。接続後、ブランチ名、タイトル、本文にタスク番号(例: `MUL-123`)を含む Pull Request(GitLab では Merge Request)は、対応する[タスク](/issues)へ**自動的に紐づけられ**、タスクサイドバーの **Pull requests** に表示されます。終了キーワードを含む PR がマージされると、タスクは「完了」へ移動します。head commit の CI はカード上のチェックバーとして表示されます。
+Multica はワークスペースごとにセルフホストの Git ホスティング、**Forgejo**、**Gitea**、**GitLab** のいずれかへ接続します。接続後、ブランチ名かタイトルにタスク番号(例: `MUL-123`)を含む Pull Request(GitLab では Merge Request)、または本文で終了キーワードの直後にタスク番号を置いた PR は、対応する[タスク](/issues)へ**自動的に紐づけられ**、タスクサイドバーの **Pull requests** に表示されます。終了キーワードを含む PR がマージされると、タスクは「完了」へ移動します。head commit の CI はカード上のチェックバーとして表示されます。
これらの Git ホスティングは GitHub と並行して利用でき、1 つのワークスペースで任意に組み合わせられます。
@@ -76,7 +76,7 @@ Multica は保存済みの secret で各 delivery を検証するため、一致
## ミラーされる内容
- **Pull / Merge Request** — open、closed、merged、draft の状態、作成者、ブランチ、および Git ホスティングが提供する場合は diff 統計。
-- **タスクの紐づけ** — タイトル、本文、ブランチの番号で PR をタスクへ紐づけます。マージ済み PR に終了キーワード(`Closes`/`Fixes`/`Resolves MUL-123`)があり、open の関連 PR が残っていなければ、タスクを「完了」へ移動します。
+- **タスクの紐づけ** — タイトルまたはブランチの番号、および本文で終了キーワードの直後に置いた番号で PR をタスクへ紐づけます。本文中の通常の参照では紐づきません。マージ済み PR に終了キーワード(`Closes`/`Fixes`/`Resolves MUL-123`)があり、open の関連 PR が残っていなければ、タスクを「完了」へ移動します。
- **CI** — Forgejo/Gitea の commit status と GitLab pipeline を、head commit の成功/失敗/進行中チェックバーへ集約します。
## エージェントによる Pull Request の作成
diff --git a/apps/docs/content/docs/vcs-integration.ko.mdx b/apps/docs/content/docs/vcs-integration.ko.mdx
index 4f2d341cf5..702944ae28 100644
--- a/apps/docs/content/docs/vcs-integration.ko.mdx
+++ b/apps/docs/content/docs/vcs-integration.ko.mdx
@@ -1,6 +1,6 @@
---
title: 자체 호스팅 Git 코드 호스팅
-description: 워크스페이스마다 자체 호스팅 Forgejo, Gitea, GitLab 인스턴스를 연결해 태스크 번호를 참조한 Pull Request / Merge Request를 해당 태스크에 자동 연결하고, merge 시 완료로 옮기며 CI 상태를 표시합니다.
+description: 워크스페이스마다 자체 호스팅 Forgejo, Gitea, GitLab 인스턴스를 연결해 브랜치 이름이나 제목에 태스크 번호가 있거나 본문에서 종료 키워드 바로 뒤에 태스크 번호를 적은 Pull Request / Merge Request를 해당 태스크에 자동 연결하고, merge 시 완료로 옮기며 CI 상태를 표시합니다.
---
import { Callout } from "fumadocs-ui/components/callout";
@@ -9,7 +9,7 @@ import { Callout } from "fumadocs-ui/components/callout";
**자체 배포한 Multica에서만 사용할 수 있습니다.** 이 연동은 Multica를 **직접 배포해 운영할 때만** 제공되며 Multica Cloud에서는 사용할 수 없습니다. 여기서 "자체 호스팅"은 **Multica 자체를 배포하는 것**을 뜻합니다. 일반적으로 자체 네트워크의 Git 인스턴스에 접근하기 위해 사용합니다. 서버 운영자가 `MULTICA_VCS_INTEGRATION_ENABLED=true`로 기능을 켜고 `MULTICA_VCS_SECRET_KEY`도 설정해야 합니다. 그전에는 설정 → 연동에 이 영역이 표시되지 않습니다.
</Callout>
-Multica는 워크스페이스별로 자체 호스팅 Git 코드 호스팅인 **Forgejo**, **Gitea**, **GitLab** 중 하나에 연결합니다. 연결하면 브랜치 이름, 제목, 본문에 태스크 번호(예: `MUL-123`)가 포함된 Pull Request(GitLab에서는 Merge Request)가 해당 [태스크](/issues)에 **자동으로 연결**되고 태스크 사이드바의 **Pull requests**에 표시됩니다. 종료 키워드가 있는 PR이 merge되면 태스크가 완료로 이동합니다. head commit의 CI는 카드에 check bar로 표시됩니다.
+Multica는 워크스페이스별로 자체 호스팅 Git 코드 호스팅인 **Forgejo**, **Gitea**, **GitLab** 중 하나에 연결합니다. 연결하면 브랜치 이름이나 제목에 태스크 번호(예: `MUL-123`)가 포함된 Pull Request(GitLab에서는 Merge Request), 또는 본문에서 종료 키워드 바로 뒤에 번호를 적은 PR이 해당 [태스크](/issues)에 **자동으로 연결**되고 태스크 사이드바의 **Pull requests**에 표시됩니다. 종료 키워드가 있는 PR이 merge되면 태스크가 완료로 이동합니다. head commit의 CI는 카드에 check bar로 표시됩니다.
이 코드 호스팅은 GitHub와 동시에 사용할 수 있으며 워크스페이스 하나에서 원하는 대로 조합할 수 있습니다.
@@ -76,7 +76,7 @@ Multica는 저장된 secret으로 모든 delivery를 검증하므로 일치하
## 미러링되는 내용
- **Pull / Merge Request** — open, closed, merged, draft 상태와 작성자, 브랜치, 그리고 코드 호스팅이 제공하는 경우 diff 통계.
-- **태스크 연결** — 제목, 본문, 브랜치의 번호가 PR을 태스크에 연결합니다. merge된 PR에 종료 키워드(`Closes`/`Fixes`/`Resolves MUL-123`)가 있고 open 상태인 연결 PR이 더 없으면 태스크를 완료로 옮깁니다.
+- **태스크 연결** — 제목이나 브랜치의 번호, 그리고 본문에서 종료 키워드 바로 뒤에 있는 번호가 PR을 태스크에 연결합니다. 본문의 일반 언급은 아무것도 연결하지 않습니다. merge된 PR에 종료 키워드(`Closes`/`Fixes`/`Resolves MUL-123`)가 있고 open 상태인 연결 PR이 더 없으면 태스크를 완료로 옮깁니다.
- **CI** — Forgejo/Gitea commit status와 GitLab pipeline을 head commit의 통과/실패/진행 중 check bar로 집계합니다.
## 에이전트의 Pull Request 생성
diff --git a/apps/docs/content/docs/vcs-integration.mdx b/apps/docs/content/docs/vcs-integration.mdx
index 1232c09e92..f62108fa1b 100644
--- a/apps/docs/content/docs/vcs-integration.mdx
+++ b/apps/docs/content/docs/vcs-integration.mdx
@@ -1,6 +1,6 @@
---
title: Self-hosted Git providers
-description: Connect a self-hosted Forgejo, Gitea, or GitLab instance per workspace so pull/merge requests that reference an issue identifier auto-attach to that issue, move it to Done on merge, and show CI status.
+description: Connect a self-hosted Forgejo, Gitea, or GitLab instance per workspace so pull/merge requests that carry an issue identifier in their branch name or title, or after a closing keyword in the body, auto-attach to that issue, move it to Done on merge, and show CI status.
---
import { Callout } from "fumadocs-ui/components/callout";
@@ -14,7 +14,7 @@ and set `MULTICA_VCS_SECRET_KEY`; until then the section does not appear in
Settings → Integrations.
</Callout>
-Multica connects to a self-hosted Git provider per workspace: **Forgejo**, **Gitea**, or **GitLab**. Once connected, any pull request (GitLab: merge request) whose branch name, title, or body contains an issue identifier (for example `MUL-123`) is **auto-linked** to that [issue](/issues), appears under **Pull requests** in the issue sidebar, and — when merged with a closing keyword — moves the issue to **Done**. CI for the head commit shows as a checks bar on the card.
+Multica connects to a self-hosted Git provider per workspace: **Forgejo**, **Gitea**, or **GitLab**. Once connected, any pull request (GitLab: merge request) whose branch name or title contains an issue identifier (for example `MUL-123`), or whose body names one after a closing keyword (`Closes MUL-123`), is **auto-linked** to that [issue](/issues), appears under **Pull requests** in the issue sidebar, and — when merged with a closing keyword — moves the issue to **Done**. CI for the head commit shows as a checks bar on the card.
These providers run alongside GitHub: a workspace can use any combination.
@@ -81,7 +81,7 @@ Multica authenticates every delivery against the stored secret, so a webhook wit
## What gets mirrored
- **Pull / merge requests** — open, closed, merged, and draft state, author, branch, and (where the provider supplies them) diff stats.
-- **Issue links** — identifiers in the title, body, or branch link the PR to the issue. A closing keyword (`Closes`/`Fixes`/`Resolves MUL-123`) on a merged PR moves the issue to **Done** once no linked PR is still open.
+- **Issue links** — an identifier in the title or branch links the PR to the issue, as does an identifier after a closing keyword in the body; a bare mention in the body links nothing. A closing keyword (`Closes`/`Fixes`/`Resolves MUL-123`) on a merged PR moves the issue to **Done** once no linked PR is still open.
- **CI** — Forgejo/Gitea commit statuses and GitLab pipelines aggregate into a passed/failed/pending checks bar for the head commit.
## Agents opening pull requests
diff --git a/apps/docs/content/docs/vcs-integration.zh.mdx b/apps/docs/content/docs/vcs-integration.zh.mdx
index 6cfc9cd562..d5801735c6 100644
--- a/apps/docs/content/docs/vcs-integration.zh.mdx
+++ b/apps/docs/content/docs/vcs-integration.zh.mdx
@@ -1,6 +1,6 @@
---
title: 自托管 Git 代码托管
-description: 为每个工作区连接自托管的 Forgejo、Gitea 或 GitLab 实例,使引用了任务编号的 Pull Request / Merge Request 自动关联到对应任务,在合并时将其移动到「完成」,并展示 CI 状态。
+description: 为每个工作区连接自托管的 Forgejo、Gitea 或 GitLab 实例,使分支名或标题中带有任务编号、或正文中在关闭关键字后带有任务编号的 Pull Request / Merge Request 自动关联到对应任务,在合并时将其移动到「完成」,并展示 CI 状态。
---
import { Callout } from "fumadocs-ui/components/callout";
@@ -9,7 +9,7 @@ import { Callout } from "fumadocs-ui/components/callout";
**仅适用于自部署的 Multica。** 此集成只在你**自己部署 Multica** 时可用,Multica 云端不提供。这里的「自托管」指的是 **Multica 本身自部署**——通常是为了让它能访问你自己网络内的 Git 实例。需要服务端运维开启(`MULTICA_VCS_INTEGRATION_ENABLED=true`)并设置 `MULTICA_VCS_SECRET_KEY`;在此之前,设置 → 集成里不会出现该板块。
</Callout>
-Multica 按工作区连接自托管的 Git 代码托管:**Forgejo**、**Gitea** 或 **GitLab**。连接后,任何在分支名、标题或正文中包含任务编号(例如 `MUL-123`)的 Pull Request(GitLab 为 Merge Request)都会**自动关联**到对应的 [任务](/issues),出现在任务侧栏的 **Pull requests** 中;当带有关闭关键字的 PR 合并后,任务会被移动到「完成」。head commit 的 CI 会以检查条的形式显示在卡片上。
+Multica 按工作区连接自托管的 Git 代码托管:**Forgejo**、**Gitea** 或 **GitLab**。连接后,任何在分支名或标题中包含任务编号(例如 `MUL-123`)、或在正文的关闭关键字后写出该编号(`Closes MUL-123`)的 Pull Request(GitLab 为 Merge Request)都会**自动关联**到对应的 [任务](/issues),出现在任务侧栏的 **Pull requests** 中;当带有关闭关键字的 PR 合并后,任务会被移动到「完成」。head commit 的 CI 会以检查条的形式显示在卡片上。
这些代码托管与 GitHub 并行工作:一个工作区可任意组合使用。
@@ -76,7 +76,7 @@ Multica 会用存储的密钥校验每次投递,因此没有匹配密钥的 We
## 镜像的内容
- **Pull / Merge Request** —— open、closed、merged、draft 状态,以及作者、分支和(在代码托管提供时)diff 统计。
-- **任务关联** —— 标题、正文或分支中的编号会将 PR 关联到任务。合并的 PR 带有关闭关键字(`Closes`/`Fixes`/`Resolves MUL-123`)且没有仍处于 open 的关联 PR 时,任务会被移动到「完成」。
+- **任务关联** —— 标题或分支中的编号会将 PR 关联到任务,正文中的编号只有紧跟关闭关键字时才会关联;正文中的普通提及不会建立任何关联。合并的 PR 带有关闭关键字(`Closes`/`Fixes`/`Resolves MUL-123`)且没有仍处于 open 的关联 PR 时,任务会被移动到「完成」。
- **CI** —— Forgejo/Gitea 的提交状态与 GitLab 的流水线会汇总为 head commit 的通过/失败/进行中检查条。
## 智能体创建 Pull Request
diff --git a/packages/views/locales/en/issues.json b/packages/views/locales/en/issues.json
index a7c08c098c..0dfe540fc1 100644
--- a/packages/views/locales/en/issues.json
+++ b/packages/views/locales/en/issues.json
@@ -372,7 +372,7 @@
"quick_action_blocked_body": "“{{name}}” runs as an agent you’re not allowed to trigger. Ask a workspace admin to make that agent available to the team, or to point this action at a shared one.",
"quick_action_blocked_ok": "Got it",
"pull_requests_loading": "Loading…",
- "pull_requests_empty": "No linked pull requests yet. Reference this issue's identifier in a PR's branch name, title, or body to auto-link it.",
+ "pull_requests_empty": "No linked pull requests yet. Put this issue's identifier in a PR's branch name or title, or write it after Closes in the PR body, to auto-link it.",
"pull_request_state_open": "Open",
"pull_request_state_draft": "Draft",
"pull_request_state_merged": "Merged",
diff --git a/packages/views/locales/en/settings.json b/packages/views/locales/en/settings.json
index eee1affad9..8222ab3bdc 100644
--- a/packages/views/locales/en/settings.json
+++ b/packages/views/locales/en/settings.json
@@ -729,8 +729,8 @@
"master_description_off": "GitHub features are turned off. The PR sidebar, co-author trailer, and auto-link are paused. Data on the backend is not deleted.",
"section_connection": "Connection",
"connection_title": "GitHub App",
- "connection_description_prefix": "Link issues to pull requests automatically. When a PR with",
- "connection_description_suffix": "in its branch, title, or body is merged, the corresponding issue moves to",
+ "connection_description_prefix": "Link issues to pull requests automatically. A PR links when",
+ "connection_description_suffix": "is in its branch name or title, or its body says Closes MUL-123. Merging a PR with that closing keyword also moves the issue to",
"connection_description_done": "Done",
"connection_identifier_example": "MUL-123",
"connected_to": "Connected to {{login}}",
@@ -759,7 +759,7 @@
"feature_co_author_description_prefix": "Append",
"feature_co_author_description_suffix": "to commits authored by agents.",
"feature_auto_link_label": "Auto-link issues and PRs",
- "feature_auto_link_description": "Match PR titles, bodies, and branch names against issue identifiers and create the link automatically.",
+ "feature_auto_link_description": "Match PR titles and branch names against issue identifiers, along with identifiers after a closing keyword in the body, and create the link automatically.",
"section_repositories": "Repositories",
"repositories_shortcut_label": "Repository URLs live in the Repositories tab",
"repositories_shortcut_link": "Manage repositories →",
diff --git a/packages/views/locales/ja/issues.json b/packages/views/locales/ja/issues.json
index 2fabbef122..54cc916978 100644
--- a/packages/views/locales/ja/issues.json
+++ b/packages/views/locales/ja/issues.json
@@ -368,7 +368,7 @@
"quick_action_blocked_body": "「{{name}}」は、あなたが実行を許可されていないエージェントで動作します。ワークスペース管理者にそのエージェントをチームへ公開してもらうか、共有エージェントへの変更を依頼してください。",
"quick_action_blocked_ok": "了解",
"pull_requests_loading": "読み込み中...",
- "pull_requests_empty": "まだリンクされた Pull request がありません。PR のブランチ名、タイトル、または本文にこのタスクの識別子を入れると、自動的にリンクされます。",
+ "pull_requests_empty": "まだリンクされた Pull request がありません。このタスクの識別子を PR のブランチ名かタイトルに入れるか、本文で Closes の直後に書くと、自動的にリンクされます。",
"pull_request_state_open": "オープン",
"pull_request_state_draft": "ドラフト",
"pull_request_state_merged": "マージ済み",
diff --git a/packages/views/locales/ja/settings.json b/packages/views/locales/ja/settings.json
index 77b987e340..f28402e16d 100644
--- a/packages/views/locales/ja/settings.json
+++ b/packages/views/locales/ja/settings.json
@@ -727,8 +727,8 @@
"master_description_off": "GitHub 機能はオフです。PR サイドバー、Co-authored-by トレーラー、自動リンクが一時停止されています。バックエンドのデータは削除されません。",
"section_connection": "接続",
"connection_title": "GitHub App",
- "connection_description_prefix": "タスクを Pull request に自動でリンクします。ブランチ、タイトル、または本文に",
- "connection_description_suffix": "を含む PR がマージされると、対応するタスクが次のステータスに移動します:",
+ "connection_description_prefix": "タスクを Pull request に自動でリンクします。PR のブランチ名かタイトルに",
+ "connection_description_suffix": "があるか、本文に Closes MUL-123 と書かれていれば、対応するタスクにリンクされます。その closing keyword を含む PR がマージされたときだけ、タスクが次のステータスに移動します:",
"connection_description_done": "完了",
"connection_identifier_example": "MUL-123",
"connected_to": "{{login}} に接続済み",
@@ -757,7 +757,7 @@
"feature_co_author_description_prefix": "エージェントが作成したコミットに",
"feature_co_author_description_suffix": "を追加します。",
"feature_auto_link_label": "タスクと PR を自動リンク",
- "feature_auto_link_description": "PR のタイトル、本文、ブランチ名をタスク識別子と照合し、自動でリンクを作成します。",
+ "feature_auto_link_description": "PR のタイトルとブランチ名、および本文で closing keyword の直後にある番号をタスク識別子と照合し、自動でリンクを作成します。",
"section_repositories": "リポジトリ",
"repositories_shortcut_label": "リポジトリ URL はリポジトリタブにあります",
"repositories_shortcut_link": "リポジトリを管理 →",
diff --git a/packages/views/locales/ko/issues.json b/packages/views/locales/ko/issues.json
index a11286b582..011263b399 100644
--- a/packages/views/locales/ko/issues.json
+++ b/packages/views/locales/ko/issues.json
@@ -368,7 +368,7 @@
"quick_action_blocked_body": "“{{name}}”은(는) 트리거 권한이 없는 에이전트로 실행됩니다. 워크스페이스 관리자에게 해당 에이전트를 팀에 공개하거나 공유 에이전트로 변경해 달라고 요청하세요.",
"quick_action_blocked_ok": "확인",
"pull_requests_loading": "불러오는 중...",
- "pull_requests_empty": "아직 연결된 Pull request가 없습니다. PR 브랜치 이름, 제목 또는 본문에 이 태스크 식별자를 넣으면 자동으로 연결됩니다.",
+ "pull_requests_empty": "아직 연결된 Pull request가 없습니다. 이 태스크 식별자를 PR 브랜치 이름이나 제목에 넣거나, 본문에서 Closes 바로 뒤에 적으면 자동으로 연결됩니다.",
"pull_request_state_open": "열림",
"pull_request_state_draft": "초안",
"pull_request_state_merged": "병합됨",
diff --git a/packages/views/locales/ko/settings.json b/packages/views/locales/ko/settings.json
index 24c23cc703..85851fec45 100644
--- a/packages/views/locales/ko/settings.json
+++ b/packages/views/locales/ko/settings.json
@@ -727,8 +727,8 @@
"master_description_off": "GitHub 기능이 꺼져 있습니다. PR 사이드바, Co-authored-by 트레일러, 자동 연결이 일시 중지됩니다. 백엔드 데이터는 삭제되지 않습니다.",
"section_connection": "연결",
"connection_title": "GitHub App",
- "connection_description_prefix": "태스크를 Pull request에 자동으로 연결합니다. 브랜치, 제목 또는 본문에",
- "connection_description_suffix": "이(가) 있는 PR이 병합되면 해당 태스크가",
+ "connection_description_prefix": "태스크를 Pull request에 자동으로 연결합니다. PR의 브랜치 이름이나 제목에",
+ "connection_description_suffix": "이(가) 있거나 본문에 Closes MUL-123이 있으면 해당 태스크에 연결되고, 그 종료 키워드가 있는 PR이 병합될 때만 해당 태스크가",
"connection_description_done": "완료",
"connection_identifier_example": "MUL-123",
"connected_to": "{{login}}에 연결됨",
@@ -757,7 +757,7 @@
"feature_co_author_description_prefix": "에이전트가 작성한 커밋에",
"feature_co_author_description_suffix": "을(를) 추가합니다.",
"feature_auto_link_label": "태스크와 PR 자동 연결",
- "feature_auto_link_description": "PR 제목, 본문, 브랜치 이름을 태스크 식별자와 대조해 자동으로 연결합니다.",
+ "feature_auto_link_description": "PR 제목과 브랜치 이름, 그리고 본문에서 종료 키워드 바로 뒤에 있는 번호를 태스크 식별자와 대조해 자동으로 연결합니다.",
"section_repositories": "저장소",
"repositories_shortcut_label": "저장소 URL은 저장소 탭에 있습니다",
"repositories_shortcut_link": "저장소 관리 →",
diff --git a/packages/views/locales/zh-Hans/issues.json b/packages/views/locales/zh-Hans/issues.json
index 4c308301ba..cc18261f5a 100644
--- a/packages/views/locales/zh-Hans/issues.json
+++ b/packages/views/locales/zh-Hans/issues.json
@@ -368,7 +368,7 @@
"quick_action_blocked_body": "\"{{name}}\"由一个你无权触发的智能体执行。可以请工作区管理员把该智能体开放给团队,或把这条操作改绑一个共享的智能体。",
"quick_action_blocked_ok": "知道了",
"pull_requests_loading": "加载中...",
- "pull_requests_empty": "还没有关联的 PR。在 PR 的分支名、标题或正文里引用本任务的 identifier 即可自动关联。",
+ "pull_requests_empty": "还没有关联的 PR。把本任务的 identifier 写进 PR 的分支名或标题,或者在正文里写在 Closes 后面,即可自动关联。",
"pull_request_state_open": "Open",
"pull_request_state_draft": "Draft",
"pull_request_state_merged": "Merged",
diff --git a/packages/views/locales/zh-Hans/settings.json b/packages/views/locales/zh-Hans/settings.json
index 7d16eef7d0..8f28ec787c 100644
--- a/packages/views/locales/zh-Hans/settings.json
+++ b/packages/views/locales/zh-Hans/settings.json
@@ -727,8 +727,8 @@
"master_description_off": "GitHub 功能已关闭。PR 侧栏、Co-authored-by trailer 与自动关联都已暂停。后台数据未删除。",
"section_connection": "连接",
"connection_title": "GitHub App",
- "connection_description_prefix": "自动把任务关联到 Pull Request。当 PR 的分支、标题或正文中包含",
- "connection_description_suffix": "并被合并时,对应的任务会自动转为",
+ "connection_description_prefix": "自动把任务关联到 Pull Request。只要 PR 的分支名或标题里出现",
+ "connection_description_suffix": "或正文里写了 Closes MUL-123,PR 就会关联到对应任务;只有带关闭关键字的 PR 合并后,任务才会转为",
"connection_description_done": "已完成",
"connection_identifier_example": "MUL-123",
"connected_to": "已连接到 {{login}}",
@@ -757,7 +757,7 @@
"feature_co_author_description_prefix": "在智能体提交的 commit 中追加",
"feature_co_author_description_suffix": "。",
"feature_auto_link_label": "任务 ↔ PR 自动关联",
- "feature_auto_link_description": "根据 PR 标题、正文和分支名匹配任务编号并自动建立链接。",
+ "feature_auto_link_description": "根据 PR 标题和分支名匹配任务编号,正文中只匹配关闭关键字后面的编号,并自动建立链接。",
"section_repositories": "代码仓库",
"repositories_shortcut_label": "仓库 URL 仍在\"代码仓库\"标签页中管理",
"repositories_shortcut_link": "前往管理 →",
diff --git a/server/internal/handler/github.go b/server/internal/handler/github.go
index 2dca6de3cf..3b79f3ec63 100644
--- a/server/internal/handler/github.go
+++ b/server/internal/handler/github.go
@@ -1579,8 +1579,7 @@ func (h *Handler) mirrorPullRequestForWorkspace(ctx context.Context, wsID pgtype
if h.workspaceAutoLinkPRsEnabled(ctx, wsID) {
idents := extractIdentifiers(p.PullRequest.Title, p.PullRequest.Body, p.PullRequest.Head.Ref)
// closingIdents is the subset of identifiers that this PR explicitly
- // declared via a closing keyword ("Closes/Fixes/Resolves MUL-X").
- // Linking still happens for every mention (idents above), but the
+ // declared via a closing keyword ("Closes/Fixes/Resolves MUL-X"). The
// link row's close_intent column — and therefore whether the
// auto-advance gate eventually fires — is only set for keyword-
// declared identifiers. Bare title prefixes and branch-name
@@ -1589,20 +1588,25 @@ func (h *Handler) mirrorPullRequestForWorkspace(ctx context.Context, wsID pgtype
for _, c := range extractClosingIdentifiers(p.PullRequest.Title, p.PullRequest.Body) {
closingIdents[c] = struct{}{}
}
- // qualifyingIdents are the identifiers that genuinely tie this PR to an
- // issue: a title prefix, a branch-name reference, or a body closing
- // keyword. Any identifier that is linked but NOT in this set was matched
- // only by a bare mention in the PR body ("Related MUL-1", "Follow up in
- // MUL-1"). Those links are still recorded (auto-link stays generous so
- // close_intent can be tracked across edits) but are flagged
- // reference_only and hidden from the issue's PR list — a passing mention
- // should not surface the PR as a working PR for that issue (MUL-3739).
- qualifyingIdents := map[string]struct{}{}
+ // claimedIdents are the identifiers this PR actually claims: a title
+ // prefix, a branch-name reference, or a body closing keyword. An
+ // identifier matched only by a bare mention in the body ("Related
+ // MUL-1", "Follow up in MUL-1") is not a claim — a passing mention must
+ // not surface the PR as a working PR for that issue (MUL-3739) — so it
+ // gets no link row at all, and drops one an earlier claim had created.
+ //
+ // MUL-3739 used to write that row anyway and flag it reference_only,
+ // hidden from every read path. A hidden row had no reader, and once the
+ // PR went terminal the preserve gate froze the flag, so adding a closing
+ // keyword to a merged PR's body could never surface it — the one
+ // recovery action a user can take was the one that could not work
+ // (MUL-7072).
+ claimedIdents := map[string]struct{}{}
for _, id := range extractIdentifiers(p.PullRequest.Title, p.PullRequest.Head.Ref) {
- qualifyingIdents[id] = struct{}{}
+ claimedIdents[id] = struct{}{}
}
for c := range closingIdents {
- qualifyingIdents[c] = struct{}{}
+ claimedIdents[c] = struct{}{}
}
// close_intent should follow the PR title/body while the PR is still
// editable before its terminal close event. Once GitHub has delivered
@@ -1625,6 +1629,27 @@ func (h *Handler) mirrorPullRequestForWorkspace(ctx context.Context, wsID pgtype
if !ok {
continue
}
+ if _, claimed := claimedIdents[id]; !claimed {
+ // A passing mention. Never links; while the PR is still
+ // editable it also drops a link an earlier claim created, so
+ // the list follows the live parse. Once the PR is terminal the
+ // same preserve rule that freezes close_intent applies: a
+ // post-merge edit must not unlink a PR that did the work.
+ if preserveCloseIntent {
+ continue
+ }
+ if err := h.Queries.UnlinkIssueFromPullRequest(ctx, db.UnlinkIssueFromPullRequestParams{
+ IssueID: issue.ID,
+ PullRequestID: pr.ID,
+ }); err != nil {
+ slog.Warn("github: unlink failed", "err", err)
+ continue
+ }
+ // Dropping a link can be what lets the issue advance, so the
+ // gate below still re-evaluates it.
+ reevalIssues = append(reevalIssues, issue)
+ continue
+ }
_, declared := closingIdents[id]
if declared && !closePolicy.permits(id, workspaceID) {
// The delivery-wide scan did not prove this workspace is the one
@@ -1635,13 +1660,10 @@ func (h *Handler) mirrorPullRequestForWorkspace(ctx context.Context, wsID pgtype
declared = false
}
closeIntent := declared && !preserveCloseIntent
- _, qualifies := qualifyingIdents[id]
- referenceOnly := !qualifies
if err := h.Queries.LinkIssueToPullRequest(ctx, db.LinkIssueToPullRequestParams{
IssueID: issue.ID,
PullRequestID: pr.ID,
CloseIntent: closeIntent,
- ReferenceOnly: referenceOnly,
PreserveCloseIntent: preserveCloseIntent,
LinkedByType: strToText("system"),
LinkedByID: pgtype.UUID{},
diff --git a/server/internal/handler/github_test.go b/server/internal/handler/github_test.go
index d04026024f..12d26cd66d 100644
--- a/server/internal/handler/github_test.go
+++ b/server/internal/handler/github_test.go
@@ -986,9 +986,8 @@ func TestWebhook_MergedPR_OnlyClosesIdentifiersWithClosingKeyword(t *testing.T)
// The closing-keyword issue (also a bare title prefix) is a genuine target,
// so it shows in the PR list. The follow-up / unblocks issues are matched
- // only by a bare body mention — auto-link still records the row (generous),
- // but the link is reference_only and excluded from the issue's PR list
- // (MUL-3739).
+ // only by a bare body mention, which claims nothing and is therefore not
+ // linked at all (MUL-3739, MUL-7072).
listed, err := testHandler.Queries.ListPullRequestsByIssue(ctx, parseUUID(closes.ID))
if err != nil {
t.Fatalf("ListPullRequestsByIssue(%s): %v", closes.Identifier, err)
@@ -1002,16 +1001,16 @@ func TestWebhook_MergedPR_OnlyClosesIdentifiersWithClosingKeyword(t *testing.T)
t.Fatalf("ListPullRequestsByIssue(%s): %v", issue.Identifier, err)
}
if len(listed) != 0 {
- t.Errorf("expected %s (bare body mention) to be hidden from the PR list, got %d rows", issue.Identifier, len(listed))
+ t.Errorf("expected %s (bare body mention) to be absent from the PR list, got %d rows", issue.Identifier, len(listed))
}
- // The link row still exists — flagged reference_only, not deleted — so
- // close_intent stays trackable across later edits.
- var refOnly bool
+ // And no row was written: a passing mention leaves nothing behind that a
+ // later read path or a schema change could surface.
+ var links int
dbfx.QueryRow(t,
- `SELECT reference_only FROM issue_pull_request WHERE issue_id = $1`, issue.ID,
- ).Scan(&refOnly)
- if !refOnly {
- t.Errorf("expected %s link to be reference_only, got false", issue.Identifier)
+ `SELECT count(*) FROM issue_pull_request WHERE issue_id = $1`, issue.ID,
+ ).Scan(&links)
+ if links != 0 {
+ t.Errorf("expected %s to have no link row, got %d", issue.Identifier, links)
}
}
@@ -1380,13 +1379,13 @@ func TestWebhook_LinkOnlySiblingMergeAfterCloseKeywordPR(t *testing.T) {
}
}
-// TestWebhook_BareBodyMentionHiddenFromPRList is the regression guard for
-// MUL-3739: a PR that only mentions an issue identifier in its body (no closing
-// keyword, no title prefix, no branch reference) must not appear in that
-// issue's PR list. Editing the body to add/remove a closing keyword flips the
-// PR's visibility, because reference_only follows the live title/body parse
-// while the PR is still open.
-func TestWebhook_BareBodyMentionHiddenFromPRList(t *testing.T) {
+// TestWebhook_BareBodyMentionIsNotLinked is the regression guard for MUL-3739:
+// a PR that only mentions an issue identifier in its body (no closing keyword,
+// no title prefix, no branch reference) claims nothing, so it must not appear in
+// that issue's PR list. Editing the body to add or remove a closing keyword
+// flips the link itself — while the PR is still open the link follows the live
+// title/body parse (MUL-7072).
+func TestWebhook_BareBodyMentionIsNotLinked(t *testing.T) {
if testHandler == nil {
t.Skip("handler test fixture not initialized (no DB?)")
}
@@ -1429,10 +1428,10 @@ func TestWebhook_BareBodyMentionHiddenFromPRList(t *testing.T) {
return len(rows)
}
- // 1) Opened with only a bare body mention → hidden from the PR list.
+ // 1) Opened with only a bare body mention → no link, nothing in the list.
firePRWebhook(t, secret, installationID, 1, "Unrelated cleanup", "Context for reviewers: see "+created.Identifier, "feat/cleanup", "opened")
if n := listLen(); n != 0 {
- t.Errorf("bare body mention should be hidden from PR list, got %d rows", n)
+ t.Errorf("bare body mention should not link, got %d rows", n)
}
// 2) Edited to declare closing intent → now a genuine target, shown.
@@ -1441,20 +1440,106 @@ func TestWebhook_BareBodyMentionHiddenFromPRList(t *testing.T) {
t.Errorf("after adding a closing keyword the PR should show, got %d rows", n)
}
- // 3) Edited back to a bare mention → hidden again.
+ // 3) Edited back to a bare mention → the claim is withdrawn, link dropped.
firePRWebhook(t, secret, installationID, 1, "Unrelated cleanup", "Reverting: just referencing "+created.Identifier, "feat/cleanup", "edited")
if n := listLen(); n != 0 {
- t.Errorf("after removing the closing keyword the PR should be hidden again, got %d rows", n)
+ t.Errorf("after removing the closing keyword the PR should be unlinked, got %d rows", n)
+ }
+
+ // 4) The same withdrawal must leave no row behind, not a hidden one.
+ var links int
+ dbfx.QueryRow(t,
+ `SELECT count(*) FROM issue_pull_request WHERE issue_id = $1`, created.ID,
+ ).Scan(&links)
+ if links != 0 {
+ t.Errorf("withdrawn claim should leave no link row, got %d", links)
+ }
+}
+
+// TestWebhook_PostMergeClosingKeywordLinksThePR is the MUL-7072 regression
+// guard. A PR that only mentioned the issue in its body, merged, and then had
+// `Closes KEY` added to the body must show up on the issue: editing the body is
+// the one repair a user can make from GitHub, and the pre-MUL-7072 reference_only
+// row made it a no-op forever (the preserve gate kept the row hidden, and no
+// unlink surface existed to clear it).
+//
+// The close-intent decision still stays frozen at merge time: the PR appears,
+// but it does not retroactively advance the issue to done.
+func TestWebhook_PostMergeClosingKeywordLinksThePR(t *testing.T) {
+ if testHandler == nil {
+ t.Skip("handler test fixture not initialized (no DB?)")
+ }
+ ctx := context.Background()
+ secret := "post-merge-closes-secret"
+ t.Setenv("GITHUB_WEBHOOK_SECRET", secret)
+
+ req := newRequest("POST", "/api/issues?workspace_id="+testWorkspaceID, map[string]any{
+ "title": "repaired after merge",
+ "status": "in_progress",
+ })
+ w := testutil.Call(t, testHandler.CreateIssue, req).Want(http.StatusCreated)
+ var created IssueResponse
+ json.NewDecoder(w.Body).Decode(&created)
+
+ t.Cleanup(func() {
+ testPool.Exec(ctx, `DELETE FROM issue_pull_request WHERE issue_id = $1`, created.ID)
+ testPool.Exec(ctx, `DELETE FROM activity_log WHERE issue_id = $1`, created.ID)
+ testPool.Exec(ctx, `DELETE FROM github_pull_request WHERE workspace_id = $1`, testWorkspaceID)
+ testPool.Exec(ctx, `DELETE FROM github_installation WHERE workspace_id = $1`, testWorkspaceID)
+ testPool.Exec(ctx, `DELETE FROM issue WHERE id = $1`, created.ID)
+ })
+
+ const installationID int64 = 30264009
+ if _, err := testHandler.Queries.CreateGitHubInstallation(ctx, db.CreateGitHubInstallationParams{
+ WorkspaceID: parseUUID(testWorkspaceID),
+ InstallationID: installationID,
+ AccountLogin: "post-merge-closes-acct",
+ AccountType: "User",
+ }); err != nil {
+ t.Fatalf("CreateGitHubInstallation: %v", err)
+ }
+
+ // Opened and merged with nothing but a passing body mention: no link.
+ firePRWebhook(t, secret, installationID, 1, "Dependency bump", "Context: see "+created.Identifier, "chore/bump", "opened")
+ firePRWebhook(t, secret, installationID, 1, "Dependency bump", "Context: see "+created.Identifier, "chore/bump", "merged")
+ listed, err := testHandler.Queries.ListPullRequestsByIssue(ctx, parseUUID(created.ID))
+ if err != nil {
+ t.Fatalf("ListPullRequestsByIssue after merge: %v", err)
+ }
+ if len(listed) != 0 {
+ t.Fatalf("passing mention must not link, got %d rows", len(listed))
+ }
+
+ // The author edits the merged PR's body to declare the issue properly.
+ firePRWebhook(t, secret, installationID, 1, "Dependency bump", "Closes "+created.Identifier, "chore/bump", "edited_merged")
+ listed, err = testHandler.Queries.ListPullRequestsByIssue(ctx, parseUUID(created.ID))
+ if err != nil {
+ t.Fatalf("ListPullRequestsByIssue after post-merge edit: %v", err)
+ }
+ if len(listed) != 1 {
+ t.Fatalf("post-merge closing keyword should link the PR, got %d rows", len(listed))
+ }
+ if listed[0].State != "merged" {
+ t.Errorf("linked PR state = %q, want merged", listed[0].State)
+ }
+
+ // Close intent stays a merge-time decision: the issue must not advance.
+ got, err := testHandler.Queries.GetIssue(ctx, parseUUID(created.ID))
+ if err != nil {
+ t.Fatalf("GetIssue after post-merge edit: %v", err)
+ }
+ if got.Status != "in_progress" {
+ t.Errorf("post-merge closing keyword must not advance the issue: status = %q, want in_progress", got.Status)
}
}
-// TestWebhook_HiddenBodyMentionDoesNotBlockAutoAdvance guards the P1 the code
-// review flagged on PR #4611: a reference_only link (a PR that only mentions the
-// issue in its body) is hidden from the PR list, so it must not silently gate
-// auto-advance either. Here PR B stays open with a bare body mention while PR A
-// merges with a closing keyword — the issue must still reach `done`, because
-// the invisible PR B is excluded from the close aggregate's open_count.
-func TestWebhook_HiddenBodyMentionDoesNotBlockAutoAdvance(t *testing.T) {
+// TestWebhook_UnlinkedBodyMentionDoesNotBlockAutoAdvance guards the P1 the code
+// review flagged on PR #4611: a PR that only mentions the issue in its body does
+// not show in the PR list, so it must not silently gate auto-advance either.
+// Here PR B stays open with a bare body mention while PR A merges with a closing
+// keyword — the issue must still reach `done`, because PR B was never linked and
+// so never reaches the close aggregate's open_count.
+func TestWebhook_UnlinkedBodyMentionDoesNotBlockAutoAdvance(t *testing.T) {
if testHandler == nil {
t.Skip("handler test fixture not initialized (no DB?)")
}
@@ -1488,12 +1573,12 @@ func TestWebhook_HiddenBodyMentionDoesNotBlockAutoAdvance(t *testing.T) {
t.Fatalf("CreateGitHubInstallation: %v", err)
}
- // PR B opens with only a bare body mention → reference_only, hidden, open.
+ // PR B opens with only a bare body mention → claims nothing, not linked.
firePRWebhook(t, secret, installationID, 1, "Unrelated cleanup", "Context: see "+created.Identifier, "feat/cleanup", "opened")
// PR A opens with a closing keyword → genuine closing PR.
firePRWebhook(t, secret, installationID, 2, "Primary work", "Closes "+created.Identifier, "feat/primary", "opened")
- // Only PR A shows in the list; PR B is hidden.
+ // Only PR A shows in the list; PR B was never linked.
listed, err := testHandler.Queries.ListPullRequestsByIssue(ctx, parseUUID(created.ID))
if err != nil {
t.Fatalf("ListPullRequestsByIssue: %v", err)
@@ -1511,15 +1596,15 @@ func TestWebhook_HiddenBodyMentionDoesNotBlockAutoAdvance(t *testing.T) {
t.Fatalf("after both PRs opened: status = %q, want in_progress", got.Status)
}
- // PR A merges. PR B is still open but reference_only, so it must NOT count
- // toward open_count — the issue should advance to done.
+ // PR A merges. PR B is still open but unlinked, so it must NOT count toward
+ // open_count — the issue should advance to done.
firePRWebhook(t, secret, installationID, 2, "Primary work", "Closes "+created.Identifier, "feat/primary", "merged")
got, err = testHandler.Queries.GetIssue(ctx, parseUUID(created.ID))
if err != nil {
t.Fatalf("GetIssue after merge: %v", err)
}
if got.Status != "done" {
- t.Errorf("closing PR merged while only a hidden body-only mention is open: status = %q, want done", got.Status)
+ t.Errorf("closing PR merged while only an unlinked body-only mention is open: status = %q, want done", got.Status)
}
}
diff --git a/server/internal/handler/vcs_webhook.go b/server/internal/handler/vcs_webhook.go
index c31e12eeb5..59590b8458 100644
--- a/server/internal/handler/vcs_webhook.go
+++ b/server/internal/handler/vcs_webhook.go
@@ -188,16 +188,17 @@ func (h *Handler) mirrorVCSPullRequest(ctx context.Context, conn db.VcsConnectio
return
}
- // Out-of-order guard for the link metadata. UpsertVCSPullRequest keeps the
+ // Out-of-order guard for the link write. UpsertVCSPullRequest keeps the
// newer persisted row on a stale redelivery, so `pr` may reflect a newer
- // event than this `ev`. Everything the link write derives below —
- // close_intent, reference_only, preserveCloseIntent — comes from `ev`, so
- // rewriting the link from a stale event would corrupt what the newer event
- // already set (e.g. a redelivered older "opened" event flipping a merged
- // PR's link back to reference_only, blocking auto-advance). If the persisted
- // row is strictly newer than this event, the newer event already linked and
- // published — stop here. (An event with no usable timestamp falls back to
- // now(), which is never strictly after the stored value, so it proceeds.)
+ // event than this `ev`. Everything the link write decides below — whether
+ // the PR still claims the issue, close_intent, preserveCloseIntent — comes
+ // from `ev`, so acting on a stale event would undo what the newer one
+ // already recorded (e.g. a redelivered older "opened" event clearing the
+ // close intent on a merged PR's link, blocking auto-advance, or dropping a
+ // link that event had just written). If the persisted row is strictly newer
+ // than this event, the newer event already linked and published — stop
+ // here. (An event with no usable timestamp falls back to now(), which is
+ // never strictly after the stored value, so it proceeds.)
evUpdatedAt := parseGHTimeRequired(ev.UpdatedAt)
if pr.PrUpdatedAt.Valid && evUpdatedAt.Valid && pr.PrUpdatedAt.Time.After(evUpdatedAt.Time) {
return
@@ -215,20 +216,18 @@ func (h *Handler) mirrorVCSPullRequest(ctx context.Context, conn db.VcsConnectio
for _, c := range extractClosingIdentifiers(ev.Title, ev.Body) {
closingIdents[c] = struct{}{}
}
- // qualifyingIdents genuinely tie this PR to an issue: a title prefix, a
+ // claimedIdents are the identifiers this PR claims: a title prefix, a
// branch-name reference, or a body closing keyword. An identifier matched
- // ONLY by a bare body mention is reference_only — it links (so the PR shows
- // in history) but is hidden from the issue PR list and excluded from the
- // close aggregate, so a drive-by "Related MUL-1" neither looks like a
- // working PR nor blocks a genuine Closes sibling from advancing the issue.
- // Mirrors the GitHub path (MUL-3739); branch is deliberately excluded from
- // the closing-keyword scan there and here.
- qualifyingIdents := map[string]struct{}{}
+ // ONLY by a bare body mention is a drive-by reference — it claims nothing,
+ // so it gets no link row and drops one an earlier claim created. Mirrors the
+ // GitHub path (MUL-3739, MUL-7072); branch is deliberately excluded from the
+ // closing-keyword scan there and here.
+ claimedIdents := map[string]struct{}{}
for _, id := range extractIdentifiers(ev.Title, ev.Branch) {
- qualifyingIdents[id] = struct{}{}
+ claimedIdents[id] = struct{}{}
}
for c := range closingIdents {
- qualifyingIdents[c] = struct{}{}
+ claimedIdents[c] = struct{}{}
}
// Freeze close_intent once the terminal merge/close event has arrived.
preserveCloseIntent := !ev.Terminal() && (ev.State == "merged" || ev.State == "closed")
@@ -239,15 +238,29 @@ func (h *Handler) mirrorVCSPullRequest(ctx context.Context, conn db.VcsConnectio
if !ok {
continue
}
+ if _, claimed := claimedIdents[id]; !claimed {
+ // Passing mention: never links, and drops an earlier claim's link
+ // while the PR is still editable. Frozen once terminal, like
+ // close_intent.
+ if preserveCloseIntent {
+ continue
+ }
+ if err := h.Queries.UnlinkIssueFromVCSPullRequest(ctx, db.UnlinkIssueFromVCSPullRequestParams{
+ IssueID: issue.ID,
+ PullRequestID: pr.ID,
+ }); err != nil {
+ slog.Warn("vcs: unlink failed", "err", err)
+ continue
+ }
+ reevalIssues = append(reevalIssues, issue)
+ continue
+ }
_, declared := closingIdents[id]
closeIntent := declared && !preserveCloseIntent
- _, qualifies := qualifyingIdents[id]
- referenceOnly := !qualifies
if err := h.Queries.LinkIssueToVCSPullRequest(ctx, db.LinkIssueToVCSPullRequestParams{
IssueID: issue.ID,
PullRequestID: pr.ID,
CloseIntent: closeIntent,
- ReferenceOnly: referenceOnly,
PreserveCloseIntent: preserveCloseIntent,
LinkedByType: strToText("system"),
LinkedByID: pgtype.UUID{},
diff --git a/server/internal/handler/vcs_webhook_test.go b/server/internal/handler/vcs_webhook_test.go
index 074c935f65..43ef005762 100644
--- a/server/internal/handler/vcs_webhook_test.go
+++ b/server/internal/handler/vcs_webhook_test.go
@@ -146,10 +146,10 @@ func TestVCSWebhook_ForgejoMirrorsAndCloses(t *testing.T) {
}
// A bare body mention ("Related MUL-X", no closing keyword, not in title or
-// branch) must link reference_only: excluded from the issue PR list and from
-// the close gate, so it neither shows as a working PR nor blocks a genuine
-// Closes sibling from advancing the issue. Mirrors the GitHub qualifying rule.
-func TestVCSWebhook_ReferenceOnlyExcludedAndNonBlocking(t *testing.T) {
+// branch) claims nothing, so it must not link at all: it neither shows as a
+// working PR nor blocks a genuine Closes sibling from advancing the issue.
+// Mirrors the GitHub claim rule (MUL-3739, MUL-7072).
+func TestVCSWebhook_BareBodyMentionIsNotLinked(t *testing.T) {
ctx := context.Background()
box := withVCSBox(t)
connID := seedVCSConnection(t, ctx, box, "forgejo", "https://forgejo.test")
@@ -157,7 +157,7 @@ func TestVCSWebhook_ReferenceOnlyExcludedAndNonBlocking(t *testing.T) {
t.Cleanup(func() { cleanupVCS(ctx, issue.ID) })
// PR #7: OPEN, mentions the issue only in the body with no closing keyword,
- // generic title/branch → reference_only.
+ // generic title/branch → no claim, no link.
refRaw, _ := json.Marshal(map[string]any{
"action": "opened",
"pull_request": map[string]any{
@@ -178,24 +178,24 @@ func TestVCSWebhook_ReferenceOnlyExcludedAndNonBlocking(t *testing.T) {
t.Fatalf("ref PR: expected 202, got %d (%s)", w.Code, w.Body.String())
}
- // The link exists but is reference_only, so it is hidden from the PR list.
- var referenceOnly bool
+ // No link row at all, so nothing to exclude from the PR list.
+ var links int
if err := testPool.QueryRow(ctx,
- `SELECT reference_only FROM issue_vcs_pull_request WHERE issue_id = $1`,
- issue.ID).Scan(&referenceOnly); err != nil {
- t.Fatalf("select reference_only: %v", err)
+ `SELECT count(*) FROM issue_vcs_pull_request WHERE issue_id = $1`,
+ issue.ID).Scan(&links); err != nil {
+ t.Fatalf("count links: %v", err)
}
- if !referenceOnly {
- t.Fatalf("body-only mention should be reference_only")
+ if links != 0 {
+ t.Fatalf("body-only mention should not link, got %d rows", links)
}
if rows, err := testHandler.Queries.ListVCSPullRequestsByIssue(ctx, parseUUID(issue.ID)); err != nil {
t.Fatalf("list: %v", err)
} else if len(rows) != 0 {
- t.Fatalf("reference_only PR must be excluded from the list, got %d rows", len(rows))
+ t.Fatalf("unlinked PR must not appear in the list, got %d rows", len(rows))
}
- // PR #8: MERGED with a title reference + Closes keyword → qualifying,
- // close_intent. The still-open reference_only PR #7 must NOT block advance.
+ // PR #8: MERGED with a title reference + Closes keyword → a real claim with
+ // close_intent. The still-open, unlinked PR #7 must NOT block advance.
closeRaw, _ := json.Marshal(map[string]any{
"action": "closed",
"pull_request": map[string]any{
@@ -219,7 +219,7 @@ func TestVCSWebhook_ReferenceOnlyExcludedAndNonBlocking(t *testing.T) {
updated, _ := testHandler.Queries.GetIssue(ctx, parseUUID(issue.ID))
if updated.Status != "done" {
- t.Errorf("issue should advance despite the open reference_only PR, got %q", updated.Status)
+ t.Errorf("issue should advance despite the open unlinked PR, got %q", updated.Status)
}
}
@@ -251,7 +251,7 @@ func TestCombinedCloseAggregateSpansProviders(t *testing.T) {
}
if err := testHandler.Queries.LinkIssueToPullRequest(ctx, db.LinkIssueToPullRequestParams{
IssueID: parseUUID(issue.ID), PullRequestID: ghPR.ID, CloseIntent: false,
- ReferenceOnly: false, LinkedByType: strToText("system"),
+ LinkedByType: strToText("system"),
}); err != nil {
t.Fatalf("LinkIssueToPullRequest: %v", err)
}
@@ -269,7 +269,7 @@ func TestCombinedCloseAggregateSpansProviders(t *testing.T) {
}
if err := testHandler.Queries.LinkIssueToVCSPullRequest(ctx, db.LinkIssueToVCSPullRequestParams{
IssueID: parseUUID(issue.ID), PullRequestID: vcsPR.ID, CloseIntent: true,
- ReferenceOnly: false, LinkedByType: strToText("system"),
+ LinkedByType: strToText("system"),
}); err != nil {
t.Fatalf("LinkIssueToVCSPullRequest: %v", err)
}
@@ -345,9 +345,9 @@ func TestDeleteIssue_VCSLinkCleanupIsWorkspaceScoped(t *testing.T) {
}
}
-// A redelivered older event must not rewrite the link metadata that a newer
-// event already set. The PR-upsert monotonic guard protects the PR row; this
-// covers the link (close_intent / reference_only).
+// A redelivered older event must not rewrite the link a newer event already
+// set. The PR-upsert monotonic guard protects the PR row; this covers the link
+// (close_intent, and the link's existence at all).
func TestVCSWebhook_StaleEventDoesNotRewriteLink(t *testing.T) {
ctx := context.Background()
box := withVCSBox(t)
@@ -377,20 +377,20 @@ func TestVCSWebhook_StaleEventDoesNotRewriteLink(t *testing.T) {
}
}
- // Newer terminal event: merged with a qualifying Closes → close_intent, not reference_only.
+ // Newer terminal event: merged with a real claim (Closes) → close_intent.
fire("closed", "closed", true, "Fix "+issue.Identifier, "Closes "+issue.Identifier, "2026-05-02T00:00:00Z")
// Older redelivered "opened" event: bare body mention, generic title/branch.
- // Without the guard this rewrites the link to close_intent=false, reference_only=true.
+ // Without the guard this clears close_intent and drops the link entirely.
fire("opened", "open", false, "WIP", "touches "+issue.Identifier, "2026-05-01T00:00:00Z")
- var closeIntent, referenceOnly bool
+ var closeIntent bool
if err := testPool.QueryRow(ctx,
- `SELECT close_intent, reference_only FROM issue_vcs_pull_request WHERE issue_id = $1`,
- issue.ID).Scan(&closeIntent, &referenceOnly); err != nil {
+ `SELECT close_intent FROM issue_vcs_pull_request WHERE issue_id = $1`,
+ issue.ID).Scan(&closeIntent); err != nil {
t.Fatalf("select link: %v", err)
}
- if !closeIntent || referenceOnly {
- t.Errorf("stale event rewrote link: close_intent=%v reference_only=%v, want true/false", closeIntent, referenceOnly)
+ if !closeIntent {
+ t.Errorf("stale event rewrote link: close_intent=%v, want true", closeIntent)
}
// The PR row also stayed at the newer merged state.
rows, _ := testHandler.Queries.ListVCSPullRequestsByIssue(ctx, parseUUID(issue.ID))
diff --git a/server/internal/service/builtin_skills/multica-platform/references/issues.md b/server/internal/service/builtin_skills/multica-platform/references/issues.md
index b4fdc22ca7..3b1bbb4915 100644
--- a/server/internal/service/builtin_skills/multica-platform/references/issues.md
+++ b/server/internal/service/builtin_skills/multica-platform/references/issues.md
@@ -16,15 +16,18 @@ Product contracts the runtime brief does not fully encode.
The GitHub webhook runs two separate scans over an incoming PR. They are not the
same gate and they read different fields.
-**Linking** scans the PR **title, body, OR branch** for a routable issue key
-(`PREFIX-NUMBER`, e.g. `MUL-123`). Each match writes an issue to PR link row.
-This is the link that `multica issue pull-requests` reads back — but see the
-reference-only rule below: a key that appears **only** as a bare mention in the
-body is linked yet hidden from that list.
+**Linking** scans three places for a routable issue key (`PREFIX-NUMBER`, e.g.
+`MUL-123`): the PR **title**, the **branch name**, and the **body right after a
+closing keyword**. Each match writes an issue to PR link row — the link that
+`multica issue pull-requests` reads back. A key that appears in the body as a
+bare mention, with nothing in the title or branch and no closing keyword, is a
+passing reference and links nothing.
```text
-MUL-123: add the thing the issue asks for # key anywhere in title → links, shown
-agent/dana/mul-123-add-the-thing # branch ref → links, shown
+MUL-123: add the thing the issue asks for # key anywhere in title → links
+agent/dana/mul-123-add-the-thing # branch ref → links
+Closes MUL-123 # body + closing keyword → links
+Related to MUL-123 # body mention only → no link
```
**Close intent** is stricter and is a separate scan over **title or body only —
@@ -37,7 +40,7 @@ auto-advances the issue to `done` when the PR merges.
Closes MUL-123 # links AND records close intent
Fixes MUL-123
Resolves MUL-123
-Fix login MUL-123 # links only — keyword not adjacent
+Fix login MUL-123 # in a title: links, no close intent
```
Consequence: a bare key in the title or a branch reference links the PR but does
@@ -45,18 +48,23 @@ not close the issue on merge. A closing keyword immediately adjacent to the issu
records close intent; on merge, that close intent can move the linked issue to
`done`.
-**Reference-only links (hidden from the PR list).** A key that appears **only**
-as a bare mention in the body — no closing keyword, and not in the title or
-branch — still writes a link row, but the row is flagged `reference_only` and
-**excluded from `multica issue pull-requests`** (and the issue's right-side PR
-list in the UI). This keeps passing mentions like `Related MUL-123` or
-`Follow up in MUL-123` from surfacing an unrelated PR as if it were working on
-that issue. To make a PR show up for an issue, put the key in the title, the
-branch, or after a closing keyword in the body — not as a loose body reference.
+**Passing mentions link nothing.** A key that appears **only** as a bare mention
+in the body — no closing keyword, and not in the title or branch — does not link
+the PR at all. This keeps `Related MUL-123` or `Follow up in MUL-123` from
+surfacing an unrelated PR as if it were working on that issue. To make a PR show
+up for an issue, put the key in the title, the branch, or after a closing keyword
+in the body — not as a loose body reference.
+
+While the PR is still open the link follows the live title and body: adding a key
+links it, and downgrading that key to a plain mention drops the link. Once the PR
+has merged or closed, existing links and their close-intent decision are frozen —
+but a PR that was never linked can still be linked by editing it, so a forgotten
+key is repairable after the fact. That late link does not move the issue to
+`done`; close intent is decided at merge time.
```text
-Closes MUL-123 in the body # links and shown
-Related to MUL-123 in the body (no title/branch) # links but reference_only → hidden
+Closes MUL-123 in the body # links
+Related to MUL-123 in the body (no title/branch) # no link
```
### Default for code-changing issue work
@@ -70,13 +78,13 @@ instead of pretending the run is complete.
To make the PR show on the issue, put a routable issue key in the PR **title**
(preferred) or the **branch**. A key that appears only as a bare mention in the
-body is reference-only and hidden from the issue PR list. Do not use a closing
-keyword (`Closes` / `Fixes` / `Resolves`) unless the issue should auto-advance
-to `done` on merge.
+body links nothing. Do not use a closing keyword (`Closes` / `Fixes` /
+`Resolves`) unless the issue should auto-advance to `done` on merge.
```text
-MUL-123: fix login redirect # key anywhere in title → links and shown
+MUL-123: fix login redirect # key anywhere in title → links
Closes MUL-123 # only when merge should mark the issue done
+Part of MUL-123 # body mention only → no link at all
```
In the final issue comment, include the PR URL when a PR exists. If the task did
@@ -119,10 +127,20 @@ Returns `{"pull_requests": [...]}`. Each element exposes:
So "is it merged?" is `state == "merged"` (or `merged_at != null`); "is it still
a draft?" is `state == "draft"`; coarse CI status is `checks_conclusion`.
-If the command returns no linked PRs after a PR was opened, the link scanner did
-not observe a routable issue key in the PR title/body/branch — or the only match
-was a bare body mention, which links as `reference_only` and is hidden from this
-list (see the reference-only rule above).
+If the command returns no linked PRs after a PR was opened, check the syntax
+first: the scanner needs a routable issue key in the PR title or branch, or one
+right after a closing keyword in the body — a bare body mention does not count
+(see the passing-mention rule above). When the syntax is the problem, editing the
+title or adding a closing keyword re-runs the scan.
+
+If the key is already written correctly and the list is still empty, stop editing
+the PR blind: another no-op edit cannot fix an integration that never received the
+event. Check the integration side instead — whether the app is installed on that
+repository, whether the installation is bound to this workspace, whether
+auto-linking is turned off for the workspace, and whether the event reached the
+platform at all. A delivery that failed is not retried on its own, but it can be
+redelivered once the receiving side is fixed. Report what you found in the result
+comment rather than repeating the edit.
## Listing and ordering issues
@@ -368,6 +386,7 @@ PR title (link the issue):
```text
Fix login redirect # incorrect — no issue key, won't link
+Body-only "Part of MUL-123" # incorrect — passing mention, won't link
MUL-123: fix login redirect # correct — links the PR
```
diff --git a/server/internal/service/builtin_skills_test.go b/server/internal/service/builtin_skills_test.go
index 85fc9521f7..3e8a66d3f9 100644
--- a/server/internal/service/builtin_skills_test.go
+++ b/server/internal/service/builtin_skills_test.go
@@ -457,7 +457,15 @@ func TestPlatformSkillCoversPlatformContracts(t *testing.T) {
"open or update a PR before posting the final Multica issue comment",
"This is a default, not",
"put a routable issue key in the PR **title**",
- "body is reference-only and hidden from the issue PR list",
+ "body links nothing",
+ // The empty-PR-list guidance drives GitHub write actions, so
+ // both halves of it are pinned: a syntax problem is repairable
+ // by editing the PR, and an integration problem is not — an
+ // agent that keeps editing burns deliveries on a no-op.
+ "editing the title or adding a closing keyword re-runs the scan",
+ "stop editing the PR blind",
+ "whether the installation is bound to this workspace",
+ "redelivered once the receiving side is fixed",
"unless the issue should auto-advance",
"include the PR URL when a PR exists",
"Closes MUL-123",
diff --git a/server/migrations/458_delete_reference_only_pr_links.down.sql b/server/migrations/458_delete_reference_only_pr_links.down.sql
new file mode 100644
index 0000000000..f5f5304f94
--- /dev/null
+++ b/server/migrations/458_delete_reference_only_pr_links.down.sql
@@ -0,0 +1,4 @@
+-- Irreversible: the deleted rows carried no information beyond "this PR body
+-- mentioned this key", which the PR body itself still records. Recreating them
+-- would resurrect links that no read path is meant to return.
+SELECT 1;
diff --git a/server/migrations/458_delete_reference_only_pr_links.up.sql b/server/migrations/458_delete_reference_only_pr_links.up.sql
new file mode 100644
index 0000000000..cb8eae6b28
--- /dev/null
+++ b/server/migrations/458_delete_reference_only_pr_links.up.sql
@@ -0,0 +1,20 @@
+-- Retire reference-only PR links. A link row was written for an issue key that
+-- appeared ONLY as a bare mention in a PR body (no closing keyword, nothing in
+-- the title or branch), then flagged reference_only and filtered out of every
+-- read path: the issue PR list, the close-intent aggregate, and the review
+-- dedup head SHA. The row therefore had no reader at all, and once the PR went
+-- terminal the link upsert preserved the flag, so adding "Closes KEY" to a
+-- merged PR's body could never surface the PR on its issue — the one recovery
+-- action a user can take was the one that could not work.
+--
+-- The webhook now links only a key it read from the PR title, the branch name,
+-- or a body closing keyword, which is exactly the set that was visible before.
+-- Deleting the hidden rows keeps the two in step: left behind, they would
+-- become visible — and block auto-advance while in flight — as soon as the read
+-- filters went away.
+--
+-- Old API instances still running during a rolling deploy can insert a few more
+-- such rows; the column stays in place for now, and the follow-up migration
+-- that drops it re-runs this delete as a mop-up.
+DELETE FROM issue_pull_request WHERE reference_only;
+DELETE FROM issue_vcs_pull_request WHERE reference_only;
diff --git a/server/pkg/db/generated/github.sql.go b/server/pkg/db/generated/github.sql.go
index 61da012270..e2544fba1d 100644
--- a/server/pkg/db/generated/github.sql.go
+++ b/server/pkg/db/generated/github.sql.go
@@ -196,7 +196,7 @@ SELECT
COALESCE(SUM(CASE WHEN pr.state = 'merged' AND ipr.close_intent THEN 1 ELSE 0 END), 0)::bigint AS merged_with_close_intent_count
FROM github_pull_request pr
JOIN issue_pull_request ipr ON ipr.pull_request_id = pr.id
-WHERE ipr.issue_id = $1 AND NOT ipr.reference_only
+WHERE ipr.issue_id = $1
`
type GetIssuePullRequestCloseAggregateRow struct {
@@ -211,14 +211,8 @@ type GetIssuePullRequestCloseAggregateRow struct {
// merged_with_close_intent_count > 0. Both the PR state and the link row
// (with close_intent) are persisted before this query runs, so the result
// is event-agnostic — a link-only sibling closing after a closing-keyword
-// PR has already merged still resolves the issue.
-//
-// reference_only links (a PR that merely mentions the issue identifier in its
-// body) are excluded: they are hidden from the issue PR list, so they must not
-// silently gate auto-advance either. An open body-only mention would otherwise
-// keep open_count > 0 and block the issue from advancing while being invisible
-// in the UI. (reference_only rows never carry close_intent, so excluding them
-// does not change merged_with_close_intent_count.)
+// PR has already merged still resolves the issue. A bare body mention is not
+// linked at all, so a passing reference can never keep open_count > 0.
func (q *Queries) GetIssuePullRequestCloseAggregate(ctx context.Context, issueID pgtype.UUID) (GetIssuePullRequestCloseAggregateRow, error) {
row := q.db.QueryRow(ctx, getIssuePullRequestCloseAggregate, issueID)
var i GetIssuePullRequestCloseAggregateRow
@@ -231,12 +225,12 @@ SELECT head_sha FROM (
SELECT pr.head_sha AS head_sha, pr.state AS state, pr.pr_updated_at AS pr_updated_at
FROM github_pull_request pr
JOIN issue_pull_request ipr ON ipr.pull_request_id = pr.id
- WHERE ipr.issue_id = $1 AND pr.head_sha <> '' AND NOT ipr.reference_only
+ WHERE ipr.issue_id = $1 AND pr.head_sha <> ''
UNION ALL
SELECT pr.head_sha AS head_sha, pr.state AS state, pr.pr_updated_at AS pr_updated_at
FROM vcs_pull_request pr
JOIN issue_vcs_pull_request ipr ON ipr.pull_request_id = pr.id
- WHERE ipr.issue_id = $1 AND pr.head_sha <> '' AND NOT ipr.reference_only
+ WHERE ipr.issue_id = $1 AND pr.head_sha <> ''
) combined
ORDER BY (state IN ('open', 'draft')) DESC, pr_updated_at DESC
LIMIT 1
@@ -255,10 +249,6 @@ LIMIT 1
// Spans both GitHub and self-hosted VCS PRs: a self-hosted PR pushing a new
// commit must move the dedup head SHA the same way a GitHub PR does, otherwise
// a fresh review round could be merged away against a stale key.
-// reference_only links are excluded on both arms, matching the PR-list and
-// close-aggregate queries: a body-only mention is hidden from the list and the
-// close gate, so it must not win this ORDER BY and become the review dedup head
-// SHA either, masking the real working PR's SHA.
func (q *Queries) GetIssueReviewHeadSha(ctx context.Context, issueID pgtype.UUID) (string, error) {
row := q.db.QueryRow(ctx, getIssueReviewHeadSha, issueID)
var head_sha string
@@ -287,18 +277,14 @@ func (q *Queries) GetPendingGitHubInstallation(ctx context.Context, installation
const linkIssueToPullRequest = `-- name: LinkIssueToPullRequest :exec
INSERT INTO issue_pull_request (
- issue_id, pull_request_id, linked_by_type, linked_by_id, close_intent, reference_only
+ issue_id, pull_request_id, linked_by_type, linked_by_id, close_intent
) VALUES (
- $1, $2, $4, $5, $3, $6
+ $1, $2, $4, $5, $3
)
ON CONFLICT (issue_id, pull_request_id) DO UPDATE SET
close_intent = CASE
- WHEN $7 THEN issue_pull_request.close_intent
+ WHEN $6 THEN issue_pull_request.close_intent
ELSE EXCLUDED.close_intent
- END,
- reference_only = CASE
- WHEN $7 THEN issue_pull_request.reference_only
- ELSE EXCLUDED.reference_only
END
`
@@ -308,7 +294,6 @@ type LinkIssueToPullRequestParams struct {
CloseIntent bool `json:"close_intent"`
LinkedByType pgtype.Text `json:"linked_by_type"`
LinkedByID pgtype.UUID `json:"linked_by_id"`
- ReferenceOnly bool `json:"reference_only"`
PreserveCloseIntent bool `json:"preserve_close_intent"`
}
@@ -320,11 +305,6 @@ type LinkIssueToPullRequestParams struct {
// the current title/body parse result so authors can remove a closing keyword
// before merge. Post-terminal edits can opt into preserving the stored value,
// keeping the merge-time decision stable.
-//
-// reference_only marks a link justified ONLY by a bare body mention (no closing
-// keyword, no title/branch reference). It follows the same preserve gate as
-// close_intent so a post-terminal edit can't retroactively hide a PR that did
-// the work. The issue's PR list filters these out (see ListPullRequestsByIssue).
func (q *Queries) LinkIssueToPullRequest(ctx context.Context, arg LinkIssueToPullRequestParams) error {
_, err := q.db.Exec(ctx, linkIssueToPullRequest,
arg.IssueID,
@@ -332,7 +312,6 @@ func (q *Queries) LinkIssueToPullRequest(ctx context.Context, arg LinkIssueToPul
arg.CloseIntent,
arg.LinkedByType,
arg.LinkedByID,
- arg.ReferenceOnly,
arg.PreserveCloseIntent,
)
return err
@@ -447,7 +426,7 @@ WITH issue_prs AS (
SELECT pr.id, pr.snapshot_head_sha
FROM github_pull_request pr
JOIN issue_pull_request ipr ON ipr.pull_request_id = pr.id
- WHERE ipr.issue_id = $1 AND NOT ipr.reference_only
+ WHERE ipr.issue_id = $1
),
checks AS (
SELECT
@@ -488,7 +467,7 @@ SELECT
FROM github_pull_request pr
JOIN issue_pull_request ipr ON ipr.pull_request_id = pr.id
LEFT JOIN checks c ON c.pr_id = pr.id
-WHERE ipr.issue_id = $1 AND NOT ipr.reference_only
+WHERE ipr.issue_id = $1
ORDER BY pr.pr_created_at DESC
`
@@ -535,9 +514,10 @@ type ListPullRequestsByIssueRow struct {
// refresh pipeline — NOT the legacy suite-level webhook aggregation, which is
// removed. The `issue_prs` CTE narrows to this issue's PR ids first so the
// aggregation only touches check rows for those PRs. Rows for an OLD head are
-// excluded by the snapshot_head_sha filter. reference_only links (a PR that
-// merely mentions the issue identifier in its body, with no closing keyword and
-// no title/branch reference) are filtered out — they are not working PRs.
+// excluded by the snapshot_head_sha filter. Every link row is a working PR:
+// the webhook only links an identifier it read from the PR title, the branch
+// name, or a body closing keyword, so a bare body mention never lands here
+// (MUL-7072).
func (q *Queries) ListPullRequestsByIssue(ctx context.Context, issueID pgtype.UUID) ([]ListPullRequestsByIssueRow, error) {
rows, err := q.db.Query(ctx, listPullRequestsByIssue, issueID)
if err != nil {
diff --git a/server/pkg/db/generated/vcs.sql.go b/server/pkg/db/generated/vcs.sql.go
index 3065baeccd..104f2ea698 100644
--- a/server/pkg/db/generated/vcs.sql.go
+++ b/server/pkg/db/generated/vcs.sql.go
@@ -52,12 +52,12 @@ WITH combined AS (
SELECT pr.state AS state, ipr.close_intent AS close_intent
FROM github_pull_request pr
JOIN issue_pull_request ipr ON ipr.pull_request_id = pr.id
- WHERE ipr.issue_id = $1 AND NOT ipr.reference_only
+ WHERE ipr.issue_id = $1
UNION ALL
SELECT pr.state AS state, ipr.close_intent AS close_intent
FROM vcs_pull_request pr
JOIN issue_vcs_pull_request ipr ON ipr.pull_request_id = pr.id
- WHERE ipr.issue_id = $1 AND NOT ipr.reference_only
+ WHERE ipr.issue_id = $1
)
SELECT
COALESCE(SUM(CASE WHEN state IN ('open', 'draft') THEN 1 ELSE 0 END), 0)::bigint AS open_count,
@@ -77,8 +77,8 @@ type GetIssueCombinedPullRequestCloseAggregateRow struct {
// open PR on the other — either webhook is blind to the other's in-flight work.
// Sum the in-flight (open/draft) and merged-with-close-intent counts across
// github_pull_request+issue_pull_request and vcs_pull_request+
-// issue_vcs_pull_request. reference_only links are excluded on both sides, so a
-// bare body mention neither counts as in-flight nor gates advance.
+// issue_vcs_pull_request. A bare body mention is not linked on either side, so
+// a passing reference never counts as in-flight.
func (q *Queries) GetIssueCombinedPullRequestCloseAggregate(ctx context.Context, issueID pgtype.UUID) (GetIssueCombinedPullRequestCloseAggregateRow, error) {
row := q.db.QueryRow(ctx, getIssueCombinedPullRequestCloseAggregate, issueID)
var i GetIssueCombinedPullRequestCloseAggregateRow
@@ -112,18 +112,14 @@ func (q *Queries) GetVCSConnectionByID(ctx context.Context, id pgtype.UUID) (Vcs
const linkIssueToVCSPullRequest = `-- name: LinkIssueToVCSPullRequest :exec
INSERT INTO issue_vcs_pull_request (
- issue_id, pull_request_id, linked_by_type, linked_by_id, close_intent, reference_only
+ issue_id, pull_request_id, linked_by_type, linked_by_id, close_intent
) VALUES (
- $1, $2, $4, $5, $3, $6
+ $1, $2, $4, $5, $3
)
ON CONFLICT (issue_id, pull_request_id) DO UPDATE SET
close_intent = CASE
- WHEN $7 THEN issue_vcs_pull_request.close_intent
+ WHEN $6 THEN issue_vcs_pull_request.close_intent
ELSE EXCLUDED.close_intent
- END,
- reference_only = CASE
- WHEN $7 THEN issue_vcs_pull_request.reference_only
- ELSE EXCLUDED.reference_only
END
`
@@ -133,17 +129,14 @@ type LinkIssueToVCSPullRequestParams struct {
CloseIntent bool `json:"close_intent"`
LinkedByType pgtype.Text `json:"linked_by_type"`
LinkedByID pgtype.UUID `json:"linked_by_id"`
- ReferenceOnly bool `json:"reference_only"`
PreserveCloseIntent bool `json:"preserve_close_intent"`
}
// =====================
// Issue ↔ VCS PR link
// =====================
-// reference_only marks a link justified ONLY by a bare body mention (no closing
-// keyword and no title/branch reference), mirroring the GitHub link upsert.
-// preserve_close_intent freezes both close_intent and reference_only once a
-// terminal merge/close event has been recorded.
+// Mirrors the GitHub link upsert: preserve_close_intent freezes close_intent
+// once a terminal merge/close event has been recorded.
func (q *Queries) LinkIssueToVCSPullRequest(ctx context.Context, arg LinkIssueToVCSPullRequestParams) error {
_, err := q.db.Exec(ctx, linkIssueToVCSPullRequest,
arg.IssueID,
@@ -151,7 +144,6 @@ func (q *Queries) LinkIssueToVCSPullRequest(ctx context.Context, arg LinkIssueTo
arg.CloseIntent,
arg.LinkedByType,
arg.LinkedByID,
- arg.ReferenceOnly,
arg.PreserveCloseIntent,
)
return err
@@ -246,7 +238,7 @@ WITH checks AS (
ON cs.connection_id = pr.connection_id
AND cs.sha = pr.head_sha
AND pr.head_sha <> ''
- WHERE ipr.issue_id = $1 AND NOT ipr.reference_only
+ WHERE ipr.issue_id = $1
GROUP BY pr.id
)
SELECT
@@ -258,7 +250,7 @@ SELECT
FROM vcs_pull_request pr
JOIN issue_vcs_pull_request ipr ON ipr.pull_request_id = pr.id
LEFT JOIN checks c ON c.pr_id = pr.id
-WHERE ipr.issue_id = $1 AND NOT ipr.reference_only
+WHERE ipr.issue_id = $1
ORDER BY pr.pr_created_at DESC
`
@@ -377,6 +369,29 @@ func (q *Queries) RotateVCSConnectionWebhookSecret(ctx context.Context, arg Rota
return i, err
}
+const unlinkIssueFromVCSPullRequest = `-- name: UnlinkIssueFromVCSPullRequest :exec
+DELETE FROM issue_vcs_pull_request
+WHERE issue_id = $1 AND pull_request_id = $2
+`
+
+type UnlinkIssueFromVCSPullRequestParams struct {
+ IssueID pgtype.UUID `json:"issue_id"`
+ PullRequestID pgtype.UUID `json:"pull_request_id"`
+}
+
+// Drops a link an earlier claim created, for the GitHub twin's reason: while a
+// PR is still editable, the link follows the live title/body parse, so a key the
+// payload still carries but no longer claims — "Closes MUL-1" edited down to
+// "Related MUL-1" — loses its link. A key deleted from the PR outright is NOT
+// covered: the payload keeps no trace of it, so noticing that needs the stored
+// links instead, which is its own change. Callers must not run this once the PR
+// has gone terminal — a post-merge edit cannot retroactively unlink a PR that
+// did the work.
+func (q *Queries) UnlinkIssueFromVCSPullRequest(ctx context.Context, arg UnlinkIssueFromVCSPullRequestParams) error {
+ _, err := q.db.Exec(ctx, unlinkIssueFromVCSPullRequest, arg.IssueID, arg.PullRequestID)
+ return err
+}
+
const upsertVCSCommitStatus = `-- name: UpsertVCSCommitStatus :exec
INSERT INTO vcs_commit_status (
diff --git a/server/pkg/db/queries/github.sql b/server/pkg/db/queries/github.sql
index 145e8c1643..1d34a1a2e4 100644
--- a/server/pkg/db/queries/github.sql
+++ b/server/pkg/db/queries/github.sql
@@ -137,14 +137,15 @@ WHERE workspace_id = $1 AND repo_owner = $2 AND repo_name = $3 AND pr_number = $
-- refresh pipeline — NOT the legacy suite-level webhook aggregation, which is
-- removed. The `issue_prs` CTE narrows to this issue's PR ids first so the
-- aggregation only touches check rows for those PRs. Rows for an OLD head are
--- excluded by the snapshot_head_sha filter. reference_only links (a PR that
--- merely mentions the issue identifier in its body, with no closing keyword and
--- no title/branch reference) are filtered out — they are not working PRs.
+-- excluded by the snapshot_head_sha filter. Every link row is a working PR:
+-- the webhook only links an identifier it read from the PR title, the branch
+-- name, or a body closing keyword, so a bare body mention never lands here
+-- (MUL-7072).
WITH issue_prs AS (
SELECT pr.id, pr.snapshot_head_sha
FROM github_pull_request pr
JOIN issue_pull_request ipr ON ipr.pull_request_id = pr.id
- WHERE ipr.issue_id = sqlc.arg('issue_id') AND NOT ipr.reference_only
+ WHERE ipr.issue_id = sqlc.arg('issue_id')
),
checks AS (
SELECT
@@ -185,7 +186,7 @@ SELECT
FROM github_pull_request pr
JOIN issue_pull_request ipr ON ipr.pull_request_id = pr.id
LEFT JOIN checks c ON c.pr_id = pr.id
-WHERE ipr.issue_id = sqlc.arg('issue_id') AND NOT ipr.reference_only
+WHERE ipr.issue_id = sqlc.arg('issue_id')
ORDER BY pr.pr_created_at DESC;
-- name: GetIssueReviewHeadSha :one
@@ -202,20 +203,16 @@ ORDER BY pr.pr_created_at DESC;
-- Spans both GitHub and self-hosted VCS PRs: a self-hosted PR pushing a new
-- commit must move the dedup head SHA the same way a GitHub PR does, otherwise
-- a fresh review round could be merged away against a stale key.
--- reference_only links are excluded on both arms, matching the PR-list and
--- close-aggregate queries: a body-only mention is hidden from the list and the
--- close gate, so it must not win this ORDER BY and become the review dedup head
--- SHA either, masking the real working PR's SHA.
SELECT head_sha FROM (
SELECT pr.head_sha AS head_sha, pr.state AS state, pr.pr_updated_at AS pr_updated_at
FROM github_pull_request pr
JOIN issue_pull_request ipr ON ipr.pull_request_id = pr.id
- WHERE ipr.issue_id = $1 AND pr.head_sha <> '' AND NOT ipr.reference_only
+ WHERE ipr.issue_id = $1 AND pr.head_sha <> ''
UNION ALL
SELECT pr.head_sha AS head_sha, pr.state AS state, pr.pr_updated_at AS pr_updated_at
FROM vcs_pull_request pr
JOIN issue_vcs_pull_request ipr ON ipr.pull_request_id = pr.id
- WHERE ipr.issue_id = $1 AND pr.head_sha <> '' AND NOT ipr.reference_only
+ WHERE ipr.issue_id = $1 AND pr.head_sha <> ''
) combined
ORDER BY (state IN ('open', 'draft')) DESC, pr_updated_at DESC
LIMIT 1;
@@ -232,20 +229,14 @@ WHERE pull_request_id = $1;
-- merged_with_close_intent_count > 0. Both the PR state and the link row
-- (with close_intent) are persisted before this query runs, so the result
-- is event-agnostic — a link-only sibling closing after a closing-keyword
--- PR has already merged still resolves the issue.
---
--- reference_only links (a PR that merely mentions the issue identifier in its
--- body) are excluded: they are hidden from the issue PR list, so they must not
--- silently gate auto-advance either. An open body-only mention would otherwise
--- keep open_count > 0 and block the issue from advancing while being invisible
--- in the UI. (reference_only rows never carry close_intent, so excluding them
--- does not change merged_with_close_intent_count.)
+-- PR has already merged still resolves the issue. A bare body mention is not
+-- linked at all, so a passing reference can never keep open_count > 0.
SELECT
COALESCE(SUM(CASE WHEN pr.state IN ('open', 'draft') THEN 1 ELSE 0 END), 0)::bigint AS open_count,
COALESCE(SUM(CASE WHEN pr.state = 'merged' AND ipr.close_intent THEN 1 ELSE 0 END), 0)::bigint AS merged_with_close_intent_count
FROM github_pull_request pr
JOIN issue_pull_request ipr ON ipr.pull_request_id = pr.id
-WHERE ipr.issue_id = $1 AND NOT ipr.reference_only;
+WHERE ipr.issue_id = $1;
-- =====================
-- Issue ↔ Pull Request link
@@ -257,24 +248,15 @@ WHERE ipr.issue_id = $1 AND NOT ipr.reference_only;
-- the current title/body parse result so authors can remove a closing keyword
-- before merge. Post-terminal edits can opt into preserving the stored value,
-- keeping the merge-time decision stable.
---
--- reference_only marks a link justified ONLY by a bare body mention (no closing
--- keyword, no title/branch reference). It follows the same preserve gate as
--- close_intent so a post-terminal edit can't retroactively hide a PR that did
--- the work. The issue's PR list filters these out (see ListPullRequestsByIssue).
INSERT INTO issue_pull_request (
- issue_id, pull_request_id, linked_by_type, linked_by_id, close_intent, reference_only
+ issue_id, pull_request_id, linked_by_type, linked_by_id, close_intent
) VALUES (
- $1, $2, sqlc.narg('linked_by_type'), sqlc.narg('linked_by_id'), $3, sqlc.arg('reference_only')
+ $1, $2, sqlc.narg('linked_by_type'), sqlc.narg('linked_by_id'), $3
)
ON CONFLICT (issue_id, pull_request_id) DO UPDATE SET
close_intent = CASE
WHEN sqlc.arg('preserve_close_intent') THEN issue_pull_request.close_intent
ELSE EXCLUDED.close_intent
- END,
- reference_only = CASE
- WHEN sqlc.arg('preserve_close_intent') THEN issue_pull_request.reference_only
- ELSE EXCLUDED.reference_only
END;
-- name: UnlinkIssueFromPullRequest :exec
diff --git a/server/pkg/db/queries/vcs.sql b/server/pkg/db/queries/vcs.sql
index 0d38360dea..5b92494fcb 100644
--- a/server/pkg/db/queries/vcs.sql
+++ b/server/pkg/db/queries/vcs.sql
@@ -121,7 +121,7 @@ WITH checks AS (
ON cs.connection_id = pr.connection_id
AND cs.sha = pr.head_sha
AND pr.head_sha <> ''
- WHERE ipr.issue_id = sqlc.arg('issue_id') AND NOT ipr.reference_only
+ WHERE ipr.issue_id = sqlc.arg('issue_id')
GROUP BY pr.id
)
SELECT
@@ -133,7 +133,7 @@ SELECT
FROM vcs_pull_request pr
JOIN issue_vcs_pull_request ipr ON ipr.pull_request_id = pr.id
LEFT JOIN checks c ON c.pr_id = pr.id
-WHERE ipr.issue_id = sqlc.arg('issue_id') AND NOT ipr.reference_only
+WHERE ipr.issue_id = sqlc.arg('issue_id')
ORDER BY pr.pr_created_at DESC;
-- name: GetIssueCombinedPullRequestCloseAggregate :one
@@ -144,18 +144,18 @@ ORDER BY pr.pr_created_at DESC;
-- open PR on the other — either webhook is blind to the other's in-flight work.
-- Sum the in-flight (open/draft) and merged-with-close-intent counts across
-- github_pull_request+issue_pull_request and vcs_pull_request+
--- issue_vcs_pull_request. reference_only links are excluded on both sides, so a
--- bare body mention neither counts as in-flight nor gates advance.
+-- issue_vcs_pull_request. A bare body mention is not linked on either side, so
+-- a passing reference never counts as in-flight.
WITH combined AS (
SELECT pr.state AS state, ipr.close_intent AS close_intent
FROM github_pull_request pr
JOIN issue_pull_request ipr ON ipr.pull_request_id = pr.id
- WHERE ipr.issue_id = $1 AND NOT ipr.reference_only
+ WHERE ipr.issue_id = $1
UNION ALL
SELECT pr.state AS state, ipr.close_intent AS close_intent
FROM vcs_pull_request pr
JOIN issue_vcs_pull_request ipr ON ipr.pull_request_id = pr.id
- WHERE ipr.issue_id = $1 AND NOT ipr.reference_only
+ WHERE ipr.issue_id = $1
)
SELECT
COALESCE(SUM(CASE WHEN state IN ('open', 'draft') THEN 1 ELSE 0 END), 0)::bigint AS open_count,
@@ -195,21 +195,27 @@ WHERE pr.connection_id = $1 AND pr.head_sha = $2 AND pr.head_sha <> '';
-- =====================
-- name: LinkIssueToVCSPullRequest :exec
--- reference_only marks a link justified ONLY by a bare body mention (no closing
--- keyword and no title/branch reference), mirroring the GitHub link upsert.
--- preserve_close_intent freezes both close_intent and reference_only once a
--- terminal merge/close event has been recorded.
+-- Mirrors the GitHub link upsert: preserve_close_intent freezes close_intent
+-- once a terminal merge/close event has been recorded.
INSERT INTO issue_vcs_pull_request (
- issue_id, pull_request_id, linked_by_type, linked_by_id, close_intent, reference_only
+ issue_id, pull_request_id, linked_by_type, linked_by_id, close_intent
) VALUES (
- $1, $2, sqlc.narg('linked_by_type'), sqlc.narg('linked_by_id'), $3, sqlc.arg('reference_only')
+ $1, $2, sqlc.narg('linked_by_type'), sqlc.narg('linked_by_id'), $3
)
ON CONFLICT (issue_id, pull_request_id) DO UPDATE SET
close_intent = CASE
WHEN sqlc.arg('preserve_close_intent') THEN issue_vcs_pull_request.close_intent
ELSE EXCLUDED.close_intent
- END,
- reference_only = CASE
- WHEN sqlc.arg('preserve_close_intent') THEN issue_vcs_pull_request.reference_only
- ELSE EXCLUDED.reference_only
END;
+
+-- name: UnlinkIssueFromVCSPullRequest :exec
+-- Drops a link an earlier claim created, for the GitHub twin's reason: while a
+-- PR is still editable, the link follows the live title/body parse, so a key the
+-- payload still carries but no longer claims — "Closes MUL-1" edited down to
+-- "Related MUL-1" — loses its link. A key deleted from the PR outright is NOT
+-- covered: the payload keeps no trace of it, so noticing that needs the stored
+-- links instead, which is its own change. Callers must not run this once the PR
+-- has gone terminal — a post-merge edit cannot retroactively unlink a PR that
+-- did the work.
+DELETE FROM issue_vcs_pull_request
+WHERE issue_id = $1 AND pull_request_id = $2;