Skip to content

skills(review-reviewers): scan PR/issue bodies and reviews for corruption - #405

Merged
max-sixty merged 3 commits into
mainfrom
hourly/review-25624020037-scan
May 10, 2026
Merged

max-sixty merged 3 commits into
mainfrom
hourly/review-25624020037-scan

Conversation

@tend-agent

Copy link
Copy Markdown
Collaborator

Problem

The corruption-scan recipe in review-reviewers only fetches issue comments (/issues/$n/comments). Bot-authored issue bodies, PR bodies, review bodies, and inline review comments live on different endpoints and are not scanned. A survey-issue body composed by gh issue create --body "$(cat <<EOF ... EOF)" containing code references with ! ships visibly corrupted backslash-bang to GitHub, and prior review-reviewers runs miss it.

Evidence

This run found 5 backslash-bang corruption sites in the body of worktrunk issue #2663 ("Nightly drift cleanup", opened by worktrunk-bot). Examples (shown raw from gh issue view 2663 --json body --jq .body):

  • <\!-- ⚠️ AUTO-GENERATED ... -->
  • eprintln\!("---")
  • assert\!(\!repo.root_path().join("marker.txt").exists())
  • anyhow::ensure\!(...), \!= ErrorKind::NotFound
  • \!self.dirty_files()

The existing recipe didn't catch any of these because it doesn't fetch /issues/$n (body) or /pulls/$n (body) at all. The maintainer engaged with the issue and merged five resulting fix PRs, so this didn't block the workflow — but every code reference in the issue rendered with literal backslashes.

The watch item "review-reviewers corruption-scan recipe doesn't cover PR/issue bodies" carried in evidence for prior months awaiting concrete recurrence; this run provides it.

Fix

Extend the recipe to fetch four endpoints, not one:

  1. /issues/$n/comments — existing; covers issue and PR comments via the issue_comment surface.
  2. /issues/$n (body) — for bot-opened issues this window.
  3. /pulls/$n (body) — for bot-opened PRs this window.
  4. /pulls/$n/reviews and /pulls/$n/comments — review bodies and inline review comments.

