Skip to content

Dev#18

Merged
FutureUnreal merged 16 commits intomainfrom
dev
Feb 8, 2026
Merged

Dev#18
FutureUnreal merged 16 commits intomainfrom
dev

Conversation

@FutureUnreal
Copy link
Member

@FutureUnreal FutureUnreal commented Feb 8, 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 自动生成)

  • 变更概览:本次主要调整 .github/workflows 下的自动化工作流(Claude/Codex 相关),将关键 checkout 从分支名改为 head.sha 并补充分支移动校验/失败日志拉取的错误处理,减少分支漂移带来的非确定性。Issue 自动化在缺少 ANTHROPIC_API_KEY/OPENAI_API_KEY 时改为显式 Skip;同时更新 PR Checks/Test Suite 中 pnpm 与 Node 相关步骤顺序,并在 README.md 增加 CONTRIBUTING.md 引导、.gitignore 忽略 .claude/
  • 影响范围:ci、docs(backend / frontend 无业务代码变更)
  • 如何验证:在该 PR 上查看 GitHub Actions,确认 PR ChecksTest Suite 正常运行;前端 job 中 Setup pnpm 位于 Setup Node.js 之前。新建 Issue 时,Claude Issue Duplicate Check / Codex Issue Triage 在未配置对应 API Key 时应出现 Skip 提示并结束(配置后应继续执行后续步骤);(可选)提交包含 @claude 的 PR Review,确认 Claude PR Review Responder 先通过 “Verify PR branch matches reviewed SHA” 再继续。
  • 风险点claude-review-responder 新增“分支已移动则失败”的保护,可能导致 review 触发的自动响应更容易被中断;claude-ci-autofix 在无法拉取失败日志时会直接报错退出。README.md 末尾新增的“这是一个测试行”可能为误提交,建议确认是否需要删除。

FutureUnreal and others added 16 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
- [Critical] auto-fix: restrict to same-repo PRs only (fork protection)
- [High] review-responder: require explicit @claude mention, restrict to same-repo
- [Medium] auto-fix: use `gh run view --log-failed` instead of broken API call
- [Medium] pr-review: fix Codex matching to use head_sha + pull_requests
- [Low] auto-fix: correct workflow name "Tests" → "Test Suite"
Rename "Claude PR Review (Fallback)" back to "Claude PR Review"
so the check name matches what branch protection expects.
Direct contributors to read the contributing guide before starting.
@FutureUnreal FutureUnreal merged commit 0838259 into main Feb 8, 2026
20 checks passed
@github-actions github-actions bot added area/ci Touches CI/CD (.github) area/docs Touches docs/README size/S PR size: < 200 lines changed labels Feb 8, 2026
@qodo-code-review
Copy link

Review Summary by Qodo

✨ Enhancement 🐞 Bug fix

Grey Divider

Walkthroughs

Description
• Improve CI workflow robustness with SHA pinning and validation
• Add graceful handling for missing API keys in issue workflows
• Fix pnpm setup step ordering in Node.js workflows
• Update README with contribution guidelines reference
Diagram
flowchart LR
  A["CI Workflows"] -->|"Add SHA pinning"| B["claude-ci-autofix.yml"]
  A -->|"Add SHA pinning"| C["claude-review-responder.yml"]
  A -->|"Improve matching logic"| D["claude-pr-review.yml"]
  E["Issue Workflows"] -->|"Graceful API key handling"| F["claude-issue-duplicate-check.yml"]
  E -->|"Graceful API key handling"| G["codex-issue-triage.yml"]
  H["Node.js Workflows"] -->|"Fix setup order"| I["pr-check.yml & test.yml"]
  J["Documentation"] -->|"Add contribution guide link"| K["README.md"]
Loading

Grey Divider

File Changes

1. .github/workflows/claude-ci-autofix.yml 🐞 Bug fix +47/-3

Add SHA pinning and robust log fetching

• Replace head_branch with head_sha for precise checkout pinning
• Add comprehensive error handling and validation for failed log fetching
• Include run URL and detailed error messages in logs and step summary
• Pass headSha to Claude context for accurate failure analysis

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


2. .github/workflows/claude-issue-duplicate-check.yml ✨ Enhancement +9/-2

Graceful handling for missing API key

• Remove API key check from job condition, add explicit skip step instead
• Add conditional if guards to all steps requiring ANTHROPIC_API_KEY
• Provide clear skip message when API key is not configured

.github/workflows/claude-issue-duplicate-check.yml


