MindAttic.Vault/BIBLE
MindAttic.Vault — Project Bible
Single source of truth for what MindAttic.Vault IS, is NOT, and the rules that keep it coherent. README.md says how to build/run and consume the package; this says how to think about the system.
1. The one sentence
MindAttic.Vault is a credentials-and-settings library for .NET that gives every MindAttic host one IConfiguration-backed pipeline for API keys, broker tokens, and per-app preferences — with the %APPDATA%\MindAttic file store as the single local source of truth for every MindAttic host, which now runs local-only (Azure was decommissioned 2026-11-26, MAT-T297); a host outside MindAttic can still wire its own IConfiguration source upstream (Key Vault, App Configuration, ...) with no code change to Vault.
2. The product promise
- One schema, every source. Secrets are defined once under
MindAttic:Vaultand resolve identically from the local APPDATA store and environment variables; Vault itself runs local-only now that Azure is decommissioned (MAT-T297, docs/RELEASE.md), though anyIConfigurationsource a host wires upstream still resolves with no code change. - Cloud-native by default, zero Azure SDK in the core. Vault reads through
IConfiguration; callers wireAddAzureKeyVault(...)(or AWS/GCP equivalents) upstream and Vault picks the values up — no vendor lock-in in the package itself. %APPDATA%keyrings are first-class.providers.jsonkeyrings are surfaced as anIConfigurationSource, so a dev machine's files and a production host's settings share one schema.- Read-only in production, writable on the laptop. Configuration-backed stores throw on writes; settings UIs land in the file-backed fallback only.
- One keyring, many apps. Each app can hold its own key for a provider and fall back to the shared default, without ever changing what another app resolves.
- Runs anywhere. Root resolution works on Windows, Linux, macOS, iOS and Android and never aborts host startup.
- Settings stay roaming, secrets stay cloud-native. Per-app preferences roam via
%APPDATA%; secrets follow the .NET cloud-native convention and live inIConfiguration.
3. What it is NOT
- NOT a secrets manager / vault server. It does not store, encrypt, or serve secrets over a network. It is a resolution and projection layer over sources the host already owns.
- NOT an Azure SDK wrapper. The core package has zero Azure-only dependencies. Key Vault is reached by registering
AddAzureKeyVault(...)upstream of Vault, not by Vault calling Azure. - NOT a User Secrets source. MindAttic projects do not use User Secrets (see M.VALT-LAW-3); the writable APPDATA store is the single local home so a stale CLI value can never mask a freshly-rotated key.
- NOT a runtime secret writer in production.
ConfigurationCredentialStorethrows on writes; production deploys never mutate secrets at runtime. - NOT a UI. It is a class library with no DOM.
MindAttic.Vault.Desktop.Wpfis the one native app where keys and settings are edited (see M.VALT-§4.1);MindAttic.Vault.Dashboardis out of scope (see M.VALT-§4.1). Neither is part of the published package.
4. Architecture canon
consumer host (Program.cs)
|
builder.Configuration.AddMindAtticVaultFiles() ... AddAzureKeyVault()
|
IConfiguration (composed source chain)
|
services.AddMindAtticVault(IConfiguration) <-- DependencyInjection
|
+------------------------+-------------------------+
| | |
LlmCredentialResolver BrokerCredentialResolver JsonSettingsStore<T>
(Composite) (Composite) (per-app settings)
| |
[ConfigurationCredentialStore] -> reads IConfiguration (cloud-native, read-only)
[LlmCredentialStore/BrokerCredentialStore] -> %APPDATA%\MindAttic\<Bucket>\providers.json (writable)
^
MindAtticConfigurationSource projects those same bucket files INTO IConfiguration
per-app BYOK: Composite( AppScopedCredentialStore("<app>", shared), shared )
Read order for any GetKey: explicit DI registration → IConfiguration (Key Vault → env vars → appsettings → AddMindAtticVaultFiles) → file fallback → null. First non-empty trimmed value short-circuits.
4.1 Projects
MindAttic.Vault— the published library (net9.0;net10.0,<Version>9.0.0</Version>,PackageId=MindAttic.Vault). The only thing in the NuGet artifact. The csproj<Version>is the authoritative version; prose never overrides it.MindAttic.Vault.Tests— NUnit suite (net10.0),InternalsVisibleTotarget. Not packable.MindAttic.Vault.Desktop.Core— platform-agnostic app logic for Vault.Desktop (net10.0),InternalsVisibleTo MindAttic.Vault.Desktop.Tests. ReferencesMindAttic.Vault. Not packable; not part of the package.MindAttic.Vault.Desktop.Wpf— RFC 0003 ("LAMP"): the one native app (net10.0-windows, WPF,<Version>1.0.0</Version>) where every MindAttic app's settings and keys are edited. Never network-exposed (no Kestrel, no WebView, no HTTP server); deployed byrun.ps1toR:\MindAttic\Apps\MindAttic.Vault\{Debug,Release}and installed with themindattic-vault://handler. ReferencesMindAttic.VaultandMindAttic.Vault.Desktop.Core. Not packable; not part of the package.MindAttic.Vault.Dashboard— the RFC 0001 Blazor LLM-health-monitor app. Out of scope: Azure was decommissioned (MAT-T297) and the Dashboard is on the "Never in the product" list (SPEC.md §2.2); Vault.Desktop's own key health covers the need and the folder's retirement is the owner's call. NOT inMindAttic.Vault.slnx; NOT part of the package.
4.2 Domain model (NOUNS)
- Bucket — a credential category whose folder name equals its config section (
MindAttic:Vault:<Bucket>):LLM,Brokers,Tokens,Subtitles,Notifications,AudioStore, plus the file-onlyFtp. Cataloged in M.VALT-§9. - Provider — a keyed entry inside a bucket (e.g.
claude,alpaca-paper) holding a typed credential triplet/record. An app-scoped provider id is{appId}-{provider}(e.g.automata-claude). - Key pool — an ordered list of keys for one provider (
CredentialPoolEntry: key + optional label); the first entry is mirrored to the plainapiKeyfield. - Credential — the resolved secret value (apiKey / secret / token) for a provider.
- Source — an
IConfigurationSourceor store the resolution chain walks (APPDATA file, env vars, appsettings, Key Vault, explicit DI). - Setting — a per-app, non-secret preference object persisted as
settings.json(roaming) or under%LOCALAPPDATA%(per-machine).
4.3 Key services (VERBS)
MindAtticConfigurationSource/…Provider(Configuration/) — project APPDATA bucket files intoIConfigurationunder the standard schema; flatten objects/arrays/scalars; optionalReloadOnChange.ConfigurationBuilderExtensions.AddMindAtticVaultFiles()(Configuration/) — register the source on anIConfigurationBuilder.LlmCredentialStore/BrokerCredentialStore/CredentialStore/TokenStore(Credentials/) — read/write the file-backed APPDATA stores (3-tier precedence, atomic write with.bak, type inference).FtpCredentialStore(Credentials/) — read/write the single flat FTP(S) deploy record at%APPDATA%\MindAttic\Ftp\ftp.json(field names match MindAttic.Deploy's existing shape;MINDATTIC_FTP_CREDENTIALSoverrides the directory). File-only; not projected intoIConfiguration.ConfigurationCredentialStore(Credentials/) — read a fixed config section; throws on write.CompositeCredentialStore+LlmCredentialResolver/BrokerCredentialResolver(Credentials/) — chain stores (config → file); writes target the file fallback.AppScopedCredentialStore(Credentials/) — namespace every provider id under{appId}-so many apps share one keyring. Composed in front of the shared store it gives "this app's own key, else the shared default"; writes land only under the app's prefix (per-app BYOK).IRotatingKeyStore(Credentials/) — get/set a provider's key pool. Implemented byCredentialStore(and so the LLM/Broker stores),CompositeCredentialStoreandAppScopedCredentialStore; a single-key provider never gains anapiKeysarray on disk.KeyResolver(Resolution/) — compose an explicit resolution chain for non-DI code.ServiceCollectionExtensions.AddMindAtticVault(...)/AddVaultAppSettings<T>(...)(DependencyInjection/) — register the resolvers/stores in DI.VaultPaths/EnvironmentOverlay(Paths/) — compute the roaming/local roots and overlay env vars onto settings. Root resolution is an ordered chain that never throws (M.VALT-LAW-7):ResolveRoaming()/ResolveLocal()return the path and theVaultRootSourcethat produced it;Describe()prints both for startup diagnostics.VaultPaths.LoggingDbPath(appId)is a second, narrower helper in the same spirit asLocalApp: it names where MindAttic.Log's standaloneMindAttic.Log.dblives for a given app (%APPDATA%\MindAttic\Logging\<appId>\, deliberately roaming so a user clearing an app's local cache can't take its logs with it). Unlike a credential bucket,Loggingis not projected intoIConfigurationand has noproviders.json— see M.VALT-§9.MINDATTIC_VAULT_ROAMING_ROOT/MINDATTIC_VAULT_LOCAL_ROOT, used verbatim;- the matching
Environment.SpecialFolder(the normal answer on Windows, macOS, iOS, Android); - the platform convention from the environment —
%APPDATA%/%LOCALAPPDATA%on Windows,~/Library/Application Supporton Apple,$XDG_CONFIG_HOME/$XDG_DATA_HOME(else~/.config,~/.local/share) on Linux and Android; $HOME/%USERPROFILE%→.mindattic/{config,data};{AppContext.BaseDirectory}/.mindattic/{config,data}.
JsonSettingsStore<T>(Settings/) — load/save/update per-app JSON settings.
5. The Laws
This bible inherits the org-wide House Rules at ../../MindAttic.HouseRules.md by reference — they are not restated here. The directly load-bearing ones for Vault: whole-number versioning (HOUSE-LAW-1), credentials-through-Vault (HOUSE-LAW-3), provider-agnostic LLMs via Legion (HOUSE-LAW-4), and verified-not-asserted done (HOUSE-LAW-8).
Project-specific laws below:
M.VALT-LAW-1 — One schema, every source
Every source surfaces the identical shape under MindAttic:Vault. Section names are constants in VaultConfigurationKeys — never hard-code the strings. The same wiring resolves keys on a laptop, on App Service, and via Key Vault with no code change.
M.VALT-LAW-2 — Folder name == config section
The single on-disk invariant: a bucket's folder under %APPDATA%\MindAttic\ equals its config section's final segment (MindAttic:Vault:<Bucket>). Each file is a faithful image of its config subtree. Never split one credential across two stores.
M.VALT-LAW-3 — APPDATA is the single local source of truth; no User Secrets
The writable %APPDATA%\MindAttic\<Bucket>\ store is the one local home for every credential. Do not add AddUserSecrets(...) or <UserSecretsId> to any MindAttic project — User Secrets ranks above the writable store and could silently mask a freshly-rotated key. Production stays env vars / App Service Application Settings / Key Vault. (Sharpens HOUSE-LAW-3.)
M.VALT-LAW-4 — Read-only in production
ConfigurationCredentialStore throws NotSupportedException on writes. Composite resolvers route writes to the file fallback only — appropriate for a dev laptop, never for a production deploy.
M.VALT-LAW-5 — No Azure SDK in the core package
The published MindAttic.Vault has zero Azure-only dependencies. Key Vault / AWS / GCP are reached by registering their IConfigurationSource upstream of AddMindAtticVault(...). Azure packages appear only in the separate Dashboard app, never in the library.
M.VALT-LAW-6 — Atomic writes, never touch real %APPDATA% in tests
File stores write atomically (temp + swap, .bak retained) and tolerate malformed/empty input by falling back to defaults. Tests redirect every path via env vars (MINDATTIC_VAULT_ROAMING_ROOT, MINDATTIC_LLM_CREDENTIALS, MINDATTIC_BROKER_CREDENTIALS, MINDATTIC_FTP_CREDENTIALS) or temp directories — no test ever reads or writes the developer's real %APPDATA%.
M.VALT-LAW-7 — Root resolution never throws
VaultPaths always returns a rooted, non-blank root via the chain in M.VALT-§4. Vault sits in the IConfiguration chain, so a throw there aborts host construction (e.g. on a Linux App Service worker) before any application code runs. An explicit override env var always wins, and a host that resolves through Environment.SpecialFolder never resolves anywhere else. Every environment dependency is injectable so each platform branch is tested from any OS.
6. Verified state
- Versioning:
MindAttic.Vault.csproj<Version>9.0.0</Version>;MindAttic.Vault.Desktop.Wpf.csproj<Version>1.0.0</Version>— both whole-number compliant (HOUSE-LAW-1). The library is packed to the local family feed; nuget.org still lists only early 0.x versions (publishing there is the next milestone, MS-93). - Build:
dotnet build MindAttic.Vault.slnxbuilds clean onmain. ✅ - Current test evidence, deploy path and the owner's sign-off checks are tracked in docs/RELEASE.md §6, which is refreshed as work lands; this section only pins the version numbers above.
- Dashboard:
MindAttic.Vault.Dashboardis out of scope (see M.VALT-§4.1); not built by the solution, not covered by the test suite.
7. Active frontier
docs/RELEASE.md: the current milestone and its epics. The whole product, built and unbuilt, is in docs/SPEC.md.
8. Quality bar
A change is done (HOUSE-LAW-8) only when:
dotnet build MindAttic.Vault.slnxis clean for bothnet9.0andnet10.0.dotnet test MindAttic.Vault.slnxis green (live-network tests may be skipped, never failing).- Any new public type ships XML doc comments (the package emits
MindAttic.Vault.xml). - New credentials/buckets honor M.VALT-LAW-2 (folder == section) and have a store/ source projection test that redirects
%APPDATA%(M.VALT-LAW-6). - A public-surface change bumps the major version in the csproj (HOUSE-LAW-1).
- The user story carrying the change is
✅only with its verifying test named in USER_STORIES.
9. Glossary
- Bucket — credential category; folder ==
MindAttic:Vault:<Bucket>. Canonical set:LLM—providers.json:{ id: { type, apiKey, apiKeys?, model, maxTokens } }.Brokers—providers.json:{ id: { type, apiKey, secret, baseUrl } }.Tokens—tokens.json: flat{ github: "...", "nuget-org": "..." }.Subtitles—providers.json:{ OpenSubtitles: { user, password } }.Notifications—providers.json:{ email: { smtpHost, smtpPort, username, password, from }, toEmail }.AudioStore—providers.json:{ provider, container, connectionString }.Ftp—ftp.json: one flat FTP(S) record; file-only, read byFtpCredentialStore, not projected intoIConfiguration.Logging— not a credential bucket: a plain roaming-root folder (%APPDATA%\MindAttic\Logging\<appId>\MindAttic.Log.db), one subfolder per app, resolved only viaVaultPaths.LoggingDbPath(appId). Noproviders.json, noIConfigurationprojection, nothing to encrypt — it exists so every app's standalone MindAttic.Log database lives under the shared Vault root instead of each app inventing its own location. See MindAttic.Log's owndocs/BIBLE.md§4 for the sink that writes there.
- Provider — a keyed entry in a bucket (
claude,alpaca-paper, …). - App-scoped id —
{appId}-{provider}(e.g.tutor-claude), written byAppScopedCredentialStore. - Key pool — the ordered keys for one provider (
IRotatingKeyStore); entry 0 mirrorsapiKey. - Resolver — a
CompositeCredentialStorechaining config → file (e.g.LlmCredentialResolver). - Source — an
IConfigurationSource/store in the read chain. - Roaming vs local — roaming settings live in
%APPDATA%; per-machine caches/data in%LOCALAPPDATA%. - Trusted panel — (Dashboard) the gating provider set (
claude,openai,gemini,deepseek) whose votes decide the overall confidence verdict.