feat(hooks): Bundle c c-2 — exe-help-block preset + pipe truncate ガイド (順位 65 + 66)#166
Conversation
… (順位 65 + 66) PR #109 SIGPIPE 事故の再発を構造的に防ぐ 2 層対策: 順位 65 (決定論層): - hooks-pre-tool-validate に exe-help-block preset 追加 - 本リポジトリの Rust 製 exe (.claude/*.exe) + 単独 --help/-h/? を block - src/<exe-name>/src/main.rs Read への代替誘導メッセージ - TP/FP 17 件の unit test (subcommand help / cargo run --help / gh pr view --help 等の FP guard) - 既存 139 件全 pass - .claude/hooks-config.toml に preset opt-in 登録 + 実機 dogfood で block/allow 確認 順位 66 (判断ガイド層): - ~/.claude/rules/common/development-workflow.md に「長時間 subprocess の出力 pipe truncate 禁止」section 追加 - 対象 (副作用 / rate-limit 中の長時間化) と許容パターン (短命 / --jq / >/dev/null / run_in_background) を明示 - 順位 65 で塞げない gray zone (例: rate-limit 中の gh api ... | head) を AI 判断で回避 Bundle c c-1 (Drop guard + reaper + ADR-030 拡張) は PR #154 で land 済、 本 PR で c-2 (trigger 防止層) を land して Bundle c 完了。 todo7.md / todo-summary.md から両エントリを削除。
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthrough
Changesexe-help-block プリセット実装
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 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. ✨ 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.
Actionable comments posted: 1
🤖 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.
Inline comments:
In `@src/hooks-pre-tool-validate/src/main.rs`:
- Around line 366-367: The regex literal
r#"(?im)(^|&&|;|\|\||\||&|\n)\s*(?:[A-Za-z_][A-Za-z0-9_]*=\S+\s+|command\s+|env\s+)*(?:\S*?[/\\])?[\w-]+\.exe\s+(?:--help|-h|/\?)(\s|$)"#
is too broad and matches any .exe --help (including system tools); narrow it to
only match executables from this repo by requiring either a .claude/ path
segment or specific allowed exe name prefixes (e.g.,
^(?:claude|myrepoprefix)[\w-]*\.exe) in the pattern used in main.rs so the check
only blocks repo-local Rust-built exes; update the regex in main.rs accordingly
and ensure the existing surrounding capture groups (prefix operators and flags
like --help) remain intact.
🪄 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: 19e123ba-e18c-4978-9a38-ec218f3db666
📒 Files selected for processing (4)
.claude/hooks-config.tomldocs/todo-summary.mddocs/todo7.mdsrc/hooks-pre-tool-validate/src/main.rs
💤 Files with no reviewable changes (2)
- docs/todo7.md
- docs/todo-summary.md
Resolved findings: - [Major] src/hooks-pre-tool-validate/src/main.rs:367 `.exe` ブロックの対象範囲が広すぎます
|
@coderabbitai review |
✅ Actions performedReview triggered.
|
…e-feedback 3 件統合) (#167) * docs(todo): 順位 139 新規追加 — PR #166 post-merge-feedback 採用 (exe-help-block system exe FP negative test) * test(hooks-pre-tool-validate): 順位 139 — exe-help-block system exe negative test 追加 PR #166 post-merge-feedback で 3 独立ソース (PR diff / Session / Pre-push:simplicity) で同時指摘された systemic pattern への対策。takt-fix で regex は `(?:cli-[\w-]+|hooks-[\w-]+|check-ci-[\w-]+)\.exe` に narrowed 済だが、 既存 `exe_help_block_allows_unrelated_exe` は `foo.exe` の架空名のみで実在 system exe を未検証。将来 regex を broad pattern に戻した場合の silent regression を test 層で明示的に検出する目的で、cargo/python/node/notepad の 4 件 negative test を追加。 * test(hooks-post-tool-linter): 順位 121 — takt_workflow_persona 3 fields 個別 fixture test 追加 + doc 修正 PR #150 CR Major fix で persona: alternation に追加された 4 fields のうち、 従来 regression test は `required_permission_mode` の 1 case のみで、 doc comment は「4 fields regression test」と主張しつつ実態と乖離していた。 本 commit で: - 既存 `takt_workflow_persona_detects_required_permission_mode_violation` の doc を 実態に合わせて「代表 case」表現に修正、残り 3 fields は個別 test で検証する旨を明記 - `pass_previous_response` / `output_contracts` / `parallel` の個別 fixture test を追加 - `.claude/custom-lint-rules.toml` の `[rules.test_coverage.main_ext_tests.yaml]` に 3 件の新 test 名を登録 (rule test coverage check で機械強制される宣言) 将来 alternation から個別 field を誤って削除した場合に test fail で検出される safety net を確保。 (順位 121、PR #150 T2-#1 採用) * docs(adr): 順位 120 — rule⑨ コメント拡張 + ADR-007 に enumeration-based pattern case study 追記 PR #150 CR Major fix で「persona: alternation の列挙漏れ」が発生した経験を踏まえ、 takt yaml schema 拡張時の rule 更新フローを 2 箇所に codify: (1) `.claude/custom-lint-rules.toml` rule⑨ 上部に「Field 拡張手順」4 ステップを追記 (grep で sibling field を抽出 → alternation 追加 → test helper 追加 → fixture test + [rules.test_coverage] 宣言追加 → cargo test 確認) (2) `docs/adr/adr-007-custom-linter-layer-boundary.md` に Case study section を追加 (Rust regex の lookahead 非対応 → enumeration-based negation 採用の判断経緯 + 列挙漏れリスクへの多層防御 + 同型 rule 設計時の checklist) 順位 121 (個別 fixture test) と 順位 120 (本 commit) で「規約 → test → 保守手順」の 3 層が完成し、次回 takt yaml schema 拡張時の rule 更新フローが文書化される。 (順位 120、PR #150 T1-#1 採用、analyzer Tier 1 → ユーザー判断で Tier 3 reclassify) * docs(todo): 順位 120 / 121 / 139 完了に伴い削除 (Bundle l land) PR #150 + #166 post-merge-feedback 採用 3 件 (Bundle l: Custom lint rule test gap closure) が同 PR で land 完了したため、対応する todo entry を削除: - 順位 139 (exe-help-block system exe negative test): commit 3049f56 で 4 件 negative test 追加 - 順位 121 (takt_workflow_persona 3 fields fixture test): commit bfab173 で 3 件 fixture test 追加 + doc 修正 + .claude/custom-lint-rules.toml の [rules.test_coverage.main_ext_tests.yaml] 宣言更新 - 順位 120 (rule⑨ コメント拡張 + ADR-007 case study): commit a2df865 で field 拡張手順 4 ステップ追記 + ADR-007 に enumeration-based pattern case study section 追加 todo-summary.md / todo8.md から該当 entry を一括削除。残存 task の優先順位に影響なし。
Summary
Bundle c の trigger 防止層 (c-2) を land。PR #109 SIGPIPE 事故の再発を 2 層で構造的に防ぐ。
hooks-pre-tool-validateにexe-help-blockpreset 追加。本リポジトリの Rust 製 exe + 単独--help|-h|/?を PreToolUse で block し、src/<exe-name>/src/main.rsRead への代替誘導メッセージを返す~/.claude/rules/common/development-workflow.mdに「長時間 subprocess の出力 pipe truncate 禁止」section 追加。決定論層で塞げない gray zone (例: rate-limit 中のgh api ... | head) を AI 判断で回避するための補完Bundle c c-1 (Drop guard + reaper + ADR-030 拡張) は PR #154 で land 済。本 PR で c-2 を land して Bundle c 完了。
変更内容
順位 65:
exe-help-blockpreset (src/hooks-pre-tool-validate/src/main.rs +170)<name>.exe+ 単独--help|-h|/?exe foo --help) は対象外 (TP/FP 設計)cli-merge-pipeline.exe --help/./.claude/cli-merge-pipeline.exe -h/.claude/check-ci-coderabbit.exe --help/e:\work\.claude\...\.exe --help/ chain / env prefix / pipecargo run --help/gh pr view --help/pnpm build --help/--version/ 引数なしdefaultconfig (設定ファイル無し) では opt-in にしない (後方互換、既存リポジトリへの影響回避)順位 66: pipe truncate 禁止ルール (~/.claude/rules/common/development-workflow.md +30)
cli-merge-pipeline.exe/pnpm push/ takt 系) + rate-limit 中に長時間化する読み取りプロセス (gh pr view --json reviews/gh api ...)--jq--json抽出 /> /dev/null破棄 /run_in_backgroundtodo cleanup
docs/todo-summary.md: 順位 65 / 66 の table エントリ削除 (-2 行)docs/todo7.md: 詳細 entry 削除 (-96 行)Test plan
cargo test -p hooks-pre-tool-validate— 139 件全 pass (新 17 件 + 既存 122 件)cli-merge-pipeline.exe --help→ exit 2 で block + 適切なメッセージcargo run --help→ exit 0 で許可 (FP なし)pnpm deploy:hooksKnown follow-ups
notepad.exe --help等の system exe も match するが block メッセージは「本リポジトリの Rust 製 exe」と謳っている。scope を.claudepath prefix または(cli|hooks|check)-name prefix に narrow する候補あり (次 PR or post-merge-feedback で議論)Summary by CodeRabbit
新機能
ドキュメント