Skip to content

Dev#13

Merged
FutureUnreal merged 4 commits intomainfrom
dev
Feb 7, 2026
Merged

Dev#13
FutureUnreal merged 4 commits intomainfrom
dev

Conversation

@FutureUnreal
Copy link
Member

@FutureUnreal FutureUnreal commented Feb 7, 2026

变更说明

关联 Issue / 需求

自测方式

  • 后端:cd backend && uv run uvicorn app.main:app --reload --port 8090
  • 前端:cd frontend && pnpm --filter @whalewhisper/web dev

风险 & 回滚

Checklist

  • 已保证改动聚焦(不混杂无关重构)
  • 已更新相关文档(如 README / 配置示例)
  • 未提交任何密钥/个人信息
  • CI(PR Checks)通过

📝 PR 说明(Codex 自动生成)

  • 变更概览:该 PR 主要更新 .github/ 下的 PR Review/CI 自动化:Claude PR Review 改为等待 Codex PR Review(最多 10 分钟)结果后再决定是否作为兜底运行,并新增 Claude CI Auto-Fix(CI 失败自动尝试安全修复/手动 main→dev 同步)与 Claude PR Review Responder(基于 review 反馈自动修改并回复)。同时升级 codex-pr-review 提示词与 CI/CD 配置文档,补充 size label、6 视角审查、置信度阈值/误报过滤与输出规范。
  • 影响范围:backend:无;frontend:无;docs:.github/CI_CD_SETUP.md.github/prompts/codex-pr-review.md;ci:.github/workflows/claude-pr-review.yml(fallback 逻辑)、新增 .github/workflows/claude-ci-autofix.yml / .github/workflows/claude-review-responder.yml
  • 如何验证
    1. 对照 .github/CI_CD_SETUP.md 配置 Secrets(至少 ANTHROPIC_API_KEYsync-dev 推送到受保护分支需 GH_PAT)。
    2. 在 GitHub Actions 中手动触发 Claude CI Auto-Fixworkflow_dispatch),分别以 task_type=ci-fixtask_type=sync-dev(source=main, target=dev;参数会被白名单校验)试跑。
    3. 在一个测试 PR 上观察:Codex review 成功时 Claude PR Review (Fallback) 是否跳过;提交 review(changes_requested 或 review body 含 @claude)后 Claude PR Review Responder 是否触发并写回提交/评论。
  • 风险点claude-ci-autofix.yml / claude-review-responder.yml 具有 contents: write 且允许执行 Bash(*)(自动提交/推送/创建 PR),需确认触发范围、分支保护与 secrets 权限符合预期;另外 claude-ci-autofix.yml 监听 workflow 名包含 "Tests",但当前测试工作流名为 "Test Suite",可能导致测试工作流失败时不触发 auto-fix。

FutureUnreal and others added 4 commits February 8, 2026 00:29
* chore: add comprehensive contributing guide

* Update CONTRIBUTING.md

Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com>

* Update CONTRIBUTING.md

Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com>

---------

Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com>
- Restore backend and frontend PR checks
- Enable Python syntax check and import test for backend
- Enable pnpm build check for frontend
- Fix 'Expected — Waiting for status to be reported' issue
- Upgrade codex-pr-review.md to 6-perspective review with confidence scoring
- Rewrite claude-pr-review.yml with Codex-first fallback pattern
- Add claude-ci-autofix.yml for auto-fixing CI failures + dev sync
- Add claude-review-responder.yml for auto-responding to PR reviews
- Update CI_CD_SETUP.md with new workflow documentation
@github-actions github-actions bot added area/ci Touches CI/CD (.github) needs-review Needs careful review (large/complex changes) size/XL PR size: >= 1000 lines changed labels Feb 7, 2026
@qodo-code-review
Copy link

Review Summary by Qodo

Enhance CI/CD with advanced PR review, auto-fix, and contributing guide

✨ Enhancement 📝 Documentation

Grey Divider

Walkthroughs

Description
• Upgrade PR review system with Codex-first fallback pattern
• Add comprehensive 6-perspective code review framework with confidence scoring
• Implement CI auto-fix workflow for safe mechanical error fixes
• Add PR review responder for automated feedback implementation
• Create detailed bilingual contributing guide (Chinese + English)
Diagram
flowchart LR
  PR["Pull Request"] -->|opened/sync| CheckCodex["Check Codex Status"]
  CheckCodex -->|success| Skip["Skip Claude"]
  CheckCodex -->|fail/timeout| Claude["Claude PR Review<br/>6-perspective analysis"]
  Claude -->|findings| InlineComments["Post Inline Comments"]
  InlineComments -->|summary| PRReview["PR Review Summary"]
  
  CIFail["CI Failure"] -->|triggered| AutoFix["Claude CI Auto-Fix"]
  AutoFix -->|safe fixes| Commit["Create Fix Commit"]
  Commit -->|PR| FixPR["Auto-fix PR"]
  
  ReviewSubmit["Review Submitted"] -->|changes_requested| Responder["Claude Review Responder"]
  Responder -->|implement| Changes["Apply Safe Changes"]
  Changes -->|commit| Response["Post Structured Response"]
  
  Docs["Documentation"] -->|bilingual| CONTRIBUTING["CONTRIBUTING.md"]
Loading

Grey Divider

File Changes

1. .github/CI_CD_SETUP.md 📝 Documentation +17/-2

Document new CI/CD workflows and fallback patterns

• Updated Claude PR Review section to describe Codex-first + Claude fallback pattern with 10-minute
 timeout
• Added documentation for new Claude CI Auto-Fix workflow (ci-fix and sync-dev modes)
• Added documentation for new Claude PR Review Responder workflow
• Enhanced security design notes for API key validation and read-only tool limits

.github/CI_CD_SETUP.md


2. .github/prompts/codex-pr-review.md ✨ Enhancement +372/-38

Implement comprehensive 6-perspective code review framework

• Completely rewrote prompt from simple review to comprehensive 6-perspective framework
• Added detailed execution workflow with 7 phases: data gathering, PR size calculation, file
 categorization, 6 review perspectives, confidence scoring, validation, and false positive filtering
• Defined 6 specialized review perspectives: Comment Analyzer, Test Analyzer, Silent Failure Hunter,
 Type Design Auditor, General Code Reviewer, Code Simplifier
• Implemented confidence scoring system with 80-point threshold and detailed validation rules
• Added severity levels (Critical/High/Medium/Low) and comprehensive output format specifications
• Included false positive filter to prevent over-reporting and validation checklist

