Skip to content

fix(mention): skip the bot's own review on someone else's PR - #916

Merged
max-sixty merged 3 commits into
mainfrom
fix/issue-915
Aug 12, 2026
Merged

max-sixty merged 3 commits into
mainfrom
fix/issue-915

Conversation

@tend-agent

Copy link
Copy Markdown
Collaborator

Problem

tend-mention's verify gate starts a full billable session for every non-empty-body review the bot leaves on a same-repo PR someone else authored. The session reads the PR, recognises the trigger as its own review, and exits silently — it can only ever no-op: the bot is the reviewer, the findings are addressed to the PR's author, and pushing unbidden to another author's branch is barred by running-in-ci's conduct rules, so there is no author role left to act in.

For a pull_request_review event the gate falls through to the participation heuristic, which counts the triggering review itself — BOT_REVIEWS is never empty, so should_run=true is unconditional. #747's gate is the same shape narrowed to one leg (approved and empty body), which excludes every review in #915's evidence: five occurrences in one 24h window on PRQL/prql, APPROVED and COMMENTED alike, bodies 455–1920 chars, $1.79 booked plus one run that hit the account's session limit before it could bill.

Solution

One author-keyed gate between the PR_AUTHOR resolution and the BOT_REVIEWS heuristic. Placement is the whole design, in three directions:

Keyed on author alone: reusing #747's REVIEW_STATE / empty-body clauses here would let every bodied COMMENTED review straight through.

Fork PRs are unaffected either way — the relay job's head.repo.full_name == github.repository condition already means a bot review on a fork PR never dispatches.

Testing

test_mention_skips_bot_review_on_another_authors_pr pins the gate and all three orderings, and asserts the state/body clauses are absent from it. It fails on the pre-change template at the first assertion. test_mention_self_comment_skip_spares_review_submissions had its APPROVED-gate slice narrowed to end at the inline-comment fetch, so it keeps discriminating between the two gates rather than passing on either. Full generator suite: 380 passed. pre-commit clean on the changed files.

Relationship to #849

Complementary, not overlapping. #849 (for #866) drops the synthetic zero-body COMMENTED container GitHub wraps around an inline reply, on any PR including the bot's own — where this gate cannot reach, because PR_AUTHOR == bot exits first. This one drops real bodied reviews on other authors' PRs, which #849's -z "$COMMENT_BODY" clause excludes. Both touch mention.yaml.j2; whichever lands second will need a one-line rebase on the header comment listing the self-review skips.


Closes #915 — automated triage

