Skip to content

skills(review-reviewers): add bash-tool-safe corruption-scan recipe - #359

Merged
max-sixty merged 2 commits into
mainfrom
hourly/review-25155760186
Apr 30, 2026
Merged

max-sixty merged 2 commits into
mainfrom
hourly/review-25155760186

Conversation

@tend-agent

Copy link
Copy Markdown
Collaborator

Problem

The Step-2 subagent prompt in review-reviewers lists "Bot comment contains corruption (literal ${, unescaped bangs, broken heredoc markers)" as a negative outcome signal but doesn't say how to scan. Each run improvises the scan inline, and the natural authorings — jq regex like test("\\!") or grep -P '\\!' written directly in a Bash command — get mangled by the same Bash-tool exclamation-mark preprocessor the scan is trying to detect: \! rewrites to \\!, jq aborts with Invalid escape "\!", the scan reports "zero matches", and the run silently passes a corrupted comment.

Evidence

Two concrete cases observed today (run 25155760186 on max-sixty/worktrunk):

  1. Detection failure. The prior review-reviewers run 25153406082 listed worktrunk-bot comment 4350585541 ("Good news — the spike at...") in its corruption scan and reported "zero matches" for \!. Today's grep on the same comment body finds clear \! corruption mid-comment inside a code span: The PR is already a substantive `\!` refactor. My own first-pass inline-jq scan reproduced the trap immediately — jq: error: Invalid escape "\!". Switching to grep -F and grep -P '\\!' against a file-dumped body found the corruption that the prior scan missed.

  2. Underlying recurrence (not fixed in this PR). Comment 4350585541 itself is the 2nd wild post-skills: restore bang-escape warning (bug still fires in CI harness) #318 occurrence of the bot shipping \! corruption to a public comment (1st was issue #2309 on 2026-04-20, recorded in the gist). Recorded in the evidence gist for the recurrence-rate counter. Not addressed here because the existing skill warning already directs the right behavior; the bot just lapsed.

Fix

Add one paragraph + one code block to the Step-2 subagent prompt: dump bot bodies to a file, then scan with grep -F (literal ${, anthropics/) and grep -P '\\!' for backslash-bang. The file-then-scan two-step keeps the regex out of the bash-tool input where the preprocessor would touch it, and grep -P is robust to the rewrite — \! in the source becomes \\! after rewrite, and PCRE \\! still matches literal \! because ! is not a regex metacharacter.

Gate assessment

  • Evidence level: Medium — 2 documented occurrences (prior run's silent miss + today's reproduction in the same skill).
  • Failure class: structural — the Bash-tool preprocessor consistently rewrites every \! regardless of quoting form, so any inline scan authored with \! in its pattern will hit the same trap.
  • Magnitude: targeted fix — adding a missing step to an existing recipe (not new conceptual guidance).
  • Both gates: PASS.

Evidence gist (current month): https://gist.github.com/44ab1483b29406255dd36141650c894d

The Step-2 subagent prompt lists corruption signals (literal ${,
unescaped bangs, broken heredoc markers) but doesn't say how to scan.
Each run improvises inline, and inline jq/grep with a literal backslash-
bang is itself mangled by the Bash-tool exclamation-mark preprocessor —
jq aborts with Invalid escape, the run reports zero matches, and the
corrupted comment slips through.

Add a recipe: dump bodies to a file first, then scan the file with
grep -F for fixed strings and grep -P for backslash-bang.

Co-Authored-By: Claude Opus 4.7 <[email protected]>
@tend-agent tend-agent added the claude-behavior Behavioral issues found by review-reviewers label Apr 30, 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.

The recipe doesn't run as written: gh api rejects --arg ("unknown flag"), and its built-in --jq has no way to accept jq variables — so the filter sees $BOT and $WIN undefined and aborts. Inlining the shell vars into the filter (matching the gh issue list ... --jq ".[] | select(.title | contains(\"$MONTH\"))" pattern already used elsewhere in this file) avoids the issue.

Comment on lines +237 to +239
> gh api "repos/$ARGUMENTS/issues/$n/comments?per_page=100" \
> --jq '.[] | select(.user.login == $BOT and .created_at > $WIN) | "=== #'$n' \(.id) ===\n\(.body)\n"' \
> --arg BOT "$BOT_LOGIN" --arg WIN "<window-start>" >> /tmp/bot-output/all.txt

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
> gh api "repos/$ARGUMENTS/issues/$n/comments?per_page=100" \
> --jq '.[] | select(.user.login == $BOT and .created_at > $WIN) | "=== #'$n' \(.id) ===\n\(.body)\n"' \
> --arg BOT "$BOT_LOGIN" --arg WIN "<window-start>" >> /tmp/bot-output/all.txt
> gh api "repos/$ARGUMENTS/issues/$n/comments?per_page=100" \
> --jq ".[] | select(.user.login == \"$BOT_LOGIN\" and .created_at > \"<window-start>\") | \"=== #$n \(.id) ===\n\(.body)\n\"" \
> >> /tmp/bot-output/all.txt

gh api rejects --arg (it's a jq CLI flag, not a gh api flag), and its built-in -q/--jq filter has no facility for passing variables — $BOT and $WIN are undefined, so the filter aborts. Inlining via shell quoting matches the pattern used in the gh issue list ... --jq ".[] | select(.title | contains(\"$MONTH\"))" block above.

gh api has no --arg flag and its built-in --jq doesn't accept jq variables,
so the original filter referenced undefined $BOT/$WIN and aborted. Inline
the shell vars into the filter, matching the pattern at line 79.

Co-Authored-By: Claude Opus 4.7 <[email protected]>
@tend-agent

Copy link
Copy Markdown
Collaborator Author

You're right — verified gh api rejects --arg. Pushed ddf07cc inlining $BOT_LOGIN and <window-start> into the --jq filter, matching the contains(\"$MONTH\") pattern at line 79. Confirmed the new form runs against a PR with bot comments and prints the expected output.

@max-sixty
max-sixty merged commit febec9d into main Apr 30, 2026
3 checks passed
@max-sixty
max-sixty deleted the hourly/review-25155760186 branch April 30, 2026 09:03
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