Skip to content

Refuse nodespace uninstall when the installed app is not the free NodeSpace - #3411

Closed
mstomar125 wants to merge 2 commits into
mainfrom
issue-3351-uninstall-product-guard
Closed

mstomar125 wants to merge 2 commits into
mainfrom
issue-3351-uninstall-product-guard

Conversation

@mstomar125

@mstomar125 mstomar125 commented Oct 1, 2026 •

Copy link
Copy Markdown
Contributor

Closes #3351

Summary

ADR-084 §5 (now Accepted on nodespace-docs main), CLI side: nodespace uninstall now runs only when the installed app is the free NodeSpace. On macOS, if /Applications/NodeSpace.app exists and its Info.plist does not declare NodeSpaceProduct = community, the command prints ADR-084's message and exits non-zero. It refuses before it stops the daemon or removes anything. With no app (a headless install), or with a community app, it uninstalls exactly as before.

Changes

  • packages/cli/src/commands/uninstall.rs
    • Adds the pure uninstall_blocker(app_bundle: &Path) -> Option<String>:
      • None when the bundle doesn't exist;
      • None when Contents/Info.plist (XML or binary) declares NodeSpaceProduct = community;
      • otherwise Some(message): another value, no key, a non-string value, a missing or unparseable plist.
    • It is compiled for any(target_os = "macos", test).
    • The first statement of run is a #[cfg(target_os = "macos")] block that checks /Applications/NodeSpace.app and bails with the message.
    • Neither the message nor the code names another product.
  • packages/cli/Cargo.toml
    • Adds plist = "1.10" under the macOS target dependencies, and under [dev-dependencies] so the pure function is tested on every platform.
    • plist 1.10.0 is already in Cargo.lock through Tauri. The lockfile diff only adds plist to nodespace-cli's dependency list; no new package.

Deviations from the issue

  • Message wording follows the accepted ADR. The issue quotes the proposed ADR's "Use that product's own uninstall". Accepted ADR-084 §5 (nodespace-docs main, CLI row) says "own uninstaller", which also matches the .pkg guard's "Uninstall it with its own uninstaller first". The constant now matches the accepted text character for character (found in review).
  • Edge cases the issue didn't list. "Bundle path can't be checked" (try_exists errors) refuses rather than proceeding. That matches the issue's "Some(message) in every other case". A dangling symlink at the app path counts as no app.
  • Two extra unit tests, both refusing: a bundle with no Info.plist, and a NodeSpaceProduct that isn't a string.

Dependency note

The CLI side doesn't depend on #3349 (PR #3381, still open) to build. At runtime it relies on the app declaring the key, which #3381 adds; it uses the same key/value (NodeSpaceProduct / community). Until #3381 merges, every core app on disk lacks the key and this guard refuses it. ADR-084 accepts that for mixed releases. Both should ship in the same release.

Ratchet

bun run scripts/check-pro-boundary.ts passes, and no marker moves: 0 delta on every marker. --changed lists one proWording hit in uninstall.rs, the existing remove_sock doc comment, which is unchanged. BASELINES is unedited.

BASELINES (unchanged)
export const BASELINES = {
  // pro_* Tauri commands, the pro_sync / pro_client modules, pro_env
  proCommands: 275,
  // the proSync store, resolveProSyncVariant, isProSyncActive, pro-sync imports
  proSyncModule: 368,
  // the Pro proto, CloudSyncService, ProClient / ProTier, Pro Worker URLs
  proProtocol: 95,
  // quoted pro:tier-detected, sync:status and sync:error event names
  proEvents: 81,
  // the Pro membership service
  membershipService: 54,
  // Pro build, daemon, socket, launchd and installer branching
  editionBranching: 113,
  // tenant binding, sync_enabled and auth_status state
  cloudBindState: 203,
  // cloud embedding and membership-edge sync hooks
  cloudSyncHooks: 4,
  // Supabase, RLS, pgvector, nodespace-sync and "Pro daemon" wording
  cloudWording: 72,
  // the word tenant (one fixture exempt, see EXEMPTIONS)
  tenantWording: 463,
  // the word Pro, except chip and model names such as "M2 Pro", "DeepSeek V4 Pro"
  proWording: 281,
  // files whose basename has a pro segment
  proNamedFiles: 18,
} satisfies Record<MarkerName, number>;

