Repository navigation
fix(agents): preserve worktree-local ignored state during lossless cleanup - #108401
Conversation
|
One remaining lossless gap: this needs to compare the provisioned file's metadata/type, not only its bytes.
Please |
|
@harjothkhara Thanks — good catch. Addressed in ece303f85f. The lossless guard now lstat()s both sides, requires regular files through non-symlink parent chains, compares the restorable permission bits, and only then compares bytes. Stat/read failures also fail closed instead of silently treating the worktree copy as safe. Added POSIX regression coverage for:
Each case leaves git status --porcelain clean and now expects removeIfLossless() to return false while preserving the worktree state. Exact-head test-types and Real behavior proof are green; the remaining CI matrix is still settling, and I will refresh the PR Evidence section with the final exact-head results. |
|
Codex review: needs changes before merge. Reviewed July 15, 2026, 11:34 PM ET / July 16, 2026, 03:34 UTC. Summary PR surface: Source +70, Tests +92. Total +162 across 2 files. Reproducibility: yes. The PR supplies a concrete real-service reproduction where only an ignored provisioned file changes, tracked status remains clean, baseline removal destroys the new value, and the patched head preserves it. Review metrics: 1 noteworthy metric.
Stored data model Root-cause cluster Members:
Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything. Merge readiness Overall follows the weaker of proof and patch quality, so missing proof can cap an otherwise strong patch. Rank-up moves:
Risk before merge
Maintainer options:
Copy recommended automerge instructionNext step before merge
Security Review findings
Review detailsBest possible solution: Retain or derive the provisioned-file set independently of the source manifest’s current contents, compare that set with the exact state restore can recreate, and cover manifest removal and pattern changes with real-service regressions. Do we have a high-confidence way to reproduce the issue? Yes. The PR supplies a concrete real-service reproduction where only an ignored provisioned file changes, tracked status remains clean, baseline removal destroys the new value, and the patched head preserves it. Is this the best way to solve the issue? No, not yet. The comparison belongs at the cleanup owner boundary, but using only the source checkout’s current include manifest leaves the lossless guarantee incomplete when provisioning rules change after worktree creation. Full review comments:
Overall correctness: patch is incorrect AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 957cc81175a3. Label changesLabel changes:
Label justifications:
Evidence reviewedPR surface: Source +70, Tests +92. Total +162 across 2 files. View PR surface stats
Acceptance criteria:
What I checked:
Likely related people:
What the crustacean ranks mean
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics. How this review workflow works
|
Co-authored-by: yetval <[email protected]>
2fbb2e6 to
2669f4a
Compare
|
Maintainer rewrite pushed at The repair now persists the exact paths OpenClaw provisioned independently of the current manifest, snapshots their bytes, modes, and deletion state into the shared SQLite store before removal, excludes them from Git snapshot objects, and restores without consulting mutable source state. Existing destination collisions and unrelated ignored caches are never claimed. Proof:
Exact-head PR CI is running after the final leaf-contract cycle fix. |
|
Merged via squash.
|
…eanup (openclaw#108401) * fix(worktrees): preserve provisioned cleanup state Co-authored-by: yetval <[email protected]> * refactor(worktrees): break provisioned registry cycle --------- Co-authored-by: Peter Steinberger <[email protected]>
…eanup (openclaw#108401) * fix(worktrees): preserve provisioned cleanup state Co-authored-by: yetval <[email protected]> * refactor(worktrees): break provisioned registry cycle --------- Co-authored-by: Peter Steinberger <[email protected]>
What Problem This Solves
Automatic managed-worktree cleanup can delete ignored worktree-local state that OpenClaw itself provisioned through
.worktreeinclude. Git status and ordinary Git snapshots omit ignored files; rereading the current source manifest during cleanup or restore is unsafe because the manifest and source copy can change or disappear after worktree creation.This reaches run-end
removeIfLossless(), idle garbage collection, and count/size eviction. The affected state can include credentials, local configuration, ignored databases, or recorded file deletion—not only rebuildable caches.Why This Change Was Made
Persist exact ownership and the removal-time file state independently of the current manifest:
.worktreeinclude, then atomically returns the registry metadata to live-ledger form.This replaces the original manifest-derived guard. Refusing cleanup was insufficient: it left the worktree permanently protected and still made restore depend on mutable source state. A worktree-gitdir sidecar also violated the database-first storage contract and would disappear with the worktree.
User Impact
Manifest removal, pattern removal, or source-file rotation no longer orphan provisioned ignored state. Automatic cleanup can still reclaim rebuildable ignored caches, while restorable worktrees round-trip exact OpenClaw-provisioned bytes, deletion state, and modes.
Evidence
node scripts/run-vitest.mjs src/agents/worktrees/service.test.ts src/agents/worktrees/service.provisioned.test.ts src/agents/worktrees/registry.test.ts— 57 passed locally; one Linux-only invalid-UTF-8 pathname case skipped on macOS.node scripts/generate-kysely-types.mjs --verify— passed.node scripts/check-changed.mjs -- <12 touched paths>— full changed gate passed on Blacksmith Testbox, including Linux core/test typechecks, full core lint, formatting, storage guards, and generated-schema validation: https://github.com/openclaw/openclaw/actions/runs/29502236569git diff --check— passed.The focused suite covers manifest and pattern removal, post-removal source mutation, large chunked content, deletion and full modes, destination collisions, legacy/malformed metadata, tracked/unignored/type/symlink fail-closed cases, literal and raw Git paths, assume-unchanged and sparse/skip-worktree state, nested repositories, failed-snapshot cleanup, idle GC, and count/size eviction.
No changelog edit per maintainer instruction; contributor credit is preserved in the commit trailer and squash metadata.