Skip to content

fix(cli): avoid protected parent access during checkpoint cleanup - #13540

Merged
marius-kilocode merged 1 commit into
mainfrom
fix-checkpoint-cleanup-on-worktree-deletion
Aug 28, 2026
Merged

fix(cli): avoid protected parent access during checkpoint cleanup#13540
marius-kilocode merged 1 commit into
mainfrom
fix-checkpoint-cleanup-on-worktree-deletion

Conversation

@marius-kilocode

Copy link
Copy Markdown
Collaborator

What Problem This Solves

Deleting an Agent Manager worktree could succeed but still show a checkpoint-cleanup error, including when checkpoint recording was disabled. Cleanup inspected every ancestor from the filesystem root. On macOS, access to a protected parent such as Documents can be denied even when the full project path is accessible, causing the cleanup endpoint to return HTTP 400.

Why This Change Was Made

Correct the protected-parent access regression in the worktree cleanup introduced by #13476. Resolve the complete target first and walk upward only to reconstruct missing path components. Keep canonical containment checks, dangling-symlink rejection, path revalidation, repository locking, and the existing quarantine and pending-materialization safeguards.

Do not skip cleanup when snapshot recording is disabled: old checkpoint data can still exist and should be removed when its worktree is explicitly deleted.

User Impact

Worktree deletion no longer requires inspecting unrelated protected parent folders. Missing checkpoint repositories remain harmless, existing checkpoint data is removed, and retained sessions remain available in history.

Evidence

  • Added regression cases for inaccessible ancestors with existing and absent checkpoint data, plus a symlinked-ancestor safety case.
  • Cleanup and endpoint-auth suites: 41 tests passed with the pinned Bun 1.3.14 runtime.
  • CLI typecheck, touched-file lint, formatting, and the upstream annotation guard passed.
  • Extension compile passed, including extension/webview typechecks, lint, and bundling.
  • A read-only diagnostic against the originally failing path changed from an EPERM error to success, with rename and deletion operations blocked throughout.
  • Isolated VS Code self-test with a disposable repository under Documents: verified snapshots were disabled, deleted a worktree without checkpoint data, then deleted another with seeded old checkpoint data. Both completed without cleanup warnings; the seeded data was removed and both sessions remained in history.
  • The isolated test instance and fixture data were removed afterward. Manual UI coverage was macOS only.

@kilo-code-bot

kilo-code-bot Bot commented Aug 28, 2026

Copy link
Copy Markdown
Contributor

Code Review Summary

Status: No Issues Found | Recommendation: Merge

Files Reviewed (3 files)
  • .changeset/fix-checkpoint-cleanup-parent-access.md
  • packages/opencode/src/kilocode/snapshot/cleanup.ts
  • packages/opencode/test/kilocode/snapshot-repository-cleanup.test.ts

Reviewed by grok-4.6 · Input: 68.6K · Output: 19.2K · Cached: 536.6K

Review guidance: REVIEW.md from base branch main

@marius-kilocode
marius-kilocode merged commit 23f6677 into main Aug 28, 2026
45 of 48 checks passed
@marius-kilocode
marius-kilocode deleted the fix-checkpoint-cleanup-on-worktree-deletion branch August 28, 2026 10:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants