Repository navigation
Description
Summary
Add DaemonProfile, the value ADR-082 §3.6 (proposed) defines, and route every edition-dependent choice of which daemon binary the desktop app runs and what extra environment its service registration carries through the process's active profile. Its fields:
binary_name: the daemon the app installs, registers, starts, and kills by image name;service_env: extra environment variables in the service registration;product: the product the app expects the daemon to belong to.
The Pro values are built in exactly one function, which the existing NODESPACE_PRO_* build switch selects. Community and Pro builds therefore behave exactly as they do today.
Identity stays out of the profile. The launchd label, socket, UI pid file and incompatible-database marker are not part of it: under ADR-084 decision 2(a) (proposed), both products use core's identity. Those selections stay as they are today, behind is_pro_build(), until #3354 deletes their Pro arms.
Arguments stay out too. ADR-084 §4.2 makes accepting core's launcher arguments the daemon's job, and #3352 exports the argument list.
This is the seam the Pro app fills through AppExtensions::daemon_profile (#3347).
Context
Line numbers are at main af8ddb6. Locate code by symbol, because #3322's library split may move the src-tauri/src modules.
-
The switch.
daemon_setup::is_pro_build()(84) returnsPRO_SUPABASE_URL.is_some(), wherePRO_SUPABASE_URL = option_env!("NODESPACE_PRO_SUPABASE_URL")(78). Only sync's Pro build sets that variable. -
What moves into the profile here:
Choice Code today After this issue Daemon binary daemon_binary_name_for(88-100),daemon_binary_name(102-105)daemon_profile::active().binary_nameWindows taskkillimagedaemon_image_name_for(670-691), used by Windowssignal_daemon_to_stop(313-323) and Windowskill_running_daemon(700-720)daemon_profile::active().image_name()launchd env write_plist'spro_envblock (1173-1188, used at 1208 and 1228)profile.service_env, rendered generically -
What does not move here:
- Delete the in-core Pro daemon profile, NODESPACE_PRO_* switch and tauri.pro.conf.json #3354 handles
launch_agent_label(134-144),daemon_socket_relative(130-132),ui_pid_relative(327-330),services/grpc_client.rsresolve_socket_path(521) andincompatible_database.rsmarker_path_in(31-40). update_check::check_for_update(120) belongs to Delete the Pro arm of core's built-in update source and its worker parsing #3323.
- Delete the in-core Pro daemon profile, NODESPACE_PRO_* switch and tauri.pro.conf.json #3354 handles
-
Pro builds must not change. The Pro GUI still builds from core HEAD.
-
Windows code is not compiled on macOS by any PR check. Keep each Windows change to a one-line swap. The reviewer reads every
#[cfg(windows)]hunk.
Scope
New file packages/desktop-app/src-tauri/src/daemon_profile.rs
Register it as pub mod daemon_profile; in the module list of src/lib.rs.
/// Which daemon this app installs, registers and starts, and what it expects of it.
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct DaemonProfile {
/// Sidecar the launcher installs, registers and starts; no `.exe`.
pub binary_name: &'static str,
/// Extra environment in the service registration, after core's own
/// NODESPACED_SOCKET and NODESPACE_UI_BINARY. Rendered into the macOS
/// launchd plist only, as today; the systemd unit and the Windows spawn
/// do not carry it.
pub service_env: Vec<(String, String)>,
/// The product the app expects the running daemon to belong to.
pub product: &'static str,
}pub fn community() -> Self:binary_name:DAEMON_BINARY_NAME(nodespaced);service_env: empty;product:community.
#[cfg(any(windows, test))] pub(crate) fn image_name(&self) -> String: returns<binary_name>.exe. Move the real-Windows.exerationale fromdaemon_image_name_for's doc onto it, without the issue reference.pub(crate) fn active() -> &'static DaemonProfile: backed bystatic ACTIVE: OnceLock<DaemonProfile>, and initialised on first read bycrate::daemon_setup::profile_for_this_build. Let an app built on core supply its DaemonProfile via AppExtensions::daemon_profile #3347 adds the install path.- Docs use generic words only. Core's Pro-boundary ratchet counts the word
Pro.
src/daemon_setup.rs
- Keep the edition block (66 and 72-86):
PRO_DAEMON_BINARY_NAME,PRO_SUPABASE_URL,PRO_ANON_KEYandis_pro_build(). The identity functions andupdate_checkstill readis_pro_build(). - Add
fn profile_for_build_env(supabase_url: Option<&'static str>, anon_key: Option<&'static str>) -> DaemonProfileto that block:- A
NoneURL returnsDaemonProfile::community(). Some(url)returns today's Pro values:binary_name:PRO_DAEMON_BINARY_NAME;service_env:NODESPACED_PRO_SUPABASE_URLset tourl, thenNODESPACED_PRO_ANON_KEYset toanon_key.unwrap_or_default(), in that order;product:pro.
- The URL alone decides, and the key defaults to empty, exactly as today.
- Move the
pro_envcomment (1173-1178) onto this function.
- A
- Add
pub(crate) fn profile_for_this_build() -> DaemonProfile, which callsprofile_for_build_env(PRO_SUPABASE_URL, PRO_ANON_KEY). These two functions are the only code that picks binary, env or product by edition. Don't give new names apro_prefix: Guardrail: stop new Pro code from landing in core #3302'sproCommandsmarker countspro_*identifiers. - Delete
daemon_binary_name_for(88-100).daemon_binary_name()now returnsdaemon_profile::active().binary_name. Its callers (170, 291, 394, 503, 519, 646, 1789) stay unchanged. - Delete
daemon_image_name_for(670-691). The Windowssignal_daemon_to_stopand the Windowskill_running_daemonusedaemon_profile::active().image_name()instead. - Fix the docs that name the deleted functions:
- the Windows
kill_running_daemondoc (692-699); sidecar_install_path(1054-1060);should_restart_for_log_rotation(1739-1740), which should now say "the same reasonDaemonProfile::image_nameis a pure method".
- the Windows
write_plist(1153-1233):- Add a
profile: &DaemonProfileparameter. - Delete the
pro_envblock. - Render
profile.service_envas<key>/<string>pairs afterNODESPACE_UI_BINARY, in the same indentation. Pass keys and values throughxml_escape. - The call site (591-592) passes
daemon_profile::active().
- Add a
- Kickstart comment (1332-1334): replace "and the Pro pair" with "and whatever the profile's
service_envadds". - Leave these alone:
DAEMON_TRAY_FLAGand the launchers' arguments (Add a single-instance daemon lock and export the launcher's argument list #3352 changes them);- the names
write_own_ui_pid_file,remove_own_ui_pid_file,signal_daemon_to_stopandkill_stale_daemon_sync, whichlib.rssource-text tests look for.
Out of scope
- The label, socket, UI pid file and marker (Delete the in-core Pro daemon profile, NODESPACE_PRO_* switch and tauri.pro.conf.json #3354).
update_check.rs(Delete the Pro arm of core's built-in update source and its worker parsing #3323).- Supplying a profile from outside core (Let an app built on core supply its DaemonProfile via AppExtensions::daemon_profile #3347).
- Deleting the Pro values (Delete the in-core Pro daemon profile, NODESPACE_PRO_* switch and tauri.pro.conf.json #3354).
packages/daemon,packages/protoandpackages/cli(Remove the pro feature and --edition from nodespaced and reject unknown arguments #3348, Collapse proto socket, pid and marker tables to debug/release; drop CLI Pro discovery #3355, Add a single-instance daemon lock and export the launcher's argument list #3352).- Carrying
service_envinto the systemd unit or the Windows spawn.
Steps
- Run the CLAUDE.md startup sequence:
git pullon main, thenEnterWorktree;bun install, thenbun run testfor the baseline;bun run gh:comment;bun run gh:assign <N> "@me"(assign at pickup, never at filing);bun run gh:status <N> "In Progress".
- Add
daemon_profile.rsand its unit tests. - Add
profile_for_build_envandprofile_for_this_build, then delete the two_forfunctions. - Switch the readers over, and pass the profile into
write_plist. - Update the docs and tests listed here. Code comments must not cite GitHub issue numbers.
- Run
bun run scripts/check-pro-boundary.tsand paste the printedBASELINES. - Run
bun run test:changedandbun run quality:fix, then commit. - Push with
git push origin HEAD:<branch>(the push only lints), then rungh pr create --head <branch>.
Acceptance criteria
-
daemon_binary_name_for,daemon_image_name_forand thepro_envblock are gone. -
git grep -nw is_pro_build packages/desktop-app/src-tauri/srclists only these: the definition,launch_agent_label,daemon_socket_relative,ui_pid_relative,grpc_client::resolve_socket_path,incompatible_database::marker_path_inandupdate_check. - A community build writes a byte-identical plist. A test asserts that
EnvironmentVariablesholds exactlyNODESPACED_SOCKETandNODESPACE_UI_BINARY. - A test pins every field of
profile_for_build_env(Some(..), Some(..))to today's Pro values. Delete the in-core Pro daemon profile, NODESPACE_PRO_* switch and tauri.pro.conf.json #3354 deletes that test. - A
service_envvalue containing<,&and>renders escaped, and the result passesplutil -lint. -
NODESPACE_PRO_SUPABASE_URL=https://example.invalid NODESPACE_PRO_ANON_KEY=test cargo check -p nodespace-appstill compiles. -
bun run scripts/check-pro-boundary.tspasses, withBASELINESupdated in this PR to the printed counts:proCommandsfalls (thepro_envlines);editionBranchingfalls (theis_proparameters);- if a marker rises only because Pro values or their pinning test moved, that is a planned relocation: name it in the PR description.
Tests and verification
- Add
daemon_profileunit tests:- the values of
community(); image_name()forcommunity(), and for a profile whosebinary_nameiscustom-daemon.
- the values of
- Add
profile_for_build_envtests:(None, None)equalscommunity();(Some(url), Some(key))returns the Pro values;(Some(url), None)gives an empty key.
- Update existing tests:
macos_plist_keepalive_tests(from 2356): pass&DaemonProfile::community(), and add the env-dict and escaping cases.windows_taskkill_image_name_tests(2663-2688): switch to profiles, and deletepro_edition_image_name_matches_pro_binary.sidecar_path_tests::sidecar_install_path_covers_pro_daemon_and_cli_names(2787-2802): rename to..._covers_any_daemon_and_cli_names, and usecustom-daemon.
- Mutation-test each new test: break the value it pins, and confirm it fails.
- Commands:
bun run test:changed. It takes the machine slot for Rust.- For iteration:
cargo clippy -p nodespace-app --all-targets -- -D warnings -D clippy::unused-asyncandcargo test -p nodespace-app --lib -- daemon_. If the build asks for staged resources, runbun run rust:test:app-unitsonce. - The Pro-env
cargo checkfrom the acceptance criteria.
- Optional manual check: run
bun run tauri devon a dev Mac before and after the change.~/Library/LaunchAgents/app.nodespace.daemon.dev.plistmust be byte-identical.
Dependencies
- NodeSpaceAI/nodespace-docs#90 (ADR-082) (ADR-082, proposed): defines
DaemonProfile. - Add the Pro-boundary ratchet check and the CLAUDE.md Pro/sync placement rule #3299: the ratchet that the acceptance criteria run.
Risks and rollback
active()keeps the first value it is initialised with. Nothing installs a profile yet, so that value is the build default. Let an app built on core supply its DaemonProfile via AppExtensions::daemon_profile #3347 adds an install that runs before any read.- The Windows hunks are not compiled on macOS. The reviewer must read each one.
- Rollback: revert the PR. Nothing outside
src-taurichanges.
Plan key: C8.1 (pro-boundary DAG).
🤖 Generated with Claude Code
Activity
mstomar125 commentedon Sep 30, 2026
Completed in #3391 (merged). Auto-close did not fire; closing manually.