worktrunk icon indicating copy to clipboard operation
worktrunk copied to clipboard

hourly-review: bot-created issues trigger claude-mention, causing duplicate fix PRs

Open worktrunk-bot opened this issue 8 months ago • 1 comments

Problem

When the hourly review workflow creates an issue that incidentally mentions @worktrunk-bot in its body text, the claude-mention workflow triggers on the issues event and duplicates the hourly review's work — including creating a second fix PR for the same problem.

Evidence

Run 22917013836 (hourly review, 18:03 UTC):

  • Created issue #1424 describing a CI regression
  • Created PR #1425 on branch hourly/fix-fork-review-comment-secrets to fix it

Run 22917265227 (claude-mention, 18:09 UTC):

  • Triggered by issue #1424's creation (body contains @worktrunk-bot in the sentence "comment contained @worktrunk-bot")
  • Read the issue, investigated the same files, created PR #1426 on branch fix/issue-1424 — a duplicate fix

Both PRs modify the same two files (.github/CLAUDE.md, .github/workflows/claude-mention.yaml) with overlapping but slightly different changes. PR #1426 adds a more detailed fork-secret reference table, while PR #1425 has a more concise fix.

Root cause

Two independent problems combine:

  1. Hourly review issues mention @worktrunk-bot incidentally — issue #1424 quotes the bot's name in a description of CI behavior, not as a request for action. The claude-mention workflow's issues trigger uses contains(github.event.issue.body, '@worktrunk-bot'), which matches any mention regardless of context.

  2. claude-mention doesn't check for existing fix PRs — the mention run checked for duplicate issues and branches named fix/issue-* or repro/issue-*, but missed PR #1425 on branch hourly/fix-fork-review-comment-secrets. It didn't run gh pr list to check for open PRs targeting the same issue.

Suggested fix

Option A: Have the hourly review workflow use backtick-escaped mentions (`@worktrunk-bot`) in issue bodies so they don't trigger claude-mention. This is the simplest fix.

Option B: Add a worktrunk-bot author check to the claude-mention issues trigger — skip issues authored by the bot itself (similar to the existing comment.user.login != 'worktrunk-bot' check for comments).

Option C: Both — escape mentions in hourly review output AND add the author filter as defense-in-depth.

Immediate action needed

One of PR #1425 or #1426 should be closed as a duplicate. PR #1426 has more thorough documentation changes (fork-secret reference table), but both fix the core workflow issue identically.

worktrunk-bot avatar Mar 10 '26 19:03 worktrunk-bot

Thanks for the detailed write-up! I investigated and confirmed the duplicate trigger chain described here.

PR #1429 implements Option B — adding github.event.issue.user.login != 'worktrunk-bot' to the issues trigger in claude-mention.yaml, consistent with the existing loop-prevention checks on issue_comment and pull_request_review_comment events. It also documents the new filter in .github/CLAUDE.md.

CI is currently running on that PR. I'll leave it to a maintainer to decide whether Option A (escaping mentions in hourly review output) is also worth adding for defense-in-depth, and which of PR #1425 / #1426 to close as the duplicate for #1424.

worktrunk-bot avatar Mar 10 '26 19:03 worktrunk-bot