3. .github/workflows/claude-pr-review.yml 🐞 Bug fix +9/-4

Enhance workflow run matching logic

• Improve workflow run matching logic with explicit SHA and branch validation
• Add fallback handling for missing pull_requests array
• Ensure more reliable Codex workflow detection before skipping Claude review

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


View more (5)
4. .github/workflows/claude-review-responder.yml 🐞 Bug fix +22/-4

Add SHA pinning and branch drift detection

• Change checkout to use head_sha instead of head_ref for precise pinning
• Add verification step to ensure PR branch hasn't advanced since review
• Update git commands to work with pinned SHA instead of branch name
• Add SHA context to Claude prompt for accurate review response

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


5. .github/workflows/codex-issue-triage.yml ✨ Enhancement +9/-3

Graceful handling for missing API key

• Remove API key check from job condition, add explicit skip step instead
• Add conditional if guards to all steps requiring OPENAI_API_KEY
• Update final step condition to check both API key and output availability

.github/workflows/codex-issue-triage.yml


6. .github/workflows/pr-check.yml 🐞 Bug fix +7/-6

Fix pnpm setup ordering in frontend checks

• Reorder pnpm setup to occur before Node.js setup for proper initialization
• Convert single-line Python command to multi-line format for clarity

.github/workflows/pr-check.yml


7. .github/workflows/test.yml 🐞 Bug fix +8/-7

Fix pnpm setup ordering in frontend checks

• Reorder pnpm setup to occur before Node.js setup for proper initialization
• Convert single-line Python command to multi-line format for clarity

.github/workflows/test.yml


8. README.md 📝 Documentation +4/-0

Add contribution guidelines reference

• Add reference to CONTRIBUTING.md with link in contribution section
• Add test line at end of file

README.md


Grey Divider

Qodo Logo

@greptile-apps
Copy link
Contributor

greptile-apps bot commented Feb 8, 2026

Greptile Overview

Greptile Summary

This PR enhances GitHub Actions workflow security and reliability across multiple Claude and CI workflows.

Key improvements:

  • Security hardening: Pins checkouts to specific SHAs instead of branch refs in claude-ci-autofix.yml and claude-review-responder.yml to prevent race conditions and TOCTOU vulnerabilities
  • Better error handling: Improved log fetching in claude-ci-autofix.yml with validation, temporary file handling, and informative error messages
  • Race condition protection: Added verification step in claude-review-responder.yml to detect if PR branch moved since review submission
  • Graceful degradation: Moved API key checks from job-level conditions to step-level conditions in claude-issue-duplicate-check.yml and codex-issue-triage.yml, improving workflow visibility when API keys are missing
  • Build fixes: Corrected pnpm setup order in pr-check.yml and test.yml to run before Node.js setup for proper dependency caching
  • PR matching logic: Enhanced workflow run matching in claude-pr-review.yml with better branch and SHA validation

Issues found:

  • README.md contains a test line ("这是一个测试行") on line 213 that should be removed before merging

Confidence Score: 4/5

  • Safe to merge after removing the test line in README.md
  • Score of 4 reflects high-quality workflow improvements with excellent security hardening and error handling. The only issue is a leftover test line in README.md that needs removal. All workflow changes follow best practices and improve reliability.
  • Pay attention to README.md:213 - contains test content that must be removed

Important Files Changed

Filename Overview
.github/workflows/claude-ci-autofix.yml Security hardening: pins checkout to SHA, improves error handling in log fetching with better validation and fallback
.github/workflows/claude-review-responder.yml Security improvement: pins checkout to SHA and adds verification step to detect if branch moved since review
.github/workflows/claude-pr-review.yml Improved PR workflow run matching logic with branch validation to handle edge cases better
.github/workflows/pr-check.yml Fixed pnpm setup order - now runs before Node.js setup for proper cache handling
.github/workflows/test.yml Fixed pnpm setup order to run before Node.js setup for proper cache handling
README.md Added reference to CONTRIBUTING.md; contains test line that should be removed

Sequence Diagram

