Repository navigation
refactor(windows): vendor the registry addon as @orca/windows-registry - #20438
Conversation
[email protected] was last published in 2023 by a single maintainer. Orca called two of its exports, both read-only, so the whole dependency is replaced by a local N-API addon under native/. The vendored addon is read-only by construction: setValue, createKey and deleteKey are gone, so RegDeleteTreeW no longer ships in the app. Two upstream defects are also fixed rather than carried over — the name/data scratch buffers were file-scope statics that concurrent reads would scribble over, and createKey/deleteKey called .c_str() on a temporary. Build wiring keeps the existing shape: still an optionalDependency gated to win32, still excluded from pnpm's allowBuilds so only Orca's own Windows rebuild runs node-gyp for it, still copied into the packaged resources. The CI native caches now key on the vendored sources so an addon.cc edit cannot restore a stale .node.
The addon is vendored source, so no upstream release proves it still decodes values the way Orca's PATH readers expect. reg.exe is the only independent oracle on the box.
|
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 (1)
🚧 Files skipped from review as they are similar to previous changes (1)
Included review availability: Your plan provides up to 10 included reviews per hour; 4 remain after this review. 📝 WalkthroughWalkthroughThe PR adds a private Priority: ➖ Normal Merge Risk: 🔵 Low · up to The addon can omit an unusually named registry value, while Windows CI may rebuild unnecessarily and can fail for a valid casing of PATH. These are bounded issues and do not block merge, but should be addressed soon. 🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (2 warnings)
✅ Passed checks (3 passed)
Full details: Description checkExplanation The description explains the implementation, rationale, scope, and Windows verification, but it omits most required template sections, including Linked Issue, Visual Proof or N/A, Testing checkboxes, AI Disclosure, Review, Agent skill upstream boundary, Notes, and Checklist. Resolution Complete the required template sections. Add a linked issue after “Fixes #”, provide Visual Proof or state N/A with a reason, record testing and platform coverage, complete the applicable checkboxes, and address AI Disclosure, Review, Agent skill upstream boundary, Notes, and Checklist. Full details: Docstring CoverageExplanation Docstring coverage is 18.18% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 11 functions across 14 files. (1 skipped: 1 unsupported.)
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 |
A Windows-gated file self-skips on ubuntu, so without both registrations it reports success while running on no machine at all.
There was a problem hiding this comment.
Important
src/main/windows-registry-addon.test.ts is Windows-gated but registered in neither Windows CI lane, so it runs on no machine and config/scripts/win32-test-lane-registration.test.mjs fails — the vendored addon's only coverage is doing nothing.
Reviewed changes
- Vendored read-only addon: replaced
[email protected]withnative/windows-registry/(addon.ccN-API source,binding.gyp, lazyindex.js,index.d.ts,package.json) exposed as@orca/windows-registry; thesetValue/createKey/deleteKeywrite surface (andRegDeleteTreeW) is gone, and the two upstream buffer/use-after-free defects are fixed with per-call locals. - Wiring rewired: root
optionalDependencies(file:./native/windows-registry),pnpm-workspace.yamlallowBuilds, lockfile,ensure-native-runtime.mjs+rebuild-native-deps.mjsmodule lists and loader branches, packaged-runtime roots, CI native-cache paths/keys, and the docs reference; the config-script contract tests were updated and pass. - Loader swap:
src/main/windows-native-registry.tsrequires@orca/windows-registry; both PATH consumers keep their raw-value/expandablecontract. - New Windows-only test:
windows-registry-addon.test.tspins the addon againstreg.exeas an independent oracle.
DeepSeek Flash (free via Pullfrog for OSS) | 𝕏
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes
- Registered the new Windows-only addon test:
4d6534256faddssrc/main/windows-registry-addon.test.tsto both Windows lanes —WINDOWS_PACKAGE_TESTSinconfig/scripts/pr-code-change-scope.mjsand theTest Windows-specific boundariesvitest argv in.github/workflows/pr.yml— resolving the prior finding that it ran on no machine and leftwin32-test-lane-registration.test.mjsred. Verified locally:win32-test-lane-registration,pr-code-change-scope, andpr-workflow-parallelismall pass (80 tests).
Everything from the prior review still holds; no other changes since 2df51f4.
DeepSeek Flash (free via Pullfrog for OSS) | 𝕏
As a `file:` dependency pnpm re-resolved and re-linked the package on every install, including `--frozen-lockfile` (measured: "added 1" on a repeat no-op install). That virtual-store churn ran concurrently with node-gyp reading the same tree and cost @vscode/windows-process-tree its binding.gyp mid-rebuild, failing package (windows) whenever the native cache hit and only that module needed building. The linux packaging job hit the same race from the other side, as a pnpm staging move failure. A workspace link resolves once and leaves the store alone; repeat installs are now 55ms no-ops. native/windows-registry is listed explicitly so `packages:` still does not auto-discover mobile/.
There was a problem hiding this comment.
Important
The workspace:* switch in 7ba6826 moved the addon's build output out of pnpm's virtual store, but the Windows native cache still points at the old .pnpm location, so the compiled addon is never cached or restored. The same commit also committed the generated node-gyp build tree, which is machine-specific macOS/arm64 output.
Reviewed changes
Reviewed the delta since the prior pullfrog review at 4d65342.
- Switched the addon to a pnpm workspace package:
package.jsonnow declares@orca/windows-registry: workspace:*instead offile:./native/windows-registry,pnpm-workspace.yamllistsnative/windows-registry, the lockfile replaces thefile:native/windows-registryentry with alink:importer, and[email protected]is no longer marked optional. - Updated the packaging contract test:
package-electron-runtime-contract.test.mjsnow expectsworkspace:*. - Committed the generated
native/windows-registry/build/tree:Makefile,binding.Makefile,config.gypi,gyp-mac-tool, andorca_windows_registry.target.mkproduced by node-gyp on macOS/arm64.
DeepSeek Flash (free via Pullfrog for OSS) | 𝕏
| path: | | ||
| node_modules/.pnpm/node-pty@*/node_modules/node-pty/build | ||
| node_modules/.pnpm/windows-native-registry@*/node_modules/windows-native-registry/build | ||
| node_modules/.pnpm/@orca+windows-registry@*/node_modules/@orca/windows-registry/build |
There was a problem hiding this comment.
With @orca/windows-registry now a workspace:* dependency, pnpm symlinks node_modules/@orca/windows-registry to native/windows-registry, so @electron/rebuild writes orca_windows_registry.node under native/windows-registry/build/Release — there is no longer any .pnpm/@orca+windows-registry@* entry. This cache path (and the identical one on the restore-only step at line 164) therefore matches nothing on Windows, so the compiled addon is rebuilt on every run and the cache-key hardening added earlier in this PR is inert for the registry addon.
Technical details
# Point the native cache at the workspace build output
## Affected sites
- `.github/actions/install-node-dependencies/action.yml:153` and `:164` — `node_modules/.pnpm/@orca+windows-registry@*/node_modules/@orca/windows-registry/build` no longer exists; `pnpm-lock.yaml` now records `native/windows-registry` as an importer with `version: link:native/windows-registry` and drops the `@orca/windows-registry` entries under `packages:`/`snapshots:`.
- `config/scripts/pr-workflow-parallelism.test.mjs:392` — asserts `cacheStep.with.path` contains `@orca+windows-registry@`, pinning the stale path.
## Required outcome
- The cached path resolves to where the Windows build actually writes the addon (the workspace package directory, `native/windows-registry/build`) on both the save and restore-only steps.
- The parallelism test asserts the new path rather than the removed virtual-store one.There was a problem hiding this comment.
Actionable comments posted: 5
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Advanced
Run ID: b206ec4b-72cb-47b5-838f-5451aae346bc
⛔ Files ignored due to path filters (1)
pnpm-lock.yamlis excluded by!**/pnpm-lock.yaml
📒 Files selected for processing (26)
.github/actions/install-node-dependencies/action.yml.github/workflows/pr.ymlconfig/packaged-runtime-node-modules.cjsconfig/scripts/ensure-native-runtime.mjsconfig/scripts/ensure-native-runtime.test.mjsconfig/scripts/package-electron-runtime-contract.test.mjsconfig/scripts/pr-code-change-scope.mjsconfig/scripts/pr-workflow-parallelism.test.mjsconfig/scripts/rebuild-native-deps-node-pty.test.mjsconfig/scripts/rebuild-native-deps-test-fixtures.mjsconfig/scripts/rebuild-native-deps.mjsdocs/reference/windows-process-enumeration.mdnative/windows-registry/binding.gypnative/windows-registry/build/Makefilenative/windows-registry/build/binding.Makefilenative/windows-registry/build/config.gypinative/windows-registry/build/gyp-mac-toolnative/windows-registry/build/orca_windows_registry.target.mknative/windows-registry/index.d.tsnative/windows-registry/index.jsnative/windows-registry/package.jsonnative/windows-registry/src/addon.ccpackage.jsonpnpm-workspace.yamlsrc/main/windows-native-registry.tssrc/main/windows-registry-addon.test.ts
Included review availability: Your plan provides up to 10 included reviews per hour; 4 remain after this review.
| path: | | ||
| node_modules/.pnpm/node-pty@*/node_modules/node-pty/build | ||
| node_modules/.pnpm/windows-native-registry@*/node_modules/windows-native-registry/build | ||
| node_modules/.pnpm/@orca+windows-registry@*/node_modules/@orca/windows-registry/build |
There was a problem hiding this comment.
🚀 Performance & Scalability | 🟡 Minor | ⚡ Quick win
Cache the workspace addon's actual build directory in every native cache.
@orca/windows-registry is rooted at native/windows-registry, and node-gyp writes its output to native/windows-registry/build. The cache blocks at action.yml:153,164 and pr.yml:832,901 are separate configurations. Changing action.yml does not change the workflow paths.
Replace the stale path in all four blocks:
Proposed fix
- node_modules/.pnpm/@orca+windows-registry@*/node_modules/@orca/windows-registry/build
+ native/windows-registry/build📝 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.
| node_modules/.pnpm/@orca+windows-registry@*/node_modules/@orca/windows-registry/build | |
| native/windows-registry/build |
| if (!values) { | ||
| return null | ||
| } | ||
| const byName = {} |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win
Use a safe map for registry value names.
A registry value named __proto__ changes the prototype of this object at Line 30. It does not create an enumerable value entry. getRegistryKey then fails its keyed-value contract.
Proposed fix
- const byName = {}
+ const byName = Object.create(null)📝 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.
| const byName = {} | |
| const byName = Object.create(null) |
| data[dataLength] = 0; | ||
| data[dataLength + 1] = 0; | ||
| entry.Set("value", Napi::String::New(env, reinterpret_cast<char16_t*>(data.get()))); |
There was a problem hiding this comment.
🩺 Stability & Availability | 🟠 Major | ⚡ Quick win
Validate UTF-16 data length before conversion.
RegEnumValueW reports dataLength in bytes. A registry value can have a string type with malformed data, including an odd byte count.
The bound Napi::String::New(env, const char16_t*) overload expects a null-terminated UTF-16 string. If dataLength is odd, the two appended zero bytes do not form a terminator at a UTF-16 boundary. The direct conversion and the REG_MULTI_SZ loop can then read beyond the initialized value data.
Reject odd-length UTF-16 data before both conversion branches.
Proposed fix
+ const bool isUtf16 =
+ valueType == REG_SZ || valueType == REG_EXPAND_SZ || valueType == REG_MULTI_SZ;
+ if (isUtf16 && dataLength % sizeof(WCHAR) != 0) {
+ RegCloseKey(key);
+ return env.Null();
+ }
+
if (valueType == REG_SZ || valueType == REG_EXPAND_SZ) {| } catch { | ||
| return null | ||
| } | ||
| const line = stdout.split(/\r?\n/).find((candidate) => candidate.trim().startsWith(name)) |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win
Match the reg.exe value name case-insensitively.
reg.exe matches registry value names without case sensitivity but prints the stored spelling. If the stored name is PATH, candidate.trim().startsWith(name) does not match Path. regQuery returns null, and the no-oracle branch then fails because the addon correctly returns PATH.
Parse the printed value name and compare it to name with toLowerCase() before parsing the type and data.
🧰 Tools
🪛 ast-grep (0.45.3)
[warning] Importing child_process exposes a command-execution surface; ensure any command/argument built from input is validated, and prefer execFile/spawn with an argument array over exec.
Context: import { execFileSync } from 'node:child_process'
Note: [CWE-78] Improper Neutralization of Special Elements used in an OS Command ('OS Command Injection').
(detect-child-process-typescript)
The build/ tree is generated per host and ABI; the committed copy was macOS-specific gyp scaffolding from a local build and would have shipped stale Makefiles to every checkout.
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes
Reviewed the delta since the prior pullfrog review at 7ba6826.
- Removed the committed node-gyp output:
native/windows-registry/build/{Makefile,binding.Makefile,config.gypi,gyp-mac-tool,orca_windows_registry.target.mk}are no longer tracked. - Ignored the generated tree:
.gitignorenow excludesnative/windows-registry/build/, so a local@electron/rebuild/node-gyprun no longer dirties the worktree.
Net: 2 insertions, 1804 deletions across 6 files; no source or runtime behavior changed.
DeepSeek Flash (free via Pullfrog for OSS) | 𝕏
node-gyp also emits bin/<platform>-<abi>/ beside build/; both are per-host generated output that must never be committed.
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.
* Reduce native dependency installs to the host platform * Remove install policy documentation * Guard cross-arch packaging and scope release installs to the runner 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. * Track the install policy doc and index it from AGENTS.md 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. * Route Windows-lane removals through the retrying helper 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. * Adapt the packaging guard to the vendored Windows registry addon 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.

