Skip to content

fix(pr-monitor): CR check flow defects (Bundle CR-CHECK 順位 208/209/210) - #212

Merged
aloekun merged 2 commits into
masterfrom
bundle-cr-check-208-210
Jun 17, 2026
Merged

fix(pr-monitor): CR check flow defects (Bundle CR-CHECK 順位 208/209/210)#212
aloekun merged 2 commits into
masterfrom
bundle-cr-check-208-210

Conversation

@aloekun

@aloekun aloekun commented Jun 17, 2026

Copy link
Copy Markdown
Owner

Summary

PR #210/#211 セッションで実観測した cli-pr-monitor の CodeRabbit check flow 不具合 3 件をバンドル修正します。

  • 順位 208 (T1-1): CR walkthrough body から "No actionable comments were generated in the recent review." を機械検出し、formal Review object が無くても recheck loop を終了させる
  • 順位 209 (T2-1): PARK signal に safe_minute_at_unix / safe_minute_at_iso_utc field 追加 + ACTION REQUIRED block で 2 制約 (round-UP + :00/:30 回避) を sequential check として明示
  • 順位 210 (T3-1): ~/.claude/rules/common/development-workflow.md + memory に「Cron 秒 → 分 round-UP」rule を 2 直交制約として codify

設計判断

順位 208 (CR walkthrough body parse)

  • WALKTHROUGH_HEADER_MARKER (= <!-- This is an auto-generated comment: summarize by coderabbit.ai -->) で auto-generated 由来であることを確認 → ユーザー手動投稿の引用文を誤検出しない
  • is_rate_limit_comment(c) 先行チェック → rate-limit overlay 中 (memory project_coderabbit_rate_limit_overlay) は body が書き換わるため clean 判定を skip
  • unresolved_threads > 0 のときは過去 review 由来の未対応事項のため walkthrough_clean を上書きせず action_required を維持

順位 209 (PARK signal output)

  • Constraint 1 (秒 → 分 round-UP) は UTC 純粋計算で完結するため cli-pr-monitor 側で適用
  • Constraint 2 (:00/:30 minute 衝突回避) は fractional-hour TZ (IST +5:30 等) で正しく適用するには local TZ awareness が必要なため、PARK signal 内の ACTION REQUIRED block に Step 2 として明示し AI agent consumer 側で処理
  • chrono crate を追加せず pure arithmetic で実装 (既存 lib-pending-file::epoch_secs_to_iso8601 と同方針)

順位 210 (rule codify)

副次更新

feedback_coderabbit_no_actionable_merge_signal.md (memory) に「順位 208 で機械化済」記述追加。machine-enforce の補完層として、(1) 機械検出が disable された場合の AI fallback、(2) walkthrough body 以外 (review object body 等) で同 marker が観測された場合の手動判定の 2 用途で残置。

global 編集 (jj 管理外)

  • ~/.claude/rules/common/development-workflow.md (新 sub-section)
  • ~/.claude/projects/.../memory/feedback_cron_round_up_for_second_timestamps.md (新規)
  • ~/.claude/projects/.../memory/MEMORY.md (pointer 追加)
  • ~/.claude/projects/.../memory/feedback_coderabbit_no_actionable_merge_signal.md (Status 追記)

snapshot は ~/.claude/__backup-20260617-...-bundle-cr-check/ に保存済 (feedback_global_config_backup 適用)。

Out of scope (別 PR で対応)

hooks-post-tool-comment-lint-rust (soft-feedback) が以下 3 件を info 出力 (block されない nag):

  • cli-pr-monitor/src/stages/poll.rs: 2090 行 > 800 行
  • check-ci-coderabbit/src/main.rs: 2356 行 > 800 行
  • check-ci-coderabbit/main.rs::run_check: 147 行 > 50 行

いずれも本 PR で 1 行追加した結果 touch-trigger ratchet が触発された既存超過。ファイル責務分割 refactor の別 PR で対応します (ユーザー合意済 2026-06-17)。

