Repository navigation
Description
Overview
NODESPACE_HOME is a test setting for the daemon and the CLI: it lets a test, the e2e harness or an eval run nodespaced with its state away from the user's ~/.nodespace. It is never needed to run NodeSpace, and the desktop app does not read it. Three things keep it from doing that job on its own.
Problem Statement
1. The default socket ignores it. The daemon (default_socket_path_for in packages/daemon/src/main.rs) and the CLI (resolve_socket_path in packages/cli/src/lib.rs) build the default socket from $HOME. With NODESPACE_HOME set and NODESPACED_SOCKET unset:
nodespacedbinds$HOME/.nodespace/daemon.sockand writes its single-instance lock beside it, in the user's real home;nodespace <command>dials that real-home socket, so it reaches whichever daemon is there, which may be the user's own;nodespace uninstall(which followsNODESPACE_HOME) cleans sockets in the redirected home, where none were created.
Nothing fails today because every harness also sets NODESPACED_SOCKET.
2. An agent the daemon starts loses the daemon's socket. A terminal agent's environment is cleared to HOME, PATH, TERM, SHELL, LANG, USER, TMPDIR plus its auth variables (BASE_ENV_ALLOWLIST and apply_env_allowlist in packages/agent/src/pty/session.rs). Neither NODESPACED_SOCKET nor NODESPACE_HOME reaches it, so a nodespace command the agent runs falls back to the user's real socket. An isolated daemon's agent session then reads and writes the user's real database.
3. The desktop app reads it in one place. packages/desktop-app/app-lib/src/bundled_model.rs holds a copy of the home rule and copies the bundled embedding model under NODESPACE_HOME, while the daemon the app registers looks under the user's home.
Proposed Solution
- The daemon and the CLI resolve the default socket, and the lock beside it, under the shared home rule (
nodespace_daemon::nodespace_dir()).NODESPACED_SOCKETand--socketstay the overrides above it. - The daemon gives every agent it starts the path of the socket it is serving, as
NODESPACED_SOCKET, whatever its own environment held. - The app's read of
NODESPACE_HOMEis removed: it copies the model under the user's home. The app's socket and daemon management are unchanged; they use the user's home.
Documentation
- daemon-cli-protocol.md: the transport section lists the paths that follow
NODESPACE_HOMEand names the socket as the exception. - daemon-cli-lifecycle.md: the embedding-model section says the app's copy follows
NODESPACE_HOME, with a caveat about the registered daemon. - ADR-033: the socket default and the
NODESPACED_SOCKEToverride. - ADR-052 §3: the socket's mode is the local-authorization boundary; the directory it is created in stays owner-only.
- ADR-032: the terminal agent's environment.
- Updates, pushed with the change:
daemon-cli-protocol.md(remove the "socket is the exception" paragraph; add thatNODESPACE_HOMEis a test setting, never needed to run NodeSpace, and that the desktop app does not read it);daemon-cli-lifecycle.md(the embedding-model section: the app copies under the user's home, and the caveat goes);development/agent-eval.mdif its isolation recipe changes.
Architecture Impact
Extends ADR-033 and reverses nothing: with NODESPACE_HOME unset every path is what it is today. No new ADR.
Acceptance Criteria
- The daemon and the CLI resolve the default socket under the shared home rule, so
NODESPACE_HOMEalone isolates it. The lock file follows the socket. -
NODESPACED_SOCKETand--socketstill override it. - With
NODESPACE_HOMEunset, every path is what it is today. - A test with
HOMEat a temp "real" home andNODESPACE_HOMEat another proves the daemon creates no socket or lock file in the real home and the CLI does not dial one there. Mutation-checked. - An agent the daemon starts has
NODESPACED_SOCKETset to the socket that daemon serves, including when the daemon's own environment had none. A test launches a stand-in agent and reads its environment. - The desktop app contains no read of
NODESPACE_HOME; a test launches the model copy with the variable set and finds the model under the user's home. The app/daemon socket agreement test still holds for both build flavours. - The docs above are updated in the same change.
-
bun run quality:fixandbun run test:changedpass.
Technical Specifications
Reference Files
packages/daemon/src/lib.rs:nodespace_home(),nodespace_home_override(),nodespace_dir(), the shared rule.packages/daemon/src/main.rs:socket_path,default_socket_path_for.packages/cli/src/lib.rs:resolve_socket_path,discover_socket_in.packages/agent/src/pty/session.rs:BASE_ENV_ALLOWLIST,apply_env_allowlist; the launch path that builds the agent's command.packages/desktop-app/app-lib/src/bundled_model.rs:nodespace_home, the app's copy of the rule, to remove.packages/proto/src/socket.rs:daemon_socket_relativereturns a home-relative path;incompatible_database_namereturns a bare filename joined onto the state directory, which is the shape to follow.packages/cli/tests/it/home_isolation.rs: the two-home test harness to reuse.
Implementation Details
default_socket_path_forreads no environment so a plain test can check both flavours; keep that by passing the home in.- The daemon knows the socket it bound; pass that path down to the session launch instead of re-deriving it.
- Windows uses a machine-global named pipe with nothing under the home, so the socket part is unaffected there.
- The service registration (LaunchAgents plist, systemd unit) and the UI pid file belong to the app and stay under the user's home.
Related Issues
- Make the CLI's uninstall and logs commands follow NODESPACE_HOME #3612
- fix(daemon): daemon.toml settings path follows NODESPACE_HOME #3609
- Resolve the embedding model under NODESPACE_HOME #3601
- Make the app's daemon management follow NODESPACE_HOME #3616 (closed: the app does not manage a daemon for another home)
Activity
[-]Make the daemon's default socket path follow NODESPACE_HOME[/-][+]Make NODESPACE_HOME alone isolate a daemon: the socket follows it, agents get the daemon's socket, and the app stops reading it[/+]