sequenceDiagram
    participant PR as Pull Request
    participant GHA as GitHub Actions
    participant Claude as Claude Workflows
    participant Check as CI/CD Checks
    
    Note over PR,Check: Workflow Security Hardening
    
    PR->>GHA: Push/Review Event
    GHA->>Claude: Trigger Claude Workflow
    
    alt claude-ci-autofix.yml
        Claude->>GHA: Checkout at head_sha (pinned)
        GHA->>GHA: Fetch failed logs with validation
        alt Log fetch succeeds
            GHA->>Claude: Provide logs for analysis
            Claude->>PR: Create fix PR/commit
        else Log fetch fails
            GHA->>GHA: Write error to failed.log
            GHA->>GHA: Exit with error message
        end
    end
    
    alt claude-review-responder.yml
        Claude->>GHA: Checkout at PR head SHA (pinned)
        GHA->>GHA: Verify branch hasn't moved
        alt Branch matches SHA
            GHA->>Claude: Process review feedback
            Claude->>PR: Push changes to PR branch
        else Branch moved
            GHA->>GHA: Exit with error
        end
    end
    
    alt claude-pr-review.yml
        GHA->>GHA: Find matching workflow run
        GHA->>GHA: Validate SHA and branch
        alt Run matches PR
            GHA->>Claude: Trigger review
            Claude->>PR: Submit review
        else No match
            GHA->>GHA: Skip review
        end
    end
    
    alt API Key Checks (duplicate-check/triage)
        GHA->>GHA: Check if API key exists
        alt API key present
            GHA->>Claude: Run workflow
            Claude->>PR: Process issue
        else API key missing
            GHA->>GHA: Skip gracefully
        end
    end
    
    alt pr-check.yml & test.yml
        Check->>GHA: Setup pnpm first
        GHA->>GHA: Setup Node.js with cache
        GHA->>Check: Run build/tests
    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.

6 files reviewed, 1 comment

Edit Code Review Agent Settings | Greptile


本项目采用 [Apache License 2.0](LICENSE) 进行许可。

这是一个测试行
Copy link
Contributor

Choose a reason for hiding this comment

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

Test line should be removed before merging

Suggested change
这是一个测试行

@qodo-code-review
Copy link

Code Review by Qodo

🐞 Bugs (3) 📘 Rule violations (0) 📎 Requirement gaps (0)

Grey Divider


Action required

1. Dispatch ci-fix always fails 🐞 Bug ✓ Correctness
Description
• The workflow advertises workflow_dispatch with task_type defaulting to ci-fix, and the
  auto-fix job is allowed to run for that path.
• The updated steps hard-require github.event.workflow_run.* fields (not present on
  workflow_dispatch) and now explicitly exit 1 when workflow_run.id is missing.
• Result: any manual run with task_type=ci-fix fails deterministically (and checkout ref is also
  undefined), making the dispatch option effectively broken.
Code

.github/workflows/claude-ci-autofix.yml[R207-224]

+          ref: ${{ github.event.workflow_run.head_sha }}
          fetch-depth: 0

      - name: Fetch failed logs
        id: failed_logs
        env:
          GH_TOKEN: ${{ secrets.GH_PAT || github.token }}
+          GH_REPO: ${{ github.repository }}
        run: |
-          gh run view ${{ github.event.workflow_run.id }} --log-failed > failed.log 2>/dev/null || echo "Failed to fetch logs" > failed.log
+          set -euo pipefail
+
+          run_id="${{ github.event.workflow_run.id }}"
+          run_url="${{ github.event.workflow_run.html_url }}"
+
+          if [ -z "$run_id" ]; then
+            echo "::error::Missing workflow_run.id; this job only supports workflow_run triggers."
+            exit 1
+          fi
Evidence
The workflow defines a manual dispatch mode with task_type default ci-fix, and the auto-fix
job condition includes that dispatch path. However, the modified checkout and log-fetch steps read
github.event.workflow_run.* unconditionally and the new guard exits when workflow_run.id is
empty—guaranteeing failure for workflow_dispatch runs.

.github/workflows/claude-ci-autofix.yml[8-17]
.github/workflows/claude-ci-autofix.yml[188-208]
.github/workflows/claude-ci-autofix.yml[215-224]

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

## Issue description
`auto-fix` is runnable via `workflow_dispatch` with `task_type=ci-fix`, but it unconditionally relies on `github.event.workflow_run.*` and now exits if `workflow_run.id` is missing. Manual dispatch runs therefore fail deterministically.

## Issue Context
This workflow supports both `workflow_run` and `workflow_dispatch`. The `sync-dev` job correctly handles dispatch inputs, but `auto-fix` does not.

## Fix Focus Areas
- .github/workflows/claude-ci-autofix.yml[8-32]
- .github/workflows/claude-ci-autofix.yml[188-208]
- .github/workflows/claude-ci-autofix.yml[215-224]

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



Remediation recommended

