Prevent nested worktree sync traversal#236
Merged
Merged
Conversation
005d4c6 to
edda1a4
Compare
edda1a4 to
7db21fd
Compare
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.
Why this matters
.claude/worktreesor.codex/worktrees.worktreesstate, a single recursive copy or recursive scan can enter a 5-10 GB tree and saturate disk bandwidth.Summary
worktreeschildren when syncing root config directories such as.claude,.codex, or custom.agententriesworktreesduring Unix recursive/glob discovery before traversalworktreesdirectories and their contents.agent/worktreesorworktreesas exact sync entriesVisual Overview
worktreesis now a traversal boundary for default/parent sync. Pane can copy config beside it, but does not cross into generated workspace state unless the user explicitly syncs that exact path.flowchart LR subgraph Before[Before: parent directory copy] A[Pane syncs .agent] --> B[recursive copy / recursive scan] B --> C[.agent/settings.json copied] B --> D[.agent/worktrees/... entered] D --> E[huge generated workspace GBs + high file count app or machine stalls] end subgraph After[After: generated workspace boundary] F[Pane syncs .agent] --> G[enumerate direct children] G --> H[copy .agent/settings.json] G --> I{child name is worktrees?} I -->|yes| J[skip before traversal] I -->|explicit exact entry| K[copy only when user opted in] L[recursive discovery] --> M[find/glob prunes worktrees dirs] endExcalidraw source saved locally at
/tmp/codex-pr-diagrams/pr-236/worktree-sync-no-traverse.excalidraw.Verification
pnpm --filter main exec vitest run src/services/__tests__/worktreeFileSyncService.test.tspnpm --filter main typecheckpnpm --filter main lint(passes with existing warnings)pnpm run -r typecheckandpnpm run -r lintNote: this shell uses Node
v20.19.3, so pnpm emitted the existing engine warning because the repo asks for Node>=22.14.0. The commands still exited successfully.