Repository navigation
v0.0.2 — checkpoint persistence profile
Purely additive over v0.0.1: 13 new exported identifiers, nothing removed and nothing changed. Existing code compiles untouched.
go get github.com/antst/go-yjs@v0.0.2
What is new
backend/persistence gains a second profile.
Until now the contract had exactly one shape — an append log — and conformance.Persistence enforced it by appending two opaque byte strings and requiring both back, in order, byte-identical. That is right for a medium that can hold an ordered log of independently durable records. It is impossible for one whose durable unit is a document-sized blob rewritten in place: an object-store key, a file whose id is a stable pointer, a single row.
CheckpointStore serves that medium:
type CheckpointStore interface {
SaveCheckpoint(context.Context, SaveCheckpointRequest) (Revision, error)
LoadCheckpoint(context.Context, backend.DocumentID) (Checkpoint, error)
FenceMode() FenceMode
}Same sentinels, same caller-owned-slice discipline, same returning-nil-means-durable rule, FenceMode fixed at construction. Methods are name-qualified so one type can offer both profiles.
conformance.CheckpointPersistence and CheckpointPersistenceFencing assert what is meaningful for the shape — round-trip fidelity, replacement, monotonic revisions, byte ownership in both directions, document isolation, explicit absence, cancellation, fencing — and deliberately assert no per-record history or pagination. Six deliberately broken stores are run against the suite in child processes and each must fail, so it is proven to reject rather than only to accept.
Example_checkpointBackend is a worked end-to-end flow in exactly that shape: one rewritable blob, no envelope, state vector derived on read, persisting from the update seam and recovering cold from storage alone. It is held to the public suite and verified to fail when persistence is disabled.
Why it exists
A service porting to this library could not express its real backend. The durable form is one blob per document, and that blob is a bare Yjs V2 state another repository also writes — so it can carry no envelope. The three ways to force it through the log suite were: one blob per record (abandoning the stable pointer the medium exists to provide), a log framed inside the blob (breaking the cross-repo format), or skipping the suite for the implementation that actually runs in production. All three are worse than adding the profile.
Also corrected
Both found by that same port rather than by us:
Coordinatorclaimed persistence provides the final stale-owner rejection. True only of a fenced store — and the checkpoint profile makes unfenced ordinary. An implementer would have believed they had defence in depth while having one layer. The doc now says the backstop is conditional, and that a node must shed clients on lease loss rather than merely decline to write.- The checkpoint suite fed opaque bytes, failing a store for deriving its state vector on read — a strategy the contract explicitly permits. Fixtures are now genuine Yjs updates;
StateVectorbecame caller-required so no store is forced to parse CRDT bytes.
Status is unchanged from v0.0.1
crdt/ and protocol/ are ready to build on — differential oracle across 13 surfaces in both directions on every push, both codecs byte-exact, 20 fuzz targets over the untrusted-byte surface.
The backend layer is still young. It now has one real implementation in progress against it, which is one more than at v0.0.1 and still not a production hour. Nothing here has run for a week.