2. Codex run match permissive 🐞 Bug ⛯ Reliability
Description
• The updated matching logic treats a workflow run as a match when pull_requests is missing/empty,
  based solely on head_sha (and head_branch only if that field is present).
• If run.head_branch is absent in the API response, the branch guard is skipped and the code may
  select an unrelated run with the same SHA, causing Claude fallback to be skipped or triggered
  incorrectly.
• This adds non-determinism to the fallback decision in the PR review workflow.
Code

.github/workflows/claude-pr-review.yml[R55-63]

+              const prSha = context.payload.pull_request.head.sha;
+              const prBranch = context.payload.pull_request.head.ref;
+
+              const matchingRun = runs.data.workflow_runs.find(run => {
+                if (run.head_sha !== prSha) return false;
+                if (run.head_branch && run.head_branch !== prBranch) return false;
+                if (!Array.isArray(run.pull_requests) || run.pull_requests.length === 0) return true;
+                return run.pull_requests.some(pr => pr.number === prNumber);
+              });
Evidence
The matcher explicitly returns true when pull_requests is absent/empty, and the branch check is
conditional on run.head_branch being present. That means the PR-number association is not enforced
in a known edge case (missing PR metadata), and branch filtering can be skipped if the API omits
that field.

.github/workflows/claude-pr-review.yml[54-63]

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-run matcher returns a match when `run.pull_requests` is missing/empty, which can mis-associate runs and affect whether Claude runs.

## Issue Context
This is in the fallback workflow that decides whether to run Claude depending on a Codex workflow’s status.

## Fix Focus Areas
- .github/workflows/claude-pr-review.yml[45-66]

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


3. Stray README test line 🐞 Bug ✓ Correctness
Description
• README.md includes an apparent placeholder/test line (“这是一个测试行”) at the end of the document.
• This looks unintentional and will ship in user-facing docs.
Code

README.md[R213-214]

+这是一个测试行
+
Evidence
The README ends with the added test line immediately after the license section, with no surrounding
context indicating it is intentional documentation.

README.md[209-214]

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

## Issue description
README contains an apparent placeholder/test line.

## Issue Context
It appears at the end of the README after the license section.

## Fix Focus Areas
- README.md[209-214]

ⓘ 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 +207 to +224
ref: ${{ github.event.workflow_run.head_sha }}
fetch-depth: 0

- name: Fetch failed logs
id: failed_logs
env:
GH_TOKEN: ${{ secrets.GH_PAT || github.token }}
GH_REPO: ${{ github.repository }}
run: |
gh run view ${{ github.event.workflow_run.id }} --log-failed > failed.log 2>/dev/null || echo "Failed to fetch logs" > failed.log
set -euo pipefail

run_id="${{ github.event.workflow_run.id }}"
run_url="${{ github.event.workflow_run.html_url }}"

if [ -z "$run_id" ]; then
echo "::error::Missing workflow_run.id; this job only supports workflow_run triggers."
exit 1
fi

Choose a reason for hiding this comment

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

Action required

1. Dispatch ci-fix always fails 🐞 Bug ✓ Correctness

• The workflow advertises workflow_dispatch with task_type defaulting to ci-fix, and the
  auto-fix job is allowed to run for that path.
• The updated steps hard-require github.event.workflow_run.* fields (not present on
  workflow_dispatch) and now explicitly exit 1 when workflow_run.id is missing.
• Result: any manual run with task_type=ci-fix fails deterministically (and checkout ref is also
  undefined), making the dispatch option effectively broken.
Agent Prompt
## Issue description
`auto-fix` is runnable via `workflow_dispatch` with `task_type=ci-fix`, but it unconditionally relies on `github.event.workflow_run.*` and now exits if `workflow_run.id` is missing. Manual dispatch runs therefore fail deterministically.

## Issue Context
This workflow supports both `workflow_run` and `workflow_dispatch`. The `sync-dev` job correctly handles dispatch inputs, but `auto-fix` does not.

## Fix Focus Areas
- .github/workflows/claude-ci-autofix.yml[8-32]
- .github/workflows/claude-ci-autofix.yml[188-208]
- .github/workflows/claude-ci-autofix.yml[215-224]

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


本项目采用 [Apache License 2.0](LICENSE) 进行许可。

这是一个测试行
Copy link

Choose a reason for hiding this comment

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

[LOGIC-BUG] Test line should be removed

This appears to be an accidental commit of a test line that should not be in the README.

Suggestion:

本项目采用 [Apache License 2.0](LICENSE) 进行许可。

