Skip to content

test(hooks): Bundle k-2 — TOML positive/negative test + extensions reminder#163

Merged
aloekun merged 1 commit into
masterfrom
test/bundle-k-2-toml-tests
May 18, 2026
Merged

test(hooks): Bundle k-2 — TOML positive/negative test + extensions reminder#163
aloekun merged 1 commit into
masterfrom
test/bundle-k-2-toml-tests

Conversation

@aloekun
Copy link
Copy Markdown
Owner

@aloekun aloekun commented May 18, 2026

Summary

Bundle k-2: PR #155 (Bundle k-1) の続編として、no-ephemeral-todo-reference rule の test gap 補強 + extensions 変更時 reminder の 2 タスクを bundled で land。

  • 順位 124 (🚀 Tier 1, S): TOML positive + negative test 追加 — 既存 self-exclusion 不変条件 test が検出力 test を含んでおらず、TOML 拡張子で rule が機能することの explicit な seal が不在だった gap を塞ぐ
  • 順位 127 (💎 Tier 3, XS): extensions 拡張時 test 追加義務を .claude/custom-lint-rules.toml の rule 上に reminder comment として明文化 — point-of-edit reminder

背景

no-ephemeral-todo-reference rule の extensions に対する test gap が複数 PR で反復観測 されてきた pattern (Frequency Medium / 4 PR 観測):

本 Bundle k-2 は test gap を closing。Bundle k-1 (実装層) + k-2 (test 層) + k-3 (UTF-8 横展開、todo 順位 125、別 PR 予定) の 3 層分割の中段。

変更内容

ファイル 変更 内容
.claude/custom-lint-rules.toml +9 順位 127: extensions 変更時 test 追加 reminder block
src/hooks-post-tool-linter/src/main.rs +41 順位 124: no_ephemeral_todo_detects_toml_ephemeral_reference + no_ephemeral_todo_toml_skips_permanent_adr_reference
docs/todo-summary.md -2 順位 124 + 127 table 行削除
docs/todo8.md -44 順位 124 + 127 詳細 entry 削除

Net: +4 lines (test code 41 増、docs 46 減、TOML 9 増)

検証

cargo test -p hooks-post-tool-linter121 passed / 0 failed

no_ephemeral_todo 系列 8 tests 全通過:

  • 新規: no_ephemeral_todo_detects_toml_ephemeral_reference (positive)
  • 新規: no_ephemeral_todo_toml_skips_permanent_adr_reference (negative)
  • 既存 6 tests に regression なし

設計判断

Test fixture の self-trigger 回避

最初 positive test の fixture に literal docs/todo3.md を書いて、まさに rule が想定する meta-case (永続成果物 = Rust source → ephemeral 参照) を踏んだ。
解決: 既存 helper build_concrete_digit_fixture(3) を再利用 — format! interpolation で literal pattern が source に出現しない設計。本リポジトリの self-exclusion 標準パターン (.claude/custom-lint-rules.toml rule⑥ 冒頭コメントに記載)。

build_concrete_digit_fixture(3)3digit 番号 (= docs/todo3.md の 3) であって violation count ではない。violations.len() == 1 のアサートは 1 件の ephemeral 参照から 1 violation が返ることを check する意図で整合。

Positive と Negative の fixture 構築非対称性

positive test は ephemeral 参照生成 helper を使い、negative test (docs/adr/...) はインライン構築。意図的に非対称:

  • helper は ephemeral 参照生成専用 (self-trigger 回避の責務)
  • permanent 参照 fixture は literal で書いても rule は fire しないので self-trigger 懸念なし → インラインの方が test 単独で意図が読みやすい

memory rule feedback_test_dry_antipattern.md (テストの DRY は適用しない、独立性優先) に沿った判断。

Non-doc comment 削除

Bundle Z #B-α (非 doc コメント禁止) の lint 層により、test 内の // comment は block される。最終的に既存 test と同じ「コメントなし、build_* helper 名で意図を表現」スタイルに収束。

