Repository navigation
Description
What happens
packages/desktop-app/app-lib/src/daemon_setup.rs copies each bundled sidecar into ~/.nodespace/bin, re-signs the copy ad hoc (resign_binary: codesign --force --sign -), and on every launch treats the copy as up to date only when dest.len() == src.len() and codesign --verify --strict passes (extract_sidecar_if_changed; the same size-only test is in kill_stale_daemon_sync).
For a Developer ID signed bundle (every notarized release, the .pkg and .dmg included) the ad-hoc copy is always smaller than the bundled file (measured: daemon 74,186,368 vs 74,638,320 bytes; CLI 5,405,808 vs 5,455,552; /bin/sleep 115,728 vs 166,512). So on every launch:
kill_stale_daemon_syncSIGKILLs a daemon running from~/.nodespace/bin/nodespaced;extract_sidecar_if_changedre-extracts and returnsbinary_updated = true;bring_up_daemoncallskill_running_daemon, writes~/Library/LaunchAgents/app.nodespace.daemon.plistand bootstraps it; when the label is already loaded from/Library/LaunchAgents(a.pkginstall), the fallback boots that job out and the per-user job takes over.
The "already running and healthy" return is never reached, the daemon restarts on every app launch, and the daemon that runs is an ad-hoc copy whose code identity differs from the notarized binary's (keychain items are bound to the identity that wrote them).
Proposed change
- Up-to-date check that survives re-signing (
extract_sidecar_if_changed,kill_stale_daemon_sync): either do not re-sign a copy whose bundled source already verifies with a real signing identity (codesign -dvreports anAuthority=/TeamIdentifier=other thannot set), copying it as is and re-signing ad hoc only ad-hoc or linker-signed sources (dev builds); or record what was extracted (a stamp~/.nodespace/bin/.<name>.sourcewith the bundled file's size and SHA-256) and treat the copy as current when the stamp matches and the copy verifies.kill_stale_daemon_syncreads the same stamp. - A
.pkginstall's machine-wide registration is authoritative (bring_up_daemon): when/Library/LaunchAgents/<label>.plistexists, do not extract sidecars into~/.nodespace/binand do not write or bootstrap the per-user plist. If the daemon does not answer,launchctl kickstart gui/<uid>/<label>(orlaunchctl bootstrap gui/<uid> /Library/LaunchAgents/<label>.plistwhen not loaded), then wait for the socket as today. Today, after a tray Quit or an incompatible-database refusal, the next app launch registers a per-user job beside the machine-wide one (two plists under one label). - Quit and the stale-daemon kill target the registered binary (
signal_daemon_to_stop,kill_running_daemon,kill_stale_daemon_sync): they only signal a process whose argv0 is~/.nodespace/bin/nodespaced, so on a.pkginstall (daemon/usr/local/bin/nodespaced) quitting the app leaves the daemon running and a binary update never restarts it. Match the program of the loaded job (launchctl print gui/<uid>/<label>->program), or both install locations. - Per-user plists of other macOS users on the same Mac: a per-user plist the app wrote runs
~/.nodespace/bin/nodespacedwithout a product's service environment. With (2), the app could delete a per-user plist under the label when the machine-wide one exists.
Acceptance criteria
- Two app launches in a row on a
.pkg-style layout leave the daemon's PID unchanged (no SIGTERM, no bootstrap). - No per-user plist is written while
/Library/LaunchAgents/<label>.plistexists. - App Quit stops the daemon the registration runs.
- ADR-084 section 3.2 (Q3) and sections 3.3/4.3 state which registration wins on a
.pkginstall and that the app never installs its own daemon copy when the machine-wide registration exists.
Why it matters
A signed, healthy daemon is killed and replaced by an ad-hoc-signed copy on every launch, losing its code identity (and keychain access bound to it), and .pkg installs end up with two registrations and a Quit that does not stop the daemon.
Activity
mstomar125 commentedon Oct 20, 2026
Planned for core v0.3.9.
mstomar125 commentedon Oct 22, 2026
Appears fixed on main by #3853 (4a8e68d): the size-only up-to-date test was replaced by a source stamp (
installed_matches_source,daemon_setup.rs), used by bothkill_stale_daemon_syncandextract_sidecar_if_changed. Not closing; needs a confirmation on a notarized build (a second launch should not restart the daemon).🤖 Generated with Claude Code
mstomar125 commentedon Oct 22, 2026
Fixed by #3853 (source stamp instead of file size), shipped in v0.3.9. Confirmed by the user on a physical Mac with the real notarized .pkg: opening the app repeatedly keeps the same daemon.