Document engine
Persistence & Server
PostgreSQL CAS, changeId, owner_epoch, snapshots, and the reference WebSocket host.
Persistence is a port on lextrix-change. The reference implementation that talks to a real database is lextrix-server (PostgreSQL + WebSocket).
Your app still owns login, TLS, and billing. Lextrix owns accept rules and compare-and-append.
Version → compareAndAppend → PostgreSQLWrites succeed only when the durable HEAD still matches what the writer expected. That stops two workers from overwriting each other.
| Option | Meaning |
|---|---|
changeId | Same id twice → no duplicate Version |
ownerEpoch | Stale owner → reject (stale_owner) |
OT accept → Handle.apply → compareAndAppend → ACK + broadcastIf CAS fails: rehydrate, skip the history ACK, skip the broadcast.
The reference schema includes document_heads, versions, change_ids, and document_ownership. Snapshot / archive tables show up when you compact history. A snapshot is a checkpoint at a Version — not a second HEAD. Do not truncate history until archive succeeds.
InMemoryAuthoritativePersistence is for tests and demos, not production.
See also Collaboration.