Repository navigation
fix(skills): add dedup check for inline review comment replies - #141
Conversation
A single PR review fires both pull_request_review and pull_request_review_comment events, triggering concurrent tend-mention runs. The existing "Recheck Before Posting" guidance only checks total comment counts, which doesn't catch duplicate replies to a specific inline comment. Add an explicit check: before replying to a review comment, query the PR's review comments for existing bot replies to the same in_reply_to_id. If one exists, exit silently. Evidence: max-sixty/worktrunk PR #1890 received two near-identical bot replies (comment IDs 3031400525 and 3031403943) to the same review question. The second run detected 1 existing reply but misread the output because it used a non-existent /replies GET endpoint that 404'd, and the fallback count was concatenated with the error JSON. Co-Authored-By: Claude Opus 4.6 <[email protected]>
how does the mention concurrency check work? wouldn't it prevent multiple runs on the same PR? |
|
Good question. The concurrency group did serialize the runs — looking at the cited worktrunk jobs, the first The problem was in the second run's recheck logic. The existing "Recheck Before Posting" section checks total comment/review counts, which is too coarse to detect a reply to a specific inline comment. The second run attempted a finer-grained check but used a So the concurrency serializes correctly; this PR fixes the recheck step so the second run can actually detect the first's reply. The PR description's "triggering concurrent workflow runs" framing is misleading — I'll update it. |
| ### Dedup check for inline review comment replies | ||
|
|
||
| A single PR review can fire both `pull_request_review` and `pull_request_review_comment` events, | ||
| triggering concurrent workflow runs. Before replying to an inline review comment, check whether |
There was a problem hiding this comment.
Yes — fixed in 9aca0ae. Now reads "triggering separate workflow runs (serialized by the concurrency group, not truly concurrent)."
The concurrency group serializes these runs — they aren't truly concurrent. Fixes the misleading framing flagged in review. Co-Authored-By: Claude Opus 4.6 <[email protected]>
The LAST_REVIEW_SHA filter excluded COMMENTED reviews with empty bodies, but these reviews carry inline comments and are substantive. This caused redundant full re-analysis when the bot had already reviewed via inline comments (observed in run 23949079715 on max-sixty/tend PR #141). Co-Authored-By: Claude Opus 4.6 <[email protected]>
## Summary Add a dedup recheck step in `running-in-ci` for PR creation, analogous to the existing dedup check for inline review comment replies. Re-run `gh pr list` immediately before `gh pr create` so a concurrent sibling run doesn't slip a duplicate PR past the initial session-start check. ## Evidence Observed on `PRQL/prql` in runs [24464554439](https://github.com/PRQL/prql/actions/runs/24464554439) and [24464634498](https://github.com/PRQL/prql/actions/runs/24464634498). Timeline: - 15:57:00 — `max-sixty` commented "do the follow-up please" on issue [PRQL/prql#5802](PRQL/prql#5802) (Zig 0.16 follow-up) - 15:57:03 — `tend-mention` run A started on issue #5802 - 15:58:45 — `vanillajonathan` commented on PR [PRQL/prql#5801](PRQL/prql#5801) asking the bot to create a Zig 0.16 PR - 15:58:48 — `tend-mention` run B started on PR #5801 (different concurrency group — runs in parallel with A) - ~16:02 — each run calls `gh pr list` once, early in its session; no Zig fix PR exists yet - 16:08:17 — run B calls `gh pr create` → [PRQL/prql#5803](PRQL/prql#5803) - 16:09:05 — run A calls `gh pr create` → [PRQL/prql#5804](PRQL/prql#5804), 48s after #5803 appeared; no recheck Both PRs modify the same two files (`.github/workflows/test-prqlc-c.yaml` to drop the `version: 0.15.2` pin, and `prqlc/bindings/prqlc-c/examples/minimal-zig/build.zig` to move calls onto `root_module`) with the same intent — near-duplicates differing only in refactoring style. Maintainers must now triage and close one. ## Root cause `tend-mention`'s [`handle` job concurrency group](https://github.com/max-sixty/tend/blob/main/generator/src/tend/workflows.py) is keyed by `issue.number || pull_request.number`, so mentions on different threads (issue #5802 vs PR #5801) run concurrently. The current `PR Creation` guidance says to check `gh pr list` before creating, but in practice runs do this once at session start. Minutes pass between the check and `gh pr create`, during which a sibling run can open a scope-overlapping PR — invisible to the stale check. ## Gate assessment - **Confidence**: High — concrete wrong outcome (two open PRs for the same fix) with a traced decision chain for both runs. - **Structural vs stochastic**: **Structural**. The same conditions (two mentions on different threads asking for the same fix within a few minutes) will reliably reproduce this; the current guidance prescribes a one-shot check that the race outflanks. - **Occurrences**: 1 this run, 0 historical in [#133](#133). Passes Gate 1 under the "one clear occurrence sufficient for structural failures" rule. - **Magnitude**: Targeted fix — adds a 17-line recheck section analogous to the existing `Dedup check for inline review comment replies` pattern merged in [#141](#141). Passes Gate 2. ## Test plan - [ ] Skill lint (`pre-commit run --all-files`) - [ ] Verify the proposed `gh pr list --state open --author $BOT_LOGIN --json number,title,headRefName,createdAt` returns what a bot can actually use to decide (it does: standard gh flags) - [ ] Spot-check: the next time two concurrent mentions hit different threads asking for the same fix, only one PR should be created Co-authored-by: continuous-bot <[email protected]> Co-authored-by: Claude Opus 4.6 <[email protected]>
Summary
running-in-ciskillin_reply_to_idbefore postingRoot cause: A single PR review fires both
pull_request_reviewandpull_request_review_commentevents. Thehandlejob's concurrency group correctly serializes these runs (the second queues until the first completes). However, the existing "Recheck Before Posting" section only checks total comment/review counts — too coarse to detect that the bot already replied to a specific inline comment. The second run's finer-grained check used a non-existentGET /repliesendpoint that returned a 404, and the fallback output was ambiguous, making the bot conclude "No existing replies."Evidence: On max-sixty/worktrunk PR #1890, runs 23933934456 (
pull_request_review, handle 04:34:16–04:36:35) and 23933934467 (pull_request_review_comment, handle 04:36:38–04:38:29) were correctly serialized by the concurrency group, but the second run's recheck failed to detect the first's reply and posted a duplicate.Gate assessment:
/repliesGET endpoint always 404s, making the fallback output always ambiguous)Test plan
pull_request_review+pull_request_review_comment), the second run should detect the first's reply and exit silently🤖 Generated with Claude Code