Skip to content

feat(hooks): Bundle c c-2 — exe-help-block preset + pipe truncate ガイド (順位 65 + 66)#166

Merged
aloekun merged 2 commits into
masterfrom
bundle-c-c2-exe-help-block
May 20, 2026
Merged

feat(hooks): Bundle c c-2 — exe-help-block preset + pipe truncate ガイド (順位 65 + 66)#166
aloekun merged 2 commits into
masterfrom
bundle-c-c2-exe-help-block

Conversation

@aloekun
Copy link
Copy Markdown
Owner

@aloekun aloekun commented May 20, 2026

Summary

Bundle c の trigger 防止層 (c-2) を land。PR #109 SIGPIPE 事故の再発を 2 層で構造的に防ぐ。

  • 順位 65 (Tier 1 / S) — 決定論層: hooks-pre-tool-validateexe-help-block preset 追加。本リポジトリの Rust 製 exe + 単独 --help|-h|/? を PreToolUse で block し、src/<exe-name>/src/main.rs Read への代替誘導メッセージを返す
  • 順位 66 (Tier 3 / XS) — 判断ガイド層: ~/.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-block preset (src/hooks-pre-tool-validate/src/main.rs +170)

  • regex: コマンド境界 + (env prefix)* + (path prefix)? + <name>.exe + 単独 --help|-h|/?
  • subcommand 形式 (exe foo --help) は対象外 (TP/FP 設計)
  • 17 件の unit test 追加 (既存 122 件 + 新 17 = 139 件全 pass)
    • TP: 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 / pipe
    • FP guard: subcommand help / cargo run --help / gh pr view --help / pnpm build --help / --version / 引数なし
  • default config (設定ファイル無し) では opt-in にしない (後方互換、既存リポジトリへの影響回避)
  • 実機 dogfood で block (exit 2 + メッセージ) と allow (exit 0) を確認

順位 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 ...)
  • 許容パターン: 短命確認コマンド + truncate / --jq --json 抽出 / > /dev/null 破棄 / run_in_background
  • 由来: PR feat(docs): ADR-035 docs-only PR 評価ポリシー集約 (順位 59/31/32) #109 SIGPIPE 事故と順位 65 決定論層との補完関係を明記

todo cleanup

  • docs/todo-summary.md: 順位 65 / 66 の table エントリ削除 (-2 行)
  • docs/todo7.md: 詳細 entry 削除 (-96 行)
  • Bundle c narrative (line 106) は永続的な設計説明として残置 (Sub-PR 分割推奨ルール dogfood case)

Test plan

  • cargo test -p hooks-pre-tool-validate — 139 件全 pass (新 17 件 + 既存 122 件)
  • 実機 dogfood: cli-merge-pipeline.exe --help → exit 2 で block + 適切なメッセージ
  • 実機 dogfood: cargo run --help → exit 0 で許可 (FP なし)
  • markdownlint: 全変更 file で 0 errors
  • pre-push review (takt): APPROVE
  • 派生プロジェクト (techbook-ledger / auto-review-fix-vc) への deploy は別途 pnpm deploy:hooks

Known follow-ups

  • W-1 (pre-push reviewer 指摘 / Warning): 現 regex は notepad.exe --help 等の system exe も match するが block メッセージは「本リポジトリの Rust 製 exe」と謳っている。scope を .claude path prefix または (cli|hooks|check)- name prefix に narrow する候補あり (次 PR or post-merge-feedback で議論)

Summary by CodeRabbit

  • 新機能

    • Rust製実行ファイルに対する単独のヘルプオプション呼び出し(--help/-h/?)を検出してブロックし、ソースコードの確認へ誘導する動作を追加しました。
  • ドキュメント

    • 完了済みと判断された2件のタスク記述をドキュメントから削除しました。

Review Change Stack

… (順位 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 から両エントリを削除。
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 20, 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: bf0ae22f-f9f4-4bc2-8d92-02354b12b321

📥 Commits

Reviewing files that changed from the base of the PR and between 596def1 and bd8ff96.

📒 Files selected for processing (1)
  • src/hooks-pre-tool-validate/src/main.rs

📝 Walkthrough

Walkthrough

.exe に対する単独の --help/-h/? 呼び出しをブロックする exe-help-block プリセットを設定・実装・テストし、対応する完了タスクをドキュメントから削除します。

Changes

exe-help-block プリセット実装

Layer / File(s) Summary
プリセット設定と有効化
.claude/hooks-config.toml, src/hooks-pre-tool-validate/src/main.rs
exe-help-block の説明コメントを hooks-config.toml に追加(30-32行)し、blocked_patterns 配列に登録(44行)。build_blocked_patterns"exe-help-block" 分岐を追加して有効化(430行)。
ブロック検出ロジック実装
src/hooks-pre-tool-validate/src/main.rs
preset_exe_help_block() を実装(333-372行)。.exe の単独 --help/-h/? を正規表現で検出して固定メッセージでブロックするロジックを追加。
ブロック条件の検証テスト
src/hooks-pre-tool-validate/src/main.rs
exe-help-block の多数のテストを追加(1065-1198行)。単独 help のブロック、サブコマンド help や --version、無関係 exe、設定未指定時の非ブロックを検証。
完了タスクのドキュメント削除
docs/todo-summary.md, docs/todo7.md
PR #109 対応完了に伴い docs/todo7.md の該当 TODO セクション(265-266行)を削除し、docs/todo-summary.md の対応エントリ(47-48行)も削除。

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

🚥 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タイトルは主要な変更内容(exe-help-blockプリセット追加と順位番号)を正確に反映しており、同じブランチから複数変更を束ねた内容を簡潔に記述している。
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.

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: 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

📥 Commits

Reviewing files that changed from the base of the PR and between 04559e7 and 596def1.

📒 Files selected for processing (4)
  • .claude/hooks-config.toml
  • docs/todo-summary.md
  • docs/todo7.md
  • src/hooks-pre-tool-validate/src/main.rs
💤 Files with no reviewable changes (2)
  • docs/todo7.md
  • docs/todo-summary.md

Comment thread src/hooks-pre-tool-validate/src/main.rs Outdated
Resolved findings:
- [Major] src/hooks-pre-tool-validate/src/main.rs:367 `.exe` ブロックの対象範囲が広すぎます
@aloekun
Copy link
Copy Markdown
Owner Author

aloekun commented May 20, 2026

@coderabbitai review

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 20, 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 768712c into master May 20, 2026
1 check passed
@aloekun aloekun deleted the bundle-c-c2-exe-help-block branch May 20, 2026 08:09
aloekun added a commit that referenced this pull request May 21, 2026
…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 の優先順位に影響なし。
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