Skip to content

fix(cli-pr-monitor,check-ci-coderabbit): CodeRabbit 指摘ゼロ完了の検知ギャップ解消 (順位258) - #249

Merged
aloekun merged 1 commit into
masterfrom
fix-coderabbit-zero-comment-detection
Jul 6, 2026
Merged

fix(cli-pr-monitor,check-ci-coderabbit): CodeRabbit 指摘ゼロ完了の検知ギャップ解消 (順位258)#249
aloekun merged 1 commit into
masterfrom
fix-coderabbit-zero-comment-detection

Conversation

@aloekun

@aloekun aloekun commented Jul 5, 2026

Copy link
Copy Markdown
Owner

概要

CodeRabbit は「指摘ゼロ」で完了した (再) レビューでは formal review object (REST pulls/{pr}/reviews) を提出せず、commit status のみで完了を通知する (context CodeRabbit / state success / description Review completed)。reviews API 単独に依存していた 2 箇所でこの完了を検知できず実害が出ていた。順位258 (WP フィードバック採用) の対応。

実害と修正

1. 助言層: 再トリガー抑止ガードの穴 (cli-pr-monitor review_trigger.rs)

head_already_reviewed() は reviews API の commit_id 照合のみで判定していたため、指摘ゼロでレビュー済みの HEAD を未レビューと誤判定し、fail-open で @coderabbitai review を再投稿してレート枠を浪費し得た (ADR-019 再トリガー抑止ガードが quota を守れないケース)。

  • reviews API + commit status の 2 系統combine_reviewed で fail-open 合成 (いずれか確証 Some(true) なら skip、両方判定不能 None なら投稿)
  • 純関数 parse_commit_status_reviewed / combine_reviewed に分離し、三値分岐 (fail-open None→投稿の反転テスト含む、順位 162 と同型) をユニットテスト化

2. 決定論層: park ループの非終了 (check-ci-coderabbit)

完了検知は元々 commit status を照会していたが、head SHA を無指定 gh pr view (cwd branch auto-detection) で取得しており、jj workspace 等で cwd branch が PR branch と食い違うと SHA 取得に失敗 → not_found に倒れ、指摘ゼロ完了で review_recheck が max_review_rechecks まで park していた (PR #247 実測: recheck 0→2 で完了検知できず)。指摘ありのレビューは actionable>0 で action_required に落ちて止まるため、指摘ゼロだけがハングする症状だった。

note: 元 todo は「review_recheck に commit status シグナルを追加」を想定していたが、実データ調査で真因が checker の SHA 取得経路と判明したため、修正箇所を変更した。詳細は ADR-019 amendment を参照。

テスト

  • cli-pr-monitor 240 tests / check-ci-coderabbit 94 tests — 全 green
  • clippy --all-targets clean (テストコード含む)

ドキュメント

Summary by CodeRabbit

  • Bug Fixes

    • 再レビューの判定精度を改善し、すでにレビュー済みのPRでは不要な再実行を抑止しやすくなりました。
    • PRの最新状態をより正確に参照して、レビュー完了の検知ミスを減らしました。
    • 判定できない場合は安全側に倒して、処理が止まりにくくなりました。
  • Documentation

    • 変更内容と運用方針に関する設計メモを更新しました。

…順位258)

CodeRabbit は指摘ゼロで完了した (再) レビューでは formal review object を提出せず
commit status のみで完了通知する。reviews API 単独では拾えず 2 つの gap があった:

1. 助言層 (review_trigger): head_already_reviewed が reviews API のみで判定し、
   指摘ゼロでレビュー済みの HEAD へ @coderabbitai review を再投稿しレート枠を浪費し得た。
   reviews API + commit status の 2 系統を combine_reviewed で fail-open 合成する。
   純関数 parse_commit_status_reviewed / combine_reviewed に分離し三値テスト (None→投稿の
   反転テスト含む) を追加。

