Sync / foldkit-durable
Limits
- SQLite only: via
@effect/sql-sqlite-node(Node 22) inJournal.make, or any Effect SQLite client (@effect/sql-sqlite-wasm,@effect/sql-d1withd1: true) infoldkit-durable/core. - In-transaction callbacks:
reduce,validate,authorize, andjudgehold the write lock; keep them pure, fast, and free of services. - Single-writer deployment: database constraints enforce uniqueness of
[key, op_id]and[key, sequence], while one authoritative writer per file avoids lock contention. - Pre-schema-3 compaction: payloads compacted before schema 3 lack canonical hashes, so key-reordered retries of those rows cannot be matched by hash.
- Application-driven recovery:
recoverruns when your host schedules it rather than spawning a background worker.
Older spellings
makeJournal, makeJournalLayer, and journalMetrics map to Journal.make, Journal.layer, and Journal.metrics; documentId, opId, actorId, sequence, and cursor map to .make constructors. Prefer Journal.define over JournalService(key) so generic parameters stay tied to the layer. Plain { encode, decode } function pairs work anywhere Schema.Codec is accepted.
Next
- Connect replicas to this journal:
foldkit-syncand Replicated state. - Reconcile journal commits with server read tables: Editing server data through a journal.
- Run a complete journal with compaction and crash-recovery tests:
examples/sync.