Skip to content

Worktrunk is a CLI for Git worktree management, designed for parallel AI agent workflows

fix(ci): verify step drops issues when concurrency cancels initial run (#1519)

worktrunk-bot9d39b44508a7
diff --git a/.github/CLAUDE.md b/.github/CLAUDE.md
index f56fa96dc..0d2f3fe24 100644
--- a/.github/CLAUDE.md
+++ b/.github/CLAUDE.md
@@ -134,7 +134,7 @@ The mention workflow runs for any user who includes `@worktrunk-bot` — the mer
- Formal review submitted on a `worktrunk-bot`-authored PR, with body or non-approval → `claude-review` responds
- `@worktrunk-bot` mentioned in an issue body → `claude-mention` responds
- `@worktrunk-bot` mentioned in any comment (issue or PR) → `claude-mention` responds
-- Any comment on a PR or issue that `worktrunk-bot` has engaged with (authored, reviewed, or commented on) → `claude-mention` runs (verify step confirms engagement via API), but the prompt instructs Claude to only respond if the comment needs bot input — otherwise exit silently. When the bot authored the PR/issue, it leans toward responding since commenters expect the author to engage.
+- Any comment on a PR or issue that `worktrunk-bot` has engaged with (authored, mentioned in the issue body, reviewed, or commented on) → `claude-mention` runs (verify step confirms engagement via API), but the prompt instructs Claude to only respond if the comment needs bot input — otherwise exit silently. When the bot authored the PR/issue, it leans toward responding since commenters expect the author to engage.
- Editing a comment or issue body re-triggers the same response
**Does not trigger:**
diff --git a/.github/workflows/claude-mention.yaml b/.github/workflows/claude-mention.yaml
index d82a3af7b..6c5a80c44 100644
--- a/.github/workflows/claude-mention.yaml
+++ b/.github/workflows/claude-mention.yaml
@@ -58,6 +58,27 @@ jobs:
id-token: write
actions: read # Required for Claude to read CI results on PRs
steps:
+ # Verify bot engagement — gate for non-mention comments.
+ #
+ # Skipped (all subsequent steps run) when:
+ # - Event is not a comment (issues opened/edited with @worktrunk-bot)
+ # - Comment body contains @worktrunk-bot (explicit mention)
+ #
+ # When it runs, checks engagement in order (first match exits 0):
+ #
+ # Plain issues:
+ # 1. Bot authored the issue
+ # 2. Issue body mentions @worktrunk-bot (catches the race where
+ # concurrency cancelled the initial run before the bot commented)
+ # 3. Bot has commented on the issue
+ #
+ # PRs:
+ # 1. Bot authored the PR
+ # 2. Bot has left a review
+ # 3. Bot has commented
+ #
+ # If none match → exit 1 (continue-on-error makes this non-fatal;
+ # subsequent steps check `steps.verify.outcome != 'failure'`).
- name: 🔍 Verify bot engagement
id: verify
continue-on-error: true
@@ -67,11 +88,13 @@ jobs:
ISSUE_NUMBER="${{ github.event.issue.number }}"
if [ -z "${{ github.event.issue.pull_request.url }}" ]; then
- # Plain issue — check if bot authored or commented
ISSUE_AUTHOR="${{ github.event.issue.user.login }}"
if [ "$ISSUE_AUTHOR" = "worktrunk-bot" ]; then
exit 0
fi
+ if echo "$ISSUE_BODY" | grep -qF '@worktrunk-bot'; then
+ exit 0
+ fi
BOT_COMMENTS=$(gh api "repos/$GITHUB_REPOSITORY/issues/$ISSUE_NUMBER/comments" \
--jq '[.[] | select(.user.login == "worktrunk-bot")] | length')
if [ "$BOT_COMMENTS" -gt "0" ]; then
@@ -107,6 +130,7 @@ jobs:
exit 1
env:
GH_TOKEN: ${{ secrets.WORKTRUNK_BOT_TOKEN }}
+ ISSUE_BODY: ${{ github.event.issue.body }}
- name: 📂 Checkout code
if: steps.verify.outcome != 'failure'