Repository navigation
fix(worktrees): prevent cleanup failures on large ignored trees - #148608
Conversation
Closes #148599 Co-authored-by: steipete <[email protected]>
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review completeClawSweeper finished reviewing this revision. The review result is being finalized. |
|
Codex review: needs maintainer review before merge. Reviewed September 14, 2026, 7:38 PM ET / 23:38 UTC. ClawSweeper reviewWhat this changesThe PR changes managed-worktree cleanup and snapshots to enumerate ignored directories incrementally, with regression coverage for restoration, nested repositories, and raw filenames. Merge readiness✅ Ready for maintainer review Keep open: this remains a useful repair for a source-confirmed cleanup failure on current main. No blocking defect was found in the introduced patch, and the protected maintainer label excludes automatic closure. Priority: P2 Review scores
Verification
How this fits togetherManaged worktrees give agent tasks isolated Git checkouts. Cleanup inventories their contents, preserves protected repositories, and creates recovery snapshots before removing eligible checkouts. flowchart TD
A[Eligible managed checkout] --> B[Git file inventory]
B --> C[Incremental ignored-directory scan]
C --> D{Nested repository found?}
D -->|Yes| E[Retain checkout]
D -->|No| F[Snapshot owned files]
F --> G[Remove checkout with recovery available]
Before mergeNone. Agent review detailsSecurityNone. PR surfaceSource +48, Tests +279. Total +327 across 3 files. View PR surface stats
Review metrics
Root-cause clusterRelationship: Members:
Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything. Technical reviewBest possible solution: Keep incremental enumeration in the shared inventory owner while preserving lossless snapshots, nested-repository retention, and fail-closed capture limits. Do we have a high-confidence way to reproduce the issue? Yes, from source: an ignored filename inventory exceeding the Git capture limit prevents cleanup. The supplied reduced-cap regression targets that path; this read-only review did not execute it. Is this the best way to solve the issue? Yes. Compact Git directory records plus incremental traversal repair the inventory owner without increasing global limits or bypassing snapshot safety. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 2e7aa1b7d86b. LabelsLabel changes:
Label justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
|
|
Merged via squash.
|
…claw#148608) Closes openclaw#148599 Co-authored-by: steipete <[email protected]>
Closes #148599
What Problem This Solves
Fixes idle managed-worktree cleanup failing when large ignored dependency or temporary trees exceed Git's buffered filename-output limit.
User Impact
Eligible worktrees can be cleaned up while retaining restorable local edits and owned staged inputs. Nested repositories, origin mismatches and other protected worktrees remain retained. No configuration, retention-policy or schema change is required.
This bounds buffered Git output, not total traversal time. A flat ignored-file inventory can still exceed the unchanged capture limit and fail closed.
Why This Change Was Made
Request compact ignored-directory records from Git and walk those directories incrementally instead of buffering every generated descendant filename. Cleanup inspection and safety snapshots share that inventory owner. Preserve raw filename bytes through Node's unknown-directory-entry fallback, do not follow directory symlinks, and retain existing nested-repository and staged-input ownership checks.
Evidence
DT_UNKNOWNfallback failure before the review correction and pass afterward using real NodeDirtype resolution and filesystem lookup.