Skip to content

fix(implode): preserve unrelated data when removing installations - #3228

Draft
jong-kyung wants to merge 5 commits into
voidzero-dev:mainfrom
jong-kyung:fix/implode-protected-roots
Draft

jong-kyung wants to merge 5 commits into
voidzero-dev:mainfrom
jong-kyung:fix/implode-protected-roots

Conversation

@jong-kyung

@jong-kyung jong-kyung commented Oct 25, 2026 •

Copy link
Copy Markdown
Collaborator

vp implode could delete unrelated files when a directory override pointed to the user home or another non-Vite+ directory. This change limits removal to verified Vite+ directories and shims, while allowing existing users to uninstall after upgrading.

For example, setting VP_HOME to $HOME/Documents must not authorize deletion of personal documents. Requiring .vp-owned everywhere avoids that deletion, but also blocks users upgrading from older versions whose installation directories have no ownership markers.

Approach

Check ownership before changing files, shell profiles, or PATH. An upgrade does not grant Vite+ ownership of preexisting directory contents.

  • Reject the user home, its ancestors, and filesystem roots, including symlink aliases, even with --yes.
  • Check each data, cache, config, and state root independently. An unmarked nested category blocks recursive deletion of its parent, even when the parent is marked.
  • Remove only shims belonging to this installation from shared bin directories. Preserve other tools.

Installation and removal rules

Installation Setup behavior vp implode behavior
Fresh installation into new or empty roots Create .vp-owned markers. Remove owned roots recursively, subject to the protected-path and nested-category checks.
Upgrade from an older version Leave existing nonempty roots unmarked. Remove verified CLI version directories and matching links and shims. Preserve and report unverified data.
Custom nonempty directory Allow installation without claiming existing contents. Apply the same partial-removal rules. If no removable installation artifacts are recognized, fail before changing files or shell configuration.

Ownership covers a whole directory, so recursive removal also deletes files added inside that verified unit. It does not extend to an unmarked parent or override the nested-category checks.

Uninstall after upgrading

Existing users can run vp implode after upgrading without manually adding ownership markers. For an unmarked installation:

  1. Match each CLI version directory against its wrapper and installed package metadata. Require its installation receipt to match the SHA-256 digest of its companion lockfile, with the evidence contained inside that directory.
  2. Remove verified versions, their matching current link, and owned shims. Clean the matching shell entries.
  3. Preserve and list the remaining paths for manual inspection. Legacy runtimes, package managers, cache, config, and state remain when their ownership cannot be established. Incomplete versions and versions with missing or mismatched receipts remain too.

This allows a successful partial uninstall without treating an old installation's parent directory as disposable. --yes skips confirmation, not ownership checks.

Reject protected deletion targets before modifying shell profiles, PATH,
or managed files, including with --yes. Check canonical paths to catch
symlink aliases and validate all roots before starting split-layout cleanup.

Add regression coverage for protected roots, normal installations,
symlink aliases, and preservation of files when validation fails.
@jong-kyung jong-kyung self-assigned this Oct 25, 2026
@jong-kyung

Copy link
Copy Markdown
Collaborator Author

@codex review

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 25, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ⚠️ Failed 2026-10-25T16:07:42.008251Z
We couldn’t complete this review. Comment @codex review to try again.
4a3a718 Manual request
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Something went wrong. Try again later by commenting “@codex review”.

An unknown error occurred
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@jong-kyung
jong-kyung marked this pull request as ready for review October 25, 2026 03:32
@jong-kyung

Copy link
Copy Markdown
Collaborator Author

@codex review

@jong-kyung
jong-kyung requested a review from fengmk2 October 25, 2026 03:33
@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Something went wrong. Try again later by commenting “@codex review”.

An unknown error occurred
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@fengmk2 fengmk2 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The home/root protection works in the targeted Linux tests, but I would like us to complete the directory ownership protection in this PR before merging. A mistaken VP_HOME override can still delete unrelated data. Please address the inline comment and add regression coverage for unowned directories.

Comment thread crates/vp_global_cli/src/commands/implode.rs
@jong-kyung
jong-kyung marked this pull request as draft October 25, 2026 05:26
Require ownership markers for every existing data, cache, config, and state root before changing files, shell profiles, or PATH. Validate nested roots independently and collapse them only when building the final recursive deletion targets. Preserve the home and filesystem root safeguards.

Check that new installation roots are empty before recording ownership. Keep nonempty legacy roots unmarked so existing installations remain usable without granting permission to delete unrelated contents.

Cover ownership checks, nested and split roots, fresh setup, and legacy setup with isolated unit tests and CLI snapshots.
@jong-kyung

Copy link
Copy Markdown
Collaborator Author

@codex review

Recognize an existing current entry without following its target, matching
installation directory resolution even when the active binary is missing.
Keep repaired legacy roots unmarked so implode still refuses their removal.

Extend the existing installer CI cases to verify ownership is not claimed
when reusing a legacy root or repairing a dangling junction.
Keep ownership checks focused on recursive removal. Setup may use an
existing nonempty root without marking it as owned, so implode still
refuses to delete it. Remove the unnecessary existing-install distinction.

Verify that setup succeeds without claiming personal files and that
implode preserves those files and shell configuration. Keep preflight
coverage for invalid roots and update the doctor cache-directory snapshot.
@jong-kyung
jong-kyung marked this pull request as ready for review October 25, 2026 08:38
@jong-kyung

Copy link
Copy Markdown
Collaborator Author

I've made some changes to address your feedback, but I'm not sure if this is the right approach. I'd appreciate it if you could take another look 🙇‍♂️

@jong-kyung
jong-kyung requested a review from fengmk2 October 25, 2026 08:39
@jong-kyung jong-kyung changed the title fix(implode): prevent deletion of home and filesystem roots fix(implode): prevent deletion of protected and unowned directories Oct 25, 2026

fengmk2 commented Oct 25, 2026

Copy link
Copy Markdown
Member

Could you update the PR description to explain the ownership and deletion rules, including how existing installations are handled?

With the current implementation, users upgrading in place from 1.4.0 will have non-empty directories without .vp-owned. Setup leaves those directories unmarked, so implode refuses to remove them, even with --yes. This affects normal upgrades, not just custom directory overrides.

Please clarify the intended behavior for fresh installs, upgrades from older versions, and custom directories. In particular, how should existing users safely uninstall after upgrading? We should consider the compatibility impact explicitly and cover the upgrade-to-uninstall flow with regression tests, while preserving protection against deleting unrelated data.

@jong-kyung
jong-kyung marked this pull request as draft October 25, 2026 14:54
@jong-kyung

Copy link
Copy Markdown
Collaborator Author

Thanks for testing this and for the detailed feedback 🫡 I'm reworking the removal approach so that existing users can still uninstall after upgrading. I'll request another review once I've verified it more thoroughly.

Identify legacy CLI version directories using matching package metadata and frozen installation receipts instead of claiming their parent roots. Preserve unverified data and report the paths left for manual inspection.

Keep protected paths and unowned nested categories safe, and remove only verified shims from shared bin directories. Cover the legacy upgrade refresh handoff, partial cleanup, invalid receipts, and symlink boundaries.
@jong-kyung jong-kyung changed the title fix(implode): prevent deletion of protected and unowned directories fix(implode): preserve unrelated data when removing installations Oct 25, 2026
@jong-kyung

Copy link
Copy Markdown
Collaborator Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Something went wrong. Try again later by commenting “@codex review”.

An unknown error occurred
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

This branch has not been deployed

No deployments
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