Skip to content

feat(workflow): 支持 Claude 模型执行 - #338

Merged
Terry-Mao merged 7 commits into
mainfrom
feat/support-claude-model-287
Nov 4, 2026
Merged

Terry-Mao merged 7 commits into
mainfrom
feat/support-claude-model-287

Conversation

@Terry-Mao

Copy link
Copy Markdown
Owner

Summary

  • 增加 AI_PROVIDER=claude,通过 Claude Code Action 直接调用 Anthropic 模型;未设置时沿用 Codex。
  • 九条 AI workflow 共用各自的任务提示词、上下文准备和产物校验;夜间审查统一接收两种后端的 JSON 结果。
  • 增加配置校验、测试和使用说明。

Refs #287

Testing

  • 同步最新 main 后,完整 unittest 通过:533 项。
  • actionlint .github/workflows/*.yml 通过。
  • git diff --check origin/main...HEAD 通过。
  • validate_ai_provider.py 编译检查通过。

Risk

尚未使用 Anthropic 凭据在 GitHub Actions 上做真实调用。Claude 路径依赖仓库配置 AI_PROVIDER=claude、ANTHROPIC_API_KEY 和 CLAUDE_MODEL;配置错误会在调用模型前失败。

How to revert

合并后执行 git revert cae5876,或在 GitHub 上撤销此 PR;然后将 AI_PROVIDER 设回 codex 或删除该变量。

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

结论:需要修复后再合并。provider 门禁、共享校验以及文档/测试覆盖整体较完整,但 Claude 路径仍有可运行性与安全边界问题。

主要问题

  • Claude 全量审查步骤要求进入 pr-worktree,却没有提供执行目录切换的工具。
  • 新增的 anthropics/claude-code-action@v1 在全部 9 个 workflow 中均使用可变标签,且在审查/实现等写权限 job 中执行。
  • 审查 job 将写权限 token 直接交给处理不可信 PR diff 的第三方 action;实现 job 还允许无参数 Bash,并可继承 checkout 的持久写凭据。

Security

  • 实现路径需要加入沙箱/网络和凭据隔离,并移除裸 Bash;审查路径应让 AI 运行在只读权限中,再由独立发布步骤使用写权限。
  • 将第三方 action 固定到审计过的 commit SHA。

未使用真实 Anthropic 凭据执行 workflow;现有测试只能覆盖静态结构,建议合并前至少执行一次 workflow_dispatch 冒烟测试。

Comment thread .github/workflows/review-pr.yml Resolved
Comment thread .github/workflows/review-pr.yml Resolved
Comment thread .github/workflows/review-pr.yml Resolved

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

结论

发现 1 个阻断性安全问题。Provider 校验、两种后端的 prompt/输出归一化,以及 review 发布职责拆分总体一致;相关定向测试均通过。

Security

respond-to-pr-comment.yml 的新 Claude 步骤同时获得 job 级写权限 token 与裸 Bash,而输入包含不可信 PR 文本,构成阻断性提示注入风险。现有未解决线程 #4463744392 的裸 Bash 已在 implementation 步骤移除,但 job 级写 token 仍未隔离;review-pr.yml 已通过独立 publish job 修复该边界,其他 Claude 写操作也应统一改为只读 token 加外层写入。

@Terry-Mao

Copy link
Copy Markdown
Owner Author

已推送 81c8872:9 处 Claude action 固定到 commit;PR 审查 AI 改为只读 job,写权限发布独立执行并校验 PR 快照和 diff 摘要;审查提示词改用 pr-worktree 路径;实现步骤移除裸 Bash 并关闭 checkout 持久凭据。

实现与 PR 评论响应的 Claude 步骤仍在写权限 job,尚未完成 token、网络和执行环境隔离。此项保持开放,#338 暂不应合并。真实 Anthropic 凭据的 workflow_dispatch 冒烟测试也尚未执行。

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

本轮第 3 轮全量评审发现一个阻断性安全问题。本轮未提供 spec 上下文;相关 provider、review workflow 和 nightly 单测均通过,但测试没有覆盖 Claude 在所有写权限 workflow 中的隔离边界。

respond-to-pr-comment.yml 的既有未解决线程在代码层面已通过 respond_claude 只读 job 与 publish_claude 独立写 job 修复;该讨论线程仍标为 open,建议维护者验证后关闭,本次不再重复内联。

Security

新增 Claude 路径只在 review、nightly 和 PR 评论响应中完成了读写隔离;create-spec、create-implementation 以及三个 update-* workflow 仍在拥有写权限的 job 内,把带写权限的 token 和 Write/Edit 工具交给处理不可信 issue/评论内容的 AI。AI 退出后,同一工作区中的受信脚本还会继续执行,因此提示注入可以改写这些脚本或 git 凭据配置,并借外层写权限提权。应沿用 respond_claude 的隔离方式,并补充覆盖所有 Claude 入口的权限边界测试。

Comment thread .github/workflows/update-dedupe.yml Resolved

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

本轮已复核讨论中的未解决安全线程:respond-to-pr-comment 与 update-dedupe 当前均已改为只读执行 job 加独立 write publisher,未再重复旧内联评论。整体 reader/publisher 拆分方向可行,不属于必须推翻的架构问题;但新加的 publish_claude_implementation 没有贯通发布所需凭据,属于阻断性实现缺陷。另需补充覆盖该凭据路径的回归测试。

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

发现 1 个阻断性安全问题,见行内评论。

Security

triage-issue.yml 的 Claude job 是九个 Claude job 中唯一仍使用 checkout 默认凭据持久化的路径;它的不可信输出随后会被发布为 issue 评论,因此需要与其他路径统一关闭凭据持久化。

架构评估:本轮补齐 implementation checkout/commit 的凭据并同步测试,此前关于 respond-to-pr-comment、guidance 更新 workflow 和 implementation 发布的三个未解决线程在当前 head 已分别由只读 job + 独立 publisher 以及本轮 token 注入处理,未再重复行内评论。连续多轮局部修复也暴露出:九个 workflow 各自复制同一信任边界,且现有跨 workflow 测试只检查写权限和禁用工具,漏掉了 checkout 凭据持久化,才使 triage-issue 仍出现同类缺口。整体拆分方向可行,但合并前应统一修正该边界并把该断言补到共享测试中。

Comment thread .github/workflows/triage-issue.yml Resolved

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

本轮增量修复为 triage checkout 关闭凭据持久化,并把测试扩展到该 job 的所有 checkout,方向正确。但跨轮审查显示整体“只读代理 + 受信任发布器”边界尚未在 triage 路径闭合:Claude 仍可写 triage_context.json,而 apply 又用该 artifact 决定目标 issue 和标签白名单,因此可被不可信 issue/评论中的提示注入用于越权写入其他 issue。其余 Claude 路径已拆分为只读代理和发布 job,问题不是整个方案不可用,而是这一处仍把代理可写输入当成受信任元数据;建议发布侧重新生成或校验 context,并只接受代理产出的结果文件。

Security

  • 需要阻断代理通过篡改 context 改变 GitHub 写入目标;当前仅关闭 checkout 凭据持久化不能解决该 artifact 信任边界。

Comment thread .github/workflows/triage-issue.yml Resolved

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

本轮增量修复了上一轮未解决的 triage_context.json 篡改风险:代理运行前记录上下文 SHA-256,发布 job 在下载 artifact 后、校验和应用结果前强制复核,并使用默认分支上的受信脚本执行写入。新增测试也固定了快照、代理、校验和应用步骤的顺序。架构复核未发现需要继续局部打补丁的同类根本缺陷;只读生成 job、受控 artifact 与写权限发布 job 的边界与本轮修复一致。未发现需要阻止合并的问题。

@Terry-Mao

Copy link
Copy Markdown
Owner Author

更新:#338 中已报告的 Claude 权限边界问题已修复,相关审查线程现已关闭。

  • 9 个 Claude action 固定到提交 SHA,所有 AI job 只使用读权限 token、非持久化 checkout,并禁用 Bash/WebFetch/WebSearch。
  • PR 审查、评论响应、spec/implementation 创建和 guidance 更新均由独立写权限 job 校验产物后发布;implementation 发布使用受信任脚本,并补齐受控 Git 凭据。
  • 分诊发布前校验代理运行前记录的 triage_context.json 摘要,防止代理改写写入目标或标签策略。

最新 head 7c15955 的 CI test 与 AI review 均通过;actionlint 和相关定向测试通过。尚未使用真实 Anthropic 凭据运行 workflow_dispatch 冒烟测试,运行期 Claude 路径仍需该验证。

@Terry-Mao
Terry-Mao merged commit 32d96d9 into main Nov 4, 2026
4 checks passed
@Terry-Mao
Terry-Mao deleted the feat/support-claude-model-287 branch November 4, 2026 16:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant