fix: 4 proactive bugs from codebase scan#192
Conversation
…ts, rate-limit pattern, scan scope) Found by proactive grep, all real: 1. create_worktree returned stale worktrees without verifying branch — matched Roy's slice-3 post-mortem symptom (detached HEAD + staged junk from prior failed run). Now branch + cleanliness check; reset to writer-<name>/<task> + origin/main when wrong; recreate when even that fails. Preserves in-progress writer state when worktree is on the correct branch (existing test pattern kept and renamed). 2. has_uncommitted_changes / has_unpushed_commits had no subprocess timeout — could hang cube indefinitely on stuck git locks. Added 10s/15s timeouts. 3. Claude rate-limit pattern only matched 'rate limit'/'capacity'/'overloaded'. Anthropic's org-monthly cap message is 'You've hit your org's monthly usage limit' — bypassed detection. claude judges silently failed, panel showed '0/2 approved'. Extended pattern to include monthly/usage limit/quota/hit-your-org. 4. find_decision_file scanned every project under WORKTREE_BASE (90+ on Jacob's machine) on every decision lookup. O(N*M) disk hit per judge per panel. Scoped to PROJECT_ROOT's project dir only. 238 tests pass (was 237 + 1 new for the wrong-branch reset path).
|
Caution Review failedThe pull request is closed. ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (4)
WalkthroughThis PR hardens git worktree management by adding conditional reuse checks and timeout guards, narrows decision-file worktree search scope, and expands Claude rate-limit error phrase matching. Existing worktrees are now validated for correctness before reuse; stale ones are reset or removed. Tests verify both reuse and reset paths. ChangesWorktree robustness and error handling
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related PRs
Poem
Comment |
Found via proactive scan. All real, all independent of the user-reported bugs.
create_worktreebranch verify — was silently reusing stale worktrees on wrong branch; now reset+recreate when wrong, preserve when righthas_uncommitted_changes/has_unpushed_commitstimeouts — could hang cube on stuck git lockfilefind_decision_filescoped scan — was walking all 90+ project worktrees on every lookup238 tests pass.
Summary
Four independent proactive bug fixes addressing stability and performance issues:
1. Worktree reuse now validates state (
git.py)Previously,
create_worktreecould blindly reuse stale worktrees on the wrong branch. Now verifies both branch and cleanliness before reusing; if incorrect, attempts reset viagit checkout -B ... origin/mainfollowed by hard reset and clean. Falls back to removing and recreating if reset fails. Includes new test coverage for the wrong-branch reset path.2. Git subprocess timeouts prevent indefinite hangs (
git.py)Added 10-second timeout to
has_uncommitted_changesand 15-second timeout tohas_unpushed_commitsto prevent hangs when git lockfiles block subprocess operations.3. Extended Claude rate-limit detection (
claude.py)Expanded error pattern recognition to catch Anthropic's org-monthly usage cap message ("You've hit your org's monthly usage limit") alongside existing "rate limit" and "capacity" matches. Previously missed this variant, causing judges to fail silently.
4. Optimised decision file lookup (
decision_files.py)Scoped
find_decision_fileworktree search to the specific project directory rather than iterating all 90+ worktrees underWORKTREE_BASE. Eliminates O(N×M) disk scans on each lookup.Tests: 238 passing; 1 new test added for wrong-branch reset validation.