Skip to content

Install coexistence checks and other-product notices (ADR-084 §4.3, §5) - #3606

Merged
malibio merged 1 commit into
mainfrom
issue-3415-install-coexistence
Oct 6, 2026
Merged

malibio merged 1 commit into
mainfrom
issue-3415-install-coexistence

Conversation

@mstomar125

@mstomar125 mstomar125 commented Oct 5, 2026 •

Copy link
Copy Markdown
Contributor

Closes #3415

Core's installers, CLI and app recognise when the installed NodeSpace is not core's, so they don't silently replace another product or remove only part of it. Every check compares the installed bundle's NodeSpaceProduct with community. No check names another product or its daemon, a bundle without the key counts as not community, and there is no fallback for older bundles. Nothing executes an installed binary.

This supersedes the parked drafts #3411 (uninstall), #3380 (cask) and #3381 (.pkg). Their nodespaced-* fallback and the product-naming message are gone; the uninstall guard is ported as it was.

What changed

Acceptance criterion Where
App bundle declares NodeSpaceProduct = community src-tauri/Info.product.plist, named by bundle.macOS.infoPlist in tauri.conf.json (a configured path rather than an auto-merged Info.plist, so a build config can replace it). The release workflow's verify_layout now fails if the installed bundle lacks the key.
.pkg installation check + preinstall scripts/build-pkg.sh (Distribution installation-check, Fatal dialog) and the new scripts/pkg-resources/preinstall (runs for every install, installer CLI included). Both refuse with the exact ADR text (ADR-084 §5 as amended 2026-10-06), take no override, and read Info.plist only (system.files.plistAtPath / /usr/bin/plutil). If the JS check throws, it logs and defers to preinstall, which decides the same way; the release workflow fails the build if that log line appears in install.log.
Homebrew cask preflight, database out of zap scripts/update-homebrew-cask.ts: preflight_steps (current Homebrew rejects a Ruby preflight block) plus the same check in uninstall_preflight_steps, because brew upgrade/reinstall move the installed app aside before the new version's preflight runs. ~/.nodespace/database is out of zap. The rendered cask passes brew style (Homebrew 7.0.4), which also needed depends_on arch before macos and an alphabetical zap. No env override here: brew runs under env -i, so a NODESPACE_* variable never reaches the step.
nodespace uninstall refusal, proceeds with no app packages/cli/src/commands/uninstall.rs (from the #3411 draft): ADR-084 §5's message, XML or binary plist.
Skill guidance packages/skill/references/cli.md: a hand-written "Uninstalling NodeSpace" section, outside the generated region. skill:gen makes no change and skill:check passes.
Both in-app notices (§4.3) Another daemon outside the shared label holds the socket: after registering its own daemon, ensure_daemon_running asks the daemon on the socket which executable it runs. If it isn't the active profile's, it records it and returns NotRunning. The status becomes other_daemon until a retry, and OtherDaemonBanner shows "Another NodeSpace background service is running (‹path›). Stop it, then choose Retry." Retry (retry_daemon_start) runs the start again. Foreign machine-wide registration: foreign_machine_wide_registration reads /Library/LaunchAgents/<label>.plist and compares its Program/ProgramArguments[0] with the profile's binary. ForeignRegistrationNotice shows the ADR text, is non-blocking and can be dismissed. Both compare only against the app's own DaemonProfile, in the new app-lib/src/coexistence.rs.
Script tests and Rust tests Below.

The reset path for incompatible databases and the new Retry share daemon_setup::start_daemon_and_report. Data-plane-ready is not emitted while another daemon holds the socket.

Tests

  • Scripts (bun test scripts/, 1398 pass): pkg-preinstall.test.ts runs the real preinstall against fixture bundles: community, another product, no key, empty or non-string value, binary plist, no Info.plist, override values and the target volume. Every fixture executable writes a sentinel, so a run that executes anything fails. pkg-installation-check.test.ts renders the real Distribution block from build-pkg.sh, runs its JS against a mocked Installer, checks that productbuild accepts it, checks that its text matches preinstall's, and covers the release-workflow tripwire. update-homebrew-cask.test.ts covers the snapshot, the stanza structure, and the rendered script run against fixture bundles (with a space in the path).
  • Rust (crate-scoped cargo-nextest): nodespace-cli 287/287, including skill_md_generation. nodespace-app-lib: all lib tests pass, including the 7 new coexistence tests and only_another_reported_executable_is_an_other_daemon. Its tests/it seam tests need a built nodespaced, so they weren't run on this shared machine; the merge gate runs them.
  • Frontend: full bun run test 5784/5784, including new tests for both notices and the daemon-status service (other_daemon, Retry and its in-flight hold, and the two reads).
  • Mutation-checked: every new test was run alone against a mutation targeted at it, and all 80 were caught: 49 scripts, 17 Rust, 14 frontend.
  • Clippy -D warnings -D clippy::unused-async is clean for nodespace-app-lib and nodespace-cli, and cargo fmt, eslint, tsc, svelte-check and design tokens are clean. scripts/check-pro-boundary.ts exits 0, and the push check passed.

Needs a real Mac to confirm (not runnable here)

  • (Checked on macOS 26.6.2 with a payload-free probe package: Installer does not pass a variable set for installer through to preinstall. The override was removed for that reason.)
  • That the refusal dialog appears over an app that declares another product. The release workflow's second install already exercises the community path of both checks on a real Installer.
  • A brew install/upgrade over a non-community app (only the extracted script is tested, plus brew style).

To settle before the release that ships this

  • A .pkg update over core v0.3.3 or earlier is refused. Those bundles have no NodeSpaceProduct key, and ADR-084 §5 counts a bundle without the key as not community, with no fallback. nodespace uninstall from a new CLI also refuses next to an old app. The refusal says what to do: move /Applications/NodeSpace.app to the Trash, then run the installer (or the command) again. Homebrew upgrades and .dmg drags are not affected. Accepted by the ADR owner: there are no users on those versions.
  • The override is removed. A real-Mac check showed the variable never reaches preinstall, and moving the app to the Trash does what it was for. There is no NODESPACE_FORCE_COMMUNITY and no replacement (ADR-084 §5, amended 2026-10-06).
  • A hand-replaced cask install. If another product's app replaces a cask-installed NodeSpace.app without going through its installer's Homebrew check, brew upgrade, brew uninstall and --force all refuse, by design, rather than delete that app. The Homebrew record then stays until that product's uninstaller runs. ADR-084's P3 flow is unaffected: the other installer stops before it writes anything, while the app is still core's.
  • A slow-exiting evicted daemon. A daemon under the shared label that still answers more than 5 s after its boot-out is reported as "another background service", and Retry clears it.

Documentation

No docs change is needed: the ADRs already describe this behaviour.

🤖 Generated with Claude Code

@mstomar125

Copy link
Copy Markdown
Contributor Author

Automated pragmatic-code-review (round 1)

Review Type: Initial Review (medium depth), head 5afcaf44
Sources of truth: ADR-084 §4.3 and §5, ADR-081 §2d and §8 (docs origin/main @ 19fb82a), plus CLAUDE.md "Pro / Sync Boundary".

What I ran (all read-only, no cargo):

  • bun test scripts/pkg-preinstall.test.ts scripts/pkg-installation-check.test.ts scripts/update-homebrew-cask.test.ts: 56/56 pass.
  • bun run --cwd packages/desktop-app test on the three new or changed frontend files: 36/36 pass.
  • bun run scripts/check-pro-boundary.ts: exit 0. The + lines of the diff name no other product or daemon.
  • Homebrew 7.0.4's own source, to check the cask claims (details below).

Requirements Check (#3415, checked against the ADRs)

Criterion Verdict
✅ App bundle declares NodeSpaceProduct = community Info.product.plist is set through bundle.macOS.infoPlist, which tauri-utils 2.9.2 supports ("merge with the default Info.plist"). verify_layout in release.yml now fails if the installed bundle lacks the key.
✅ / ⚠️ .pkg installation check and preinstall refuse with the exact text, honour NODESPACE_FORCE_COMMUNITY=1, and execute nothing The text matches character for character in both places, and a parity test holds them together. Both read static data only (plistAtPath, /usr/bin/plutil). A missing key, an empty or non-string value, or an unreadable plist all refuse, with no fallback. ⚠️ Whether the override reaches preinstall is unverified (finding 1).
✅ Cask has the same check and message, and ~/.nodespace/database is out of zap I checked this against Homebrew 7.0.4's source. rubocops/cask/install_steps.rb maps preflight to preflight_steps, so the declarative form is correct. Cask::Upgrade runs old_cask_installer.start_upgrade (the old cask's uninstall artifacts) before new_cask_installer.install_artifacts, so the PR's reason for repeating the check in uninstall_preflight_steps holds. PreflightSteps#uninstall_phase only reverses symlink steps, so the check never runs twice. {{appdir}} is expanded inside run args (run_serialised_command).
✅ nodespace uninstall refuses with §5's exact text and proceeds with no app It fails closed on an unreadable or binary plist, a non-string value, or a missing Info.plist. A test pins the whole text.
✅ Skill guidance in references/cli.md Hand-written section placed outside the generated region.
✅ Both in-app notices use the §4.3 text The other-daemon banner leaves out the parentheses when the daemon reports no path. The foreign-registration notice cannot block anything and can be dismissed. Both compare only against the active DaemonProfile.
✅ Script tests (community, another product, no key) and Rust tests for the CLI guard The fixtures are thorough. Every fixture executable writes a sentinel file, which proves nothing gets executed.
✅ ADR-081 §8 hard ban Exit 0. No allowlist entry was needed.

Retry flow. I traced it end to end, and it does restart the app's own daemon. When Retry runs after the other daemon has stopped, the eviction probe fails, so evicted=false. The socket reports NotRunning. write_plist and bootstrap_launchd_agent then run. The job is still loaded after exiting 0 on the lock, so the first bootstrap fails, the code runs enable → bootout → bootstrap, and RunAtLoad starts the daemon. The product check then finds a Match and the result is Healthy. On Linux, enable --now starts the inactive unit. When Retry runs while the other daemon is still up, the record is set again after about 5s (EVICTION_EXIT_GRACE).

Stuck or false other_daemon record. The record is cleared at every start and set only on a Mismatch reported after registration. An Unknown result (timeout or RPC error) never sets it. A NODESPACED_SOCKET override skips the check. No other unit test in the shared cargo test --test-threads=2 process reads the global, so the new process-wide test is safe. I found no path that leaves the record stuck without the user being able to clear it with Retry. Two minor windows are noted below (findings 3 and 5).

Code Review Findings

🟡 1. [Improvement] The NODESPACE_FORCE_COMMUNITY=1 override probably never reaches preinstall
📁 scripts/pkg-resources/preinstall:29, scripts/build-pkg.sh:227

  • Issue: The Distribution JS reads system.env inside the installer process, so the override likely works there. preinstall, however, is run by Installer's script service (installd → package_script_service), which gives scripts a fixed environment (COMMAND_LINE_INSTALL, INSTALLER_TEMP, PACKAGE_PATH, USER, and so on). As far as I know, it does not pass on arbitrary variables from sudo VAR=1 installer …. If so, a scripted install over another product passes the installation check but preinstall still refuses it, and the override that ADR-084 §5 requires does nothing. The PR body already lists this as unverified on a real Mac. I'm raising it because, if it fails, the cause is the design, not an Installer quirk.
  • Recommendation: Before this ships in a release, run a cheap check on a real Mac that leaves /Applications alone: a pkgbuild --nopayload package whose preinstall dumps env to a temp file, installed with sudo FOO=1 installer -pkg … -target /. If FOO is missing, take it to the ADR owner rather than inventing a mechanism here. Possible options are a root-owned marker file that both checks read, or amending §5's override for the preinstall half. Either way, record the result in the PR or a follow-up issue.
  • Principle: Correctness of a stated requirement. An untested override that no test can reach is a guarantee nobody can rely on.

🟡 2. [Improvement] Upgrading from v0.3.3 or earlier by .pkg is refused as "Another NodeSpace product", and this isn't stated anywhere
📁 scripts/pkg-resources/preinstall:33-37, scripts/build-pkg.sh:219-238, packages/cli/src/commands/uninstall.rs:37-42

  • Issue: Every shipped core build up to v0.3.3 lacks the key. Following the ADR literally (a bundle without the key is not community, with no fallback), the next .pkg refuses to install over the user's own older NodeSpace and says another product is installed. nodespace uninstall refuses too ("update NodeSpace first"). Together with finding 1, a GUI user's only way through is to drag /Applications/NodeSpace.app to the Trash first. The in-app update banner points to the releases page, so every internal tester on v0.3.x will hit this on their next update. Homebrew upgrades are not affected: per the Homebrew source, the old app is moved aside before the new preflight_steps run.
  • Recommendation: No code change; this is the ADR as written. State it in the PR body and in the release notes for the release that ships this: "upgrading from v0.3.3 or earlier with the .pkg: move /Applications/NodeSpace.app to the Trash first; your databases stay." Optionally, flag to the ADR owner that §5's rationale ("none was ever shipped to users") covers older Pro builds, while the side effect falls on older core builds.
  • Principle: Operational correctness. A documented sharp edge is fine; an undocumented one becomes a bug report.

🟢 3. [Improvement] Clearing the record at the start of a Retry briefly reports the other daemon as healthy
📁 packages/desktop-app/app-lib/src/daemon_setup.rs:757, :916

  • Issue: ensure_daemon_running clears the record first and sets it again only at the end, which takes at least 5s because of EVICTION_EXIT_GRACE. A check_daemon_status in that window probes the socket, gets an answer from the other daemon, and returns "healthy". The window that pressed Retry holds this back (restartInFlight), but other windows don't, so they fire onDaemonReconnect against the other daemon until the final other_daemon emit arrives.
  • Recommendation: Compute the outcome and swap the record once at the end (for example, record_other_daemon(found) on every exit path), or have daemon_status_body report "starting" while a start is in flight.
  • Principle: Atomic state transitions, so readers never see a half-made decision.

🟢 4. [Improvement] Comments now overstate what other_daemon isolates, and one doc comment is stale
📁 packages/desktop-app/app-lib/src/daemon_setup.rs:642, packages/desktop-app/app-lib/src/lib.rs:713-716

  • Issue: The doc on evict_if_other_product still ends "…the app keeps using the survivor", which this PR changes. The startup comment "this app does not load from that daemon" is true only of the data-plane-ready event. The watcher (lib.rs:690), the token stream and spawn_daemon_ready_tasks (:700) still run against whatever holds the socket. So does the frontend's pull-on-subscribe check_daemon_status, which runs before the record is set and reports healthy, firing reconnect loads. That matches main's behaviour, and ADR-084 §4.3 asks only for the notice, so this is not a regression.
  • Recommendation: Fix both comments to say what actually happens: the app reports the other daemon but its client still dials the shared socket. Gating the data plane is out of scope; open a follow-up only if wanted.
  • Principle: Comments are part of the contract. A wrong comment at a concurrency seam is worse than none.

🟢 5. [Suggestion] A booted-out daemon under the shared label that takes more than 5s to exit is reported as "another background service"
📁 packages/desktop-app/app-lib/src/daemon_setup.rs:579, :905-918

  • Issue: After eviction, if the booted-out daemon is still answering when wait_for_daemon_or_refusal returns, the new check records it as an other daemon. The app's daemon has already exited 0 on the lock, so nothing restarts it, and the banner names a process that is on its way out. Retry recovers, and on main this case ended in not_running, so the PR is still a net improvement.
  • Recommendation: Optional. When evicted is true and the post-registration check reports the same executable eviction just saw, wait for socket release once more before declaring other_daemon.
  • Principle: Avoid false-positive user-facing errors at known transient states.

🟢 6. [Suggestion] uninstall_preflight_steps leaves no way to drop a stale cask record
📁 scripts/update-homebrew-cask.ts:221-249

  • Issue: If another product has already replaced a cask-installed app, brew upgrade, brew uninstall --cask nodespace and --force all refuse. In Homebrew 7, --force doesn't skip uninstall phases. The only way out is to remove the other product. That is the right default under "each product removes only what it installed", since otherwise Homebrew's app uninstall would delete the other product's bundle. It does, however, conflict with ADR-084 P3's advice ("Run brew uninstall --cask nodespace") in the narrow case where P3 was bypassed.
  • Recommendation: Keep the behaviour. Note it in the PR body, and send it to the nodespace-sync side, which owns P3's message, so the two sides agree.
  • Principle: Make the deliberate trade-off visible across the boundary.

🟢 7. [Nit] The startup task repeats start_daemon_and_report's status mapping
📁 packages/desktop-app/app-lib/src/lib.rs:595-622

  • Issue: The match from Healthy to "healthy" and from anything else to daemon_down_status() is now in two places.
  • Recommendation: The startup block could emit "starting" and then call start_daemon_and_report.
  • Principle: DRY.

What's good: The change is cleanly atomic, and the boundary discipline is strong: every check runs against the active profile or community, so nothing names the other product. preinstall is pinned to $3, the target volume. The heredoc hazards are documented and tested ($, backticks, #, {{). The release-workflow tripwire for a JS check that throws is a smart guard against the dialog silently turning off. The CLI guard fails closed. The tests run the real artifacts (rendered heredoc, real preinstall, extracted cask script) rather than re-implementations.

Recommendation: APPROVE

This is a net positive with no critical or blocking issues. Before the release that ships this, settle finding 1 (verify on a real Mac, or escalate to the ADR owner) and finding 2 (release notes and PR body). Findings 3 and 4 are small and can go in this PR or a follow-up.

🤖 Generated with Claude Code

@mstomar125 mstomar125 left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Automated pragmatic-code-review round 1: APPROVE (posted as a comment — GitHub blocks self-approval). Full findings in the review comment above.

@mstomar125

Copy link
Copy Markdown
Contributor Author

Address-review, round 1

Addressed in d961643b.

  • ✅ 🟢 3 — Retry briefly reported the other daemon as healthy. ensure_daemon_running no longer clears the record up front. Its body is now start_daemon, which returns the status together with any other daemon it found, and the record is replaced once with that answer (cleared on an error). During a Retry, other windows' polls keep reporting other_daemon until the start finishes.
  • ✅ 🟢 4 — Two stale comments. evict_if_other_product now says the survivor is reported as another daemon. The startup comment now says the frontend is not told to load from that daemon; it no longer claims the app never talks to it.
  • ✅ 🟢 7 — Duplicated status mapping. The startup task reports through start_daemon_and_report, which keeps the info and warn logs the old block had. Net −15 lines.
  • 📝 🟡 1 — Override reaching preinstall. It can't be verified on this machine, because running a real installer is off-limits here. It's listed in the PR body under "To settle before the release that ships this", with the suggested env-dump package check and escalation to the ADR owner if the variable doesn't reach the script.
  • 📝 🟡 2 — .pkg over v0.3.3 or earlier is refused. This is ADR-084 §5 applied literally: no key means not community, with no fallback. It's in the same PR-body section as a release-notes or ADR-owner item, with the workaround.
  • ⏭️ 🟢 5 — Slow-exiting evicted daemon. Skipped. It needs a daemon that still answers more than 5 s after a launchd boot-out, and Retry recovers. A second wait-and-recheck would add a branch to the startup path for a rare case. Documented in the PR body.
  • 📝 🟢 6 — Stale cask record after a hand replacement. Documented in the PR body. The cask refusing to delete another product's app is the intended default. ADR-084's P3 flow is unaffected, because the other installer stops while the app is still core's, so brew uninstall --cask nodespace passes then.

Checks after the change: clippy -p nodespace-app-lib --all-targets -D warnings -D clippy::unused-async is clean, app-lib lib tests pass 316/316, cargo fmt --check is clean, and the push check (lint and the Pro-boundary ban) passed.

Re-Review Decision

Decision: RE-REVIEW NEEDED

Rationale: The record timing is a behaviour change on the daemon start path, and the startup task in lib.rs now reports through a different function. Both are small, but they sit on the app's startup path, so the new commit should get its own look.

🤖 Generated with Claude Code

@mstomar125

Copy link
Copy Markdown
Contributor Author

Automated pragmatic-code-review (round 2, re-review)

Review Type: Re-Review (medium depth) of the new commit d961643b ("Record another daemon only once a start has its answer"), head d961643b. Round 1 reviewed 5afcaf44.
Sources of truth: ADR-084 §4.3 and §5 (docs origin/main).

What I ran (read-only, no cargo): bun run scripts/check-pro-boundary.ts exits 0 with zero hits on every marker. I read ensure_daemon_running, start_daemon, start_daemon_and_report, evict_if_other_product, the startup task and daemon_status_body in lib.rs, incompatible_database::{daemon_down_status, reset}, coexistence.rs, and the frontend daemon-status.ts (polling and restartInFlight). I grepped the repo for the old and new log strings and for callers of the changed functions. The author reports clippy -p nodespace-app-lib clean and app-lib lib tests 316/316 on this commit; I did not re-run them.

Previous Review Summary

Round 1 made 7 recommendations. 3 were fixed in code, 3 were documented in the PR body, 1 was skipped with a reason, and every justification holds. This review found 0 blocking issues and 2 new optional items.

Round-1 item Outcome Verdict
🟡 1: override may not reach preinstall 📝 In the PR body under "To settle before the release that ships this", with the env-dump check and escalation to the ADR owner ✅ Holds. The machine rules forbid a real installer here, and round 1 asked only that it be recorded. See the note below the table.
🟡 2: .pkg refused over v0.3.3 or earlier 📝 Same section, with the workaround (move the old app to the Trash) and "needs a release-notes line, or a decision from the ADR owner" ✅ Holds. ADR-084 §5 says "a bundle without the key counts as not community" with no fallback, so no code change was expected.
🟢 3: Retry briefly reported the other daemon as healthy ✅ Fixed. The record is now written once, after the start ✅ Verified below
🟢 4: stale comments ✅ Fixed. evict_if_other_product's doc now points to ensure_daemon_running reporting the survivor. The startup comment now says "the frontend is not told to load from that daemon", which is accurate for that block: socket_reachable is false, so data-plane-ready is not emitted. ✅
🟢 5: slow-exiting evicted daemon ⏭️ Skipped, and listed in the PR body ✅ Holds. It's rare, Retry recovers, and on main the same case ended in not_running.
🟢 6: stale cask record after a hand replacement 📝 Documented ✅ Holds. I checked ADR-084 P3 ("Run brew uninstall --cask nodespace…"). P3 fires while /Applications/NodeSpace.app is still core's, so uninstall_preflight_steps passes at that point. Only the bypassed-installer case is stuck, and that is by design.
🟢 7: duplicated status mapping ✅ Fixed. The startup task now emits starting and calls start_daemon_and_report ✅ Verified below

Note on 🟡 1 and 🟡 2: both now live only in the PR body. Once this merges, nothing raises them at release time. I suggest a short tracking issue, or a line in the draft release notes for the next release, so whoever cuts that release sees them. This is process only and does not block the merge.

Verification of the new commit

The record now changes only when a start has its answer, and it cannot get stuck.

  • ensure_daemon_running is now a thin wrapper. It awaits start_daemon, then calls record_other_daemon(...) exactly once with Some(executable) or None. Every exit from start_daemon reaches that one write: the two Healthy early returns, every ? error, the other-daemon return and the final Ok. This is structurally better than before, because no exit path can skip the write.
  • During a Retry, daemon_status_body keeps returning other_daemon in other windows, since the record still holds the old value. The window that pressed Retry holds back polls with restartInFlight. At the end, start_daemon_and_report broadcasts the final status (emit_routed(..., None)), so other windows move to healthy or stay on other_daemon together. Round-1 finding 3 is closed.
  • Ordering. The record is written inside ensure_daemon_running before it returns, so start_daemon_and_report's daemon_down_status() already sees the new value. This is the same order as in 5afcaf44.
  • An Err clears the record. This matches the round-1 design, where an Unknown product check never sets it. A failed start says nothing about who holds the socket. Keeping the old value instead would show the other-daemon banner for an unrelated failure after the user had stopped the other daemon. A Retry clears the record either way, so it cannot get stuck.
  • Placement. The write sits in the pub ensure_daemon_running, not in start_daemon_and_report, so any direct caller of the public function also keeps the record current. I found no caller outside daemon_setup.rs.

The startup task's behaviour is unchanged.

  • Statuses. The task emits daemon-status = starting, then exactly one of healthy or daemon_down_status(), through the same emit_routed(..., None) call, in the same order and before the skill install, watcher, token stream, spawn_daemon_ready_tasks and the post-startup reachability check. The return value is dropped, which is fine because a &'static str is not #[must_use].
  • Logging. The startup path keeps info on healthy, warn with the status otherwise and error with {:#} on failure. Two wordings changed: "Daemon setup failed" became "Daemon start failed", and "not yet healthy: {:?}" became a structured ?status. Nothing in the repo greps for either string (I checked .rs, .ts, .svelte, .md, .sh and .yml). Retry and reset now also log info/warn where they logged nothing before, which helps.
  • No dead code or unused imports. The block-scoped use daemon_setup::{ensure_daemon_running, DaemonStatus} went with its block. use tauri::Emitter is still used for the DATA_PLANE_READY_EVENT emit. incompatible_database::daemon_down_status is still used by the post-startup check. DaemonStatus is still imported where the probe needs it. Windows compiles the same shape and always records None.

Code Review Findings (new commit only)

🟢 1. [Suggestion] No test pins the new ordering, so the round-1 fix can regress silently
📁 packages/desktop-app/app-lib/src/daemon_setup.rs:756-764, packages/desktop-app/app-lib/src/coexistence.rs:135-155

  • Issue: Moving record_other_daemon(None) back to the top of ensure_daemon_running would bring finding 3 back, and every test would still pass. The PR body says every new test was mutation-checked, but this commit changes behaviour without adding a test. The wrapper is only four lines and easy to check by reading, so this is optional.
  • Recommendation: Pull the wrapper into a helper that takes the start as a future, for example async fn record_start(start: impl Future<Output = Result<(DaemonStatus, Option<String>)>>) -> Result<DaemonStatus>, and have ensure_daemon_running call record_start(start_daemon(app)). Then extend the one test that already touches the process-wide record, which keeps that test's "only test that touches it" rule: record Some("old"), run record_start(async { assert_eq!(other_daemon().as_deref(), Some("old")); Ok((DaemonStatus::Healthy, None)) }) with block_on, and assert the record is None afterwards. Add an Err case that also ends in None.
  • Principle: Tests pin behaviour. A fix requested in review should leave behind a test that fails if the fix is undone.

Nit 2. ensure_daemon_running's doc and the new function's name now read slightly wrong
📁 packages/desktop-app/app-lib/src/daemon_setup.rs:748-751, :767-769

  • Issue: The doc still says "Call this from the Tauri setup block. It is non-fatal: logs errors and returns them so the caller can emit…". The setup block now calls start_daemon_and_report, and that function does the error logging and the emit. Also, the outermost entry point (start_daemon_and_report) and the innermost body (start_daemon) share a prefix, while the function between them (ensure_daemon_running) is the one that writes the record. A reader could assume start_daemon_and_report → start_daemon and miss that write.
  • Recommendation: Point the doc at start_daemon_and_report for UI callers, and say that this function updates [crate::coexistence]'s record. Optionally rename the inner function to something like run_daemon_start.
  • Principle: Comments are part of the contract, and names should reflect how the functions layer.

What's good: The fix takes the cleaner of round 1's two options: one write at one point, with no in-flight flag to keep in sync. The startup task drops 32 lines of duplicated mapping, and a Retry and an app start now produce the same statuses and logs. Every changed comment now describes what the code actually does. The Pro boundary is still clean.

Recommendation: APPROVE

The new commit is correct and slightly simplifies the start path. Round-1 findings 3, 4 and 7 are fixed. Findings 1, 2, 5 and 6 have sound justifications and are recorded in the PR body. Neither new item blocks the merge. Before the release that ships this, settle the two "To settle" items as round 1 asked. Ideally, track them somewhere that outlives the PR body.

🤖 Generated with Claude Code

@mstomar125 mstomar125 left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Automated pragmatic-code-review round 2: APPROVE (posted as a comment — GitHub blocks self-approval). Full findings in the review comment above.

@mstomar125

Copy link
Copy Markdown
Contributor Author

Address-review, round 2

Addressed in 045ec5ea.

  • ✅ 🟢 1 — No test pinned the record's timing. The record write is now record_outcome(bring_up), which takes the start as a future and replaces the record once the future resolves. ensure_daemon_running is record_outcome(bring_up_daemon(app)).await. The one test that owns the process-wide record (the_other_daemon_record_holds_until_a_start_has_its_answer) now checks three things: the record still holds the previous daemon inside a running start, a start that finds another daemon records it, and a failed start clears it. Mutation-checked against three mutations, all caught:
    • clearing the record before the await (the round-1 bug);
    • keeping a stale record on error;
    • not recording a found daemon.
  • ✅ Nit 2 — Stale doc and confusing names. ensure_daemon_running's doc now points callers that report to the frontend (the startup among them) at start_daemon_and_report. The inner function is renamed bring_up_daemon, so it no longer shares a prefix with start_daemon_and_report.
  • 📝 Process note — 🟡 1 and 🟡 2 live only in the PR body. Passed to the coordinator, who owns the release, so they can become a tracking issue or a release-notes line.

Checks: clippy -p nodespace-app-lib --all-targets -D warnings -D clippy::unused-async is clean, app-lib lib tests pass 316/316, cargo fmt is clean, and the push check (lint and the Pro-boundary ban) passed.

Re-Review Decision

Decision: NO RE-REVIEW NEEDED

Rationale: The production logic is unchanged from what round 2 approved. The wrapper's body moved into a helper that takes a future, the inner function was renamed, and a doc comment was updated. The only new code is the test, and mutations show it catches the regression it targets.

🤖 Generated with Claude Code

@mstomar125

Copy link
Copy Markdown
Contributor Author

@malibio a sequencing question for tomorrow. This PR's installer coexistence checks look for NodeSpaceProduct = community in the installed app's Info.plist. v0.3.3 bundles don't have that key, so shipping this in v0.3.4 would refuse .pkg updates from v0.3.3.

The key alone landed in #3610 (confirmed in a real CI build's Info.plist), so v0.3.4 will carry it. My suggestion: hold this PR for the release after v0.3.4, by which point every install has the key. The FORCE_COMMUNITY path to the preinstall script also still needs a real-Mac check.

🤖 Generated with Claude Code

@malibio

malibio commented Oct 5, 2026

Copy link
Copy Markdown
Collaborator

@mstomar125 answering the sequencing question: land this now. Don't hold it for the release after v0.3.4.

Updates from v0.3.3. A v0.3.3 bundle has no NodeSpaceProduct key, so the v0.3.4 .pkg will refuse to install over it. That's acceptable. There are releases, but no users: nobody outside the team has installed one. That is what CLAUDE.md's "no backward compatibility" rule refers to, and I'm rewording its first line to say so (it currently reads "NO releases", which is what made this look like a question). Anyone on our own machines with v0.3.3 deletes the app or sets NODESPACE_FORCE_COMMUNITY=1 once.

So: no hold, and no reading of a missing key as community either. That would be compatibility code for an old version.

The NODESPACE_FORCE_COMMUNITY preinstall path. This still needs its run on a real Mac before the merge, since no test covers it. Please do that run, note the result here, and then queue the PR with bun run merge 3606.

What depends on it. nodespace-core#3639 and nodespace-docs#112 (the startup hold) should be rebased onto this once it lands: the hold is to release on this PR's post-registration check. Decisions on those are coming on nodespace-docs#112.

@malibio

malibio commented Oct 5, 2026

Copy link
Copy Markdown
Collaborator

@mstomar125 one change before this lands, so please don't queue it yet.

New rule for core, being written into ADR-081 now: core carries no reference to another NodeSpace product, in what a user sees or in the code. We ship a new binary that replaces the installed one; core does not announce or describe it.

This PR adds user-facing text and code that say otherwise:

  • messages such as "a different NodeSpace product", "Another NodeSpace product's background service is registered…", "Another NodeSpace background service is running";
  • comments and names about "another product", "other product", "other-product notices";
  • the NodeSpaceProduct = community key and the checks that compare against community.

What the checks protect is still wanted: don't install over, evict or talk to something this build doesn't recognise. Please reword it in those terms, with nothing implying a second product exists. For example: "The NodeSpace app installed here was not built by this installer's publisher or is a version it does not recognise", and "A background service this app did not start is using NodeSpace's socket ({executable}). Stop it, then choose Retry." Names and comments follow the same rule.

For the plist key, a neutral identity is fine (the build's own identifier); what should go is a vocabulary that only makes sense if there are two products.

The real-Mac check of the override path is still needed after the rewording.

@malibio

malibio commented Oct 5, 2026

Copy link
Copy Markdown
Collaborator

@mstomar125 please disregard my previous comment. The hold is lifted and no rewording is needed.

I recorded a rule that went further than intended. The actual decision is about the name: the paid offering is NodeSpace Sync, a service added to the one app, not an edition, and we stop using the word "Pro" (ADR-081 §2, amended 2026-10-05). Core may still say that sync exists, and the checks in this PR, which compare against community and name no other product, are fine as written.

So this PR is back to where the earlier reply left it: run the NODESPACE_FORCE_COMMUNITY check on a real Mac, note the result here, then queue it.

The only follow-on from the naming decision is that nothing new should say "Pro"; the rename of what core already says is filed separately in this repo.

@malibio

malibio commented Oct 6, 2026

Copy link
Copy Markdown
Collaborator

Pragmatic code review (independent, on behalf of @malibio)

Review Type: Initial review of the whole diff at head 045ec5ea, against main at 21f199fd. The two earlier rounds were the author's own reviewer; I read them and did not rely on their verdict.

Verdict: changes needed before merge. The design is sound and the checks do what ADR-084 §5 and §4.3 say. Two things break the merge gate once this is brought up to current main, and the owner's required real-Mac run of the override is still outstanding.

How I checked. Read-only: the full diff, the PR head's files, a git merge-tree of the head onto main, ADR-084, ADR-081 (with the 2026-10-05 amendment), and Homebrew 7.0.6's source on this machine. I built nothing and ran no tests. Each claim below is marked [read] (verified by reading code or by a read-only command) or [inferred].

Requirements check (#3415)

Criterion Finding
✅ Bundle declares NodeSpaceProduct = community Already on main through #3610; the PR's copy of Info.product.plist and tauri.conf.json merges without a conflict. [read]
✅ / ⚠️ .pkg installation check and preinstall refuse, exact message, override, nothing executed Both refuse a missing key, a non-community value, a non-string and an unreadable plist; text matches ADR-084 §5 exactly; only plistAtPath and /usr/bin/plutil are used. preinstall ships because pkgbuild --scripts takes the whole pkg-resources directory and the file is mode 755. [read] ⚠️ Whether the override reaches preinstall is unverified (finding 4).
✅ Cask preflight, database out of zap preflight_steps and uninstall_preflight_steps exist in Homebrew 7.0.6 (cask/artifact/install_steps.rb), run defaults to must_succeed: true, and Cask::Upgrade runs the old cask's start_upgrade before the new cask's install_artifacts, so repeating the check in the uninstall phase is justified. [read] Not run against a real brew.
⚠️ nodespace uninstall refuses, proceeds with no app The function is right and fails closed. As merged with main it makes three integration tests depend on the real /Applications (finding 1), and nothing tests that run calls it (finding 7).
✅ / ⚠️ Skill guidance Present, outside the generated region. ⚠️ Its advice loops for an app without the key (finding 5). I did not run the drift check.
✅ / ⚠️ Both in-app notices Both texts match §4.3. ⚠️ The app still reads and writes through the other daemon while the banner shows (finding 6).
✅ Script tests with community, another product and no key; Rust tests for the CLI guard All three fixtures exist for the installation check, preinstall and the cask script; every fixture executable writes a sentinel. [read]

The owner's decision on a bundle without the key: confirmed. All four checks treat a missing key as not community, with no fallback and no reading of an older bundle [read]: preinstall:33-37, the Distribution script (build-pkg.sh:230-233), the cask script and uninstall_blocker. No compatibility code. What the refusal tells that user to do is finding 5.

Does it merge with current main?

No. Three files conflict (git merge-tree --write-tree origin/main 045ec5ea) [read]:

Stale against main, beyond the conflicts:

Findings

🔴 Critical (must change before merge)

1. The uninstall guard makes three integration tests read the real /Applications, and they fail on a machine with an older app.
📁 packages/cli/src/commands/uninstall.rs:40

  • run checks the hard-coded /Applications/NodeSpace.app before anything else. main now has packages/cli/tests/it/home_isolation.rs (Make NODESPACE_HOME alone isolate a daemon: the socket follows it, the app stops reading it #3658), which spawns the compiled nodespace uninstall with HOME at a tempdir and expects success in three tests: uninstall_removes_the_redirected_install_and_leaves_the_real_home_alone, uninstall_without_a_redirect_removes_the_install_in_the_users_home and an_empty_nodespace_home_is_not_a_redirect_to_the_working_directory. [read]
  • Those tests isolate themselves from the machine with a PATH that does not exist. The guard reads the machine's real app regardless. On the owner's Mac, /Applications/NodeSpace.app is v0.3.1 with no NodeSpaceProduct key (plutil confirms) [read], so all three exit non-zero with the refusal and the merge gate fails. [inferred: not run] On a machine with no app, or a v0.3.4 app, they pass. The outcome depends on what is installed.
  • Fix, in two parts. First, decide what a redirected run does: on main a run with NODESPACE_HOME set removes only what is under that home and leaves the service alone, so the guard's reason ("it would stop that app's daemon and delete its per-user files") does not apply to it, and skipping the guard when redirected matches Make NODESPACE_HOME alone isolate a daemon: the socket follows it, the app stops reading it #3658. Second, the non-redirected tests need the app location to be something a test can point at a fixture bundle (the repo already uses test seams of this kind, for example NODESPACED_TEST_BIN). With that seam, add a test that the compiled binary refuses and leaves the home byte-for-byte unchanged, which also closes the gap in finding 7.
  • Principle: test isolation. A test must not pass or fail on the state of the developer's machine.

2. Resolving the lib.rs conflict breaks a source-order test on main, and can silently drop the bundled-model copy.
📁 packages/desktop-app/app-lib/src/lib.rs:592

  • main's startup block calls bundled_model::provision_bundled_model(&app_handle).await before ensure_daemon_running, because the daemon reads the model path only when it starts. This PR replaces that whole block with daemon_setup::start_daemon_and_report(&app_handle).await. [read]
  • bundled_model.rs's test startup_copies_the_model_before_it_starts_the_daemon finds the literal match ensure_daemon_running(&app_handle).await in lib.rs and expects it. After this PR that text is gone, so the test panics. [read; failure inferred]
  • Fix: keep the provision_bundled_model call between the starting emit and start_daemon_and_report, and point the test's needle at the new call. Taking the PR's side of the conflict as it stands would ship an app that starts the daemon before the model is in place.
  • Principle: a merge is a change to review, not a mechanical step.

3. The owner's condition for merging is still open: the NODESPACE_FORCE_COMMUNITY run on a real Mac. No result is recorded on the PR. See finding 4 and the procedure below.

🟡 Important

4. The override reaches preinstall only if Installer forwards the installer process's environment to package scripts. Nothing in this PR makes that happen.
📁 scripts/pkg-resources/preinstall:29, scripts/build-pkg.sh:227

  • How the variable travels, as written [read]: sudo NODESPACE_FORCE_COMMUNITY=1 installer -pkg … -target / puts it in the installer process's environment. The Distribution check reads system.env in that process, so that half should work. preinstall reads its own environment and nothing else: the package carries no file, choice or argument that conveys the override.
  • Package scripts are not children of the installer process; the system's install service runs them. Whether it copies the caller's environment into the script is the open question, and I cannot settle it from this code. [inferred]
  • The word order matters. NODESPACE_FORCE_COMMUNITY=1 sudo installer … does not work under the default sudoers env_reset; the assignment has to follow sudo. [inferred from sudo's documented behaviour]
  • Failure if it is not forwarded: the Distribution check passes, preinstall refuses, and the user sees Installer's generic failure with the real reason only in /var/log/install.log. The override then does nothing, and the only way through is to delete the app.
  • A double-clicked install cannot set the variable at all. ADR-084 scopes the override to scripted installs, so that is as decided.
  • If the run shows it is not forwarded, that is a decision for the ADR owner, not something to patch around here. The two options I see: a root-created marker file that both checks read, or dropping the override from §5, since deleting the app does the same job for a scripted install.

5. For an app without the key, neither refusal tells the user something that works, and the skill guidance forbids the one thing that does.
📁 scripts/pkg-resources/preinstall:36, scripts/build-pkg.sh:236, packages/cli/src/commands/uninstall.rs:30, packages/skill/references/cli.md:876

  • The .pkg says "Uninstall it with its own uninstaller first." An older NodeSpace has no uninstaller that removes the app: nodespace uninstall removes binaries and the service registration, not /Applications/NodeSpace.app, and the new CLI's uninstall refuses beside that app anyway. [read]
  • The CLI says "or update NodeSpace first". Updating by .pkg is the thing that is refused. [read]
  • cli.md tells the agent "don't delete the app … by hand to get around the refusal". Moving the old app to the Trash is the stated way through.
  • The refusal itself is the accepted decision and I am not questioning it. The wording is fixed by ADR-084 §5 and pinned by tests in four files, so changing it is an ADR edit first. A clause such as "If this is an older NodeSpace, move it to the Trash and run the installer again" names no other product and adds no compatibility code. Cheapest to settle now, while the strings are being touched; it is the owner's call whether it holds the merge.

6. While the "another background service" banner shows, the app still reads and writes through that daemon.
📁 packages/desktop-app/app-lib/src/daemon_setup.rs:55, packages/desktop-app/src/lib/components/layout/app-shell.svelte:677

7. The pure functions are well tested; the places that call them are not.
📁 packages/desktop-app/app-lib/src/daemon_setup.rs:932, packages/cli/src/commands/uninstall.rs:40

  • Deleting any of these fails no test [read]: the post-registration block in bring_up_daemon, the early return in daemon_status_body, the other_daemon().is_none() gate on socket_reachable, and the guard call in run.
  • evict_if_other_product already takes its boot-out as a parameter; the same shape for "ask the daemon on the socket" would let a test cover the wiring. The uninstall call is covered by the test in finding 1.

🟢 Suggestions (can follow)

  • Let the release workflow do the real-Mac check on every release. 📁 .github/workflows/release.yml:626. The job already runs sudo installer twice on a macOS runner. A third step that sets the installed bundle's NodeSpaceProduct to another value, asserts a plain install fails and nothing changed, then asserts the override install succeeds, would turn finding 4 from a one-off manual run into a standing check.
  • The Distribution check and preinstall disagree on a non-string value. 📁 scripts/build-pkg.sh:231. String(info.NodeSpaceProduct) === 'community' is true for an array holding community; plutil … raw prints a count for an array and refuses. preinstall decides in the end, so this is cosmetic.
  • Retry is not serialized. 📁 packages/desktop-app/app-lib/src/coexistence.rs:58. Two windows choosing Retry run two starts at once, each booting out and re-registering the job. Each Retry while the other daemon is still up also boots out the app's own fresh registration and waits out the 5 s grace before reporting. Both are harmless today.
  • Nit: a dangling symlink at /Applications/NodeSpace.app passes [[ ! -e ]] in preinstall as "no app".

Things I looked for and did not find

  • Nothing new kills or boots out a process. The post-registration check only asks the daemon which executable it runs; the one boot-out in this path is the existing eviction on main, which targets the app's own label. [read]
  • Shell. preinstall quotes every expansion, set -e cannot abort on a failing plutil (|| true), a path with spaces is handled (the cask test uses one on purpose), and a missing plist, missing key or malformed plist all refuse. It reads a user-writable path as root but only compares one extracted string. The check-then-install window is the accident guard ADR-052 describes, not a security boundary.
  • Tests. No wall-clock assertions (the setDefaultTimeout calls are timeouts). The one process-wide record is touched by one test, and no other unit test in that process reads it. No test touches the real launchd; the only one that reaches the real /Applications is finding 1. [read]
  • Project rules. No compatibility or migration code, no #[allow(…)], no lint suppression, no console.*, no issue numbers in comments, nothing spawns cargo. The one new shell script is an installer preinstall, which qualifies. [read]

The manual check on a real Mac

Step A: does a package script see the variable at all? This touches nothing of NodeSpace.

  1. Make a package with no payload whose preinstall and postinstall both write env | sort to a file under /tmp, with pkgbuild --nopayload --scripts <dir> --identifier <any> --version 1 probe.pkg.
  2. Run sudo NODESPACE_FORCE_COMMUNITY=1 installer -pkg probe.pkg -target /.
  3. Look for NODESPACE_FORCE_COMMUNITY=1 in the dumped file. Present means the override can work as written. Absent means it cannot, whatever Step B shows.

Step B: the real package, over an app without the key. The owner's Mac already has one (v0.3.1). Use the .pkg built from this branch.

  1. sudo installer -pkg NodeSpace.pkg -target /. Expect a non-zero exit with the ADR message on the terminal, and the app's CFBundleShortVersionString and /usr/local/bin/nodespaced unchanged.
  2. sudo NODESPACE_FORCE_COMMUNITY=1 installer -pkg NodeSpace.pkg -target / -verbose. Expect exit 0, the new version, and plutil -extract NodeSpaceProduct raw on the installed Info.plist printing community. If it fails with Installer's generic error and /var/log/install.log holds the ADR message from preinstall, the variable passed the Distribution check and did not reach the script.
  3. Before step 2, or on a second Mac: double-click the .pkg over the old app. Expect the dialog titled "Another NodeSpace product is installed" before any password prompt.
  4. Run the plain install again over the now-current app. Expect success and no "NodeSpace installation check failed" line in /var/log/install.log.

Record the outcome of A.3, B.1 and B.2 on this PR.

Recommendation

Before merge:

  1. Rebase onto main and resolve the three conflicts, keeping provision_bundled_model ahead of the daemon start and updating the bundled_model test (finding 2).
  2. Make the uninstall guard independent of the machine's real /Applications in tests, and decide what a redirected run does (finding 1).
  3. Run the manual check and record the result (findings 3 and 4). If the variable does not reach preinstall, stop and ask the ADR owner.
  4. Correct the "instead of using it" comment (finding 6).

Owner's call whether it holds the merge: the wording for an app without the key (finding 5).

Can follow: the wiring tests of finding 7 other than the uninstall one, the release-workflow step, and the remaining suggestions.

Not merging. No approval given.

@malibio malibio left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Independent review for @malibio: changes needed before merge (posted as a comment, not an approval).

Full report: #3606 (comment)

Before merge:

  1. Rebase onto main. Three files conflict (release.yml, uninstall.rs, app-lib/src/lib.rs). The lib.rs resolution must keep provision_bundled_model ahead of the daemon start and update the bundled_model source-order test.
  2. The uninstall guard reads the real /Applications in three home_isolation tests, which fail on a Mac with an older app installed.
  3. The NODESPACE_FORCE_COMMUNITY run on a real Mac is still to be done and recorded here.
  4. Correct the comment that says the app does not use the other daemon.

Owner's call: the refusal wording for an app without the key. The rest can follow.

Comment thread packages/cli/src/commands/uninstall.rs Outdated
// leaving the app itself behind, so it refuses before touching anything.
#[cfg(target_os = "macos")]
{
if let Some(message) = uninstall_blocker(Path::new(INSTALLED_APP)) {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔴 Critical: this reads the machine's real /Applications in three integration tests.

main now has packages/cli/tests/it/home_isolation.rs, which spawns the compiled nodespace uninstall with HOME at a tempdir and expects success in three tests. They isolate themselves with a PATH that does not exist, but this guard reads /Applications/NodeSpace.app regardless. On a Mac with an older app there (the owner's has v0.3.1, no key) all three exit with the refusal, so the merge gate fails; on a Mac with no app they pass.

Two parts to the fix:

  • Decide what a run with NODESPACE_HOME set does. On main it removes only what is under that home and leaves the service alone, so the guard's reason does not apply; skipping it when redirected matches that.
  • Give the non-redirected path an app location a test can point at a fixture bundle, then add a test that the compiled binary refuses and leaves the home unchanged. Today nothing fails if this call is deleted.

This file also conflicts with main: home_dir() is gone there and run has a redirected branch.

// systemd on Linux). Signal the frontend to hold off on gRPC calls
// until the daemon is ready, then report how the start went.
window_routing::emit_routed(&app_handle, "daemon-status", "starting", None);
daemon_setup::start_daemon_and_report(&app_handle).await;

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔴 Critical: the conflict here must keep the bundled-model copy, and a test on main looks for the text this replaces.

main's version of this block calls bundled_model::provision_bundled_model(&app_handle).await before the daemon start, because the daemon reads the model path only when it starts. Taking this side of the conflict as it stands drops that call.

bundled_model.rs's startup_copies_the_model_before_it_starts_the_daemon finds the literal match ensure_daemon_running(&app_handle).await in this file and expects it, so it panics once that text is gone. Keep the provision call between the starting emit and this line, and point the test at start_daemon_and_report.

Comment thread scripts/pkg-resources/preinstall Outdated
VOLUME="${3:-/}"
APP="${VOLUME%/}/Applications/NodeSpace.app"

if [[ ! -e "${APP}" || "${NODESPACE_FORCE_COMMUNITY:-}" == "1" ]]; then

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Important: nothing here makes the override arrive.

This reads the script's own environment. sudo NODESPACE_FORCE_COMMUNITY=1 installer … sets the variable for the installer process, where the Distribution check sees it, but package scripts are run by the system's install service, not as children of installer. Whether that service forwards the caller's environment is the unverified part, and the package carries no file or argument that would convey the override otherwise.

If it is not forwarded, the Distribution check passes, this refuses, and the user gets Installer's generic failure with the reason only in /var/log/install.log.

The owner asked for this run before the merge. The procedure is in the review comment: a payload-free package whose scripts dump env, then the real package over an app without the key, with and without the variable. Note the assignment must follow sudo; before it, env_reset drops it.

Comment thread scripts/pkg-resources/preinstall Outdated
product="$(/usr/bin/plutil -extract NodeSpaceProduct raw -o - "${APP}/Contents/Info.plist" 2>/dev/null || true)"

if [[ "${product}" != "community" ]]; then
echo "Another NodeSpace product is installed on this Mac. Uninstall it with its own uninstaller first. Your databases stay on this Mac." >&2

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Important: for an app without the key, this tells the user to do something that does not exist.

An older NodeSpace has no uninstaller that removes the app: nodespace uninstall removes binaries and the service registration, and the new CLI's uninstall refuses beside that app. The CLI's own text says "or update NodeSpace first", which by .pkg is this refusal. Moving the old app to the Trash is what works, and neither message says so.

The refusal is the accepted decision; this is only about the text. It is fixed by ADR-084 §5, so it needs an ADR edit first. Owner's call whether it holds the merge.

Comment thread packages/skill/references/cli.md Outdated

> The NodeSpace app on this Mac is a different NodeSpace product, or an older NodeSpace that does not say which product it is. Use that product's own uninstaller, or update NodeSpace first; this command removes only the free NodeSpace.

**Pass that on and stop.** Tell the user to run the installed product's own uninstaller, or to update NodeSpace first if the app is an older free NodeSpace, and that their databases stay on the Mac either way. Don't retry, and don't delete the app, the binaries or `~/.nodespace` by hand to get around the refusal.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Important: this forbids the one remedy that works for an older app.

"Update NodeSpace first" leads to the .pkg refusal when the installed app has no key, and "don't delete the app … by hand" rules out moving that old app to the Trash, which is the stated way through. An agent following this has nothing useful to tell that user. Goes with the wording question on preinstall.

//! daemon outside the shared registration (a Homebrew service, one started
//! by hand) survives the boot-out and keeps the socket, while the app's own
//! daemon exits on the single-instance lock; the app then reports the other
//! daemon through [`crate::coexistence`] instead of using it.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Important: the app does keep using that daemon.

The status only picks a banner in app-shell.svelte. +layout.svelte renders the shell without waiting for the daemon, and the gRPC client dials the same socket, so loads and saves go to the other daemon while the banner shows. ADR-084 §4.3 asks only for the notice, so the behaviour meets the issue, but "instead of using it" claims more than the code does. Please correct the comment; the gating belongs with the startup hold.

// daemon just registered exits on the single-instance lock.
#[cfg(unix)]
if status == DaemonStatus::Healthy {
if let Some(executable) = other_daemon_on_socket(app, &socket_path).await {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Important: no test fails if this block is removed.

other_daemon_in is tested, but not that the start calls it and turns a healthy answer into NotRunning plus the executable. The same holds for the early return in daemon_status_body and the socket_reachable gate in lib.rs. evict_if_other_product takes its boot-out as a parameter; the same shape for the question to the daemon would let a test cover this. Can follow.

Comment thread scripts/build-pkg.sh
return true;
}
var info = system.files.plistAtPath(app + '/Contents/Info.plist');
if (info && String(info.NodeSpaceProduct) === 'community') {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Suggestion: String(info.NodeSpaceProduct) === 'community' is also true for an array holding community, where preinstall's plutil … raw prints a count and refuses. preinstall decides in the end, so this is cosmetic; a typeof check would keep the two in step.

# through system.log, which Installer writes to install.log, so fail
# the build if it ever reported a failure. A missing log matches
# nothing and passes.
if grep -a -q "NodeSpace installation check failed" /var/log/install.log 2>/dev/null; then

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Suggestion: this job already runs the real Installer twice on a macOS runner. A further step that sets the installed bundle's NodeSpaceProduct to another value, asserts a plain install fails and nothing changed, then asserts the override install succeeds, would make the refusal and the override a standing check instead of a one-off manual run.

Also, the NodeSpaceProduct check added to verify_layout above is already on main; keep main's lines when resolving the conflict.

/// app's daemon again, then emits and returns the resulting status, the same
/// strings `check_daemon_status` reports.
#[tauri::command]
pub async fn retry_daemon_start(app: AppHandle) -> String {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Suggestion: nothing serializes this. Two windows choosing Retry run two starts at once, each booting out and re-registering the job. Harmless today; a single in-flight start would make it tidy.

@malibio

malibio commented Oct 6, 2026

Copy link
Copy Markdown
Collaborator

@mstomar125 I'm taking this PR over to get it landed, so please don't push to issue-3415-install-coexistence until I say it's done; I'll post here when it is.

From the review above I'm doing: the merge with main (three conflicts), keeping the bundled-model copy ahead of the daemon start; the uninstall guard so it doesn't read the real /Applications in tests and is skipped for a redirected run; the "instead of using it" comment; and a test for the guard's call site. I'll run the NODESPACE_FORCE_COMMUNITY check on a Mac here and record the result.

Not changing here: the refusal wording for an app without the key (it's fixed by ADR-084 §5; I'll decide that separately) and the suggestions marked "can follow".

@malibio

malibio commented Oct 6, 2026

Copy link
Copy Markdown
Collaborator

Result of the real-Mac check, step A (macOS 26.6.2): the override does not reach preinstall.

A payload-free probe package whose preinstall and postinstall only dump their environment was installed with:

sudo NODESPACE_FORCE_COMMUNITY=1 installer -pkg /tmp/probe.pkg -target /

Both scripts ran as root with a fresh 27-variable environment built by the install service (PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/libexec, COMMAND_LINE_INSTALL=1, SCRIPT_NAME, PACKAGE_PATH, a sandbox TMPDIR). NODESPACE_FORCE_COMMUNITY was in neither.

So, as written, the override can pass the Distribution installation check (which reads the installer process's environment) but can never reach scripts/pkg-resources/preinstall, which then refuses. The user would see Installer's generic failure, with the reason only in /var/log/install.log.

The override mechanism therefore has to change or go before this merges. Decision pending with the ADR owner; step B (the real package over an app without the key) waits on it.

@malibio

malibio commented Oct 6, 2026

Copy link
Copy Markdown
Collaborator

Address-review (owner's pass), pushed as 476f2558c..7f7e6d414

Merged with main (three conflicts): the release workflow keeps main's NodeSpaceProduct check once plus this PR's install-log tripwire; uninstall.rs takes main's shape with the guard inside it; lib.rs starts with the starting emit, then provision_bundled_model, then start_daemon_and_report.

Addressed

  • 🔴 1. Uninstall guard and the real /Applications. run hands the installed-app location to an inner uninstall(state_dir, redirected, installed_app, …). A run redirected by NODESPACE_HOME is not checked, because it only removes binaries and sockets under its own home and leaves the service, the skills and the app alone. Unit tests use fixture bundles; a source-text test pins the hand-off from run. Mutation-checked.
  • 🔴 2. Model copy before the daemon start. Order kept; startup_copies_the_model_before_it_starts_the_daemon now finds start_daemon_and_report. Swapping the order fails it.
  • 🔴 3 / 🟡 4. The override. The probe on macOS 26.6.2 showed the variable never reaches preinstall (comment above). NODESPACE_FORCE_COMMUNITY is removed, with no replacement: the Distribution check, preinstall, the cask generator, tests and docs. ADR-084 §5 is amended (2026-10-06).
  • 🟡 5. Refusals name a remedy that works. The .pkg, cask and nodespace uninstall messages now say to move /Applications/NodeSpace.app to the Trash and run again; the skill reference tells an agent to ask the person to do that, not to remove the app itself.
  • 🟡 6. Comment. The module comment in daemon_setup.rs says only the reported status changes; the client still dials the same socket.
  • 🟡 7. Call sites. start_outcome (post-registration check) and coexistence::status_unless_other_daemon (the status early return) are extracted and tested, each mutation-checked.

Left

  • The socket_reachable gate in the startup task (finding 7): covering it means restructuring startup around an AppHandle.
  • The suggestions marked "can follow": a release-workflow step for the refusal, the non-string check in the Distribution script, serializing Retry across windows, the dangling-symlink nit.

To know

  • Two home_isolation tests run the compiled binary with no redirect, so they read the machine's real /Applications/NodeSpace.app. They now check that app themselves: beside an app that blocks they assert the refusal and an untouched home; otherwise they keep main's assertions. On a machine with an older NodeSpace installed, the end-to-end removal path is not exercised by them.
  • NODESPACE_HOME=$HOME nodespace uninstall is treated as redirected and so is not checked.
  • The cask's uninstall preflight prints the install wording ("To replace it … run the install again").
  • plist is now an unconditional dependency of nodespace-cli.

Tests: bun run quality:fix clean; bun run test:changed passed on the final tree, every tier (frontend, scripts, skill, browser, types and node-types checks, Rust workspace).

Re-Review Decision

Decision: RE-REVIEW NEEDED
Rationale: critical findings were addressed with significant changes (a merge with conflict resolution, a restructured uninstall path, a removed mechanism and reworded user-facing text).

@malibio

malibio commented Oct 6, 2026

Copy link
Copy Markdown
Collaborator

Pragmatic code review: re-review (on behalf of @malibio)

Review Type: Re-Review of 045ec5ead..7f7e6d414 (476f2558c, 4c8ce1cf6, 35341dd5c, 7f7e6d414), against main at ed42fe6b1 (the branch's merge-base is main's tip, so git diff origin/main...HEAD is exactly what lands).

Verdict: can merge as is. Nothing found that must change. Everything below the finding table is optional.

How I checked. Read-only: the full diff of the files the new commits touched, ADR-084 §5 as amended 2026-10-06 (docs origin/main), and a few greps. I built nothing and ran no tests. Claims are marked [read] or [inferred].

Previous review summary

  • Previous recommendations: 11 (3 critical, 4 important, 4 suggestions)
  • Addressed: 6 (findings 1 to 6)
  • Partly addressed: 1 (finding 7)
  • Not addressed, as agreed "can follow": 4 suggestions
  • New issues from these commits: 0 that must change; 5 optional notes

Finding by finding

# Previous finding Status Where
1 Uninstall guard reads the real /Applications in three integration tests Addressed, with a known residual (see note A) packages/cli/src/commands/uninstall.rs:28-81, tests :357-431; packages/cli/tests/it/home_isolation.rs:117-141, :205, :258
2 Model copy must stay before the daemon start; source-order test Addressed packages/desktop-app/app-lib/src/lib.rs:612-618; bundled_model.rs:581
3 Real-Mac run of the override outstanding Addressed (step A run and recorded; it showed the override cannot work) PR comment of 2026-10-06 09:59
4 Override never reaches preinstall Addressed by removal scripts/pkg-resources/preinstall:33-39, scripts/build-pkg.sh:221-239, scripts/update-homebrew-cask.ts:202-209
5 Refusals name a remedy that does not exist Addressed same three files, uninstall.rs:23-26, packages/skill/references/cli.md:976-988
6 "instead of using it" comment Addressed packages/desktop-app/app-lib/src/daemon_setup.rs:51-57
7 Call sites of the pure functions untested Partly daemon_setup.rs:947-964 and tests :4001-4036; coexistence.rs:55-62 and test :162-176. Still untested: the lines that call them (daemon_setup.rs:930, lib.rs:142) and the socket_reachable gate (lib.rs:711)

What I verified

Merge resolution [read]. lib.rs startup is: starting emit, provision_bundled_model, start_daemon_and_report; provision_bundled_model( appears once. Since the merge-base is main's tip, any line of main the resolution lost would show as a removal in the diff. The only removals in the three conflicted files are the match ensure_daemon_running block that start_daemon_and_report replaces (same three arms, same emits), and the body of run in uninstall.rs, which moved into uninstall. release.yml has only additions and holds main's NodeSpaceProduct check once (:607-608). Nothing dropped, nothing duplicated.

Uninstall, every combination [read].

redirected not redirected
any OS not checked; removes bin and the sockets under that home; service, skills and app untouched (as on main)
not macOS INSTALLED_APP is None: proceeds
macOS, no app try_exists is Ok(false): proceeds
macOS, community (XML or binary) proceeds
macOS, another value, empty, no key, non-string, unparseable plist, no Info.plist, try_exists error refuses

A refusal returns before remove_from_user_home, remove_bin_dir and remove_sock; the only thing that ran is resolving the state directory. The check fails closed. No compatibility fallback for a bundle without the key.

The source-text test for run (uninstall.rs:421) is reasonable. It slices run out of the file, so its own needle cannot satisfy it, and it fails if INSTALLED_APP stops reaching uninstall. It is tied to rustfmt keeping that call on one line; if that changes it fails loudly with the text of run, which is a false failure that explains itself, not a false pass.

plist as an unconditional dependency of the CLI is acceptable. It adds quick-xml and time to the CLI on Linux and Windows, where no app is ever checked; in exchange the check compiles and is unit-tested on every platform with no cfg around it. [inferred: a few hundred KB; not measured]

Override removal [read]. No trace in code, tests, the workflow or the skill reference: git grep FORCE_COMMUNITY is empty in this repo, and the docs repo mentions it only in the ADR's amendment note. preinstall quotes every expansion, plutil … || true cannot trip set -e, and the script's only expansions are $3, VOLUME, APP and product (pinned by a test). The Distribution check no longer reads system.env (pinned by a test). Each of the three script suites proves a refusal for another value, an empty value, a non-string, no key and no Info.plist; the .pkg suites also prove that environment variables change nothing.

Messages [read]. Character-for-character matches to ADR-084 §5 in preinstall:37, build-pkg.sh:233, the cask (update-homebrew-cask.ts:189-193, "run the install again"), uninstall.rs:23-26 and cli.md:982. The skill reference tells the agent to pass the remedy on and not remove the app itself.

Project rules [read]. No added line has compatibility code, a test-only switch in product code, a lint suppression, #[allow(…)], a wall-clock assertion, an issue number or "Pro".

Optional notes (none holds the merge)

A. On a gate machine with an older app, the end-to-end removal path is no longer exercised. 📁 packages/cli/tests/it/home_isolation.rs:205, :258
The branching tests are sound: both branches assert real invariants (the refusal text and a byte-for-byte unchanged home, or main's assertions), neither can pass vacuously, and a disagreement between the test's helper and the product fails loudly. But this machine's /Applications/NodeSpace.app has no NodeSpaceProduct key (plutil confirms) [read], so here uninstall_without_a_redirect_removes_the_install_in_the_users_home only ever checks the refusal. A regression in stop_daemon's plist removal or in the closure run passes would go unseen on this machine until that app is gone. I see no better shape that avoids a test-only switch in product code. The fix is operational: move the v0.3.1 app to the Trash on any machine that runs the merge gate, which is what the refusal says to do anyway.

B. The cask's uninstall-phase refusal uses the install wording. 📁 scripts/update-homebrew-cask.ts:248
A plain brew uninstall --cask nodespace beside such an app prints "To replace it … run the install again". The remedy still works (with the app gone the step is skipped and the uninstall completes), so it is odd, not wrong, and on brew upgrade or reinstall the wording fits. If you want one text that reads correctly in both stanzas, it needs a line in ADR-084 §5 first: "The NodeSpace app on this Mac is a different NodeSpace product, or an older NodeSpace that does not say which product it is. To replace or remove it, move /Applications/NodeSpace.app to the Trash, then run the brew command again. Your databases stay on this Mac." Not worth holding the merge.

C. The message names /Applications/NodeSpace.app when the cask checks #{appdir}. 📁 scripts/update-homebrew-cask.ts:191
With --appdir set, the refused app is elsewhere. The script already has the real path as $1, so the third part could be "$1 to the Trash, then run the install again." (the shell expands it inside msg="…"; the parts' "no $" rule would need that one exception). It also departs from the ADR's fixed text, and a non-default appdir is rare. Leave it.

D. NODESPACE_HOME=$HOME nodespace uninstall is unchecked and removes the real home's bin, sockets and lock files. 📁 packages/cli/src/commands/uninstall.rs:32
Beside another app whose daemon is running, that unlinks the socket the daemon serves on until it restarts. It takes a deliberate redirect to one's own home, and main already behaves this way for the service, so it is a narrow hole. If it should be closed later: treat the run as redirected only when the resolved state directory differs from the user's own (dirs::home_dir().join(".nodespace")).

E. Housekeeping.

  • The PR description still says the checks "honour NODESPACE_FORCE_COMMUNITY=1" and quotes the old message. Worth a gh pr edit before merging if the squash commit takes its body from it.
  • Step B of the manual check (the real .pkg over an app without the key: refusal text on the terminal, the dialog on double-click) was never run. The override was its main subject and is gone; the first v0.3.4 .pkg install on this Mac will be that run.
  • Nit: scripts/build-pkg.sh:200 has an unwrapped comment line.

Still open from the first review, as agreed

The release-workflow step for the refusal, the non-string check in the Distribution script, serializing Retry, the dangling-symlink nit, and tests for the three call sites in finding 7.

Recommendation

Merge as is. Must change: nothing. Optional: notes A to E above; A is the one I would act on soon, and it needs no code.

Not merging; that is the owner's call.

@malibio malibio left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Re-review of 045ec5ead..7f7e6d414: can merge as is. Findings 1 to 6 of the first review are addressed and finding 7 partly; nothing found that must change. The inline comments are optional. Full report: #3606 (comment)

.output()
.expect("run nodespace");

if installed_app_blocks_uninstall() {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Optional, no code needed. Both branches assert real invariants and neither can pass vacuously. But on a machine whose /Applications/NodeSpace.app has no NodeSpaceProduct key (this gate machine has one, v0.3.1), this test only ever checks the refusal, so the end-to-end removal below (stop_daemon's plist removal, the closure run passes) is not exercised there. I see no better shape without a test-only switch in product code. Moving the old app to the Trash on machines that run the merge gate restores the coverage.

# The same check before an uninstall, which is how a reinstall or upgrade
# sees the app: Homebrew moves the old app aside before the new version's
# preflight_steps run.
${otherProductCheckStanza("uninstall_preflight_steps")}

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Optional. A plain brew uninstall --cask nodespace beside such an app prints the install wording ("To replace it … run the install again"). The remedy still works, and on upgrade or reinstall the wording fits. One text that reads correctly in both stanzas would need a line in ADR-084 §5 first, for example: "… To replace or remove it, move /Applications/NodeSpace.app to the Trash, then run the brew command again. Your databases stay on this Mac." Not worth holding the merge.

const OTHER_PRODUCT_MESSAGE_PARTS = [
"The NodeSpace app on this Mac is a different NodeSpace product, or an older",
"NodeSpace that does not say which product it is. To replace it, move",
"/Applications/NodeSpace.app to the Trash, then run the install again.",

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Optional. The check runs against {{appdir}}/NodeSpace.app, but the message always names /Applications/NodeSpace.app, which is wrong under --appdir. The script has the real path as $1, so this part could read "$1 to the Trash, then run the install again.". That departs from the ADR's fixed text and a non-default appdir is rare; fine to leave.

// The service registration and the agent skills live in the user's own
// home, not the NodeSpace home, and belong to the install there. A
// redirected run removes only what is under its own home.
let redirected = nodespace_daemon::nodespace_home_override().is_some();

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Optional, can follow. NODESPACE_HOME=$HOME nodespace uninstall counts as redirected, so it is not checked and removes the real home's bin, sockets and lock files beside any app. It takes a deliberate redirect to one's own home, so the hole is narrow. To close it later: treat the run as redirected only when the resolved state directory differs from the user's own.

Comment thread scripts/build-pkg.sh
# install, so keep the two in step: the installed bundle proceeds only when
# its Info.plist declares NodeSpaceProduct = community. Nothing overrides
# that; the refusal says to move the installed app to the Trash. Both read
# static data and run nothing the previous install left on disk. rootVolumeOnly pins the target to the

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: this comment line lost its wrap when the override sentence was replaced.

@malibio

malibio commented Oct 6, 2026

Copy link
Copy Markdown
Collaborator

Address-review, round 2 (after the re-review's APPROVE)

  • ✅ E. PR description updated: no override, the amended refusal wording, and the probe result.
  • ⏭️ A. No code change: the gate machine's old NodeSpace app without the key makes two home_isolation tests exercise the refusal branch only. Removing that app from the machine restores the other branch.
  • ⏭️ B, C. The cask's uninstall-time wording and the path named under --appdir stay as the ADR's fixed text; both are rare and the remedy still works. Revisit if the cask message is next edited.
  • ⏭️ D. NODESPACE_HOME=$HOME being unchecked takes a deliberate redirect to one's own home; left as is.
  • ⏭️ Step B of the manual check is not run separately: the first .pkg install of the next release over an older app is that run.

Re-Review Decision

Decision: NO RE-REVIEW NEEDED
Rationale: only the PR description changed since the approved head 7f7e6d414.

@malibio
malibio force-pushed the issue-3415-install-coexistence branch from 7f7e6d4 to fa869d5 Compare October 6, 2026 10:22
@malibio
malibio merged commit 66ec33b into main Oct 6, 2026
@malibio
malibio deleted the issue-3415-install-coexistence branch October 6, 2026 10:22
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.

Pro rebuild (after core release): core install coexistence checks and other-product notices (ADR-084 §4.3, §5)

2 participants