.github/prompts/codex-pr-review.md


3. .github/workflows/claude-ci-autofix.yml ✨ Enhancement +461/-0

Add CI auto-fix and branch sync workflow

• New workflow triggered by PR Checks or Tests failures, with manual dispatch options
• Implements two task modes: ci-fix (auto-fix safe mechanical issues) and sync-dev (rebase main to
 dev with conflict resolution)
• Uses Claude Code action to analyze CI logs and apply targeted fixes (formatting, linting, unused
 imports)
• Includes comprehensive error categorization and safe-fix-only principles
• Implements verification phase before pushing and creates fix PRs with detailed documentation
• Supports branch synchronization with intelligent conflict resolution strategies

.github/workflows/claude-ci-autofix.yml


View more (4)
4. .github/workflows/claude-pr-review.yml ✨ Enhancement +191/-26

Implement Codex-first fallback PR review pattern

• Renamed to "Claude PR Review (Fallback)" to reflect new Codex-first pattern
• Added check-codex-status job that waits up to 10 minutes for Codex workflow completion
• Implements fallback logic: skip Claude if Codex succeeds, run Claude if Codex fails/times out
• Added external user detection to always run Claude for non-internal contributors
• Updated prompt to reference comprehensive 6-perspective review framework with confidence scoring
• Enhanced output format with PR size labels, issue categorization table, and structured summary
• Simplified workflow by removing redundant validation steps (moved to check job)

.github/workflows/claude-pr-review.yml


5. .github/workflows/claude-review-responder.yml ✨ Enhancement +234/-0

Add automated PR review responder workflow

• New workflow triggered when PR review is submitted with changes_requested state or @claude mention
• Implements 7-phase execution: context gathering, feedback classification, feasibility assessment,
 implementation, validation, commit/push, and structured response
• Classifies feedback into Must Fix / Should Fix / Consider / Question categories
• Includes comprehensive validation checks before making changes to ensure safety and intent
 preservation
• Provides structured response templates for different scenarios (ambiguous feedback, conflicting
 feedback, unsafe changes)
• Uses Claude Code action with Read/Write/Edit/Grep/Glob/Bash tools for safe implementation

.github/workflows/claude-review-responder.yml


6. .github/workflows/pr-check.yml ✨ Enhancement +3/-38

Simplify PR check workflow by removing conditionals

• Simplified backend job by removing conditional detection logic (always runs if PR not draft)
• Removed redundant if conditions on individual steps since backend detection is removed
• Simplified frontend job with same approach, added working-directory default for cleaner step
 definitions
• Removed frontend detection step and conditional logic, streamlined pnpm setup
• Maintained all core checks: Python syntax, import tests, TypeScript build verification

.github/workflows/pr-check.yml


7. CONTRIBUTING.md 📝 Documentation +659/-0

Add comprehensive bilingual contributing guide

• Created comprehensive bilingual contributing guide (Chinese + English with navigation)
• Chinese section covers: introduction, code of conduct, quick start, contribution workflow, branch
 naming, commit format, code style (Python/TypeScript/Vue), testing, PR process, and issue reporting
• English section provides complete translation of all Chinese content with identical structure
• Includes detailed setup instructions for backend (uv/venv) and frontend (pnpm)
• Specifies dev branch as target for all PRs, main branch as release-only
• Documents code style guidelines: PEP 8 for Python, 2-space indentation for TypeScript/Vue,
 async-first patterns
• Provides testing checklist, PR submission template, and issue reporting guidelines with examples
• Includes environment configuration instructions and development server startup commands

CONTRIBUTING.md


Grey Divider

Qodo Logo

@greptile-apps
Copy link
Contributor

greptile-apps bot commented Feb 7, 2026

Greptile Overview

Greptile Summary

This PR significantly upgrades the CI/CD automation infrastructure by introducing three new Claude-powered workflows and comprehensive documentation. The changes establish a sophisticated review and auto-fix system with Codex as primary reviewer and Claude as fallback, automatic CI failure remediation, and intelligent review response automation.

Key Changes

  • New Workflows: Added claude-ci-autofix.yml (461 lines), claude-review-responder.yml (234 lines), and enhanced claude-pr-review.yml with fallback logic
  • Enhanced PR Review: Codex-first strategy with Claude fallback after 10-minute timeout, includes 6-perspective review system (comment accuracy, test coverage, error handling, type safety, logic/security, code simplification)
  • CI Auto-Fix: Automatic detection and remediation of mechanical CI failures (formatting, linting, unused imports) with human-review safeguards for complex issues
  • Review Responder: Auto-responds to PR review feedback with classification (Must/Should/Consider/Question) and safe implementation of changes
  • Branch Sync: Automated main→dev synchronization with conflict resolution for post-release updates
  • Documentation: New comprehensive bilingual CONTRIBUTING.md (659 lines) with detailed workflow, style guides, and contribution process

Issues Identified

Logic Issues (3):

  1. claude-ci-autofix.yml:205 - Missing ref handling for workflow_dispatch trigger
  2. claude-ci-autofix.yml:216 - Missing null check for workflow_run.id in manual trigger path
  3. claude-ci-autofix.yml:62 - Branch validation occurs after checkout (security ordering issue)

Workflow Interaction Flow

The PR establishes a multi-layered automation system:

  1. PR opened → Codex reviews (priority) → Claude reviews (fallback if Codex fails/times out)
  2. CI fails → Auto-fix analyzes logs → Categorizes errors → Applies safe fixes → Creates fix PR
  3. Review submitted → Responder analyzes feedback → Classifies priority → Implements safe changes → Posts structured response
  4. Release → Manual sync trigger → Validates branches → Rebases dev onto main → Resolves conflicts → Verifies build

Security Posture

The workflows implement multiple security layers:

  • Branch validation (only main→dev allowed)
  • Bot filtering to prevent automation loops
  • Safe checkout (base.sha for reviews, not PR head)
  • Read-only tools for review workflows
  • Mechanical-only fixes with behavior-change safeguards

Confidence Score: 4/5

  • This PR is generally safe to merge with minor fixes needed for workflow robustness
  • Score reflects high-quality infrastructure improvements with solid security design, but deducted 1 point due to 3 logic issues in the auto-fix workflow that could cause runtime failures when manually triggered. The issues are straightforward to fix (missing conditionals for workflow_dispatch path). No security vulnerabilities or breaking changes identified. The extensive documentation and multi-layered safeguards demonstrate careful design.
  • .github/workflows/claude-ci-autofix.yml requires fixes for manual trigger handling (lines 205, 216) and branch validation ordering (line 62)

