feat: jj workspace 並列セッション安全化 — ADR-045 改訂 + push -b 明示化 + stale/op 検証 hook (順位278/279消化) - #267
Conversation
…79消化、ADR-054 事故 follow-up)
…ADR-045 G案、opt-in)
📝 WalkthroughWalkthroughJJのpush対象をbookmark単位に限定し、workspace stale通知とoperation記録検証hookを追加した。関連する設定、ビルド配線、ADR、TODO記録、テストを更新した。 ChangesPush対象の限定
Workspace stale通知
JJ Operation検証フック
Estimated code review effort: 4 (Complex) | ~45 minutes Sequence Diagram(s)Push対象の受け渡しsequenceDiagram
participant PushRunner
participant BookmarkCheck
participant PushStage
participant JJ
PushRunner->>BookmarkCheck: 非trunk bookmarkを検出
BookmarkCheck-->>PushRunner: bookmark名一覧
PushRunner->>PushStage: detected_bookmarksを渡す
PushStage->>JJ: -b <name>付きjj git pushを実行
Operation記録検証sequenceDiagram
participant BashPostToolUse
participant JjOpVerify
participant JJ
BashPostToolUse->>JjOpVerify: Bash実行結果を渡す
JjOpVerify->>JJ: jj op log --limit 1を実行
JJ-->>JjOpVerify: 直近operationを返す
JjOpVerify-->>BashPostToolUse: OKまたは警告contextを返す
Possibly related PRs
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
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 |
🤖 PR Monitor 分析 (GitHub Actions バックストップ)
Applicable Findings (Critical / High / Major)(該当なし — レビュー指摘が 1 件も無いため省略) Applicable Findings (Medium 以下)(該当なし — レビュー指摘が 1 件も無いため省略) Filtered (not applicable)(該当なし) Diff 概要 (軽量サマリー)19 ファイル変更 (
CodeRabbit のレビューは未着 (処理中)。 次のアクション
|
There was a problem hiding this comment.
🧹 Nitpick comments (2)
src/hooks-post-tool-jj-op-verify/src/main.rs (1)
61-95: 🎯 Functional Correctness | 🔵 Trivial | ⚡ Quick win変更系 jj コマンドの検出対象に漏れがあります。
以下の変更系コマンドが
detect_last_mutating_jj_opで未検出です:
jj undo— 直前の操作取り消し (lost-update 再発リスクが高い)jj restore— ファイル復元jj split— commit 分割jj bookmark move—bookmark setの後継コマンド (jj バージョンによってsetが非推奨化されている可能性あり)jj bookmark track/untrack— remote bookmark 追跡設定の変更
bookmark moveは特に重要です — プロジェクトの jj バージョンがset→move移行済みの場合、bookmark moveコマンドが検出されず検証対象から漏れます。現在bookmark setに紐づけている"point bookmark"キーワードの妥当性も含めて確認が必要です。♻️ 提案する拡張
let detected = match *sub { "new" => Some(("new", "new empty commit")), "describe" => Some(("describe", "describe commit")), "abandon" => Some(("abandon", "abandon commit")), "rebase" => Some(("rebase", "rebase commit")), "squash" => Some(("squash", "squash")), + "undo" => Some(("undo", "undo operation")), + "restore" => Some(("restore", "restore")), + "split" => Some(("split", "split commit")), "bookmark" => match tokens.get(i + 2).copied() { Some("create") => Some(("bookmark create", "create bookmark")), Some("set") => Some(("bookmark set", "point bookmark")), + Some("move") => Some(("bookmark move", "point bookmark")), Some("delete") => Some(("bookmark delete", "delete bookmark")), Some("forget") => Some(("bookmark forget", "forget bookmark")), Some("rename") => Some(("bookmark rename", "rename bookmark")), + Some("track") => Some(("bookmark track", "track bookmark")), + Some("untrack") => Some(("bookmark untrack", "untrack bookmark")), _ => None, }, _ => None, };各
expected_op_keywordは実際の jj op log の description 文言と照合してください。🤖 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 `@src/hooks-post-tool-jj-op-verify/src/main.rs` around lines 61 - 95, 拡張された変更系コマンドを detect_last_mutating_jj_op で検出し、undo・restore・split と bookmark の move・track・untrack を対応する expected_op_keyword とともに追加してください。bookmark set の既存検出は維持しつつ、各キーワードが実際の jj operation log の description と一致する文言になるよう確認・調整してください。src/hooks-session-start/src/hooks_config.rs (1)
93-116: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win
stale_check_enabledのパーステストを追加してください。既存テスト
hooks_config_parses_session_start_staleness_sectionはstale_check_enabledを含んでいません。新フィールドの TOML パースを検証するため、テスト TOML と assertion に追加することを推奨します。✨ 提案するテスト拡張
[session_start.staleness] enabled = true fetch_timeout_secs = 5 default_branch = "main" +stale_check_enabled = true "#;assert_eq!(staleness.enabled, Some(true)); assert_eq!(staleness.fetch_timeout_secs, Some(5)); assert_eq!(staleness.default_branch.as_deref(), Some("main")); + assert_eq!(staleness.stale_check_enabled, Some(true));🤖 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 `@src/hooks-session-start/src/hooks_config.rs` around lines 93 - 116, Extend hooks_config_parses_session_start_staleness_section to include a stale_check_enabled entry in the test TOML and assert the parsed staleness.stale_check_enabled value, preserving the existing field assertions.
🤖 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 `@src/hooks-post-tool-jj-op-verify/src/main.rs`:
- Around line 61-95: 拡張された変更系コマンドを detect_last_mutating_jj_op
で検出し、undo・restore・split と bookmark の move・track・untrack を対応する
expected_op_keyword とともに追加してください。bookmark set の既存検出は維持しつつ、各キーワードが実際の jj
operation log の description と一致する文言になるよう確認・調整してください。
In `@src/hooks-session-start/src/hooks_config.rs`:
- Around line 93-116: Extend hooks_config_parses_session_start_staleness_section
to include a stale_check_enabled entry in the test TOML and assert the parsed
staleness.stale_check_enabled value, preserving the existing field assertions.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: f854efb5-5754-4158-ba39-8b55a28a0e0e
⛔ Files ignored due to path filters (1)
Cargo.lockis excluded by!**/*.lock
📒 Files selected for processing (19)
.claude/hooks-config.toml.claude/settings.local.json.templateCargo.tomldocs/adr/adr-015-push-runner-takt-migration.mddocs/adr/adr-045-jj-workspace-parallel-sessions.mddocs/todo-summary.mddocs/todo13.mdpackage.jsonpush-runner-config.tomlsrc/cli-push-runner/src/main.rssrc/cli-push-runner/src/stages/bookmark_check.rssrc/cli-push-runner/src/stages/push.rssrc/hooks-post-tool-jj-op-verify/Cargo.tomlsrc/hooks-post-tool-jj-op-verify/src/main.rssrc/hooks-session-start/src/hooks_config.rssrc/hooks-session-start/src/jj_helpers.rssrc/hooks-session-start/src/main.rssrc/hooks-session-start/src/staleness.rstemplates/push-runner-config.toml
💤 Files with no reviewable changes (2)
- docs/todo13.md
- docs/todo-summary.md
🤖 PR Monitor 分析 (GitHub Actions バックストップ)
Applicable Findings (Critical / High / Major)(該当なし) Applicable Findings (Medium 以下)
Filtered (not applicable)
次のアクション
|
概要
jj workspace 並列セッション運用での lost-update incident (2026-07-12/13、2 コミット分の操作が op log に痕跡なく消失) の再発防止セット。jj 公式の lock-free 設計を尊重し、ロックではなく「危険操作の排除 + 早期検知」で防御する。todo 順位 278/279 を消化。
変更内容 (コミット単位)
update-stale→ recovery commit / bookmark 競合) に即して是正。Known operational risks (stale / bookmark 競合 / colocated 未テスト / output corruption 事故記録)・並列運用の運用ルール (1 terminal = 1 session、--all禁止等 7 項)・Operation Verification Checklist の 3 節を新設。再評価 trigger fix(hooks): extra_protected_files でパス付き指定をサポート #3 の発火を記録-b明示化: push stage が bookmark_check の検出名からjj git push -b <name>を組み立て、--allを廃止 (他 workspace の bookmark 巻き込み防止)。jj 0.42 の-bは新規 bookmark を自動 track するため--allの存在理由 (新規 bookmark push) を代替。shell-safe 検証付き、--allを含む旧 config は従来挙動 (後方互換)。config + templates 更新jj workspace update-staleを促す (自動実行しない、recovery commit の勝手な生成を避ける)hooks-post-tool-jj-op-verify。変更系 jj コマンド後にjj op log --limit 1で operation の記録を確認し、無ければ「operation not recorded」警告。incident の「成功表示だが記録なし」クラスを即時検出する設計判断
jj-push-guardpreset が対話操作のjj git pushを全 block 済み。ギャップは exe 層のみだった (ADR-015 の 2 層管理原則として記録)enabled = false)実地検証
[push] jj git push -b parallel-session-safetyで新規 bookmark が auto-track 付きで push 成功 (--allなし)jj bookmark createに対し「OK: operation を記録確認」を自動返答、偽 payload (実行されていないjj new) に対し「operation not recorded」警告を正しく発報cargo clippy --workspace --all-targets -- -D warnings: clean /cargo test --workspace: 全 green (新規 24 テスト含む) /pnpm lint:docs: OKkill-switch table (ADR-039)
-b組み立て[push] command = "jj git push"--allを戻す (後方互換分岐で従来挙動).claude/hooks-config.toml[session_start.staleness] stale_check_enabled = truefalseに戻す[post_tool_use.jj_op_verify] enabled = truefalseに戻す🤖 Generated with Claude Code
Summary by CodeRabbit