Skip to content

Move the .pkg guard to a static pre-install check and declare NodeSpaceProduct #3349

Closed as not planned

Description

@mstomar125

Summary

Carry out core's side of ADR-084 §5 (proposed, decision 5(a)) for the .pkg:

  1. Declare the product. Core's app bundle declares NodeSpaceProduct = community in its Info.plist.

  2. Move the guard before the payload. Today's guard against installing over another NodeSpace product lives in postinstall, which runs after the payload is written, runs the installed nodespaced as root, and never fires. It moves to the pre-install stage, in two places:

    • a new scripts/pkg-resources/preinstall;
    • the Distribution installation check that scripts/build-pkg.sh writes.

    Both read only static data: the installed app's NodeSpaceProduct, or, when that key is absent, whether Contents/MacOS/nodespaced-pro exists. NODESPACE_FORCE_COMMUNITY=1 stays as the override for scripted installs.

  3. Remove the old guard from postinstall.

Context

  • Today's guard. In scripts/pkg-resources/postinstall: the header bullet at 10-14, NODESPACED at 20, and the block at 22-59. It never sees pro, because the Pro installer puts nodespaced-pro beside nodespaced instead of replacing it.

  • ADR-084 §5 sets the rules. The guard runs before anything is written, never runs an installed binary, reads static data, and refuses with a message that names Pro's uninstall. The message:

    NodeSpace Pro is installed. To switch back to the free NodeSpace, uninstall Pro first (NodeSpace → Uninstall NodeSpace Pro…). Your databases stay on this Mac.

  • Recognition points. ADR-084 §5 lets exactly three core files name the other product's daemon, and only in the transitional fallback:

    ADR-081 §2d and §8 are widened to allowlist exactly these three.

  • How the script gets into the package. pkgbuild --scripts "${PKG_RESOURCES}" (build-pkg.sh 177-184) packages every file in scripts/pkg-resources. An executable file named preinstall there becomes the package's preinstall script. macOS Installer passes it four arguments: $1 is the package path, $2 the target location, $3 the target volume and $4 the startup disk. Locating the app through $3 also gives the tests their seam.

  • Where the key comes from. Tauri merges the plist named by bundle.macOS.infoPlist into the bundle's Info.plist (tauri-utils 2.9.2 MacConfig::info_plist; the CLI is 2.11.4). It also auto-merges any file named exactly Info.plist next to tauri.conf.json.

    • Use the explicit config key, pointing at a file with a different name.
    • Today's Pro build runs core's tauri build --config tauri.pro.conf.json. A JSON merge patch there can replace the infoPlist path with a Pro-owned plist. It cannot un-merge an auto-discovered Info.plist.
  • Why the pin gate. The key sits in the bundle that the Pro GUI build inherits from core's config. Until the Pro GUI builds from a pin, and overrides the key to pro when it bumps past this commit, a Pro build from core HEAD would declare community. ADR-084's guards would then treat that Pro app as core.

