The first SettingsEngine migration is a narrow cleanup, not a legacy string-to-typed JSON conversion.
Existing settings.json files already store typed JSON values. The migration should only remove shapes that are known to be obsolete or unnecessarily verbose before the SettingsEngine binder reads the document.
Settings migrations run during SettingsEngine.InitializeAsync(), not during service registration.
Use the existing settings version gate:
Settings.Version
Do not introduce a separate migration ledger for this cleanup. The migration must remain idempotent and should skip safely once the target version has been reached.
The cleanup currently targets Model.CustomAssistants[] only.
Rules:
- Convert
Icon.ForegroundandIcon.Backgroundfrom ARGB objects such as{ "A": 140, "R": 179, "G": 47, "B": 115 }to the currentSerializableColorJSON string format. - Preserve icon colors that are already strings or
null. - Leave malformed color objects unchanged so validation can fail fast and preserve the original file.
- Remove obsolete assistant root fields:
Temperature,TopP,ReasoningEffort,ThinkingType,SupportsTemperature, andSupportsTopP. - Do not create or backfill provider option sections such as
OpenAIOptions,OpenAIResponsesOptions,GoogleOptions, orAnthropicOptions.
Keep the SettingsMigrator behavior, but invoke it from the settings initializer:
- parse the settings file as a
JsonObject - create a timestamped backup before migration
- apply pending migrations in memory
- validate the migrated JSON with SettingsEngine before writing
- write atomically only after validation succeeds
- preserve the original file and throw on parse, validation, backup, or write failure
Some migrations need another local store, such as Prompt Manager moving old assistant prompt text from settings.json into prompt.db. Those migrations should not run inside AddSettings() and should not be forced into a settings-only migration.
Use this lifecycle instead:
- SettingsEngine migrates and patches settings at
AsyncInitializerIndex.Settings. - The feature owns a later initializer, usually
Settings + 1, that reads the patched settings and any required preserved JSON fields. - The feature commits its own database changes.
- Only after the feature commit succeeds, it edits the settings JSON through the internal document-editing infrastructure and flushes the result.
The feature migration must be idempotent independently of Settings.Version. Version gating is useful but cannot be the only correctness check when a migration spans settings and a database.
Required coverage:
- ARGB icon colors are converted to
#AARRGGBBstrings. - string and
nullicon colors are unchanged. - obsolete assistant root fields are removed.
- provider option sections are not created or overwritten.
- migration is stable after the target version is reached.
- malformed color objects fail validation and preserve the original file plus backup.
- successful migration output can be loaded by SettingsEngine without warning or error diagnostics.
- settings migration runs during the settings initializer, not during DI registration.
- a post-settings feature migration can edit preserved JSON fields without racing the settings save loop.