順位 211 (T3-2、testing.md N=0/1/2 単複境界 guideline) は本バンドル対象外で docs/todo10.md に残置。

Test plan

  • cargo build --release clean
  • cargo test -p check-ci-coderabbit: 89 passed (82 既存 + 7 新規 = walkthrough header あり / rate-limit overlay / marker なし / CR 以外 / push_time 前 / decide 2 経路)
  • cargo test -p cli-pr-monitor: 203 passed (193 既存 + 10 新規 = round-UP 5 件 / compute 4 件 / signal 1 件)
  • cargo clippy ... -D warnings clean
  • markdownlint clean
  • dogfood opportunity: 本 PR の wakeup スケジューリングで Constraint 1 + 2 を自己適用してマージ前検証

関連

Summary by CodeRabbit

リリースノート

  • New Features
    • CodeRabbit の自動レビューワークスルー完了(clean marker)を検出し、条件を満たす場合にモニタリングを完了/停止する判定を追加しました。
    • 定期確認の PARK シグナル生成で、cron の秒→分の丸めを安全なタイミング基準に調整しました(特定時刻を避ける処理を含む)。
  • Documentation
    • TODO 記録(推奨実行順序・PR post-merge feedback 関連)を削除/整理しました。
  • Tests
    • 完了判定・丸めロジック・上書き挙動を含むテストケースを追加しました。

PR #210/#211 セッションで実観測した cli-pr-monitor の CR check flow 不具合 3 件を
バンドル修正:

順位 208 (CR walkthrough body parse):
- check-ci-coderabbit に WALKTHROUGH_CLEAN_MARKER / WALKTHROUGH_HEADER_MARKER 定数 +
  parse_walkthrough_clean_marker + is_clean_walkthrough_comment helper を追加
- CodeRabbitStatus に walkthrough_clean: bool フィールド追加
- decide() に 'walkthrough_clean && !has_unresolved → complete' 分岐追加
- formal Review object が無くても walkthrough body の clean marker を信頼して
  recheck loop を構造的に終了。memory feedback_coderabbit_no_actionable_merge_signal
  の手動 workaround を機械化
- 7 fixture test (header あり / rate-limit overlay / marker なし / CR 以外 / push_time
  前 / decide 2 経路)

順位 209 (PARK signal output round-UP):
- cli-pr-monitor/stages/poll.rs に round_up_to_next_minute pure helper +
  compute_safe_minute_for_park_signal helper 追加
- ReviewParkSignalFields に safe_minute_unix / safe_minute_iso_utc 追加
- format_review_park_signal template に新 field 出力 + ACTION REQUIRED block で
  2 制約 (秒→分 round-UP + :00/:30 minute 衝突回避) を sequential check として明示
- AI agent consumer が round-DOWN 罠を踏まない構造的防御
- 10 test (round-UP 5 件 / compute 4 件 / signal 1 件)

順位 210 (rule codify):
- ~/.claude/rules/common/development-workflow.md に 'Cron スケジューリングの秒 → 分
  round-UP' section 追加、analyzer 観点の '30s jitter vs 90s 前倒し制約' 混在を
  2 直交制約として別個に明示 (Constraint 1 = scheduling minimum lead time /
  Constraint 2 = execution jitter ≤90s pre-fire)
- feedback_cron_round_up_for_second_timestamps.md 新規 memory + MEMORY.md pointer
- feedback_coderabbit_no_actionable_merge_signal.md に '順位 208 で機械化済' 追記

検証:
- cargo build --release clean (30.72s)
- cargo test -p check-ci-coderabbit: 89 passed (82 既存 + 7 新規)
- cargo test -p cli-pr-monitor: 203 passed (193 既存 + 10 新規)
- cargo clippy ... -D warnings clean
- markdownlint clean