Tests

Unit tests (commands::uninstall::tests, tempdir bundles whose Info.plist the test writes with plist; none reads /Applications):

Bundle Expected Test
absent None uninstall_blocker_allows_no_app
community (XML) None uninstall_blocker_allows_an_app_declaring_community
community (binary plist, asserts bplist00 header) None uninstall_blocker_allows_a_binary_plist_declaring_community
pro, other Some uninstall_blocker_refuses_an_app_declaring_another_product
key missing Some uninstall_blocker_refuses_an_app_without_the_key
unparseable plist Some uninstall_blocker_refuses_an_unparseable_info_plist
no Info.plist Some uninstall_blocker_refuses_an_app_without_an_info_plist
non-string value Some uninstall_blocker_refuses_a_product_that_is_not_a_string

Mutation checks (each run against only the uninstall_blocker tests):

  • Flip the comparison (== → !=): 7 of 8 fail. The no-app test passes because it never reaches the comparison.
  • Drop the missing-bundle early return: allows_no_app fails.
  • Swap in an XML-only reader (from_reader_xml): the binary-plist test fails.

End-to-end wiring check (manual, sandboxed). I built the nodespace binary and ran nodespace uninstall with:

  • a scratch HOME holding stand-ins for ~/.nodespace/bin, the per-user LaunchAgent plist and a socket;
  • fake launchctl/bun/node first on PATH, which log their calls;
  • sandbox-exec denying writes to the real ~/.nodespace, ~/Library, /Applications and ~/.claude, and exec of /bin/launchctl.

Only the real /Applications/NodeSpace.app/Contents/Info.plist was read. It is a current core app with no NodeSpaceProduct key.

Results:

  • Guard in place: exit 1, stderr Error: The NodeSpace app on this Mac is a different NodeSpace product, …, no tool calls (no launchctl bootout), and the scratch HOME was byte-identical afterwards.
  • Mutation, guard block removed from run: exit 0, the fake launchctl bootout gui/502 app.nodespace.daemon and the skill uninstall ran, and the scratch HOME files were deleted. So the probe catches a missing guard.

The community-app and no-app paths of the binary weren't run end to end: that would need a community bundle at the real /Applications path, or a real uninstall. The unit tests cover uninstall_blocker returning None there, and run is unchanged after the guard.

Commands:

  • cargo fmt -p nodespace-cli: clean.
  • cargo clippy -p nodespace-cli --all-targets -- -D warnings -D clippy::unused-async: 0 warnings.
  • bun run test:changed: rust + scripts tiers passed; the workspace nextest ran 4155 tests, all passed.
  • bun run scripts/check-pro-boundary.ts: passes.

🤖 Generated with Claude Code