The four greps (${, backslash-bang, blob/main/...#L, anthropics/) stay the same. The change is purely about what is scanned, not how.

Companion to #404

PR #404 extends the running-in-ci bang-escape rule to enumerate issue/PR bodies (preventative). This PR extends the scan recipe to detect them (detective). Either lands independently — they are reverted independently and address different concerns.

…tion

The recipe only covered issue_comments. Bot-authored issue and PR bodies are
composed via the same `gh issue create --body` / `gh pr create --body` paths
that the Bash-tool preprocessor mangles — when a body quotes code references,
backslash-bang corruption ships to GitHub and prior runs missed it because
the scan didn't look there. Reviews and inline review comments are also
distinct endpoints. Cover all four surfaces.
@tend-agent tend-agent added the claude-behavior Behavioral issues found by review-reviewers label May 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 coverage gap in the new recipe: the reviews + inline-review-comments scans iterate <bot-opened-prs>, but tend-review's output ships in reviews/inline comments on human-authored PRs — those PRs won't be in <bot-opened-prs>, so the new scan still misses the most common bot-review surface. Splitting the loop catches that case.

Comment on lines 250 to 261
> # PR bodies (when bot opened the PR this window) + reviews + inline review comments
> for n in <bot-opened-prs>; do
> gh api "repos/$ARGUMENTS/pulls/$n" \
> --jq "select(.user.login == \"$BOT_LOGIN\" and .created_at > \"<window-start>\") | \"=== PR #$n body ===\n\(.body)\n\"" \
> >> /tmp/bot-output/all.txt
> gh api "repos/$ARGUMENTS/pulls/$n/reviews" \
> --jq ".[] | select(.user.login == \"$BOT_LOGIN\" and .submitted_at > \"<window-start>\") | \"=== PR #$n review \(.id) state=\(.state) ===\n\(.body)\n\"" \
> >> /tmp/bot-output/all.txt
> gh api "repos/$ARGUMENTS/pulls/$n/comments?per_page=100" \
> --jq ".[] | select(.user.login == \"$BOT_LOGIN\" and .created_at > \"<window-start>\") | \"=== PR #$n inline-comment \(.id) ===\n\(.body)\n\"" \
> >> /tmp/bot-output/all.txt
> done

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.

Suggested change
> # PR bodies (when bot opened the PR this window) + reviews + inline review comments
> for n in <bot-opened-prs>; do
> gh api "repos/$ARGUMENTS/pulls/$n" \
> --jq "select(.user.login == \"$BOT_LOGIN\" and .created_at > \"<window-start>\") | \"=== PR #$n body ===\n\(.body)\n\"" \
> >> /tmp/bot-output/all.txt
> gh api "repos/$ARGUMENTS/pulls/$n/reviews" \
> --jq ".[] | select(.user.login == \"$BOT_LOGIN\" and .submitted_at > \"<window-start>\") | \"=== PR #$n review \(.id) state=\(.state) ===\n\(.body)\n\"" \
> >> /tmp/bot-output/all.txt
> gh api "repos/$ARGUMENTS/pulls/$n/comments?per_page=100" \
> --jq ".[] | select(.user.login == \"$BOT_LOGIN\" and .created_at > \"<window-start>\") | \"=== PR #$n inline-comment \(.id) ===\n\(.body)\n\"" \
> >> /tmp/bot-output/all.txt
> done
> # PR bodies (when bot opened the PR this window)
> for n in <bot-opened-prs>; do
> gh api "repos/$ARGUMENTS/pulls/$n" \
> --jq "select(.user.login == \"$BOT_LOGIN\" and .created_at > \"<window-start>\") | \"=== PR #$n body ===\n\(.body)\n\"" \
> >> /tmp/bot-output/all.txt
> done
> # PR reviews + inline review comments (any PR the bot reviewed/commented on, not just bot-opened)
> for n in <pr-numbers-bot-reviewed>; do
> gh api "repos/$ARGUMENTS/pulls/$n/reviews" \
> --jq ".[] | select(.user.login == \"$BOT_LOGIN\" and .submitted_at > \"<window-start>\") | \"=== PR #$n review \(.id) state=\(.state) ===\n\(.body)\n\"" \
> >> /tmp/bot-output/all.txt
> gh api "repos/$ARGUMENTS/pulls/$n/comments?per_page=100" \
> --jq ".[] | select(.user.login == \"$BOT_LOGIN\" and .created_at > \"<window-start>\") | \"=== PR #$n inline-comment \(.id) ===\n\(.body)\n\"" \
> >> /tmp/bot-output/all.txt
> done```

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.

Adopted the split in c832145; switched the placeholder to your <pr-numbers-bot-reviewed> in 4d29a1f — agreed it signals intent better than the broader <pr-numbers> I had.

tend-agent and others added 2 commits May 10, 2026 08:47
The loop iterating <bot-opened-prs> covered PR bodies, reviews, and inline
review comments together, but tend-review writes reviews and inline comments
on human-authored PRs that never appear in <bot-opened-prs>. Split the loop:
PR bodies still use <bot-opened-prs>, reviews and inline review comments use
<pr-numbers> (all PRs touched in the window).

Co-Authored-By: Claude Opus 4.7 <[email protected]>
Replace <pr-numbers> with the more precise <pr-numbers-bot-reviewed>
suggested in review — signals that the loop wants the set of PRs the bot
reviewed or commented on this window, not every PR touched.

Co-Authored-By: Claude Opus 4.7 <[email protected]>
@max-sixty
max-sixty merged commit 04761f8 into main May 10, 2026
5 checks passed
@max-sixty
max-sixty deleted the hourly/review-25624020037-scan branch May 10, 2026 14:57
max-sixty added a commit that referenced this pull request Aug 13, 2026
…eck (#966)

Drops the `47 * * * *` cron from `review-reviewers`, leaving
`workflow_dispatch`. Its recent output had converged on maintaining its
own evidence machinery, at the fleet's highest per-run cost and a
seven-day quota ceiling that twice took the user-facing workflows down
with it; each adopter's daily `tend-review-runs` already reviews that
repo's runs from the inside and routes bundled-skill defects upstream,
so this removes the direct loop rather than the only one.

The skill is scoped to match: it described itself as hourly and told the
session to analyze "the past hour". It now states the window
`list-recent-runs.sh` actually hands it — floor at the previous
successful run of the workflow, clamped 6h back — which with no cron
makes the clamp the normal case rather than an outage signal, and scopes
its claims to that window. (An earlier revision of this PR described a
cron-payload branch; #965 replaced that logic while this branch was
open, and the text was rebased onto what merges.)

<details><summary>What the sweep caught, and when</summary>

Its unique catches — the ones no inside-out session would have found —
cluster in April–June: rubber-stamped APPROVEs over visibly failing
checks (#667), backslash-backtick corruption in already-published
comment bodies across repos (#359, #405, #424, #562), stale PRs silently
dropping mentions (#391), and the stale/re-anchored approval family
(#798, #821, #884).

The last two weeks are dominated by fixes to its own machinery —
evidence-gist plumbing, survey-window arithmetic, matrix branch naming,
run→output attribution — while per-run cost climbed from $5.31 to
$10.49. That is the shape the cost gate in #960 was written for.

</details>

Re-enable by dispatching it after a change that could move bot behavior
fleet-wide: a release, a harness switch, a model bump — within the hour
of that change, per the window note in the overlay.

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

---------

Co-authored-by: Claude Fable 5 <[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.

2 participants