scope 外 (別 PR で対応):
- poll.rs (1988→2090 lines) / check-ci-coderabbit/main.rs (2143→2356 lines) /
  run_check (147 lines) の file/function-length lint 違反は touch-trigger ratchet
  情報 (block されない soft-feedback) として残置、ファイル責務分割 refactor で対応

global 編集 (jj 管理外):
- ~/.claude/rules/common/development-workflow.md
- ~/.claude/projects/.../memory/feedback_cron_round_up_for_second_timestamps.md
- ~/.claude/projects/.../memory/MEMORY.md
- ~/.claude/projects/.../memory/feedback_coderabbit_no_actionable_merge_signal.md
@coderabbitai

coderabbitai Bot commented Jun 17, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: c2c6ad8d-bb32-4d3a-9fcd-633499128209

📥 Commits

Reviewing files that changed from the base of the PR and between b26616d and 34e4dfc.

📒 Files selected for processing (1)
  • src/check-ci-coderabbit/src/main.rs
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/check-ci-coderabbit/src/main.rs

📝 Walkthrough

ウォークスルー

check-ci-coderabbitwalkthrough_clean フィールドと判定ロジックを追加し、CodeRabbit ウォークスルーコメントの clean 検出で complete を返すよう decide を更新した。cli-pr-monitor の PARK signal では cron 秒→分 round-up を実装し、ReviewParkSignalFields と CronCreate テンプレートを更新した。関連 TODO エントリを docs から削除した。

変更内容

CodeRabbit walkthrough clean 検出

Layer / File(s) Summary
walkthrough_clean フィールドとマーカー定数
src/check-ci-coderabbit/src/main.rs
CodeRabbitStatuswalkthrough_clean: bool#[serde(default)])を追加し、clean marker と自動生成ヘッダ判定用の2定数を定義した。
walkthrough clean 判定ロジック
src/check-ci-coderabbit/src/main.rs
parse_walkthrough_clean_markeris_clean_walkthrough_comment を新設し、投稿者・ヘッダ存在・rate-limit 除外・push_time 以降の複合条件で clean を判定するようにした。
decide への組み込みと run_check への配線
src/check-ci-coderabbit/src/main.rs
run_checkcomments_json から walkthrough_clean を算出して CodeRabbitStatus に格納し、decide では walkthrough_clean かつ未解決スレッドなしの場合に complete/stop_monitoring_success を返す分岐を追加した。
walkthrough clean 関連テスト
src/check-ci-coderabbit/src/main.rs
clean 検出・rate-limit 除外・ヘッダ欠落・push_time 前イベント除外の新規テスト、decide の新規分岐テスト、既存テストへの walkthrough_clean: false 補完を追加した。

PARK signal 秒→分 round-up

Layer / File(s) Summary
round-up ユーティリティ関数と struct フィールド追加
src/cli-pr-monitor/src/stages/poll.rs
round_up_to_next_minutecompute_safe_minute_for_park_signal(sentinel 含む)を新設し、ReviewParkSignalFieldssafe_minute_unix / safe_minute_iso_utc を追加した。
format_review_park_signal と CronCreate テンプレート更新
src/cli-pr-monitor/src/stages/poll.rs
format_review_park_signal の出力に safe_minute_at_* を追加し、ACTION REQUIRED と CronCreate テンプレートを safe minute 基点・:00/:30 回避手順に更新した。CronCreate へ渡す引数を safe_unix / safe_iso に切り替えた。
round-up / safe minute テスト
src/cli-pr-monitor/src/stages/poll.rs
round_up_to_next_minutecompute_safe_minute_for_park_signal の仕様と format_review_park_signal の出力を検証するテスト群を追加した。

完了 TODO の削除

Layer / File(s) Summary
todo10.md / todo-summary.md から完了エントリ削除
docs/todo10.md, docs/todo-summary.md
PR #210 対応として挙げられていた3タスク(walkthrough clean 検出、PARK round-UP、Cron codify)のエントリを両ファイルから削除した。

推定コードレビュー工数

