anthropics / anthropics/claude-code

Session's declared worktree path sometimes not populated by git worktree add — falls through to shared main checkout

Đang mở
#91,349 0 bình luận 0 reaction 0 người được giao Xem trên GitHub
area:core bug
Ngôn ngữ chính
Python
Star
145k
Fork
23.1k
Chỉ số merge pull request
Chỉ số pull request đang chờ

Mô tả

Investigating a session that was given a `.claude/worktrees/` path in its system prompt as its "Worktree path", but the directory was completely empty (no `.git`, no files) even though the session had already done real work (reading files, editing, committing, pushing a branch, opening/merging a PR).

Because `git` walks up parent directories looking for `.git` when none exists in the cwd, every git command run with that empty directory as cwd silently resolved to and operated on the shared main repo checkout instead of an isolated worktree. The session's own commits/push/PR were still valid (they hit the real `.git` and remote), so no work was lost in that instance — but the isolation the harness presumably intended was silently absent for the whole session, and a concurrent session using the same shared checkout could have had its own in-progress branch/checkout state stomped on.

Broader check across the same repo (read-only) found this is not a one-off: under `.claude/worktrees/` there were 12 directories total, but `git worktree list` only registered 6 of them as real, populated git worktrees. The other 6 were empty shells not registered in `git worktree list` at all, with folder mtimes spanning at least two days and clearly many separate sessions (not one bad run). One of the six was later cleaned up automatically (removed entirely) between checks; the other five are still sitting there empty and unregistered.

This suggests the session-provisioning step creates/declares a worktree folder and path, but the corresponding `git worktree add` that should populate and register it doesn't always run (or fails silently, or races) — leaving the session pointed at a path that git treats as no worktree at all, with a silent fallback to the shared checkout rather than any error.

Reported as a repo-external / harness-level issue since there's no application code path to fix; happy to share more detail on the repo layout if useful (kept generic here since the actual repo is private).

Hướng dẫn đóng góp

Chưa lập chỉ mục được hướng dẫn đóng góp cho kho mã nguồn này

Hướng nghiên cứu

Begin with the harness-level session-provisioning path that creates `.claude/worktrees/`, then compare the expected `git worktree add` step with `git worktree list` for empty directories. Done means each declared path is populated and registered, while any failed or raced provisioning attempt reports an error instead of falling back to the shared checkout.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Đánh giá

Công nghệ
git
Lĩnh vực
cli, devtools
Loại issue
Lỗi
Độ khó
4/5
Thời gian dự kiến
3-5 ngày
Mức độ hoạt động
Sôi nổi
Độ rõ ràng
Cần làm rõ
Mức phù hợp với người mới
25/100

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.