Skip to content

Add a Homebrew cask preflight for other NodeSpace products; keep databases out of zap #3350

Closed as not planned

Description

@mstomar125

Summary

Core's side of ADR-084 §5 (proposed) for the Homebrew cask. scripts/update-homebrew-cask.ts generates Casks/nodespace.rb. This issue changes two things in what it generates.

  1. A preflight block. It aborts brew install, brew upgrade and brew reinstall --cask nodespace when #{appdir}/NodeSpace.app declares a product other than community, with the same message as the .pkg.
    • If the NodeSpaceProduct key is absent, the app counts as pro when Contents/MacOS/nodespaced-pro exists.
  2. The zap trash list. ~/.nodespace/database leaves the list, as ~/.nodespace/models already has. A zap then never deletes databases that another NodeSpace product may be using.

Context

  • The generator. In scripts/update-homebrew-cask.ts:
    • CASK_FOOTER (181-197) renders app, binary and zap trash (185-195).
    • renderCask (211-229) assembles the cask.
  • Its tests. scripts/update-homebrew-cask.test.ts has:
    • a byte-for-byte test (line 72);
    • a zap test (line 140), which today asserts that the database is zapped.
  • When the change reaches users. The tap's live cask changes at the next release, when release.yml's sync-homebrew-cask job runs this script with --push. This PR pushes nothing.
  • Homebrew DSL notes:
    • preflight do ... end runs Ruby before the artifacts are installed.
    • Raise CaskError to abort.
    • Read the key with system_command "/usr/bin/plutil", args: ["-extract", "NodeSpaceProduct", "raw", "-o", "-", plist], print_stderr: false. Treat a failure or empty stdout as "key absent".
    • Use appdir, so --appdir is respected.
    • brew style checks stanza order: put preflight after binary and before zap.
  • Verify the upgrade ordering. During brew upgrade --cask, Homebrew may move the old version's app artifact aside before the new version's preflight runs. If so, the preflight cannot see a Pro app that replaced a cask-installed core.
    • Test this with a local tap (see Steps).
    • If the preflight does not see the app, stop and raise it with the ADR-084 owner before merging.
  • Ratchet exemptions. This generator is ADR-084's third recognition point. Its test's byte-for-byte fixture renders the same Pro-named text, so both files need exemptions.

Scope

  • CASK_FOOTER:
    • Add the preflight block after binary.
    • Remove "~/.nodespace/database" from zap trash.
    • Update the comment above zap: neither models nor databases are zapped, and why.
  • Tests:
    • Update the byte-for-byte expectation.
    • Rename and rewrite the zap test: "zap trash removes both launchd agents but neither the database nor the models".
    • Add a test that the rendered cask has a preflight that:
      • reads NodeSpaceProduct;
      • compares it with community;
      • has the nodespaced-pro fallback;
      • raises the ADR message.
  • scripts/check-pro-boundary.ts:
    • Add per-file exemptions on editionBranching and proWording for scripts/update-homebrew-cask.ts and scripts/update-homebrew-cask.test.ts, with the ADR-084 §5 recognition-point comment.
    • Paste BASELINES.

Out of scope

Steps

  1. Run the startup sequence, and assign the issue at pickup.
  2. Edit the generator and its tests.
  3. Check the rendered cask:
    • Render a cask locally with a fake digest. The test helpers already do this.
    • Run brew style --cask on the rendered file.
    • If you can, also run brew audit --cask on a local tap.
  4. Test with a local tap:
    1. Create a tap with brew tap-new, holding a cask whose url points at a local .dmg of the current release.
    2. Install it.
    3. Replace /Applications/NodeSpace.app with a fake bundle that declares NodeSpaceProduct = pro.
    4. Run brew reinstall --cask. It must refuse.
    5. Run brew upgrade --cask to a bumped version. It must refuse.
    6. Record the results in the PR.
  5. Add the exemptions and paste the baselines.
  6. Run bun run test:scripts and bun run quality:scripts:check, push, and open the PR.

Acceptance criteria

  • The rendered cask has the preflight, has no ~/.nodespace/database in zap, and passes brew style.
  • With the local tap, the cask refuses to install over:
    • a bundle that declares pro;
    • a bundle with no key and the Pro sidecar.
  • With the local tap, the cask proceeds over:
    • a bundle that declares community;
    • a bundle with no key and no Pro sidecar.
  • One of these holds:
    • brew upgrade is refused in the Pro-replaced case;
    • the PR documents that Homebrew's ordering prevents the refusal, and the ADR-084 owner has decided what to do.
  • bun run test:scripts and bun run quality:scripts:check pass.
  • bun run scripts/check-pro-boundary.ts passes, with BASELINES pasted and the two exemptions in place.

Tests and verification

  • Commands:
    • bun test scripts/update-homebrew-cask.test.ts
    • bun run test:scripts
    • brew style --cask <rendered file>
  • Manual: the local-tap steps above.

Dependencies

Risks and rollback

  • A Ruby error in preflight breaks every brew install of the cask. brew style and the local-tap install must pass before merge.
  • Rollback: revert the PR, then re-run bun run scripts/update-homebrew-cask.ts <version> --push so the tap goes back to the previous render.

Plan key: C8.7 (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. 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