Repository navigation
fix(worktrees): keep worktrees placed directly under the worktrees root (#119691) - #119709
Conversation
|
Codex review: needs maintainer review before merge. Reviewed August 5, 2026, 8:44 PM ET / August 6, 2026, 00:44 UTC. ClawSweeper reviewWhat this changesThe PR changes managed-worktree orphan cleanup to preserve registered direct-root, nested, unborn, and canonical-path-alias Git worktrees while deleting genuine debris. Regression provenancePossible regression — probable (reproduction; reviewed change). No predecessor PR is attributed. Merge readinessThe rewritten patch addresses the confirmed destructive cleanup path at its owner boundary and resolves the prior unborn-worktree finding. No actionable patch defect was found; keep this PR open for exact-head CI completion and normal merge gating. Priority: P0 Review scores
Verification
How this fits togetherThe managed-worktree service periodically scans OpenClaw’s state-directory worktree tree and removes unregistered leftovers. It must identify registered Git checkout roots before recursive descent so garbage collection cannot delete a user’s working tree. flowchart TD
A[Gateway maintenance sweep] --> B[Managed worktree cleanup]
B --> C[Classify directory]
C --> D[Git worktree registry]
D --> E[Preserve registered checkout]
C --> F[Remove genuine orphan]
E --> G[User worktree intact]
F --> H[State directory cleaned]
Before merge
Agent review detailsSecurityNone. PR surfaceSource +44, Tests +149. Total +193 across 2 files. View PR surface stats
Review metrics
Stored data modelPersistent data-model change detected: Root-cause clusterRelationship: Members:
Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything. Merge-risk optionsMaintainer options:
Technical reviewBest possible solution: Land the fail-closed, registry-based preservation flow after exact-head CI passes, retaining the real-Git regression suite as protection for direct-root and unborn checkouts. Do we have a high-confidence way to reproduce the issue? Yes. Current main’s top-level scan descends into a direct-root checkout and deletes child directories; the PR’s real-Git regression suite directly exercises that path and its unborn variants. Is this the best way to solve the issue? Yes. The preservation decision now occurs in the orphan-reconciliation owner before descent or deletion; a root-only .git skip would miss nested, unborn, and canonical-path cases. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against d28371e95d70. LabelsLabel changes:
Label justifications:
EvidenceWhat I checked:
Likely related people:
Rank-up movesOptional improvements that raise the rating; they are not merge blockers.
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (2 earlier review cycles)
|
Classify direct and nested checkout roots through Git worktree registration before recursive orphan cleanup, including unborn and canonicalized paths. Fail closed when checkout metadata cannot be inspected. Co-authored-by: 李琪0668001400 <[email protected]> Punchcard-Session: amber-meadow-timber-8r
d3a0bef to
7aa31a2
Compare
|
@clawsweeper re-review The contributor branch was rewritten at |
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
|
Merged via squash.
|
…claw#119709) Classify direct and nested checkout roots through Git worktree registration before recursive orphan cleanup, including unborn and canonicalized paths. Fail closed when checkout metadata cannot be inspected. Punchcard-Session: amber-meadow-timber-8r Co-authored-by: Vincent Koc <[email protected]>
…cope * origin/main: (24 commits) fix(backup): skip transient gateway lock databases (openclaw#119782) test(agents): use canonical auth session fixtures (openclaw#119821) fix(memory): keep QMD file hints after stale docid misses (issue openclaw#113041) (openclaw#113515) test(doctor): align fast-path repair contracts (openclaw#119812) perf(agents): index subagent recovery ownership (openclaw#119793) fix(gateway): keep chat startup off catalog discovery (openclaw#119742) fix(test): keep TUI PTY suites in their owner lane (openclaw#119787) docs: correct dashboard auth precedence (openclaw#119785) docs: document control ui owner handoff fix: grant host-authorized control ui owner access fix(worktrees): preserve registered roots during orphan cleanup (openclaw#119709) fix(matrix): prevent shared client key collisions (openclaw#119667) fix(diagnostics-otel): propagate exported span context (openclaw#112283) fix(worker): isolate state observer failures (openclaw#117507) fix(qa): attest realized profile executions (openclaw#119761) fix(gateway): finish successful sessions after timestamp races (openclaw#119752) fix(agents): fence restart recovery lifecycle (openclaw#119776) fix(ui): preserve chat history and active run timing (openclaw#119729) improve(ollama): reduce inactive startup cost (openclaw#119745) improve(gateway): defer inactive plugin runtime imports (openclaw#119733) ...
Fixes #119691
What Problem This Solves
Fixes an issue where operators with a Git worktree placed directly under OpenClaw's worktrees state root could have that checkout's child directories recursively deleted by orphan garbage collection. The same risk also affected registered unborn worktrees and path aliases such as a symlinked state root.
Why This Change Was Made
Orphan reconciliation now classifies each top-level and nested candidate with one preservation rule before descending or deleting. It uses Git's stable
worktree list --porcelain -zregistry from checkout roots, canonicalizes target and listed paths, preserves committed and unborn worktrees, and aborts cleanup when checkout metadata cannot be inspected safely. The existing commit-required repository resolver remains unchanged.User Impact
Registered Git worktrees remain intact whether they use OpenClaw's fingerprint layout or live directly below the worktrees root. Genuine unregistered debris still gets removed.
Evidence
Before the repair on
origin/mainbaselinea20746e3abf7:The failing cases were direct committed, direct unborn, nested unborn, and symlinked-state-root worktrees.
After the repair at
7aa31a2ae395:Linux proof: https://github.com/openclaw/openclaw/actions/runs/31059656680
The new failure-path regression also verifies that a broken checkout control path aborts garbage collection before its payload can be deleted.
Release note: prevent managed-worktree orphan cleanup from recursively deleting registered direct-root or unborn Git worktrees.
[AI-assisted]
Punchcard-Session: amber-meadow-timber-8r