takt pre-push-review

  • APPROVED (1 iteration / 3m20s)
  • Blocking anomalies: 0
  • Non-blocking notes: 0
  • reviewer が positive/negative test の非対称性、build_concrete_digit_fixture(3) の digit 解釈、todo cleanup の atomicity を独立 validate

Test plan

  • cargo test -p hooks-post-tool-linter: 121 passed
  • takt pre-push-review: APPROVED
  • CI green (post-push)
  • CodeRabbit に actionable comments がない

Summary by CodeRabbit

  • Documentation

    • ドキュメントのタスク追跡情報を更新しました。
  • Tests

    • ルール検証用のテストケースを追加しました。
  • Chores

    • ルール拡張時の注意事項をコメントで明記しました。

Review Change Stack

…時 test 追加 reminder comment (順位 124 + 127)

## 順位 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 不要。
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 18, 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: b51376b1-9721-4341-8548-a71ac73c4bcf

📥 Commits

Reviewing files that changed from the base of the PR and between 9942e46 and 55ceed9.

📒 Files selected for processing (4)
  • .claude/custom-lint-rules.toml
  • docs/todo-summary.md
  • docs/todo8.md
  • src/hooks-post-tool-linter/src/main.rs
💤 Files with no reviewable changes (2)
  • docs/todo8.md
  • docs/todo-summary.md

📝 Walkthrough

Walkthrough

PR #163no_ephemeral_todo_reference_rule に対して TOML ファイル拡張子のサポートテストを追加し、extensions 変更時の テスト追加規約をカスタムリント設定にコメント化し、対応済み TODO エントリを削除します。

Changes

TOML カスタムルール拡張テストと規約

Layer / File(s) Summary
no_ephemeral_todo_reference_rule の TOML positive/negative テスト
src/hooks-post-tool-linter/src/main.rs
config.toml に含まれるエフェメラル TODO 参照(docs/todo3.md)を 1 件検出する positive テストと、permanent な ADR 参照(docs/adr/adr-...)が検出されない negative テストを追加。既存の検出ロジックは変更なし。
Extensions 変更時のテスト追加規約をコメント化
.claude/custom-lint-rules.toml
no_ephemeral_todo_reference_rule 定義に、extensions 追加/削除時は同一 PR で positive/negative テスト系列を追加すべき旨の注意書きコメントを挿入し、サイレント検出力回帰のリスクを明文化。
対応済み TODO エントリの削除
docs/todo-summary.md, docs/todo8.md
PR #151 で実装・完了した「TOML positive test 追加」と「extensions 拡張時テスト追加パターン明文化」タスクを削除。推奨実行順序サマリーテーブルは順位 125 を保持。

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

Possibly related PRs

  • aloekun/claude-code-hook-test#151: 当 PR の TOML positive/negative テスト追加は、retrieved PR #151 で実装された no-ephemeral-todo-reference ルール(.claude/custom-lint-rules.toml 内 extensions 設定)に対する直接的なテストカバレッジ拡張のため。
  • aloekun/claude-code-hook-test#141: 当 PR の no_ephemeral_todo_reference_rule TOML テスト追加が、retrieved PR #141 で導入された no-ephemeral-todo-reference self-exclusion invariant テスト領域と同じルール内でテストを拡張するため。
  • aloekun/claude-code-hook-test#110: Retrieved PR #110 で初期導入された no-ephemeral-todo-reference ルール定義に対して、当 PR が TOML 拡張子対応のテストカバレッジを追加するため。
🚥 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 プルリクエストのタイトルは、TOML 形式のポジティブ/ネガティブテストの追加と extensions 拡張時のリマインダーコメント追加という 2 つの主要な変更内容を正確に反映しており、変更セットの核心を明確に要約しています。
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.

