guanghu/docs/adr/0002-filesystem-source-of-truth.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.5 KiB

type, id, title, status, date
type id title status date
ADR 0002 Filesystem as the single source of truth active 2026-02-14

Context

Laputa needs a persistence model. The core question: does the app own the data, or does the filesystem? This affects sync, conflict resolution, offline support, portability, and long-term trust with users.

Decision

The vault is the source of truth. The app never owns the data — it only reads and writes .md files. All cache, React state, and in-memory representations are derived from the filesystem and must be reconstructible by deleting them. When in doubt, the file on disk wins.

Alternatives considered

  • Database-first (SQLite): faster queries, easier relationships. Rejected — creates lock-in, makes files unreadable outside the app, complicates sync.
  • Cloud-first (proprietary sync): easier multi-device. Rejected — zero lock-in is a core principle; git handles sync.
  • Hybrid (DB + files): DB as primary, files as export. Rejected — two sources of truth always diverge.

Consequences

  • Notes are plain markdown files, readable and editable by any text editor
  • Git provides history, sync, and collaboration for free
  • Vault can be opened/edited externally without app corruption
  • App rebuilds cache on startup — acceptable cost for integrity guarantees
  • No "save" button needed — autosave writes to disk immediately
  • Triggers re-evaluation if: vault size grows to millions of files and filesystem scanning becomes a bottleneck