@tend-agent tend-agent left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The gate itself is right, and its placement holds up under trace: REVIEW_AUTHOR is only ever set on the pull_request_review arm of the dispatch case, so the second clause can't read a stale value from an issue_comment; the earlier APPROVED + empty-body gate stays load-bearing for the bot's own PRs rather than becoming dead; and all four mention regtests that carry the verify block are updated (test_extras_apply_path_regtest.out renders tend-review, so it's correctly untouched). Suite passes at 380 locally.

Three things on the prose and the test, none blocking.

The header comment now says the two skips are keyed "on the review being terminal for the bot rather than on authorship", while the new gate's own comment eleven lines later says "Keyed on author alone". Both are describing the same gate in opposite terms — "authorship" means self-authorship of the review in the first and review-author as the key in the second. That block's whole job is to steer a future editor away from a blanket self-review skip, so a framing that reads as "these aren't author-keyed" is the wrong signal to leave there.

The rationale in the gate comment — pushing unbidden to another author's branch is barred by conduct rules — is narrower than the set of PRs the gate covers. On a Dependabot/renovate PR the review skill's step 8 explicitly directs pushing the fix, so "no author role left to act in" isn't why mention is skippable there; it's skippable because tend-review pushes that fix in its own session and never needed a mention run. The behaviour is right either way, but as written the comment will read as an oversight to whoever next debugs a bot-authored PR that stopped waking mention.

The last assertion in the new test doesn't discriminate. run.index("reviews/$PAYLOAD_ID/comments") < run.index("BOT_REVIEWS=$(") holds on the pre-change template too (the inline fetch has always preceded the heuristic), so the third ordering the docstring claims to pin isn't pinned by anything except the gate slice bounds. Anchoring the right-hand side to the gate's own index makes it fail pre-change, like the other two.

The #849 overlap is called correctly — that one is only reachable on bot-authored PRs once this gate lands, since everything it targets on someone else's PR is now caught here first. Both edit this same header comment, so whichever is second wants the rebase you flagged.

Comment thread generator/tests/test_generate.py Resolved
@tend-agent

Copy link
Copy Markdown
Collaborator Author

All three addressed in 5a3e441.

The header comment no longer denies the gates are author-keyed — it says they are, and that each is additionally narrowed to a case that leaves the run nothing to do, which is the steer against a blanket self-review skip stated without the contradiction.

On the rationale: confirmed against the review skill, which directs pushing the fix on Dependabot/renovate PRs rather than stopping at analysis. So the conduct-rules clause was the wrong load-bearing reason. Reframed to what actually covers both cases — whatever the review warranted, the tend-review session that submitted it has already done: left the findings for a human author (where pushing to their branch unbidden is barred), or pushed the fix itself where no author will act.

The third assertion now anchors its right-hand side to the gate's own index rather than to BOT_REVIEWS=$(. Verified it discriminates: with main's template restored under the new test file, the test fails; with the gate, it passes.

# Conflicts:
#	generator/src/tend/templates/mention.yaml.j2
#	generator/tests/_regtest_outputs/test_generate.test_sandbox_levers_regtest.out
#	generator/tests/_regtest_outputs/test_generate.test_workflow_minimal_codex_regtest[mention].out
#	generator/tests/_regtest_outputs/test_generate.test_workflow_minimal_regtest[mention].out
#	generator/tests/_regtest_outputs/test_generate.test_workflow_with_setup_regtest[mention].out
#	generator/tests/test_generate.py
@max-sixty
max-sixty merged commit e2fc61b into main Aug 12, 2026
7 of 8 checks passed
@max-sixty
max-sixty deleted the fix/issue-915 branch August 12, 2026 16:49
max-sixty pushed a commit that referenced this pull request Aug 12, 2026
## Problem

`tend-mention` starts a full billable session every time **someone other
than the bot approves a PR with an empty review body and no inline
comments**. The session reads the PR, finds nothing addressed to it, and
exits silently. It can only ever no-op: a bare `APPROVED` asks for
nothing, and the bot is barred from merging, so there is no role left
for it to act in.

`verify` has two terminal-review gates and both key on `REVIEW_AUTHOR`:
the empty-body `APPROVED` gate (#747) and the synthetic reply-container
gate (#849/#866). A third party's approval matches neither, so it falls
through to the `PR_AUTHOR == bot` short-circuit on a bot-authored PR —
or to `BOT_REVIEWS`, which counts the triggering review itself — and
`should_run=true` is unconditional. Structural: there is no decision
point, so the same shape recurs every time a human approves one of the
bot's PRs without typing anything.

Distinct from the three issues already open or closed on this path. #747
fixed the bot's *own* empty-body approval; #866 targets the synthetic
empty-body `COMMENTED` container GitHub creates for an inline reply;
#915/#916 target the bot's *own* content-bearing review on someone
else's PR. All three are author-keyed by design; this is the residual
their author-keying leaves behind, and it was named as such in the
evidence log two days before this run.

## Evidence

Three occurrences on `PRQL/prql`, all traced to the review record rather
than inferred from the run:

| When | PR | Approver | Review | Handle job |
|---|---|---|---|---|
| 2026-08-10 | [#6164](PRQL/prql#6164) |
`kgutwin` | `APPROVED`, empty body, no inline comments |
[31395281267](https://github.com/PRQL/prql/actions/runs/31395281267) — 2
m 10 s, published nothing |
| 2026-08-12 08:18Z | [#6185](PRQL/prql#6185) |
`vanillajonathan` | `4914418538`, `APPROVED`, body length 0,
`pulls/6185/comments` empty |
[31577748274](https://github.com/PRQL/prql/actions/runs/31577748274) —
08:18:45Z→08:20:35Z (110 s), published nothing |
| 2026-08-12 13:27Z | [#6186](PRQL/prql#6186) |
`kgutwin` | `4916991960`, `APPROVED`, body length 0, zero inline
comments |
[31601473217](https://github.com/PRQL/prql/actions/runs/31601473217) —
13:27:22Z→13:28:51Z (89 s), published nothing |

The third one's session log says why it published nothing, in five tool
calls: *"The trigger was a plain approval (`APPROVED`, empty body, no
inline comments) from @kgutwin on PR #6186, which is already **MERGED**.
No questions, no requested changes, no unaddressed comments anywhere on
the thread. Per the review-response rules, a plain approval gets no
reply, so I'm not posting anything."* The model reaches the right
verdict every time; the cost is that it has to boot to reach it.

## Solution

A third clause on the same gate chain, inside the `pull_request_review`
block and after the `@`-mention scan, so a mention buried in an inline
comment still summons the bot:

```bash
if [ "$REVIEW_STATE" = "approved" ] \
   && [ -z "$COMMENT_BODY" ] \
   && [ -z "$INLINE" ]; then
  echo "should_run=false" >> "$GITHUB_OUTPUT"
  exit 0
fi
```

It costs no extra API call — `$INLINE` is already fetched a few lines
above for the mention scan.

Two narrowings, both load-bearing:

- **`approved`, not any state.** A human's reply to one of the bot's
review threads also arrives as an empty-body review container, but
`COMMENTED`. Widening the state here would silence the bot on every
human reply to its own threads — the same trap
`test_mention_skips_bot_reply_container` pins from the author side,
since `pull_request_review_comment` subscribes to `edited` only.
- **`$INLINE` empty, not reply-only.** An approval whose nits live in
inline comments is a request addressed to the PR's author, and on a
bot-authored PR that is a role the bot has to act in. Only a review with
nothing in it anywhere is terminal.

The two author-keyed gates stay as they are: the bot's own empty-body
`APPROVED` is skipped before the `$INLINE` fetch, which keeps that path
one API call cheaper.

## Gate assessment

- **Evidence level: High** — a consistent pattern across three sessions
on two PRs and two approvers, spanning two days. High needs 2–3; this is
3.
- **Structural, not stochastic.** The gate condition is author-keyed in
the workflow YAML, so replaying any of these three scenarios ten times
boots the agent ten times. The model's judgement is not involved and is
not at fault.
- **Change type: targeted fix** — one clause on an existing chain,
reusing data already fetched. Normal bar, met by Gate 1.
- Both gates passed.

Evidence log: https://gist.github.com/192514ea2c36586f9b7f842a482d62ab
(`review-reviewers evidence: PRQL/prql 2026-08`), where this finding was
recorded at one occurrence on 2026-08-10 and at two on 2026-08-12 before
crossing here.

## Testing

`test_mention_skips_third_party_bare_approval` compares the whole gate
condition with whitespace normalized, so an author clause added later —
or the `$INLINE` clause dropped — fails on equality rather than sliding
past an `in` check. It fails on `main` (`ValueError: substring not
found`). The four `mention` regtest snapshots are updated. Full
generator suite: 420 passed.

---------

Co-authored-by: tend-agent <[email protected]>
max-sixty added a commit that referenced this pull request Aug 12, 2026
The release's last step: all eight generated workflows move from
`max-sixty/tend/[email protected]` to `@0.1.15`, which now exists as a tag.

The behaviour tend itself gains, having shipped it to adopters first:

- **`tend-review` gets the examined-HEAD gate**
([#903](#903)). Concurrency drops
to `cancel-in-progress: false` and the pre-check skips a queued run
whose live HEAD already carries the `tend-review/<pr>` stamp, so a push
mid-review queues behind the session instead of throwing away what it
had read.
- **`tend-mention` stops booting sessions that can only no-op**
([#849](#849),
[#916](#916),
[#955](#955)), and its verify gate
fetches a review's inline comments when deciding engagement.
- **`tend-notifications`** carries the pre-check's setup guard, so a run
that finds an empty inbox does no setup either.

Generated by `uvx tend@latest init`; the hand-maintained
`review-reviewers.yaml` is restamped onto `@0.1.15` in the same branch,
so `.github/workflows/` holds one action ref. `pre-commit run
--all-files` (actionlint included) is clean.

> _This was written by Claude Code on behalf of max-sixty_

---------

Co-authored-by: Claude Opus 5 (1M context) <[email protected]>
max-sixty pushed a commit to max-sixty/worktrunk that referenced this pull request Aug 13, 2026
Automated nightly regeneration of tend's workflow files.

**tend version:** 0.1.14 → 0.1.15

**Notable changes**

- **Rate-limit handling**: a maintainer can approve past the spike limit
(max-sixty/tend#874), and `tend-mention` now skips comments on
`tend-rate-limit`-labelled issues as well as `tend-outage` ones — the
same self-trigger loop guard, widened to every issue tend files about
its own health.
- **Review flow**: a push is queued behind an examined-HEAD gate instead
of cancelling the in-flight review (max-sixty/tend#903), the review is
submitted before a fix is pushed (max-sixty/tend#834), a force-push
triggers a re-review rather than trusting the re-anchored SHA
(max-sixty/tend#884), and the `/code-review` second pass is
unconditional (max-sixty/tend#937).
- **CI monitoring**: both the check poll and the `gh run rerun --failed`
poll now end terminally when the cap is hit instead of reading as done
(max-sixty/tend#876, max-sixty/tend#951), and a failed GitHub-status
probe no longer reads as "no incident" (max-sixty/tend#913).
- **Nightly**: conflicted bot PRs are test-merged locally instead of
filtered on the lazy `mergeable` field (max-sixty/tend#898), and mention
runs skip the bot's own review and a third party's content-free approval
(max-sixty/tend#916, max-sixty/tend#955).
- **`tend check`**: an unreadable ruleset bypass list is reported as
unknown rather than ungated (max-sixty/tend#825), environment names are
read one per line and addressed encoded (max-sixty/tend#879), and
`credential-environments` no longer points at the setting it rejects
(max-sixty/tend#900) — this repo currently `SKIP`s that check, so its
wording should improve here.

Full comparison:
max-sixty/tend@0.1.14...0.1.15

Co-authored-by: worktrunk-bot <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

tend-mention: bot's own non-empty-body review on someone else's PR starts a guaranteed no-op session (#747's sibling leg)

2 participants