A removed worktree is resurrected: the MCP server respawns its daemon, which recreates the directory, and provenance then reports the parent repo's HEAD as its head #361
Labels
No labels
code-review
correctness
dos
performance
security
severity/high
severity/low
severity/medium
tech-debt
Kind/Breaking
Kind/Bug
Kind/Documentation
Kind/Enhancement
Kind/Feature
Kind/Security
Kind/Testing
Priority
Critical
Priority
High
Priority
Low
Priority
Medium
Reviewed
Confirmed
Reviewed
Duplicate
Reviewed
Invalid
Reviewed
Won't Fix
Status
Abandoned
Status
Blocked
Status
Need More Info
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
h-dv/code-index#361
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Observed (0.36.1 /
876b78b5, 2026-10-12).claude/worktreesas linked projects (it lists them only at startup, #310).git worktree removeafter stopping each one's daemon by PID.project_overview) spawned new daemons for three of the removed roots (agent-a0914…,agent-ab2a1…,agent-af2fc…). Each daemon recreated the deleted root directory to hold a fresh.code-index/.answer_provenance.indexed_treesthen reported, for those three:"head":"407c49251ccd","uncommitted_changes":false, which is the primary checkout's HEAD.git -Cin a directory holding only.code-index/walks up to the parent repository.unavailable: cannot change to …: No such file or directory.This has happened before: 11 more directories under
.claude/worktreescontained only.code-index/, dated 2026-10-04 and 2026-10-10, both earlier worktree cleanups.Why it matters
Expected
daemon_command/ attach-or-spawn refuses to start for a root that does not exist, instead of creating it. Same answer asunavailable, with the reason.indexed_treesderivesheadonly when the root is itself a git worktree top level (git rev-parse --show-toplevelequals the root). Otherwise it reports unavailable, never the parent repo's HEAD.🤖 Generated with Claude Code
Fixed in v0.41.0 (merge
9f1ae9c2, PR #389).spawn_refusal) instead of starting a daemon for it. The state directory is no longer created through a missing parent (ensure_state_dir), and the panic log is opened without recreating parents (panic_log::appendthroughcreate_state_dir_tight). So no daemon recreates a removed worktree.unavailable: … No such file or directoryand never walks up to the parent repository.crates/mcp-server/tests/worktree_projects_e2e.rsremoves a worktree mid-session, queries, and asserts the root is not recreated and the project is gone. Mutations run during verification: the log append back tocreate_dir_all→ RED; never re-derive → RED.🤖 Generated with Claude Code