Skip to content

feat(hooks): Phase D D-5 — comment-lint test 拡充 + MAX cap break scope test#151

Merged
aloekun merged 2 commits into
masterfrom
d5-comment-lint-test-expansion
May 13, 2026
Merged

feat(hooks): Phase D D-5 — comment-lint test 拡充 + MAX cap break scope test#151
aloekun merged 2 commits into
masterfrom
d5-comment-lint-test-expansion

Conversation

@aloekun
Copy link
Copy Markdown
Owner

@aloekun aloekun commented May 13, 2026

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 件追加
  • 副産物 production bug fix: byte_offset_to_line の char-boundary panic を解消 (UTF-8 multi-byte 文字で終わる needle で panic していた production bug)

Test

  • comment-lint-rust: 85 passed / linter: 111 passed = 全 196 tests pass

Phase D D-5 dogfood 観測 (3 push events で 3 data points)

  • Push 1 (Rust diff 649 行): auto_fix + 1 FP (file 混同型 hallucinate)
  • Push 2 (docs-only 67 行): auto_fix + 1 FP (同 FP 再現 = mistral:7b が diff 外 hook source を見ている根拠)
  • Push 3 (docs-only 50 行): auto_fix + 1 FP (file 名を hallucinate、reviewer が "the report documents its own FP" と評価)
  • 累積 6 data points / 3 PR で ADR-038 採用条件先行充足、fallback 0/5 = 0%

詳細は docs/local-llm-offload-analysis.md の D-5 outcome 節を参照。

Test plan

  • cargo test 全 pass (196 tests)
  • cargo fmt / clippy clean
  • pre-push-review APPROVE (3 push events 全て 1-iter 収束)
  • lint_screen dogfood 観測完了 (3 data points)
  • CodeRabbit review (post-PR)

Summary by CodeRabbit

リリースノート

  • ドキュメント

    • 分析進捗と実装データを更新
    • タスク管理・推奨実行順序を最新状況に反映
  • テスト

    • 多言語・特殊文字に対応したテストカバレッジを拡充
    • カスタムルール動作の検証テストを追加
  • 機能拡張

    • TOML ファイルに対応する規則を追加

Review Change Stack

aloekun added 2 commits May 13, 2026 15:15
…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 観測予定。
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 13, 2026

📝 Walkthrough

Walkthrough

PR #151 は Phase D Round 2 の lint_screen 実測結果をドキュメントに記録し、D-5 で発見された UTF-8/byte_offset のバグを Comment Lint Rust hook で修正・テスト拡張、Linter hook で MAX_CUSTOM_VIOLATIONS キャップのテストカバレッジを強化し、no-ephemeral-todo-reference rule を toml ファイルへ拡張する変更をまとめたもの。

Changes

Phase D Round 2 進捗とUTF-8バグ修正

