shakedown: wave 12: auto-select preset from detected hardware (--target now optional)#9
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You shouldn't have to type your SKU when the machine already knows it.
./runwith no--targetnow auto-selects the matching preset from the detected hardware, so the right chassis class, inventory asserts, and golden baseline all apply with nothing to type.What this adds
--target, the orchestrator matches the machine's chip / memory / model against the presets intargets/and uses the one that fits (printing which). Exactly one match wins; zero or several falls back to the prior chassis-auto-detect-with-asserts-skipped behavior.--targetbecomes an optional override for asserting an expected SKU ("I ordered a Max, not a Pro") or forcing a specific preset.--target.Why it's safe
The match uses the SAME sources as the inventory asserts:
chip_type/cpu_typeandround(hw.memsize / 1024^3)andmachine_model + machine_name. So an auto-selected preset always passes its own asserts (no "matched then failed" inconsistency). The guard[[ -z TARGET && -z CHASSIS_CLASS ]]preserves every existing explicit-input path unchanged: pass--targetor setCHASSIS_CLASSand auto-select stands down.Why python, not bash
The match parses JSON presets, reads
sysctl hw.memsizeas an int, and globs a directory. macOS ships no jq and bash can't do this cleanly, so it goes through Python exactly like every other JSON touch in the repo.Verification
Live on this Intel box:
./runauto-selectedmbp-16-intel-2019(chassisintel-laptop) from the detected i7 / 32 GB / "16" model; an explicit--target mbp-16-m5-max-64overrode it with no auto-match. Unit-tested the matcher: single match wins, ambiguous (2 presets) falls back, wrong-memory and unknown-chip fall back. Lint clean (shellcheck, all PYEOF heredocs ast.parse, zero em dashes). Passed dad review: simplicity ship-it, correctness zero-defects (the auto-selected-always-passes-asserts claim verified source-by-source), consistency one-voice.