feat(hooks): 関数長スケーリング検出 lint 追加 (順位 48) + Bundle b 登録 - #105
Conversation
… 安定化) を追加 - 順位 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 / 過剰一般化リスク / 重複ルール)。
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 発火を確認
順位 48 (関数長スケーリング検出 lint) を実装完了 (前 commit) に伴い、todo.md 表と todo5.md 詳細エントリを削除。
|
Warning Rate limit exceeded
To keep reviews running without waiting, you can enable usage-based add-on for your organization. This allows additional reviews beyond the hourly cap. Account admins can enable it under billing. ⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughPR は関数長検出機能を Rust lint hook に追加し、ドキュメント内の実行優先度表を更新します。既存のコメント検証ロジックと並行して、50 行を超える関数をフラグします。 Changes関数長検出機能の追加
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related PRs
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. 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. Review rate limit: 0/1 reviews remaining, refill in 34 minutes and 51 seconds.Comment |
There was a problem hiding this comment.
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/hooks-post-tool-comment-lint-rust/src/main.rs`:
- Around line 549-551: The combined violations list currently calls
find_violations(...) and then extends it with
find_function_length_violations(...), but each function independently stops at
MAX_VIOLATIONS so the merged result can exceed MAX_VIOLATIONS; change the merge
logic in the block that creates violations (the variable named violations built
from find_violations and find_function_length_violations) to enforce a global
cap by collecting results incrementally and truncating to MAX_VIOLATIONS (e.g.,
call find_violations, then call find_function_length_violations and only take up
to (MAX_VIOLATIONS - violations.len()) from it, or extend then truncate
violations.truncate(MAX_VIOLATIONS)), ensuring the final returned violations
vector never exceeds MAX_VIOLATIONS.
- Around line 297-299: The overlap check currently uses the full function span
(f.line_start..f.line_end) so signature-only edits still trigger touch-trigger;
change the check in the line_filter block to test overlap against the function
body span (e.g., use f.body_start and f.body_end or the equivalent body range
fields) when calling span_overlaps_ranges, and ensure you handle the case where
the body range may be missing/None by falling back to skipping the function (or
the desired behavior) instead of using the full function span.
🪄 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: 1c50e327-0e33-4b63-b4f8-934a4110dcfa
📒 Files selected for processing (3)
docs/todo.mddocs/todo5.mdsrc/hooks-post-tool-comment-lint-rust/src/main.rs
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 統合後の違反件数に全体上限が効いていません。
… (PR 3) (#106) * docs(todo): PR #105 post-merge-feedback 採用分 + format 拡張タスクを追加 - 順位 57: Aggregation cap integration test (PR #105 T2-1 採用、Tier 2 / S) — collect_all_violations の MAX_VIOLATIONS contract を test 化、将来の lint 追加時の truncate 削除 regression を防止 - 順位 58: post-merge-feedback findings table format 拡張 (Tier 2 / S) — Severity / Frequency / Adoption Risk / Recommendation 必須列化、AI 採用 判定を rubric ベースで安定化、卻下根拠の言語化 PR #105 post-merge-feedback の他 7 件 (T1-1/2/3, T2-2/3, T3-1, T3-2) は採用 見送り (低頻度 + 高実装コスト / NLP 必要 / 過剰一般化 / 重複ルール 等)。 * feat(takt): Bundle Z Phase 3 — reviewer 役割変更 + fix-trust 連帯 (PR 3 / #B-γ + #C-2) 決定論層 (Phase 1 #B-α + Phase 2 #B-β) を通過した状態を前提に、reviewer の責務を 「lint で防げない高次違反のみ flag」 に再定義し、fix step 報告に基づく Iter 3 短絡を追加する。 #B-γ reviewer 役割変更: - review-simplicity.md: 7 criteria enumerate 義務を削除、anomaly detection モードに転換 - 決定論層 intercept 項目 (comment policy / function length / function metrics) を skip - 異常検知 criteria: Unexplained complexity / Inconsistent style / Dead-on-arrival code / Hidden coupling / Missing failure paths / Non-obvious magic values - DRY/YAGNI scope guards は維持 - 'Calibration: avoid over-narrowing' セクションで二重 miss リスク対策 - review-security.md: vulnerability checklist を memory aid に格下げ、anomaly mode を primary entry point に - concrete exploit path 要件を強化 (input control / what becomes possible) - docs-only trust boundary criterion は維持 #C-2 fix-trust 連帯: - fix.md: Convergence verdict セクション追加 (REQUIRED) - persists==0 AND misdirected==0 → 'convergence_verdict: fully_resolved' - else → 'convergence_verdict: partial' - 'Honesty constraint' で安全網 bypass リスクを明示 - post-pr-review.yaml + pre-push-review.yaml: fix step rules に新 condition 追加 - fully_resolved → COMPLETE 直行 (analyze/reviewers 再実行 skip) - partial → analyze/reviewers (既存挙動) - Unable to proceed → supervise (既存挙動) 期待効果: - attention drift 問題消滅 (検出対象が absolute に narrow に) - 1-iter ALL APPROVE 率 90% 超 (決定論層で大半 intercept) - review 所要時間短縮 (1m30s〜3m → 30s〜1m 期待) - post-pr-review 3-iter outlier を 2-iter に圧縮 (~3 分削減/run) 進捗管理 (docs/pipeline-token-efficiency.md): - #C-3 / #A-2 / #B-β を 'Completed' に更新 - #B-γ / #C-2 を '実装中' (本 commit) に更新 リスク対策: - 二重 miss: reviewer の anomaly mode に 'Calibration: avoid over-narrowing' を残置 - 自己評価信頼性: fix.md の 'Honesty constraint' で fully_resolved を慎重に emit するよう明示 * fix(review): apply CodeRabbit Major fix for #106 Finding #1 (Major / .takt/facets/instructions/review-simplicity.md:35): 'Hidden coupling' を anomaly criteria に残しつつ cross-file 全面禁止すると 裏取り不可能で矛盾する指摘 (resolved)。Scope constraint を softening し、 limited cross-file lookups を anomaly verification 目的に限定して許可する。 findings 自体は依然 diff hunk traceable のまま。 Finding #2 (Minor / docs/todo.md:73): reject。docs/todo.md の運用ルール '新規タスクは追加しない' は task body 追加禁止で、priority table 行追加は 既存運用 (順位 32 で既知の文言整合タスクとして登録済) のため本 PR では 変更しない。
…(順位 58) (#107) * feat(takt): post-merge-feedback aggregate facet 9-列 rubric format 拡張 (順位 58) 各提案に Severity / Frequency / Adoption Risk / Recommendation の 4 列を必須化し、 post-merge-feedback の AI 採用判定を rubric ベースで安定化させる。PR #105 の評価 セッションで Effort + Rationale のみでは AI が採用判定根拠を systematically 落とす ことを実証したため、format 自体に rubric を組み込むことで AI に強制する設計。 追加列: - Severity (Critical/High/Medium/Low) — 何を防ぐかの深刻度 - Frequency (High/Medium/Low/Very Low) — 発生頻度 / 再発リスク - Adoption Risk (1-2 語のタグ) — 採用に伴うリスク (None/既存ルール重複/過剰一般化/ NLP 必要/false positive リスク/etc) - Recommendation (✅ 採用/🤔 様子見/❌ 却下、必須) — 採用判定 emoji + 根拠 Rationale 列は拡張し、従来 Source 表記 + 採用根拠 (なぜ S × F × Effort × Risk から この Recommendation に至ったか) を 1-2 文で記述する。 期待効果: - post-merge-feedback の評価セッションで AI が rubric を埋める → ユーザー審査時間 短縮 (本セッションのような手動 Severity / Frequency 補完が消滅) - 卻下根拠の言語化により preventive over-engineering 等のアンチパターンを systematic に表面化 - 「✅ 採用」「🤔 様子見」「❌ 却下」の 3 段階で取捨選択が明示化 dogfood: - 次の post-merge-feedback (順位 47/56/Bundle b 等の通常作業 PR) で新フォーマット が動作するか確認 - v1 の rubric 定義に dogfood で改善余地が出れば順位 58 follow-up で漸進改善 * docs(todo): 順位 58 完了に伴い削除 順位 58 (post-merge-feedback findings table format 拡張) を実装完了 (前 commit) に 伴い、todo.md 表と todo5.md 詳細エントリを削除。 * fix(review): apply CodeRabbit fixes for #107 - Finding #1 (Minor / line 51): 品質フィルタ read-only zone 判定を明文化 (Target に編集可能パスが一つでも含まれる場合は除外しない、判定基準を追加) - Finding #2 (Major / line 100): Recommendation rubric の曖昧性を解消 - 条件式に括弧追加で演算子優先順位を明示 - Effort rubric (XS/S/M/L/XL) を新規追加 - Adoption Risk の 'weak/strong' 定義を追加 (Recommendation 条件式から参照) - Finding #3 (Minor / line 146): Effort rubric 追加で同根の懸念も解消
… 59/60 + ADR-035/036/037) (#108) * docs(todo): 順位 59 (ADR-035 docs 評価ポリシー / PR #107 T3-1) を追加 PR #107 post-merge-feedback の Tier 3 #1 採用に伴い、docs/todo.md 表と todo5.md 詳細を追加。 - 順位 59 (Tier 3, M): ADR-035 docs 評価ポリシー - docs-only 変更への code review criteria 誤適用を排除する global policy - review-security.md の既存 trust boundary criterion を ADR で集約 - review-simplicity.md / analyze-coderabbit.md にも一貫展開 - false REJECT 削減 + 開発体験劣化抑制 判定根拠 (順位 58 で導入した rubric ベース): - Severity Medium / Frequency Medium / Effort M / Adoption Risk None / ✅ 採用 * docs(efficiency): docs-pr-iteration-efficiency.md を新規作成 docs-only PR の iteration 改善に関する task 分類・bundle 案を集約する index を docs/ に新規追加。各 task の作業詳細は docs/todo*.md 系列に置き、本ファイル は概要 + リンクに留める設計。 掲載内容: - 現状の課題 / ボトルネック分析 (5 観点) - 改善 task 分類 (HIGH / MEDIUM / LOW IMPACT、合計 12 順位) - 推奨 bundle 案 (Bundle 'docs PR streamline' = 順位 59+31+32 を最優先) - 関連ドキュメント (todo.md / pipeline-token-efficiency.md / ADR-019/027/035) 役割: 試験運用 (bundle が消化されたら役割を終える計画書)。pipeline-token- efficiency.md と並列の領域特化計画書として機能する。 動機: 本セッションで 「docs-only PR の iteration 改善に当たる task をピック アップしてほしい」「毎回この情報を調べるのは手間」 とのユーザー要望に対応。 分析結果を再調査せず参照可能にする。 * docs(efficiency): coderabbit-monitoring-efficiency.md を新規作成 CodeRabbit 監視機能改善 (rate-limit 自動回復) に関する task 分類・bundle 案 を集約する index を docs/ に新規追加。各 task の作業詳細は docs/todo*.md 系列に置き、本ファイルは概要 + リンクに留める設計。 掲載内容: - 現状の課題 (CodeRabbit 無課金 = 1 時間 3 reviews 上限、47 分 rate-limit で auto-retry がバウンスする致命点) - ボトルネック分析 (6 観点: 長時間 rate-limit / polling 負荷 / silent loss / structured findings / 自動 trigger 信頼性 / ポリシー暗黙化) - 改善 task 分類 (HIGH / MEDIUM / LOW IMPACT、合計 9 順位) - 推奨 bundle 案 (Bundle 'CR auto-monitoring core' = 順位 53/54/55、 Bundle 'CR rate-limit auto-retry robustness' = 順位 42/43/46/49) - 推奨実行順序: 53 → 42-43-46-49 → 54 → 55 (1 と 2 は並行可) - 関連ドキュメント (ADR-009/018/019/034、todo.md、pipeline-token- efficiency.md、docs-pr-iteration-efficiency.md) 役割: 試験運用 (bundle 消化後に役割終了)。pipeline-token-efficiency.md / docs-pr-iteration-efficiency.md と並列の領域特化計画書として機能。 動機: 本セッションで 'CodeRabbit の監視機能改善に関する task をピックアップ してほしい'、'毎回この情報を調べるのは手間' とのユーザー要望に対応。 * docs(retire): pipeline-token-efficiency.md retire — ADR-036/037 化 + 順位 60 移管 + 削除 PR #97 セッション起源の計画書 docs/pipeline-token-efficiency.md (481 行) を 役割完了として retire。重要な設計決定は ADR に永続保存し、残作業 1 件のみを todo に移管した上で計画書ファイル本体を削除する。 新規 ADR (2 件): - ADR-036: Bundle Z 3 層アーキテクチャ - 決定論層 (#B-α PR #99/#105) → 制約付き修正 (#B-β PR #103) → 異常検知レビュアー (#B-γ PR #106) の 3 層スタック設計 - 'upper layer skips what lower layer catches' 原則 - 二重 miss 対策 (Calibration: avoid over-narrowing) を残置 - ADR-037: takt fix-trust shortcut (convergence_verdict 機構) - post-pr-review / pre-push-review の fix step が 'convergence_verdict: fully_resolved' で COMPLETE 直行する設計 - 'LLM が出した結果を後段で再検証しない' 原則 - Honesty constraint で安全網 bypass リスク管理 ADR-034 更新: - #D-4 (Claude 応答スタイル簡素化) を ❌ 不採用 に確定 (2026-05-04 ユーザー判断) Bundle Z Phase 2/3 完了後の再評価で副作用観測手段確立が見えないため 永続的に見送り。潜在 2.5-4M tokens 削減は採用しない - '将来の検討事項' から #D-4 再評価条件セクションを削除 - pipeline-token-efficiency.md への参照を '(削除済)' に annotate 順位 60 新規登録 (旧 #A-3、唯一の残作業): - analyze-session の transcript filter 絞り込み (Tier 3 / M) - input range を PR 作成 commit〜merge に限定し input token 30-50% 削減 ファイル削除: - docs/pipeline-token-efficiency.md (481 行) を削除 内容は git log で復元可能、主要設計は ADR-036/037 に集約 参照更新 (5 ファイル): - docs/coderabbit-monitoring-efficiency.md: 関連リンクから dead link 削除、ADR-036/037 を追加 - docs/docs-pr-iteration-efficiency.md: 同上 - docs/todo4.md: 順位 41 (Bundle Y2 効果定量計測) は動機失効を明記 (Bundle Z 完成 + Z2 不採用)、本格着手前にユーザー判断要。 順位 44/45 の参照を '(削除済)' に annotate - docs/todo5.md: 順位 51 の参照を ADR-036 に置換 - CLAUDE.md: ADR-036 / ADR-037 を index に追加 動機: ユーザー方針 '本当に必要な決定事項はADRに残し、不要になったTodoファイルや 作業計画のファイルは定期的に削除' に従い、計画書 retire の標準パターンを 本セッションで確立。今後類似の '計画書' (試験運用フラグ付き docs/) は 役割完了時に同パターンで retire する。 * fix(todo): 順位 41 entry の retire 済前提と旧フロー文言の不整合を解消 (#108 CR Minor) CodeRabbit が PR #108 review で 'outside diff range comment' として指摘した docs/todo4.md 順位 41 (Bundle Y2 効果定量計測) の line 371/378 残存問題を修正。 - 削除: 'Line 371: 想定削減量達成判定に基づき計画書 retire / 追加 Bundle 提案' (計画書はすでに retire 済のため、retire 判定ステップが矛盾) - 削除: 'Line 378: Bundle Z / Z2 の ROI 判断材料として活用可能なデータが揃う' (Bundle Z は完成、Bundle Z2 = #D-4 は不採用で本目的の役割消滅) - 修正: '結果を本 todo entry 内 (もしくは新規 ADR) に記録 — 旧計画は ...' → '結果を本 entry または新規 ADR に記録 (= 完了)' に簡素化 判定対象を「本 entry/ADR への記録完了」に統一し、retire 済前提との整合を確保。 備考 (別観察): 本指摘は CodeRabbit が 'outside diff range comment' として review body 内に含めて投稿したため、inline comment 前提の takt analyze-coderabbit step では 0 findings 判定 (= 検出漏れ) となった。 takt analyzer の coverage gap として将来の post-merge-feedback で扱う。
Summary
Summary by CodeRabbit
新機能