Files
vscode/.github
Josh Spicer 5a270e6dbd policy: resolve managed settings per-key across delivery channels (#323780)
* policy: resolve managed settings per-key across delivery channels

Managed settings previously used a single authoritative source: the first
non-empty delivery channel (native MDM > server > file) won wholesale and the
others were ignored entirely. Switch to per-key precedence: the same order is
honored, but resolved key-by-key. A key locked by a higher-precedence channel
still cannot be overwritten, while keys a higher channel leaves unset are now
filled in by a lower channel.

Centralize the resolution in a new pickManagedSettings() (replacing
selectManagedSettings) that returns the merged bag, per-key provenance, and the
active sources, so policy evaluation and the Policy Diagnostics report share one
implementation. Build the merged bag with Object.fromEntries so an untrusted
__proto__ key cannot corrupt its prototype chain.

Rework the Policy Diagnostics report to show every contributing source, a per-key
Resolution table (effective value, winning source, and struck-through overrides),
and per-key policy attribution.

Add unit coverage for the per-key merge (provenance, fill-down, falsy values,
ordering, prototype-pollution guard) plus an end-to-end test proving two keys can
win from two different channels and both reach policy evaluation.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

* policy: iterate managed-settings bags with Object.keys over own props

Address PR feedback: switch pickManagedSettings from `for...in` to a guarded
`Object.keys` loop so only own enumerable properties are visited (managed-settings
bags are untrusted input) and absent channels are skipped explicitly.

Note: `for...in` over an undefined bag was already a no-op (never threw), so this is
a robustness/clarity improvement rather than a crash fix.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

* policy: tidy pickManagedSettings unit suite

Drop two redundant cases (distinct-keys and standalone activeSources ordering,
both already covered by the headline and empty/absent tests) and fold the
non-contributing-middle-channel ordering check into the empty/absent snapshot.
Verified against the live node unit runner (all green).

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

---------

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-07-01 13:55:15 -07:00
..