feat(cli-push-runner): Bundle 3 — 順位 5 _tmp_* pattern 追加 + 順位 159 lint rule⑪ + 順位 142 ADR-041 補強#176
Conversation
…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
📝 Walkthrough全体サマリーこのプルリクエストは、新カスタムリント規則 変更内容新カスタムリント規則と scratch_file_warning の実装
ドキュメント更新とタスク管理
推定レビュー工数🎯 3 (中程度) | ⏱️ ~25 分 関連する可能性のあるプルリクエスト
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 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.
🧹 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
📒 Files selected for processing (8)
.claude/custom-lint-rules.tomldocs/adr/adr-041-test-isolation-patterns.mddocs/todo-summary.mddocs/todo3.mddocs/todo8.mdpush-runner-config.tomlsrc/cli-push-runner/src/stages/scratch_file_warning.rssrc/hooks-post-tool-linter/src/main.rs
💤 Files with no reviewable changes (3)
- docs/todo-summary.md
- docs/todo8.md
- docs/todo3.md
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 化。
scratch_file_warningstage のpatternsconfig に_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 検査)。.claude/custom-lint-rules.tomlに rule⑪ (no-jj-template-first-line) を新規追加。jj template の脆弱なdescriptionのfirst_line()メソッド使用を error severity で禁止し、emptykeyword 利用を促進。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 と同系統)。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
xrtmwvlvdocs(todo): PR feat(cli-push-runner): Bundle 2 — 順位 2 bookmark check stage + 順位 156/158 docs #175 post-merge-feedback 採用 1 件を todo9.md / summary table に登録 (前セッション分)pumssnpkfeat(cli-push-runner): Bundle 3 — 順位 5 tmp* pattern 追加 + 順位 159 lint rule⑪ + 順位 142 ADR-041 補強mvowowywdocs(todo): Bundle 3 完了に伴い 順位 5 / 159 / 142 を削除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)設計判断:
Implementation Details (順位 159)
.claude/custom-lint-rules.toml: rule⑪ 追加 (id:no-jj-template-first-line、pattern:description\.first_line\(\)、severity: error)toml,yaml,md(jj template が記述されうる主要 file 形式)no-ephemeral-todo-referenceと同パターン)src/hooks-post-tool-linter/src/main.rs: rule⑪ test 5 件追加 (toml/yaml positive+negative + md positive)rule_test_coverage_checkmeta validation 通過Implementation Details (順位 142)
docs/adr/adr-041-test-isolation-patterns.md: § 関連 pattern: State Preservation Invariant (write-once 不変式) を## 帰結の前に挿入poll.rsのfinalize_*_preserves_existing_fix_push_time+monitor.rsのresume_returns_fix_push_time_from_state_when_setを citeTests
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_coveragefield 整合性確認)pnpm build:cli-push-runner/pnpm build:hooks-post-tool-linter: release profile build success__test.ps1+_tmp_test.txtの block 動作確認 (post-merge で実施)Out of Scope (案 A 完了)
Bundle 3 = 案 A 第 3 PR で land により案 A (Tier 1 軽量 hook 群先行) 完了。残る次フェーズ候補:
post-merge-feedback で発見された別 finding
なし (現時点の takt pre-push-review pass、CR 結果は post-PR で観察)
Summary by CodeRabbit
リリースノート
New Features
Documentation
Tests