MindAttic.Vault/lamp-migration
LAMP app migration playbook
How one MindAttic app moves its app-level settings and keys into MindAttic.Vault 7 so that MindAttic.Vault.Desktop.Wpf is the only place they are edited. Plan: RFC 0003. Each app has one migration ticket, part-of M.VALT-T35. The app must behave exactly as before when it's done: same effective values, same keys used, same startup.
Names (final)
| What | Name in files, App Configuration and IConfiguration |
|---|---|
| App setting | MindAttic:Settings:{AppId}:{property} (camelCase, nested objects add :{child})
|
| Cross-app setting | MindAttic:Settings:Global:{property} (MindAtticGlobalSettings)
|
| Named key | MindAttic:Vault:LLM:{provider}:keys:{keyName} (brokers: MindAttic:Vault:Brokers:...)
|
| Key order / disabled | ...:{provider}:keyOrder:{i}, ...:{provider}:disabledKeys:{i}
|
| App's keys | MindAttic:Vault:Assignments:{AppId}:{provider}:{i} (first = active)
|
{AppId} is the [SettingsApp] id and the app's folder under %APPDATA%\MindAttic\ (M.VALT-LAW-2). If the app already has a folder there, use that exact name.
Steps
- Package. Every project in the repo that references
MindAttic.Vaultmoves to7.0.0(local feedC:\LocalNuGet). Fix any breaking changes from older majors. - One settings class. All app-level settings (scope: the RFC's section 0) go in one class:
[SettingsApp("IdiotProof", "IdiotProof", Icon = "chart", Description = "...")] [UsesCredential("claude", Required = true, Purpose = "Strategy review")] public sealed class IdiotProofSettings { [Setting("Max loss per trade", Group = "Risk", Help = "Dollars per trade", Order = 1)] [SettingRange(0, 100000)] public decimal MaxLossPerTrade { get; set; } = 50m; // initializer = today's default }- Property initializers are the first-run defaults: exactly what the app uses today when nothing is set.
- Lists of objects (profiles, users, ...) are
List<TItem>of a settable class; add[SettingCollection(ItemName = "profile")]. - No secrets. Keys/passwords/tokens never go in this class (the manifest builder throws on secret-looking names). Mark a look-alike that isn't a secret with
[Setting(..., NotSecret = true)]. - If the app already used
JsonSettingsStore<T>at%APPDATA%\MindAttic\{App}\settings.json, keep the property names so the existing file still loads; just add the attributes. - Per-user / per-universe / CMS data stays where it is (RFC section 0).
- Load it.
var store = JsonSettingsStore<TSettings>.ForSettingsApp(); var settings = store.LoadOrSeed();(DI:services.AddVaultAppSettings<TSettings>("{AppId}")and injectISettingsStore<TSettings>).LoadOrSeedwritessettings.manifest.jsonbeside the file. Hosts built on IConfiguration may instead addconfiguration.AddMindAtticVaultConfiguration()and bindGetSection("MindAttic:Settings:{AppId}"). - Import today's values once. When the new
settings.jsondoesn't exist yet, read the old storage (SQLite row, other JSON, registry,appsettings.json, ...) into the class andSaveit, so the user's current values carry over. Never modify or delete the old storage (it is the rollback). Run the app once on this machine (or its--write-settings-manifest) so the real%APPDATA%gets today's values. - Remap consumers. Every place that read the old storage reads the new class (or the IConfiguration name). Grep for the old accessors until none remain.
- Keys. Declare
[UsesCredential]for every provider the app uses. Resolve keys through the shared named lists, never a per-app copy:- Desktop/console:
var keys = KeySelector.ForCurrentUser(); - IConfiguration hosts:
var keys = configuration.CreateKeySelector(); - Wrap calls:
await keys.ExecuteAsync("claude", "{AppId}", (key, ct) => CallAsync(key, ct), ct)orkeys.SendAsync(...)for raw HTTP. Where a call can't be wrapped (streaming, SDK-owned retries):keys.GetActiveKey(provider, appId)thenReportSuccess/ReportFailure(provider, name, kind). - Remove
AppScopedCredentialStore; at startup callKeyImporter.ImportAppScopedFor("{AppId}")once so any per-app copy moves into the shared list and stays this app's active key. - Catch
AllKeysFailedExceptionwhere the app reported a missing key before, and show its message (it names keys, never values) plus a button that callsVaultSettings.Open("{AppId}").
- Desktop/console:
- Manifest on install. First line of
Main/Program.cs:if (SettingsManifestCommand.TryRun<TSettings>(args)) return;and have the repo'srun.ps1run the built exe once with--write-settings-manifestafter publishing. - Remove the settings screen. Delete the app-level settings page/window/menu/route. The cog (or settings menu/button) calls
VaultSettings.Open("{AppId}"); a link next to one value can pass its full name:VaultSettings.Open("{AppId}", "MindAttic:Settings:{AppId}:maxLossPerTrade"). Blazor Server apps call it from the server-side handler (the server runs on the user's machine) and may also renderVaultSettings.Link(...)as an<a href>for a remote browser. Never host a settings editor in the app. - Tests (NUnit; the repo's existing test project, or a new
{Project}.Tests):- One test per setting, each proving it end to end: the old stored value imports into the right property, it round-trips through
JsonSettingsStoreunder its manifest name, and the code that consumes it actually gets that value. - The manifest builds (
SettingsManifestBuilder.Build<TSettings>()), every field has a label, no secret fields. LoadOrSeedon an empty folder seeds exactly today's defaults.- LLM apps: first key 401 → the second key is used (KeySelector over a temp
NamedKeyStore). - The old settings UI is gone (type/route/file no longer exists) and the cog calls
VaultSettings.Open(setVaultSettings.Launcherto a fake). - Use
TempDirectory-style folders andMINDATTIC_VAULT_ROAMING_ROOT/MINDATTIC_VAULT_LOCAL_ROOToverrides: tests never touch the real%APPDATA%(M.VALT-LAW-6).
- One test per setting, each proving it end to end: the old stored value imports into the right property, it round-trips through
- Verify. Build the whole solution, run the repo's full test suite, run the import on this machine, start the app the way MindAttic.Orchestrator starts it and confirm it behaves as before.
Lessons from the pilot (MediaButler)
- No
run.ps1? Don't invent one; run--write-settings-manifestby hand on this machine and say so. - Run controls stored as settings (e.g. a "dry run" switch on the app's main screen) may stay where the user works, as long as they read and write through the settings store. Only the settings screen goes.
- Other app files next to settings.json (caches, catalogs, cert stores) must resolve through
VaultPaths.RoamingBucket(appId)/VaultPaths.LocalApp(appId), never a hard-coded%APPDATA%path, or tests leak into the real AppData. - Test isolation is assembly-wide: each test project sets
MINDATTIC_VAULT_ROAMING_ROOTandMINDATTIC_VAULT_LOCAL_ROOTto temp folders in a[SetUpFixture](and passes them to any process it spawns), so no test, including end-to-end ones, can write the real AppData. - Remapping includes copy helpers: anything that clones or projects the settings object (per-source copies, option builders) must carry every property; add a test that each property survives the copy.
- Username/password pairs (OpenSubtitles, SMTP) stay in their existing Vault stores (
Subtitles,Notifications); they are not named-key providers. - Deployed web apps read their settings by name from IConfiguration (App Configuration): load
GetSection("MindAttic:Settings:{AppId}")when it exists and only fall back to the local store otherwise (see Cursory'sCursorySettings.Load).LoadOrSeednever throws on a read-only disk. - Old config keys (
appsettings.jsonsections,Foo:Barkeys) are imported once when the Vault file doesn't exist yet, then removed from the shippedappsettings.jsonso nothing reads them twice (see ProcessLogger'sProcessLoggerOptions.Load). - Global default, app override (M.VALT-T77): Global (
MindAtticGlobalSettings) holds exactly the values every app should reach: theme, workspace root and alert recipient. An app's own copy of one is an optional override: blank follows Global, set wins. Resolve it withMindAtticGlobalSettings.Resolve(appValue, g => g.AlertRecipient)(see the Orchestrator'spsstAlertToandworkspaceRoot). - Per-machine apps (hotkeys, autostart, local databases) use
[SettingsApp(..., Local = true)]. - Apps that change behavior while running (tray apps, services) watch their settings file and apply edits live (see Unstuck's
SettingsService.Watch+SettingsApplier). - Shared credential groups (
NotificationsSMTP/Twilio,Subtitles,AudioStore, broker key+secret pairs) stay in their Vault buckets and are edited in Vault.Desktop's Credentials section (M.VALT-T62); don't copy them into an app's settings class. - NuGet: the repo's
NuGet.configmust listC:\LocalNuGet; add it if missing. - Elevated exes (ETW, admin tools) can't run
--write-settings-manifestunelevated; seed today's values through the unelevated companion app or a scratch console calling the sameLoad. - Computed properties on a settings class need
[JsonIgnore]or they get written into settings.json. - Case-insensitive file names: an app whose folder already holds
Settings.json(capital S) can't use that folder for Vault'ssettings.json; Windows sees one file. Use the other root (or keep the old file as data). - When the Vault file is the app's existing settings.json, "import once" can't key off the file's absence; detect "not upgraded yet" another way (e.g. a new field missing) and keep a byte-identical
*.pre-lamp.json. - snake_case JSON names need
[ConfigurationKeyName]next to[JsonPropertyName]so deployed IConfiguration values bind. - Imported keys keep their old priority: don't create an assignment that puts an app's old copy ahead of a shared key the app used to prefer; when an app preferred something else first (e.g. a Claude OAuth session), only its assigned keys win and everything else falls back as before.
- Settings databases: when settings live in an app database row (JobHunt, Automata), overlay the Vault values on the row in the store, import from the row once, keep non-setting state (active user, window placement) in the database, and leave the schema alone so exports/imports keep working.
- Development-only config: run
--write-settings-manifestwithASPNETCORE_ENVIRONMENT=Developmentsoappsettings.Development.jsonvalues are imported too. - Library options (MindAttic.Authentication) become a group a host embeds (
MindAtticAuthSettings Auth), bound through the library's section option; one parameterized test case per option is fine for "a test per setting". - Don't edit files with Windows PowerShell 5.1
Get-Content/Set-Content: it re-encodes UTF-8 and garbles non-ASCII text. Use the editor tools, PowerShell 7, or-Encoding utf8on both read and write.
Final verification (M.VALT-T57)
- 2026-10-31: every app migration landed;
mindattic-vault://open?app=<id>selected the right tab for all 23 manifests; 13 apps passed a real cog click and Prose passed via the app's ownVaultSettings.Open(AppId)call; each migrated repo ran its full suite (Prose's two unrelated failures: PRS-T830, PRS-T831). - 2026-11-26 re-check: 24 manifests under
%APPDATA%\MindAtticand%LOCALAPPDATA%\MindAttic; every app source tree with a settings screen still reaches Vault throughVaultSettings. One gap: MediaViewer writes a manifest but has no cog (M.MVIEW-T38). Vault.Desktop's Azure profile has nothing to connect to since MAT-T297 (M.VALT-T126). - The Orchestrator restart is the user's step (CLIs idle,
run.ps1); the full suites run on main by the orchestrator.
Rules while migrating
Work on main in the repo's own checkout (no branches, no worktrees). One ticket per commit, subject ending with the ticket id; commit by path (git commit -m "..." -- <paths>), never git add -A, stash or reset. Don't push. Close the ticket with tickets ticket close <ID> --ref "<hash> <test class>" when every step holds.