Repository navigation
Reduce native dependency installs to the host platform - #20420
Conversation
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Advanced Run ID: 📒 Files selected for processing (2)
Included review availability: Your plan provides up to 10 included reviews per hour; 5 remain after this review. 📝 WalkthroughWalkthroughDefault pnpm installs now include native optional dependencies for the current OS and CPU only. Release installation retains current, x64, and arm64 CPU variants. CI workflows use host-only installs or macOS CPU-expanded installs as required. Electron packaging validates required native variants before packing and loads Windows resources only when the Windows addons exist. Windows-specific tests are gated or run in the Windows CI lane. Priority: ➖ Normal Merge Risk: 🔵 Low · up to The documented install-size comparison may be inaccurate, but this does not block packaging or installation behavior. 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches 💡 1📝 Generate docstrings 💡
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Advanced
Run ID: 9128aac2-57a1-4e9d-9211-7d8928aa0518
📒 Files selected for processing (21)
.github/CONTRIBUTING.md.github/workflows/adhoc-mac-build.yml.github/workflows/daily-mac-build.yml.github/workflows/dev-channel-win-build.yml.github/workflows/hourly-mac-build.yml.github/workflows/pr.yml.github/workflows/release-cut.yml.github/workflows/release-mac-build.yml.github/workflows/windows-signing-rehearsal.ymlconfig/electron-builder.config.cjsconfig/scripts/ci-dependency-download-cache.test.mjsconfig/scripts/electron-builder-config.test.mjsconfig/scripts/electron-builder-runtime-resources.test.mjsconfig/scripts/measure-pnpm-install.mjsconfig/scripts/package-electron-runtime-contract.test.mjsconfig/scripts/pr-workflow-parallelism.test.mjsconfig/scripts/windows-process-tree-gyp-path.test.mjsconfig/scripts/windows-process-tree-gyp-rebuild.test.mjsdocs/reference/pnpm-install-policy.mdpackage.jsonpnpm-workspace.yaml
Included review availability: Your plan provides up to 10 included reviews per hour; 7 remain after this review.
| sherpa: ['sherpa-onnx-'], | ||
| oxlint: ['@oxlint+', '@oxlint-tsgolint+'], | ||
| swc: ['@swc+core-'], | ||
| typescript: ['@typescript+'] |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win
Include the unscoped typescript packages in the family measurement.
The script matches virtual-store names with startsWith. The store contains both [email protected] and [email protected], so @typescript+ does not count the compiler packages. Keep the scoped platform-package match and add the unscoped prefix.
Proposed fix
- typescript: ['`@typescript`+']
+ typescript: ['`@typescript`+', 'typescript@']📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| typescript: ['@typescript+'] | |
| typescript: ['@typescript+', 'typescript@'] |
There was a problem hiding this comment.
Important
The beforePack guard fails loudly for Windows packaging without the Windows addons, but the equivalent cross-arch failure for local macOS/Linux packaging is unguarded and silent. Worth a look before merge.
Reviewed changes
- Host-only default install:
pnpm-workspace.yamlnarrowssupportedArchitectures.os/cputo[current]; the release workflows and the newinstall:releasescript opt back into--os=current,darwin,linux,win32 --cpu=current,x64,arm64. - Windows packaging guard:
config/electron-builder.config.cjscomputeswindowsRuntimeResourcesonly when both Windows addons are present and throws frombeforePackforwin32when they are not. - Platform-gated tests: Windows-addon/packaging assertions moved behind
process.platform === 'win32'and registered in the PR Windows lane; new tests pin the cross-target flags on release workflows andinstall:release. - Docs/measurement: new
docs/reference/pnpm-install-policy.mdandconfig/scripts/measure-pnpm-install.mjs.
ℹ️ Stale comments and docs still describe the old broad install
The default now fetches only the host, so two existing references state behavior that is no longer true and can mislead the next engineer debugging a cross-arch package:
config/packaged-runtime-node-modules.cjs:439— "we package every installed@parcel/watcher-<platform>optional subpackage (supportedArchitectures fetches all)". After this change, "fetches all" is only true underinstall:release; a default install fetches just the host variant.docs/reference/windows-process-enumeration.md:511-512— "pnpm installs optional dependencies on every host, and macOS/Linux must never runnode-gypfor it". The addon is no longer installed on macOS/Linux at all, so the rationale needs updating.
Technical details
# Stale cross-host install rationale
## Affected sites
- `config/packaged-runtime-node-modules.cjs:438-440` — comment asserts every platform subpackage is installed; only true with the release flags now.
- `docs/reference/windows-process-enumeration.md:510-515` — `allowBuilds` rationale says pnpm installs the Windows addon on every host; it no longer does.
## Required outcome
- Comments/docs should describe the new contract: host-only by default, broad closure only via `pnpm install:release`.ℹ️ Nitpicks
- The new page
docs/reference/pnpm-install-policy.mdhas no!docs/reference/pnpm-install-policy.mdentry in.gitignore's allow-list, so a cleangit addwould not pick it up (tracked here only because it was force-added). Per repo convention this is at most a nitpick.
openrouter/deepseek/deepseek-v4.1-flash (free via Pullfrog for OSS) | 𝕏
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes
- Re-introduced the install-policy documentation (
.github/CONTRIBUTING.md,AGENTS.md, newdocs/reference/pnpm-install-policy.md,.gitignoreallow-list) after the intermediate deletion. - Added
assertPackagedNativeVariantsInstalledand wired it intobeforePack, extending the missing-native build-failure guard from win32 to darwin and linux architectures. - Scoped release installs to each runner's actual target (macOS
--cpu=current,x64,arm64, other packaging jobs host-only) and removed the unusedconfig/scripts/measure-pnpm-install.mjs. - Updated the packaging tests, the
supportedArchitecturespin, and the Windows CI lane to match the new contract.
ℹ️ Stale cross-host rationale in windows-process-enumeration.md
The allowBuilds rationale in docs/reference/windows-process-enumeration.md:510-512 still says "pnpm installs optional dependencies on every host", which the narrowed supportedArchitectures makes untrue — the Windows addon is no longer installed on macOS/Linux. The sibling comment in package-electron-runtime-contract.test.mjs was rewritten for this exact reason; this doc was not.
Technical details
# Stale cross-host install rationale
## Affected sites
- `docs/reference/windows-process-enumeration.md:510-512` — `allowBuilds` rationale asserts pnpm installs the Windows addon on every host, so macOS/Linux must never run `node-gyp`. After the host-only narrowing, the addon is not installed off Windows at all.
## Required outcome
- The rationale should describe the new contract: host-only by default, Windows addons arriving only where `os: win32` matches (and built only by the Windows-only rebuild).
## Open questions for the human (optional)
- This was raised in the prior review body; treating it as informational since it is a doc-only polish and does not block merge.DeepSeek Flash (free via Pullfrog for OSS) | 𝕏
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes
- Routed the two config specs newly added to the Windows lane through the retrying teardown helper:
electron-builder-runtime-resources.test.mjsnow awaitsremoveTree(...)andwindows-process-tree-gyp-rebuild.test.mjscallsremoveTreeSync(...), both fromsrc/shared/windows-transient-lock-removal.ts, satisfying thewindows-lane-tree-removal-boundaryratchet. - Dropped the now-unused
rm/rmSyncimports in those two files.
The other two specs added to the same lane (windows-process-tree-gyp-path.test.mjs, package-electron-runtime-contract.test.mjs) contain no raw recursive removals, so the lane is clean. The ratchet and both edited specs pass locally (30 passed, 1 win-only skipped).
DeepSeek Flash (free via Pullfrog for OSS) | 𝕏
electron-builder only logs a warning for a missing extraResources source, so a host-only install silently shipped a foreign-arch slice without its natives — `pnpm build:mac` on Apple Silicon produced an x64 DMG with no sherpa-onnx-darwin-x64 and no @parcel/watcher-darwin-x64. The previous beforePack hook covered only win32. - Add assertPackagedNativeVariantsInstalled, an arch-aware check over the target's sherpa-onnx, @parcel/watcher, and (on Windows) node-gyp addons. beforePack now runs it for every platform, with remedies split: another architecture comes from install:release, the os:win32 addons need a Windows host. - Drop --os from the release installs. Every packaging job already runs on a runner whose OS matches its target, so only the macOS lanes need extra breadth, and only on CPU for their x64+arm64 config. Windows and Linux packaging return to a plain host-only install. - Add --frozen-lockfile to install:release so a bare run cannot rewrite the lockfile. - Restore the install policy reference doc and the CONTRIBUTING note, plus the rationale comments dropped from the runtime contract test. - Gate the packaging-closure assertions on whether the Windows addons are installed rather than on the host OS, so a cross-arch install exercises them off Windows too. - Make the workflow contract test read `run:` steps as well as retry-action commands, and enforce host-only scoping on the non-macOS packaging lanes. - Remove the unreferenced install measurement script; its numbers live in the policy doc.
docs/** is ignored behind a per-file allow-list, so the new reference doc was only committed via git add -f and future edits would be skipped. Add it to the allow-list and give it an AGENTS.md entry like every other tracked reference doc, so the host-only install rule is discoverable before someone packages a second architecture.
Adding these four specs to the PR Windows lane pulled them into the windows-lane-tree-removal-boundary ratchet, which failed on 20 raw recursive removals. On Windows a bare rmSync races a handle the OS has not released, throwing EPERM after the assertions already passed and reporting a green test as a lane failure.
main vendored windows-native-registry as the workspace package @orca/windows-registry (#20438). A workspace link resolves on every host, so including it in the installed-Windows-addons checks proved nothing. @vscode/windows-process-tree is the only os: win32 npm addon left, so it alone decides whether the win32 resource plan resolves.
23be43e to
a63c839
Compare
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes
- Adapted the cross-arch packaging guard to main vendoring the Windows registry addon (#20438): the win32 check in
assertPackagedNativeVariantsInstallednow requires only@vscode/windows-process-tree, replacing the stale unscopedwindows-native-registryname that no longer resolves. - Narrowed the config-load gate for
win.extraResourcesand thewindowsAddonsInstalledtest gate inelectron-builder-runtime-resources.test.mjsto the same single package, since the@orca/windows-registryworkspace link resolves on every host and proved nothing. - Updated
docs/reference/pnpm-install-policy.mdto explain why the guard checks one package.
The old unscoped name would have failed every Windows package after the vendoring, so this is a necessary fix rather than a new risk. @orca/windows-registry's binding.gyp declares OS!='win' → type none, confirming off-Windows installs link the package but compile no binary, so the doc's "compiled only on Windows" claim holds. Focused tests pass locally (74 passed across electron-builder-config, electron-builder-runtime-resources, package-electron-runtime-contract).
DeepSeek Flash (free via Pullfrog for OSS) | 𝕏

ELI5
Every developer checkout and ordinary CI job installed native binaries for macOS, Linux, and Windows on both CPU architectures. Install only what the host can use, and let the few jobs that genuinely package for a second target opt in. On a fresh Apple Silicon install this removes 90 packages and 1.23 GiB of logical package content (53.3%).
What Changed
supportedArchitecturesto the current OS/CPU; local development and ordinary CI inherit it.--cpu=current,x64,arm64because the mac config emits x64 and arm64 from an arm64 runner; Windows and Linux packaging use a plain host-only install.pnpm install:release(pnpm install --frozen-lockfile --cpu=current,x64,arm64) covers local cross-architecture packaging, includingpnpm build:mac.beforePackguard. electron-builder only warns on a missingextraResourcessource and continues, so a thin install would ship a foreign-architecture slice with nosherpa-onnx-*and no@parcel/watcher-*. The guard fails the build instead, naming every missing package and giving the remedy that fits — another architecture comes frominstall:release; theos: win32addons need a Windows host.docs/reference/pnpm-install-policy.mdand.github/CONTRIBUTING.md.Why
Clean, frozen, script-free, offline installs using the same lockfile and existing pnpm store on macOS arm64 / pnpm 12.0.0:
These are logical file bytes, not unique physical disk savings: hardlinks/APFS clones can share storage. Lifecycle builds and Electron downloads were excluded equally. The single timing pair does not establish a speedup; cold-network and Linux/Windows CI timings were not measured. Existing
node_modulescan retain variants, so reclaiming them requires a fresh install. Shared pnpm caches are not deleted. Full numbers and method are in the policy doc.Linked Issue
User-requested dependency-install audit; no existing issue supplied.
Visual Proof
N/A — no visual change; dependency installation and packaging configuration only.
Testing
pnpm tcpasses all three projects,oxlintclean, changed-code quality gate clean, from a host-only install.darwin/{x64,arm64},win32/{x64,arm64},linux/x64: the host target passes and every foreign target fails with the correct missing-package list.--cpu-widened--frozen-lockfileinstall adds the missing variants on top of an existing host-onlynode_modules, and that narrowing back does not prune them.Review
The first revision of this PR kept a broad
--os=current,darwin,linux,win32on every release lane and guarded only Windows packaging. Both were wrong: no packaging job cross-compiles across operating systems, and the platform that could silently ship a broken artifact was macOS, whose dual-architecture build runs on an arm64 host. This revision narrows the release installs to what each runner actually targets and replaces the win32-only check with an arch-aware guard over all platforms.No dependency versions or lockfile changed. SSH execution, wire formats, folder workspaces, agents, integrations, git providers, and mobile's separate dependency policy are unaffected. No new network execution or security-sensitive runtime behavior. UI review is not applicable.
Cross-platform verification
Rebased onto current
main, which vendored the Windows registry addon as the workspace package@orca/windows-registry(#20438). Because a workspace link resolves on every host,@vscode/windows-process-treeis now the onlyos: win32npm addon and is what the installed-addon checks key on.Verified at
a63c8399c2bon real hosts, not just CI:sherpa-onnx-darwin-arm64+watcher-darwin-arm64; guard passesdarwin/arm64and fails every foreign target; 117 tests;pnpm tccleansherpa-onnx-linux-x64+watcher-linux-x64-glibc;@vscode/windows-process-treeabsent; guard correct; 107 testssherpa-onnx-win-x64+watcher-win32-x64; both addons present; guard passeswin32/x64; Windows lane 43/44 files, 371 testsThe one Windows lane failure,
src/main/cursor/hook-service.test.ts, is pre-existing: it fails identically onorigin/mainon that same machine and passes in CI.Agent skill upstream boundary
Checklist