Skip to content

CLI: name the refused database when the socket is outside the state directory - #4406

Merged
mstomar125 merged 1 commit into
mainfrom
cli-refused-database
Nov 30, 2026
Merged

mstomar125 merged 1 commit into
mainfrom
cli-refused-database

Conversation

@mstomar125

@mstomar125 mstomar125 commented Nov 30, 2026 •

Copy link
Copy Markdown
Contributor

What

When the daemon stops for an incompatible database, the CLI names the refused database and the reason even when the socket is not in the state directory (NODESPACED_SOCKET redirected, or the Windows pipe). It looks for the marker beside the socket first, then in the state directory the CLI itself resolves. With no marker anywhere the message is unchanged.

Work item: "The CLI names the refused database and the reason when the daemon stopped for an incompatible database".

Why

The marker was only read from the socket's directory. The daemon writes it under <NODESPACE_HOME>/.nodespace, so a socket living elsewhere got the generic "Is the daemon running?" text. Reproduced with the built nodespace binary and a hand-written marker.

Trade-off (wrong-daemon attribution)

The marker records no socket, so for a redirected socket the marker in the default state directory may belong to a different daemon. Choice made: keep the fallback (it is the only way the redirected-socket case can be helped), but when the marker was not found beside the dialled socket, the message appends a note that the socket is outside the NodeSpace state directory and, if a different daemon was started via NODESPACED_SOCKET, to check that daemon's own state directory. A marker beside the socket, or for the Windows pipe, is stated without the note.

Tests (packages/cli/src/lib.rs, connect_failure_tests)

  • redirected socket: marker found, flagged as not the socket's own; message carries the caveat
  • default socket: marker is the socket's own, no caveat
  • no marker / empty state dir: None, generic message unchanged
  • dev-flavour marker beside the socket
  • existing marker-flavour test and connect_failure_message_matches_classification made hermetic (state directory injected)
  • in-process integration tests that dial a missing daemon (cli_integration::connect_refused_returns_friendly_error, wait::a_daemon_that_is_not_running_...) call isolate_state_dir(), which points NODESPACE_HOME at an empty temp dir
  • whole nodespace-cli suite (lib 354 + tests/it 158, RUST_TEST_THREADS=1) passes both clean and with NODESPACE_HOME at a dir holding a live marker

Mutation checks

  • removing the state-dir lookup fails the redirected-socket tests (2 fail)
  • disabling the caveat fails the message test (1 fails)

Not verified

No real refusing daemon was run; markers were hand-written. The original validation setup is inferred (the report may have dropped the .nodespace path part, in which case the existing code already applied). Windows pipe path not exercised.

🤖 Generated with Claude Code

@mstomar125 mstomar125 changed the title CLI names the refused database and reason when the socket is outside the state dir CLI: name the refused database when the socket is outside the state directory Nov 30, 2026
@mstomar125
mstomar125 force-pushed the cli-refused-database branch 2 times, most recently from 13775d8 to 2f69f07 Compare November 30, 2026 07:14
The CLI only looked for the incompatible-database marker beside the socket it
dialled, so with NODESPACED_SOCKET pointing elsewhere (or a Windows pipe) it
printed the generic 'Is the daemon running?' text instead of naming the refused
database and the reason. It now tries the socket's directory, then the state
directory it resolves itself. A marker found only in the latter is qualified
with a note, since it records no socket and may belong to a different daemon.
With no marker the message is unchanged.

The marker-lookup tests inject the state directory, and the two in-process
integration tests that dial a missing daemon point NODESPACE_HOME at an empty
temp dir, so none depends on the developer's own state directory.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
@mstomar125
mstomar125 merged commit 1f36db0 into main Nov 30, 2026
@mstomar125
mstomar125 deleted the cli-refused-database branch November 30, 2026 07:34
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.

1 participant