Skip to content

fix(review): skip APPROVE when incremental commits are bot-authored - #212

Closed
tend-agent wants to merge 2 commits into
mainfrom
hourly/review-24219300860
Closed

tend-agent wants to merge 2 commits into
mainfrom
hourly/review-24219300860

Conversation

@tend-agent

Copy link
Copy Markdown
Collaborator

Summary

  • Add an explicit pre-flight check to the /tend-ci-runner:review skill: when every commit since LAST_REVIEW_SHA was authored by the bot itself, do not submit a new APPROVE — leave any existing approval in place.
  • Guards against the re-approval loop where a bot-pushed fix (from tend-notifications, tend-ci-fix, or a mention run) triggers tend-review, which then ratifies its own commit.

Evidence

Incident: max-sixty/worktrunk#2041 (merged)

Timeline on the logs branch (PR by max-sixty):

Time Commit Actor Review result
23:10:40Z d4e3e8b worktrunk-bot review #1 COMMENTED — flagged 2 real issues
23:17:58Z d6456bc worktrunk-bot review #2 COMMENTED — acknowledged trash-sweep fix
23:30:31Z f96b126 worktrunk-bot review #3 APPROVED (empty body)
23:32:17Z c30d804 worktrunk-bot push (fix from tend-notifications run 24218351323) —
23:36:57Z c30d804 worktrunk-bot review #4 APPROVED (empty body) — self-review of own commit

tend-review run 24218513196 session transcript shows the bot reasoning:

The bot already approved at f96b1260. The new commit is trivial — just one line change in state.rs using to_slash_lossy() for Windows path consistency. Let me verify the change is correct, check threads, and re-approve.

The skill's existing trivial-change branch already says "Otherwise do not submit a new review — the existing one stands", but the bot re-approved anyway. This ended with the bot holding 4 reviews on the PR, the last of which approved its own commit.

Related prior attempt: #154 (closed)

PR #154 tried to fix a similar pattern on PRQL/prql#5774 (5 redundant approvals) by skipping the review entirely. That was rejected — a review IS still needed, because bot-pushed commits can still introduce issues worth catching. This PR takes the narrower approach suggested in that thread: still review, just do not re-APPROVE.

