Skip to content

docs/test: PR #194 follow-up bundle — fail-closed ADR + jj test/revset patterns + experimental feature checklist - #195

Merged
aloekun merged 9 commits into
masterfrom
followup/pr-194-bundle
Jun 4, 2026
Merged

docs/test: PR #194 follow-up bundle — fail-closed ADR + jj test/revset patterns + experimental feature checklist#195
aloekun merged 9 commits into
masterfrom
followup/pr-194-bundle

Conversation

@aloekun

@aloekun aloekun commented Jun 4, 2026

Copy link
Copy Markdown
Owner

Summary

PR #194 (feat(hooks): merge 前 mechanical gate 強化) の post-merge-feedback で採用された 6 件 (順位 183-188) を 1 PR に bundle して land する。

変更内容 (commit ごと)

Commit 種別 内容
1 docs(todo) 順位 183-188 を docs/todo-summary.md + docs/todo10.md に登録
2 test(hooks) build_todo_staleness_message(None, ...) の fail-closed test 2 件追加 (PR #194 T2-#1)
3 test(pr-monitor) sweep revset の variant test 3 件追加 (non-fix(review) skip / alternative branch / no-op) + helper 関数 3 件 (PR #194 T2-#2)
4 docs(rules) ~/.claude/rules/common/testing.md § "jj 操作コードの integration test pattern" + fix_commit.rs//! companion doc (PR #194 T2-#3)
5 docs(adr) ADR-043 (Security/Quality Gate Fail-Closed 原則) 新設 + CLAUDE.md table 追加 (PR #194 T3-#2)
6 docs(adr) ADR-021 に § Revset Composability section 追記 (PR #194 T3-#3)
7 docs(adr) ADR-039 に § 設計段階 pre-check (6 点) 追加 + ~/.claude/rules/common/patterns.md § Experimental Feature 設計時の参照必須 (PR #194 T3-#1)
8 docs(todo) 完了に伴い todo-summary/todo10 entry 削除

統計

  • 本リポ scope: 6 files changed (+ todo-summary.md / todo10.md), 386 insertions / 6 deletions
  • グローバル scope: ~/.claude/rules/common/{testing,patterns}.md を 2 ファイル更新 (派生プロジェクトに波及)
  • 新規 ADR: ADR-043 (試験運用)

試験運用判断基準

  • ADR-043 (Fail-closed 原則): 3 PR の review で fail-open 指摘が CR / reviewer から再発しなければ stable 昇格 (docs/adr/adr-043-security-gates-fail-closed.md § 試験運用判断基準)
  • ADR-021 § Revset Composability: 3 PR 以上で「revset filter で書き直し」の review iteration が発生しなければ stable 昇格
  • ADR-039 § 設計段階 pre-check 6 点: 既存 § self-review 4 点と組み合わせて「設計 → 実装」の 2 段 gate を成す

Test plan

  • cargo test --workspace 全 pass (unit test)
  • cargo test --workspace -- --ignored --test-threads=1 5 件の integration_sweep_* pass
  • markdownlint-cli2 全 modified .md ファイルで 0 errors
  • pre-push-review (simplicity facet) で Status: all("approved")
  • CodeRabbit walkthrough での確認 (本 PR push 後の自動 review 待ち)
  • ADR-043 / ADR-021 § Revset Composability の dogfood (後続 3 PR で観測)

参照

  • PR feat(hooks): merge 前 mechanical gate 強化 (clippy + 空 commit sweep) #194 (merge 前 mechanical gate 強化) commit dfad56ff — takt-fix iteration の behind?is_none_or 修正
  • ADR-043 (新設、本 PR) — fail-closed 原則と is_none_or イディオム
  • ADR-021 § Revset Composability (本 PR で追記) — jj revset 設計原則
  • ADR-039 § 設計段階 pre-check (本 PR で追記) — experimental feature 6 点設計チェックリスト
  • ~/.claude/rules/common/testing.md § jj 操作コードの integration test pattern (本 PR で追加) — count NG / description-based assert OK pattern
  • ~/.claude/rules/common/patterns.md § Experimental Feature 設計時の参照必須 (本 PR で追加) — 3 軸の設計時確認
  • .claude/feedback-reports/194.md — post-merge-feedback 採用根拠

Summary by CodeRabbit

  • Documentation

    • 新規:セキュリティ/品質ゲートの Fail‑Closed 原則に関する設計文書を追加
    • Revset 設計原則(取得最小化やフィルタパターン)と実装事例を追記
    • 実験機能の設定段階向け事前チェックリストを追加
    • Architecture Decisions 一覧にエントリを追加
  • Tests

    • PR 範囲検証や description ベースの不変式を検証する統合テストとテストヘルパーを追加・拡充
    • 判定不能時に fail‑closed と扱う挙動を検証するテストを追加

@coderabbitai

coderabbitai Bot commented Jun 4, 2026

Copy link
Copy Markdown

Review Change Stack

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: 19522720-e025-40a1-b6f8-4f866320311d

📥 Commits

Reviewing files that changed from the base of the PR and between 5c16d69 and 9663dd6.

📒 Files selected for processing (1)
  • src/cli-pr-monitor/src/fix_commit.rs
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/cli-pr-monitor/src/fix_commit.rs

📝 Walkthrough

Walkthrough

PR #195 では、セキュリティゲートの fail-closed 原則(ADR-043)、jj revset の composability(ADR-021 拡張)、実験的機能の設計チェックリスト(ADR-039 拡張)を体系化し、統合テストで動作を検証する変更を実施します。

Changes

Fail-Closed 設計パターンと Revset 原則の確立・検証

Layer / File(s) Summary
ADR-043: Fail-Closed 原則の定義と登録
docs/adr/adr-043-security-gates-fail-closed.md, CLAUDE.md
新規 ADR-043 で gate 関数における Option::? の fail-open リスク、None / Err / timeout の確定不能入力を block 側にデフォルトする原則、is_none_or / map_or(true, ...) の使用義務を定義。反例・好例、適用範囲判別方法、PR #194 実装事例、試験運用基準(対象 gate 関数数と観測期間)を記載し、CLAUDE.md に ADR リスト登録。
ADR-021 / ADR-039: Revset 設計と実験機能チェックリスト拡張
docs/adr/adr-021-jj-change-detection-principles.md, docs/adr/adr-039-experimental-feature-standard-pattern.md
ADR-021 に revset composability セクションを追加し、取得対象最小化原則、フィルタ関数一覧、「generate-then-filter」アンチパターン(empty 全取得→Rust 側フィルタ)vs revset 側 filter の好例を Rust コード例で対比。ADR-039 に設計段階 6 点チェックリスト(enabled 設計、Default、kill-switch 経路、lifetime trigger、ゲート関数集約、integration test 計画)を追記し、PR #194 SweepConfig の NG/OK 実例を提示。
統合テスト用ヘルパ関数と test 不変式の確立
src/cli-pr-monitor/src/fix_commit.rs
tests モジュール冒頭に jj integration test の assert 原則(count-based 回避、description-based 使用、abandon 後 WC 生成を考慮)を明記。build_jj_empty_with_description() / rename_bookmark() / assert_description_in_jj_log() の3つのヘルパ関数を新規追加し、既存テストで直接 jj new していた処理をヘルパ化。
Fail-Closed 動作と Revset フィルタの統合テスト検証
src/cli-pr-monitor/src/fix_commit.rs, src/hooks-pre-tool-validate/src/main.rs
新規 integration test で sweep_empty_commits_in_pr_range の description filter 挙動(fix(review): 以外は対象外 / 別名 default_branch への revset 範囲適用 / 対象 empty が0件時の abandon 早期終了)を検証。加えて build_todo_staleness_messagebehind: None での fail-closed メッセージ生成と、キーワード一致時の複数セクション包含を確認するテストを追加。

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

  • aloekun/claude-code-hook-test#194: PR #194 で導入された fail-closed 影響箇所(behind: None 扱い)および sweep/description フィルタ実装の実例と直接連動しています。
  • aloekun/claude-code-hook-test#139: ADR-039 の実験的機能パターン基盤に関する変更で、本 PR の ADR-039 拡張と内容的に重複・関連しています。
  • aloekun/claude-code-hook-test#189: ADR-039 関連のドキュメント拡張を扱っており、本 PR の ADR 文書追記と横断的に関連する箇所があります。
🚥 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 タイトルは「docs/test: PR #194 follow-up bundle — fail-closed ADR + jj test/revset patterns + experimental feature checklist」で、PR #194 に関連した複数の follow-up アイテム(テスト追加、ADR 新規作成・更新、ドキュメント更新)をまとめた bundle として説明しており、変更セット全体の主要な内容を正確に反映している。
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.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 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 `@src/cli-pr-monitor/src/fix_commit.rs`:
- Around line 720-721: The test helper assert_descriptions_absent_in_pr_range
currently hardcodes the range "master..@" which breaks tests that set
default_branch="main"; modify assert_descriptions_absent_in_pr_range to accept a
branch/range parameter (or a default_branch argument) and use that when
constructing the git range instead of "master..@", then update the call in
integration_sweep_respects_alternative_default_branch to pass "main..@" (or
construct the range from the test's default_branch) so the assertion checks the
intended main..@ range.
🪄 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: 5d0b3eb7-7d81-4f29-b480-906fe2a39d83

📥 Commits

Reviewing files that changed from the base of the PR and between 94f4f36 and 5c16d69.

📒 Files selected for processing (6)
  • CLAUDE.md
  • docs/adr/adr-021-jj-change-detection-principles.md
  • docs/adr/adr-039-experimental-feature-standard-pattern.md
  • docs/adr/adr-043-security-gates-fail-closed.md
  • src/cli-pr-monitor/src/fix_commit.rs
  • src/hooks-pre-tool-validate/src/main.rs

Comment thread src/cli-pr-monitor/src/fix_commit.rs Outdated
@aloekun

aloekun commented Jun 4, 2026

Copy link
Copy Markdown
Owner Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Jun 4, 2026

Copy link
Copy Markdown
✅ Action performed

Review finished.

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 82d64ec into master Jun 4, 2026
1 check passed
@aloekun
aloekun deleted the followup/pr-194-bundle branch June 4, 2026 12:05
aloekun added a commit that referenced this pull request Jun 5, 2026
PR #195 で test helper 3 関数のうち 2 関数が `"master..@"` hardcode → CR Major
指摘で default_branch 引数化済 (commit 9663dd6)、残 1 関数 (`count_empty_in_pr_range`)
は pre-push F-1 で non-blocking 観測。手動 grep / reviewer 判断で塞ぐと再発するため、
決定論的防止層 (ADR-007) として機械検出する。

- Pattern: `master\.\.@` (jj revset 固有 token、FP リスクは Bundle Z #B-α で
  非 doc comments 既に禁止のため軽微)
- extensions = ["rs"] のみ、main.rs source は format! 経由で literal を runtime 組立し
  self-exclusion 維持 (`grep -n 'master\.\.@' src/hooks-post-tool-linter/src/main.rs` = 0 hit)
- Test 4 件: simple hardcode / empty() filter scope / parameterized format skip /
  other branch literal skip
- TOML meta field `[rules.test_coverage.main_ext_tests.rs]` 宣言、
  順位 137 land 済の rule_test_coverage_check が機械強制

順位 190 (count_empty_in_pr_range parameterize) と同 PR で land 推奨 = 機械検出が
auto-fix promotion 候補を提示し、順位 190 で受け修正、dogfood 循環を 1 PR で成立。

Bundle 195-FB Layer 1 (mechanical)
aloekun added a commit that referenced this pull request Jun 5, 2026
…化 (PR #195 T2-#1)

PR #195 で test helper 3 関数のうち 2 関数 (`assert_descriptions_absent_in_pr_range` /
`assert_descriptions_present_in_pr_range`) は `default_branch` 引数化済 (commit 9663dd6)
だが、`count_empty_in_pr_range` のみ `master..@` 引数化漏れ = API cohesion 違反。
順位 189 lint rule (rule⑫ no-hardcoded-jj-revset-range) が機械検出した hardcode を受けて修正、
companion helper group 3 関数の API signature を `(repo_dir, default_branch, ...)` で整合化。

- `count_empty_in_pr_range(repo_dir, default_branch: &str)` に signature 変更
- caller (`integration_sweep_empty_commits_abandons_multiple_in_range`) は `"master"` 引数で更新
- `integration_sweep_respects_alternative_default_branch` に `count_empty_in_pr_range(repo_dir, "main")`
  sanity check 追加 (alternative branch variant が helper レベルで保護)
- doc comments (line 621, 644) は `<default_branch>..@` placeholder に書き換え
  (rule⑫ pattern `master\.\.@` の FP を構造的に排除)
- `grep -n 'master\.\.@' src/` = 0 hit (clean baseline)

検証:
- cargo test --bin cli-pr-monitor fix_commit: 11 unit tests pass
- cargo test --bin cli-pr-monitor 'fix_commit::tests::integration_sweep' -- --ignored --test-threads=1: 5 integration tests pass
- 順位 189 lint rule が production code 上で fire 0 件

Bundle 195-FB Layer 2 (実装)
aloekun added a commit that referenced this pull request Jun 5, 2026
Bundle 195-FB (PR #195 post-merge-feedback 4 件) の 4 layer が land 完了したため
todo10.md / todo-summary.md から 順位 189-192 entries を削除。

Layer:
- 189 (T1): rule⑫ no-hardcoded-jj-revset-range 追加 (commit uoxuyxrp、本 PR 内)
- 190 (T2): count_empty_in_pr_range default_branch 引数化 (commit qntnzyxt、本 PR 内)
- 191 (T3): non-blocking finding 留置基準を code-review.md に追記 (~/.claude/、本 PR 外)
- 192 (T3): Companion Helper API Cohesion section + ADR-041 cross-ref (~/.claude/、本 PR 外)

global rule 編集 (191, 192) は ~/.claude/rules/common/{code-review,patterns,testing}.md
への edit のため本リポジトリの diff には含まれないが、 feedback_global_config_backup per
~/.claude-backups/20260605-131309-bundle-195-fb/ で snapshot を取得済。
派生プロジェクト (techbook-ledger / auto-review-fix-vc) に自動波及。

memory feedback_todo_no_history per: 完了タスクは ADR/仕組みに反映後、todo.md から削除
(履歴は git log で追跡可能)。

Bundle 195-FB Layer 4 (cleanup)
aloekun added a commit that referenced this pull request Jun 5, 2026
* docs(todo): PR #195 post-merge-feedback 採用 4 件登録 (順位 189-192)

* feat(lint): rule⑫ no-hardcoded-jj-revset-range 追加 (PR #195 T1-#1)

PR #195 で test helper 3 関数のうち 2 関数が `"master..@"` hardcode → CR Major
指摘で default_branch 引数化済 (commit 9663dd6)、残 1 関数 (`count_empty_in_pr_range`)
は pre-push F-1 で non-blocking 観測。手動 grep / reviewer 判断で塞ぐと再発するため、
決定論的防止層 (ADR-007) として機械検出する。

- Pattern: `master\.\.@` (jj revset 固有 token、FP リスクは Bundle Z #B-α で
  非 doc comments 既に禁止のため軽微)
- extensions = ["rs"] のみ、main.rs source は format! 経由で literal を runtime 組立し
  self-exclusion 維持 (`grep -n 'master\.\.@' src/hooks-post-tool-linter/src/main.rs` = 0 hit)
- Test 4 件: simple hardcode / empty() filter scope / parameterized format skip /
  other branch literal skip
- TOML meta field `[rules.test_coverage.main_ext_tests.rs]` 宣言、
  順位 137 land 済の rule_test_coverage_check が機械強制

順位 190 (count_empty_in_pr_range parameterize) と同 PR で land 推奨 = 機械検出が
auto-fix promotion 候補を提示し、順位 190 で受け修正、dogfood 循環を 1 PR で成立。

Bundle 195-FB Layer 1 (mechanical)

* refactor(cli-pr-monitor): count_empty_in_pr_range を default_branch 引数化 (PR #195 T2-#1)

PR #195 で test helper 3 関数のうち 2 関数 (`assert_descriptions_absent_in_pr_range` /
`assert_descriptions_present_in_pr_range`) は `default_branch` 引数化済 (commit 9663dd6)
だが、`count_empty_in_pr_range` のみ `master..@` 引数化漏れ = API cohesion 違反。
順位 189 lint rule (rule⑫ no-hardcoded-jj-revset-range) が機械検出した hardcode を受けて修正、
companion helper group 3 関数の API signature を `(repo_dir, default_branch, ...)` で整合化。

- `count_empty_in_pr_range(repo_dir, default_branch: &str)` に signature 変更
- caller (`integration_sweep_empty_commits_abandons_multiple_in_range`) は `"master"` 引数で更新
- `integration_sweep_respects_alternative_default_branch` に `count_empty_in_pr_range(repo_dir, "main")`
  sanity check 追加 (alternative branch variant が helper レベルで保護)
- doc comments (line 621, 644) は `<default_branch>..@` placeholder に書き換え
  (rule⑫ pattern `master\.\.@` の FP を構造的に排除)
- `grep -n 'master\.\.@' src/` = 0 hit (clean baseline)

検証:
- cargo test --bin cli-pr-monitor fix_commit: 11 unit tests pass
- cargo test --bin cli-pr-monitor 'fix_commit::tests::integration_sweep' -- --ignored --test-threads=1: 5 integration tests pass
- 順位 189 lint rule が production code 上で fire 0 件

Bundle 195-FB Layer 2 (実装)

* docs(todo): Bundle 195-FB 完了で 順位 189-192 削除 + global rule edit 同伴

Bundle 195-FB (PR #195 post-merge-feedback 4 件) の 4 layer が land 完了したため
todo10.md / todo-summary.md から 順位 189-192 entries を削除。

Layer:
- 189 (T1): rule⑫ no-hardcoded-jj-revset-range 追加 (commit uoxuyxrp、本 PR 内)
- 190 (T2): count_empty_in_pr_range default_branch 引数化 (commit qntnzyxt、本 PR 内)
- 191 (T3): non-blocking finding 留置基準を code-review.md に追記 (~/.claude/、本 PR 外)
- 192 (T3): Companion Helper API Cohesion section + ADR-041 cross-ref (~/.claude/、本 PR 外)

global rule 編集 (191, 192) は ~/.claude/rules/common/{code-review,patterns,testing}.md
への edit のため本リポジトリの diff には含まれないが、 feedback_global_config_backup per
~/.claude-backups/20260605-131309-bundle-195-fb/ で snapshot を取得済。
派生プロジェクト (techbook-ledger / auto-review-fix-vc) に自動波及。

memory feedback_todo_no_history per: 完了タスクは ADR/仕組みに反映後、todo.md から削除
(履歴は git log で追跡可能)。

Bundle 195-FB Layer 4 (cleanup)
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