🎯 4 (Complex) | ⏱️ ~50 minutes

関連する可能性のある PR

  • aloekun/claude-code-hook-test#11: check-ci-coderabbit/src/main.rs の CodeRabbit 判定ロジックを同様に変更しており、本 PR の walkthrough_clean 追加はその判定フローを直接拡張する。
  • aloekun/claude-code-hook-test#113: src/cli-pr-monitor/src/stages/poll.rs の PARK signal / CronCreate スケジューリングロジックを変更しており、本 PR の safe minute round-up と同一コードパスに影響する。
  • aloekun/claude-code-hook-test#211: 本 PR で削除される TODO エントリ(PR #210 対応:順位 208–210)を追加していた PR であり、実装と docs 削除が対応する。
🚥 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 プルリクエストのタイトルは、主な変更内容(3つのCodeRabbitチェックフロー不具合の修正)を明確かつ簡潔に要約しており、変更セットの重要な部分を正確に反映しています。
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
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.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch

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 and usage tips.

@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.

🧹 Nitpick comments (1)
src/check-ci-coderabbit/src/main.rs (1)

1674-1685: 💤 Low value

テストケースの補足を検討してください。

このテストは humanreviewer ユーザーを使用しているため、ユーザーフィルタとヘッダー欠落の両方を同時にテストしています。ヘッダー要件を単独で検証するには、coderabbitai[bot] ユーザーでクリーンマーカーは含むがヘッダーマーカーが欠落しているケースを追加することを推奨します。

