Repository navigation
config: load a configuration whatever version wrote it - #947
Merged
Merged
Conversation
A machine holds the retired `[scsi.N]` tables as a `toml::Table`, and TOML's value model has no null, so the `"size_mb": null` every pre-TOML front end wrote for a disk with no scratch size made the whole preferences file unreadable: the library stayed empty and New Machine refused, on every platform and in the sandboxed Mac build alike. Parse the preferences to a `serde_json::Value` and drop null members before deserializing. Every field in `GuiSettings` and `MachineConfig` has a serde default, so an absent member and a null member mean the same thing. The suite missed this because the migration fixtures are built by serializing today's structs, and `legacy_scsi` is `skip_serializing` — so no fixture could contain the key the fold exists for. The new test writes the legacy JSON as literal text instead. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
`MachineConfig` is both the live schema and the migration target for every file any version ever wrote, and it is `deny_unknown_fields`, so each schema change silently redefined which older files still load and turned the ones that didn't into a locked-out front end. That shipped twice: the retired `[impact]` section, and a disk's `size_mb: null`. The legacy JSON path is now lenient, because nothing hand-wrote it: a null means absent, each machine is read on its own, and a key no fold claims is dropped and named in the log instead of costing the file. Folding stays how a retired key keeps its meaning; the drop is the net under it. Quarantining a machine rather than the whole file means `migration_pending` -- which blocks every save -- now means only that the preferences file itself cannot be read or written. A machine that would not read is named in the library, with its settings still in `gui.json.pre-toml.bak`. Nothing writes a null into a configuration any more: the twenty bare `Option` fields that would have serialized one now skip. TOML omits `None` either way, so this only ever mattered on the JSON side, which is the legacy direction. Configurations take a `schema` version. Nothing writes it, by design: an older build refuses a key it has never seen, so a build must read the stamp a release before any build may write one. A file stamped newer now says to update IRIS instead of failing on whichever key that build did not recognise. Two findings from auditing August 2026 forward. `[audio] cpal_buffer_frames` was being silently discarded, because `AudioConfig` is not `deny_unknown_fields`; it folds into `latency_ms` now, 960 frames being 20 ms at 48 kHz. `[o2] control_port` was refused without naming a replacement, and now names one. Nothing else from August hard-fails once `alias`, the `legacy_*` renames and per-struct `deny_unknown_fields` are accounted for. Two guards so this stops recurring. `iris-gui/core/tests/legacy/` holds preferences as shipped versions actually wrote them, as literal text -- building a fixture by serializing today's structs is exactly how the null got past the suite, since the retired `[scsi.N]` tables are a `skip_serializing` field and so can never appear in a generated one. And `tools/config-compat.py` reads the structs at a past revision and names every key that version could write and this one would refuse, separating silent breakage from a `refuse()` that names its replacement. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
techomancer
force-pushed
the
gui-legacy-prefs-migration
branch
from
December 1, 2026 05:25
9e2f691 to
2cabb35
Compare
Collaborator
|
nice, thanks for doing this! |
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.
Installing the latest nightly over an August-or-earlier install left the front end
with an empty library and no way to create a machine: every machine in
gui.jsonfailed to migrate with
and
migration_pendingthen locks the library. The cause is one missingskip_serializing_if:ScsiDeviceConfig::size_mbwrote"size_mb": nullforevery disk, and
legacy_scsi: Option<toml::Table>cannot hold a JSON null,because TOML has no null. Any install with a disk was affected, on every
platform, including the August Mac App Store build.
Rather than fix that one key, this makes reading an old configuration lenient by
construction, since
MachineConfigis both today's strict schema and themigration target for every file ever written.
Reading preferences (
iris-gui/core/src/model/settings.rs)load_in()— the single migration entry point all four front ends share — nowreads
gui.jsonby three rules instead of one strictfrom_str:Nonecan neveragain reject a file.
a warning, and the machine loads. Bounded at 32 keys.
the other machines work, and the failure is reported against the retained
original with the reason.
Version stamping (
src/config.rs)New
iris::config::SCHEMA(= 1) and an optionalschemakey onMachineConfig.Nothing writes it yet; both readers check it, so a file from a future IRIS says
"update IRIS to open it" instead of failing on whichever key it happens to hit
first. 20 bare
Optionfields gainedskip_serializing_ifso they stop writingnulls at all.
Two defects the audit turned up
[audio] cpal_buffer_frameswas silently discarded on load; it now folds tolatency_ms(frames ÷ 48, one 48 kHz period).[o2] control_portwas refused without naming a replacement; it now points atci = trueand iris-ci.Guards
iris-gui/core/tests/legacy/holds real preference files as literal text —a June nightly, an August App Store install, and synthetic unknown-key,
one-bad-machine and newer-schema cases. Fixtures are never written by
serializing today's structs;
README.mdthere says so.tools/config-compat.py <rev>reads the config structs at a past revision andreports any key that would now stop a file loading without saying why. It
understands
rename,alias,skip,skip_serializingand per-structdeny_unknown_fields. Exit 1 on a lockout.Verification
cargo test -p iris-gui-core --lib model::settings— 14 passed, 0 failed,including the two real-world fixtures.
tools/config-compat.pyagainst June, August and 14 November — no lockouts.cargo check --tests -p iris -p iris-gui-core— clean.The
iriscrate's own unit tests are type-checked but were not run locally:the test binary needs more memory than this machine can give it safely. They need
CI.
🤖 Generated with Claude Code