Repository navigation
fix(mention): don't cancel verify job on rapid comments - #95
Conversation
The verify job's concurrency group (keyed by PR number with cancel-in-progress: true) caused explicit @bot mentions to be dropped when a second comment arrived on the same PR within seconds. Remove concurrency from verify (it's lightweight) and change handle's cancel-in-progress to false so jobs queue instead of cancelling. Closes #93 Co-Authored-By: Claude <[email protected]>
|
do we have a spec of how we handle concurrency? let's write one out if not in this case: does it fully solve the issue? if a are we left needing to look through the whole history of the issue, including downloading its content, to evaluate whether we need to respond? |
|
@tend-agent looks like there was a 500 error in https://github.com/max-sixty/tend/actions/runs/23694484189 So open a new issue with:
Then:
|
|
Created #97 for the 500 error handling. On the concurrency question — no, a So the flow for rapid comments is:
Comment B's handle never touches the concurrency group, so Comment A's handle runs uninterrupted. The only scenario where queuing matters is two genuine We don't have a written concurrency spec yet — happy to draft one if you'd like. |
|
yes, please draft one please ensure it contains where jobs drop out: it seems that some get cut by GHA conditions but some get cut by our own, more custom, conditions? |
Document the three filtering layers (GHA conditions, custom should_run logic, concurrency groups) and where each workflow drops events. Replaces the previous concurrency section which was outdated after #93. Co-Authored-By: Claude Opus 4.6 <[email protected]>
|
Done — pushed a concurrency spec in DESIGN.md (edb9dc2). It documents three filtering layers:
The key distinction you flagged: GHA conditions (Layer 1) drop jobs before they touch concurrency, while our custom verify script (Layer 2) feeds into a GHA condition on the handle job. Both result in the handle job being skipped, but the logic lives in different places. |
tend-agent
left a comment
There was a problem hiding this comment.
DESIGN.md spec contradicts the code change: the Layer 3 table and rationale still document verify as having a concurrency group, but the code (correctly) removes it. See inline suggestion.
The spec table and rationale incorrectly documented verify as having a concurrency group — the code correctly removes it. Co-Authored-By: Claude <[email protected]>
| | Workflow | Condition | Filters out | | ||
| |----------|-----------|-------------| | ||
| | **review** | `event == pull_request_target && !draft` | Draft PRs | | ||
| | **review** | `event == pull_request_review && pr.user == bot && reviewer != bot && (state != approved \|\| body)` | Reviews on non-bot PRs; bot self-reviews; bare approvals with no body | |
There was a problem hiding this comment.
why does the review workflow respond to pull_request_review at all? should that just be the mention / react workflow?
There was a problem hiding this comment.
Good question — there's a meaningful distinction between the two event types:
-
pull_request_review(submitted) — a top-level review on a PR (approve / request changes / comment, with an optional body). The review workflow handles this, but only for bot-authored PRs (pr.user == bot). The idea is that when a human reviews a PR the bot created, the bot should re-run its full review skill to address the feedback — it needs the same checkout/context setup as a regular review run, just triggered by the review event instead of a push. -
pull_request_review_comment(inline code comments) — these go to the mention workflow, which handles them like any other comment where the bot may need to respond.
That said, you could argue the review workflow's pull_request_review handler is really "respond to review feedback on my PR" — which is conceptually closer to mention/react territory than to "review this PR." The current split means the review workflow serves two purposes: (1) review other people's PRs on push, and (2) respond to reviews on its own PRs. Those could be separated.
Want me to open an issue to track whether this should move to the mention workflow (or a dedicated workflow)?
There was a problem hiding this comment.
(1) review other people's PRs on push, and (2) respond to reviews on its own PRs. Those could be separated.
change our workflow types to only do (1)
There was a problem hiding this comment.
Done in 4a151f3 — removed pull_request_review from the review workflow entirely. It now only triggers on pull_request_target (PR open/push/ready). Simplified the checkout, concurrency group, and prompt accordingly. Updated DESIGN.md and regenerated all workflows.
Note: top-level reviews on bot-authored PRs won't trigger anything now. Inline review comments (pull_request_review_comment) still go through the mention workflow. If we want top-level review responses routed somewhere, that'd be a separate addition to the mention workflow.
There was a problem hiding this comment.
Done — removed pull_request_review from the review workflow (0c8d21b). It now only triggers on pull_request_target (reviewing other people's PRs on push). Also updated the DESIGN.md example workflow and Layer 1 table to match.
Remove the `issue.user.type != 'Bot'` filter from the triage workflow so the bot triages issues opened by other bots. The self-login filter is kept to prevent the bot from triaging its own issues. Co-Authored-By: Claude Opus 4.6 <[email protected]>
| |----------|-----------|-------------| | ||
| | **review** | `event == pull_request_target && !draft` | Draft PRs | | ||
| | **review** | `event == pull_request_review && pr.user == bot && reviewer != bot && (state != approved \|\| body)` | Reviews on non-bot PRs; bot self-reviews; bare approvals with no body | | ||
| | **mention (verify)** | `event == issues && body contains @bot && author != bot` | Issue edits by the bot itself, edits without a mention | |
There was a problem hiding this comment.
what does each of these conditions precisely mean?
There was a problem hiding this comment.
The table uses pseudo-code shorthand — here's what each maps to in GHA expression context:
Review (line 357):
event == pull_request_target— thepull_request_targetevent (PR opened/pushed/reopened)!draft—github.event.pull_request.draft == false
Review (line 358):
event == pull_request_review— thepull_request_reviewevent (someone submits a review)pr.user == bot— the PR was authored by the bot (github.event.pull_request.user.login == 'tend-agent')reviewer != bot— the reviewer isn't the bot itself (github.event.review.user.login != 'tend-agent')state != approved || body— either it's not an approval, or it's an approval that has a body. This filters out bare "approve clicks" with no text (nothing actionable for the bot to respond to)
Mention verify (line 359, issues event):
event == issues— fires on issue opened/editedbody contains @bot—contains(github.event.issue.body, '@tend-agent')— the issue body mentions the botauthor != bot— the issue wasn't authored by the bot (avoids self-triage loops)
Mention verify (line 360, issue_comment):
comment.author != bot— the comment wasn't posted by the bot itself
Mention verify (line 361, pull_request_review_comment):
- Same as above but for inline review comments
These are all direct translations of the actual GHA if: expressions. Want me to expand the table to be more self-explanatory (e.g., replace the pseudo-code with plain-English descriptions)?
There was a problem hiding this comment.
Each row maps to one branch of the verify job's if: expression (workflows.py:212-219):
if: |
(github.event_name == 'issues' &&
contains(github.event.issue.body, '@bot') &&
github.event.issue.user.login != 'bot') ||
(github.event_name == 'issue_comment' &&
github.event.comment.user.login != 'bot') ||
(github.event_name == 'pull_request_review_comment' &&
github.event.comment.user.login != 'bot')Breaking it down:
-
issuesevent (on: issues: types: [edited]): fires when someone edits an issue body. The condition requires@botis in the body AND the editor isn't the bot itself. Purpose: catch someone editing@botinto an existing issue, while ignoring the bot's own edits (which would cause a loop). -
issue_commentevent (on: issue_comment: types: [created, edited]): fires on any new or edited comment on issues or PRs (GitHub treats PR comments as issue comments). Only condition: comment author isn't the bot. Purpose: let verify check whether the bot should engage (direct mention or prior engagement), while filtering out the bot's own comments to prevent loops. -
pull_request_review_commentevent (on: pull_request_review_comment: types: [created, edited]): fires on inline code review comments. Same filter: comment author isn't the bot. Purpose: same as above, but for inline review threads specifically (these use a different GitHub event than regular PR comments).
The issues branch is the strictest — it requires @bot in the body at the GHA level. The other two are permissive at the GHA level (just "not the bot's own comment") and delegate the engagement check to the Layer 2 should_run script.
I can make the spec table clearer if you think the pseudocode notation is too compressed — e.g. expanding each row to say "fires when X; skips when Y."
The pseudocode shorthand (e.g. `event == issues && body contains @bot && author != bot`) was hard to parse. Replace with plain-English descriptions split by event type, so each row is self-explanatory. Co-Authored-By: Claude Opus 4.6 <[email protected]>
The review workflow now only reviews other people's PRs on push/open (purpose 1). Responding to reviews on bot-authored PRs (purpose 2) is removed per feedback — it's conceptually closer to the mention workflow. - Remove pull_request_review trigger and conditional logic - Simplify checkout (single path, no event branching) - Simplify concurrency group key (no event_name split needed) - Set use_sticky_comment: true unconditionally - Update DESIGN.md Layer 1 and Layer 3 tables - Regenerate all workflow files Co-Authored-By: Claude Opus 4.6 <[email protected]>
The review workflow now only reviews other people's PRs on push (pull_request_target), and no longer responds to reviews on bot-authored PRs. This separates the two concerns as requested. - Remove pull_request_review trigger and all review-response checkout/prompt logic - Simplify if: condition to just draft check - Simplify concurrency group key (no longer needs event_name) - Update DESIGN.md spec and example workflow - Regenerate all workflow files Co-Authored-By: Claude Opus 4.6 <[email protected]>
|
|
||
| 1. **Issue edits** (`issues` event): always `true` (the GHA condition already | ||
| confirmed `@bot` is in the body). | ||
| 2. **Direct mention**: comment body contains `@bot` → `true`. |
There was a problem hiding this comment.
to confirm, is this literally looking for @bot? or $bot-name?
if the latter, can we adjust this?
There was a problem hiding this comment.
It's the configured bot_name from .config/tend.toml — the generated workflows use @{bot_name} (e.g. @tend-agent, @prql-bot). Updated the spec to say @$bot_name to make that clear (ef414f2).
The generated workflows use the configured bot_name from .config/tend.toml, not a literal "@bot". Clarify this in the concurrency spec. Co-Authored-By: Claude Opus 4.6 <[email protected]>
|
@tend-agent can we do another review of this concern?
Given that jobs can make it through to Layer 2, doesn't that displace the queued job? and if the queued job would have |
|
Good question — let me trace through this carefully. Can a No. When the handle job's Where displacement can happen: GitHub Actions concurrency queues have a depth of exactly 1. With This means: if three or more genuine Summary: The |
but this actually seems quite likely in lots of people are adding comments the important question is: can job A be displaced by a job B that won't review job A's content Can you:
|
Each handle job only processes its own triggering comment, so if three genuine mentions race, the middle one can be displaced from the GHA pending queue and lost. Document this as a known limitation with mitigation paths. Co-Authored-By: Claude Opus 4.6 <[email protected]>
|
You're right to push on this — the answer is yes, a displaced job's mention can be lost. Each handle job receives only its own triggering comment's URL in the prompt. It does not scan the conversation for unprocessed mentions. So if job B is displaced from the GHA pending queue by job C, job C only processes its own comment — job B's GHA concurrency queues have a depth of exactly 1. With
The most natural mitigation: have the handle job scan recent conversation for any unprocessed Pushed 668cfab with this documented as a known limitation + mitigation paths in the spec. |
|
@tend-agent merge in |
# Conflicts: # .github/workflows/tend-review.yaml
|
Merged |
| - Have the handle job scan recent conversation for any unprocessed `@$bot_name` | ||
| mentions (not just its own triggering comment) before responding. This would | ||
| make the bot self-healing: even if job B is displaced, job C would pick up | ||
| B's mention when it scans the conversation. |
There was a problem hiding this comment.
right, this is what we should do — the skill should review the state when it loads, not just the comment it was asked to mention
it should be aware of both:
- other jobs might have responded to its comment, prior to it running
- other comments might need responding
we could inject the time difference between the job being queued and running, as some indication of this likelihood
There was a problem hiding this comment.
Agreed — updated the mitigation spec (ae922a1). It now describes two things the skill should check on load:
- Whether another job already responded to its triggering comment (avoid duplicating work)
- Whether other
@botmentions in the conversation are unprocessed (pick up displaced jobs' work)
Also added the queue-to-run time delta idea — the workflow can inject the delay as an env var so the skill knows how stale its triggering context might be.
Update the queue-depth-of-1 mitigation spec per review feedback: the skill should review conversation state on load (check for prior responses and unprocessed mentions), not just its triggering comment. Add queue-to-run time delta as a proposed signal. Co-Authored-By: Claude Opus 4.6 <[email protected]>
Problem
The
tend-mentionworkflow'sverifyjob has a concurrency group keyed by PR number withcancel-in-progress: true. When two comments arrive on the same PR within seconds, the second run cancels the first — even if the first was an explicit@botmention.This is exactly what happened at PRQL/prql#5750:
@prql-bot can you do a follow-up...→ triggered run 23664429862thanks @snth !(5 seconds later) → triggered run 23664431397@prql-botrequest was lost.Solution
verifyjob — it's lightweight and fast; parallel verify jobs for the same PR are harmless.handle'scancel-in-progresstofalse— jobs queue instead of cancelling. The first handle completes (processes the mention), then the second runs (exits silently for non-mention). No mention gets dropped.Testing
test_mention_verify_no_concurrency— verifies the verify job has no concurrency grouptest_mention_handle_job_queues_not_cancels— verifies handle usescancel-in-progress: falseCloses #93 — automated triage