…eSpace (closes #3351)

On macOS, `run` first checks /Applications/NodeSpace.app. If the bundle exists
and its Info.plist (XML or binary) does not declare NodeSpaceProduct =
community, it returns ADR-084's message before stopping the daemon or removing
anything. No bundle, or a community bundle, uninstalls as before.

The check is the pure `uninstall_blocker(app_bundle)`, compiled for macOS and
tests and unit-tested on tempdir bundles. It reads the plist with the `plist`
crate, which is already in the lockfile through Tauri.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@mstomar125

Copy link
Copy Markdown
Contributor Author

Pragmatic Code Review: PR #3411 (closes #3351)

Review Type: Initial Review (reviewed at a871e15c)

Summary

The change is small and does what it should. uninstall_blocker is a pure function. The guard is the first statement of run, ahead of stop_daemon. The only thing before it in nodespace_cli::run is resolve_socket_path, which only reads. Every failure path (missing or unreadable plist, a non-dictionary root, a missing key, a value that is not a string, a try_exists error) refuses, as ADR-084 requires.

The cfg gating is right on all three platforms:

  • On Linux and Windows non-test builds, the function, its constants and plist all drop out.
  • In test builds every item is used, so nothing is dead code.
  • INSTALLED_APP is macOS-only and has a caller there.

plist 1.10.0 is the only version in the lockfile, so no new package comes in. No test reads /Applications.

There is one thing to fix before merge: the message text no longer matches the accepted ADR-084.

Requirements Check

  • ⚠️ macOS, non-community app: exits non-zero, prints the message, changes nothing. The behaviour is right: bail! runs before any side effect, and the PR's sandboxed end-to-end probe confirms it. The message is one word off the accepted ADR (see 🟡 below).
  • ✅ A community app or no app uninstalls as before. Both paths return None, the unit tests cover both, and run is unchanged after the guard.
  • ✅ Neither the message nor the code names another product. "pro" appears only as a lowercase test value, which no ratchet marker matches.
  • ✅ The ratchet passes. I re-ran it: bun run scripts/check-pro-boundary.ts passes. --changed lists only the existing remove_sock doc comment (uninstall.rs:181), which this PR doesn't touch.

Findings

🟡 Important: the refusal message says "uninstall", but the accepted ADR-084 says "uninstaller"

📁 packages/cli/src/commands/uninstall.rs:29-32

The constant copies the issue's text: "…Use that product's own uninstall, or update NodeSpace first; …". The issue was written from the proposed ADR (nodespace-docs 88140d4568). The ADR was then accepted in nodespace-docs 3cd35c5a3b (2026-09-30), which reworded the §5 CLI row to:

"The NodeSpace app on this Mac is a different NodeSpace product, or an older NodeSpace that does not say which product it is. Use that product's own uninstaller, or update NodeSpace first; this command removes only the free NodeSpace."

The ADR is now Accepted and merged on main via nodespace-docs#95; the issue's "#94" link is stale. The issue says "The message is ADR-084's", so the accepted wording is the contract. "Uninstaller" also matches the .pkg guard's "Uninstall it with its own uninstaller first", and Pro's §6.1 uninstaller that this message points the user to.

Fix: change own \ + uninstall, or update to own \ + uninstaller, or update. The tests compare against the constant, so they need no change.

Principle: user-facing text that an ADR pins is a contract. Keep one source of truth, so that the guards across channels read the same.

🟡 Merge order: land with or after #3381

This is not a code defect; the PR body already says it. Until #3381 (NodeSpaceProduct = community in the app's Info.plist) is on main, every core app refuses this command. Telling the user to "update NodeSpace first" can't help, because the updated app would lack the key as well. Don't cut a release from a main that has this PR but not #3381. Merging #3381 first, or both together, removes the risk.

Observations (no action in this PR)

  • scripts/uninstall.sh has the same partial-uninstall shape and no guard. Nothing in core, the README, CI or the website references it, and ADR-084 assigns the guard only to the CLI, so it is out of scope. If it is still served anywhere, it is worth a follow-up issue.
  • I checked the plist API against the 1.10.0 source:
    • Value::from_file → Reader autodetects binary, XML and ASCII.
    • Builder::build errors on a second root value, so the "not a property list" test hits the parse-error path as intended rather than parsing as an ASCII string.
    • The missing-Info.plist test covers the File::open error path separately.

Recommendation: REQUEST CHANGES

The only blocking item is the one-word message change. The rest is ready to approve. Re-review only needs to confirm the constant.

@mstomar125 mstomar125 left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Automated pragmatic-code-review: REQUEST CHANGES (posted as a comment — GitHub blocks self-approval). Full findings in the review comment above.

Accepted ADR-084 section 5 says "Use that product's own uninstaller"; the
constant had the proposed draft's "own uninstall".

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@mstomar125

Copy link
Copy Markdown
Contributor Author

Address review: summary

Addressed (1)

  • 🟡 Refusal message wording (packages/cli/src/commands/uninstall.rs, NOT_COMMUNITY_MESSAGE): fixed in 74f394a.
    • Changed "own uninstall" to "own uninstaller".
    • I checked independently against nodespace-docs main. ADR-084 is Status: Accepted, and its §5 CLI row reads "Use that product's own uninstaller, or update NodeSpace first; this command removes only the free NodeSpace."
    • A script check confirms the joined Rust constant matches that sentence character for character.
    • The tests compare against the constant, so they needed no change.
    • Re-run: cargo fmt -p nodespace-cli --check is clean. bun run test:changed passed: 4155 of 4155 Rust tests, including all 8 uninstall_blocker tests, plus the scripts tier. The push check passed, including the ratchet.
    • The PR body now says ADR-084 is accepted, and records this as a deviation from the issue text.

No code change (1)

Skipped (1 observation)

  • scripts/uninstall.sh has no product guard. It's out of scope:
    • ADR-084 §5 assigns the guard only to the CLI, the .pkg and the cask.
    • Per the review, nothing references the script.
    • Worth revisiting only if that script is still served to users.

Re-Review Decision

Decision: NO RE-REVIEW NEEDED. The fix is a one-word change to a string literal, with no logic change. A short confirmation pass on 74f394a follows anyway, so the PR carries a current verdict instead of the earlier REQUEST CHANGES.

@mstomar125

Copy link
Copy Markdown
Contributor Author

Pragmatic Code Review: PR #3411, re-review

Review Type: Re-Review. Only new commit 74f394ac since the last review at a871e15c.

Previous Review Summary:

  • Previous recommendations: 2 (plus 1 observation)
  • Addressed: 1. The message wording is fixed in 74f394ac.
  • Not addressed: 0. The merge-order note asks for no code change; the author agrees, and the PR body's "Dependency note" records it.
  • Observation: the author skipped scripts/uninstall.sh as out of scope. I agree, since ADR-084 §5 assigns the guard only to the CLI, the .pkg and the cask.
  • New issues found: 0

Verification

  • The joined constant matches the accepted ADR exactly. I reconstructed NOT_COMMUNITY_MESSAGE at 74f394ac, applying Rust's backslash-newline continuation (it drops the newline and the next line's leading whitespace). I compared it, as a byte string, with the quoted message in the nodespace uninstall row of ADR-084 §5 on nodespace-docs main (Status: Accepted). They are equal: "…Use that product's own uninstaller, or update NodeSpace first; this command removes only the free NodeSpace."
  • Nothing else changed. git diff a871e15c..74f394ac touches one line in one file: packages/cli/src/commands/uninstall.rs:32, where uninstall, becomes uninstaller,. Logic, tests, Cargo.toml and Cargo.lock are untouched, and the added word is not a ratchet marker.
  • The tests still hold. They assert against the constant, so they stay valid with no edit.

Code Review Findings

None.

Recommendation: APPROVE

One reminder carries over: land this with or after #3381, and don't cut a release from a main that has this PR without #3381.

@mstomar125 mstomar125 left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Automated pragmatic-code-review (re-review): APPROVE (posted as a comment — GitHub blocks self-approval).

@mstomar125

Copy link
Copy Markdown
Contributor Author

Superseded by #3606, which carries all of the coexistence work for the issue in one PR, reworked to the accepted ADR-084: every check compares NodeSpaceProduct with community, with no fallback for bundles without the key and no wording that names another product.

🤖 Generated with Claude Code

@mstomar125 mstomar125 closed this Oct 5, 2026
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.

Make nodespace uninstall refuse when the installed app is not the free NodeSpace

1 participant