Skip to content

feat(cli-push-runner): Bundle 2 — 順位 2 bookmark check stage + 順位 156/158 docs#175

Merged
aloekun merged 4 commits into
masterfrom
bundle-2-bookmark-check
May 26, 2026
Merged

feat(cli-push-runner): Bundle 2 — 順位 2 bookmark check stage + 順位 156/158 docs#175
aloekun merged 4 commits into
masterfrom
bundle-2-bookmark-check

Conversation

@aloekun
Copy link
Copy Markdown
Owner

@aloekun aloekun commented May 26, 2026

Summary

Bundle 2 (案 A 第 2 PR): 順位 2 (cli-push-runner jj bookmark 未設定 early-exit) を実装し、PR #174 post-merge-feedback 採用済の Tier 2 / Tier 3 (順位 156 / 158) を同 PR に bundle 化。

Commit Chain

Implementation Details (順位 2)

新 stage 配置: run_pipeline の最早期 (Stage -1、scratch_file_warning Stage 0 より前)。bookmark 不在は push 自体が不可能な状態のため、最優先で fail-fast。

  • src/cli-push-runner/src/stages/bookmark_check.rs (新規、166 行): 新 stage 本体
  • src/cli-push-runner/src/stages/mod.rs: module register
  • src/cli-push-runner/src/main.rs:
    • Stage -1 として run_bookmark_check を追加
    • EXIT_BOOKMARK_MISSING = 7 を新設
    • run_pipeline が 50 行制限を超えたため run_pre_checks を抽出 (Bundle Z #B-α 関数長 50 行制限準拠、bookmark + scratch の 2 check を責務統合)

設計判断:

  • 設計上の non-config: jj git push が bookmark を必須とする仕様で、本 stage をバイパスする正当な use case が存在しない。[bookmark_check] config section は追加せず、常に有効
  • lib_jj_helpers 活用: is_trunk_bookmark で master / main を filter (ADR-024 共通 jj ヘルパー継承)
  • fail-open: jj bookmark list 実行失敗 (timeout / 起動失敗) 時は warning ログのみで push 続行 (jj 不調で push 自体を止めない、Bundle 1 と同設計)

Implementation Details (順位 156)

scratch_file_warning.rseffective_patterns() test 群を 4 filter path 直交化:

Test 関数 Filter path Variant input Expected
effective_patterns_all_blank_falls_back_to_default collection-level empty ["", " ", "\t"] ["__*"]
effective_patterns_mixed_blank_and_valid_keeps_only_valid element-level empty ["", "__*", " ", "_tmp_*"] ["__*", "_tmp_*"]
effective_patterns_whitespace_padded_is_trimmed element-level trim [" __* "] ["__*"]
effective_patterns_mixed_filter_to_empty_falls_back_to_default element + collection chained [" ", "\t"] ["__*"]

既存 3 test を新命名規約 (filter path 明示) にリネーム + variant #4 (mixed_filter_to_empty) を新規追加。1 path のみ regression した場合に 1 test だけ failed する構造で、原因切り分けが即特定可能。

Implementation Details (順位 158)

ADR-039 § 3 Bounded lifetime の既存 bullet list 末尾に「明示的 decision trigger の必須化」section を追加 (約 14 行):

Tests

  • cargo test --manifest-path src/cli-push-runner/Cargo.toml: 133 passed (新規: bookmark_check 6 件 + effective_patterns variant fix(hooks): Replace matcher追加 & deploy時のpermissions保持 #4 1 件)
  • pnpm build:cli-push-runner (release profile): build success
  • markdownlint: 0 errors
  • comment-lint (Bundle Z #B-α): 0 errors (function length 50 行制限の対応 + 非 doc コメント 0 件)
  • takt pre-push-review: APPROVE (all approved aggregate、1 iteration、4m 16s)
  • dogfood: 順位 157 (Bundle 1 dogfood checklist) と組み合わせて __test.ps1 + 「bookmark 削除して push」 の block 動作確認 (post-merge で実施)

Out of Scope (案 A 後続 PR)

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

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

Summary by CodeRabbit

  • 新機能

    • Pre-push パイプラインにブックマーク検査を追加し、非 trunk のローカルブックマークがある場合に事前に検知するようにしました。
  • テスト

    • パターンマッチング検証を拡張し、ブランク文字の扱いやフォールバック動作を包括的に検証するテストを追加しました。
  • ドキュメント

    • 実験的機能の意思決定トリガーの必須化と記録場所を明文化する ADR を追加・更新しました。
    • TODO ドキュメントに複数のタスク(優先度更新・チェック手順追加)を追記・整理しました.

Review Change Stack

aloekun added 3 commits May 26, 2026 19:30
…ble に登録

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

- 順位 155 (T1 #1): cli-pr-monitor fix chain 末尾に空 commit 検査 + jj abandon
  step 追加 (PR #174 で観測した kqvluqyv 事例の構造化予防、Effort S)
- 順位 156 (T2 #1): effective_patterns() の空 variant test 4 件直交化 (CR Minor
  finding 起点の 4 filter path 独立検証化、Effort S)
- 順位 157 (T2 #2): Bundle 1 dogfood checklist 実行 — __test.ps1 block +
  override env 確認 (ADR-039 bounded lifetime data point #1、Effort XS)
- 順位 158 (T3 #1): ADR-039 に bounded lifetime decision trigger 必須化パターン
  追記 (PR #174 の 3-5 PR dogfood 実例を reusable rule に昇格、Effort S)
…158 docs

順位 2 (PR #85 T1-3) jj bookmark 未設定 early-exit を実装。jj 環境では新規ブランチ
で bookmark を作成し忘れる落とし穴があり、PR #85 で初回 `pnpm push` が
`Nothing changed` で終了し 158s かけた quality_gate + takt review が無駄になった
事象の構造的予防。

## 実装 (順位 2)

- src/cli-push-runner/src/stages/bookmark_check.rs (新規): 新 stage
- src/cli-push-runner/src/stages/mod.rs: module register
- src/cli-push-runner/src/main.rs:
  - Stage -1 として run_bookmark_check を pipeline 最早期に追加
  - EXIT_BOOKMARK_MISSING = 7 を新設
  - run_pipeline が 50 行制限を超えたため run_pre_checks を抽出して責務分離

設計:
- 配置: scratch_file_warning より前の最早期 stage (push 自体不可能な状態を最優先で fail-fast)
- 検出: `jj bookmark list` で非 trunk bookmark の有無を確認 (lib_jj_helpers::is_trunk_bookmark で filter)
- 失敗時挙動: error 終了 + 推奨コマンド (`jj bookmark create <name> -r @`) 提示
- fail-open: jj 実行失敗時は warning ログのみで push を続行 (jj 不調で push 自体を止めない)
- 設計上の non-config: jj git push が bookmark 必須仕様のため、本 stage をバイパスする
  正当な use case なし。`[bookmark_check]` config section は追加せず常に有効

## Bundled docs

- 順位 156: effective_patterns() の空 variant test 4 件直交化。既存 3 test を
  filter path 直交命名 (all_blank / mixed_blank_and_valid / whitespace_padded)
  にリネーム + 4 番目 variant (mixed_filter_to_empty) を新規追加。1 path
  regression で 1 test だけ failed する構造 (memory feedback_test_dry_antipattern.md 適用)。
- 順位 158: ADR-039 § 3 Bounded lifetime に「明示的 decision trigger 必須化」要件を
  追記。PR #174 を実例 (Bundle 1 = 3-5 PR dogfood trigger) として cite、formless な
  「未来の判定」記述を ADR レベルで禁止する reusable pattern として codify。

## Tests

cargo test --manifest-path src/cli-push-runner/Cargo.toml: 133 passed
新規 test: bookmark_check 6 件 + effective_patterns 1 件 (variant #4)
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 26, 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: f98ccb1e-c2be-47d4-a0fa-dedf4b7ab0ea

📥 Commits

Reviewing files that changed from the base of the PR and between 8ed077f and b10a83b.

📒 Files selected for processing (2)
  • docs/todo9.md
  • src/cli-push-runner/src/main.rs
✅ Files skipped from review due to trivial changes (1)
  • docs/todo9.md

📝 Walkthrough

Walkthrough

PR #175 は pre-push パイプラインに非 trunk bookmark チェックを追加し、bookmark_check ステージと scratch_file_warning を run_pre_checks に統合。ADR-039 の bounded lifetime に関する decision trigger 標準化と関連ドキュメント/タスク追跡の更新を含む。

Changes

Bookmark Check Stage の実装と統合

Layer / File(s) Summary
ADR-039 decision trigger 標準化
docs/adr/adr-039-experimental-feature-standard-pattern.md
「bounded lifetime」節に明示的 decision trigger(期限・条件・PR数)の必須化と永続記録先(TOMLコメント、module doc、PR body)を明示し、既存 ADR の追補方針を追記。
Bookmark check ステージ実装
src/cli-push-runner/src/stages/bookmark_check.rs, src/cli-push-runner/src/stages/mod.rs
run_bookmark_check() を追加し jj bookmark list の出力から非 trunk bookmark を解析・判定。fail-open 挙動と情報ログを実装、解析ルールを検証するユニットテスト群を追加。
Pre-checks 統合と制御フロー
src/cli-push-runner/src/main.rs
run_pre_checks(config) に bookmark_check と scratch_file_warning を集約。新規終了コード EXIT_BOOKMARK_MISSING (7) を追加し、pipeline 起動前の早期中断を制御。
Scratch file warning テスト拡張
src/cli-push-runner/src/stages/scratch_file_warning.rs
effective_patterns のテストを整理・拡張し、空白のみ・混在・トリム後のフォールバック等のケースを追加検証。

タスク追跡と計画ドキュメント更新

Layer / File(s) Summary
推奨実行順序と進捗記録
docs/todo-summary.md
Tier 1(順位 5)タスクの追加(AI 生成一時スクリプト pattern の pre-push 検出)と、順位 155・157 のタスク行(空 commit 検査、dogfood checklist)を追加。
進行状況と実装計画
docs/todo2.md, docs/todo9.md
docs/todo2.md から早期終了タスクを削除し、cli-pr-monitor の残留プロセス検出用 integration test を追加。docs/todo9.md に fix-chain の空 description commit 廃棄手順と scratch_file_warning dogfood checklist の詳細を追記。

Sequence Diagram

sequenceDiagram
  participant main as main.rs
  participant pre as run_pre_checks()
  participant bookmark as run_bookmark_check()
  participant jj as "jj bookmark list"
  participant parse as parse_non_trunk_bookmarks()
  main->>pre: run_pre_checks(config)
  pre->>bookmark: run_bookmark_check()
  bookmark->>jj: spawn subprocess "jj bookmark list"
  jj-->>bookmark: stdout/stderr
  bookmark->>parse: parse output
  parse-->>bookmark: non-trunk bookmark list
  alt non-trunk found
    bookmark-->>pre: true (continue)
  else none found
    bookmark-->>pre: false (halt)
  end
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

  • aloekun/claude-code-hook-test#174: scratch_file_warning 周りの実装・テスト更新を含む PR。今回の run_pre_checks / scratch_file_warning 変更と直接関連。
  • aloekun/claude-code-hook-test#49: bookmark 関連の事前ステップを変更する PR で、bookmark チェック周辺の振る舞いに関連性あり。
🚥 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 タイトルは「Bundle 2 — 順位 2 bookmark check stage + 順位 156/158 docs」で、PR の主な変更内容(bookmark_check ステージの追加と関連ドキュメント更新)を明確に示しており、PR の中核となる変更を的確に要約している。
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: 2

🤖 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 `@docs/todo9.md`:
- Around line 464-465: The template uses description.first_line() but the filter
checks description = "", causing a mismatch; update the flow so the filter
matches the template output: either change the jj log template to emit the full
description (use -T 'description') so the existing description = "" check is
valid, or change the filter to test the first line (empty string) of the
template output (i.e. treat an empty first_line as a blank commit message), or
replace both with a revset predicate like empty() (e.g. jj log -r 'master..@ &
empty()') so selection and template are consistent; locate and update the jj log
invocation and the filter logic referencing description.first_line() and
description = "" accordingly.

In `@src/cli-push-runner/src/main.rs`:
- Around line 81-82: The user-visible Japanese message in main.rs contains
duplicated punctuation at the substring "検出。.gitignore"; locate the string
literal containing "パイプライン中断: scratch ファイル検出。.gitignore 修正 / ファイル削除 /
SCRATCH_FILE_WARNING_OVERRIDE=1 のいずれかで再実行してください。" and fix the punctuation by
removing the extra full stop so it reads e.g. "パイプライン中断: scratch ファイル検出:
.gitignore 修正 / ファイル削除 / SCRATCH_FILE_WARNING_OVERRIDE=1 のいずれかで再実行してください。" (or
otherwise remove the duplicated punctuation between "検出" and ".gitignore") to
produce a natural Japanese sentence.
🪄 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: cb7a8fe8-2c14-4cfa-a458-0230cab01167

📥 Commits

Reviewing files that changed from the base of the PR and between 37682fc and 8ed077f.

📒 Files selected for processing (8)
  • docs/adr/adr-039-experimental-feature-standard-pattern.md
  • docs/todo-summary.md
  • docs/todo2.md
  • docs/todo9.md
  • src/cli-push-runner/src/main.rs
  • src/cli-push-runner/src/stages/bookmark_check.rs
  • src/cli-push-runner/src/stages/mod.rs
  • src/cli-push-runner/src/stages/scratch_file_warning.rs
💤 Files with no reviewable changes (1)
  • docs/todo2.md

Comment thread docs/todo9.md Outdated
Comment thread src/cli-push-runner/src/main.rs Outdated
…ation + todo9.md 順位 155 design clarification)
@aloekun
Copy link
Copy Markdown
Owner Author

aloekun commented May 26, 2026

@coderabbitai review

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 26, 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 b69f7a3 into master May 26, 2026
1 check passed
@aloekun aloekun deleted the bundle-2-bookmark-check branch May 26, 2026 13:12
aloekun added a commit that referenced this pull request May 26, 2026
…t rule⑪ + 順位 142 ADR-041 補強 (#176)

* docs(todo): PR #175 post-merge-feedback 採用 1 件を todo9.md / summary table に登録

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)

* feat(cli-push-runner): Bundle 3 — 順位 5 _tmp_* pattern 追加 + 順位 159 lint 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

* docs(todo): Bundle 3 完了に伴い 順位 5 / 159 / 142 を削除
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