Skip to content

fix(daemon): daemon.toml settings path follows NODESPACE_HOME - #3609

Merged
mstomar125 merged 3 commits into
mainfrom
issue-3605-settings-path
Oct 5, 2026
Merged

mstomar125 merged 3 commits into
mainfrom
issue-3605-settings-path

Conversation

@mstomar125

@mstomar125 mstomar125 commented Oct 5, 2026 •

Copy link
Copy Markdown
Contributor

Closes #3605

Summary

SettingsServiceImpl::with_default_path built $HOME/.nodespace/daemon.toml, so an isolated daemon (NODESPACE_HOME set) still read and wrote the user's real settings file, including API keys and cached routing-probe verdicts. It now resolves through the existing crate::nodespace_dir(), the same resolver every other daemon.toml consumer in the daemon already uses (local agent, capture, assembly). No second resolver.

Callers checked

  • Eval scripts: none read or depend on the real daemon.toml; evals use local models. No opt-in env var added (none exists for settings, and nothing needs one). scripts/eval/preflight.ts isolation message now says daemon.toml follows NODESPACE_HOME too.
  • run-app skill: documents that an isolated daemon has no API keys and how to supply a throwaway daemon.toml under the isolated home.
  • CLI: nodespace mcp (packages/cli/src/commands/mcp.rs) also read $HOME; now uses nodespace_daemon::nodespace_dir() too, so it cannot flip the real user's [mcp] flag under NODESPACE_HOME.

Tests

Two tests with HOME at a temp home holding a settings file with an API key and NODESPACE_HOME at another dir: the isolated service never sees or rewrites the real file, and uses the file under NODESPACE_HOME. Both fail when with_default_path is reverted to $HOME. Daemon nextest (excluding golden/live/scenario6): 488 passed; clippy, fmt, bun test scripts/eval, pro-boundary check clean.

Documentation

Updates the state-path list in architecture/daemon-cli-protocol.md: https://github.com/NodeSpaceAI/nodespace-docs/pull/104

🤖 Generated with Claude Code

@mstomar125

Copy link
Copy Markdown
Contributor Author

Review round 1 (pragmatic-code-reviewer, medium)

Verdict: approve, no critical issues. Improvements raised: (1) CLI mcp still resolves daemon.toml from $HOME, so under NODESPACE_HOME it would mutate the real file and its doc comment was stale; (2) env-mutation test helper not panic-safe; nits on stale ~/.nodespace/daemon.toml comments.

Address-review

  • (1) Fixed: daemon_config_path in packages/cli/src/commands/mcp.rs now uses nodespace_daemon::nodespace_dir(); doc comment corrected. CLI mcp integration tests now env_remove("NODESPACE_HOME") so an ambient value can't redirect them. Removed the 'out of scope' note.
  • (2) Fixed: EnvRestore Drop guard. No existing repo helper to reuse (grepped serial_test/env guards).
  • Nits: stale default-case comments (~/.nodespace/daemon.toml in lib.rs, local_agent_service.rs, frontend files) left as accurate default descriptions; error string kept.
    Verification: fmt, clippy (daemon+cli, -D warnings -D clippy::unused-async), nextest daemon+cli 768 passed with NODESPACE_HOME set, cli 281 passed without it.

@mstomar125

Copy link
Copy Markdown
Contributor Author

Review round 2 (pragmatic-code-reviewer, medium)

Verdict: approve. Code change correct (CLI resolver, test env isolation, EnvRestore guard). One blocker: a stray mcp_integration.rs-E sed backup was committed.

Address-review

Removed in a follow-up commit (no other changes). Follow-up noted, not blocking: uninstall.rs/logs.rs in the CLI still read $HOME directly; separate from daemon.toml, can be a new issue. No further re-review needed.

mstomar125 and others added 3 commits October 5, 2026 13:43
SettingsServiceImpl::with_default_path built its path from $HOME, so an
isolated daemon read and wrote the user's real daemon.toml (API keys, routing
probe verdicts). It now resolves through crate::nodespace_dir(), like every
other daemon.toml reader.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
… guard in tests

Address review: nodespace mcp resolved daemon.toml from $HOME, so under
NODESPACE_HOME it would read and flip the real user's [mcp] flag while the
daemon used the isolated file. It now uses nodespace_daemon::nodespace_dir().
CLI mcp integration tests drop an ambient NODESPACE_HOME. The settings tests
restore the environment through a Drop guard.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
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 the daemon's settings file follow NODESPACE_HOME

1 participant