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's authorization policy refused the operation. reason is the refusing rule's own words, present only when authorize returned one; the message…
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.
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
RecoveryIntentOne effect a committed operation requires. key must be stable across restarts.
RecoveryOptions
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.