#[test]
fn walkthrough_clean_skipped_when_coderabbit_post_lacks_header() {
    let json = r#"[
        {"user": {"login": "coderabbitai[bot]"},
         "body": "No actionable comments were generated in the recent review.",
         "created_at": "2026-04-01T12:30:00Z"}
    ]"#;
    assert!(!parse_walkthrough_clean_marker(json, "2026-04-01T12:00:00Z"));
}
🤖 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/check-ci-coderabbit/src/main.rs` around lines 1674 - 1685, The current
test function
`walkthrough_clean_skipped_when_header_missing_to_avoid_user_post_false_positive`
conflates two separate concerns by testing both the user filter (via
humanreviewer user) and the header requirement simultaneously. Add a new
separate test function
`walkthrough_clean_skipped_when_coderabbit_post_lacks_header` that uses the
coderabbitai[bot] user (to pass the user filter check) with a body containing
the clean marker text but without the required header marker, ensuring that the
header requirement is validated independently from the user filter logic.
🤖 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.

Nitpick comments:
In `@src/check-ci-coderabbit/src/main.rs`:
- Around line 1674-1685: The current test function
`walkthrough_clean_skipped_when_header_missing_to_avoid_user_post_false_positive`
conflates two separate concerns by testing both the user filter (via
humanreviewer user) and the header requirement simultaneously. Add a new
separate test function
`walkthrough_clean_skipped_when_coderabbit_post_lacks_header` that uses the
coderabbitai[bot] user (to pass the user filter check) with a body containing
the clean marker text but without the required header marker, ensuring that the
header requirement is validated independently from the user filter logic.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 27aef292-df30-4f41-8efc-d2439827de03

📥 Commits

Reviewing files that changed from the base of the PR and between 8439b51 and b26616d.

📒 Files selected for processing (4)
  • docs/todo-summary.md
  • docs/todo10.md
  • src/check-ci-coderabbit/src/main.rs
  • src/cli-pr-monitor/src/stages/poll.rs
💤 Files with no reviewable changes (2)
  • docs/todo10.md
  • docs/todo-summary.md

…212 CR Nitpick 採用)

CR Nitpick 指摘 (PR #212 review 1 件) を採用。既存 test
walkthrough_clean_skipped_when_header_missing_to_avoid_user_post_false_positive
が humanreviewer ユーザーで user filter + header check の 2 責務を同時テストして
いたため、header marker 単独の検証を coderabbitai[bot] + clean marker + header 欠落
の独立 test として補完。

追加: walkthrough_clean_skipped_when_coderabbitai_post_lacks_header_marker

検証:
- cargo test -p check-ci-coderabbit: 90 passed (89 既存 + 1 新規)
- memory feedback_test_dry_antipattern.md と整合 (テスト独立性を優先、新規 test は
  fixture を inline で独立 setup)

CR 評価: 🧹 Nitpick / Low value / Effort XS / Risk None。memory
feedback_test_dry_antipattern の精神と一致する提案 (DRY ではなく test responsibility
分離) のため採用。
@aloekun
aloekun merged commit 3770788 into master Jun 17, 2026
1 check passed
@aloekun
aloekun deleted the bundle-cr-check-208-210 branch June 17, 2026 17:21
aloekun added a commit that referenced this pull request Jun 19, 2026
* refactor(check-ci-coderabbit): main.rs を 7 module に分割 (PR A、file/function length 解消)

PR #212 で残置した touch-trigger ratchet 違反 (file_length / function-too-long)
を解消するため check-ci-coderabbit/src/main.rs (2369 行) を 7 module に分割し、
run_check (147 行) を 8 helper 関数に decompose。

分割後:
- models.rs (118): CheckResult / RateLimitInfo / CiStatus / CodeRabbitStatus /
                   Gh* / Listed* models 集約
- markers.rs (60): RATE_LIMIT_MARKERS / WALKTHROUGH_* + 3 判定 helper
- decide.rs (412): decide + build_summary + 16 tests、build_summary を
                   2 helper (build_summary_ci_part / build_summary_cr_part) に分解
- parsers.rs (532): parse_ci_runs / parse_coderabbit_status / parse_new_comments /
                    parse_walkthrough_clean_marker / parse_actionable_comments /
                    extract_actionable_count / parse_unresolved_threads + 32 tests、
                    parse_ci_runs 内の classification を classify_ci_overall /
                    is_pending_run / is_failure_run に分解
- rate_limit.rs (365): parse_rate_limit + extract_*_format_wait_time +
                       parse_iso8601_to_unix + 21 tests
- findings.rs (381): parse_findings / parse_listed_findings + 抽出 helper +
                     16 tests、各 parse 関数を candidate/transform 2 関数に分解
- main.rs (483): entry, parse_args, run_check (37 行) + 8 fetch helper,
                  run_list_findings, auto_detect_*, is_valid_*, parse_args test

run_check decomposition (147→37 行) で抽出した helper:
- resolve_repo_and_pr (Box<CheckResult> で result_large_err 回避)
- build_init_error_result
- fetch_ci / fetch_coderabbit_commit_state / fetch_issue_comments_json /
  fetch_actionable_count / fetch_unresolved_threads / fetch_findings

合計行数: 2351 (元 2369、わずかに減少)。
全ファイル 800 行以下 (file_length lint 解消)。
全関数 50 行以下 (function_length lint 解消)。

検証:
- cargo build --release: clean (18.22s)
- cargo test -p check-ci-coderabbit: 90 passed (refactor 前後で同数、test 同一性確認)
- cargo clippy -p check-ci-coderabbit --tests -- -D warnings: clean
- Box<CheckResult> で clippy::result_large_err warning 解消

scope 外 (PR B で対応):
- cli-pr-monitor/src/stages/poll.rs (2090 行) の分割

途中事故:
- PowerShell スクリプトで main.rs を 0 行に誤削除 → jj op restore で復旧 →
  module ファイル再 Write で継続 → 以降 PowerShell の in-file 編集を回避し
  Edit/Bash sed のみ使用

* fix(review): apply CodeRabbit fixes for #213

Resolved findings:
- [Major] src/check-ci-coderabbit/src/parsers.rs:93 CodeRabbitステータスの取得順序が誤っています。
- [Major] src/check-ci-coderabbit/src/parsers.rs:175 `push_time` の境界条件が1件取りこぼします。
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