fix: judge cwd + shared cube state across worktrees (rebase of #182+#183)#184
Conversation
) PR #182 and #183 squash-merged to empty diffs because they were stacked off the verify-gate branch instead of main. Re-applying both fixes against the actual main HEAD: 1. judge_panel.run_judge: use judge_info.review_worktree as the cwd when the PR review flow synced one. Stops judges from inheriting the operator's Claude Code session worktree (which may be on a stale unrelated branch). Previously: judges reviewed code from cool-satoshi worktree on commits dozens behind the actual PR. 2. config._find_git_root: use 'git rev-parse --git-common-dir' to find the MAIN repo working tree, not the per-Claude-Code-session worktree. All worktrees of the same repo now share .agent-sessions/, .prompts/decisions/, .cube/. Eliminates the 'No session found' regression that came from state being scattered across worktrees. Verified: PROJECT_ROOT resolves to the main repo root from both the main checkout and any Claude Code session worktree. 237 tests pass. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
|
Caution Review failedPull request was closed or merged during review No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
📜 Recent review details🧰 Additional context used🪛 Ruff (0.15.13)python/cube/core/config.py[error] 33-33: Starting a process with a partial executable path (S607) 🔇 Additional comments (2)
WalkthroughThis PR fixes git worktree support by improving how the codebase detects the shared git repository root and ensures judge processes execute from the correct PR review worktree directory instead of potentially stale or incorrect working directories. ChangesGit Worktree Support
Estimated code review effort🎯 2 (Simple) | ⏱️ ~12 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. Comment |
Why
PRs #182 and #183 squash-merged to empty diffs because they were stacked on the verify-gate branch (#181) instead of branched from main. GitHub squashed #181's parent commits into #182's PR, and again into #183's; nothing actually changed for the latter two.
Re-applying both fixes properly against current main HEAD.
What lands
1. `judge_panel.run_judge`: use `review_worktree` as the judge cwd
Stops judges from inheriting the operator's Claude Code session worktree (which may be on a stale unrelated branch). Previously caused judges to review code from a worktree dozens of commits behind the actual PR head — Roy diagnosed this manually on `cool-satoshi-bd8d21`.
2. `_find_git_root`: resolve to the MAIN repo root, not the per-worktree path
Cube state (`.agent-sessions/`, `.prompts/decisions/`, `.cube/`) needs to be shared across all worktrees of the same repo. The naive walk-up stopped at the per-worktree `.git` file. Now uses `git rev-parse --git-common-dir` to find the shared `.git` and returns its parent.
Eliminates the recurring "No session found" regression caused by state scattered across multiple Claude Code worktrees.
Verified
🤖 Generated with Claude Code
Overview
Re-applies fixes from PRs
#182and#183, addressing worktree isolation and shared repository state issues that arose when judges and cube utilities operate across Git worktrees.Key Changes
judge_panel.py:
run_judgenow explicitly usesjudge_info.review_worktreeas the working directory when available, preventing judges from inheriting the operator's potentially stale/unrelated Claude Code session worktree. Falls back to previous behaviour if no review worktree is set.config.py:
_find_git_root()now usesgit rev-parse --git-common-dirto identify the shared.gitdirectory, ensuring it returns the main repository root rather than stopping at per-worktree.gitfiles. This guarantees cube state directories (.agent-sessions/,.prompts/decisions/,.cube/) are shared across all worktrees. Includes fallback to legacy walk-up method when git-based lookup fails.Verification
PROJECT_ROOTcorrectly resolves to main repo root from both primary checkout and worktree contexts