What this journal's store guarantees of concurrent appends: serializable
over SQLite, isolating a transaction (one per append); serializable over
D1 isolating one statement, since a read and the append that follows are
two round trips (the uniqueness constraints keep the order). A journal
over another store says its own.
The sequence of the document's last commit; 0 if none. Unlike load, it
decodes nothing, so an exchange can check a client's cursor before it
appends anything.
The identity of the document's history: the same while its operations are kept, new
after reset or on a new database file. A client that saw another epoch holds a
cursor into history this journal does not have, and must start again from 0.
Replays committed operations after after for a reconnecting client.
Returns Operations when the client's cursor is within the retained log
and its epoch (if given) matches; otherwise returns Snapshot with the
authoritative state and the reason it could not replay incrementally.
Commits an operation. A repeat of a known opId returns Committed with the
stored operation while its payload is retained, and AlreadyCommitted
without one once compaction has removed it. A reuse with different data or
actor is an IdentityConflictError in either case, proven by a retained
payload hash.
Rebuilds the database file, returning to the file system the space that
compact freed: compaction empties payloads but leaves their pages allocated.
It rewrites every table and holds the database while it runs, so it is
maintenance, not something to run per commit.
Reuses recorded successes and shares concurrent runs within this journal
instance. Pending and failed records are retried when called again, unless
retryFailed says otherwise — false for every failed record, or a
predicate that decides from the record itself.
An external action can succeed before its result is recorded; recovery
requires provider idempotency or reconciliation. Use a stable key including
the document, operation, and semantic effect identity, and pass that same
key to the provider. Results must be JSON-compatible. See the README's
effect recovery policy before retrying work with uncertain outcomes.
Runs the effect intents of a document's committed operations after from,
reusing recorded successes and stopping before any operation whose intent
failed or was skipped. Returns the cursor up to which every intent settled,
so a caller can persist it and resume. The journal does not schedule this;
the application owns discovery and startup.
Drops a document's snapshot and operations, and its epoch, so the next epoch differs.
Replica bindings stay: they are who a replica is, not history. Effect records are keyed
by the application's own effect identity, not by document, so they are not scoped to a
key; clearEffect removes one.
The document keys a commit changed. Subscription is a Stream, so a
subscriber never fails or slows a commit; a caller that needs a callback
adapts it at the edge.