Skip to content

feat(cli-push-runner): Bundle 3 — 順位 5 _tmp_* pattern 追加 + 順位 159 lint rule⑪ + 順位 142 ADR-041 補強#176

Merged
aloekun merged 3 commits into
masterfrom
bundle-3-scratch-pattern-extension
May 26, 2026
Merged

feat(cli-push-runner): Bundle 3 — 順位 5 _tmp_* pattern 追加 + 順位 159 lint rule⑪ + 順位 142 ADR-041 補強#176
aloekun merged 3 commits into
masterfrom
bundle-3-scratch-pattern-extension

Conversation

@aloekun
Copy link
Copy Markdown
Owner

@aloekun aloekun commented May 26, 2026

Summary

Bundle 3 (案 A 第 3 PR、案 A 完了): 順位 5 (AI 生成一時スクリプト pattern の pre-push 検出) を Bundle 1 確定の補完アプローチで実装し、Bundle 1 / 2 の post-merge-feedback 採用済 follow-up (順位 159 / 142) を同 PR に bundle 化。

  • 順位 5 (Tier 1): scratch_file_warning stage の patterns config に _tmp_* を追加。Bundle 1 で config-driven にした設計を活用し、Rust コード変更最小で AI 生成一時スクリプト pattern (_tmp_* prefix) の検出範囲を拡張。ADR-007 (linter layer boundary) との責務分担を doc comment + config TOML コメントで明示 (本 stage = pre-push @ commit 検査 / ADR-007 = edit 時 text 検査)。
  • 順位 159 (Tier 1): .claude/custom-lint-rules.toml に rule⑪ (no-jj-template-first-line) を新規追加。jj template の脆弱な descriptionfirst_line() メソッド使用を error severity で禁止し、empty keyword 利用を促進。PR feat(cli-push-runner): Bundle 2 — 順位 2 bookmark check stage + 順位 156/158 docs #175 Minor finding 由来の ad-hoc fix を構造的予防に格上げする「自己強化パターン」(Bundle 1 順位 116/134 / Bundle 2 順位 156/158 と同系統)。
  • 順位 142 (Tier 3): docs/adr/adr-041-test-isolation-patterns.md に § 関連 pattern: State Preservation Invariant (write-once 不変式) を追加。Multi-Condition Guards (本体) との別 pattern class として codify、PR test(cli-pr-monitor): Bundle B — early-return guard 単独検証 test + code-review.md checklist 追記 (順位 83 + 84) #168/169/170 連続観測の write-once field 設計 + 3 variant 直交 test pattern (既存値 preservation / 新値 provision / 書き換え不可) を明文化。

Commit Chain

Implementation Details (順位 5)

  • push-runner-config.toml: patterns = ["__*", "_tmp_*"] に拡張、ADR-007 との責務分担コメント追加
  • src/cli-push-runner/src/stages/scratch_file_warning.rs: module doc 更新 (Bundle 3 完了状況 + ADR-007 関係明示)、_tmp_* pattern の 3 件 test 追加
    • find_violations_detects_tmp_prefix_pattern (positive)
    • find_violations_with_dunder_and_tmp_patterns_combined (combined patterns)
    • find_violations_tmp_pattern_does_not_match_underscore_only (negative)

設計判断:

  • 補完アプローチ採用済 (Bundle 1 で確定): Rust コード変更最小、config 拡張のみで pattern 追加
  • ADR-007 との責務分担明示: 本 stage = pre-push @ commit ファイル列挙検査 (= push 直前最終防衛層) / ADR-007 § custom_lint_rule = PostToolUse hook で text 内容検査 (= 編集時即時検出層)

Implementation Details (順位 159)

  • .claude/custom-lint-rules.toml: rule⑪ 追加 (id: no-jj-template-first-line、pattern: description\.first_line\(\)、severity: error)
  • extensions: toml, yaml, md (jj template が記述されうる主要 file 形式)
  • Self-exclusion 設計: message / why / example / コメント内で pattern 文字列 を連続記述しない (= 「description の first_line()」のように間に文字を挟む) ことで self-trigger を回避 (rule⑥ no-ephemeral-todo-reference と同パターン)
  • src/hooks-post-tool-linter/src/main.rs: rule⑪ test 5 件追加 (toml/yaml positive+negative + md positive)
  • rule_test_coverage_check meta validation 通過

Implementation Details (順位 142)

  • docs/adr/adr-041-test-isolation-patterns.md: § 関連 pattern: State Preservation Invariant (write-once 不変式) を ## 帰結 の前に挿入
  • Multi-Condition Guards (本体) との比較表で別 pattern class であることを明示
  • 3 variant 直交 test (既存値 preservation / 新値 provision / 書き換え不可) を原則として codify
  • 参照実装: poll.rsfinalize_*_preserves_existing_fix_push_time + monitor.rsresume_returns_fix_push_time_from_state_when_set を cite
  • § 改訂履歴 に 2026-05-27 追記 entry を追加

