Skip to content

claude-code-review: gha#541's diff-redirect denial loop recurred despite gha#542's prompt paragraph (7 of 14 denials, $7.99, no verdict) #565

Description

@d-morrison

What happened

Morrison-Lab/ai-config run 32529549403 (PR ai-config#1841) burned $7.99 across two attempts and produced no verdict.

  • Attempt 1: 5 turns, 23s, $0.91, permission_denials_count: 0, no ### Verdict -> classified retryable (gha#185).
  • Attempt 2 (retry): 8 turns, 327s, $7.08, 14 denials, no verdict -> above the threshold of 5, classified gha#198, not retried, job failed.

gha#543's failure comment did post, so the thread is not silent -- that part worked.

The recurrence

Seven of the 14 denials are gha#541's exact pattern, which gha#542 was supposed to have mitigated by adding a system-prompt paragraph telling the reviewer to call gh pr diff bare:

gh pr diff 1841 --repo Morrison-Lab/ai-config > /tmp/pr1841.diff 2>&1; grep -nP '...' /tmp/pr1841.diff | ...
gh pr diff 1841 --repo Morrison-Lab/ai-config > /tmp/pr1841.diff && grep -nP '[^\x00-\x7F]' /tmp/pr1841.diff | head -50
gh pr diff 1841 --repo Morrison-Lab/ai-config > /tmp/pr1841.diff
gh pr diff 1841 --repo Morrison-Lab/ai-config > /home/runner/work/ai-config/ai-config/pr1841.diff && wc -l ...
gh pr diff 1841 --repo Morrison-Lab/ai-config > /tmp/pr1841.diff          (again)
gh pr diff 1841 --repo Morrison-Lab/ai-config > /tmp/pr1841.diff          (again)
gh pr diff 1841 --repo Morrison-Lab/ai-config > /home/runner/work/ai-config/ai-config/pr1841.diff.tmp

That paragraph was verifiably live in this run -- it is in the --append-system-prompt block in the job log. So this is not a case of the mitigation not having shipped; it shipped and did not hold.

Why prompt-only is the wrong shape of fix here

This is the "a prompt instruction is a request; a permission rule is a constraint" point that gha's own CLAUDE.md already makes for gha#392/#532. The reviewer wants a file it can grep, and telling it not to want one has now failed twice. Note the motive is legitimate: it was scanning the diff for non-ASCII punctuation, which needs grep -P over the whole diff rather than a paged tool result.

Proposed deterministic fix: pre-fetch the diff in the workflow, before the agent starts, into the workspace, and name the path in the prompt.

  • A workflow step runs gh pr diff <n> --repo <owner>/<repo> > "$GITHUB_WORKSPACE/pr-<n>.diff".
  • The system prompt is amended to say the complete diff is already saved at that path -- read or grep it directly, and never try to produce it yourself.

That removes the wanting, rather than forbidding the acting. It also makes the diff available to grep/Read (default-allowed tools) with no Bash redirect involved at all.

Alternative considered

Widening the allowlist cannot express this: Bash(gh pr diff:*) rejects a command as a whole once a redirect, pipe, or chain is present, so no allowlist entry short of allowing arbitrary Bash would permit these.

Evidence

The other seven denials are a separate gap; filed alongside this.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions