SPB Git

Repository Public License

0004-sqlite-access.md 1.1 KB

# ADR 0004 — SQLite access layer

Status: accepted (2026-11-22)

# Decision

A thin wrapper (SQLiteDatabase, about 150 lines) over the system SQLite3 module: prepared statements, typed binding of JSONValue, row decoding, transaction { }, WAL for file databases, a 5 s busy timeout. One connection per store, serialized by a recursive lock. No ORM, no third-party library.

  • App data: one database per app (AppDataStore). Schema follows the blueprint with additive migrations only (create table, add column); nothing is dropped, which is what makes blueprint rollback lossless.
  • PRISM metadata: ProjectStore with numbered migrations tracked in PRAGMA user_version.
  • Queries from blueprints are declarative objects compiled to parameterized SQL over identifiers validated against the schema and quoted; values are always bound. Blueprints never contain SQL.

# Consequences

Queries run synchronously on the calling thread (the main actor for UI). Measured on this Mac this is well under a frame for 10,000 rows; moving heavy queries off the main thread is deferred until profiling asks for it.

Files main
Menu

Theme