Tests

  • cargo test --manifest-path src/cli-push-runner/Cargo.toml: 136 passed (+3 for _tmp_* pattern)
  • cargo test --manifest-path src/hooks-post-tool-linter/Cargo.toml no_jj_template_first_line: 5 passed (新規 rule⑪ test)
  • cargo test --manifest-path src/hooks-post-tool-linter/Cargo.toml rule_test_coverage_check: 1 passed (meta validation で rule⑪ の test_coverage field 整合性確認)
  • pnpm build:cli-push-runner / pnpm build:hooks-post-tool-linter: release profile build success
  • markdownlint: 0 errors
  • comment-lint (Bundle Z #B-α): 0 errors
  • takt pre-push-review: APPROVE
  • dogfood: 順位 157 (Bundle 1 dogfood checklist) と組合せて __test.ps1 + _tmp_test.txt の block 動作確認 (post-merge で実施)

Out of Scope (案 A 完了)

Bundle 3 = 案 A 第 3 PR で land により案 A (Tier 1 軽量 hook 群先行) 完了。残る次フェーズ候補:

  1. 順位 155 (cli-pr-monitor 空 commit 自動 abandon、PR feat(cli-push-runner): Bundle 1 — 順位 1 scratch file warning hook + 順位 116/134 docs + 順位 8 planning #174 T1-feat(hooks): 設定駆動型アーキテクチャに移行し配布自動化を実装 #1 採用) — Tier 1 単独 PR or 別 bundle
  2. 順位 157 (Bundle 1 dogfood checklist) — manual operation、Bundle 2 で実施想定だったが未実施
  3. 順位 8 (週次レビュー Phase B) — 依存: 順位 136 land 先行推奨
  4. ADR-032 系列 (順位 6 / 10 / 20 / 21 / 22) — docs-only PR 高速パス基盤

post-merge-feedback で発見された別 finding

なし (現時点の takt pre-push-review pass、CR 結果は post-PR で観察)

Summary by CodeRabbit

リリースノート

  • New Features

    • テンプレート記述の曖昧さを防ぐ新しい検証ルールを追加しました。
  • Documentation

    • テスト設計パターンに関する詳細ガイダンスを追加しました。
    • 開発タスク管理ドキュメントを最新の進行状況に更新しました。
  • Tests

    • 検出パターンの精度を高めるテストケースを追加しました。

Review Change Stack

aloekun added 3 commits May 26, 2026 22:29
…ble に登録

PR #175 (Bundle 2) post-merge-feedback で採用判定された Tier 1 #1 を docs/todo9.md
新規エントリとして追加し、docs/todo-summary.md table に行追加。

- 順位 159 (T1 #1): jj template 内で脆弱な `description.first_line()` パターン
  を lint で禁止する custom lint rule (rule ⑪) 追加 (PR #175 Minor finding 由来
  の ad-hoc fix を構造化予防に格上げ、`empty` keyword 利用促進、Effort XS、
  対象 ext = toml/yaml/md)
…t rule⑪ + 順位 142 ADR-041 補強

順位 5 (PR #88 T1-2) AI 生成一時スクリプト pattern の pre-push 検出を実装。
Bundle 1 で確定した補完アプローチ (config-driven patterns extension) を採用、
`_tmp_*` pattern を `scratch_file_warning` stage の patterns に追加することで
PR scope 外 scratch file の混入を構造的に防止する範囲を拡張。

## 実装 (順位 5)

- push-runner-config.toml: patterns に `_tmp_*` 追加、ADR-007 との責務分担を
  コメントで明示 (本 stage = pre-push @ commit 検査 / ADR-007 = edit 時 text 検査)
- src/cli-push-runner/src/stages/scratch_file_warning.rs: module doc に Bundle 3
  完了状況と ADR-007 関係を追記、_tmp_* pattern の 3 件 test 追加
  (detects_tmp_prefix_pattern / combined patterns / does_not_match_underscore_only)

## 実装 (順位 159)

- .claude/custom-lint-rules.toml: rule⑪ (no-jj-template-first-line) 追加。
  jj template の `description` の `first_line` メソッド使用を error severity
  で禁止、`empty` keyword 利用を促進。
- extensions: toml / yaml / md (jj template が記述されうる主要 file 形式)
- Self-exclusion: message / why / example / コメント内で pattern 文字列を連続
  記述しない設計で self-trigger を回避 (rule⑥ no-ephemeral-todo-reference と
  同パターン)
- src/hooks-post-tool-linter/src/main.rs: rule⑪ test 5 件追加
  (toml / yaml positive+negative + md positive)
- rule_test_coverage_check meta validation 通過

## 実装 (順位 142)

- docs/adr/adr-041-test-isolation-patterns.md: § 関連 pattern: State Preservation
  Invariant (write-once 不変式) を追加。Multi-Condition Guards (本体) との別
  pattern class として codify、PR #168/169/170 連続観測の write-once field
  (state.fix_push_time 等) 設計 + 3 variant 直交 test pattern (既存値 preservation /
  新値 provision / 書き換え不可) を明文化。参照実装 = poll.rs の
  finalize_*_preserves_existing_fix_push_time + monitor.rs の
  resume_returns_fix_push_time_from_state_when_set を cite。

## Tests

- cargo test --manifest-path src/cli-push-runner/Cargo.toml: 136 passed (+3)
- cargo test --manifest-path src/hooks-post-tool-linter/Cargo.toml no_jj_template_first_line: 5 passed (新規)
- cargo test --manifest-path src/hooks-post-tool-linter/Cargo.toml rule_test_coverage_check: 1 passed (meta validation)
- pnpm build:cli-push-runner / pnpm build:hooks-post-tool-linter: release profile build success
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 26, 2026

📝 Walkthrough

全体サマリー

このプルリクエストは、新カスタムリント規則 no-jj-template-first-line を追加し、jj テンプレート内の曖昧な description.first_line() 呼び出しを禁止します。同時に、既存の scratch_file_warning ステージに _tmp_* ファイルパターンマッチング機能を拡張し、ADR-041 に State Preservation Invariant テストパターンセクションを追加し、タスク追跡ドキュメントを整理しました。

変更内容

新カスタムリント規則と scratch_file_warning の実装

レイヤー / ファイル 説明
no-jj-template-first-line リント規則の定義とテスト設計
\.claude/custom-lint-rules.toml
description.first_line() を検出し error 重大度で禁止するルール定義、修正戦略(empty キーワードまたは if(description, ...) への置換)、テストカバレッジ(toml/yaml/md 対象)を追加。
no-jj-template-first-line テスト実装
src/hooks-post-tool-linter/src/main.rs
3 フォーマット(toml/yaml/md)各々での正負ケーステスト、空キーワード除外時の非検出を確認するテストヘルパおよび #[test] 群を追加。
scratch_file_warning の tmp パターン拡張*
push-runner-config.toml, src/cli-push-runner/src/stages/scratch_file_warning.rs
patterns_tmp_* を追加、ADR-007 との検査タイミング差分を説明するコメント、_tmp_* 検出および __* との併用検出の動作検証テストを実装。

ドキュメント更新とタスク管理

レイヤー / ファイル 説明
ADR-041 State Preservation Invariant パターン追加
docs/adr/adr-041-test-isolation-patterns.md
write-once フィールド向けテスト 3 variant 直交方針(既存値 preservation / 新値 provision / 書き換え不可強化)、Multi-Condition Guards との対比、参照実装(poll.rs・monitor.rs)と実装不変式要点を新規セクションに追記、改訂履歴を 2026-05-27 に更新。
タスク追跡ドキュメントの整理
docs/todo-summary.md, docs/todo3.md, docs/todo8.md
完了タスク(順位 5・142)を docs/todo-summary.md から削除、進行中タスク記録(PR #88#91)を docs/todo3.md から削除、ADR 移管完了タスク記述を docs/todo8.md から削除して後続順位を繰り上げ。

推定レビュー工数

🎯 3 (中程度) | ⏱️ ~25 分

関連する可能性のあるプルリクエスト

  • aloekun/claude-code-hook-test#175: src/cli-push-runner/src/stages/scratch_file_warning.rs のパターン定義およびテスト領域における同一モジュール変更が関連。
  • aloekun/claude-code-hook-test#158: docs/todo-summary.mddocs/adr-041-test-isolation-patterns.md の同一ガバナンス流れにおけるドキュメント更新が関連。
  • aloekun/claude-code-hook-test#165: .claude/custom-lint-rules.tomltest_coverage 定義と src/hooks-post-tool-linter/src/main.rs の同時検証機構における強い関連。
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 73.33% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed プルリクエストのタイトルは、3つの主要な変更(tmp* パターン追加、カスタムリントルール追加、ADR-041補強)を実装する Bundle 3 の内容を正確に反映している。
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)
docs/adr/adr-041-test-isolation-patterns.md (1)

136-138: 💤 Low value

参照実装リストの完全性を検討

現在の参照実装リストは variant 1(既存値 preservation)と variant 3(書き換え不可)のテスト例を含んでいますが、128-130行で説明した 3 variant のうち variant 2(新値 provision)の具体的なテスト参照が欠けています。

また、138行の実装コード例 state.fix_push_time.or_else(|| Some(new)) は概念説明用の簡略化ですが、実際の poll.rs 実装は state.fix_push_time.or_else(|| ctx.fix_push_time.map(String::from)) となっています。「実装側の不変式」として紹介しているため、擬似コードである旨を明示するか、実際のコードスニペットを引用することを検討してください。

📝 改善案

Option 1: variant 2 のテスト参照を追加

 ### 参照実装
 
-- `src/cli-pr-monitor/src/stages/poll.rs` の `finalize_*_preserves_existing_fix_push_time` (variant 1 + 3 を兼ねる)
+- `src/cli-pr-monitor/src/stages/poll.rs` の `finalize_*_preserves_existing_fix_push_time` (variant 1 + 3 を兼ねる)
+- `src/cli-pr-monitor/src/stages/poll.rs` の `finalize_*_sets_fix_push_time_when_absent` (variant 2 の例、該当テストが存在する場合)
 - `src/cli-pr-monitor/src/monitor.rs` の `resume_returns_fix_push_time_from_state_when_set` (variant 1 の resume path 版)
-- 実装側の不変式: `state.fix_push_time.or_else(|| Some(new))` (= `or_else` clause で値なし時のみ新値 set、= variant 2 の path)
+- 実装側の不変式 (概念): `state.fix_push_time.or_else(|| Some(new))` (= `or_else` clause で値なし時のみ新値 set、= variant 2 の path)

Option 2: 138行を実際のコードスニペットに置き換え

-- 実装側の不変式: `state.fix_push_time.or_else(|| Some(new))` (= `or_else` clause で値なし時のみ新値 set、= variant 2 の path)
+- 実装側の不変式: `state.fix_push_time.or_else(|| ctx.fix_push_time.map(String::from))` (poll.rs:839-842、= `or_else` clause で値なし時のみ新値 set、= variant 2 の path)
🤖 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 `@docs/adr/adr-041-test-isolation-patterns.md` around lines 136 - 138, 参照実装リストが
variant
2(新値を設定するパス)の参照テストを欠いているため、テスト参照を追加するか擬似コードの扱いを明確にしてください:具体的には、既存のテスト参照名(finalize_*_preserves_existing_fix_push_time
in src/cli-pr-monitor/src/stages/poll.rs と
resume_returns_fix_push_time_from_state_when_set in
src/cli-pr-monitor/src/monitor.rs)に対して「variant 2
に該当するテスト」を追加して参照リストを完成させるか、ドキュメント中の実装例 `state.fix_push_time.or_else(||
Some(new))` を擬似コードであると明記するか、もしくは実際の実装で使われている形(poll.rs の
`state.fix_push_time.or_else(||
ctx.fix_push_time.map(String::from))`)に置き換えて一貫性を持たせてください。
🤖 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 `@docs/adr/adr-041-test-isolation-patterns.md`:
- Around line 136-138: 参照実装リストが variant
2(新値を設定するパス)の参照テストを欠いているため、テスト参照を追加するか擬似コードの扱いを明確にしてください:具体的には、既存のテスト参照名(finalize_*_preserves_existing_fix_push_time
in src/cli-pr-monitor/src/stages/poll.rs と
resume_returns_fix_push_time_from_state_when_set in
src/cli-pr-monitor/src/monitor.rs)に対して「variant 2
に該当するテスト」を追加して参照リストを完成させるか、ドキュメント中の実装例 `state.fix_push_time.or_else(||
Some(new))` を擬似コードであると明記するか、もしくは実際の実装で使われている形(poll.rs の
`state.fix_push_time.or_else(||
ctx.fix_push_time.map(String::from))`)に置き換えて一貫性を持たせてください。

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: be29b52c-7ad5-463f-95d5-c72260870d0a

📥 Commits

Reviewing files that changed from the base of the PR and between b69f7a3 and d17c7ea.

📒 Files selected for processing (8)
  • .claude/custom-lint-rules.toml
  • docs/adr/adr-041-test-isolation-patterns.md
  • docs/todo-summary.md
  • docs/todo3.md
  • docs/todo8.md
  • push-runner-config.toml
  • src/cli-push-runner/src/stages/scratch_file_warning.rs
  • src/hooks-post-tool-linter/src/main.rs
💤 Files with no reviewable changes (3)
  • docs/todo-summary.md
  • docs/todo8.md
  • docs/todo3.md

@aloekun aloekun merged commit 283eafc into master May 26, 2026
1 check passed
@aloekun aloekun deleted the bundle-3-scratch-pattern-extension branch May 26, 2026 17:00
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