Jump to content

MindAttic.Vault

From MindAttic Docs
Revision as of 02:51, 2 December 2026 by Docs Sync (talk | contribs) (md2wiki: sync from MindAttic.Docs)

MindAttic.Vault — Overview

MindAttic.Vault is the one home for keys and settings across every MindAttic app. It has two parts:

  • The MindAttic.Vault library (net9.0;net10.0, package version 9.0.0, packed to C:\LocalNuGet). It gives every app one IConfiguration-backed pipeline for API keys, broker credentials, tokens and per-app settings, with %APPDATA%\MindAttic as the single local source of truth.
  • MindAttic.Vault.Desktop.Wpf (version 1.0.0), the one native app where those keys and settings are edited. Every app's cog opens it at that app's own tab through mindattic-vault:// (RFC 0003, "LAMP").

It is for the MindAttic apps and their owner: apps read their keys and settings through the library, and the owner edits them in one place instead of a settings screen per app.

Why

  • Stop hand-rolling Load(), Save() and environment-overlay plumbing in every service; one library replaces it.
  • Ship the same code to a developer laptop, Azure App Service, Azure Container Apps or AKS with no changes between environments.
  • Define secrets once under MindAttic:Vault and have local files, environment variables, App Service settings and Key Vault all resolve into the same shape.
  • Keep production read-only: configuration-backed stores throw on writes, so a deployed app never mutates its secrets.
  • Keep existing %APPDATA% keyrings working; they surface as a first-class IConfigurationSource, so migrating is zero-risk.
  • Take no Azure SDK dependency in the core package; wire Key Vault, AWS or GCP providers upstream and Vault reads them through IConfiguration.

Features

Credential resolution

  • LlmCredentialResolver and BrokerCredentialResolver chain IConfiguration in front of a writable file store; reads walk config, then file, then null, and writes go to the file store only.
  • ConfigurationCredentialStore is a read-only view over any configuration section; every write method throws NotSupportedException.
  • CompositeCredentialStore chains any number of stores: first non-null read wins, writes target the first writable store.
  • AppScopedCredentialStore gives each app its own key per provider (namespaced as appId-provider), falling back to the shared key when the app has none.
  • IRotatingKeyStore lets a provider hold a pool of keys in priority order, each with an optional label, while the first key stays mirrored to the plain apiKey field for single-key callers.

File stores

  • LlmCredentialStore, BrokerCredentialStore and FtpCredentialStore read and write the canonical bucket files under %APPDATA%\MindAttic\<Bucket>\.
  • TokenStore holds single-secret buckets such as GitHub or USPS tokens.
  • Writes are atomic (temp file plus File.Replace). Settings files keep a .bak; credential files (providers.json, tokens.json, ftp.json) keep none, so a replaced secret isn't left on disk. Malformed files are recovered from instead of crashing the host, and a providers.json or tokens.json that no longer parses is copied aside as <file>.corrupt-<timestamp> before a write replaces it.

Settings and paths

  • JsonSettingsStore<T> loads, saves and updates per-app JSON settings, roaming or local, with sync and async APIs.
  • VaultPaths replaces scattered Path.Combine(APPDATA, "MindAttic", ...) path math and works cross-platform.
  • EnvironmentOverlay and KeyResolver compose environment-variable overlays and custom resolution chains for code without a DI host.

Dependency injection

  • services.AddMindAtticVault() for console and desktop apps (file stores only).
  • services.AddMindAtticVault(builder.Configuration) for web and worker hosts (cloud-native resolvers).
  • services.AddVaultAppSettings<T>("MyApp") for a roaming settings store.

Every public type ships XML doc comments (MindAttic.Vault.xml is emitted at build time), so IntelliSense explains behaviour, edge cases and exceptions inline.

Scope

  • The complete product: SPEC.md lists every epic, feature and story of the finished Vault, built or not, and what is never in it. Every item there is a ticket.
  • The current finish line: RELEASE.md, milestone MS-26 "Vault Desktop 1.0, local only": the Azure profile and projects are removed (Azure was decommissioned 2026-11-26, MAT-T297), Vault's own suites pass, and these docs describe the local-only system. After it, MS-93 publishes the package on nuget.org; that is the finished product.
  • How to think about it: BIBLE.md holds the laws, the architecture and the glossary.

Until the Azure removal lands, the repo still carries MindAttic.Vault.Desktop.Azure, its tests and an Azure profile in Vault.Desktop; none of it has anything to connect to. MindAttic.Vault.Dashboard (the old LLM health monitor) is not part of the product.

How the library resolves a key

services.AddMindAtticVault(builder.Configuration)
llm.GetKey("claude")  -->  LlmCredentialResolver
   1. IConfiguration   MindAttic:Vault:LLM:claude:apiKey   (environment variables, appsettings,
                                                            AddMindAtticVaultFiles())
   2. LlmCredentialStore   %APPDATA%\MindAttic\LLM\providers.json   (writable)
   3. null

The first non-blank value wins. Writes go to the file store only; a configuration-backed store throws on write.

Quick start

Prerequisites: the .NET 9 or .NET 10 SDK and a reference to the MindAttic.Vault package (see Build, run and deploy to pack it yourself).

// Program.cs
using MindAttic.Vault.Configuration;
using MindAttic.Vault.DependencyInjection;

var builder = WebApplication.CreateBuilder(args);