2. 決定論層 (check-ci-coderabbit): 完了検知は元々 commit status を照会していたが、head SHA
   を無指定 gh pr view (cwd auto-detection) で取得しており jj workspace 等で SHA 取得に失敗
   → not_found に倒れ指摘ゼロ完了の park ループが終了しなかった (PR #247 実測)。get_head_sha
   を monitor が渡す解決済み repo/PR での repos/{repo}/pulls/{pr} 照会に変更。真因は parse で
   なく SHA 取得経路のため parse_coderabbit_status は不変、PR #247 実測 status を回帰テスト化。

ADR-019 § 再トリガー抑止ガードを amendment。todo 順位258 を消化。
@coderabbitai

coderabbitai Bot commented Jul 5, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

CodeRabbitの再レビュー済み判定ロジックを、reviews APIとcommit statusの2系統からなる三値合成方式に拡張。checker側のhead SHA取得方法をpull request直参照に修正。関連ドキュメント(ADR、TODOリスト)を更新し、対応する回帰テストとユニットテストを追加した。

Changes

再トリガー抑止ガードの二重判定化

Layer / File(s) Summary
ADR・TODOドキュメントの更新
docs/adr/adr-019-coderabbit-review-hybrid-policy.md, docs/todo13.md, docs/todo-summary.md
WP-05の判定ソース二系統化とfail-open方針をADRに追記し、対応TODOをtodo13.mdへ追加、実行順序サマリーから完了エントリを削除。
checker側のhead SHA取得方法の修正
src/check-ci-coderabbit/src/main.rs, src/check-ci-coderabbit/src/parsers.rs
get_head_shaをrepo/pr引数でpulls/{pr}.head.shaを参照する形に変更し、fetch_coderabbit_commit_stateの呼び出しを更新、実測データに基づく回帰テストを追加。
reviews API・commit statusの二系統判定合成
src/cli-pr-monitor/src/stages/review_trigger.rs
reviewed_via_reviews_api、reviewed_via_commit_status、parse_commit_status_reviewed、combine_reviewedを追加し、いずれかが確証あれば skip、両方不明ならfail-open投稿する合成ロジックとユニットテストを実装。

Estimated code review effort: 3 (Moderate) | ~25 minutes

Possibly related PRs

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed 変更内容の主眼であるCodeRabbitの指摘ゼロ完了検知ギャップ解消を、対象サブシステム付きで簡潔かつ具体的に表しています。
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix-coderabbit-zero-comment-detection

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
src/cli-pr-monitor/src/stages/review_trigger.rs (1)

83-95: 🎯 Functional Correctness | 🟠 Major | ⚡ Quick win

gh pr view--repo を渡して cwd 依存を外してください。

head_already_reviewedrepo を受け取っているのに、この呼び出しだけ gh pr view $pr_str --json headRefOid になっています。jj ワークスペースなどで repo 推測が外れるとここで空結果になり、以降の判定が丸ごとスキップされます。--repo を明示してください。

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/cli-pr-monitor/src/stages/review_trigger.rs` around lines 83 - 95, The
head_already_reviewed function builds a gh pr view command without using the
repo argument, so it still depends on the current working directory for repo
selection. Update the run_gh_quiet invocation in head_already_reviewed to pass
the repo explicitly with --repo using the existing repo parameter, so the
headRefOid lookup works reliably even when cwd-based repo inference fails.
🧹 Nitpick comments (1)
src/cli-pr-monitor/src/stages/review_trigger.rs (1)

129-143: 🎯 Functional Correctness | 🔵 Trivial | ⚡ Quick win

CodeRabbit context のマッチング方式が check-ci-coderabbit 側と異なる。

本関数(eq_ignore_ascii_case("CodeRabbit") による完全一致)と src/check-ci-coderabbit/src/parsers.rsparse_coderabbit_statuscontains("CodeRabbit") による大文字小文字区別ありの部分一致)とで、CodeRabbit ステータス判定の意味論が異なります。現状のfixtureでは両者とも "CodeRabbit" 完全一致なので問題は顕在化しませんが、本PRの目的は2つの検出層(advisory層/deterministic層)のギャップを埋めることなので、判定ロジック自体が揃っていないと将来的なcontext文字列の変化時にドリフトするリスクがあります。

共通の判定ヘルパーとして抽出するか、少なくとも同じマッチング方式(大文字小文字無視の完全一致、または部分一致)に揃えることを推奨します。

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/cli-pr-monitor/src/stages/review_trigger.rs` around lines 129 - 143, The
CodeRabbit context matching in parse_commit_status_reviewed is inconsistent with
parse_coderabbit_status, so align both status checks to the same semantics.
Update the matching logic in review_trigger::parse_commit_status_reviewed to use
the same approach as check-ci-coderabbit/src/parsers.rs, or extract a shared
helper used by both parse_commit_status_reviewed and parse_coderabbit_status so
the context comparison stays consistent across advisory and deterministic paths.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Outside diff comments:
In `@src/cli-pr-monitor/src/stages/review_trigger.rs`:
- Around line 83-95: The head_already_reviewed function builds a gh pr view
command without using the repo argument, so it still depends on the current
working directory for repo selection. Update the run_gh_quiet invocation in
head_already_reviewed to pass the repo explicitly with --repo using the existing
repo parameter, so the headRefOid lookup works reliably even when cwd-based repo
inference fails.

---

Nitpick comments:
In `@src/cli-pr-monitor/src/stages/review_trigger.rs`:
- Around line 129-143: The CodeRabbit context matching in
parse_commit_status_reviewed is inconsistent with parse_coderabbit_status, so
align both status checks to the same semantics. Update the matching logic in
review_trigger::parse_commit_status_reviewed to use the same approach as
check-ci-coderabbit/src/parsers.rs, or extract a shared helper used by both
parse_commit_status_reviewed and parse_coderabbit_status so the context
comparison stays consistent across advisory and deterministic paths.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 984b97bf-2b97-499a-91df-d8ecc143efde

📥 Commits

Reviewing files that changed from the base of the PR and between 5ad9dc9 and cba61fa.

📒 Files selected for processing (6)
  • docs/adr/adr-019-coderabbit-review-hybrid-policy.md
  • docs/todo-summary.md
  • docs/todo13.md
  • src/check-ci-coderabbit/src/main.rs
  • src/check-ci-coderabbit/src/parsers.rs
  • src/cli-pr-monitor/src/stages/review_trigger.rs
💤 Files with no reviewable changes (2)
  • docs/todo-summary.md
  • docs/todo13.md

@aloekun
aloekun merged commit f557472 into master Jul 6, 2026
1 check passed
@aloekun
aloekun deleted the fix-coderabbit-zero-comment-detection branch July 6, 2026 04:48
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