Skip to content

Add a preset library and validate presets before use - #29

Merged
BiosSystem merged 2 commits into
masterfrom
feature/preset-library
Sep 8, 2026
Merged

Add a preset library and validate presets before use#29
BiosSystem merged 2 commits into
masterfrom
feature/preset-library

Conversation

@BiosSystem

Copy link
Copy Markdown
Owner

Four presets alongside gaming-rig, plus the loader work that had to come first.

The loader would have shipped broken presets silently

Proved before changing anything: a preset switch that does not match a feature is added to the parameter table and then dropped by the apply phase without a word. One typo produced a run that applied nothing and exited 0. A missing preset file printed a warning and carried on. Neither is acceptable for a library people will copy and edit.

Import-PresetSwitches now throws for a preset that cannot be found or read, names a switch that does not exist, lists a switch twice, names none, or selects two values from one mutually exclusive group. A missing preset lists the ones that do exist:

Preset 'does-not-exist' was not found. Available presets: dev-box, gaming-rig, htpc, minimal-workstation, privacy-max.
Preset '...' names switches that do not exist: DisableTelemtry.
Preset '...' selects more than one value for 'ExplorerLocation': ExplorerToThisPC, ExplorerToDownloads.

Mutual exclusion comes from the UiGroups block already shipped in Features.json - nine declared groups - rather than a hand-maintained list. And -Preset htpc now works; it used to require the full path.

Six switches (EnablePerformanceTweaks, DisableWindowsAds, EnableCompetitiveGaming, DisableMemoryIntegrity, DisableSettingsAds, DisableWidgetsDeep) are dispatched by explicit blocks rather than Features.json; gaming-rig has always relied on them, so validation accepts them. Verified gaming-rig passes the new validation unchanged.

The presets

Preset Switches Intent
privacy-max 21 Telemetry, tracking, ads and AI collection stripped; no performance or UI opinion
minimal-workstation 17 Quiet office machine; default app list removed
htpc 17 Media box: quiet UI, and Windows Update cannot reboot mid-playback
dev-box 17 WSL and Sandbox on, full context menu back, Explorer shows what it hides

Every switch in every preset validated against the real catalogue: no unknowns, no duplicates, no exclusive-group conflicts. The Pester suite loads each shipped preset, so a future preset with a typo fails CI rather than shipping.

Found while composing privacy-max

-DisableSearchHistory and -DisableSearchHighlights are declared as parameters and have both apply and undo reg files - but no Features.json entry and no handler block. Passing either does nothing, silently. They are the only two of 145 parameters in that state (checked all of them). Left out of the presets; wiring them up is a small separate change since all four reg files already exist.

Verification

All five presets load through the new path, name resolution covers bare name, name.json and explicit path, and each validation failure throws with the message shown above. 12 new Pester tests wired into CI. Static validation passes (114 files, up from 112); standalone rebuilt and parse-checked.

Not verified end to end: applying a preset needs elevation, and the mutating integration suite still needs Sandbox.

Four presets alongside gaming-rig: privacy-max, minimal-workstation,
htpc and dev-box.

The loader needed work first. A preset switch that did not match a
feature was added to the parameter table and then dropped by the apply
phase without a word, so one typo produced a run that applied nothing
and still exited 0. A missing preset file only printed a warning and
carried on. Neither is acceptable for a library people copy and edit.

Import-PresetSwitches now throws for a preset that cannot be found or
read, names a switch that does not exist, lists the same switch twice,
names none at all, or selects two values from one mutually exclusive
group. A missing preset lists the ones that do exist.

Mutual exclusion comes from the UiGroups block already in Features.json
rather than a list kept in step by hand. Nine groups are declared there,
covering the taskbar, Explorer location, drive letters, alt-tab and the
Start menu views.

-Preset now takes a bare name, so -Preset htpc works where it used to
need the full path to the json. Explicit paths still work.

Six switches are dispatched by their own blocks in WinSwift.ps1 rather
than through Features.json, and gaming-rig has always relied on them
being accepted, so validation allows them.

Presets read through LoadJsonFile, which reads UTF8, so a preset with
non-ASCII in its description no longer depends on the ANSI codepage.

Found while composing privacy-max: -DisableSearchHistory and
-DisableSearchHighlights are declared as parameters and have both apply
and undo reg files, but no Features.json entry and no handler, so
passing either does nothing. Left out of the presets and reported
separately rather than fixed here.
Set-Preset was declared in the Context body, which Pester executes
during discovery, so the function did not exist by the time the tests
ran. All six tests that called it failed in CI while everything else
passed. Moved into BeforeAll, which shares the run-phase scope.
@BiosSystem
BiosSystem merged commit 7d0cb6a into master Sep 8, 2026
1 check passed
@BiosSystem
BiosSystem deleted the feature/preset-library branch September 8, 2026 07:53
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.

1 participant