@aloekun aloekun merged commit 6f2f250 into master May 18, 2026
1 check passed
@aloekun aloekun deleted the test/bundle-k-2-toml-tests branch May 18, 2026 05:50
aloekun added a commit that referenced this pull request May 19, 2026
…ule-test coverage check + global testing.md 明文化)

PR #163 (Bundle k-2) merge 後の post-merge-feedback で 2 件採用された follow-up
task を todo 系列に登録。

## 順位 137 (Tier 1, M, Frequency High)

Rule-Test Coverage Check Cargo test。
`.claude/custom-lint-rules.toml` の各 rule の extensions ⇔
`src/hooks-post-tool-linter/src/main.rs` の test 関数名を mechanical に検証
する Cargo test step を追加する。

由来: PR #110/#151/#152/#155 の 4 PR 観測 (Frequency High)、PR #163 で順位 127
として passive reminder comment を追加したが、analyzer が「passive reminder
では PR #152 同根再発を防止できなかった実証ベース → mechanical enforcement
が必要」と判定。

必須カバレッジ scope (CodeRabbit Minor 指摘で確定): 主要 ext rs/toml/yaml/yml ×
全 rule に対応 test 必須、その他 ext (jsonc/json/ts/tsx/js/jsx/py/ps1) は
rule あたり positive single test 1 件以上で代替。完了基準と詰まっている箇所
の scope drift を fix。

## 順位 138 (Tier 3, XS, Frequency High)

Rule Extension Test Pattern を `~/.claude/rules/common/testing.md` に明文化。
順位 137 (mechanical Cargo test) と 2 層構成。`~/.claude/` global 配下のため
派生プロジェクト (techbook-ledger / auto-review-fix-vc) へ自動波及。

## land 順序の推奨

順位 137 + 138 は同 PR で land 推奨 (命名規約 + 必須 ext scope 決定が
atomic に整う、cross-reference が同 commit で完結)。

## 補正事項

analyzer report は target を `src/cli-custom-linter/src/main.rs` と記載
していたが、実際の crate 名は `hooks-post-tool-linter` のため詳細 entry
で補正済。

## CodeRabbit review 反映

