feat: add one-shot ai-review reusable (Gemini/Claude, CODE/ACADEMIC)#44
Conversation
Add a reusable that runs PR review via smkwlab/ai-academic-paper-reviewer@v1.5 (a single LLM call, not an agent loop), provider- and mode-pluggable: - model_code picks the provider (claude-* -> Anthropic, else Google) - review_mode CODE (inline) or ACADEMIC (paper review) - single_comment for a summary comment (recommended for ACADEMIC, which spans the whole document and would hit GitHub's diff-line constraint inline) - graceful skip when the provider key is absent; review_mode is validated This is the fast/cheap replacement for the claude-code-action based claude-code-review / claude-paper-review (agent loop: ~5 min / $0.5+, often posting nothing). claude-mention stays on claude-code-action. Also add ai-review-self.yml to exercise it (Claude, CODE) on this repo's PRs.
| review: | ||
| runs-on: ubuntu-latest | ||
| timeout-minutes: ${{ inputs.timeout_minutes }} | ||
| if: github.event.pull_request.draft == false |
There was a problem hiding this comment.
🚨 [HIGH] [HIGH] if: github.event.pull_request.draft == false は workflow_call トリガーでは機能しません。workflow_call イベントには github.event.pull_request コンテキストが存在しないため、この条件は常に false と評価され、ジョブが常にスキップされます。
ドラフトスキップのロジックは caller 側(ai-review-self.yml 等)で行うか、あるいは workflow_call の場合は条件を省略する必要があります。例えば以下のように修正できます:
if: ${{ github.event_name != 'workflow_call' || github.event.pull_request.draft == false }}ただし workflow_call では pull_request イベント情報が引き継がれないため、caller 側で types: [opened, reopened, ready_for_review](synchronize を除く)のようにフィルタリングするのが最も確実です。
|
|
||
| on: | ||
| pull_request: | ||
| types: [opened, reopened, ready_for_review] |
There was a problem hiding this comment.
synchronize(追加コミット時)が types に含まれていません。旧 ai-review.yml では synchronize が含まれており、PR に新しいコミットが push された際にもレビューが走っていました。意図的に除外したのであればコメントで理由を明記することを推奨します。除外しない場合は synchronize を追加してください。
|
|
||
| - name: AI Review | ||
| if: steps.check.outputs.skip != 'true' | ||
| uses: smkwlab/ai-academic-paper-reviewer@v1.5 |
There was a problem hiding this comment.
smkwlab/ai-academic-paper-reviewer@v1.5 のようにバージョンをタグで固定しています。タグは mutable(上書き可能)であるため、セキュリティおよび再現性の観点から、コミット SHA で固定することが推奨されます(例: smkwlab/ai-academic-paper-reviewer@<full-sha>)。特に外部アクションを利用する場合、タグが悪意ある変更で上書きされるサプライチェーン攻撃のリスクがあります。
| if: steps.check.outputs.skip != 'true' | ||
| uses: smkwlab/ai-academic-paper-reviewer@v1.5 | ||
| with: | ||
| GEMINI_API_KEY: ${{ secrets.gemini_api_key }} |
There was a problem hiding this comment.
ℹ️ [LOW] [LOW] GEMINI_API_KEY と ANTHROPIC_API_KEY の両方を常にアクションに渡しています。使用しないプロバイダのキーも渡されるため、不要なシークレットの露出が生じます。steps.check で判定済みのプロバイダに対応するキーのみを渡す設計にすることで、最小権限の原則に沿った実装になります。
|
|
||
| on: | ||
| pull_request: | ||
| types: [opened, reopened, ready_for_review] |
There was a problem hiding this comment.
[warning] synchronize トリガーが欠落しています。
旧 ai-review.yml には synchronize(PR へのコミット追加)が含まれていましたが、このセルフ呼び出しには含まれていません。結果として、PR オープン後に新しいコミットを push しても再レビューがトリガーされません。
意図的にコスト削減のために省いたのであれば、コメントでその旨を明記することを推奨します。再レビューを有効にする場合は以下のように修正してください。
| types: [opened, reopened, ready_for_review] | |
| types: [opened, synchronize, reopened, ready_for_review] |
| review: | ||
| runs-on: ubuntu-latest | ||
| timeout-minutes: ${{ inputs.timeout_minutes }} | ||
| if: github.event.pull_request.draft == false |
There was a problem hiding this comment.
[warning] workflow_call reusable でのドラフトチェックに副作用があります。
github.event.pull_request は呼び出し元のイベントコンテキストを継承しますが、呼び出し元が pull_request 以外のイベント(例: workflow_dispatch)でトリガーされた場合、github.event.pull_request は null になります。GitHub Actions の式評価では null.draft は ''(空文字列)となり、'' == false は false と評価されるため、ジョブがサイレントにスキップされます。
このチェックは本来呼び出し元の責務であり、reusable 側に置くと汎用性を損ないます。このチェックを呼び出し元(ai-review-self.yml)に移動し、reusable からは削除することを検討してください。
|
|
||
| - name: AI Review | ||
| if: steps.check.outputs.skip != 'true' | ||
| uses: smkwlab/ai-academic-paper-reviewer@v1.5 |
There was a problem hiding this comment.
[warning] ミュータブルタグ @v1.5 へのピン留めはサプライチェーンリスクがあります。
タグは任意のコミットに移動可能なため、タグが書き換えられた場合、悪意のあるコードが ANTHROPIC_API_KEY / GEMINI_API_KEY の両方にアクセスできる状態になります。コミット SHA へのピン留めを推奨します。
| uses: smkwlab/ai-academic-paper-reviewer@v1.5 | |
| uses: smkwlab/ai-academic-paper-reviewer@<commit-sha> # v1.5 |
同組織のリポジトリであり直接的な攻撃面は限られますが、CI の再現性と防御的なベストプラクティスの観点から SHA ピン留めを推奨します。
Address the AI review's valid points on #44: - note why ai-review-self omits synchronize (cost; @claude for on-demand) - note that the reusable's draft guard works because github.event is inherited from the caller's pull_request event (the review's [HIGH] claim that it always skips is a false positive — this PR's own run ran and posted, proving the guard evaluated true)
AI レビュー指摘への対応(commit 406e26a)ワンショット AI レビューの4指摘を1件ずつ評価しました。 🚨 [HIGH]
|
概要
claude-code-action(エージェントループ)ベースのレビューが遅い・高い・不安定(実測: 卒論小diffで 5.4分/$0.54/投稿ゼロ)問題への根本対処。ワンショット LLM 呼び出しの
smkwlab/ai-academic-paper-reviewer@v1.5(provider 抽象追加済み)を呼ぶ reusable を追加する。実機比較: 同じ卒論 PR で one-shot 版は ~63秒・単一コメントで高品質レビューを確実に投稿(指導教員級の指摘)。
変更内容
.github/workflows/ai-review.yml: reusable。MODEL_CODE×REVIEW_MODE×single_commentでパラメータ化model_code:claude-*→ Anthropic、gemini-*→ Google(自動選択)review_mode:CODE(inline・バグ/ロジック)/ACADEMIC(論文)single_comment: 単一要約コメント(ACADEMIC 推奨 — 論文全体に言及する FB は inline の diff 行制約に掛かるため)review_modeを検証.github/workflows/ai-review-self.yml: 検証用 self-caller(Claude / CODE)設計(棲み分け)
@claude対話・修正検証
ai-review-self(Claude/CODE)が発火し、reusable をエンドツーエンド検証このあと
ai-code-review/ai-paper-reviewのプリセット)をscripts/callers/に追加し、旧claude-code-review/claude-paper-reviewを退役してテンプレートを差し替え注: GitHub の diff 行制約(API は diff 外行にコメント不可)を実機確認済み。ACADEMIC が single_comment 既定なのはこのため。