Gate assessment

  • Classification: structural — any bot push to a PR the bot has already approved can repeat this.
  • Confidence: High. 1 fresh occurrence (PR #2041) plus the prior incident documented in fix(review): skip re-review when bot pushes to already-approved PR #154. Skill already has indirect guidance ("existing one stands") that was violated; the new check makes it keyed on commit authorship instead of an ambiguous triviality judgment.
  • Magnitude: Targeted fix (13 added lines in one skill file, no code changes).
  • Both gates pass.

Test plan

  • Next time tend-notifications or tend-ci-fix pushes a fix to a human PR that the bot has already approved, verify the follow-up tend-review run does not submit a second APPROVE.
  • Verify normal human-authored incremental review paths are unchanged (commits from the human PR author still get reviewed and approved as before).
  • Verify self-authored PRs (PR_AUTHOR == BOT_LOGIN) continue to work with the existing separate guidance.

Add an explicit pre-flight check in the /tend-ci-runner:review skill: if every
author of commits since LAST_REVIEW_SHA is the bot itself, do not submit a new
APPROVE. The existing review stands; a COMMENT is still allowed if the bot
spots a genuine issue in its own code. This prevents the re-approval loop
where a bot-pushed fix (tend-notifications, tend-ci-fix, tend-mention) triggers
tend-review, which then ratifies its own commit.

This complements the existing "existing one stands" rule for trivial
incremental changes by adding a structural safeguard keyed on commit
authorship rather than change size.

Co-Authored-By: Claude Opus 4.6 <[email protected]>
@tend-agent tend-agent added the claude-behavior Behavioral issues found by review-reviewers label Apr 10, 2026

@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.

One small concern: the new bot-authored branch jumps from "exit silently" straight to step 6 (monitor CI), skipping step 7 (resolve handled threads). When tend-notifications or tend-ci-fix pushes a fix for an issue the bot previously flagged in a COMMENT review, the addressed threads will be left open — a regression versus the existing trivial-changes branch, which routes through step 7. Inline suggestion below.

Otherwise the change is sound: keying on commit authorship is more reliable than the trivial-judgment heuristic the worktrunk #2041 bot reasoned its way around, and posting a COMMENT (rather than nothing) for genuine new issues is the right escape hatch.

Addresses review feedback: the new bot-authored branch jumped straight to
step 6, skipping step 7 (resolve handled threads). When a tend-notifications
or tend-ci-fix push addresses a prior bot COMMENT review, the suggestion
threads must still be resolved — a regression vs. the existing trivial-changes
branch, which already routes through step 7.

Co-Authored-By: Claude <[email protected]>
@max-sixty

Copy link
Copy Markdown
Owner

Guards against the re-approval loop where a bot-pushed fix (from tend-notifications, tend-ci-fix, or a mention run) triggers tend-review, which then ratifies its own commit.

but this is totally fine — we should not treat a bot PR differently from any other PR. We should make that clear in our docs

@tend-agent

Copy link
Copy Markdown
Collaborator Author

Got it — treating bot-authored commits specially is the wrong framing; the reviewer role is independent of commit authorship. Closing this. This is the second attempt at fixing this non-problem (first was #154), so happy to open a follow-up docs PR making the intended behavior explicit if you'd like — otherwise I'll leave it to you.

@tend-agent tend-agent closed this Apr 10, 2026
tend-agent pushed a commit that referenced this pull request Apr 10, 2026
review-reviewers has now made two attempts to "fix" tend-review
re-approving on bot-pushed fix commits — #154 and #212. Both were
closed by the maintainer as solving a non-problem ("bot PRs should
not be treated differently from any other PR"). Add a "Non-issues"
section to review-reviewers so the judgment doesn't repeat, and
document the principle in the review skill itself so the intent is
visible where the behavior lives.

Co-Authored-By: Claude Opus 4.6 <[email protected]>
max-sixty pushed a commit that referenced this pull request Apr 10, 2026
## Summary

- Add a **"Non-issues: do not flag these"** section to
`review-reviewers/SKILL.md` so the hourly judgment doesn't keep
re-discovering the same non-problem.
- Document in `review/SKILL.md` that commit and PR authorship don't
affect review behavior — reviewing/re-approving after a bot-pushed fix
is expected.

## Evidence — two prior rejections of the same fix

`review-reviewers` has now made two attempts to guard `tend-review` from
re-approving on bot-pushed fix commits. Both were closed by the
maintainer as solving a non-problem.

| PR | Title | Closed | Maintainer feedback |
|---|---|---|---|
| [#154](#154) | `fix(review):
skip re-review when bot pushes to already-approved PR` | 2026-04-07 |
"but presumably this does require a new review, no? why is this case
special?" |
| [#212](#212) | `fix(review):
skip APPROVE when incremental commits are bot-authored` | 2026-04-10
01:07Z | "this is totally fine — we should *not* treat a bot PR
differently from any other PR. We should make that clear in our docs" |

The second rejection explicitly asked for the principle to be
documented. This PR does that.

## Root cause

Run
[24219300860](https://github.com/max-sixty/tend/actions/runs/24219300860)
(prior `review-reviewers` run at 23:59Z) observed a `tend-review` run on
max-sixty/worktrunk#2041 submitting a fourth APPROVED review on a
bot-authored commit pushed by `tend-notifications`, classified it as
"Structural — recurs whenever the bot pushes to a PR it already
reviewed," and filed #212. The judgment was wrong: commit authorship is
not a review-logic problem. Run
[24220122739](https://github.com/max-sixty/tend/actions/runs/24220122739)
(`tend-review` on #212) then correctly executed the new logic the PR
added, but the PR's premise was rejected by the maintainer minutes later
in run
[24221123712](https://github.com/max-sixty/tend/actions/runs/24221123712).

The underlying 5-stacked-approvals incident that originally motivated
#154 ([PRQL/prql#5774](PRQL/prql#5774)) was a
*concurrency* issue — cancelled runs racing to POST approvals before
SIGTERM arrived — not a review-logic issue. This is called out in the
new "Non-issues" entry so it isn't confused for the same pattern in
future.

## Gate assessment

| Gate | Result |
|---|---|
| **Evidence level** | Critical — two closed PRs with explicit
maintainer rejection, plus an explicit "make that clear in our docs"
request |
| **Occurrences** | 3 independent instances (PR #154 authoring run, PR
#212 authoring run 24219300860, and each closure) |
| **Classification** | **Structural** — the skill has no guidance
distinguishing expected re-approval from a loop; it will make the same
judgment again without a fix |
| **Change type** | **Targeted fix** — 21 lines total across two files,
no restructuring |
| **Passes Gate 1 (confidence)** | Yes — Critical bar is 1 occurrence;
this has 2 |
| **Passes Gate 2 (magnitude)** | Yes — targeted fix at normal threshold
|

## Test plan

- [ ] Next time a `tend-review` run re-approves after
`tend-notifications` or `tend-ci-fix` pushes a fix, the subsequent
`review-reviewers` run should not flag it as a behavioral problem.
- [ ] The `review` skill continues reviewing bot-pushed fixes normally
(no behavior change — only documentation added).

Co-authored-by: continuous-bot <[email protected]>
Co-authored-by: Claude Opus 4.6 <[email protected]>
max-sixty pushed a commit that referenced this pull request Apr 10, 2026
…aping (#217)

## Summary

The CI polling loop in `running-in-ci` and `review` skills uses `if !
cmd`, but the Claude Code Bash tool escapes `!` as `\!` before handing
commands to bash. Bash then parses the escaped token as a literal
command (`!: command not found`), so the early-exit branch of `if !
pipeline` is unreachable. Every poll runs all 10 iterations and prints a
false "CI still running after 10 minutes".

Switched both loops to `cmd || { ...; }`, which doesn't rely on `!`.

## Evidence

Reproduced in the bash tool this run:

```
$ echo 'if ! false; then echo then; else echo else; fi' > /tmp/t.sh
$ cat /tmp/t.sh
if \! false; then echo then; else echo else; fi
$ bash /tmp/t.sh
/tmp/t.sh: line 1: !: command not found
else
```

And similarly `printf '%s\n' '!test'` writes `\!test` — the escape
happens even inside single quotes, so there is no source-level
workaround.

Observed in a real polling run — tend-mention PR #212, run
[24220018870](https://github.com/max-sixty/tend/actions/runs/24220018870).
The background task output was:

```
CI still running after 10 minutes
no required checks reported on the 'hourly/review-24219300860' branch
```

With a working `!`, the first iteration's pipeline exits 1 (grep -q no
match), the `!` flips it to 0, and the loop exits immediately. Instead,
the loop ran to completion — consistent with `if ! pipeline` always
evaluating to the else branch (because `!` is treated as an unknown
command, exit 127, which is non-zero, which `if` sees as false).

The bot on that run attributed the timeout to "no required checks" but
that explanation doesn't hold — any polling of any PR in this harness
suffers the same fate.

## Fix

Replace

```bash
if ! gh pr checks <n> --required 2>&1 | grep -v ... | grep -q 'pending\|...'; then
  gh pr checks <n> --required
  exit 0
fi
```

with

```bash
gh pr checks <n> --required 2>&1 | grep -v ... | grep -q 'pending\|...' || {
  gh pr checks <n> --required
  exit 0
}
```

`||` is a distinct operator (not `!`), so the escape doesn't apply.
Verified locally that the rewritten loop exits on iteration 1 when the
pipeline returns non-zero.

## Gate assessment

- **Confidence**: Critical. Every polling run hits this; reproduced
in-session and observed in a real run. One occurrence is sufficient per
the gates.
- **Classification**: Structural. The same conditions will recur on
every polling invocation.
- **Magnitude**: Targeted fix — 6 lines changed across 2 skill files, no
behavior change on the happy path.

## Test plan

- [x] `cd generator && uv run pytest` (147 passed)
- [ ] Next tend-review run on this branch polls CI and exits cleanly
within one iteration instead of timing out at 10 minutes

Co-authored-by: tend-agent <[email protected]>
tend-agent pushed a commit that referenced this pull request Apr 14, 2026
…as non-issue

Add `tend-mention` self-triggers from bot-authored comments to the non-issues
list. Multiple review-reviewers runs have observed this pattern (bot posts a
comment → `issue_comment` event fires `tend-mention` → Claude exits silently
via the self-conversation guard) and one prior PR (#203) attempted sender-
based filtering, which the maintainer closed without merge — same authorship-
keyed-guard pattern rejected in #154 and #212. Recording this explicitly
prevents future runs from re-drafting similar PRs.

Co-Authored-By: Claude Opus 4.6 <[email protected]>
max-sixty pushed a commit that referenced this pull request Apr 14, 2026
## Summary

Add a second entry to the `review-reviewers` **Non-issues** list so
future
hourly runs don't re-draft sender-based filters for `tend-mention`. The
entry
covers the case where the bot's own `issue_comment` (e.g., posting on a
user
issue where it previously replied, or its own tracking issue) fires
`tend-mention`, which then exits silently via the prompt's
self-conversation
guard.

## Evidence

Three self-trigger runs on `max-sixty/tend` in the past ~2 hours (window
15:18Z–16:17Z on 2026-04-14), each spun up Claude and exited silently:

| Run | Trigger | Cost | Turns |
|---|---|---|---|
|
[24407340908](https://github.com/max-sixty/tend/actions/runs/24407340908)
| `tend-agent` comment on `review-reviewers-tracking` #133 | $0.47 | 12
|
|
[24409523729](https://github.com/max-sixty/tend/actions/runs/24409523729)
| `tend-agent` triage comment on issue #269 | $0.20 | 6 |
|
[24410231240](https://github.com/max-sixty/tend/actions/runs/24410231240)
| `tend-agent` comment on tracking issue #133 | $0.22 | 7 |

All three exit with reasoning like "self-trigger, no role boundary,
exiting
silently" — the prompt-level guard works correctly, just at a few
hundred
tokens of cost per occurrence.

## Why no workflow fix

[#203](#203) ("fix: filter bot
self-triggers in tend-mention workflow") proposed exactly this sender
filter
for `pull_request_review` / `pull_request_review_comment` events on
2026-04-09. @max-sixty closed it without merge or comment, matching the
pattern of earlier closures of authorship-keyed guards
([#154](#154),
[#212](#212)) already called out
in the
non-issues list. Extending the same sender filter to `issue_comment`
would
fit the same rejected shape, so this PR only updates the skill to
prevent
future runs from re-drafting it.

## Gate assessment

- **Evidence level**: High — 3 occurrences this run, structural (every
bot
comment on a participated-in issue fires `tend-mention` verify→handle),
and
  direct prior-art signal (#203 closed by maintainer).
- **Classification**: Structural (deterministic from workflow logic) —
same
  condition always produces the wasted Claude invocation.
- **Change type**: Targeted simplification — adds one bullet to an
existing
  warning list. No workflow or generator changes.
- **Passes both gates**: yes (structural 1+ occurrence sufficient for
  removal/simplification; change is one-paragraph docs).

## Test plan

- [ ] Rendered non-issues list reads sensibly and cites #203 / #268
accurately

Co-authored-by: continuous-bot <[email protected]>
Co-authored-by: Claude Opus 4.6 <[email protected]>
tend-agent added a commit that referenced this pull request May 10, 2026
Remove links to specific past PRs (#154, #212, #263, #203, #268, #392, #375, #305, #318) from review-reviewers and running-in-ci, restating each as a structural rule (what shape is accepted, what shape is not). Extend "Authoring skills" in the root CLAUDE.md with a parallel "No specific past-case references" bullet so future skill edits don't re-introduce them.

Co-Authored-By: Claude Opus 4.7 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

claude-behavior Behavioral issues found by review-reviewers

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants