Jump to content

MindAttic.Vault/rfc/0003-lamp

From MindAttic Docs

LAMP — MindAttic.Vault.Desktop: one settings & secrets app for the whole workspace

Code name: LAMP. When the user says "LAMP" (in any window, on any login), that means: start implementing this plan.

Step 0 — make LAMP findable from any login (first thing after approval)

This file lives under one login's .claude-accounts folder, so another login can't see it. Before any code:

  1. Copy this plan into the repo as D:\Projects\MindAttic\MindAttic.Vault\docs\rfc\0003-lamp.md and commit it, so it travels with the code.
  2. Add a note to RFC ticket M.VALT-T35: "Code name LAMP — full plan in docs/rfc/0003-lamp.md".
  3. Save a memory in this repo's and MindAttic.Vault's memory: "LAMP = docs/rfc/0003-lamp.md in MindAttic.Vault (M.VALT-T35); 'do LAMP' means start implementing it."
  4. Run /quicksave so /quickload <code> restores the context from any login.

Context

Every MindAttic app with a settings/options screen builds its own (IdiotProof, Tutor, ThinkTank, Prose, Orchestrator, JobHunt, MediaButler, Browser, TaxRateCollector, ...), and each stores keys its own way. LLM keys get re-entered per app. A new user can't get going without hand-configuring every app.

RFC 0002 (M.VALT-T26, now wont-do) tried to fix this with a split Vault.Web + Vault.Desktop pair. Rejected: a web-hosted settings editor is a standing attack surface for credential-adjacent data, and running a web app locally just to edit settings is pointless.

Outcome wanted:

  • One native WPF app, MindAttic.Vault.Desktop, never network-exposed, is the only place any app's settings or secrets are edited.
  • Profiles: Desktop (local AppData) and Azure (Key Vault + App Configuration), with more to come. Same tabs and fields in every Profile; only the backend changes. On the Azure Profile, Load pulls the live values into the fields and Save writes them back, so you never use the Azure portal.
  • LLM keys shared across every app through Vault, with several keys per provider you can switch between when one stops working.
  • Remembers its last state (Profile, tab, selected keys, window).
  • First run works out of the box: every non-secret setting has a shipped default, so a new user only brings their own keys (BYOK).
  • Every app's own settings screen goes away; its cog opens Vault.Desktop at its tab.

What already exists (reuse, don't rebuild)

Vault core (D:\Projects\MindAttic\MindAttic.Vault\MindAttic.Vault\):

  • Credentials\ICredentialStore.cs — secrets contract; file implementations (CredentialStore, LlmCredentialStore, BrokerCredentialStore, FtpCredentialStore, TokenStore), read-only ConfigurationCredentialStore (how Key Vault reaches apps today, via IConfiguration), CompositeCredentialStore (read first non-null, write first writable), AppScopedCredentialStore.
  • Credentials\IRotatingKeyStore.cs — key pools already exist and are already on the LLM path: CredentialPoolEntry(string Key, string? Label), GetKeys(providerId) in priority order, SetKeys(...). GetKey = first entry (CredentialStore.cs:70). Stored as apiKeys: [{key,label}] in providers.json only when a provider has more than one key (single-key files unchanged). LlmCredentialStore and LlmCredentialResolver (Composite: Configuration over File) both implement it. Missing: per-key health (disabled / last failure / last success) and any automatic failover — callers today only ever use key 0.
  • Settings\JsonSettingsStore.cs — concrete, no interface. Load() returns new T() when the file is missing/empty/corrupt (never null, never throws). No seed hook; defaults come only from property initializers on T. MediaButler's SettingsService is the one app that writes those defaults to disk on first run.
  • DependencyInjection\ServiceCollectionExtensions.cs:107 — AddVaultAppSettings<T> (where T : class, new()), AddMindAtticVault(), AddMindAtticVault(IConfiguration).
  • Paths\VaultPaths.cs — roaming/local roots with MINDATTIC_VAULT_ROAMING_ROOT / _LOCAL_ROOT overrides; VaultPaths.LoggingDbPath(app).
  • Laws (docs\BIBLE.md): LAW-1 one schema, every source · LAW-2 folder name == config section · LAW-3 APPDATA is the single local source of truth; no User Secrets · LAW-4 read-only in production · LAW-5 no Azure SDK in the core package · LAW-6 atomic writes, never touch real %APPDATA% in tests · LAW-7 root resolution never throws.

Security conventions in use:

  • Secrets are never put on any display or log path; output says only whether it's set and where it came from (IdiotProof Operations\Llm\LlmKeysOperation.cs "Keys are never displayed"; KeysStatusOperation.cs shows only a 4-char prefix of a key id). No shared masking helper exists.
  • Diagnostic logging: MindAttic.Log via Serilog (WriteToMindAtticLog, AddMindAtticLog).
  • Audit ("who changed what, when"): a separate append-only store, not the diagnostic log — IdiotProof Core\Data\AuditLog.cs + Core\Services\AuditLogRepository.cs (write failures logged, never thrown; overflow kept in DataJson).
  • Azure SDK versions in the workspace: Azure.Identity 1.21.0 (current; Vault.Dashboard's 1.13.1 is stale), Azure.Security.KeyVault.Secrets 4.11.1 (MindAttic.Ideas.Blazor). No Azure.ResourceManager.* or Azure.Data.AppConfiguration anywhere yet.
  • No reveal-on-demand secret control exists in Components (no MaPasswordBox/MaSecretField).
  • No remembered-UI-state convention exists in any WPF app.

Test conventions in use:

  • One *.Tests project per source project. Vault and IdiotProof use NUnit ([TestFixture]/[Test]/Assert.That); MindAttic.Components uses xunit.
  • WPF control tests (MindAttic.Components\dotnet\tests\MindAttic.Components.Wpf.Tests\, e.g. MaTabStripTests.cs:231): a real STA thread per test with its own Dispatcher, Host.Pump() to flush, windows from OffScreenWindow.cs so nothing flashes on screen (enforced by TestWindowHygieneTests.cs).
  • Razor tab tests: IdiotProof.Blazor.Tests\IdiotProofSettingsTabTests.cs — NUnit + bunit 2.11.3, JSInterop.Mode = Loose, in-memory EF, WaitForAssertion.
  • Fake HTTP: subclass HttpMessageHandler and script responses — reusable version at Automata\Automata.Tests\Fakes\ScriptedHttpMessageHandler.cs; also IdiotProof.Brokers.Tests\AlpacaApiTests.cs. Azure SDK clients accept it through ClientOptions.Transport = new HttpClientTransport(handler).
  • Vault file tests: MindAttic.Vault.Tests\TempDirectory.cs (GUID temp folder, deleted on dispose) + VaultPaths env overrides; JsonSettingsStoreTests.cs, CredentialStoreTests.cs, CompositeCredentialStoreTests.cs already cover today's stores.
  • CI: no dotnet test workflow in Vault, Components or Tickets (only docs workflows). Tests run locally / via /test.

Components (D:\Projects\MindAttic\MindAttic.Components\dotnet\src\MindAttic.Components.Wpf\):

  • Controls\MaTabControl.cs (tabs with accent, trailing badge, status light), MaModal, MaMessageBox, MaToast/MaToastHost, MaPicker (status-aware combo), MaTextBox placeholder + MaTextBox/MaTextArea styles, button styles, MaTheme (live dark/light), MaWindow (themed title bar), MaBadge, MaStatusLight, MaLayout, MaToolTips.KeepOpen().
  • Mvvm\ObservableObject, RelayCommand, CollectionSync.SyncBy (in-place diff of a bound collection; drives Orchestrator's dynamic tabs).
  • Gaps: no MaCheck/checkbox style, no AsyncRelayCommand, no IUiDispatcher, no masked-secret field.

Host-app patterns to copy:

  • Orchestrator src\MindAttic.Orchestrator.Core\Setup\SingleInstance.cs — named mutex + show-event + per-user named pipe for argument hand-off. Reuse for "cog opens Vault.Desktop at my tab".
  • Orchestrator src\MindAttic.Orchestrator.Wpf\ViewModels\MainViewModel.Tabs.cs — runtime tab list via SyncBy bound to MaTabControl.
  • Tickets Desktop TicketsLog.cs — Serilog → MindAttic.Log, VaultPaths.LoggingDbPath(app).
  • App.OnStartup wires DispatcherUnhandledException, AppDomain.UnhandledException, TaskScheduler.UnobservedTaskException.
  • Publish: self-contained single-file win-x64 via run.ps1.
  • No DI container in existing WPF apps (manual composition). No tray pattern exists anywhere.

Earlier work: the M.COMP-T153 open-my-settings helper is marked closed but its code was reverted in Components a9391c4, so it gets re-filed. IdiotProof ccd6119 extracted /settings into the IdiotProof.Settings Razor library; manifest-generated tabs make it unnecessary and its migration removes it.

Decisions (from the user, 2026-10-31)

  • LLM keys: one shared, named list of keys per provider for the whole workspace (e.g. ClaudeApiKeys["key1"], ClaudeApiKeys["2026-10-31 IdiotProof"]). An app overrides by picking which named key(s) from that list it uses — never by holding its own copy of a key.
  • Everything is Name/Value: every setting and every key has one readable full name that is the same in the UI, the local files, App Configuration and the deployed app's IConfiguration.
  • A key that fails (401/403/quota): apps fail over to the next key automatically, and the bad key is flagged in Vault.Desktop.
  • First-run defaults live in each app's own settings class (property initializers); Vault writes them to disk on first run.
  • App tabs are generated from each app's settings manifest (no app UI code inside Vault.Desktop).
  • Local keys stay plain text in providers.json (no DPAPI); protection is the user's Windows profile folder permissions.
  • Delivery: everything at once — Desktop and Azure Profiles, key pools, first-run, every app migrated. Work is still ordered by dependency (phases below); nothing ships half-done.

Amendments (2026-10-31, during implementation)

These supersede anything below that disagrees.

  • Exe name: MindAttic.Vault.Desktop.Wpf.exe.
  • Deep links: a cog opens the app's tab and scrolls to one setting: --app <id> [--setting <full name>]. Every setting is one full-width row.
  • Collections: list-of-object settings (profiles, users) get Add / Remove / Edit, generated on the fly from the manifest by MindAttic.Components (M.COMP-T159); no app UI code runs in Desktop.
  • Web apps: a locally hosted web app calls VaultSettings.Open server-side over the current-user-only pipe; a deployed one renders VaultSettings.Link (mindattic-vault://open?app=&setting=, a per-user protocol handler, M.VALT-T56). Azure changes are made by Desktop's Azure Profile under the operator's sign-in. Still no network listener.
  • VaultSettings.Open lives in Vault core (M.VALT-T58), not Components, so Blazor and console apps can call it.
  • JSON layout: one %APPDATA%\MindAttic\{AppId}\settings.json per app plus Global\settings.json, keys in their own files, all exposed as one IConfiguration tree by AddMindAtticVaultConfiguration() (M.VALT-T55). Per-app files avoid cross-app write races and contain corruption to one app.
  • Names keep Vault's existing schema (M.VALT-LAW-1) and avoid colliding with sections apps already have in appsettings.json: settings are MindAttic:Settings:{AppId}:{property}; keys MindAttic:Vault:LLM:{provider}:keys:{name} with keyOrder/disabledKeys; assignments MindAttic:Vault:Assignments:{AppId}:{provider}:{i}. Full table in lamp-migration.md.
  • Today's data: every non-broker key stays in the LLM bucket (ElevenLabs, fal, maps keys already live there). Alias entries already on disk (xai, anthropic) are kept and mirrored with the same list rather than collapsed, so an app still reading the alias is unaffected. .key override files lead the list and are folded into the pool (renamed .key.imported) on the first edit.
  • App-scoped copies move automatically on the app's first start (KeyImporter.ImportAppScopedFor); env vars and legion.json keys are offered on Get Started.
  • Done means: every app migrated in one effort, today's values imported and organized, a separate test per setting, every app's cog opens its tab, full suites green, and restarting MindAttic.Orchestrator leaves every app working as before (M.VALT-T57).

Design

0. What counts as a setting (scope line)

Vault.Desktop owns every app-level and machine-level setting and every key — anything one person configures once for an install or a deployment. It does not own data that belongs to the app's own users or content, because a single-person desktop tool can't sensibly edit another user's data:

  • IdiotProof per-user SettingsKv / UserPreferences (each trader's own limits) — stays in IdiotProof's UI; IdiotProof's app-level settings move.
  • Prose per-universe Setting rows — stays in Prose; Prose's app-level settings move.
  • MindAttic.Ideas site and widget-instance settings (CMS content) — stays in Ideas; its app-level settings move.
  • JobHunt (single-row SQLite AppSettings) and Orchestrator (JsonStore in its db) are single-machine: their settings move entirely to Vault (JsonSettingsStore), with a one-time import from the database on first run.

Each migrated app keeps a settings screen only for user/content data; the cog for app-level settings opens Vault.Desktop.

MindAttic.Vault (core NuGet, no Azure SDK, no UI)          used by every app
  ISettingsStore<T>, JsonSettingsStore<T> (Desktop backend)
  settings manifest: [Setting]/[SettingsApp] attributes -> settings.manifest.json
  LoadOrSeed (first-run defaults), key pools + key health + KeySelector (failover)
  ConfigurationCredentialStore learns named key lists + app assignments (Azure read path)

MindAttic.Components.Wpf (NuGet)                            shared UI
  + MaSecretBox, + AsyncRelayCommand, + MaCheck style (M.COMP-T121)

MindAttic.Vault.Desktop (WPF exe, in the Vault repo, not packaged)   the only editor
  Profiles: DesktopProfile, AzureProfile (Azure SDKs live only here)
  tab per app, generated from that app's manifest
  Keys tab: shared provider pools, health, per-app overrides
  Get Started checklist (BYOK), remembered state, audit log

1. One settings contract in Vault core

  • Extract ISettingsStore<T> (Exists, Load, LoadAsync, Save, SaveAsync, Update, plus LoadOrSeed) from JsonSettingsStore<T>. JsonSettingsStore<T> implements it unchanged. AddVaultAppSettings<T> registers the interface.
  • LoadOrSeed(): if the file doesn't exist, save new T() (the app's property-initializer defaults) atomically and return it. This is MediaButler's SettingsService.Load() pattern moved into Vault so every app gets it. Existing files are never overwritten.
  • No secret ever lives in a settings class. Secrets stay in credential stores (that's already how Vault is built; now it's a rule with a test).

2. Settings manifest — tabs are generated, not hand-built per app

Instead of each app shipping its own settings screen (Razor or WPF) for Vault.Desktop to host, each app describes its settings and Vault.Desktop renders them. Reasons: the user said every field is fixed per app; no app UI code ever runs inside the secrets app; no BlazorWebView (no browser engine in the secrets app); Desktop never has to be rebuilt when an app adds a setting; works the same for WPF, Blazor and console apps.

  • Attributes in Vault core: [SettingsApp(Id, DisplayName, Icon)] on the settings class; [Setting(Label, Group, Help, Order)] on properties; optional [Range], [Choices], [PathPicker(File|Folder)], [Url], [Multiline]. Field kind is inferred from the property type (string, bool, int/decimal, enum, string list, path, url, TimeSpan).
  • [UsesCredential(ProviderId, Required, Purpose)] on the settings class declares which key pools the app needs (e.g. claude, openai, alpaca). This drives the Get Started checklist and the app tab's "Keys used" section. No key value ever appears in the manifest.
  • On every startup, AddVaultAppSettings<T> (or LoadOrSeed) writes settings.manifest.json next to settings.json in the app's bucket: schema version, app id, fields, defaults, credentials used. Atomic write; only rewritten when content changes.
  • Vault.Desktop discovers apps by scanning %APPDATA%\MindAttic\*\settings.manifest.json and keeps the tab list in sync with CollectionSync.SyncBy (Orchestrator's MainViewModel.Tabs.cs pattern).
  • An app that hasn't run yet has no manifest. Each app's install/run.ps1 runs it once with --write-settings-manifest (seed + manifest, then exit) so a fresh ecosystem install shows every app immediately.
  • Extending: a new field kind = one IFieldEditor (a DataTemplate + a value converter) registered in Desktop. Nothing else changes.

3. Names, and LLM keys shared across all apps (named keys, selection, health, failover)

Naming (Name/Value everywhere). Every value has one canonical name in IConfiguration path form, Section:Name:

  • App settings: {AppId}:{Property} — e.g. IdiotProof:MaxLossPerTrade = 50. The local settings.json keeps today's JSON shape, whose paths are exactly these names, so existing files and code don't change.
  • Keys: Llm:{provider}:ApiKeys:{keyName} = <secret> — the user's ClaudeApiKeys["2026-10-31 IdiotProof"] is Llm:claude:ApiKeys:2026-10-31 IdiotProof. Key names are free text you choose (trimmed, unique per provider, no :), shown everywhere; they are the key's identity.
  • Which keys an app uses: {AppId}:Keys:{provider} = ["2026-10-31 IdiotProof", "key1"] — a non-secret ordered list of key names; the first is the app's active key, the rest are its fallbacks. Missing = use the shared list in its default order.
  • Desktop shows every field's full name (copyable) next to its label, so any value can be found by name in files, App Configuration or logs.

Named key lists.

  • The existing LlmCredentialStore bucket becomes the workspace-wide named list per provider. CredentialPoolEntry's Label becomes the required, unique Name (old unlabeled entries are named key1, key2... on first load), plus an optional Disabled flag. providers.json stays back-compatible: single-key and today's apiKeys:[{key,label}] files both load.
  • Order of the shared list = default failover order. Rename keeps the key's health and every app's selection pointing at it (Desktop rewrites the references in one atomic operation and audits it).
  • Keys are managed only on the Keys tab; apps are assigned keys on their own tab. Each app tab has a "Keys" section with one row per provider the app uses ([UsesCredential]): an Active key picker (MaPicker listing the provider's key names, each with its status light) and an optional ordered Fallback keys list. Choosing 2026-10-31 IdiotProof stores only names: IdiotProof:Keys:claude = ["2026-10-31 IdiotProof", ...fallbacks] (first = active). "Use shared default" clears the assignment. Deleting a key that an app still has assigned is blocked with "assigned to IdiotProof, Tutor" until you reassign. No secret is ever copied per app (replaces the old AppScopedCredentialStore override idea).
  • Resolution in apps: KeySelector reads the app's selected names (or the shared order), then the values from the shared list.

Provider catalog (one list for everyone). Vault core gets a static ProviderCatalog: id, display name, category (LLM, broker, media, TTS, other), key-page URL, aliases. Canonical LLM ids from the inventory: claude (alias anthropic), openai, gemini (alias google), deepseek, kimi, mistral, grok (alias xai), groq, perplexity, cohere, openrouter, ollama; non-LLM: alpaca (broker), elevenlabs (TTS), jellyfin (media). Aliases resolve on read, so anthropic and claude keys merge into one list. The Keys tab groups by category, so non-LLM keys (Alpaca, ElevenLabs, Jellyfin) get the same named-list treatment. Legion's provider list is reconciled to this catalog.

Migrating today's per-app key copies. Automata, MediaButler, Tutor, IdiotProof, JobHunt and TaxRateCollector wrap the keyring in AppScopedCredentialStore today. On first run of the new Vault, each app-scoped key is moved into the shared list (named {app} (imported), deduplicated if the value already exists under another name) and set as that app's active key. Behavior is unchanged and no copies remain. Same for keys in .key override files, env vars the apps read today (JF_API_KEY, ELEVENLABS_API_KEY) and legion.json: the import is offered on the Get Started screen, never silent.

Key health is observed state, kept separately: %LOCALAPPDATA%\MindAttic\Vault\key-health.json keyed by {provider, keyName} (never the key or a hash of it): last success, last failure, failure kind, cool-down-until. Written atomically (LAW-6), shared by every app on the machine, so a key one app finds broken is skipped by all.

  • KeySelector (new, core): ExecuteAsync(providerId, appId, Func<string key, Task<T>> call) tries the app's active key, then its fallbacks in order (or the shared order when the app has no assignment), skipping disabled and cooling-down ones. It classifies the result: auth failures (401/403) mark the key failed (needs you), quota/429 sets a cool-down (honors Retry-After), network errors don't blame the key. On success it records health and returns. When every key fails it throws one AllKeysFailedException listing providers and failure kinds, never keys. Apps call LLMs through this instead of GetKey().
  • Desktop's Keys tab: one section per provider listing its named keys in default order (drag to reorder) — name, masked value (MaSecretBox), status light (healthy / cooling down / failed / disabled / never used), last used, "used by" apps, Test (one cheap authenticated call through the same classifier), add / rename / disable / remove.

4. Profiles

  • IProfile { Id, DisplayName, bool IsReady, ISettingsBackend For(AppManifest), IRotatingKeyStore Keys(appId) }. Registered in Desktop; the profile picker binds to the list. A future platform is one new class.
  • Desktop Profile: JsonSettingsStore<T> (untyped JSON variant driven by the manifest, since Desktop doesn't reference app assemblies) and the file credential stores.
  • Azure Profile: one environment = (app → Key Vault + App Configuration store) mappings, picked once per app through the resource picker and remembered.
    • Sign-in: InteractiveBrowserCredential with a persisted, OS-encrypted MSAL token cache (TokenCachePersistenceOptions), so you sign in once. Your own identity; no secrets stored by Desktop for Azure access.
    • Picker: Azure.ResourceManager lists subscriptions → resource groups → Key Vaults / App Configuration stores.
    • Names live in App Configuration, secret values live in Key Vault. Every name from section 3 is an App Configuration key with exactly that name (App Configuration allows spaces, so Llm:claude:ApiKeys:2026-10-31 IdiotProof is stored as-is). Plain settings hold their value; key entries hold a Key Vault reference to the secret. ETag optimistic concurrency on every write.
    • Key Vault secret names only allow letters, digits and dashes, so each secret gets a generated name (llm-claude-<slug>-<6-char id>) and carries the readable key name in a name tag. You never see or type it; App Configuration's reference maps the readable name to it. One naming function, contract-tested. Save writes a new secret version; rename only changes the App Configuration key and the tag.
    • Deployed apps stay read-only (LAW-4) and read everything by name through IConfiguration using the App Configuration provider with Key Vault reference resolution, wired by the host (LAW-5: the core package still has no Azure SDK). ConfigurationCredentialStore gains named-key-list reading (Llm:{provider}:ApiKeys:*) and app selections ({AppId}:Keys:{provider}), so selection and failover behave the same in Azure as locally.
    • Missing RBAC role (Key Vault Secrets Officer / App Configuration Data Owner) gets a plain explanation of which role is needed on which resource, not a stack trace.
    • After Save, Desktop says when the app will see it (App Configuration refresh vs restart).
  • Load / edit / Save is identical in every Profile. Dirty tracking per field; Save writes only changed fields; Revert reloads.

5. Remembers its state

VaultDesktopState (non-secret) via JsonSettingsStore<VaultDesktopState> in the Vault.Desktop bucket: last Profile, last tab, window bounds (clamped to a monitor that still exists), theme, collapsed groups, Azure environment mappings. Saved debounced on change and on exit. Corrupt/missing file → defaults (that's JsonSettingsStore's existing behavior).

6. First run / BYOK

  • Every app seeds its own defaults (LoadOrSeed) and writes its manifest, so nothing is blank except keys.
  • Desktop opens on Get Started when any required credential ([UsesCredential(Required=true)]) has no key: one row per provider ("Claude — needed by Tutor, Prose, IdiotProof"), a key field, a link to that provider's key page, and Test. Done when every required provider has a working key; it then never shows again unless a required key goes missing.

7. Opening from an app

  • Re-file the open-my-settings helper (M.COMP-T153's code was reverted in Components a9391c4): VaultSettings.Open(appId) launches or activates Vault.Desktop at that app's tab.
  • Single instance: copy Orchestrator's SingleInstance.cs (named mutex + show event + PipeOptions.CurrentUserOnly pipe). Desktop accepts exactly one argument shape, --app <id>, length-capped, validated against discovered manifests; anything else is ignored and logged.
  • Each app deletes its own settings screen/route/window and points its cog at the helper.

8. Composition and code layout

  • Desktop uses Microsoft.Extensions.DependencyInjection (no Generic Host). Existing WPF apps hand-compose, but Vault already exposes IServiceCollection extensions and DI makes every ViewModel testable with fakes.
  • MVVM on MindAttic.Components.Wpf.Mvvm (ObservableObject, RelayCommand, new AsyncRelayCommand). Views are DataTemplates keyed by ViewModel type in App.xaml.
  • Startup copies the house pattern: MaToolTips.KeepOpen(), three unhandled-exception hooks, Serilog → MindAttic.Log (TicketsLog.cs shape), MaTheme, MaWindow.SetThemedTitleBar.
  • Publish like the other apps: self-contained single-file win-x64 via run.ps1.

Security

Threat model: local malware/other users on the machine, accidental leaks (logs, screenshots, clipboard history, crash dumps, git), a compromised app on the ecosystem, Azure credential misuse.

  1. No network listener, ever. No Kestrel, no WebView, no HTTP server. Only outbound HTTPS to Azure and to LLM providers for Test. Pipe is CurrentUserOnly and accepts only --app <known id>.
  2. Secrets are write-mostly in the UI. New MaSecretBox (Components): masked by default; Reveal needs a click and hides again after 30 s or when focus/window changes; the automation/accessibility name never contains the value; Copy puts the value on the clipboard excluded from clipboard history/cloud sync and clears it after 30 s. Values are held only in the edit buffer, never in a bindable string property that logging or diagnostics could read.
  3. Never logged. A Serilog destructuring/enricher policy redacts anything typed as a secret; audit and diagnostic messages carry field names and key Ids, never values or hashes. Canary-secret tests enforce it (Testing #6).
  4. Audit. Every Save appends one entry: time, Windows user (and Azure UPN on Azure), Profile, app, fields changed (secrets as "changed", no value). Append-only SQLite at VaultPaths local Vault\audit.db with insert-only triggers (the Tickets DB technique). Audit write failures are logged, not thrown (IdiotProof AuditLogRepository convention). Azure writes also land in Azure's own Key Vault/App Configuration logs.
  5. Local keys at rest: plain text, by decision. providers.json stays readable JSON under %APPDATA%\MindAttic\. Desktop checks at startup that the Vault folders aren't readable by other users or Everyone (a too-open ACL shows a warning with a one-click fix), and keys are never written anywhere else locally (no state file, temp file, log or crash dump).
  6. Least privilege on Azure. Your own identity, interactive sign-in, OS-encrypted token cache; the exact RBAC roles are documented; production apps keep managed-identity read-only access (LAW-4).
  7. Concurrency and integrity. Atomic writes (LAW-6); file watcher warns when another process changed a file you're editing; ETags on App Configuration; Azure Save shows a confirm listing changed field names (never values).
  8. Input handling. Values are validated by kind (Range, Url, Path) before Save; path pickers don't follow into other users' profiles; manifests are parsed with size limits and unknown kinds render read-only rather than crash.
  9. Supply chain. Exact package versions: Azure.Identity 1.21.0 (match the workspace), Azure.Security.KeyVault.Secrets 4.11.1 (match MindAttic.Ideas), current stable Azure.Data.AppConfiguration, Azure.ResourceManager, .KeyVault, .AppConfiguration pinned exactly. Only Vault.Desktop references them.
  10. Crash safety. Unhandled-exception handlers log type/message/stack only; no ViewModel dumps.

Testing

All NUnit except Components (xunit), matching each repo.

  1. MindAttic.Vault.Tests
    • An abstract SettingsStoreContract fixture (load missing → defaults, seed writes once and never overwrites, round-trip, corrupt → defaults, atomic write) run against JsonSettingsStore<T>, the manifest-driven JSON store and the App Configuration store (fake HTTP).
    • Manifest: attributes → manifest JSON (kinds, defaults, groups, credentials used), unchanged content isn't rewritten, schema version present, no secret-typed property allowed on a settings class (fails the build test).
    • Named keys: old single-key and apiKeys files both load and unlabeled entries become key1, key2...; names unique per provider, : rejected; rename moves health and every app's selection atomically; delete blocked while selected; Disabled round-trips; the on-disk format stays plain JSON readable by older Vault versions for single-key providers.
    • Catalog: anthropic→claude, google→gemini, xai→grok merge into one list; unknown ids still work as their own provider.
    • Import: an AppScopedCredentialStore key becomes {app} (imported) and that app's active key; a value already present under another name is reused, not duplicated; running import twice changes nothing.
    • Selection: app with no selection uses shared order; app selecting ["2026-10-31 IdiotProof","key1"] uses exactly those in that order; a selected name that no longer exists is skipped and reported.
    • KeySelector: 401 → next key and key marked failed; 429 + Retry-After → cool-down; network error → key not blamed; disabled skipped; all fail → AllKeysFailedException without key text; health file written atomically and never contains a key.
    • Names: every manifest field's full name equals its IConfiguration path; ConfigurationCredentialStore reads named key lists and selections from config; Key Vault secret-name generation is valid for any key name (spaces, unicode, long) and stable.
    • Reuse TempDirectory.cs and VaultPaths env overrides (LAW-6: never real %APPDATA%).
  2. MindAttic.Vault.Desktop.Tests (new, ViewModel level, no window): tab sync from manifests, Profile switch reloads every tab from the new backend, dirty tracking and Save of only changed fields, Revert, Get Started appears/disappears correctly, state saved/restored (incl. off-screen window clamp), argument validation for --app, audit entry per Save. Fake IProfiles and in-memory stores.
  3. Azure Profile: Key Vault and App Configuration stores against ScriptedHttpMessageHandler (copy Automata.Tests\Fakes\ScriptedHttpMessageHandler.cs) via ClientOptions.Transport: new secret version on Save, ETag conflict surfaced, 403 → role explanation, picker paging. A separate [Category("AzureLive")] suite runs only when MINDATTIC_VAULT_AZURE_TEST_* env vars point at a throwaway subscription.
  4. MindAttic.Components.Wpf.Tests (xunit, STA + OffScreenWindow like MaTabStripTests.cs): MaSecretBox masked by default, Reveal/auto-hide, automation name has no value, Copy clears; AsyncRelayCommand can-execute while running and error surfacing; MaCheck style.
  5. Each migrated app: its settings class produces a manifest with every field labeled; LoadOrSeed seeds the expected defaults; LLM calls go through KeySelector (fake handler: first key 401 → second key used); old settings page/route is gone.
  6. Leak tests: a canary secret value is pushed through every store, Save, audit, log and state path; tests assert it appears in none of the log DB, audit DB, state file, manifest or exception messages.

Rollout / tickets

Delivered together, built in this order (each step depends on the one before):

  1. Vault core: ISettingsStore<T> + LoadOrSeed (M.VALT-T36); manifest attributes/writer; named keys (Name + Disabled) and app assignments; key health + KeySelector; ConfigurationCredentialStore named keys and assignments. Publish next major MindAttic.Vault (HOUSE-LAW-1 whole numbers).
  2. Components: MaSecretBox, AsyncRelayCommand, MaCheck (existing M.COMP-T121), re-filed open-my-settings helper. Publish next major MindAttic.Components.Wpf.
  3. Vault.Desktop: scaffold (M.VALT-T37), tab host + Profile switcher (M.VALT-T38), single instance (M.VALT-T39), Keys tab, Get Started, remembered state, audit.
  4. Azure Profile: resource picker (M.VALT-T40), Key Vault store (M.VALT-T41), App Configuration store (M.VALT-T42).
  5. Every app (one ticket per app). Each one: move to the new Vault major (apps are on 1.0–6.0 today), put its app-level settings in one [SettingsApp] class read through ISettingsStore<T>/LoadOrSeed (with a one-time import from wherever they live now), declare [UsesCredential]s, resolve keys through KeySelector and the shared named lists, add --write-settings-manifest to its run script, remove its app-level settings UI and point its cog at Vault.Desktop.
    AppSettings UI to remove / today's storage to importKeys
    TutorTutor.Shared\...\Settings.razor; ISecurePreferences / secure-preferences.jsonclaude, openai, gemini, deepseek, kimi (scoped copy → import)
    ThinkTankSettings.razor, SettingsAppearance.razor; %LOCALAPPDATA%\MindAttic\ThinkTank\Settings.jsonclaude/anthropic, openai, gemini, deepseek, kimi
    IdiotProofPages\Settings.razor app-level parts; drop IdiotProof.Settings RCL (ccd6119); per-user SettingsKv staysclaude, openai, gemini, deepseek, mistral; alpaca
    MindAttic.OrchestratorSettingsViewModel modal; OrchestratorSettings/GatewaySettings from its dbclaude, gemini, kimi, mistral (BillingSwitch, Gateway VaultSecrets)
    ProseProse.WriterUi\...\SettingsPanel.razor app-level parts; per-universe rows stay~14 providers
    JobHuntsettings area in JobHunt.App\MainWindow.xaml; SQLite AppSettingsclaude, openai, gemini, kimi (ByokKeys)
    MediaButlerMediaButler.Wpf.UI\Pages\Settings.razor + SettingsEditor.cs; already JsonSettingsStoreclaude (scoped copy → import)
    MindAttic.BrowserSettingsWindow.xaml; already JsonSettingsStorenone today (uses a "claude" string)
    TaxRateCollectorSettings.razor; settings.json via own serviceclaude/anthropic
    Automatasettings area in Automata.App\MainWindow.xaml; AutomataSettingsStoreclaude, openai, gemini, kimi (scoped copy → import)
    MindAttic.Launcherconsole Menus\SettingsMenu.cs (becomes "Open settings"); already JsonSettingsStoreclaude, gemini, grok, kimi (+ KimiConfigSync)
    OpenCredentialsv2\Blazor\...\Settings.razor; Settings.cs (Vault 1.0)own anthropic/openai store → import
    MindAttic.IdeasAdmin\SettingsPanel.razor app-level parts only; CMS site/widget settings staynone
    MindAttic.CaptureTray\SettingsForm.cs; %LOCALAPPDATA%\MindAttic\Capture\tray.jsonnone
    MindAttic.Tickets.Desktop(no page) desktop.json → manifest + importnone
    MindAttic.Log (Reader), Unstuckno UI; already JsonSettingsStore → manifest onlynone
    MindAttic.Legion, Gadflylegion.json; Legion resolves keys through KeySelector, Gadfly inheritsall LLM providers
    MindAttic.Psst, ProcessLogger, Formicarium Dashboard, Unity.Multiplayer Hosting.Cli, MindAttic.Authentication, Cursoryconfig file / appsettings.json → manifest for what's user-configurablenone
    JellyFinPoster, Claudiaenv vars → Keys tabjellyfin, elevenlabs

    Out of scope: MindAttic.Deploy (CLI arguments only) and the repos with no settings or keys.

Ticket housekeeping:

  • M.VALT-T35 (RFC): replace its description with this plan's summary and point it at docs/rfc/0003-lamp.md.
  • M.COMP-T154 (dual Razor/WPF tab contract): close wont-do, superseded by manifest-driven tabs.
  • File new tickets for: provider catalog + aliases, key import from app-scoped copies/env/legion.json, manifest, named keys + app assignments, key health + KeySelector, config named keys, folder-ACL check, audit, Keys tab, Get Started, remembered state, MaSecretBox, AsyncRelayCommand, open-my-settings helper, and one migration ticket per app — each linked part-of M.VALT-T35.
  • IdiotProof ccd6119 (IdiotProof.Settings Razor library): no longer needed once its tab is manifest-generated; its migration ticket removes it.

Verification

  1. dotnet test in MindAttic.Vault, MindAttic.Components and each migrated app: all green, including the leak tests.
  2. Fresh-machine run (point MINDATTIC_VAULT_ROAMING_ROOT/_LOCAL_ROOT at empty temp folders): run each app's --write-settings-manifest, open Vault.Desktop → every app has a tab with defaults filled in and Get Started lists only the missing keys. Enter one Claude key, Test → healthy, checklist done.
  3. Failover: add a deliberately bad key first and a good key second; run an LLM call from one app → it succeeds on key 2, key 1 shows failed in Desktop, and the audit/log contain no key text.
  4. Remembered state: change Profile, tab, window size; close; reopen → restored.
  5. Cog: click an app's cog with Desktop closed (opens at that tab) and open (activates and switches tab).
  6. Azure Profile on a throwaway resource group: sign in once, pick resources, Load shows live values, edit and Save, confirm the deployed app reads the new value after refresh/restart; remove your role → clear role message.
  7. Security spot checks: netstat shows no listening port for Vault.Desktop; Windows clipboard history doesn't contain a copied key; loosening the Vault folder ACL triggers the warning; searching the log DB, audit DB, state file and manifests for a test key finds nothing.
  8. Assignment: on the Keys tab add 2026-10-31 IdiotProof; on IdiotProof's tab set it as Active key; IdiotProof's next LLM call uses it (audit shows the assignment, never the value); try deleting the key → blocked with "assigned to IdiotProof".
From MindAttic.Vault/docs/rfc/0003-lamp.md via MindAttic.Docs; synced automatically, so edit the repo, not this page.