Skip to content

feat(check-ci-coderabbit): --list-findings モード追加 (Bundle a Sub-PR 1)#101

Merged
aloekun merged 3 commits into
masterfrom
feat/check-ci-coderabbit-list-findings
May 2, 2026
Merged

feat(check-ci-coderabbit): --list-findings モード追加 (Bundle a Sub-PR 1)#101
aloekun merged 3 commits into
masterfrom
feat/check-ci-coderabbit-list-findings

Conversation

@aloekun
Copy link
Copy Markdown
Owner

@aloekun aloekun commented May 2, 2026

Summary

  • ADR-034 Bundle a Sub-PR 1 (token 削減層) を実装
  • check-ci-coderabbit.exe --list-findings --pr <N> モードを追加し、CodeRabbit インラインレビューコメントを構造化 JSON {"findings": [...]} で取得可能にした
  • Sub-PR 2 (cli-pr-monitor の rate-limit auto-retry) で本 API を消費する想定
  • gh CLI 使用規則 (#D-1) は global rule (~/.claude/rules/common/git-workflow.md) に追記済 (リポ外につき本 PR には含まれない)
  • pre-existing WIP (docs/todo.md +1 行 / docs/todo4.md Sub-PR 2 entry) は別 commit として同梱

変更内容

feat(check-ci-coderabbit): --list-findings Rust モード追加 (Bundle a Sub-PR 1 #D-3)

  • CliArgslist_findings: bool フラグ + --push-time の epoch 0 fallback
  • ListedFinding { severity, file, line, summary, url } + ListFindingsOutput 専用型 (lib_report_formatter::Finding 共有型に影響なし)
  • parse_listed_findings: thread root のみ抽出 + resolved: reply による outdated filter (HashSet<u64> で resolved_root_ids を一度構築)
  • is_resolve_reply: trim + lowercase で resolved: prefix 判定 (memory project_coderabbit_auto_resolve.md 仕様準拠)
  • extract_summary: extract_issue を再利用しつつ改行を空白に正規化 + 120 chars 切り詰め
  • GhPullCommentid, in_reply_to_id, html_url を拡張 (#[serde(default)] 互換)
  • run_list_findings: CI / rate-limit / status check を skip して findings のみ取得
  • 単体テスト 16 件追加 (resolve filter / push_time / 非 CR 著者 / schema 検証 等)

docs(todo): Bundle a Sub-PR 2 integration test entry + 順位 46 を実行順序に追加

PR #100 post-merge-feedback で生成された Sub-PR 2 follow-up エントリ:

  • 順位 46 を docs/todo.md 推奨実行順序に追加 (Bundle a Sub-PR 2 integration test、Effort M)
  • docs/todo4.md に詳細エントリ追加 (cli-pr-monitor rate-limit auto-retry の test 計画 4 シナリオ)

実装は Sub-PR 2 で着手予定。設計根拠は ADR-034 参照。

動作確認

  • cargo test -p check-ci-coderabbit: 79 passed / 0 failed
  • cargo clippy -- -D warnings: clean
  • pnpm build:check-ci-coderabbit: 成功 (.claude/check-ci-coderabbit.exe 配置済)
  • スモーク --list-findings --pr 99: 空配列を返却 (= 6 thread root すべて resolved: reply 済、正解動作)
  • スモーク --list-findings --pr 100: 空配列を返却

Test plan

関連

  • ADR-034: CodeRabbit 監視・対話の自動化戦略 (Bundle a 設計根拠)
  • docs/pipeline-token-efficiency.md: Bundle a 全体構成 (#D-1 + #D-3 統合)
  • 次のステップ: Sub-PR 2 (cli-pr-monitor rate-limit auto-retry + ADR-018/009 明文化 + integration test)

Summary by CodeRabbit

リリースノート

  • New Features

    • CodeRabbit findings を JSON 形式で出力する --list-findings モードを追加しました。
  • Documentation

    • CodeRabbit rate-limit auto-retry の integration test タスクをドキュメントに記録しました。

PR #100 post-merge-feedback で生成された Sub-PR 2 follow-up エントリを反映:
- 順位 46 を docs/todo.md 推奨実行順序に追加 (Bundle a Sub-PR 2 integration test)
- docs/todo4.md に詳細エントリ追加 (cli-pr-monitor rate-limit auto-retry の test 計画)

設計根拠は ADR-034 参照。実装は Sub-PR 2 で着手予定。
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 2, 2026

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: e90fb83e-400a-4a9c-83fe-37115065e748

📥 Commits

Reviewing files that changed from the base of the PR and between c7d69c7 and 22b354d.

📒 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

Walkthrough

このPRは、CodeRabbit連携強化に関する2つの独立した変更を含みます。(1) rate-limit auto-retry統合テストの計画・ドキュメント化、(2) check-ci-coderabbit に --list-findings モード(ADR-034)を実装し、PR inline findings をJSON形式で一覧出力する機能を追加。

Changes

Rate-limit Auto-retry 統合テスト計画

Layer / File(s) Summary
タスク追跡(実行順序)
docs/todo.md
推奨実行順序テーブルに Tier 2 タスク「CodeRabbit rate-limit auto-retry 統合テスト(PR #100 T2-1)」を新規追加(行62)。
テスト仕様・設計記録
docs/todo4.md
rate-limit 検出→解除時刻計算→自動投稿→再検出の main flow と、dedup / max_retries 超過 / session 超え recovery の4シナリオを含む統合テスト設計、モック戦略、作業計画、完了基準、未決事項(gh APIモック方針・session超え再現性)を詳細に記録。

--list-findings モード実装

Layer / File(s) Summary
CLI インターフェース拡張
src/check-ci-coderabbit/src/main.rs (lines 8-75)
--list-findings フラグを追加;listing モード時は --push-time が不要で EPOCH_PUSH_TIME にデフォルト化。CliArgslist_findings: bool フィールドを追加。
データモデル拡張
src/check-ci-coderabbit/src/main.rs (lines 231-247)
GhPullComment に thread-root 識別・リンク用フィールド(id, in_reply_to_id, html_url)を追加;listing モード用の新型 ListedFindingListFindingsOutput { findings: Vec<ListedFinding> } を導入。
コメント時刻フィルタ統一
src/check-ci-coderabbit/src/main.rs (lines 366-371, 566-572)
既存の parse_new_commentsparse_findings の時刻ゲートを created_at > push_time から created_at >= push_time に変更;境界タイムスタンプを含める。
Listing モード解析実装
src/check-ci-coderabbit/src/main.rs (lines 597-690)
parse_listed_findings 関数:coderabbitai[bot] の thread root のみを抽出、created_at >= push_time でフィルタ、resolved threads(resolved: で始まる返信がある)を除外、severity/file/line/summary/url を構造化。Helper 関数 is_resolve_reply(case-insensitive resolved: プリフィックス判定)、extract_summary(1行要約)を追加。
Listing 実行フロー
src/check-ci-coderabbit/src/main.rs (lines 1169-1196, 1198-1228)
新規 run_list_findings 関数で paginated PR inline comments を gh で fetch;main ブランチで args.list_findings 判定、listing 時は CI/rate-limit 検査をスキップして JSON 出力。共有 print_json helper を追加。
テスト・ドキュメント更新
src/check-ci-coderabbit/src/main.rs (lines 1957-2114)
is_resolve_reply, extract_summary, parse_listed_findings の単体テスト追加;thread-root 含む/除外、push-time フィルタ・epoch 境界、line fallback、author フィルタ、JSON 妥当性、出力スキーマ を検証。

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Possibly related PRs

  • PR #100: --list-findings モードの設計(ADR-034)を提案・ドキュメント化;本PRがその実装を実現。
  • PR #25: src/check-ci-coderabbit/src/main.rsGhPullComment フィールド拡張とコメント解析機能を追加;同様の構造化 findings パース機能を実装。
  • PR #89: rate-limit 関連タスクの再構成と documentation 更新を含む;本PR の todo ドキュメント追加と共通テーマ。
🚥 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 PR タイトルは「feat(check-ci-coderabbit): --list-findings モード追加」で、main.rs に新しい --list-findings CLI モード(ADR-034)を追加するという主要な変更を正確に反映しており、簡潔で明確です。
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
Review rate limit: 0/1 reviews remaining, refill in 60 minutes.

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

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@src/check-ci-coderabbit/src/main.rs`:
- Around line 662-666: The comparison that computes after_push_time currently
uses created_at.as_deref().map(|t| t > push_time) which excludes commits with
created_at == push_time; change the comparison operator to >= so the boundary is
inclusive (i.e., map(|t| t >= push_time)), and update any nearby comment or
function doc that describes the boundary to reflect the inclusive behavior;
ensure this change is applied where after_push_time, created_at and push_time
are referenced together.
- Around line 1191-1197: The current .unwrap_or_else(|e| { ... "[]".to_string()
}) swallows all errors and treats failures (auth/network/API) as an empty
findings array; change this to propagate the error instead of returning "[]":
remove the unwrap_or_else and return/propagate the Err (e.g., use ? or map_err
to convert into the function's Result) so callers can retry or fail
appropriately; update the caller signatures if needed to accept a Result and
handle retry/failure logic. Ensure you modify the exact expression that contains
.unwrap_or_else(|e| ...) so errors are not converted into a "[]" success value.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 728eef1d-f1a8-48eb-a2b8-fe41f6ea57d2

📥 Commits

Reviewing files that changed from the base of the PR and between e1dc0ab and c7d69c7.

📒 Files selected for processing (4)
  • .tmp-pr-body-draft.md
  • docs/todo.md
  • docs/todo4.md
  • src/check-ci-coderabbit/src/main.rs

Comment thread src/check-ci-coderabbit/src/main.rs
Comment thread src/check-ci-coderabbit/src/main.rs Outdated
aloekun added 2 commits May 2, 2026 19:54
…R 1 #D-3)

ADR-034 Bundle a Sub-PR 1 の token 削減層。CodeRabbit インラインレビュー
コメントを構造化 JSON `{"findings": [...]}` で出力する新モードを追加する。

- CliArgs に `--list-findings` フラグ + `--push-time` の epoch 0 fallback
- ListedFinding struct (severity / file / line / summary / url) + 出力 envelope
- parse_listed_findings: thread root のみ抽出 + `resolved:` reply による outdated filter
- GhPullComment に id / in_reply_to_id / html_url を拡張
- run_list_findings: CI / rate-limit / status check を skip して findings のみ取得
- 単体テスト 16 件追加 (resolve filter / push_time / 非 CR 著者 / schema 検証 等)

Sub-PR 2 (cli-pr-monitor の rate-limit auto-retry) で本 API を消費する想定。
gh CLI 規則 (#D-1) は global rule (~/.claude/rules/common/git-workflow.md) に
追記済 (リポ外)。
Resolved findings:
- [Minor] src/check-ci-coderabbit/src/main.rs:666 `push_time` 境界を inclusive に揃えてください。
- [Major] src/check-ci-coderabbit/src/main.rs:1197 取得失敗を空配列に潰さないでください。
@aloekun aloekun force-pushed the feat/check-ci-coderabbit-list-findings branch from c7d69c7 to 22b354d Compare May 2, 2026 11:00
@aloekun
Copy link
Copy Markdown
Owner Author

aloekun commented May 2, 2026

@coderabbitai review

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 2, 2026

✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@aloekun aloekun merged commit 6cd9316 into master May 2, 2026
1 check passed
@aloekun aloekun deleted the feat/check-ci-coderabbit-list-findings branch May 2, 2026 13:20
aloekun added a commit that referenced this pull request May 3, 2026
…do follow-ups (#103)

* docs(todo): PR #101 post-merge-feedback の Tier 1/2 finding を採用 (順位 47-49) + todo5.md 新設

- 順位 47 (Tier 1): `>` vs `>=` boundary inconsistency lint rule
- 順位 48 (Tier 1): 関数長スケーリング検出 oxlint rule
- 順位 49 (Tier 2): `parse_findings` 系の error-path test infrastructure (Bundle a Sub-PR 2)
- todo5.md を新設 (todo4.md が 50KB 到達のため、新規エントリ移行先)
- todo.md ヘッダを todo5.md 言及に更新

* docs(todo): PR #102 post-merge-feedback Tier 1 #1 を採用 (順位 50)

PR #102 post-merge-feedback で提案された 4 件のうち Tier 1 #1 のみ user 判断で採用:

- comment-lint hook の scope を「変更行のみ」に限定する設計修正
- PR #102 セッション中に観測した 'pre-existing 20 violations が edit のたびに flag される'
  問題への対応 (hook の file-level scan の設計問題)

todo.md の推奨実行順序サマリーに 順位 50 (Tier 1, Effort M) として追加し、
todo5.md に詳細エントリ (動機・設計決定 2 案・作業計画・完了基準・詰まっている箇所) を記載。

Bundle Z Phase 2 (#B-β) 着手前に解消することを推奨 (Phase 2 で fix.md / helper script を
編集する際に同じ block 問題が再発するため)。

参照: .claude/feedback-reports/102.md Tier 1 #1

* feat(takt+hooks): Bundle Z Phase 2 - 制約付き fix instruction (#B-β)

fix step の self-check を LLM 判断ではなく機械的指標の diff 比較に置き換える決定論層を実装。
fix が introduce した新規 violation (nesting / function 長 / non-doc comment 数の増加) を
構造的に検出し、LLM に override / refactor 判断を促す。

実装要素:
- hooks-post-tool-comment-lint-rust crate に '--metrics <file>' モード追加
  - tree-sitter で function_item を walk、name / line range / max nesting depth を抽出
  - non-doc comment count は既存 ALLOWED_*_PREFIXES (PR #99) を流用 (single source of truth)
  - JSON 出力で scripts/fix-metrics-check.ps1 が消費
  - 13 件の新規 unit test (空 file / 単純 / nested / match / closure / trait / 関数長 等)
- scripts/fix-metrics-check.ps1 新規追加
  - jj file show -r @- で pre-state 取得、temp file 経由で metrics 算出
  - 関数を name で突き合わせ、length / max_nesting_depth の増加を検出
  - file-level non_doc_comment_count の増加も検出
  - PASS / FAIL (exit 1, JSON violations) / SKIPPED (新規 file) / infrastructure error (exit 2)
  - Windows + 日本語ロケールで jj UTF-8 stdout が Shift-JIS 解釈される問題を回避するため
    [Console]::OutputEncoding = UTF8 を明示設定 (実装中に発覚した mojibake → tree-sitter 早期失敗)
- .takt/facets/instructions/fix.md に Pre-completion deterministic check セクション追加
  - 各 .rs 修正 file で helper 起動を指示
  - exit 1 時は refactor 優先、override は Metrics override 見出しで根拠記載
  - exit 2 (infra error) は fix 完了を block しない (環境問題なので surface のみ)

v1 (PoC) の意図的な scope 外 (docs/pipeline-token-efficiency.md PR 2 参照):
- change-site 周辺への scope 絞り込み (file 全体 + 関数単位の比較で代用)
- Rust 限定 (将来言語拡張で別 metric tool 評価)
- 関数 rename 時の追跡 (name match のみ、rename は新規扱い)

参照: docs/pipeline-token-efficiency.md PR 2 (Bundle Z Phase 2)、PR #99 (Phase 1)
aloekun added a commit that referenced this pull request May 3, 2026
* docs(todo): PR #104 post-merge-feedback の採用分 + Bundle b (CR operation 安定化) を追加

- 順位 53: rate-limit retry の CronCreate 化 (Bundle b PR-1, Tier 1) — 47 min
  rate-limit auto-retry 不能の致命点解消
- 順位 54: review 完了待ちの CronCreate 化 + observer 廃止 (Bundle b PR-2, Tier 2)
- 順位 55: config 拡張 + SessionStart catch-up (Bundle b PR-3, Tier 3)
- 順位 56: comment-lint hook test 拡充 (PR #104 T2-1+T2-2 bundle, Tier 2) —
  UTF-8 multi-byte + block comment boundary の回帰テスト体系化

PR #104 post-merge-feedback の Tier 2-3/4 と Tier 3 全件は採用見送り (overlap /
過剰一般化リスク / 重複ルール)。

* feat(hooks): 関数長スケーリング検出 lint 追加 (順位 48 / PR #101 T1-4)

CLAUDE.md `coding-style.md` 50 行ガイドラインを決定論的に維持する PostToolUse
lint を `hooks-post-tool-comment-lint-rust` に追加。touch-trigger ratchet 方式で
既存の 50 行超過関数 (40 個) は変更行に触れた瞬間にだけ flag、grandfather される。

実装:
- 新 violation type `RUST_FUNCTION_TOO_LONG` (severity: error)
- 閾値 `MAX_FUNCTION_LINES = 50`
- `find_function_length_violations`: `compute_metrics` の関数 length を使い、
  > 50 行 かつ 関数 body の行範囲が `line_filter` と overlap する関数のみ flag
- 順位 50 の `compute_changed_lines` ロジックを再利用 (Edit / Write / MultiEdit
  の挙動と整合)
- empty filter (Edit 純削除) は lint skip、None filter (Write / MultiEdit) は
  whole-file lint
- 既存 `line_in_ranges` を削除 (`span_overlaps_ranges` で代替)
- `main` を 64 行 → 39 行に refactor (`extract_file_path` /
  `collect_all_violations` / `emit_violations_feedback` に分割)、本 lint の
  自己適用

Pivot 経緯:
- 当初計画は oxlint 自作 rule + .oxlintrc.json + src/oxlint-rules/ だったが、
  oxlint は JS/TS 専用 + 自作 rule 未対応のため structurally impossible
- Rust 限定 + 既存 Rust hook 拡張で代替 (ユーザー承認、TS/JS は保留)
- ロールアウト戦略は Ratchet (touch-trigger、既存 40 個 grandfather) を採用

検証:
- cargo test: 73 passed (新 10 件: function length 系)
- cargo clippy --all-targets -- -D warnings: clean
- 自己適用: main.rs の 50 行超関数は `find_violations` (90 行 / 既存 / 触らず)
  と `function_too_long_violation` (32 行 / 新規 / OK)、main は 39 行に refactor
- 統合テスト: main.rs 内 main() を Edit する hook input → RUST_FUNCTION_TOO_LONG
  発火を確認

* docs(todo): 順位 48 完了に伴い削除

順位 48 (関数長スケーリング検出 lint) を実装完了 (前 commit) に伴い、todo.md
表と todo5.md 詳細エントリを削除。

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

Resolved findings:
- [Major] src/hooks-post-tool-comment-lint-rust/src/main.rs:299 touch-trigger 判定が「body overlap」仕様と一致していません。
- [Minor] src/hooks-post-tool-comment-lint-rust/src/main.rs:551 統合後の違反件数に全体上限が効いていません。
aloekun added a commit that referenced this pull request May 7, 2026
…7 / §A-2 P-2) (#126)

§A-2 Phase 5 dogfood P-2。PR #101 で実証された latent drift (parse_findings
系 3 関数で created_at > push_time vs >= の混在) を構造的に防止する custom
lint rule を追加。Bundle Z #B-α と同じ「決定論的防止層」哲学。

ルール仕様:
- pattern: \b(created_at|submitted_at|updated_at|comment_event_time|
  event_time|comment_created_at|published_at|posted_at|commented_at)
  \s*>\s*[a-zA-Z_]
- direction: `>` のみ flag (`<` は is_stale 等で意図的 exclusive 境界
  の正しい用途があるため scope 外)
- target: .rs files only

検証:
- 11 unit tests (4 detect 系 + 7 skip 系) + 1 helper 関数 で transition
  matrix を網羅
- 全 75 tests passed
- 既存 codebase で 0 violations (created_at >= は doc コメントのみ、
  is_stale の created_at < は `<` で対象外)

build + deploy 済 (.claude/hooks-post-tool-linter.exe)。
aloekun added a commit that referenced this pull request May 9, 2026
…#133)

* docs(todo): split summary and todo5.md tasks to keep files under 50KB

Claude Code の読み取り安定性閾値 (~50KB) を超過していた docs/todo.md (68KB)
と docs/todo5.md (67KB) を分割。

- docs/todo.md (68KB → 36KB): 推奨実行順序サマリー section を独立した
  docs/todo-summary.md (新規 33KB) に切り出し。todo.md には pointer のみ残す
- docs/todo5.md (67KB → 25KB): PR #101#109 由来の古い半分 13 タスクを
  docs/todo7.md (新規 45KB) に分離。todo5.md には PR #110 以降が残存
- recommended-order-summary anchor 参照 7 箇所 (todo2-6.md /
  custom-lint-rules.toml) を todo-summary.md# に更新
- ADR-034 / local-llm-offload-history.md の priority table 参照 4 箇所も
  todo-summary.md に追従更新
- todo-summary.md table の「ファイル」列で 順位 47-67 を todo5.md → todo7.md
  に変更、todo7.md 内部チェックリストの「本 todoN.md エントリを削除」も整合

全 8 ファイル (todo.md / todo2-7.md / todo-summary.md) が 50KB 以下に収まる。

* docs(todo): fix CR review findings (preamble counts + broken ADR link)

PR #133 で CodeRabbit が検出した 3 件 Minor finding を修正:

- docs/todo6.md:5: 「六つすべてを確認すること」→「八つすべてを確認すること
  (todo.md / todo2-7.md / todo-summary.md)」
- docs/todo7.md:5: 「七つすべてを確認すること」→「八つすべてを確認すること
  (todo.md / todo2-7.md / todo-summary.md)」 (todo-summary.md カウント漏れ修正)
- docs/todo7.md:103: ADR-036 link を `../docs/adr/...` → `adr/...` に修正
  (todo7.md は docs/ 配下なので `../docs/` は誤り。todo5.md からの分割で表面化
  した pre-existing bug)

cli-finding-classifier (ADR-038) は ADR-035 docs-only filter で
not_applicable 判定したが、GitHub thread state は依然 unresolved のため
fold-in fix で thread を closeable な状態にする。
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