PR review (PR #164 round 1) で順位 137 の「完了基準」(全 (rule, ext) ペア必須)
と「詰まっている箇所」(主要 ext に絞った coverage 推奨) の scope drift を
🟡 Minor で指摘。修正方針:

- 完了基準を 主要 ext (rs/toml/yaml/yml) × 全 rule 必須 + その他 ext は
  rule あたり single positive test で代替、と明示
- 設計決定 section に必須カバレッジ scope を追加 (順位 138 testing.md と
  同一 commit で codify することで cross-reference の atomicity 確保)
- 詰まっている箇所 から該当議論を削除、TOML meta field vs 命名規約方式の
  trade-off のみ残す (= 順位 138 実装時に確定する補助 design 議論)

## docs only

実装は別 PR で着手予定。
aloekun added a commit that referenced this pull request May 19, 2026
…ule-test coverage check + global testing.md 明文化) (#164)

PR #163 (Bundle k-2) merge 後の post-merge-feedback で 2 件採用された follow-up
task を todo 系列に登録。

## 順位 137 (Tier 1, M, Frequency High)

Rule-Test Coverage Check Cargo test。
`.claude/custom-lint-rules.toml` の各 rule の extensions ⇔
`src/hooks-post-tool-linter/src/main.rs` の test 関数名を mechanical に検証
する Cargo test step を追加する。

由来: PR #110/#151/#152/#155 の 4 PR 観測 (Frequency High)、PR #163 で順位 127
として passive reminder comment を追加したが、analyzer が「passive reminder
では PR #152 同根再発を防止できなかった実証ベース → mechanical enforcement
が必要」と判定。

必須カバレッジ scope (CodeRabbit Minor 指摘で確定): 主要 ext rs/toml/yaml/yml ×
全 rule に対応 test 必須、その他 ext (jsonc/json/ts/tsx/js/jsx/py/ps1) は
rule あたり positive single test 1 件以上で代替。完了基準と詰まっている箇所
の scope drift を fix。

## 順位 138 (Tier 3, XS, Frequency High)

Rule Extension Test Pattern を `~/.claude/rules/common/testing.md` に明文化。
順位 137 (mechanical Cargo test) と 2 層構成。`~/.claude/` global 配下のため
派生プロジェクト (techbook-ledger / auto-review-fix-vc) へ自動波及。

## land 順序の推奨

順位 137 + 138 は同 PR で land 推奨 (命名規約 + 必須 ext scope 決定が
atomic に整う、cross-reference が同 commit で完結)。

## 補正事項

analyzer report は target を `src/cli-custom-linter/src/main.rs` と記載
していたが、実際の crate 名は `hooks-post-tool-linter` のため詳細 entry
で補正済。

## CodeRabbit review 反映

PR review (PR #164 round 1) で順位 137 の「完了基準」(全 (rule, ext) ペア必須)
と「詰まっている箇所」(主要 ext に絞った coverage 推奨) の scope drift を
🟡 Minor で指摘。修正方針:

- 完了基準を 主要 ext (rs/toml/yaml/yml) × 全 rule 必須 + その他 ext は
  rule あたり single positive test で代替、と明示
- 設計決定 section に必須カバレッジ scope を追加 (順位 138 testing.md と
  同一 commit で codify することで cross-reference の atomicity 確保)
- 詰まっている箇所 から該当議論を削除、TOML meta field vs 命名規約方式の
  trade-off のみ残す (= 順位 138 実装時に確定する補助 design 議論)

## docs only

実装は別 PR で着手予定。
aloekun added a commit that referenced this pull request May 19, 2026
…le 137+138) (#165)

* feat(lint): rule-test coverage check cargo test + global testing.md codify (Bundle 137+138, TOML meta field 方式)

- src/hooks-post-tool-linter/src/main.rs:
  - CustomRule に test_coverage: Option<CustomRuleTestCoverage> field 追加
  - rule_test_coverage_check cargo test 新規 (helper 4 関数に分割)
    - load_deployed_custom_rules / extract_existing_test_fn_names
    - classify_rule_extensions / check_main_ext_coverage / check_other_ext_coverage / check_main_ext_keys_sanity
    - collect_rule_coverage_gaps
  - test gap 補填 (合計 +7 tests, 121 → 128):
    - rule② (no-personal-paths): positive×2 + negative×1 (元 0 tests, 配布後初の検証)
    - rule⑥ (no-ephemeral-todo-reference) yaml: positive×1 + negative×1
    - rule⑥ (no-ephemeral-todo-reference) yml: positive×1

- .claude/custom-lint-rules.toml:
  - 全 10 rule に [rules.test_coverage] meta field を宣言
  - 主要拡張子 (rs/toml/yaml/yml) を targets する rule は main_ext_tests.<ext> で各 ext に 1+ test を明示
  - 非主要専用 rule は other_ext_tests でカバレッジ宣言

- ~/.claude/rules/common/testing.md (グローバル):
  - 新 section 'Custom Lint Rule Test Coverage' を追加
  - 命名規約 vs TOML meta field の trade-off と採用根拠 (案 b) を codify
  - 派生プロジェクト (techbook-ledger / auto-review-fix-vc) へ自動波及

順位 137 + 138 (PR #163 post-merge-feedback T1-#1 + T3-#1 採用)。命名規約に依存しない明示的 mapping を採用したのは AI 生成の揺らぎを構造的に抑止する意図 (ユーザー指示)。

* docs(todo): 順位 137 + 138 完了に伴い削除 (Bundle 137+138 land)

- docs/todo-summary.md: 行 137 + 138 を削除 (table)
- docs/todo8.md: 順位 137/138 entry block を削除 (合計 90 行 -)

PR 本作業 (@-: feat(lint) commit) で実装 + ドキュメント codify が land したため、todo entries を片付け。
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