guanghu/docs/adr/0023-repair-vault-auto-bootstrap.md
Guanghu Domestic Migration 9b41d51231
Some checks are pending
Auto-update PR branches / Update open PR branches (push) Waiting to run
CI / Frontend Static Quality Checks (push) Waiting to run
CI / Frontend Tests & Coverage (push) Waiting to run
CI / Rust Tests & Quality Checks (push) Waiting to run
CI / Linux build verification (push) Waiting to run
Deploy docs / Build VitePress site (push) Waiting to run
Deploy docs / Deploy to GitHub Pages (push) Blocked by required conditions
Release (Alpha) / Compute alpha version (push) Waiting to run
Release (Alpha) / Build release artifacts (push) Blocked by required conditions
Release (Alpha) / GitHub Release (alpha) (push) Blocked by required conditions
Release (Alpha) / Update docs and release pages (push) Blocked by required conditions
chore: import sanitized domestic snapshot for REPO-004
Source snapshot: 514ab1975951d94342ea38e64101d5a0f1c51c77
2026-07-17 15:55:28 +08:00

1.9 KiB

type, id, title, status, date
type id title status date
ADR 0023 Repair Vault auto-bootstrap pattern active 2026-03-07

Context

As Laputa adds features that depend on vault files (type definitions, config files, agents), users with existing vaults would miss these files. Manually creating them is error-prone. Features must work on both new and existing vaults without user intervention.

Decision

Every feature that depends on vault files must auto-bootstrap: check if file/folder exists on vault open, create with defaults if missing (silent, idempotent). All bootstrap functions are registered with the central Cmd+K → "Repair Vault" command for manual re-creation.

Options considered

  • Option A (chosen): Auto-bootstrap on vault open + manual Repair Vault command — works for new and existing vaults, idempotent, no user action needed. Downside: vault may accumulate files the user didn't explicitly create.
  • Option B: Require users to run a setup wizard — explicit, user-controlled. Downside: friction, users forget, new features don't work until setup is run.
  • Option C: Store defaults in app bundle, not vault — no vault files created. Downside: breaks the "vault as source of truth" principle, custom configs can't override defaults.

Consequences

  • Type definitions (type/project.md, etc.) are seeded on vault open if missing.
  • Config files (config/agents.md, etc.) are seeded on vault open if missing.
  • Repair Vault command (Cmd+K) re-creates all expected files — useful after manual deletion or vault corruption.
  • All bootstrap operations are silent and idempotent — running twice has no effect.
  • getting_started.rs creates the Getting Started demo vault with all expected structure.
  • The vault_health_check command detects missing or misconfigured vault files.
  • Re-evaluation trigger: if the number of auto-created files becomes excessive or confusing for users.