Skip to content

Wire the nodespace-cli Homebrew formula into release-sync and drift-check - #2175

Merged
mstomar125 merged 2 commits into
mainfrom
issue-2162-formula-sync
Aug 20, 2026
Merged

mstomar125 merged 2 commits into
mainfrom
issue-2162-formula-sync

Conversation

@mstomar125

Copy link
Copy Markdown
Contributor

Closes #2162.

Problem

Formula/nodespace-cli.rb (added in #2146) hardcoded its own version and 6 asset URLs/sha256 digests, entirely independent of the automation #2114 built for the sibling nodespace cask. scripts/update-homebrew-cask.ts only knew about Casks/nodespace.rb, and homebrew-drift-check.yml only compared the cask's version — it would report "Tap in sync" while the formula silently drifted indefinitely behind it. Same failure mode #2114 fixed for the cask, reintroduced for the formula in the very PR that added it.

What changed

  • scripts/update-homebrew-formula.ts (new): resolves all 6 digests (nodespace + nodespaced, for each of the 3 required build-headless targets — macOS arm64, Linux arm64, Linux x86_64, sharing REQUIRED_HEADLESS_TARGETS with publish-install-script.ts so there's one source of truth instead of a second copy) from the actual published release assets, fully re-renders Formula/nodespace-cli.rb, and pushes it to the tap. Every target is required — a missing asset is a loud hard error (matching Make the Homebrew cask generator arm64-only to match the Intel-macOS drop #2171's "missing arm64 is a hard error, not a warning" precedent for the cask), since this formula has no optional architecture to gracefully omit. Supports <version> (dry run), <version> --push, and drift-check, mirroring update-homebrew-cask.ts's CLI shape.
  • scripts/homebrew-tap-push.ts (new): the shared "clone the tap, write the file, commit, push" mechanics, extracted out of update-homebrew-cask.ts so the credential-scrubbing safety net on a failed clone can't drift out of sync between the cask and formula sync scripts. update-homebrew-cask.ts now uses it too — behavior unchanged, ~35 lines de-duplicated.
  • scripts/publish-install-script.ts: exports REQUIRED_HEADLESS_TARGETS (was a private const) so update-homebrew-formula.ts can share it instead of maintaining an independent copy of "which build-headless targets are required."
  • .github/workflows/release.yml: adds a sync-homebrew-formula job, gated on build-headless the same way sync-install-script already is (that job's own required-target set is only 3 of build-headless's 4 matrix legs, and needs only exposes the aggregate result, not individual legs — so it runs whenever build-headless finishes (not cancelled) and lets resolveFormulaDigests()'s own asset check be the real gate). Added to notify-failure's needs list.
  • .github/workflows/homebrew-drift-check.yml: adds an independent formula-drift-check job so formula staleness is caught by the same daily watchdog, with its own distinctly-titled issue (... (nodespace-cli formula) vs ... (cask)) so an operator doesn't have to open the raw run log to know which artifact drifted.
  • package.json: adds homebrew:sync-formula and homebrew:formula-drift-check scripts, mirroring the existing cask ones.

The on_intel do odie(...) end question (issue point 3)

Deliberately left hardcoded, not made conditional on asset presence. Reasoning: unlike the cask's now-removed Intel .dmg leg (which build-tauri used to produce until #2169), release.yml's build-headless matrix has never had a macOS x86_64 leg at all — there is no CI job this script could ever observe flip from absent to present. Making this conditional now would be speculative generality for a scenario with no live path to occur under the current pipeline, and it lines up with #2171's own "Apple Silicon is the only supported target, reversible but requires restoring code" decision for the cask. If a macOS x86_64 build ever gets added to build-headless, that's the point to revisit this.

Verification

  • renderFormula() verified byte-for-byte against a live fetch of NodeSpaceAI/homebrew-nodespace's Formula/nodespace-cli.rb (own test + confirmed independently against the real published file, not just the fixture).
  • Ran the real sync script end-to-end against the real v0.2.0 release (bun run scripts/update-homebrew-formula.ts 0.2.0, bun run scripts/update-homebrew-formula.ts drift-check) — dry-run output matches the live formula; drift-check correctly reports "Tap formula in sync: v0.2.0".
  • bun run test:scripts: 115 pass, 0 fail (was 110 before this PR).
  • bun run quality:fix clean.
  • bun run test:all clean (222 frontend test files, 115 script tests, 2 skill test files, full Rust workspace).
  • Full pre-push gate (scripts/test-gate.ts) passed, including cargo test -p nodespace-app (ADR-048 Tauri-seam suite).
  • Adversarial review (general-purpose subagent) ran against the real diff.

Test plan

  • update-homebrew-formula.ts resolves all 6 digests from real release assets and fails loudly if any is missing
  • renderFormula() output verified byte-identical to the published Formula/nodespace-cli.rb for v0.2.0
  • drift-check command correctly reports sync/drift for the formula
  • homebrew-tap-push.ts extraction is behavior-preserving for the cask (existing cask tests still pass unchanged)
  • release.yml's sync-homebrew-formula job gated the same way sync-install-script is, wired into notify-failure
  • homebrew-drift-check.yml checks both cask and formula independently, with distinctly-titled failure issues
  • bun run test:scripts / test:all / quality:fix all clean
  • Adversarial review ran against the real diff — findings addressed

🤖 Generated with Claude Code

mstomar125 and others added 2 commits August 20, 2026 08:53
…heck

Formula/nodespace-cli.rb (added in #2146) hardcoded its own version and
6 asset digests, completely independent of the automation that keeps the
sibling nodespace cask in sync -- the same "hand-maintained artifact
silently drifts" failure mode #2114 fixed for the cask, reintroduced for
the formula in the very PR that added it.

- Add scripts/update-homebrew-formula.ts: resolves all 6 digests (cli +
  daemon, for each of the 3 required build-headless targets) from real
  release assets, fully re-renders Formula/nodespace-cli.rb (verified
  byte-for-byte against the live published file), and pushes to the tap.
  Every required target is hard-required -- a missing asset is a loud
  error, matching #2171's "missing arm64 is a hard error" precedent for
  the cask, since the formula has no optional architecture to omit.
- Add scripts/homebrew-tap-push.ts: the shared "clone tap, write file,
  commit, push" mechanics, extracted out of update-homebrew-cask.ts so
  the credential-scrubbing safety net can't drift out of sync between
  the cask and formula sync scripts.
- Export REQUIRED_HEADLESS_TARGETS from publish-install-script.ts so the
  formula's required-target set shares one source of truth with
  install.sh's own pin instead of maintaining a second copy.
- Add the sync-homebrew-formula job to release.yml, gated on
  build-headless the same way sync-install-script already is.
- Extend homebrew-drift-check.yml with an independent formula-drift-check
  job so formula staleness is caught the same day, with its own
  distinctly-titled issue.

The on_intel odie block for macOS stays hardcoded rather than becoming
conditional on asset presence: unlike the cask's now-removed Intel .dmg
leg, build-headless has never had a macOS x86_64 leg at all, so there is
no CI signal this script could ever observe flip from absent to present.

Co-Authored-By: Claude <[email protected]>
…d digests

Three real findings from an independent adversarial review of PR #2175:

- release.yml: sync-homebrew-formula and sync-homebrew-cask are two
  independent jobs that both push to homebrew-nodespace's main branch in
  the same release run. Before this PR there was only ever one writer;
  running them concurrently lets either git push lose a non-fast-forward
  race with no retry. Add sync-homebrew-cask to sync-homebrew-formula's
  `needs` purely for sequencing (matching the existing needs-for-ordering-
  without-gating-on-result pattern already used elsewhere in this file),
  so the formula sync's fresh clone always sees whatever the cask sync
  already pushed.

- update-homebrew-formula.ts: renderFormula()'s six url stanzas had the
  asset filename hand-typed as a separate literal, decoupled from the
  digest.fileName that was actually downloaded and hashed. Today they
  happened to agree, but nothing would catch a future edit to the target
  constants leaving them silently out of sync (sha256 for one asset, url
  for another). Build the filename segment from digests.*.fileName
  instead, tying it to the same verified value the sha256 came from.

- homebrew-tap-push.ts: the credential-scrubbing catch only wrapped the
  git clone call, not the subsequent add/commit/push steps. Widen it to
  cover the whole operation for defense in depth, matching the file's own
  stated purpose.

Co-Authored-By: Claude <[email protected]>
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.

homebrew-nodespace: nodespace-cli formula isn't wired into release-sync/drift-check automation

1 participant