Important Files Changed

Filename Overview
.github/workflows/claude-ci-autofix.yml New workflow for auto-fixing CI failures and syncing branches. Includes branch validation and safe-fix categorization logic.
.github/workflows/claude-review-responder.yml New workflow that auto-responds to PR reviews. Triggers on review submission with proper bot filtering.
.github/workflows/claude-pr-review.yml Enhanced PR review workflow with Codex fallback logic. Added wait mechanism to avoid duplicate reviews.
.github/prompts/codex-pr-review.md Comprehensive rewrite of PR review prompt with 6 specialized review perspectives and strict confidence scoring system.
CONTRIBUTING.md New comprehensive bilingual contributing guide covering workflow, branch naming, commit format, code style, and testing requirements.

Sequence Diagram

sequenceDiagram
    participant Dev as Developer
    participant PR as Pull Request
    participant Codex as Codex PR Review
    participant Claude as Claude PR Review
    participant Checks as PR Checks
    participant AutoFix as CI Auto-Fix
    participant Responder as Review Responder

    Dev->>PR: Open/Update PR
    
    rect rgb(220, 240, 255)
        Note over PR,Claude: PR Review Phase
        PR->>Codex: Trigger review (pull_request_target)
        PR->>Claude: Trigger review (pull_request_target)
        
        Claude->>Claude: Check if bot or draft
        alt External User
            Claude->>Claude: Skip Codex check, run immediately
        else Internal User
            Claude->>Claude: Wait for Codex (max 10 min)
            Codex-->>Claude: Status update
            alt Codex succeeds
                Claude->>Claude: Skip (Codex handled it)
            else Codex fails/timeout
                Claude->>Claude: Run as fallback
            end
        end
        
        Claude->>PR: Post review comments
    end
    
    rect rgb(255, 240, 220)
        Note over Checks,AutoFix: CI & Auto-Fix Phase
        PR->>Checks: Run backend/frontend checks
        
        alt Checks fail
            Checks->>AutoFix: Trigger workflow_run
            AutoFix->>AutoFix: Analyze CI logs
            AutoFix->>AutoFix: Categorize errors
            AutoFix->>AutoFix: Apply safe fixes
            alt Has PR
                AutoFix->>PR: Create fix PR
            else No PR
                AutoFix->>PR: Push fixes directly
            end
        end
    end
    
    rect rgb(240, 255, 240)
        Note over Dev,Responder: Review Response Phase
        Dev->>PR: Submit review feedback
        
        alt Review requires changes OR mentions @claude
            PR->>Responder: Trigger review response
            Responder->>Responder: Analyze feedback
            Responder->>Responder: Classify (Must/Should/Consider/Question)
            Responder->>Responder: Implement safe changes
            Responder->>PR: Push fixes & post response
        end
    end
    
    rect rgb(255, 245, 220)
        Note over Dev,AutoFix: Manual Sync (Release)
        Dev->>AutoFix: Manual trigger (sync-dev)
        AutoFix->>AutoFix: Validate branches (only main→dev)
        AutoFix->>AutoFix: Rebase dev onto main
        AutoFix->>AutoFix: Resolve conflicts
        AutoFix->>AutoFix: Verify build
        AutoFix->>PR: Push with --force-with-lease
    end
Loading

Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

5 files reviewed, 3 comments

Edit Code Review Agent Settings | Greptile

- name: Checkout code
uses: actions/checkout@v5
with:
ref: ${{ github.event.workflow_run.head_branch }}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing ref when workflow_dispatch is used. When manually triggered, github.event.workflow_run.head_branch is undefined.

Suggested change
ref: ${{ github.event.workflow_run.head_branch }}
ref: ${{ github.event_name == 'workflow_dispatch' && github.ref || github.event.workflow_run.head_branch }}

