Sync / API

foldkit-durable

foldkit-durable — a durable, ordered operation log with snapshots.

Storage and ordering only; application semantics live in the reduce the caller supplies. Append is atomic and idempotent by operation identity, committed order is stable, and compaction never changes the logical state a replay would produce.

Namespaces

CodecEncodes a value to JSON-compatible data and decodes it back strictly.
JournalA durable journal; see journal.ts. Declared here beside the Journal namespace, since a type and a const of one name must come from one module.
journalMetricsCounters an application can scrape; the default registry already collects them.

Functions

actorId
cursor
documentId
JournalServiceThe journal as a service, so an application composes it with Effect.provide instead of threading the shape through its own wiring. Pass the codec's Encoded…
makeJournalLayerProvides the journal as a scoped layer, releasing the database when the layer closes.
opId
sequence

Values

ActorIdThe trusted actor a principal commits as.
CursorA read position in a document; 0 is the start.
DocumentIdA journal's partition key: one authoritative document per key.
makeJournalOpens a durable, ordered operation log with a snapshot and cursor per key.
OpIdThe stable identity of one operation within its document.
SequenceA committed operation's position in a document; 1-based and gap-free.

Classes

CompactedCursorErrorA read requested a position compaction has already discarded.
EffectFailedErrorrunEffect was asked not to retry a key whose previous run failed.
IdentityConflictErrorAn operation identity was reused with a different payload or actor.
InvalidCompactionErrorA compaction cursor was not a forward step within the snapshot.
InvalidCursorErrorA read requested a position past the committed cursor.
InvalidOperationErrorThe supplied operation did not satisfy the application's codec or checks.
JournalErrorA storage or database failure, not something the caller did.
OperationRejectedErrorThe application refused the operation: its authorization policy, or a law judge found broken by the snapshot the operation leaves. reason is the refusing…
UnsupportedJournalVersionErrorThe database was written by a newer schema version than this build supports.

Interfaces

AuthorizationRequestThe application's policy decision for an operation, against the authoritative snapshot.
CommittedAn operation as the journal committed it, with its authoritative order and actor.
CursorsNamed cursors over documents and the runs parked behind them, stored beside the effect ledger. Every write names the epoch it was decided in and does…
EffectRecordThe durable record of one externally visible effect.
JournalDefinitionOne journal's service tag together with the layer that satisfies it, both built from the same type parameters, so the tag cannot be read back as a journal…
JournalOptions
JournalShape
JournalStoreWhat the store under a journal guarantees of concurrent writes. It has the shape of StoreCapabilities in @doeixd/metakit/store, which this package does not…
JudgeRequestWhat a law sees: the snapshot before the operation and the one it leaves, with the operation as stamped.
ParkedRunA run set aside so its cursor could move past it, kept until a person resolves it.
RecoveryIntentOne effect a committed operation requires. key must be stable across restarts.
RecoveryOptions
TrackedCursorWhere a named piece of work over one document has reached, in the document's current epoch: every commit at or before cursor was handled or set aside. A…
ValidationRequestStructural checks that run before a commit and throw when the operation is invalid.

Types

AppendError
AppendResultThe outcome of append. AlreadyCommitted means the operation is known but its payload was compacted away, so no Committed operation can be returned; a caller…
AuthorizationDecisionWhat authorize answers. true allows and false refuses; the object form refuses with the rule's own reason, which reaches the caller on…
CodecInputWhat JournalOptions.operation and .snapshot accept: an Effect Schema.Codec, or the function pair for an application that does not use Schema. A schema that…
EffectStatus
JournalStoreOptionsJournalOptions without the file: the store is the SqlClient the core Journal.layer is given.
JudgeDecisionWhat judge answers: true when every law holds, or the first broken one, by its id, its words and the snapshot fields it names.
ReplayResultThe outcome of replay for a reconnecting client: either the incremental operations committed after the client's cursor, or the authoritative snapshot when…