Layer / File(s) Summary
Phase D Round 2 進捗ドキュメント更新
docs/local-llm-offload-analysis.md, docs/todo-summary.md, docs/todo7.md, docs/todo8.md
local-llm-offload-analysis.md に Phase D Round 2 の state セクション、D-4(PR #150 merged)の dogfood outcome(2 回の push による informational/auto_fix のスクリーンショット結果)、D-5 の dogfood outcome(両方 auto_fix、false positive 再現、production bug fix 副産物)を追記。todo-summary.md・todo7.md から comment-lint hook テスト拡充タスク削除、todo8.md に PR #150 関連の 3 つの新規タスク(takt-workflow-persona コメント拡張+ADR-007 case study、permission_mode doc 修正+fixture テスト、development-workflow Step 0 チェック)を追加。
Comment Lint Rust の UTF-8/Multibyte バグ修正とテスト拡張
src/hooks-post-tool-comment-lint-rust/src/main.rs
D-5 で観測された byte_offset/UTF-8 境界バグを修正。byte_offset_to_lineas_bytes() スライスベースの実装に再構築し multibyte 文字の正確な行計算を実現。function_metriccollect_all_violations をリフォーマット。新たに 4 つのテストグループを追加:mixed ASCII+Kanji・emoji・combining characters での locate_string_line_ranges 検証、mid-multibyte offset での byte_offset_to_line 検証、multiline/inline block comment の range overlap(start/middle/end only 等)での find_violations 検証。

Linter ルール拡張とテストカバレッジ

Layer / File(s) Summary
MAX_CUSTOM_VIOLATIONS 上限キャップのテスト
src/hooks-post-tool-linter/src/main.rs
複数ルール間での MAX_CUSTOM_VIOLATIONS キャップ動作の 2 つの新規テストを追加。Outer break テストで最初のルール実行後のキャップ使い尽くしと後続ルール実行ブロック、inner cap テストで最初のルール部分消費後の次ルール実行を検証。
Linter ルール拡張とコード整形
src/hooks-post-tool-linter/src/main.rs
compile_paths_glob エラーマッピングをシングルライン化、build_violation_json の関数シグネチャと JSON 構築をマルチラインチェーン形式に再整形。複数の test helper 呼び出し(make_test_rulewrite_file)を整形。no-ephemeral-todo-reference rule の extensions"toml" を追加して toml ファイルへのマッチング対象を拡張。deployed custom rules テストを可読性向上のため再整形。

推奨される関連PR

  • aloekun/claude-code-hook-test#104: comment-lint-rust の byte_offset_to_line/find_violations range-filter リファクタリング・UTF-8/offset テスト拡張が PR #104 で導入された line_filter 仕組みの上に直接構築。
  • aloekun/claude-code-hook-test#148: Linter hook の compile_paths_glob/build_violation_json 変更が PR #148 の paths-filter 整備の直後に追加実装。
  • aloekun/claude-code-hook-test#141: no-ephemeral-todo-reference rule の extensions"toml" 追加と PR #141 の同ルール self-exclusion 回帰テスト(deployed TOML が自分自身で発火しない)が相互補完。

🎯 3 (Moderate) | ⏱️ ~25 minutes

🚥 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タイトルは「feat(hooks): Phase D D-5 — comment-lint test 拡充 + MAX cap break scope test」で、PR目標に完全に一致し、変更内容の主要部分(comment-lint テスト拡充と MAX_CUSTOM_VIOLATIONS の break scope テスト追加)を正確に反映している。
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.

🧹 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

📥 Commits

Reviewing files that changed from the base of the PR and between 39ae2cd and 1a69cc6.

📒 Files selected for processing (6)
  • docs/local-llm-offload-analysis.md
  • docs/todo-summary.md
  • docs/todo7.md
  • docs/todo8.md
  • src/hooks-post-tool-comment-lint-rust/src/main.rs
  • src/hooks-post-tool-linter/src/main.rs
💤 Files with no reviewable changes (1)
  • docs/todo7.md

@aloekun aloekun merged commit 6cfa8b2 into master May 13, 2026
1 check passed
@aloekun aloekun deleted the d5-comment-lint-test-expansion branch May 13, 2026 08:50
aloekun added a commit that referenced this pull request May 13, 2026
…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)
aloekun added a commit that referenced this pull request May 18, 2026
…時 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 不要。
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 24, 2026
…171)

* docs(todo): 順位 142 新規追加 — PR #170 T3-#1 採用 (ADR-041 補強: State Preservation Invariant pattern)

PR #170 post-merge-feedback の Tier 3 #1 採用結果として、ADR-041
(Test Isolation Patterns for Multi-Condition Guards) に新 section
"State Preservation Invariant" (once-set-never-overwritten) を
追記する task を 順位 142 として登録。