[email protected]was last published in 2023 by a single maintainer. Orca called exactly two of its exports, both read-only, so the whole dependency is replaced by a local N-API addon undernative/windows-registry/.What changed
setValue,createKeyanddeleteKeyare gone, soRegDeleteTreeWno longer ships inside the app. OnlygetKeyremains.createKey/deleteKeycalled.c_str()on a temporaryUtf16Value()— that use-after-free left with the write surface.optionalDependencygated to win32, still excluded from pnpm'sallowBuildsso only Orca's own Windows rebuild runs node-gyp, still copied into packaged resources.addon.ccedit cannot restore a stale.node.Verification on real Windows (
awin)@electron/rebuild+ node-gyp against thefile:-linked package (orca_windows_registry.nodeproduced), and again standalone for the Node ABI (gyp info ok). This was the main risk — no existingnative/module is a node-gyp addon, so this is a new build pattern for the repo.src/main/windows-registry-addon.test.tschecks the addon againstreg.exeas an independent oracle — the real user PATH value and itsREG_SZ/REG_EXPAND_SZtype must match. 4/4 pass on Windows, skipped elsewhere.Note for reviewers
The
awinworktree I used has a pre-existing broken node-pty build (its DLL was locked by the running Orca app), which fails 5-6 node-pty tests on both this branch andmain. Those failures are environmental and unrelated; this PR's CIpackage (windows)job is the clean check.