Repository navigation
Make the CLI's uninstall and logs commands follow NODESPACE_HOME - #3634
Conversation
Pragmatic code review: PR #3634Review Type: Initial Review SummaryThe change does what the issue asks and is a net improvement. Both commands now take their state directory from On the design choice (skip the service manager and skill removal under Requirements Check
Code Review Findings🟡 Important: an unusable
|
malibio
left a comment
There was a problem hiding this comment.
Automated pragmatic-code-review: APPROVE (posted as a comment — GitHub blocks self-approval). Full findings in the review comment above.
Address-review summaryCommit Addressed
Mutation-checked, each reverted: dropping the empty-value filter fails the empty-
Skipped
Pending
Re-Review DecisionDecision: RE-REVIEW NEEDED Rationale: the fix changes how the shared resolver reads |
Pragmatic code review: PR #3634Review Type: Re-Review (scope: SummaryThe commit fixes both 🟡 findings from the first review and adds the unredirected-path test. The resolver change is sound for every caller inside the daemon and CLI. It leaves one thing behind: the desktop app keeps its own copy of the
Previous Review Summary
Requirements Check
Code Review Findings🟡 Important: the app's own copy of the
|
NODESPACE_HOME |
App copies the model to | Daemon looks in |
|---|---|---|
| not valid UTF-8 | the user's real ~/.nodespace/models |
the redirected home |
| empty | .nodespace/models under the working directory |
the user's real home |
In the first case an isolated run writes into the real home, which is the leak this PR exists to close, and the daemon finds no model.
Recommendation: apply the same rule in bundled_model.rs: take Option<OsString> from var_os, filter the empty value, and correct the comment and its unit tests. nodespace-app-lib does not depend on nodespace-daemon, so it cannot call the resolver; matching the rule is the fix in this PR.
Principle: one rule for one concept. Where a second copy has to exist, a change to one must change the other in the same commit.
🟢 Suggestion: an empty NODESPACE_HOME now runs uninstall against the real install
📁 packages/daemon/src/lib.rs:57-59, packages/cli/tests/it/home_isolation.rs:198-220
This is what the first review asked for, and it matches common practice (XDG treats an empty variable as unset). It has one cost. A script that runs NODESPACE_HOME="$DIR" nodespace uninstall with DIR unset now stops the user's daemon and removes the real bin, with no message. The new test asserts exactly that outcome.
Recommendation: your call. The stricter option is for nodespace_home() to return an error on a set-but-empty value ("NODESPACE_HOME is set but empty"); it already returns Result. If the current rule stays, the docs sentence should state it.
Principle: a destructive command should fail closed on a malformed isolation setting.
Checked and found sound
- Every caller of
nodespace_home()/nodespace_dir(). The callers are the database registry,daemon.toml(settings, local agent, capture), the model path, the incompatible-database marker,resolve_db_path, and the CLI'smcp,uninstallandlogs. All go through the one function, so they move together. For a non-UTF-8 value they now honour the redirect instead of dropping to the real home. For an empty value they use the real home instead of a path relative to the working directory. No caller converts the path to a string in a way that would newly fail. - Test harnesses. Every harness that sets the variable (
daemon-harness.ts, app-libtest-support, the daemon and CLI integration tests) passes a temp directory. None passes an empty value, so none changes behaviour. - Hermeticity of the new tests.
HOMEis a temp directory andPATHnames a directory that does not exist. The CLI spawnslaunchctl,systemctl,bunandnodeby bare name without changing its own environment, so the lookup uses thatPATHand finds nothing; a setPATHgets no default fallback. The plist and unit paths are built fromHOME, so only the temp ones are removed. In this checkout the skill installer resolves topackages/skill/dist/install.jsand then fails for want of a runtime. If a compiled installer were staged beside the test binary it would run, but against the tempHOME. After the run, this machine's daemon was still registered and running and~/.nodespace/binwas intact. - The
PATHchange.command()returns aCommand, so a temp directory created inside it would be deleted on return. A nonexistent path under the temp home avoids that and does not appear in the snapshot. - The unredirected test's stdout check. It uses
ends_withbecause the skill-removal line differs by checkout ("Could not locate the skill installer" without a builtdist, "Skill uninstall failed" with one). That is the right looseness. - Platform cfg. The two new integration tests are limited to macOS and Linux, where
stop_daemondoes something andHOMEis whatdirs::home_dir()reads. The non-UTF-8 unit test is#[cfg(unix)]. - Project standards. No compatibility code, no issue numbers in comments, no lint suppression, no Pro-boundary wording.
Recommendation
APPROVE. Fold the bundled_model.rs fix into this PR before merging; it is the same rule in a second place.
malibio
left a comment
There was a problem hiding this comment.
Automated pragmatic-code-review (re-review): APPROVE (posted as a comment — GitHub blocks self-approval). Full findings in the review comment above.
Address-review summary (round 2)Addressed
Skipped
Re-Review DecisionDecision: NO RE-REVIEW NEEDED Rationale: the change applies the rule the re-review specified to one small pure function, with unit tests for both cases, and nothing else changed. |
#3612) Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
… as unset, test the skill-removal skip and the unredirected uninstall Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
…emon's rule Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
900ef8f to
46e5276
Compare
Closes #3612
What changed
nodespace uninstallandnodespace logsbuilt their paths from$HOME. Both now take the state directory fromnodespace_daemon::nodespace_dir(), soNODESPACE_HOMEisolates them.uninstallremoves<nodespace_dir>/binand the sockets and lock files in<nodespace_dir>. The closing message prints the real data path instead of a fixed~/.nodespace/database/.logstakes its home candidate from the resolver. It already ignored the Homebrew prefixes underNODESPACE_HOME, but through its own reading of the variable.nodespace_daemon::nodespace_home_override()is new: the redirected home, orNone.nodespace_home()is built on it, so the variable is read in one place.A behaviour decision to check
Under
NODESPACE_HOME,uninstallnow skips two steps and says so in one line:launchctl bootout, the LaunchAgents plist, the systemd unit);Both live in the user's own home, not the NodeSpace home, and belong to the install there. Without this, an isolated
uninstallwould stop the user's real daemon. WithNODESPACE_HOMEunset, nothing changes.Tests
New
tests/it/home_isolation.rsruns the compiled binary withHOMEat a temp "real" home holding a full install (binaries, sockets, lock files, database, log, plist, systemd unit) andNODESPACE_HOMEat another:uninstallleaves the real home byte-for-byte unchanged, and leaves only the database and log in the redirected one;logs --path-onlyandlogsresolve and read the redirected log;logsfails naming only the redirected path, with no fallback to the real home or a Homebrew prefix.The tests set
PATHto an empty directory, so no run can reach this machine's service manager.Mutation-checked, each reverted afterwards:
uninstallstate directory from$HOMEuninstallignores the redirectlogsstate directory from$HOMElogsignores the redirectbun run test:changedpasses (scripts and the Rust workspace).Notes
uninstall.rs, inrun()and just above it. Whichever lands second needs a small rebase there.default_socket_path_forinpackages/daemon/src/main.rs) and the CLI'sresolve_socket_pathstill build from$HOME, thoughdaemon-cli-protocol.mdsays the socket followsNODESPACE_HOME. They agree with each other and with the app, so changing one alone would break the pairing.🤖 Generated with Claude Code