Repository navigation
fix(forker): tolerate vanished Git worktree locks - #2623
Merged
Merged
Conversation
Handle the remaining concurrent-fork observation in #2327 at both the walk and source-open boundaries. Preserve existing locks and propagate unrelated source and destination failures. Co-authored-by: Mecatl <[email protected]>
ChrisJBurns
approved these changes
Oct 30, 2026
10 of 14 tasks
Merged
2 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fix the remaining
internal/adapter/forkerobservation in #2327:TestForkDirtyOverlayConcurrentcan fail when copying.git/worktrees/<id>/lockedwhile Git removes that temporary checkout lock.ErrNotExistonly for the exact.git/worktrees/<single-id>/lockedpath, both at the walk boundary and after enumeration when opening the source file.ENOENTremains a failure.lockedcan also represent an intentional operator-owned worktree lock.Evidence and regression coverage
The original CI attempt reports:
A failed worktree creation takes the recursive-copy fallback while other concurrent worktree creations mutate the repository's administrative files. The old copy walker failed if an enumerated
lockedfile disappeared beforeos.Open.The deterministic regression saves a real regular-file
DirEntry, removes the file, and invokes the production callback. Both walk-time and source-open assertions fail before the fix. Negative controls retain errors for missing worktree HEAD/index locks, malformed/nested paths, ordinary tracked files, walk permission failures, non-ENOENT source-open failures, and destination-side ENOENT. A fullcopyTreetest verifies an existing lock's contents are preserved.Mutation checks:
Verification
-count=50 -cpu=1,2,4(150 executions per selected top-level test), includingTestForkDirtyOverlayConcurrent, copy-tree regressions, existing maintenance-lock tests, and force-copy maintenance-lock integration.task test.task lint(including after the final test addition).task test:race.go run ./cmd/mecademo: real offline engine tool call, permission ask/approval, and final result; team and background subagent demos also passed.API compatibility
Backward-compatible bug fix restoring successful local environment forking when a Git administrative lock disappears. No client changes, wire schemas, event/control semantics, API major, or feature identifiers change. No exported Go API or persisted-data format changes; no migration or coordinated upgrade required.
This addresses only the related forker observation in #2327. It does not close the umbrella tracker or claim all concurrent Git metadata races are solved.