Repository navigation
Refuse to install the cask over another NodeSpace product; keep databases out of zap - #3380
mstomar125 wants to merge 2 commits into
Conversation
…ases out of zap The generated cask gains two install-steps stanzas that run one check when an app is already at the appdir: read NodeSpaceProduct from its Info.plist (or, when the key is absent, look for the other product's daemon beside the CLI) and exit non-zero with the .pkg's refusal message unless the product is community. The check is a static read; nothing inside the bundle is executed. The check appears twice. preflight_steps covers `brew install`; on `brew reinstall` and `brew upgrade` Homebrew removes the old app before the new version's preflight_steps run, so the check is repeated in uninstall_preflight_steps, which the installed version runs first. `~/.nodespace/database` leaves the zap trash list, as `~/.nodespace/models` already had: a zap no longer deletes databases another NodeSpace product may be using. Homebrew 7 rejects the previous render under `brew style`: depends_on arch now precedes depends_on macos, and the zap entries are sorted. Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
Pragmatic Code Review: PR #3380 (closes #3350)Review Type: Initial Review (medium depth) Verdict: COMMENT. No code blocker. The ordering claims check out against the Homebrew 7.0.4 source, and the shell check behaves correctly on every fixture I ran. Two statements in the PR description are inaccurate or incomplete (minimum Homebrew version, and the zap change not reaching existing installs), and one test gap should be closed before undrafting. The draft/HOLD for the ADR-084 owner is the right call and stays. What I verified myself: Requirements Check (issue #3350 acceptance criteria)
Scope items (footer comment above Verified claims (the ones the author's track record says to distrust)
Code Review Findings[Improvement] 1. PR description understates the minimum Homebrew version (5.1.14 claimed; it is 6.0.13). [Improvement] 2. The zap change does not reach existing installs; the PR's residual-gap section covers only the preflight. [Improvement] 3. Residual gap: say what a "refused" Pro user actually experiences. [Improvement] 4. Tests: script quoting is protected only by the byte-for-byte snapshot; no behavioral case has a space in the app path. [Nit] 5. Skipped [Nit] 6. Undocumented constraint: Homebrew expands [Nit] 7. Optional stronger test for the Ruby layer. [Nit] 8. Refusal wording on Low-confidence, not verified by running: a possible fail-open in Homebrew's sandbox. Steps run inside Answers to the specific review questions
Recommendation: COMMENTKeep the PR as a draft pending the ADR-084 owner's decision on the residual gap. Before undrafting: correct the Homebrew minimum (Finding 1), add the existing-install zap lag and the repeated-failure behavior to the residual-gap section (Findings 2 and 3), and add a space-in-path behavioral test (Finding 4). Findings 5-8 are optional polish. Automated review by the Principal Engineer Reviewer sub-agent. |
mstomar125
left a comment
There was a problem hiding this comment.
Automated pragmatic-code-review: COMMENT (posted as a comment, GitHub blocks self-approval). Full findings in the review comment above.
The behavioral fixtures now live under a directory with a space in its name,
so an unquoted expansion in the check script lets a refusal pass and a test
fails; before, only the byte-for-byte snapshot noticed. The fixture directory
is created in beforeAll rather than at collection time, so a skipped describe
off macOS no longer leaves one behind.
The script-safety test also rejects `{{`, which Homebrew expands in every run
argument, and the generator comment names that restriction.
Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
Address-review summary (responds to the review above)Pushed Addressed (5 of 8)
Skipped (2 of 8)
Re-Review DecisionDecision: NO RE-REVIEW NEEDED Rationale: This round changed no product behavior: the generated cask is identical, and the code changes are test-hardening the reviewer prescribed (each mutation-checked), a moved |
|
Held as draft (coordinator): not needed for the core-only release — it guards Pro installs (no Pro users yet), needs an ADR-084 owner decision on the Homebrew ordering limitation, and raises the minimum Homebrew to 6.0.13 for every free user. Revisit after ADR-084 is accepted. |
|
Superseded by #3606, which carries all of the coexistence work for the issue in one PR, reworked to the accepted ADR-084: every check compares 🤖 Generated with Claude Code |
Closes #3350
Core's side of ADR-084 §5 (proposed) for the Homebrew cask. It changes what
scripts/update-homebrew-cask.tsgenerates. Nothing is pushed to the tap: the live cask changes at the next release, whenrelease.yml'ssync-homebrew-caskjob runs this script with--push.HOLD: needs the ADR-084 owner before merging
The issue says to stop and raise it if the preflight cannot see a Pro app that replaced a cask-installed core. Testing found it cannot, in a way that goes past the upgrade case the issue anticipated. The cask now protects every reinstall and upgrade from a cask installed with this change or later. It cannot protect the first reinstall or upgrade off a cask installed before it (details under "Residual gap"). That needs a decision, so this PR is a draft.
What it generates
Two install-steps stanzas after
binaryand beforezap,preflight_stepsanduninstall_preflight_steps, running the same check when an app is already at#{appdir}/NodeSpace.app:NodeSpaceProductfrom the bundle'sInfo.plistwith/usr/bin/plutil;prowhenContents/MacOS/nodespaced-proexists, otherwisecommunity;community, exit non-zero with the.pkg's 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."It is a static read; nothing inside the bundle is run.
appdiris used, so--appdiris respected.~/.nodespace/databaseleaveszap trash, as~/.nodespace/modelsalready had, with the comment abovezaprewritten to say why.Deviations from the issue, with evidence (Homebrew 7.0.4)
preflight_steps, notpreflight do ... end. The legacy block is deprecated in Homebrew 7: every install printsWarning: Calling preflight is deprecated! Use preflight_steps instead., andbrew stylereportsCask/InstallSteps: Casks must use preflight_steps instead of preflight. The acceptance criterion needsbrew styleto pass, which the legacy block cannot do. Cask install steps arrived in Homebrew 5.1.14, but this stanza also needsif_path_existsand{{appdir}}(6.0.12) and therunstep'sprint_stderr(6.0.13, 2026-07-26). The cask therefore needs Homebrew 6.0.13 or newer; on an older one it fails to load, sobrew installandbrew upgradeofnodespaceerror for every free user, not only Pro users.brew updatealso updates Homebrew itself, so the exposure is a pinned or rarely-updated brew; the rollout note should say so.uninstall_preflight_steps, with the same check. With only a preflight (legacy or steps),brew reinstallandbrew upgradeboth bypassed the guard and destroyed the Pro app. Homebrew backs the old app up, removes it, installs the new one, then purges the backup, all before the new version's preflight runs. The installed version's uninstall-phase block runs first, so the check is repeated there. Step 3.4 of the issue ("brew reinstall --caskmust refuse") is only achievable this way.brew uninstall --caskalso refuses while a non-community app is in place (even with--force), rather than deleting the other product's app. The message tells the user to uninstall Pro first.runstep whose script exits 1. Homebrew's error prints the full escaped command line, then the message. The message cannot be passed throughenv:(Homebrew shell-escapes it into the output). The legacyraise CaskErrorprinted the message cleanly; that is the price of (1).brew stylefailures fixed. The render onorigin/mainalready failsbrew styleunder Homebrew 7.0.4 with 3 offenses:depends_on archmust precededepends_on macos, and thezapentries must be alphabetical. Both are fixed so the criterion holds.must_succeed: falseis deliberately not used, and a test guards it:rundefaults tomust_succeed: true, which is what makes the refusal fail the install.Local-tap results
Scratch tap (
brew tap-new), a cask rendered from this generator (only token, version, url, sha256 and thebinarystanza changed), a tiny fake.dmgper version, and--appdir/--no-binariespointed at a scratch directory. The real/Applications/NodeSpace.app,/opt/homebrew/bin/nodespaceand the installednodespacecask were never touched. A fake dmg was used instead of the real release because the check reads only the app already in the appdir. Fixtures replace the installed app the way another product's installer would.brew installover an existing appbrew install --forcebrew reinstall(installed from this version)brew upgrade0.2.0 to 0.2.1 (installed from this version)brew uninstallEvery refusal printed the message and left the other product's app byte-for-byte in place. *Homebrew's own "It seems there is already an App" applies without
--force; the refusal fires first forpro, even with--force.The same matrix with the legacy
preflight doblock:brew installrefuses, butbrew reinstallandbrew upgradeproceed and replace the Pro app in every fixture.brew style --caskon the render: no offenses.brew audit --caskandbrew audit --cask --strict: exit 0.Residual gap (needs the ADR-084 owner)
Homebrew runs the installed version's stored definition (the copy in the Caskroom metadata) for the uninstall phase. A cask installed before this change has no guard in that copy, so the first
brew reinstallorbrew upgradeoff it still replaces a Pro app (backed up, then purged). Tested: it proceeds and the Pro app is gone. Nothing in the cask can close this. Options: accept it (no Pro users, and protection starts from the next version); or have the Pro installer take over the cask's record so a laterbrew upgradeno longer targets the same app. That choice belongs to the ADR-084 owner. Also for the owner:brew uninstall --zapandbrew reinstall --zaprun the installed definition'szap, and every existing install still lists~/.nodespace/database. Until a user's cask is reinstalled onto this definition, a zap still trashes their database, including one shared with another product. The "a zap never deletes databases" goal holds from the next version onward only.brew upgradedownloads the whole dmg (the fetch precedes the old app being touched), then fails with the script-dump error, and the overallbrew upgradeexits non-zero.brew uninstall,--zapand--forceare refused too, so the only ways out are uninstalling Pro or deleting the Caskroom entry by hand..pkgkeepsNODESPACE_FORCE_COMMUNITY=1for scripted installs; the cask has none, because the issue specifies none and Homebrew passes no environment to install steps. Say if one is wanted.HOMEBREW_CACHEis outside$HOME, Homebrew's step sandbox denies reading all of$HOME, so with--appdir=~/Applicationstheif_path_existsguard would see no app and skip the check; and an appdir containing[ ? * {is treated as a glob.Ratchet (
check-pro-boundary.tsis not onmain; #3376 is open)Nothing to lower: this change adds markers rather than removing them. Measured with #3376's script on this tree against
origin/main:editionBranching122 to 127 (+5) andproWording312 to 321 (+9), all in the two files below; every other marker is unchanged. With the two per-file exemptions the issue calls for, both return to their baselines andBASELINESneed no edit:Conflict to resolve in #3376: its
exemptionProblemsrejects an exemption on a non-test file ("only test files (TEST_PATH) may be exempted. Use fragments in anything else."), andupdate-homebrew-cask.tsis not a test file. The same applies to the.pkgissue'spreinstallandbuild-pkg.sh. Either #3376 must allow the ADR-084 recognition-point files, or these sources must build their markers from fragments. Whichever lands second needs the entries above (or a baseline refresh of +5/+9).Tests
bun test scripts/update-homebrew-cask.test.ts: 26 pass. The byte-for-byte expectation is updated and the zap test is rewritten as "zap trash removes both launchd agents but neither the database nor the models". New tests parse the rendered cask, run the real script from it against real fixture bundles through/bin/shandplutil(darwin only; includes a binary plist, a bundle with executables that record if they run, and no app), and runruby -con the whole cask. The fixtures live under a directory with a space in its name, so an unquoted expansion in the script is caught by a behavioral case, not only by the snapshot.Mutation checks (each applied to the generator, tests run, generator restored). All 23 killed:
proinstead ofcommunity; drop the sidecar fallback; change the message;must_succeed: false; stanzas afterzap; database or models back inzap; plutil stderr not silenced; run the bundle's CLI; a#in the script; read the plist withgrepinstead ofplutil; drop the appdir guard; hard-code/Applications; invalid Ruby; the two stanzas run different scripts;{{token}}in the script.Also run:
bun run test:changed(scripts tier),bun run quality:scripts:fix,bun run scripts/check-code-references.ts(71 / 0, unchanged).Risks and rollback
A broken stanza would break every
brew installof the cask, sobrew style,brew auditand the local-tap runs above must stay green. Rollback: revert, thenbun run scripts/update-homebrew-cask.ts <version> --pushto put the tap back on the previous render.🤖 Generated with Claude Code