Skip to content

fix(setup): retain symlinked data roots during uninstall - #1821

Merged
morluto merged 1 commit into
morluto:mainfrom
shoyann:fix/uninstall-purge-root-symlink
Oct 11, 2026
Merged

morluto merged 1 commit into
morluto:mainfrom
shoyann:fix/uninstall-purge-root-symlink

Conversation

@shoyann

@shoyann shoyann commented Oct 11, 2026

Copy link
Copy Markdown
Contributor

Summary

Fixes #1816.

rea uninstall --purge-data followed a symlink at ~/.rea and deleted the target's cache and state directories. Validate the managed data root before inspecting either child, retaining linked roots and their target data.

Problem and expected behavior

When .rea links to an unrelated directory containing cache/ and state/, checking only the children with lstat sees ordinary directories and permits recursive deletion. The documented uninstall contract preserves symlinks and unknown paths; the managed root must satisfy that contract too, including dangling links.

Change and scope

The shared uninstall host checks .rea with its existing lstat boundary before purging either child. Linked or non-directory roots retain both entries; missing roots skip them; inspection errors fail both entries without deletion. Ordinary roots continue through the existing leaf checks. Legitimate HOME directory links remain supported.

Contract and boundary impact

  • Semantic owner and earliest changed stage: application uninstall host, managed data root admission before child cleanup.
  • CLI and MCP/tool-catalog contract: no schema changes; the uninstall CLI reports existing retained, skipped, and failed statuses for rejected or unavailable roots.
  • Provider, bridge, target-format, or platform compatibility: no provider or target-format changes; tests use directory symlinks on POSIX and junctions on Windows.
  • Evidence, artifact, provenance, or reconstruction contract: none.
  • Process execution, authorization, cleanup, or containment impact: prevents purge from traversing a symlinked managed root into unrelated target data.
  • Generated metadata, package, or installation impact: no generated metadata changes; enforces the existing installation guide's uninstall retention contract.

Evidence and regression coverage

  • Tests added or updated: real-filesystem existing/dangling root links, a non-directory root, a legitimate HOME link, an injected root inspection error with zero removals, and a real public CLI regression checking external sentinel contents and JSON statuses.
  • Base reproduction: the two root-link filesystem cases and the CLI regression failed against f178bf1c; the CLI reported the target's cache and state as removed, and both sentinels were deleted.
  • Representative corrected CLI output (relevant fields): {"status":"complete","items":[{"name":"cache","status":"retained"},{"name":"state","status":"retained"}]}.
  • Remaining proof gaps: executed on WSL Ubuntu with Node 24.18.0 and npm 11.16.0; native Windows junction and macOS execution remain unverified. Permission failure is injected at the filesystem boundary.

Evidence-bearing analysis outputs are not changed by this PR.

Validation performed

  • npm run test:focused -- tests/boundary/filesystem/clientLifecycle.test.ts tests/boundary/cli/clientProfileLifecycle.test.ts — 52/52 passed.
  • npm run check — passed (repository lint reports warnings but no errors).
  • npm run verify:package — passed, including setup/uninstall, package update, CLI, and MCP checks. The first attempt hit the host proxy when connecting to the local registry fixture; rerunning with NO_PROXY, no_proxy, and npm_config_noproxy set to 127.0.0.1,localhost,::1 passed. No repository workaround was added.
  • npm pack --dry-run — passed.
  • Scoped lint on all three changed files and git diff --check — passed.

Compatibility, safety, and release

  • Breaking changes or migration steps: none; ordinary directory cleanup and existing leaf symlink retention continue unchanged.
  • Real Hopper/Ghidra, browser, or OS coverage: WSL Ubuntu filesystem and public CLI execution; optional real providers are not involved.
  • Package or release metadata impact: none.
  • Security, privacy, process, or containment review: this guards existing root links before deletion. It does not establish race-free containment against concurrent path replacement; cleanup still uses the existing path-based filesystem API.

Review checklist

  • This PR addresses a concrete problem or an agreed enhancement.
  • The PR has one focused outcome and the title follows type(scope): outcome.
  • Related issue is linked, or the reason for not linking one is stated above.
  • Tests cover changed observable behavior and meaningful failure paths.
  • Owning docs, contracts, and generated metadata are updated where needed (the existing documented contract is unchanged).
  • User-visible CLI/MCP changes include representative output.
  • I checked the final diff for secrets, unrelated cleanup, and unsupported claims.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 11, 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 ✅ Completed 2026-10-11T12:59:34.249891Z be027f0 PR opened
ℹ️ 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.

@morluto
morluto merged commit 7e2f79a into morluto:main Oct 11, 2026
31 checks passed
@github-actions github-actions Bot mentioned this pull request Oct 11, 2026
3 tasks done
@morluto

morluto commented Oct 11, 2026

Copy link
Copy Markdown
Owner

Protecting data beneath a linked ~/.rea root was a subtle uninstall bug, @shoyann. Your check validates the managed root before inspecting cache or state, so a purge retains unrelated target data and reports the existing retained/skipped statuses. Thanks for covering real symlinks, Windows junctions, and the CLI sentinel case.

@morluto morluto added bug Something isn't working area: setup Setup, packaging, upgrade, install, Doctor, and client registration labels Oct 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: setup Setup, packaging, upgrade, install, Doctor, and client registration bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] uninstall --purge-data follows a symlinked .rea root and deletes target data

2 participants