guanghu/docs/adr/0004-vault-vs-app-settings-storage.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 0004 Vault vs app settings for state storage active 2026-03-24

Context

As features were added, there was recurring ambiguity about where to persist configuration and state: in the vault (as frontmatter in .md files) or in app settings (~/.config/com.laputa.app/settings.json / localStorage). Without a clear rule, some decisions were inconsistent.

Decision

Ask: "Would the user want this to follow the vault across all their installations?"

  • If yes → store in the vault (as frontmatter in the relevant .md file, using the _ convention for system properties)
  • If no → store in app settings

Examples:

Data Storage Reason
Note type icon (_icon) Vault frontmatter Follows the vault everywhere
Note type color (_color) Vault frontmatter Follows the vault everywhere
Note sort preference Vault frontmatter (type file) Per-vault, consistent across devices
API keys (Anthropic, OpenAI) App settings Installation-specific
GitHub token App settings Installation-specific
Window size / zoom App settings Device-specific
Editor zoom level App settings Device-specific
Telemetry consent App settings Installation-specific

Alternatives considered

  • Everything in localStorage: simple, but breaks cross-device sync for vault-level config.
  • Everything in vault: pure, but makes device-specific settings (zoom, window size) propagate to all devices — confusing.

Consequences

  • Config that "belongs to a note or type" lives in frontmatter — readable/diffable in git
  • The _ prefix convention (see ABSTRACTIONS.md) distinguishes system properties from user properties
  • App rebuilds from vault state on open — no stale config files to manage
  • Triggers re-evaluation if: vault files become too polluted with system frontmatter properties