0003 — A .sfproj directory with SQLite inside

Status: Accepted · 2026-08-20

Context

A project is a set of drawings, thousands of markup records, per-page scales and an audit trail. It must survive a power cut, be handed to somebody, and open with no network.

Three shapes were considered: one opaque container file; a directory of loose JSON; a directory with a database inside it.

Decision

A directory, with SQLite for the records and content-addressed files for the drawings.

Against a single container file: it would have to be rewritten to add one markup. On a 400 MB set that is slow, and it is precisely the moment a power cut destroys the whole project rather than one record.

Against loose JSON: "open structural comments on Level 4" would mean parsing every file, and a status change would mean rewriting one. Worse, there is no atomic multi-record write, so a crash mid-save leaves an inconsistent set with no way to tell which files are current.

SQLite gives indexed queries over the set and an atomic, crash-safe write of one record. Wrapping it in a directory means the large immutable part — the drawings — is written once at import and never touched again, and when something does go wrong the PDFs are still PDFs that a file manager can recover.

Supporting choices:

What it costs

What would reverse it

Users routinely damaging packages by moving files inside them, or a transport story that demands a single file. The fix would be a zipped container unpacked to a working directory on open — which keeps the durability properties and changes only what sits on disk at rest.