COSI_WORKTREES_DIR links worktrees only at startup: a lane created mid-session is invisible to every tool #310
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#310
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?
Found while dogfooding on 2026-10-02.
With
COSI_WORKTREES_DIRset (#238), each worktree under that directory becomes a project namedagent-<id>.project_overviewsays the link was "Discovered at startup: a worktree created since then is not here." In practice the agent workflow creates a worktree for every lane, AFTER the MCP server has started. Today four lanes were spawned after the server started, and their worktrees became reachable only after a manual/mcpreconnect.Impact. A lane's own code is invisible to
search_symbols,search_text,file_outline,find_callers,changed_symbolsandreview_difffor the whole life of the lane. Agents fall back to grep and sed, which is the failure #238 set out to fix. Lanes Q and P of #309 reported exactly this.Expected. Worktrees created under
COSI_WORKTREES_DIRare discovered while the server runs, for example by the watcher on that directory or by a re-scan onproject_not_foundfor anagent-*name. They are disclosed the same way startup links are. A worktree removed mid-session goesproject_not_available, not stale.Test. Start the server, create a worktree, then query
project: "agent-<new>"→ answered. Mutation: disable rediscovery →project_not_found.This is the second half of the same problem, observed on 2026-10-02: a linked worktree removed mid-session is resurrected.
git worktree removedeleted.claude/worktrees/agent-ac20002b5c531d127. The directory then came back holding only.code-index/(created 18:27, the minute of the removal), sogit worktree removefailed with "Directory not empty". The server still had the link from startup, and something in its per-link handling recreated the index directory under a project root that no longer existed.Expected: when a linked root disappears, the link becomes
project_not_availableand nothing is created there. The index directory of a missing root must never be created; at most it is opened if it still exists. Test: link a worktree, remove it, query the link →project_not_available, and the path does not exist afterwards.Fixed in v0.41.0 (merge
9f1ae9c2, PR #389).The linked-worktree set is no longer frozen at startup.
crates/mcp-server/src/project_set.rsre-derives it from the worktrees directory, at most once per 2 s (REDERIVE_BOUND), so:agent-<id>without a/mcpreconnect;Test:
crates/mcp-server/tests/worktree_projects_e2e.rsstarts the server, creates a worktree, queries it by name (answered), removes it, and queries again (gone). Mutation run during verification: never re-derive → both cases RED.🤖 Generated with Claude Code