ADR-0023 — Local SQLite sync database as a rebuildable cache

Context

The sync engine needs durable local state — the three trees (ADR-0022), the operation queue, the cursor, and metadata caches — that survives restarts and crashes, supports the planner’s queries, and enables offline work. It must be crash-consistent (a half-applied state must never corrupt data) and must not itself become a single point of data loss.

Decision

Use SQLite (WAL mode, one DB per sync root) as the local store:

Consequences

Positive

Negative / costs

Alternatives considered

Scaling

Metadata-only size (grows with file count, not bytes); indexed on parent, state, and the disagreement predicate; chunk cache is LRU-capped; one DB per root bounds size and isolates corruption.