fix(worktree): do not report EXIT_OK when .git is absent (PP-ew10) - #2094
fix(worktree): do not report EXIT_OK when .git is absent (PP-ew10)#2094timothyfroehlich wants to merge 4 commits into
Conversation
When a worktree directory has no `.git` marker (partial removal, `rm -rf`
without the hook, or a Web-sandbox session — the PP-qlzu path),
`cleanup_worktree()` skipped the whole Docker/Supabase phase because it
can't derive a branch, and therefore can't target a Supabase project_id.
It then deallocated the slot and returned EXIT_OK ("Cleaned up worktree")
— a false success, since the volumes were never queried at all. That is
the same "success without evidence" shape as PP-omz3 and PP-3w4g, reached
from a third direction: the WorktreeRemove hook reads that 0 as "clean"
while the Supabase volumes may still be on disk.
Record the volume state as UNKNOWN in that path so the run returns
EXIT_DOCKER_UNKNOWN (4) with the `worktree_orphan_sweep.py --apply` hint,
matching the honest-reporting contract the exit code already describes.
The slot is still deallocated, so the sweep (which matches on the Docker
label, not the manifest) remains the backstop — a delayed leak, not a
permanent one. The final message is split so the .git-absent case tells
its own story rather than borrowing the "once Docker is reachable" wording,
which is wrong here (no worktree was git-removed, and Docker was never
contacted).
Adds a regression test alongside the PP-omz3/PP-3w4g cases; verified it
fails on the pre-fix source (returned 0, now 4).
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01JdLKkQtCQRzaTa3gJZnkAu
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
@codex review |
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: c48d5d5a31
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
What
Closes the remaining
worktree_cleanup.pypaths that could exit0without evidence (PP-ew10)..gitmarker — partial removal,rm -rfwithout the hook, or a Web-sandbox session (the PP-qlzu path) — cleanup cannot derive a branch or target a Supabaseproject_id. It used to skip Docker, deallocate the slot, and returnEXIT_OKdespite never querying volumes..gitexists butgit rev-parsecannot report a branch: cleanup could likewise skip Docker and continue toward a successful teardown.Fix
.git-absent path, returningEXIT_DOCKER_UNKNOWN(4). The diagnostic now gives the complete recovery sequence: prune the stale Git registration, then runworktree_orphan_sweep.py --apply. The slot is still deallocated..gitexists but the branch cannot be read, fail closed withEXIT_FAILEDand retain both the worktree and slot manifest entry for investigation. Nothing is queried or removed..git-present Docker-unavailable wording unchanged, and give the.git-absent path its own honest summary.EXIT_DOCKER_UNKNOWNdocumentation to cover volumes that were never queried as well as volumes that could not be enumerated.Tests
test_missing_git_marker_is_incomplete_not_successproves the PP-qlzu path returns 4, deallocates only the slot, never invokes Docker or Git removal, carries both recovery steps, and never prints a clean-success message.test_unreadable_branch_refuses_cleanup_instead_of_reporting_successproves branch lookup failure returns 1 while retaining the worktree and slot and avoiding Docker/removal calls.pnpm run checkpasses (pre-existing warnings only).pnpm run check:pythonpasses: 580 tests.scripts/tests/test_worktree_cleanup.pypasses: 43 tests.Scope / follow-up
No behavior change to healthy cleanup, missing-Docker, Docker-unavailable, stale-target, or main-worktree paths. One adjacent cosmetic inaccuracy remains deliberately out of scope:
worktree_reap.py's exit-4 message says "removed," which is slightly off for the slot-only.git-absent path; it is recorded on the bead.Bead: PP-ew10.
This PR was opened by the unattended nightly bead routine and adopted by Codex-PRBurndown2 for lifecycle completion.
Generated with Claude Code
https://claude.ai/code/session_01JdLKkQtCQRzaTa3gJZnkAu
Generated by Claude Code