/
/
# What does this implement/fix? Smart Fades loads nine model components, and adding or removing one meant editing four hand-synced lists: the attribute declarations, the tuple unpack in `_load_models()`, the `= None` assignments in `_free_models()`, and the return-tuple annotation on `_initialize_models()`. Miss one and a model either stays in memory after an unload or gets wired to the wrong slot — the two FireRed CMVN arrays share a type, so swapping them would type-check fine and silently produce garbage features. The models are loaded and freed as one set, so they now live in one frozen `LoadedModels` dataclass behind a single field. Adding a model is one line, and mypy points at the one place that still needs updating. No behaviour change. ## Changes - Collapse the nine model attributes into a frozen `LoadedModels` dataclass held in one field. - Build it with keyword arguments, so components can no longer be wired to the wrong slot. - Replace the nine per-component `_require_loaded()` guards with a single `_require_models()` that resolves the whole set once per code path. - Reduce the test fixture to one stub set, and cover that unloading releases all of it. - Pin the "models resolve before the beat stage" contract with a test that frees them mid-inference, so that race can no longer be broken silently. ## Types of changes - [ ] Bugfix (non-breaking change which fixes an issue) — `bugfix` - [ ] New feature (non-breaking change which adds functionality) — `new-feature` - [ ] Enhancement to an existing feature — `enhancement` - [ ] New music/player/metadata/plugin provider — `new-provider` - [ ] Breaking change (fix or feature that would cause existing functionality to not work as expected) — `breaking-change` - [ ] Refactor (no behaviour change) — `refactor` - [ ] Documentation only — `documentation` - [x] Maintenance / chore — `maintenance` - [ ] CI / workflow change — `ci` - [ ] Dependencies bump — `dependencies` ## Checklist - [x] The code change is tested and works locally. - [x] `pre-commit run --all-files` passes. - [x] `pytest` passes, and tests have been added/updated under `tests/` where applicable. - [ ] For changes to shared models, the companion PR in `music-assistant/models` is linked. - [ ] For changes affecting the UI, the companion PR in `music-assistant/frontend` is linked. - [x] I have read and complied with the project's [AI Policy](https://github.com/music-assistant/.github/blob/main/AI_POLICY.md) for any AI-assisted contributions. - [ ] I have [raised a PR against the documentation repository](https://github.com/music-assistant/music-assistant.io/blob/main/CONTRIBUTING.md) targeting the main or beta branch as appropriate.