const run = await github.rest.actions.getWorkflowRun({
owner: context.repo.owner,
repo: context.repo.repo,
run_id: ${{ github.event.workflow_run.id }}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing null check. github.event.workflow_run.id is undefined when workflow_dispatch is triggered.

Suggested change
run_id: ${{ github.event.workflow_run.id }}
run_id: ${{ github.event_name == 'workflow_run' && github.event.workflow_run.id || 0 }}

- name: Checkout code
uses: actions/checkout@v5
with:
ref: ${{ github.event.inputs.target_branch }}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Branch validation occurs after checkout, meaning the workflow checks out potentially arbitrary branches first. Move validation before checkout.

Suggested change
ref: ${{ github.event.inputs.target_branch }}
- name: Validate branch parameters
run: |
TARGET="${{ github.event.inputs.target_branch }}"
SOURCE="${{ github.event.inputs.source_branch }}"
if [[ "$TARGET" != "dev" ]]; then
echo "::error::Security: Only 'dev' branch is allowed as target. Got: $TARGET"
exit 1
fi
if [[ "$SOURCE" != "main" ]]; then
echo "::error::Security: Only 'main' branch is allowed as source. Got: $SOURCE"
exit 1
fi
echo "Branch validation passed: syncing $SOURCE -> $TARGET"
- name: Checkout code
uses: actions/checkout@v5

@qodo-code-review
Copy link

Code Review by Qodo

🐞 Bugs (4) 📘 Rule violations (2) 📎 Requirement gaps (0)

Grey Divider


Action required

1. CI logs sent to Claude 📘 Rule violation ⛨ Security
Description
• The workflow collects raw CI job logs and injects them into an external LLM prompt, which can
  unintentionally include sensitive values (tokens, secrets, PII) that appear in CI output.
• This violates secure logging/data-handling expectations because sensitive information must not be
  emitted or shared via logs, and external inputs must be handled in a way that prevents unintended
  disclosure.
• Impact: potential secret/PII exposure to a third-party service, plus increased blast radius if
  masking fails or sensitive values are not covered by GitHub’s masking.
Code

.github/workflows/claude-ci-autofix.yml[R219-289]

+            const jobs = await github.rest.actions.listJobsForWorkflowRun({
+              owner: context.repo.owner,
+              repo: context.repo.repo,
+              run_id: ${{ github.event.workflow_run.id }}
+            });
+
+            const failedJobs = jobs.data.jobs.filter(job => job.conclusion === 'failure');
+
+            let errorLogs = [];
+            for (const job of failedJobs) {
+              try {
+                const logs = await github.rest.actions.downloadJobLogsForWorkflowRun({
+                  owner: context.repo.owner,
+                  repo: context.repo.repo,
+                  job_id: job.id
+                });
+                const logLines = logs.data.split('\n');
+                const relevantLogs = logLines.slice(-3000).join('\n');
+                errorLogs.push({
+                  jobName: job.name,
+                  logs: relevantLogs
+                });
+              } catch (error) {
+                console.log(`Failed to get logs for job ${job.name}: ${error.message}`);
+              }
+            }
+
+            const pullRequests = ${{ toJSON(github.event.workflow_run.pull_requests) }};
+            const hasPR = pullRequests && pullRequests.length > 0;
+
+            return {
+              runUrl: run.data.html_url,
+              workflowName: run.data.name,
+              failedJobs: failedJobs.map(j => j.name),
+              errorLogs: errorLogs,
+              hasPR: hasPR,
+              prNumber: hasPR ? pullRequests[0].number : null,
+              headBranch: '${{ github.event.workflow_run.head_branch }}'
+            };
+
+      - name: Run Claude Code for Auto-Fix
+        uses: anthropics/claude-code-action@v1
+        env:
+          ANTHROPIC_BASE_URL: ${{ secrets.ANTHROPIC_BASE_URL }}
+        with:
+          anthropic_api_key: ${{ secrets.ANTHROPIC_API_KEY }}
+          github_token: ${{ secrets.GITHUB_TOKEN || secrets.GH_PAT }}
+
+          prompt: |
+            # Role: CI Failure Auto-Fix Assistant
+
+            You are a CI failure auto-fixer for repository ${{ github.repository }}. Your task is to analyze CI failures and apply safe, minimal fixes.
+
+            ---
+
+            ## Context
+
+            - **Workflow**: ${{ fromJSON(steps.failure_details.outputs.result).workflowName }}
+            - **Failed Run**: ${{ fromJSON(steps.failure_details.outputs.result).runUrl }}
+            - **Branch**: ${{ fromJSON(steps.failure_details.outputs.result).headBranch }}
+            - **Has PR**: ${{ fromJSON(steps.failure_details.outputs.result).hasPR }}
+            - **PR Number**: ${{ fromJSON(steps.failure_details.outputs.result).prNumber }}
+            - **Failed Jobs**: ${{ join(fromJSON(steps.failure_details.outputs.result).failedJobs, ', ') }}
+
+            ---
+
+            ## Error Logs
+
+            ```
+            ${{ toJSON(fromJSON(steps.failure_details.outputs.result).errorLogs) }}
+            ```
Evidence
PR Compliance ID 5 prohibits sensitive data in logs, and PR Compliance ID 6 requires secure handling
of external inputs/data. The added workflow explicitly downloads job logs, stores up to the last
3000 lines, and then embeds those logs into the Claude prompt payload, creating a direct path for
sensitive data to leave GitHub and be processed externally.

Rule 5: Generic: Secure Logging Practices
Rule 6: Generic: Security-First Input Validation and Data Handling
.github/workflows/claude-ci-autofix.yml[230-240]
.github/workflows/claude-ci-autofix.yml[285-289]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
The workflow downloads raw CI job logs and includes them in the Claude prompt. CI logs can contain secrets/PII or other sensitive data, which must not be exposed or shared externally.

## Issue Context
GitHub secret masking is not a complete guarantee (e.g., non-registered secrets, partial tokens, user-provided credentials, or PII). Passing logs verbatim to an external provider increases disclosure risk.

## Fix Focus Areas
- .github/workflows/claude-ci-autofix.yml[219-289]

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


2. Unvalidated head_branch checkout 📘 Rule violation ⛨ Security
Description
• The auto-fix job checks out ${{ github.event.workflow_run.head_branch }} with write permissions,
  but does not validate that the branch originates from the same repository (non-fork) or otherwise
  trusted context.
• This violates security-first input validation/authorization expectations: the branch name is
  external event data and should be treated as untrusted, especially when secrets and write tokens are
  available.
• Impact: a malicious or untrusted source branch could cause the workflow to operate on
  attacker-controlled code with elevated permissions, increasing risk of secret exfiltration or
  unwanted writes.
Code

.github/workflows/claude-ci-autofix.yml[R188-207]

+  auto-fix:
+    if: |
+      (github.event_name == 'workflow_run' &&
+       github.event.workflow_run.conclusion == 'failure' &&
+       !startsWith(github.event.workflow_run.head_branch, 'claude-fix-')) ||
+      (github.event_name == 'workflow_dispatch' && github.event.inputs.task_type == 'ci-fix')
+    runs-on: ubuntu-latest
+    permissions:
+      contents: write
+      pull-requests: write
+      actions: read
+      issues: write
+
+    steps:
+      - name: Checkout code
+        uses: actions/checkout@v5
+        with:
+          ref: ${{ github.event.workflow_run.head_branch }}
+          fetch-depth: 0
+
Evidence
PR Compliance ID 6 requires external inputs and authorization boundaries to be validated. The
workflow grants contents: write / pull-requests: write and then checks out a ref derived
directly from the workflow_run event (head_branch) without ensuring it is from a trusted repo
context.

Rule 6: Generic: Security-First Input Validation and Data Handling
.github/workflows/claude-ci-autofix.yml[195-207]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
The workflow uses `github.event.workflow_run.head_branch` to checkout code under write permissions without validating repository origin/trust. This can enable unsafe operations on untrusted code.

## Issue Context
`workflow_run` executes in the base repository context and may have access to secrets/permissions. Event payload values (like branch names and PR metadata) must be treated as untrusted unless validated.

## Fix Focus Areas
- .github/workflows/claude-ci-autofix.yml[188-207]

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


3. Auto-fix pushes to branch 🐞 Bug ⛨ Security
Description
claude-ci-autofix.yml 监听 workflow_run(PR Checks/Tests)失败后触发,且 auto-fix job 具备 `contents:
  write 并 checkout workflow_run.head_branch`,会在失败分支上运行可执行 Bash 的 agent。
• 对于非 PR 场景(hasPR=false,例如 Tests 在 pushmain/dev 失败),prompt 明确指示直接 `git push origin
  {headBranch},可能导致无人审查的自动提交直接落到 main/dev`,并可能在持续失败时形成反复触发/推送的循环。
Code

.github/workflows/claude-ci-autofix.yml[R435-446]

+            **For non-PR branch (hasPR = false):**
+            ```bash
+            git add .
+            git commit -m "fix: auto-fix CI failures
+
+            Fixed:
+            - [List each fix]
+
+            CI Run: ${{ fromJSON(steps.failure_details.outputs.result).runUrl }}"
+
+            git push origin ${{ fromJSON(steps.failure_details.outputs.result).headBranch }}
+            ```
Evidence
Tests 工作流在 push 到 main/dev 时运行;claude-ci-autofix 通过 workflow_run 订阅 Tests/PR Checks 的完成事件,只要结论为
failure 就触发 auto-fix。auto-fix 具备写权限并 checkout head_branch;在无 PR 的情况下,prompt 指示直接 push 回
headBranch,从流程上允许在 main/dev 失败时由 agent 直接向 main/dev 推送修复提交。

.github/workflows/test.yml[3-6]
.github/workflows/claude-ci-autofix.yml[3-7]
.github/workflows/claude-ci-autofix.yml[188-207]
.github/workflows/claude-ci-autofix.yml[435-446]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

### Issue description
`claude-ci-autofix.yml` 在 `workflow_run` 失败时运行,具备写权限并 checkout 失败的 `head_branch`。对无 PR 的失败(例如 push 到 main/dev 的 Tests 失败),prompt 指示直接 push 回该分支,带来“AI 直接写入主分支”的重大流程/安全风险。

### Issue Context
应避免在拥有 secrets/写权限的上下文中自动执行不受信任代码或自动推送到受保护分支。

### Fix Focus Areas
- .github/workflows/claude-ci-autofix.yml[1-7]
- .github/workflows/claude-ci-autofix.yml[188-207]
- .github/workflows/claude-ci-autofix.yml[435-446]

### Suggested direction
- 在 `auto-fix` job 增加约束:仅当 `github.event.workflow_run.event == &#x27;pull_request&#x27;` 且 `pull_requests` 非空时运行
- 对非 PR 失败:禁止直接 push;改为新建分支并创建 PR 指向 `dev`/`main`(由人 review/merge)
- 如需 checkout PR 分支,增加 gate:仅允许同仓库分支(避免 fork),并尽量移除 `Bash(*)`/包管理器执行
- 增加额外 loop 防护(例如检测最近 N 次是否为 auto-fix 提交,或为 push 场景直接跳过)

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


View more (1)
4. GH_PAT never used 🐞 Bug ✓ Correctness
Description
auto-fix job 的 github_token 使用 ${{ secrets.GITHUB_TOKEN || secrets.GH_PAT }},由于
  GITHUB_TOKEN 通常总是存在,导致即使配置了 GH_PAT 也不会被选中。
• 这会与文档中“sync-dev 需要 GH_PAT 推送到受保护分支”的预期相违背,且在需要更高权限时造成不可预期的权限失败。
Code

.github/workflows/claude-ci-autofix.yml[R259-266]

+      - name: Run Claude Code for Auto-Fix
+        uses: anthropics/claude-code-action@v1
+        env:
+          ANTHROPIC_BASE_URL: ${{ secrets.ANTHROPIC_BASE_URL }}
+        with:
+          anthropic_api_key: ${{ secrets.ANTHROPIC_API_KEY }}
+          github_token: ${{ secrets.GITHUB_TOKEN || secrets.GH_PAT }}
+
Evidence
workflow 明确声明 sync-dev 需要 GH_PAT,但 auto-fix 使用的 token 选择顺序把总是存在的 GITHUB_TOKEN 放在前面,导致 GH_PAT
永远不会被用到。

.github/workflows/claude-ci-autofix.yml[259-266]
.github/CI_CD_SETUP.md[89-96]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

### Issue description
`github_token: ${{ secrets.GITHUB_TOKEN || secrets.GH_PAT }}` 的短路逻辑会让 GH_PAT 永远不会生效。

### Issue Context
文档要求 GH_PAT 用于推送到受保护分支;即使不推送受保护分支,也应让“配置了 GH_PAT 就优先使用”成为一致行为。

### Fix Focus Areas
- .github/workflows/claude-ci-autofix.yml[259-266]

### Suggested direction
- 改为:`github_token: ${{ secrets.GH_PAT || secrets.GITHUB_TOKEN }}`
- 如特定模式强依赖 GH_PAT(例如 sync-dev),在缺失时 fail-fast 并输出清晰错误信息

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools



Remediation recommended

5. PR Checks skip removed 🐞 Bug ⛯ Reliability
Description
PR Checks 现在无条件执行后端/前端步骤(例如 pip install -e backend,以及所有命令默认在 frontend/
  目录运行),在目录不存在/临时移除时会直接失败。
• 这与仓库文档声明的“backend/ 或 frontend/ 不存在时应 skip 并通过”不一致;同时 Test Suite 仍保留 detect+skip,导致两套 CI 行为分裂。
Code

.github/workflows/pr-check.yml[R18-55]

      - name: Setup Python
-        if: steps.detect.outputs.exists == 'true'
        uses: actions/setup-python@v5
        with:
          python-version: "3.11"
          cache: "pip"
          cache-dependency-path: backend/pyproject.toml
      - name: Install backend (editable)
-        if: steps.detect.outputs.exists == 'true'
        run: |
          python -m pip install --upgrade pip
          pip install -e backend
      - name: Backend syntax check (compileall)
-        if: steps.detect.outputs.exists == 'true'
        run: python -m compileall -q backend/app
      - name: Backend import smoke test
-        if: steps.detect.outputs.exists == 'true'
        run: python -c "from app.main import app; print('backend app import: ok')"

  frontend:
    if: github.event.pull_request.draft == false
    runs-on: ubuntu-latest
+    defaults:
+      run:
+        working-directory: frontend
    steps:
      - uses: actions/checkout@v5
-
-      - name: Detect frontend
-        id: detect
-        run: |
-          if [ -f frontend/pnpm-lock.yaml ] || [ -f frontend/package.json ]; then
-            echo "exists=true" >> "$GITHUB_OUTPUT"
-          else
-            echo "exists=false" >> "$GITHUB_OUTPUT"
-          fi
-
-      - name: Skip frontend checks (no frontend/)
-        if: steps.detect.outputs.exists != 'true'
-        run: echo "No frontend/ found; skipping frontend checks."
-
      - name: Setup Node.js
-        if: steps.detect.outputs.exists == 'true'
        uses: actions/setup-node@v4
        with:
          node-version: "20"
          cache: "pnpm"
          cache-dependency-path: frontend/pnpm-lock.yaml
      - name: Setup pnpm
-        if: steps.detect.outputs.exists == 'true'
        uses: pnpm/action-setup@v4
        with:
          version: "9.12.2"
          run_install: false
      - name: Install dependencies
-        if: steps.detect.outputs.exists == 'true'
-        working-directory: frontend
        run: pnpm install --frozen-lockfile
      - name: Build web app
-        if: steps.detect.outputs.exists == 'true'
-        working-directory: frontend
        run: pnpm --filter @whalewhisper/web build
Evidence
文档明确声明 PR Checks 在缺少 backend/frontend 时应 skip 并通过,但当前 pr-check.yml 已删除 detect/skip 逻辑并无条件运行相关命令;同时
test.yml 仍保留 detect/skip,说明 repo 内部对该行为的预期并未统一。

.github/workflows/pr-check.yml[12-31]
.github/workflows/pr-check.yml[33-55]
.github/CI_CD_SETUP.md[17-26]
.github/workflows/test.yml[18-30]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

### Issue description
`PR Checks` 删除了 detect/skip,导致在 backend/ 或 frontend/ 不存在时会硬失败,与 CI_CD_SETUP.md 描述不一致,且与 test.yml 行为不一致。

### Issue Context
如果该仓库确实始终包含 backend/frontend,可更新文档;否则建议恢复 detect/skip 以提升工作流可复用性与鲁棒性。

### Fix Focus Areas
- .github/workflows/pr-check.yml[12-55]
- .github/CI_CD_SETUP.md[17-26]

### Suggested direction
- 方案 A:在 pr-check.yml 恢复 backend/frontend detect+skip(可直接复用 test.yml 的实现)
- 方案 B:若决定不再支持缺失目录的场景,更新 CI_CD_SETUP.md 对应说明,避免误导

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


6. Codex match too brittle 🐞 Bug ⛯ Reliability
Description
• Claude fallback 通过 created_at 与 PR updated_at 的 2 分钟窗口来匹配 Codex workflow run,PR 的 updated_at
  可能因评论/标签/基准分支同步等变化而漂移,导致匹配失败。
• 结果是:即使 Codex 已成功完成,也可能仍然等待到超时(10 分钟)后运行 Claude,增加 CI 时延与噪音评论风险。
Code

.github/workflows/claude-pr-review.yml[R45-60]

+            while (Date.now() - startTime < maxWait) {
+              const runs = await github.rest.actions.listWorkflowRuns({
+                owner: context.repo.owner,
+                repo: context.repo.repo,
+                workflow_id: 'codex-pr-review.yml',
+                event: 'pull_request_target',
+                per_page: 10
+              });
+
+              const prNumber = context.payload.pull_request.number;
+              const matchingRun = runs.data.workflow_runs.find(run => {
+                const runTime = new Date(run.created_at).getTime();
+                const prTime = new Date(context.payload.pull_request.updated_at).getTime();
+                return Math.abs(runTime - prTime) < 120000 && run.head_sha === context.payload.pull_request.head.sha;
+              });
+
Evidence
当前匹配逻辑依赖 PR updated_at 与 workflow run created_at 的时间差,这个信号不稳定;一旦匹配不到 matchingRun,循环只会 sleep
等待直到超时,随后强制运行 Claude。

.github/workflows/claude-pr-review.yml[41-59]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

### Issue description
Claude fallback 对 Codex run 的匹配依赖 `updated_at` 与 `created_at` 的时间窗口,容易误判,从而导致不必要的等待/兜底执行。

### Issue Context
目标是:如果存在相同 `head_sha` 的 Codex run 且已 success,则立即跳过 Claude;若失败则立即执行 Claude;若不存在则尽快执行 Claude(或短等待后执行)。

### Fix Focus Areas
- .github/workflows/claude-pr-review.yml[35-83]

### Suggested direction
- 仅使用 `run.head_sha === pull_request.head.sha` 作为主匹配条件(并可额外校验 `run.event`/`run.name`)
- 如需确认该 run 属于当前 PR,可对候选 run 调用 `getWorkflowRun` 并检查其关联信息(避免时间窗口)
- 找到同 sha 的 completed run 后立即决策,不要无条件等满 10 分钟

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


Grey Divider

ⓘ The new review experience is currently in Beta. Learn more

Grey Divider

Qodo Logo

Comment on lines +219 to +289
const jobs = await github.rest.actions.listJobsForWorkflowRun({
owner: context.repo.owner,
repo: context.repo.repo,
run_id: ${{ github.event.workflow_run.id }}
});

const failedJobs = jobs.data.jobs.filter(job => job.conclusion === 'failure');

let errorLogs = [];
for (const job of failedJobs) {
try {
const logs = await github.rest.actions.downloadJobLogsForWorkflowRun({
owner: context.repo.owner,
repo: context.repo.repo,
job_id: job.id
});
const logLines = logs.data.split('\n');
const relevantLogs = logLines.slice(-3000).join('\n');
errorLogs.push({
jobName: job.name,
logs: relevantLogs
});
} catch (error) {
console.log(`Failed to get logs for job ${job.name}: ${error.message}`);
}
}

const pullRequests = ${{ toJSON(github.event.workflow_run.pull_requests) }};
const hasPR = pullRequests && pullRequests.length > 0;

return {
runUrl: run.data.html_url,
workflowName: run.data.name,
failedJobs: failedJobs.map(j => j.name),
errorLogs: errorLogs,
hasPR: hasPR,
prNumber: hasPR ? pullRequests[0].number : null,
headBranch: '${{ github.event.workflow_run.head_branch }}'
};

- name: Run Claude Code for Auto-Fix
uses: anthropics/claude-code-action@v1
env:
ANTHROPIC_BASE_URL: ${{ secrets.ANTHROPIC_BASE_URL }}
with:
anthropic_api_key: ${{ secrets.ANTHROPIC_API_KEY }}
github_token: ${{ secrets.GITHUB_TOKEN || secrets.GH_PAT }}

prompt: |
# Role: CI Failure Auto-Fix Assistant

You are a CI failure auto-fixer for repository ${{ github.repository }}. Your task is to analyze CI failures and apply safe, minimal fixes.

---

## Context

- **Workflow**: ${{ fromJSON(steps.failure_details.outputs.result).workflowName }}
- **Failed Run**: ${{ fromJSON(steps.failure_details.outputs.result).runUrl }}
- **Branch**: ${{ fromJSON(steps.failure_details.outputs.result).headBranch }}
- **Has PR**: ${{ fromJSON(steps.failure_details.outputs.result).hasPR }}
- **PR Number**: ${{ fromJSON(steps.failure_details.outputs.result).prNumber }}
- **Failed Jobs**: ${{ join(fromJSON(steps.failure_details.outputs.result).failedJobs, ', ') }}

---

## Error Logs

```
${{ toJSON(fromJSON(steps.failure_details.outputs.result).errorLogs) }}
```

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Action required

1. Ci logs sent to claude 📘 Rule violation ⛨ Security

• The workflow collects raw CI job logs and injects them into an external LLM prompt, which can
  unintentionally include sensitive values (tokens, secrets, PII) that appear in CI output.
• This violates secure logging/data-handling expectations because sensitive information must not be
  emitted or shared via logs, and external inputs must be handled in a way that prevents unintended
  disclosure.
• Impact: potential secret/PII exposure to a third-party service, plus increased blast radius if
  masking fails or sensitive values are not covered by GitHub’s masking.
Agent Prompt
## Issue description
The workflow downloads raw CI job logs and includes them in the Claude prompt. CI logs can contain secrets/PII or other sensitive data, which must not be exposed or shared externally.

## Issue Context
GitHub secret masking is not a complete guarantee (e.g., non-registered secrets, partial tokens, user-provided credentials, or PII). Passing logs verbatim to an external provider increases disclosure risk.

## Fix Focus Areas
- .github/workflows/claude-ci-autofix.yml[219-289]

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools

Comment on lines +188 to +207
auto-fix:
if: |
(github.event_name == 'workflow_run' &&
github.event.workflow_run.conclusion == 'failure' &&
!startsWith(github.event.workflow_run.head_branch, 'claude-fix-')) ||
(github.event_name == 'workflow_dispatch' && github.event.inputs.task_type == 'ci-fix')
runs-on: ubuntu-latest
permissions:
contents: write
pull-requests: write
actions: read
issues: write

steps:
- name: Checkout code
uses: actions/checkout@v5
with:
ref: ${{ github.event.workflow_run.head_branch }}
fetch-depth: 0

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Action required

2. Unvalidated head_branch checkout 📘 Rule violation ⛨ Security

• The auto-fix job checks out ${{ github.event.workflow_run.head_branch }} with write permissions,
  but does not validate that the branch originates from the same repository (non-fork) or otherwise
  trusted context.
• This violates security-first input validation/authorization expectations: the branch name is
  external event data and should be treated as untrusted, especially when secrets and write tokens are
  available.
• Impact: a malicious or untrusted source branch could cause the workflow to operate on
  attacker-controlled code with elevated permissions, increasing risk of secret exfiltration or
  unwanted writes.
Agent Prompt
## Issue description
The workflow uses `github.event.workflow_run.head_branch` to checkout code under write permissions without validating repository origin/trust. This can enable unsafe operations on untrusted code.

## Issue Context
`workflow_run` executes in the base repository context and may have access to secrets/permissions. Event payload values (like branch names and PR metadata) must be treated as untrusted unless validated.

## Fix Focus Areas
- .github/workflows/claude-ci-autofix.yml[188-207]

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools

Comment on lines +435 to +446
**For non-PR branch (hasPR = false):**
```bash
git add .
git commit -m "fix: auto-fix CI failures

Fixed:
- [List each fix]

CI Run: ${{ fromJSON(steps.failure_details.outputs.result).runUrl }}"

git push origin ${{ fromJSON(steps.failure_details.outputs.result).headBranch }}
```

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Action required

3. Auto-fix pushes to branch 🐞 Bug ⛨ Security

claude-ci-autofix.yml 监听 workflow_run(PR Checks/Tests)失败后触发,且 auto-fix job 具备 `contents:
  write 并 checkout workflow_run.head_branch`,会在失败分支上运行可执行 Bash 的 agent。
• 对于非 PR 场景(hasPR=false,例如 Tests 在 pushmain/dev 失败),prompt 明确指示直接 `git push origin
  {headBranch},可能导致无人审查的自动提交直接落到 main/dev`,并可能在持续失败时形成反复触发/推送的循环。
Agent Prompt
### Issue description
`claude-ci-autofix.yml` 在 `workflow_run` 失败时运行,具备写权限并 checkout 失败的 `head_branch`。对无 PR 的失败(例如 push 到 main/dev 的 Tests 失败),prompt 指示直接 push 回该分支,带来“AI 直接写入主分支”的重大流程/安全风险。

### Issue Context
应避免在拥有 secrets/写权限的上下文中自动执行不受信任代码或自动推送到受保护分支。

### Fix Focus Areas
- .github/workflows/claude-ci-autofix.yml[1-7]
- .github/workflows/claude-ci-autofix.yml[188-207]
- .github/workflows/claude-ci-autofix.yml[435-446]

### Suggested direction
- 在 `auto-fix` job 增加约束:仅当 `github.event.workflow_run.event == 'pull_request'` 且 `pull_requests` 非空时运行
- 对非 PR 失败:禁止直接 push;改为新建分支并创建 PR 指向 `dev`/`main`(由人 review/merge)
- 如需 checkout PR 分支,增加 gate:仅允许同仓库分支(避免 fork),并尽量移除 `Bash(*)`/包管理器执行
- 增加额外 loop 防护(例如检测最近 N 次是否为 auto-fix 提交,或为 push 场景直接跳过)

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools

Comment on lines +259 to +266
- name: Run Claude Code for Auto-Fix
uses: anthropics/claude-code-action@v1
env:
ANTHROPIC_BASE_URL: ${{ secrets.ANTHROPIC_BASE_URL }}
with:
anthropic_api_key: ${{ secrets.ANTHROPIC_API_KEY }}
github_token: ${{ secrets.GITHUB_TOKEN || secrets.GH_PAT }}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Action required

4. Gh_pat never used 🐞 Bug ✓ Correctness

auto-fix job 的 github_token 使用 ${{ secrets.GITHUB_TOKEN || secrets.GH_PAT }},由于
  GITHUB_TOKEN 通常总是存在,导致即使配置了 GH_PAT 也不会被选中。
• 这会与文档中“sync-dev 需要 GH_PAT 推送到受保护分支”的预期相违背,且在需要更高权限时造成不可预期的权限失败。
Agent Prompt
### Issue description
`github_token: ${{ secrets.GITHUB_TOKEN || secrets.GH_PAT }}` 的短路逻辑会让 GH_PAT 永远不会生效。

### Issue Context
文档要求 GH_PAT 用于推送到受保护分支;即使不推送受保护分支,也应让“配置了 GH_PAT 就优先使用”成为一致行为。

### Fix Focus Areas
- .github/workflows/claude-ci-autofix.yml[259-266]

### Suggested direction
- 改为:`github_token: ${{ secrets.GH_PAT || secrets.GITHUB_TOKEN }}`
- 如特定模式强依赖 GH_PAT(例如 sync-dev),在缺失时 fail-fast 并输出清晰错误信息

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools

@github-actions
Copy link

github-actions bot commented Feb 7, 2026

🤖 Codex PR Review

PR Summary

  • 7 files changed; +1,937 / -104 lines (≈2,041 total).
  • Adds CONTRIBUTING.md and two new Claude automation workflows (CI auto-fix + review responder).
  • Updates Claude PR Review to be a Codex-first, Claude-fallback workflow; simplifies PR Checks job setup.

Key Risks

  • New workflows run AI agents with contents: write and shell access; without strict gating they can create unintended pushes/PRs or amplify prompt-injection impact.
  • workflow_run-triggered auto-fix currently targets head_branch; for fork PRs this can map to an unrelated branch name in the base repo (wrong checkout / wrong PR base).

Findings

  • [Critical] [SECURITY] .github/workflows/claude-ci-autofix.yml:188 — Auto-fix runs on workflow_run failures with contents: write and checks out head_branch

    • Evidence:
      on:
        workflow_run:
          workflows: ["PR Checks", "Tests"]
      ...
      auto-fix:
        permissions:
          contents: write
          pull-requests: write
      ...
        with:
          ref: ${{ github.event.workflow_run.head_branch }}
    • Why it matters: workflow_run can be triggered by PR CI runs; using head_branch is unsafe for fork PRs (branch names can collide, e.g. main) and combining that with a write-scoped token + an agent capable of Bash(*) raises the blast radius (wrong target branch, unintended pushes/PRs, secret/token exfiltration if the agent is ever induced to print env/headers).
    • Suggested fix: hard-gate to same-repo PR runs and avoid non-PR runs; also consistently prefer GH_PAT when present.
      auto-fix:
        if: |
          (github.event_name == 'workflow_run' &&
           github.event.workflow_run.conclusion == 'failure' &&
           github.event.workflow_run.event == 'pull_request' &&
           github.event.workflow_run.head_repository.full_name == github.repository &&
           !startsWith(github.event.workflow_run.head_branch, 'claude-fix-')) ||
          (github.event_name == 'workflow_dispatch' && github.event.inputs.task_type == 'ci-fix')
      
        steps:
          - uses: actions/checkout@v5
            with:
              ref: ${{ github.event.workflow_run.head_branch }}
              fetch-depth: 0
          # and in the Claude step:
          # github_token: ${{ secrets.GH_PAT || secrets.GITHUB_TOKEN }}
  • [High] [SECURITY] .github/workflows/claude-review-responder.yml:9 — Review responder auto-commits on any changes_requested review, with contents: write, on PR head code

    • Evidence:
      if: |
        ... &&
        (github.event.review.state == 'changes_requested' ||
         contains(github.event.review.body, '@claude'))
      ...
      permissions:
        contents: write
      ...
      ref: ${{ github.event.pull_request.head.sha }}
    • Why it matters: this creates a “review → bot edits → push” path without explicit opt-in (a routine “changes requested” review triggers it). If it runs on a same-repo branch, it can mutate contributor branches automatically; if it runs on fork PRs it will fail (secrets unavailable / no push perms) and add noise.
    • Suggested fix: require explicit @claude mention + restrict to same-repo PRs, and checkout the branch ref (not detached SHA) so the scripted git checkout <branch> path is consistent.
      if: |
        !endsWith(github.event.review.user.login, '[bot]') &&
        contains(github.event.review.body, '@claude') &&
        github.event.pull_request.head.repo.full_name == github.repository
      
      steps:
        - uses: actions/checkout@v5
          with:
            fetch-depth: 0
            ref: ${{ github.event.pull_request.head.ref }}
      
        # also fix token precedence:
        # github_token: ${{ secrets.GH_PAT || secrets.GITHUB_TOKEN }}
  • [Medium] [ERROR] .github/workflows/claude-ci-autofix.yml:230 — CI log “parsing” likely fails because job log downloads are not plain text

    • Evidence:
      const logs = await github.rest.actions.downloadJobLogsForWorkflowRun({
        ...
        job_id: job.id
      });
      const logLines = logs.data.split('\n');
    • Why it matters: downloadJobLogs* endpoints typically return an archive/binary response; treating it as a string can throw (split is not a function) and silently remove the error context from the prompt, making “auto-fix” ineffective or erratic.
    • Suggested fix: fetch readable logs via gh (or skip logs entirely and let the agent pull them).
      - name: Fetch failed logs (text)
        id: failed_logs
        env:
          GH_TOKEN: ${{ secrets.GH_PAT || github.token }}
        run: |
          gh run view ${{ github.event.workflow_run.id }} --log-failed > failed.log
          echo "log_path=failed.log" >> "$GITHUB_OUTPUT"
  • [Medium] [LOGIC] .github/workflows/claude-pr-review.yml:55 — Codex-run matching uses a timestamp heuristic that can miss the correct run and cause duplicate reviews

    • Evidence:
      return Math.abs(runTime - prTime) < 120000 &&
        run.head_sha === context.payload.pull_request.head.sha;
    • Why it matters: pull_request.updated_at changes for many non-code events (labels/comments), so the ±2 minute window is brittle; missing the run means Claude posts a fallback review even when Codex succeeded.
    • Suggested fix: match by head_sha + PR number association (available on workflow run objects) and pick the newest match.
      const prNumber = context.payload.pull_request.number;
      const matchingRun = runs.data.workflow_runs.find(run =>
        run.head_sha === context.payload.pull_request.head.sha &&
        run.pull_requests?.some(pr => pr.number === prNumber)
      );
  • [Low] [DX] .github/workflows/claude-ci-autofix.yml:5 — Auto-fix listens for a workflow named "Tests", but the repo workflow is "Test Suite"

    • Evidence:
      workflows: ["PR Checks", "Tests"]
    • Why it matters: the auto-fix won’t trigger for the push workflow in .github/workflows/test.yml unless the names match, making the feature appear broken.
    • Suggested fix: change "Tests""Test Suite" (or rename the test.yml workflow to "Tests" for consistency).

@FutureUnreal FutureUnreal merged commit a1df5af into main Feb 7, 2026
14 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/ci Touches CI/CD (.github) needs-review Needs careful review (large/complex changes) size/XL PR size: >= 1000 lines changed

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant