Repository navigation
Closed
Labels
pro-boundaryPro/core boundary: Pro code moves to nodespace-sync (ADR-081..085)
Description
Summary
Core's side of ADR-084 §4.3 (proposed): the installed app decides which daemon runs.
- The daemon reports its executable.
GetDaemonVersionResponsegainsstring executable_path = 2;.NodeServiceImpl::get_daemon_versionfills it at run time from the process's ownstd::env::current_exe().- The Pro daemon serves core's
GetDaemonVersionthrough core's router, so it reports its own path with no Pro code in core. - A daemon built before this change reports an empty string.
- The Pro daemon serves core's
- The app compares that executable with its profile. In
ensure_daemon_running, once the sidecar is extracted and the socket answers, the app asks the running daemon forexecutable_path. It compares the path's file name, without any.exe, withdaemon_profile::active().binary_name.- Match: use the running daemon, as today.
- Mismatch, including an empty value: boot out the app's service registration, wait for the socket to clear, and continue into the existing register path. To boot it out:
- on macOS, run
launchctl bootout gui/<uid>/<launch_agent_label()>; - on Linux, run
systemctl --user stop nodespace.service.
- on macOS, run
- The RPC fails or times out: the result is unknown. Log it and keep today's behaviour.
- Windows is skipped. Windows has no second product (ADR-084 §8) and no label to boot out.
Context
- Why the app needs this. Under the shared identity (Delete the in-core Pro daemon profile, NODESPACE_PRO_* switch and tauri.pro.conf.json #3354), both products register
app.nodespace.daemonondaemon.sock. After a hand replacement (core's.dmgdragged over Pro), or with a stale registration, the fast path would use the other product's daemon. - Why a bootout. The existing kill path signals only the app's own installed binary (
process_argv0_matches). Evicting another product's daemon needs the bootout. - The check is generic. It runs in the app and compares only against the app's own profile.
GetDaemonVersiontoday:- proto:
node_service.proto716-721; - daemon:
services/node_service.rs1353-1361, with its test at ~4291; - app:
commands/database.rs18-35. That command still returns the version string, and the frontend's version badge uses it.
- proto:
- Which client to call it with. The app's managed
GrpcClientexists before the startup task runs (lib.rs~466). Use it with a 2 s timeout. - Why the pin gate. Suppose a Pro build from core HEAD talks to a pinned Pro daemon that lacks the field. It would see an empty value, evict its own daemon at every launch, and pay about 9 s of model load each time. With one pin, the Pro daemon at the same revision fills the field.
- Why Add a single-instance daemon lock and export the launcher's argument list #3352 comes first. After the eviction and re-registration, a daemon outside the registration may still hold the socket, for example an older
brew servicesdaemon. The app's own daemon must then exit on the lock rather than fight for the socket. Tell the user when another NodeSpace product's daemon is running or registered #3356 tells the user. - An intended change for the free app. A running daemon from an older
nodespace-cliformula reports an empty path, so it counts as another product. The app re-registers its own daemon, which exits on the lock, and the app keeps using the Homebrew daemon until the formula updates.
Scope
packages/proto/proto/node_service.proto: add the field with this comment: "the serving process's own executable path, for the app's product check; empty from daemons built before this field existed".packages/daemon/src/services/node_service.rsget_daemon_version:- Set
executable_pathtostd::env::current_exe().map(|p| p.to_string_lossy().into_owned()).unwrap_or_default(). - This is the only
GetDaemonVersionResponsestruct literal in the workspace.
- Set
packages/desktop-app/src-tauri/src/daemon_setup.rs:- A pure
fn product_check(reported: Option<&str>, profile: &DaemonProfile) -> ProductCheck, whereProductCheckisMatch,MismatchorUnknown:None(the RPC failed) givesUnknown;Some("")givesMismatch;- otherwise, compare the file stem, with any
.exestripped.
async fn running_daemon_executable(app: &AppHandle) -> Option<String>, which callsGetDaemonVersionthrough the managedGrpcClientwith a 2 s timeout.fn boot_out_service_registration(), with the macOS and Linux bodies above. Keep it small, so the reviewer can read it.- Wiring in
ensure_daemon_running(unix only):- Right after the two
extract_sidecar_if_changedcalls, ifcheck_daemon_socketreportsHealthy, run the check. - On
Mismatch:- log both names;
- call
boot_out_service_registration(); - wait up to 5 s for
NotRunning, askill_running_daemondoes, then remove a stale socket file; - skip the
binary_updatedkill and the healthy early returns, and go straight torotate_daemon_logsand registration.
MatchandUnknownkeep today's flow.
- Right after the two
- A pure
- Docs: comments name no product.
Out of scope
- The user-facing notices, and the re-check after registering (Tell the user when another NodeSpace product's daemon is running or registered #3356).
- Windows.
Steps
- Run the startup sequence, and assign the issue at pickup. Confirm the pin gate is met.
- Add the proto field, the daemon code and the daemon test.
- Add the pure check and its tests, the RPC helper, and the bootout.
- Wire the check into
ensure_daemon_running. - Run
bun run scripts/check-pro-boundary.tsand pasteBASELINES. - Run
bun run test:changedandbun run quality:fix, push, and open the PR. Code comments must not cite GitHub issue numbers.
Acceptance criteria
-
GetDaemonVersionreturnsexecutable_path, and the daemon test asserts that it equals the test process'scurrent_exe(). - When the daemon matches, startup takes today's fast path: no bootout and no respawn.
- When the report is mismatched or empty, the app boots out its registration and registers its own daemon.
- An RPC failure changes nothing.
-
bun run scripts/check-pro-boundary.tspasses, withBASELINESpasted. No change is expected.
Tests and verification
- Unit tests for
product_check: the same name, a full path, a.exesuffix, a different name, an empty string, andNone. - Daemon unit test: extend
get_daemon_version_reports_the_daemon_crate_version. - ADR-048 seam test. The
test-supportharness spawns a realnodespaced. Assert that:- the RPC returns a path whose file name is
nodespaced; product_checkgivesMatchforDaemonProfile::community();product_checkgivesMismatchfor a profile namedcustom-daemon.
- the RPC returns a path whose file name is
- The bootout is not run in tests, because it would touch the real launchd. The reviewer reads it instead.
- Commands:
bun run test:changedcargo clippy -p nodespace-proto -p nodespace-daemon -p nodespace-app --all-targets -- -D warnings -D clippy::unused-async
- Optional manual check on a dev Mac:
- Start a debug build, and confirm the daemon is not respawned.
- Stop the app, and point the dev plist at a differently named copy of the daemon binary.
- Start the app again. It re-registers
nodespaced.
Dependencies
- Add a DaemonProfile for the app's daemon binary and service env (no behavior change) #3346:
DaemonProfile.binary_name. - Add a single-instance daemon lock and export the launcher's argument list #3352: the lock.
- NodeSpaceAI/nodespace-docs#94 (ADR-084): ADR-084 §4.3 (proposed).
SYNC:Pro GUI and Pro daemon build from one pinned core rev.
Risks and rollback
- A false mismatch makes the app restart the daemon at every launch. The
Matchtest and the manual check guard against it. - Rollback: revert the PR. The proto field is additive.
Plan key: C8.10 (pro-boundary DAG).
🤖 Generated with Claude Code
Metadata
Metadata
Assignees
Labels
pro-boundaryPro/core boundary: Pro code moves to nodespace-sync (ADR-081..085)
Activity
mstomar125 commentedon Sep 30, 2026
Heads-up from the #3352 work (PR #3388, not merged yet): it adds
remove_socket_if_stale(socket_path, grace)inpackages/desktop-app/app-lib/src/daemon_setup.rs. It deletes the daemon socket file only once nothing accepts connections on it, andkill_running_daemon/kill_stale_daemon_syncnow use it. With the single-instance lock, deleting the socket of a daemon that is still serving (abrew servicesdaemon, one started by hand) leaves it alive, holding the lock and unreachable, and the app's replacement daemon exits 0 without serving. The step here that removes a stale socket file after waiting forNotRunningshould use the same helper rather than an unconditionalremove_file. Staleness is decided by connecting, not by probing the lock, because a lock probe makes a daemon that starts at that moment see the lock held and exit.