feat: support scalar union policy types - #75
Conversation
|
All GitHub Actions and platform build jobs are now green after pinning the GitHub Windows job to the VS 2022 image supported by Node 22's node-gyp. This PR is the dependency for microsoft/vscode-internalbacklog#8826; a 1.5.0 package release will be needed before the dependent VS Code PR can consume it. |
|
Dependent draft is now open: microsoft/vscode#332071. The watcher PR's GitHub Actions and all Azure Linux/macOS/Windows/package jobs are green. VS Code CI currently fails only because 1.5.0 is not yet published, so merge + publish of this PR is the remaining dependency. |
|
Correction: I briefly changed the GitHub Windows runner to work around the hosted VS 2026/node-gyp discovery failure. That was unrelated scope, so I reverted it in 5164f91 and updated the PR description. The Azure Windows build is green; the GitHub windows-latest failure is documented as infrastructure rather than hidden by this feature PR. |
|
AI review I think the union readers currently turn wrong-typed native values into an enforced empty string whenever the union accepts strings.
This seems different from the existing single-type readers, which treat native type mismatches as unset. Downstream consumers could therefore treat an invalid policy as actively enforced; on Windows, we can also lose the established user-policy fallback. Maybe wrong-typed values should remain unset while preserving the existing HKLM/HKCU behavior. Thanks. |
There was a problem hiding this comment.
Pull request overview
Adds scalar-union policy types to support boolean-or-string managed settings, unblocking VS Code PR #332071.
Changes:
- Adds union validation and TypeScript value inference.
- Implements native Windows/macOS union readers.
- Prepares version 1.5.0 and adjusts CI/build configuration.
Show a summary per file
| File | Description |
|---|---|
src/windows/UnionPolicy.hh |
Defines Windows union policies. |
src/windows/UnionPolicy.cc |
Reads union values from the registry. |
src/windows/PolicyWatcher.cc |
Registers Windows union policies. |
src/PolicyWatcher.hh |
Adds the shared union registration API. |
src/main.cc |
Validates and dispatches union declarations. |
src/macos/UnionPolicy.hh |
Defines macOS union policies. |
src/macos/UnionPolicy.cc |
Reads forced scalar preferences. |
src/macos/PreferencesPolicy.hh |
Rejects unforced preferences. |
src/macos/PolicyWatcher.cc |
Registers macOS union policies. |
src/linux/PolicyWatcher.cc |
Adds the Linux API stub. |
package.json |
Bumps the package to 1.5.0. |
package-lock.json |
Synchronizes package metadata. |
index.d.ts |
Exposes union policy typings. |
binding.gyp |
Builds the new native readers. |
.github/workflows/ci.yml |
Pins Windows CI to Windows 2022. |
Review details
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Suppressed comments (1)
src/windows/UnionPolicy.cc:79
- This constructs
linewithout a length bound, but registry string data is not guaranteed to be NUL-terminated. A malformedREG_MULTI_SZcan therefore make this read pastbufferand crash the watcher. Scan only up toendand append that bounded range.
while (current < end && *current != '\0') {
std::string line(current);
- Files reviewed: 13/15 changed files
- Comments generated: 2
- Review effort level: Balanced
6991a87 to
36c7200
Compare
- allow a policy key to declare a non-empty union of scalar native types - read exact boolean/string/number representations through one per-key native policy - preserve machine-over-user precedence and reject unforced macOS preferences - keep existing single-type declarations on their established readers - pin GitHub Windows CI to the Windows 2022 image supported by Node 22's node-gyp - prepare the 1.5.0 package release Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
36c7200 to
200652f
Compare
Summary
This unblocks the canonical
strictPluginOnlyCustomizationmanaged-setting key from carrying both its existing boolean form and its selective JSON-array string form without breaking deployed native booleans.Dependent VS Code PR: microsoft/vscode#332071
Validation
REG_DWORD trueandREG_SZ "[]"CI compatibility
GitHub's
windows-latestimage now exposes Visual Studio 2026, which Node 22's bundled node-gyp cannot identify. PR #76 pins the GitHub Windows job towindows-2022, retaining the supported Visual Studio 2022 toolchain while leaving the Azure Windows build unchanged.Release sequence
After approval and merge, run the existing Azure pipeline with
publishPackage: trueto publish@vscode/policy-watcher@1.5.0. The dependent VS Code draft will then replace its temporary 1.4 compatibility state with the published version and regenerated lockfile.