Skip to content

Fix the .pkg's LaunchAgent identity and complete the cask's uninstall - #2372

Merged
mstomar125 merged 2 commits into
mainfrom
issue-2366-pkg-plist-cask-zap
Sep 7, 2026
Merged

mstomar125 merged 2 commits into
mainfrom
issue-2366-pkg-plist-cask-zap

Conversation

@mstomar125

Copy link
Copy Markdown
Contributor

Summary

Items 3 and 4 of #2366.

Item 3 — the bug that started the whole investigation. The .pkg installer's static plist registered under Label com.nodespace.daemon with bare KeepAlive: true, while the bundled NodeSpace.app self-registers under app.nodespace.daemon with the conditional SuccessfulExit: false form (from core#2353). Two different labels meant the pkg and the app ran two independent daemons: a tray "Quit" only ever stopped the one the app itself started, and the pkg's own copy unconditionally restarted regardless of how it exited.

Kept the .pkg route (didn't take the "delete it entirely" option the issue raised) and fixed it in place:

  • Relabeled to app.nodespace.daemon, matching daemon_setup.rs's launch_agent_label() for the community build exactly. This isn't just a labeling fix -- it means the app's own existing self-healing bootstrap logic (bootout+retry on a failed registration) naturally takes over daemon lifecycle management once the user opens NodeSpace.app, with zero new reconciliation code needed.
  • KeepAlive → the conditional dict form, matching write_plist and the Linux systemd unit's Restart=on-failure.
  • Renamed the plist file itself (com.nodespace.daemon.plist → app.nodespace.daemon.plist) for consistency with the app's own plist_filename() convention, updating build-pkg.sh and postinstall's references.
  • Added a regression test (pkg_plist_matches_app_plist_tests) that reads the static file from disk and asserts both the label and the KeepAlive form, since this is a static file with no shared code path with write_plist and has already drifted from it once.

Item 4. The cask's zap trash: list was missing ~/Library/LaunchAgents/app.nodespace.daemon.dev.plist (confirmed left behind after brew uninstall --zap on a real machine, per the issue) and ~/.nodespace/database. Added both, documented why ~/.nodespace/models stays excluded (100GB+ of downloaded weights -- trashing that on every zap would be hostile), and added test coverage alongside the existing full-cask snapshot test (which I updated -- its assertion needed to become the generator's own expected-output snapshot, not a claim about what's currently live on the tap, since the tap only re-syncs on the next real release).

Test plan

  • New Rust tests read the static .pkg plist and assert Label + KeepAlive -- mutation-verified (reverted the label, confirmed the test fails with a clear message; restored, confirmed it passes).
  • New/updated TS tests for the cask's zap trash: list -- mutation-verified (reverted to the old list, confirmed both tests fail; restored, confirmed all 10 pass).
  • plutil -lint on the fixed plist -- valid XML.
  • cargo clippy -p nodespace-app --all-targets clean (caught and fixed a real gap of my own here: the new test module needed #[cfg(test)], not just #[cfg(target_os = "macos")], or it compiles into the regular non-test build where its #[test] fns are genuinely dead code).
  • bun run quality:fix + bun run test:all clean workspace-wide.
  • Manual verification (per the issue's own acceptance criteria) that a real .pkg install, tray Quit, leaves no daemon running and none restarts -- not exercised here, no macOS pkg-build/install environment available in this session.

🤖 Generated with Claude Code

The .pkg installer's static plist registered under Label
com.nodespace.daemon with bare KeepAlive: true, while the bundled
NodeSpace.app self-registers under app.nodespace.daemon with the
conditional SuccessfulExit: false form. Different labels meant the
pkg and the app ran two independent daemons -- a tray Quit only ever
stopped the one the app itself started, and the pkg's copy
unconditionally restarted regardless. Relabeled and fixed KeepAlive
to match daemon_setup.rs::write_plist exactly, renamed the plist
file to match its own label, and added a regression test that reads
the static file from disk and asserts both.

The Homebrew cask's zap trash: list was missing the dev-build
LaunchAgent (app.nodespace.daemon.dev.plist, confirmed left behind
after brew uninstall --zap on a real machine) and the local
database. Added both, documented why ~/.nodespace/models stays
excluded (100GB+ of downloaded weights), and added coverage
alongside the existing full-cask snapshot test.

Co-Authored-By: Claude <[email protected]>
The prior commit renamed the file via git mv but never re-staged the
content edit made after the rename -- git mv snapshots the file at
its pre-edit content, so the previous commit shipped a byte-for-byte
identical file under a new name (confirmed via `git diff --cached`
showing zero changes before this commit, and the pushed raw content
still reading Label=com.nodespace.daemon, bare KeepAlive: true). The
two regression tests added in that same commit were correct and did
catch this -- they were just never actually run against what got
pushed, only against the uncommitted working tree.

Co-Authored-By: Claude <[email protected]>
@mstomar125

Copy link
Copy Markdown
Contributor Author

Correction — the review was right, the previous commit did not actually fix item 3. Root cause: I ran git mv com.nodespace.daemon.plist app.nodespace.daemon.plist (which stages the rename with the file's pre-edit content), then edited the file's content afterward in the working tree, then later ran git add <5 explicitly-listed files> — a list that omitted the renamed plist path. The commit captured the rename but not the content change (git diff showed zero content diff / "similarity index 100%"), and the two new regression tests, while correctly written, were only ever run against my local uncommitted working tree, never against what actually got pushed. My "mutation-verified, confirmed passing" claim in the original PR description was true locally and false for the commit that shipped.

Pushed a follow-up commit (5f402fc2) with the actual content fix, this time verified independently:

  • git diff --cached showed the real content diff before committing (not just git status).
  • Re-fetched the pushed file directly from raw.githubusercontent.com at the new commit SHA after pushing (not from local state) -- confirms Label = app.nodespace.daemon and the conditional KeepAlive form are actually there now.
  • Dispatched a separate, independent verification agent that clones fresh from GitHub, builds from scratch, and actually runs cargo test -p nodespace-app --lib pkg_plist_matches_app_plist_tests against the real pushed branch (not my own worktree) -- will report back before I merge.

Thank you for catching this -- it would have shipped the exact bug this PR exists to fix, completely unfixed, if not for the review.

@mstomar125

Copy link
Copy Markdown
Contributor Author

Independently re-verified the fix at the current head (5f402fc), this time from a completely fresh `git clone` (not the earlier local worktree state, not just a raw-file fetch): `scripts/pkg-resources/app.nodespace.daemon.plist` genuinely has `Label` = `app.nodespace.daemon` and the conditional `KeepAlive` dict form. Combined with the earlier raw.githubusercontent.com confirmation and the passing test run in the worktree that produced this exact commit (staged/verified via `git diff --cached` before committing this time, not just `git status`), I'm confident this is genuinely fixed now. Merging per standing authorization.

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