builder.Configuration
    .AddJsonFile("appsettings.json", optional: true)
    .AddJsonFile($"appsettings.{builder.Environment.EnvironmentName}.json", optional: true)
    .AddMindAtticVaultFiles()                 // %APPDATA%\MindAttic\... single local source of truth
    .AddEnvironmentVariables();

builder.Services.AddMindAtticVault(builder.Configuration);
builder.Services.AddSingleton<MyService>();
// MyService.cs
using MindAttic.Vault.Credentials;

public class MyService(LlmCredentialResolver llm, BrokerCredentialResolver brokers)
{
    public string? Claude      => llm.GetKey("claude");
    public string? AlpacaPaper => brokers.GetKey("alpaca-paper");
}

Set a secret once and every MindAttic project on the machine sees it. Edit the bucket file directly, or use the writable store API:

LlmCredentialStore.Default.SetKey("claude", "sk-ant-...");           // LLM\providers.json
BrokerCredentialStore.Default.SetBrokerCreds("alpaca-paper",
    new BrokerCredentialStore.BrokerCreds("PK...", "S...", null));   // Brokers\providers.json
TokenStore.ForBucket("Tokens").Set("github", "ghp_...");             // Tokens\tokens.json
FtpCredentialStore.Default.Set(new FtpCredentialStore.FtpCreds(
    "ftp.example.com", 21, "user@example.com", "pw", true,
    "prod.example.net", null));                                      // Ftp\ftp.json

The equivalent %APPDATA%\MindAttic\LLM\providers.json:

{ "claude": { "type": "anthropic", "apiKey": "sk-ant-..." } }

FtpCredentialStore.Default.TryGetJson() returns the exact flat JSON blob that MindAttic.Deploy's MINDATTIC_FTP_JSON environment variable expects, with no reshaping at the call site.

Buckets on disk

The folder name under %APPDATA%\MindAttic\ equals the config section MindAttic:Vault:<Bucket>.

Bucket File Shape
LLM providers.json { id: { type, apiKey, apiKeys?, model, maxTokens } }
Brokers providers.json { id: { type, apiKey, secret, baseUrl } }
Tokens tokens.json { github: "<TOKEN>", ... } (flat)
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 { host, port, user, password, secure, servername } (file-only, not projected)

Per-app settings live in %APPDATA%\MindAttic\<app>\settings.json (roaming) or %LOCALAPPDATA%\MindAttic\<app>\ (per-machine apps). Shared values every app reaches live on the Global tab.

Configuration

Variable Default Meaning
MINDATTIC_VAULT_ROAMING_ROOT %APPDATA%\MindAttic (platform equivalent elsewhere) Overrides the roaming root
MINDATTIC_VAULT_LOCAL_ROOT %LOCALAPPDATA%\MindAttic Overrides the per-machine root
MINDATTIC_LLM_CREDENTIALS <roaming>\LLM Overrides the LLM bucket folder (tests)
MINDATTIC_BROKER_CREDENTIALS <roaming>\Brokers Overrides the Brokers bucket folder (tests)
MINDATTIC_FTP_CREDENTIALS <roaming>\Ftp Overrides the FTP bucket folder (tests)

Environment variables in the standard form (MindAttic__Vault__LLM__claude__apiKey=<YOUR_API_KEY>) are read through IConfiguration like any other source.

Build, run and deploy

cd D:\Projects\MindAttic\MindAttic.Vault
dotnet build MindAttic.Vault.slnx
dotnet pack MindAttic.Vault\MindAttic.Vault.csproj -c Release -o C:\LocalNuGet
.\run.ps1

run.ps1 is the shared deploy-lib menu: Redeploy builds Vault.Desktop.Wpf Debug and Release to R:\MindAttic\Apps\MindAttic.Vault, and the Release build installs to %LOCALAPPDATA%\MindAttic\Vault.Desktop and registers the mindattic-vault:// handler. Vault is not deployed to Azure or Hetzner.

The pre-commit hook (.githooks/pre-commit) checks the trusted LLM keys live and blocks a code commit while one is dead. A commit that only touches docs/, Markdown or .githooks/ skips the check (M.VALT-T218); SKIP_LLM_KEY_CHECK=1 remains the offline bypass.

The full API reference for the library is in the XML doc comments (MindAttic.Vault.xml) and in the README history before it became a pointer (MAT-T355).

Pages in this repository

  • MindAttic.Vault — Project Bible — MindAttic.Vault is a credentials-and-settings library for .NET that gives every MindAttic host one IConfiguration-backed pipeline for API…
  • 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…
  • MindAttic.Vault — Release charter — The MindAttic.Vault library gives every MindAttic app one IConfiguration-backed home for keys and settings under %APPDATA%\MindAttic.…
  • research/llm-provider-catalog — Research for Vault's key-and-credit dashboard, 2026-11-30. Ranking source: Artificial Analysis Intelligence Index (fetched 2026-11-30;…
  • rfc/0001-llm-health-dashboard — Vault knows every LLM key the family holds, but nothing tells an operator whether those keys are still good: a key can be revoked, hit a…
  • rfc/0003-lamp — Code name: LAMP. When the user says "LAMP" (in any window, on any login), that means: start implementing this plan.
  • MindAttic.Vault — Product specification — Place in the ecosystem: Vault is the platform owner of credentials and settings (docs/ECOSYSTEM.md §2.1): every key and setting in every…
From MindAttic.Vault/docs/overview.md via MindAttic.Docs; synced automatically, so edit the repo, not this page.