PR #168/169/170 で write-once 不変式 (state.fix_push_time.or_else(...)
形式) のテストカバレッジ漏れが連続観測されたことが trigger。ADR-041 既存
section は Multi-Condition Guards (early-return) のみで、write-once 不変式は
別 pattern class として未収録だったため補強する。順位 141 で takt-fix が
自動追加した 3 件の preservation test (poll.rs / monitor.rs) を参照実装と
して cite し、3 点セット test pattern (既存値あり / 新値提供 / preservation
確認) を明文化する。

* test(hooks-linter): UTF-8 multi-byte content での line 算出 defensive test 追加 (順位 125 採用)

PR #151 (T2-#1) で hooks-post-tool-comment-lint-rust の byte_offset_to_line を multi-byte
boundary test 拡充で production bug を発見した経験を横展開。hooks-post-tool-linter の
build_violation_json (L500) は content[..m.start()] による str slicing を行うが、
regex::Match::start() が char boundary を保証するため panic 安全。

本 test は line 算出 (.bytes().filter(|b| *b == b'\n').count() + 1) が multi-byte content
(日本語/emoji/結合文字) でも正しく動作することを empirical に seal する。将来 char_indices()
ベースへの書き換え等で line off-by-one regression が入った場合に検知する。

string-processing 系の hooks のうち他 (pre-tool-validate / session-start / stop-quality /
user-prompt-feedback-recovery / stop-feedback-dispatch) は as_bytes() を write 用途で
使用するのみで offset 操作を持たないため横展開 scope 外。

* test(hooks-comment-lint-rust): collect_all_violations の MAX_VIOLATIONS truncate contract test 追加 (順位 57 採用)

collect_all_violations (L551) は find_violations と find_function_length_violations の両 source を extend した後に truncate(MAX_VIOLATIONS) で合計を cap する設計。既存 cap test (max_violations_capped / function_length_violations_capped) は各 source 単体の cap のみ検証し、合算 truncate の contract が機械強制されていなかった gap を補填。

将来の lint 追加時に L562 の truncate(MAX_VIOLATIONS) を削除した regression (= 合計が MAX を超える) を catch する explicit 安全網。

fixture: 長 function (55 行 > MAX_FUNCTION_LINES=50) 1 件 + 非 doc コメント 25 行 → find_function_length_violations 1 件 + find_violations が cap で 20 件 → 合計 21 件 → truncate 後 20 件に cap される contract を assert。

* docs(todo): 順位 91 [lint_screen] config parse test を既実装発見で削除 (memory feedback_verify_task_not_already_done.md 適用)

PR #132 (Phase c MVP land = 2026-05-09) 直後の post-merge-feedback で entry 化された
順位 91 だが、本セッション着手前の jj log + 既存 test 確認で src/cli-push-runner/src/config.rs
の test module L325-481 に既に 5 件の lint_screen parse test が存在することを発見:

  - config_parses_with_lint_screen_section_full_fields (L326): 全 7 field deserialize
  - config_parses_with_lint_screen_section_minimal_only_enabled (L370): enabled=false でも Some 構築
  - config_lint_screen_section_absent_yields_none (L402): section 不在 → None
  - config_lint_screen_numeric_defaults_resolve_via_constants (L441): default 値 fallback
  - config_lint_screen_string_defaults_resolve_via_constants (L456): default 値 fallback

entry の作業計画 4 項目はすべてカバー済 (silent field rename 防止 / 全 field deserialize /
section 不在時 None / default 値検証)。post-merge-feedback で採用された後、別 PR で
先行 land 済だった可能性が高い。

memory rule feedback_verify_task_not_already_done.md (todo 着手前に既実装検証 → stale
entry を削除に再目的化) の正典的 dogfood 例として価値あり。Bundle i のペアタスク 順位 92
(scale-aware eval fixtures) は別タスクとして残し、bundle 表記は historical note 化。

- docs/todo6.md: 順位 91 entry (L13-39) 削除
- docs/todo-summary.md: 順位 91 行削除 + 順位 92 行を独立タスクとして修正
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