Skip to content

feat(post-merge-feedback): L2 recovery hook を実装 (ADR-030 Phase C)#80

Merged
aloekun merged 2 commits intomasterfrom
feat-l2-recovery
Apr 26, 2026
Merged

feat(post-merge-feedback): L2 recovery hook を実装 (ADR-030 Phase C)#80
aloekun merged 2 commits intomasterfrom
feat-l2-recovery

Conversation

@aloekun
Copy link
Copy Markdown
Owner

@aloekun aloekun commented Apr 26, 2026

Summary

  • ADR-030 Phase C: UserPromptSubmit hook (hooks-user-prompt-feedback-recovery) を新規追加し、.claude/feedback-reports/*.md.failed marker を検出した場合に additionalContext で Claude に再実行を促す L2 recovery 経路 を実装
  • soft fail policy: L1 (cli-merge-pipeline → takt workflow) が失敗しても merge は成功扱い、後続 prompt で marker を拾うことで silent loss を防ぐ二層構造を完成
  • exit 0 を厳守 (UserPromptSubmit の exit 2 は prompt 自体をブロックするため、stdin parse 失敗 / I/O 失敗もすべて silent exit に倒す)

主要変更

  • 新 crate src/hooks-user-prompt-feedback-recovery/ (workspace member, 11 unit tests, all green)
  • additionalContext は [POST_MERGE_FEEDBACK_RECOVERY] タグ + count + 各 marker の絶対パスを PR 番号昇順 で列挙 (Stop hook の [POST_MERGE_FEEDBACK_TRIGGER] と命名規約を統一)
  • <pr>.md.failed 形式以外のファイルは defensive に無視 (78.md 成功レポート / readme.txt / not-a-pr.md.failed などは skip)
  • 配布経路を全て更新: Cargo.toml workspace members / package.json build:all / scripts/deploy-hooks.ts EXE_FILES / .claude/settings.local.json.templateUserPromptSubmit エントリ
  • cli-merge-pipeline::feedback::write_failed_marker の marker 本文を改修:
    • 未実装の pnpm feedback-retry 参照を削除
    • pnpm exec takt -w post-merge-feedback ... の手動再実行手順 + cross-PR overwrite 警告 (.takt/post-merge-feedback-context.jsonpr_number 一致確認) を追加
  • 運用ルール (完了タスクは todo.md から削除) に従い docs/todo.md の Phase C セクションを除去 (別 commit)

Validation

  • cargo test -p hooks-user-prompt-feedback-recovery --release — 11 passed (parse / collect 4 ケース / format 3 ケース / serialize / 不正 stdin)
  • cargo test --release -p cli-merge-pipeline — 44 passed (marker body 改修後リグレッションなし)
  • cargo clippy -p hooks-user-prompt-feedback-recovery --release -- -D warnings — clean
  • pnpm build:all — 全 exe ビルド + .claude/ 配布成功
  • smoke test: marker なし → silent exit / 9999.md.failed 作成 → 正しい JSON (hookEventName / additionalContext / 絶対パス) を出力 + exit 0
  • pnpm push (pre-push-review takt workflow): security + simplicity 共に APPROVE in 1 iteration

Test plan (Phase F dogfood)

  • 次回正常マージ: L1 成功 → marker が生成されない (cleanup 経路) ことを確認
  • cli-merge-pipeline で takt 失敗を意図的に inject: <pr>.md.failed 残存 → 次 prompt で UserPromptSubmit hook 発火 → additionalContext 出力 → Claude が手動再実行手順を実行できることを確認
  • 複数 PR の marker が同時に存在するシナリオ (本実装が PR 番号昇順で列挙する性質の確認)

References

Summary by CodeRabbit

リリースノート

  • 新機能

    • ユーザープロンプト送信時に自動的に実行される新しいフィードバック復旧メカニズムを追加しました。
  • ドキュメント

    • フィードバック失敗時の復旧手順のガイダンスを更新しました。失敗マーカーの確認と手動でのリトライプロセスに関する指示を改善しています。

aloekun added 2 commits April 26, 2026 14:21
…DR-030 Phase C)

`.claude/feedback-reports/*.md.failed` marker を検出した場合に additionalContext で
Claude に再実行を促す `hooks-user-prompt-feedback-recovery` exe を新規追加する。

主要変更:
- 新 crate `hooks-user-prompt-feedback-recovery` (workspace member, 11 unit tests)
- exit 0 を厳守 (UserPromptSubmit で exit 2 は prompt をブロックする)
- additionalContext は `[POST_MERGE_FEEDBACK_RECOVERY]` タグ + count + 各 marker の
  絶対パスを PR 番号昇順で列挙
- `<pr>.md.failed` 形式以外のファイルは無視 (defensive)
- `package.json` の `build:all` / `scripts/deploy-hooks.ts` の `EXE_FILES` /
  `.claude/settings.local.json.template` の UserPromptSubmit エントリを更新
- `cli-merge-pipeline` の `feedback::write_failed_marker` の marker 本文を更新:
  - 未実装の `pnpm feedback-retry` への参照を削除
  - `pnpm exec takt -w post-merge-feedback ...` の手動再実行手順 +
    cross-PR overwrite 警告 (context.json の pr_number 確認) に差し替え
運用ルール (todo.md 冒頭): 完了タスクは ADR/仕組みに反映後、todo.md から削除する。
Phase C は実装され ADR-030 §L2 Recovery で記述済みのためエントリを除去する。
Phase E (旧機構廃止) と Phase F (dogfood 検証) は引き続き残す。
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Apr 26, 2026

📝 Walkthrough

Walkthrough

新しい UserPromptSubmit フックを実装し、プロンプト送信時に失敗マーカーを回復するツール (hooks-user-prompt-feedback-recovery.exe) を実行します。Rust のクレート、設定、ビルドスクリプト、デプロイメント、および失敗マーカーの案内テキストが追加・更新されました。

Changes

Cohort / File(s) Summary
Hook Configuration & Workspace Tooling
.claude/settings.local.json.template, Cargo.toml, package.json, scripts/deploy-hooks.ts
新しい UserPromptSubmit フックの設定を追加し、ワークスペースメンバーに新しいクレートを登録、ビルドスクリプト build:hooks-user-prompt-feedback-recovery を追加、デプロイメントスクリプトに新しいフック実行ファイルを含める。
Hook Implementation
src/hooks-user-prompt-feedback-recovery/Cargo.toml, src/hooks-user-prompt-feedback-recovery/src/main.rs
新しい Rust クレートを追加。stdin を読込、.claude/feedback-reports/ ディレクトリをスキャンして失敗マーカー(.md.failed ファイル)を検出し、JSON 形式で hookEventNameadditionalContext を出力。PR番号でソートされたマーカーリストと回復手順を含む。単体テストで filename 解析、ディレクトリ操作、JSON シリアライゼーションをカバー。
Documentation & Failure Marker Guidance
docs/todo.md, src/cli-merge-pipeline/src/feedback.rs
Phase C チェックリスト項目を完全削除。失敗マーカーの復旧手順テキストを更新し、新しい hooks-user-prompt-feedback-recovery フック経由での回復、および pnpm exec takt コマンドの手動再実行手順へ変更。マーカーテンプレートに TAKT_WORKFLOWTAKT_TASK_PREFIX の補間を追加。

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~22 minutes

Possibly related PRs

  • PR #79: src/cli-merge-pipeline/src/feedback.rs を同時に修正しており、失敗マーカーフローのタイムアウト・調整・並行処理ロジックに関連。
  • PR #75: ADR-030 で説明される hooks-user-prompt-feedback-recovery フックの実装仕様ドキュメント。
  • PR #8: 他の新しいスタンドアロンフック実行ファイルを追加した際と同じパターン(ワークスペースメンバー、ビルドスクリプト、deploy-hooks.ts エントリの追加)で関連。
🚥 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 タイトルは ADR-030 Phase C の L2 recovery フック実装という主要な変更を正確に反映しており、changeset の中心的な目的を明確に示しています。
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/cli-merge-pipeline/src/feedback.rs (1)

398-422: LGTM!

復旧手順の文面更新は L2 recovery 設計と整合しています。手動再実行コマンド (pnpm exec takt -w {TAKT_WORKFLOW} -t "{TAKT_TASK_PREFIX}{pr_number}") は run_takt_workflow (Line 327-328) と同一パラメータで呼び出すため、再実行時に同じ run dir 命名規則が適用されます。cross-PR overwrite 警告も具体的な検証ポイント(pr_number の一致確認)まで踏み込んでおり、運用上の落とし穴を適切にカバーしています。

format! の {} プレースホルダ 8 個と引数 8 個も一致しています。

💡 任意の改善案

context.json が既に別 PR で上書きされていた場合、step 3 の手動再実行は別 PR の transcript range を使ってしまいます。「不一致を検出した場合の選択肢(context.json を当該 PR 用に書き直す or feedback を諦める)」を 1 行追記すると、運用時に迷わず判断できそうです。本 PR スコープ外でも問題ありません。

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/cli-merge-pipeline/src/feedback.rs` around lines 398 - 422, Summary: No
code change required—the formatted message uses eight `{}` placeholders matching
eight arguments and the manual rerun command matches run_takt_workflow
parameters. Action: Leave the block that builds body and writes the marker file
as-is; verify that TAKT_WORKFLOW and TAKT_TASK_PREFIX constants and the call
site run_takt_workflow still use the same parameters (see TAKT_WORKFLOW,
TAKT_TASK_PREFIX, run_takt_workflow and the fs::write call) and then approve the
change.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@src/cli-merge-pipeline/src/feedback.rs`:
- Around line 398-422: Summary: No code change required—the formatted message
uses eight `{}` placeholders matching eight arguments and the manual rerun
command matches run_takt_workflow parameters. Action: Leave the block that
builds body and writes the marker file as-is; verify that TAKT_WORKFLOW and
TAKT_TASK_PREFIX constants and the call site run_takt_workflow still use the
same parameters (see TAKT_WORKFLOW, TAKT_TASK_PREFIX, run_takt_workflow and the
fs::write call) and then approve the change.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 81650274-b8a8-49cf-9ba5-a17a953b3e49

📥 Commits

Reviewing files that changed from the base of the PR and between 72a1f47 and 0b8b9e5.

⛔ Files ignored due to path filters (1)
  • Cargo.lock is excluded by !**/*.lock
📒 Files selected for processing (8)
  • .claude/settings.local.json.template
  • Cargo.toml
  • docs/todo.md
  • package.json
  • scripts/deploy-hooks.ts
  • src/cli-merge-pipeline/src/feedback.rs
  • src/hooks-user-prompt-feedback-recovery/Cargo.toml
  • src/hooks-user-prompt-feedback-recovery/src/main.rs
💤 Files with no reviewable changes (1)
  • docs/todo.md

@aloekun aloekun merged commit 58d2626 into master Apr 26, 2026
1 check passed
@aloekun aloekun deleted the feat-l2-recovery branch April 26, 2026 06:23
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