Scope

  1. The key.

    • Add packages/desktop-app/src-tauri/Info.product.plist: an XML plist with one dict entry, NodeSpaceProduct = community. The name is illustrative, but it must not be Info.plist.
    • In tauri.conf.json, add "infoPlist": "Info.product.plist" under bundle.macOS (31-33).
  2. New scripts/pkg-resources/preinstall. It is a bash script (#!/bin/bash, set -euo pipefail), committed as mode 755.

    • Set APP to "${3:-/}" with any trailing / stripped, followed by /Applications/NodeSpace.app. If APP doesn't exist, exit 0.
    • Read the key: product=$(/usr/bin/plutil -extract NodeSpaceProduct raw -o - "$APP/Contents/Info.plist" 2>/dev/null || true).
    • If product is empty, it is pro when $APP/Contents/MacOS/nodespaced-pro exists, and community otherwise. Comment that this fallback covers bundles built before the key existed, and is removed once no such Pro build is supported (ADR-084 §5).
    • If product isn't community and NODESPACE_FORCE_COMMUNITY isn't 1, print the ADR message to stderr and exit 1.
    • Never run anything under $APP or /usr/local/bin. Call system tools by absolute path.
    • The header comment says what the script checks, when it runs, why it reads only static data, and how the override works. No issue numbers and no docs paths.
  3. The Distribution check. In build-pkg.sh's DIST_XML (192-213), add <installation-check script="nodespaceInstallationCheck()"/> and a <script> that makes the same decision in Installer JS:

    • Read the app with system.files.fileExistsAtPath and system.files.plistAtPath('/Applications/NodeSpace.app/Contents/Info.plist').
    • Read the override from system.env.
    • To refuse, set my.result.type = 'Fatal' plus a title and the message, then return false.

    The heredoc is unquoted, so don't use $ in the JS. First confirm that system.env exists in Installer JS on the macOS version CI builds on. If it doesn't, the check can't honour the override: leave it out, keep only preinstall, and say so in the PR.

  4. postinstall.

    • Delete the header bullet (11-12) and renumber the rest.
    • Delete NODESPACED (20), which becomes unused, and the guard block (22-59).
    • Keep everything else byte-identical, including the launchd-bootstrap sentinel block.
  5. The release check. In release.yml's verify_layout (532-563), check that plutil -extract NodeSpaceProduct raw /Applications/NodeSpace.app/Contents/Info.plist prints community.

  6. Ratchet exemptions. In scripts/check-pro-boundary.ts, exempt scripts/pkg-resources/preinstall and scripts/build-pkg.sh from the editionBranching and proWording markers, per file. Comment the entries: "ADR-084 §5 recognition points: the transitional fallback names the other product's daemon, and the refusal names the product". Then paste BASELINES.

Out of scope

Steps

  1. Run the startup sequence, and assign the issue at pickup. Confirm the pin gate is met.
  2. Add the key, then check it on a locally built bundle:
    • build with bun run tauri build -- --debug --bundles app, or the release app build;
    • run plutil -extract NodeSpaceProduct raw <app>/Contents/Info.plist.
  3. Write preinstall and its tests.
  4. Add the Distribution check.
  5. Edit postinstall.
  6. Add the CI check.
  7. Add the ratchet exemptions and paste the baselines.
  8. Run bun run test:changed, bun run test:scripts, bun run quality:scripts:check and bun run quality:fix. Push and open the PR.

Acceptance criteria

  • The built app's Info.plist has NodeSpaceProduct = community.
  • preinstall is executable (git mode 100755), refuses as the matrix below says, and never runs a binary.
  • The Distribution check refuses in the Installer GUI with the ADR message, or the PR documents why it was left out.
  • postinstall has no guard: git grep -n -F -e --edition -e FORCE_COMMUNITY -- scripts/pkg-resources/postinstall prints nothing.
  • Under scripts/, nodespaced-pro and NODESPACE_FORCE_COMMUNITY appear only in preinstall and build-pkg.sh. Add a Homebrew cask preflight for other NodeSpace products; keep databases out of zap #3350 later adds the cask generator.
  • release.yml checks the key, and its two back-to-back installs still pass. Installing core over core is unchanged.
  • bash -n passes on both scripts. bun run test:scripts and bun run quality:scripts:check pass.
  • bun run scripts/check-pro-boundary.ts passes, with BASELINES lowered. editionBranching and proWording fall by the old guard's lines: 3 and 7 at af8ddb6.

Tests and verification

  • New scripts/pkg-preinstall.test.ts (bun:test, DOM-free). It skips unless process.platform === "darwin", because the script calls /usr/bin/plutil.

    • It writes fixture bundles under <tmp>/Applications/NodeSpace.app and runs bash scripts/pkg-resources/preinstall pkg / <tmp> / with a scrubbed environment.
    • Build the Pro sidecar name and the override variable from fragments, for example ["nodespaced", "pro"].join("-").
    Fixture Expected exit
    no app 0
    key community 0
    key pro 1, and stderr mentions the uninstall
    key other 1
    no key, no Pro sidecar 0
    no key, Pro sidecar present 1
    key pro, override set to 1 0
    • Also put an executable Contents/MacOS/nodespaced in the fixture that writes a sentinel file, and assert the sentinel is never created.
  • Static test: postinstall never runs the installed daemon and never contains the edition flag (built from fragments). Mutation check: re-add the old probe line, and the test must fail.

  • Static test: tauri.conf.json's bundle.macOS.infoPlist names a file that exists and declares NodeSpaceProduct = community.

  • Existing test: scripts/postinstall-bootstrap.test.ts still passes.

  • Manual, optional. On a spare macOS user or a VM:

    1. Build the package with SKIP_NOTARIZATION=1.
    2. Run pkgutil --expand and confirm it shows Scripts/preinstall.
    3. Install over a fake bundle that declares pro: the install is refused.
    4. Run sudo NODESPACE_FORCE_COMMUNITY=1 installer -pkg ... -target /: the install proceeds.

    If the variable doesn't reach the script, record that in the PR and tell the ADR-084 owner.

Dependencies

Risks and rollback

  • A mislabelled Pro build. Merging before the pin gate would let a Pro build from core HEAD declare community.
  • The override might not reach the script. Whether the environment reaches installer scripts under sudo installer isn't guaranteed. The manual check covers this.
  • A terse error on the command line. A failing preinstall shows only a generic "installation failed" in installer. The Distribution check gives the real message in the GUI.
  • Rollback: revert the PR. That restores the old guard, which never fired, and removes the key.

Plan key: C8.3b (pro-boundary DAG).

🤖 Generated with Claude Code

Activity

  1. self-assigned this
    on Sep 30, 2026
  2. added
    pro-boundary
    on Sep 30, 2026
  3. added 2 commits that reference this issue on Sep 30, 2026
    d8bf61f
    d1dab7b
  4. mstomar125 commented on Oct 1, 2026

    @mstomar125
    ContributorAuthor

    Superseded by #3415 (umbrella against the final ADR-081–085)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

pro-boundary

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions