From 1c4b11e5502f895cf345389f63c0634a39b69c84 Mon Sep 17 00:00:00 2001 From: Spencer Bryngelson Date: Sat, 4 Apr 2026 09:21:58 -0400 Subject: [PATCH 1/5] Fix Claude Code Review CI: remove synchronize trigger, filter tests/ dir Remove the synchronize event trigger that was causing the review to run on every push to a PR branch, exhausting the API quota. Also remove all incremental review mode logic (now dead code) and filter out tests/ directory from review inputs since golden files don't need code review. --- .github/workflows/claude-code-review.yml | 95 +++--------------------- 1 file changed, 11 insertions(+), 84 deletions(-) diff --git a/.github/workflows/claude-code-review.yml b/.github/workflows/claude-code-review.yml index 6d603d55db..dfbe7113fd 100644 --- a/.github/workflows/claude-code-review.yml +++ b/.github/workflows/claude-code-review.yml @@ -2,7 +2,7 @@ name: Claude Code Review on: pull_request_target: - types: [opened, synchronize, ready_for_review, reopened, labeled] + types: [opened, ready_for_review, reopened, labeled] issue_comment: types: [created] @@ -15,7 +15,6 @@ jobs: github.event.action == 'opened' || github.event.action == 'ready_for_review' || github.event.action == 'reopened' || - github.event.action == 'synchronize' || ( github.event.action == 'labeled' && github.event.label.name == 'claude-full-review' @@ -47,7 +46,7 @@ jobs: with: fetch-depth: 1 - - name: Determine PR number and requested review mode + - name: Determine PR number id: mode shell: bash run: | @@ -55,34 +54,14 @@ jobs: if [[ "${{ github.event_name }}" == "pull_request_target" ]]; then PR_NUMBER="${{ github.event.pull_request.number }}" - case "${{ github.event.action }}" in - opened|ready_for_review|reopened) - REQUESTED_MODE="full" - ;; - synchronize) - REQUESTED_MODE="incremental" - ;; - labeled) - if [[ "${{ github.event.label.name }}" == "claude-full-review" ]]; then - REQUESTED_MODE="full" - else - REQUESTED_MODE="full" - fi - ;; - *) - REQUESTED_MODE="full" - ;; - esac elif [[ "${{ github.event_name }}" == "issue_comment" ]]; then PR_NUMBER="${{ github.event.issue.number }}" - REQUESTED_MODE="full" else echo "Unsupported event" exit 1 fi echo "pr_number=$PR_NUMBER" >> "$GITHUB_OUTPUT" - echo "requested_mode=$REQUESTED_MODE" >> "$GITHUB_OUTPUT" - name: Resolve review state id: state @@ -94,7 +73,6 @@ jobs: PR_NUMBER="${{ steps.mode.outputs.pr_number }}" REPO="${{ github.repository }}" - REQUESTED_MODE="${{ steps.mode.outputs.requested_mode }}" mkdir -p .claude-review/context @@ -108,23 +86,13 @@ jobs: )" EXISTING_COMMENT_ID="" - PREVIOUS_REVIEWED_SHA="" if [[ -n "${LAST_COMMENT_B64:-}" ]]; then LAST_COMMENT_JSON="$(printf '%s' "$LAST_COMMENT_B64" | base64 -d)" EXISTING_COMMENT_ID="$(printf '%s' "$LAST_COMMENT_JSON" | jq -r '.id // empty')" - COMMENT_BODY="$(printf '%s' "$LAST_COMMENT_JSON" | jq -r '.body // empty')" - PREVIOUS_REVIEWED_SHA="$(printf '%s' "$COMMENT_BODY" | sed -n 's/.*reviewed_sha=\([0-9a-fA-F]\{7,\}\).*/\1/p' | tail -n1)" - fi - - EFFECTIVE_MODE="$REQUESTED_MODE" - if [[ "$REQUESTED_MODE" == "incremental" && -z "${PREVIOUS_REVIEWED_SHA:-}" ]]; then - EFFECTIVE_MODE="full" fi echo "existing_comment_id=${EXISTING_COMMENT_ID:-}" >> "$GITHUB_OUTPUT" - echo "previous_reviewed_sha=${PREVIOUS_REVIEWED_SHA:-}" >> "$GITHUB_OUTPUT" - echo "effective_mode=$EFFECTIVE_MODE" >> "$GITHUB_OUTPUT" - name: Build review diff and changed-file list id: review_input @@ -136,43 +104,20 @@ jobs: PR_NUMBER="${{ steps.mode.outputs.pr_number }}" REPO="${{ github.repository }}" - MODE="${{ steps.state.outputs.effective_mode }}" - CURRENT_SHA="${{ steps.state.outputs.current_head_sha }}" - PREV_SHA="${{ steps.state.outputs.previous_reviewed_sha }}" mkdir -p .claude-review - : > .claude-review/review.diff - : > .claude-review/changed_files.txt - build_full() { - gh pr diff "$PR_NUMBER" --repo "$REPO" > .claude-review/review.diff - gh pr view "$PR_NUMBER" --repo "$REPO" --json files --jq '.files[].path' > .claude-review/changed_files.txt - echo "actual_mode=full" >> "$GITHUB_OUTPUT" - } + gh pr diff "$PR_NUMBER" --repo "$REPO" > .claude-review/review.diff.raw + gh pr view "$PR_NUMBER" --repo "$REPO" --json files --jq '.files[].path' > .claude-review/changed_files.txt.raw - if [[ "$MODE" == "full" ]]; then - build_full - else - if gh api -H "Accept: application/vnd.github.diff" \ - "repos/$REPO/compare/$PREV_SHA...$CURRENT_SHA" > .claude-review/review.diff.tmp 2>/dev/null \ - && gh api "repos/$REPO/compare/$PREV_SHA...$CURRENT_SHA" --jq '.files[].filename' > .claude-review/changed_files.txt.tmp 2>/dev/null; then - mv .claude-review/review.diff.tmp .claude-review/review.diff - mv .claude-review/changed_files.txt.tmp .claude-review/changed_files.txt - echo "actual_mode=incremental" >> "$GITHUB_OUTPUT" - else - echo "Compare diff failed; falling back to full review." - build_full - fi - fi + # Filter out tests/ directory — golden files don't need code review + grep -v '^tests/' .claude-review/changed_files.txt.raw > .claude-review/changed_files.txt || true + # Strip diff hunks for tests/ files + awk '/^diff --git a\/tests\//,/^diff --git a\//{if(/^diff --git a\// && !/^diff --git a\/tests\//)print; next}; {print}' \ + .claude-review/review.diff.raw > .claude-review/review.diff sed -i '/^[[:space:]]*$/d' .claude-review/changed_files.txt || true - if [[ ! -s .claude-review/review.diff ]] || [[ ! -s .claude-review/changed_files.txt ]]; then - echo "Prepared diff or changed file list is empty; falling back to full review." - build_full - sed -i '/^[[:space:]]*$/d' .claude-review/changed_files.txt || true - fi - echo "review_diff_path=.claude-review/review.diff" >> "$GITHUB_OUTPUT" echo "changed_files_path=.claude-review/changed_files.txt" >> "$GITHUB_OUTPUT" @@ -235,10 +180,7 @@ jobs: prompt: | You are running in GitHub Actions review automation. - REQUESTED REVIEW MODE: ${{ steps.state.outputs.effective_mode }} - ACTUAL REVIEW MODE: ${{ steps.review_input.outputs.actual_mode }} PR NUMBER: ${{ steps.mode.outputs.pr_number }} - PREVIOUS REVIEWED SHA: ${{ steps.state.outputs.previous_reviewed_sha }} CURRENT HEAD SHA: ${{ steps.state.outputs.current_head_sha }} Review ONLY the prepared inputs for this run. @@ -278,10 +220,7 @@ jobs: 8) Do NOT post, update, or create GitHub comments yourself Review policy: - - In full mode, review the full PR diff. - - In incremental mode, review only the delta diff. - - In incremental mode, report only new issues introduced by that delta. - - Do NOT repeat earlier findings. + - Review the full PR diff. - Do NOT restate the full PR summary. - If there are no high-confidence findings, leave .claude-review/output.md empty and STOP. @@ -292,9 +231,8 @@ jobs: Output rules: - Write markdown only to .claude-review/output.md - - If there are findings, use exactly one of these formats. + - If there are findings, use exactly this format: - For full mode: Claude Code Review Head SHA: @@ -308,17 +246,6 @@ jobs: - For incremental mode: - Claude Code Review - - Incremental review from: - Head SHA: - - New findings since last Claude review: - - - - - - Always include the hidden marker exactly once at the end of the file. - If there are no findings, write nothing. From 39a3752fd5ee498b5244564b80747cc79b397d5d Mon Sep 17 00:00:00 2001 From: Spencer Bryngelson Date: Sat, 4 Apr 2026 09:30:37 -0400 Subject: [PATCH 2/5] Fix awk filter to properly strip entire tests/ diff blocks --- .github/workflows/claude-code-review.yml | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/.github/workflows/claude-code-review.yml b/.github/workflows/claude-code-review.yml index dfbe7113fd..0c5d27d8af 100644 --- a/.github/workflows/claude-code-review.yml +++ b/.github/workflows/claude-code-review.yml @@ -113,8 +113,11 @@ jobs: # Filter out tests/ directory — golden files don't need code review grep -v '^tests/' .claude-review/changed_files.txt.raw > .claude-review/changed_files.txt || true # Strip diff hunks for tests/ files - awk '/^diff --git a\/tests\//,/^diff --git a\//{if(/^diff --git a\// && !/^diff --git a\/tests\//)print; next}; {print}' \ - .claude-review/review.diff.raw > .claude-review/review.diff + awk ' + /^diff --git a\/tests\// { skip=1; next } + /^diff --git / { skip=0 } + !skip { print } + ' .claude-review/review.diff.raw > .claude-review/review.diff sed -i '/^[[:space:]]*$/d' .claude-review/changed_files.txt || true From 6c6aa33172dd39c9138351013440d89fd61dd42e Mon Sep 17 00:00:00 2001 From: Spencer Bryngelson Date: Sat, 4 Apr 2026 09:38:08 -0400 Subject: [PATCH 3/5] Tune Claude review: lower max-turns, inline review priorities, prioritize src/ context, raise file size cap --- .github/workflows/claude-code-review.yml | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/.github/workflows/claude-code-review.yml b/.github/workflows/claude-code-review.yml index 0c5d27d8af..8e8862f2bc 100644 --- a/.github/workflows/claude-code-review.yml +++ b/.github/workflows/claude-code-review.yml @@ -138,6 +138,10 @@ jobs: mkdir -p .claude-review/context + # Prioritize src/ files for context (most likely to need review) + sort -t/ -k1,1 -s < "${{ steps.review_input.outputs.changed_files_path }}" | \ + awk '/^src\//{print; next} {rest[NR]=$0} END{for(i in rest) print rest[i]}' > .claude-review/sorted_files.txt + while IFS= read -r path; do [[ -z "$path" ]] && continue COUNT=$((COUNT + 1)) @@ -154,10 +158,10 @@ jobs: [[ -z "$CONTENT" ]] && continue LINE_COUNT="$(printf '%s' "$CONTENT" | wc -l | tr -d ' ')" - if [[ "$LINE_COUNT" -le 400 ]]; then + if [[ "$LINE_COUNT" -le 1500 ]]; then printf '%s' "$CONTENT" > ".claude-review/context/$SAFE_NAME" fi - done < "${{ steps.review_input.outputs.changed_files_path }}" + done < .claude-review/sorted_files.txt echo "context_dir=.claude-review/context" >> "$GITHUB_OUTPUT" @@ -177,7 +181,7 @@ jobs: plugins: "code-review@claude-code-plugins" claude_args: > --dangerously-skip-permissions - --max-turns 90 + --max-turns 20 --allowedTools "Bash" prompt: | @@ -227,8 +231,14 @@ jobs: - Do NOT restate the full PR summary. - If there are no high-confidence findings, leave .claude-review/output.md empty and STOP. - Review standard: - - Prefer correctness, reliability, cleanup/finalization gaps, inconsistent behavior, edge cases, and meaningful test gaps. + Review standard (in priority order per CLAUDE.md "Code Review Priorities"): + 1. Correctness (logic bugs, numerical issues, array bounds) + 2. Precision discipline (stp vs wp mixing) + 3. Memory management (@:ALLOCATE/@:DEALLOCATE pairing, GPU pointer setup) + 4. MPI correctness (halo exchange, buffer sizing, GPU_UPDATE calls) + 5. GPU code (GPU_* Fypp macros only, no raw pragmas) + 6. Physics consistency (pressure formula matches model_eqns) + 7. Compiler portability (4 CI-gated compilers + AMD flang for GPU) - Avoid style nitpicks. - A finding is valid only if it is supported by changed lines, with changed-file context used only to confirm it. From a27a2ffbb3f7fe5401621f4371d5d2071f1d59dd Mon Sep 17 00:00:00 2001 From: Spencer Bryngelson Date: Sat, 4 Apr 2026 09:39:40 -0400 Subject: [PATCH 4/5] Allow Claude review to soft-fail without blocking CI --- .github/workflows/claude-code-review.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/claude-code-review.yml b/.github/workflows/claude-code-review.yml index 8e8862f2bc..2e74bb1410 100644 --- a/.github/workflows/claude-code-review.yml +++ b/.github/workflows/claude-code-review.yml @@ -173,6 +173,7 @@ jobs: : > .claude-review/output.md - name: Run Claude Code Review + continue-on-error: true uses: anthropics/claude-code-action@v1 with: claude_code_oauth_token: ${{ secrets.CLAUDE_CODE_OAUTH_TOKEN }} From 8cf4f111b3a11d3f003a5fb8bc9aa606dccb8025 Mon Sep 17 00:00:00 2001 From: Spencer Bryngelson Date: Sat, 4 Apr 2026 09:41:51 -0400 Subject: [PATCH 5/5] Increase max-turns to 40 --- .github/workflows/claude-code-review.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/claude-code-review.yml b/.github/workflows/claude-code-review.yml index 2e74bb1410..47a4824040 100644 --- a/.github/workflows/claude-code-review.yml +++ b/.github/workflows/claude-code-review.yml @@ -182,7 +182,7 @@ jobs: plugins: "code-review@claude-code-plugins" claude_args: > --dangerously-skip-permissions - --max-turns 20 + --max-turns 40 --allowedTools "Bash" prompt: |