feat(hooks): Phase D D-5 — comment-lint test 拡充 + MAX cap break scope test#151
Conversation
…NS outer/inner break test (順位 56 + 119) ## D-5 実装 (順位 56 + 119 bundle) ### 順位 56: comment-lint hook test 拡充 (PR #104 T2-1+T2-2 bundle) `src/hooks-post-tool-comment-lint-rust/src/main.rs`: - UTF-8 multi-byte test 5 パターン追加: 漢字 + ASCII 混合 / 漢字単独 / emoji / BMP 外 文字 (𝕊) / 結合文字 (e + U+0301) - Block comment boundary test 6 パターン追加: 複数行 (start/end/middle 被覆) + 単行 block comment (exact / starts-at / ends-at) で `span_overlaps_ranges` の inclusive-bounds 区間交差判定を体系化 - 既存 1 パターンずつのテストは保持 (regression 防止) ### 副産物: `byte_offset_to_line` char-boundary panic fix UTF-8 漢字単独パターン test 着手時に発見した production bug を修正: - 旧: `source[..clamped].bytes()` は `clamped` が char boundary でない場合 panic - 新: `source.as_bytes()[..clamped].iter()` で byte slice 経由に変更 (char boundary 不要) - 影響: needle 末尾が multi-byte 文字の場合 (例: 「漢字のみのコメント」を Edit/Write の new_string として渡す現実シナリオ) で hook が panic していたのを修正 - direct unit test `byte_offset_to_line_handles_mid_multibyte_offset` を追加して bug location を pinpoint ### 順位 119: MAX_CUSTOM_VIOLATIONS outer/inner loop break scope explicit test `src/hooks-post-tool-linter/src/main.rs`: - `run_custom_rules_outer_break_skips_subsequent_rules`: rule_a 単独で 21 件 → cap で 20 件、rule_b は呼ばれない (全 violation が "RULE_A") を assert - `run_custom_rules_inner_cap_after_partial_first_rule`: rule_a 19 件 + rule_b 1 件 = 20 件 (rule_b の inner break が mid-rule で発火) を type 分布で検証 - PR #148 で発見した `run_custom_rules` refactor の outer/inner loop break scope を test net で固定化 ## test 結果 - hooks-post-tool-comment-lint-rust: 85 passed (前 84 + 新 1 direct unit + 11 integration) - hooks-post-tool-linter: 111 passed (前 109 + 新 2) - 合計 196 tests pass ## docs 整理 - docs/todo7.md: 順位 56 entry 削除 - docs/todo8.md: 順位 119 entry 削除 - docs/todo-summary.md: 順位 56 / 119 行削除 - docs/local-llm-offload-analysis.md: D-5 row を ✅ 着手済 に更新、bug fix を副産物として明記 ## 並行: PR #150 post-merge-feedback 登録 (本セッション前から @ に含まれていた変更) - docs/todo8.md: 順位 120 (rule comment + ADR-007 case study) / 順位 121 (4 fields 個別 fixture test) / 順位 122 (development-workflow.md Step 0 stale entry 確認 step) 登録 - docs/todo-summary.md: 3 行追加 ## Phase D 累積状況 D-3 (PR #148) + D-4 (PR #150) + D-5 (本 PR) = 3 PR 完了、Phase E 着手要件 (5 PR 累積) まであと 2 PR (D-6 + D-7)。本 PR の dogfood は push 時に `LINT_SCREEN_ENABLED=true` で opt-in 観測予定。
📝 WalkthroughWalkthroughPR ChangesPhase D Round 2 進捗とUTF-8バグ修正
Linter ルール拡張とテストカバレッジ
推奨される関連PR
🎯 3 (Moderate) | ⏱️ ~25 minutes 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
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. Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
src/hooks-post-tool-linter/src/main.rs (1)
1917-1918: ⚡ Quick win
toml追加に対する正方向の検出テストを1本追加しておくと堅いです。
extensionsに"toml"を追加したので、config.tomlで実際に違反が検出されるケースも明示しておくと、この拡張の回帰検知がより確実になります。📌 追加例(テスト)
+ #[test] + fn no_ephemeral_todo_detects_concrete_digit_reference_in_toml() { + let dir = tempfile::tempdir().unwrap(); + let file = write_file( + dir.path(), + "config.toml", + "note = \"see docs/todo3.md\"\n", + ); + let rules = compile_test_rules(vec![no_ephemeral_todo_reference_rule()]); + let violations = run_custom_rules(file.to_str().unwrap(), &rules); + assert_eq!(violations.len(), 1); + }🤖 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/hooks-post-tool-linter/src/main.rs` around lines 1917 - 1918, extensions 配列に "toml" を追加したので、対応する正方向の検出テストを追加してください: 新しいユニット/統合テストを作り、config.toml を入力として linter 実行(関数/バイナリ呼び出しを担当するテストヘルパー)し、期待通り違反が検出されることをアサートします。該当コード箇所は extensions 配列("rs","toml",...)と linter 実行を行うテストヘルパー(既存のテストで使っている run_lint/execute_tool 相当の関数名)を使って、config.toml に違反となるサンプルを書き込み、違反メッセージが返ることを検証するように実装してください。
🤖 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/hooks-post-tool-linter/src/main.rs`:
- Around line 1917-1918: extensions 配列に "toml" を追加したので、対応する正方向の検出テストを追加してください:
新しいユニット/統合テストを作り、config.toml を入力として linter
実行(関数/バイナリ呼び出しを担当するテストヘルパー)し、期待通り違反が検出されることをアサートします。該当コード箇所は extensions
配列("rs","toml",...)と linter 実行を行うテストヘルパー(既存のテストで使っている run_lint/execute_tool
相当の関数名)を使って、config.toml に違反となるサンプルを書き込み、違反メッセージが返ることを検証するように実装してください。
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 7413deb6-f185-4dbc-b287-34a6902d592b
📒 Files selected for processing (6)
docs/local-llm-offload-analysis.mddocs/todo-summary.mddocs/todo7.mddocs/todo8.mdsrc/hooks-post-tool-comment-lint-rust/src/main.rssrc/hooks-post-tool-linter/src/main.rs
💤 Files with no reviewable changes (1)
- docs/todo7.md
…ions + Bundle k post-merge-feedback (#152) * docs(todo): PR #151 post-merge-feedback ★ Bundle k — 5 件採用 (順位 123-127) ## 採用 5 件 (Tier 1 #1+#2 / Tier 2 #1 / Tier 3 #1+#2) ### Tier 1 (決定論的防止層) - 順位 123 (Bundle k コア): lint-screen の Markdown ファイル除外フィルター追加 (M, Frequency High) - D-3/D-4/D-5 で 3 PR・4 push 一貫観測の mistral:7b による .md → Rust hallucinate FP を構造的に解消 - 順位 124: no-ephemeral-todo-reference rule の TOML positive test 追加 (S, Frequency Medium) ### Tier 2 (横展開) - 順位 125: UTF-8 マルチバイト boundary test を他の string-processing hooks に横展開 (M, Frequency Medium) - PR #151 で発見した byte_offset_to_line char-boundary panic bug の systemic 防御 ### Tier 3 (docs/comment 明文化) - 順位 126 (順位 123 と同 PR 推奨): ADR-038 に mistral:7b 「diff 外 context hallucinate」failure mode を追記 (XS, Frequency High) - 順位 127 (順位 124 と同 PR 推奨): extensions 拡張時の test 追加 pattern をコード comment で明文化 (XS, Frequency Medium) ## Sub-PR 構成推奨 - k-1: 順位 123 + 126 (実装 + ADR codify、コア層) - k-2: 順位 124 + 127 (TOML test + extensions code comment、test gap 補強層) - k-3: 順位 125 (UTF-8 boundary 横展開、独立) ## 却下 (4 件) / 様子見 (3 件) 却下: UTF-8 lint rule (FP リスク + AST 必須) / byte_offset_to_line 強化 (既対応) / UTF-8 guideline + extensions checklist (feedback_no_unenforced_rules.md 適用) 様子見: lint-screen dogfood CI step (L + takt infra 依存) / test→bug pattern を ADR-007 (1 PR 観測) / multi-rule fixture pattern を test comment (Low × Low) ## 含意 Phase D dogfood 観測 (docs/local-llm-offload-analysis.md L334-340 の docs-only FP failure mode 記述) が 直接 actionable な決定論的防止層 (順位 123) に結実。Phase E 採否判定前に systemic FP root cause が 解消される構造的進展。 * feat(takt-facet): D-6 — refresh .takt/review-diff.txt between fix and review iterations (順位 51)
…時 test 追加 reminder comment (順位 124 + 127) (#163) ## 順位 124 (Tier 1): TOML positive + negative test 追加 PR #151 T1-#1 採用、PR #152 で再観測 (Frequency Medium)。 既存 `no_ephemeral_todo_self_exclusion_invariant_holds_on_deployed_toml` は self-exclusion 不変条件のみ確認、TOML での検出力 test が不在だった gap を 構造的に塞ぐ: - `no_ephemeral_todo_detects_toml_ephemeral_reference`: TOML + ephemeral 参照 → 1 violation 検出 (positive) - `no_ephemeral_todo_toml_skips_permanent_adr_reference`: TOML + ADR 参照 → 0 violation (negative、pattern 正確性も seal) self-trigger 回避: fixture content は既存 `build_concrete_digit_fixture(3)` (format! interpolation) を再利用。 ## 順位 127 (Tier 3): extensions 拡張時 test 追加義務の comment 明文化 PR #151 T3-#2 採用、PR #152 で再観測。 `.claude/custom-lint-rules.toml` の `no-ephemeral-todo-reference` rule 上に 9 行のコメントブロックを追加: extensions 変更時は同 PR で positive/negative test を追加することを次回 rule 編集者の目に入る位置に置く。 `feedback_no_unenforced_rules.md` 例外 = 既存実践の明文化 + guide 効果 (機械強制ではなく point-of-edit reminder)。 ## 検証 - cargo test -p hooks-post-tool-linter: 121 passed / 0 failed - 新規 2 test (positive / negative) を含む 8 tests (no_ephemeral_todo 系列) 全通過 ## Net 差分 - `.claude/custom-lint-rules.toml`: +9 lines (reminder comment) - `docs/todo-summary.md`: -2 lines (順位 124 + 127 削除) - `docs/todo8.md`: -44 lines (詳細 entries 削除) - `src/hooks-post-tool-linter/src/main.rs`: +41 lines (2 test + doc comment) production code path 変更なし。exe rebuild 不要。
Summary
Phase D Round 2 の D-5 (順位 56 + 119 bundle) 実装 + dogfood 観測。
コード変更 (commit 5cbed3c)
hooks-post-tool-comment-lint-rust: UTF-8 multi-byte test 5 パターン + block comment boundary test 6 パターン + direct unit test 1 件追加 (計 12 tests)hooks-post-tool-linter: MAX_CUSTOM_VIOLATIONS outer/inner loop break scope explicit test 2 件追加byte_offset_to_lineの char-boundary panic を解消 (UTF-8 multi-byte 文字で終わる needle で panic していた production bug)Test
Phase D D-5 dogfood 観測 (3 push events で 3 data points)
詳細は docs/local-llm-offload-analysis.md の D-5 outcome 節を参照。
Test plan
Summary by CodeRabbit
リリースノート
ドキュメント
テスト
機能拡張