Remove the line "这是一个测试行".

Copy link

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

Code Review Summary

This PR improves GitHub Actions workflow reliability by pinning checkouts to specific SHAs instead of branch names, adds proper error handling for log fetching failures, and implements graceful skipping when API keys are missing. The changes are well-structured and address real race conditions in CI/CD pipelines.

PR Size: S

Lines Changed: 116 additions, 29 deletions
Files Changed: 9

Issues Found

Category Critical High Medium Low
Logic Bug 0 0 0 1
Error Handling 0 0 0 0
Security 0 0 0 0
Code Quality 0 0 0 0

Key Improvements in This PR

  1. SHA Pinning (.github/workflows/claude-ci-autofix.yml:207, claude-review-responder.yml:26): Changed from ref: ${{ github.event.workflow_run.head_branch }} to ref: ${{ github.event.workflow_run.head_sha }} - prevents race conditions when branches move during workflow execution.

  2. Branch Verification (.github/workflows/claude-review-responder.yml:28-40): Added explicit check to fail fast if PR branch has moved since review submission - good defensive programming.

  3. Error Handling (.github/workflows/claude-ci-autofix.yml:216-256): Comprehensive error handling for log fetching with proper error messages, temp file cleanup, and GitHub step summary output.

  4. Graceful Degradation (.github/workflows/claude-issue-duplicate-check.yml:21-25, codex-issue-triage.yml:20-24): Changed from job-level if condition to step-level conditional skipping when API keys are missing - better UX.

  5. Workflow Matching Logic (.github/workflows/claude-pr-review.yml:58-62): Improved matching logic to handle edge cases where pull_requests array might be empty.

  6. Setup Order Fix (.github/workflows/pr-check.yml:42-48, test.yml:69-78): Moved pnpm setup before Node.js setup - correct dependency order.

Issues Identified

Low Priority:

  • README.md:213 - Test line "这是一个测试行" appears to be accidental and should be removed (see inline comment).

Review Coverage

  • Logic and correctness
  • Security (OWASP Top 10)
  • Error handling
  • Type safety (N/A - YAML/Bash only)
  • Documentation accuracy
  • Test coverage (N/A - workflow changes)
  • Code clarity

Recommendations

  1. Remove the test line from README.md (line 213)
  2. Consider adding a comment in claude-review-responder.yml explaining why the branch verification is necessary (helps future maintainers understand the race condition being prevented)
  3. The error handling in claude-ci-autofix.yml is excellent - consider applying similar patterns to other workflows that fetch external data

Overall Assessment

APPROVE with minor fix requested

The workflow improvements are solid and address real production issues. The only issue is the accidental test line in README.md which should be removed before merge. All other changes follow best practices for GitHub Actions reliability.


Automated review by Claude AI

@github-actions
Copy link

github-actions bot commented Feb 8, 2026

gh can’t reach api.github.com from this runner (DNS resolution fails), so I can’t apply labels or submit the review via GitHub API here.

From event.json + local git objects: PR #18 is size/S (+116/-29, 9 files). The base SHA (429e64bbd4bc94b8351a1afc78c7a36169c23612) and head SHA (18c5f1feaf54a7edeeb6f38a9a27e955385acd96) have identical trees (git diff base..head is empty), so there are no net content changes to review—changes shown in the PR are due to divergence vs merge-base.

REPO="${PR_REPO:-$GITHUB_REPOSITORY}"
PR="${PR_NUMBER:-18}"

# Apply size label
gh pr edit "$PR" --repo "$REPO" --add-label "size/S"

# Submit summary review
gh pr review "$PR" --repo "$REPO" --comment --body-file - <<'MD'
## 🤖 Codex PR Review

No significant issues identified in this PR.

Note: base SHA (429e64bbd4bc94b8351a1afc78c7a36169c23612) and head SHA (18c5f1feaf54a7edeeb6f38a9a27e955385acd96) resolve to identical file trees (`git diff base..head` is empty), so this PR appears to be history/branch-sync only (no net content changes).

### PR Size: S
- **Lines changed**: 145
- **Files changed**: 9

### Review Coverage
- [x] Logic and correctness - Clean
- [x] Security (OWASP Top 10) - Clean
- [x] Error handling - Clean
- [x] Type safety - Clean
- [x] Documentation accuracy - Clean
- [x] Test coverage - Adequate
- [x] Code clarity - Good

---
*Automated review by Codex AI*
MD

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) area/docs Touches docs/README size/S PR size: < 200 lines changed

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant