Skip to main content

Crate durable

Crate durable 

Source
Expand description

Pi Durable storage: typed records, the Storage contract, and MemoryStorage.

Port of packages/durable/src/{types,errors}.ts and storage/memory-storage.ts from earendil-works/pi (MIT); the pinned revision is recorded in fixtures/storage-conformance.json. Errors carry the upstream error name and message. Upstream’s SQLite and JSONL file backends are not ported: the product keeps durable records in the session’s format-4 journal (session-core’s durable_store::open: a MemoryStorage whose commits are journal records).

Differences from upstream:

  • Storage is synchronous and takes no cancellation context; the Session (phase 3) owns scheduling and cancellation.
  • Records are typed, so malformed records fail to deserialize instead of reaching storage, and a document.create whose content is a delta is rejected at commit (upstream’s types forbid it).

Structs§

CheckpointInfo
Stored replay state supplied to a document’s checkpoint predicate.
CommitPublication
Every change of one successful commit.
ConversationId
ConversationOwner
ConversationParent
ConversationQuery
ConversationRecord
Doc
A shared document definition passed explicitly to typed access.
DocDefinition
A document definition. initial receives null (upstream’s family seed) and runs only when the document is absent; migrate converts a stored value of an older version; checkpoint_when returning true stores an ordinary change as a complete base instead of a delta.
DocumentAddress
Exact logical identity of a singleton (key absent) or one keyed family member.
DocumentCopySource
Exact persisted source of a definition-free document copy.
DocumentCreate
Fields supplied when storage creates and stamps a new DocumentRecord.
DocumentId
DocumentQuery
Incarnations alive in one exact scope at one point.
DocumentRecord
Persisted lifecycle record of one create-to-retire document incarnation.
EntryDraft
Entry content supplied before the Session assigns identity and task attribution.
EntryId
EntryQuery
Inclusive ID bounds for a scan of one conversation’s fork-aware history.
EntryRecord
Immutable transcript event. model and edits stay JSON until the message model is ported (phase 4).
MemoryStorage
Detached in-memory reference implementation of Storage. Reads return owned copies.
Page
One ordered scan result and its optional continuation.
PreparedCommit
A validated commit whose writes have their document copies resolved to creations.
Seq
Strictly increasing sequence of one atomic storage commit; gaps are permitted.
Session
Owner of one mutation line, its records, and its tracked documents.
StoredDocument
Materialized value and stored definition version at a selected point.
StoredEntry
An entry and the sequence of the commit that persisted it.
SubmissionCreate
Submission fields supplied before the Session assigns an ID. No admission rules apply to a raw creation.
SubmissionId
SubmissionQuery
SubmissionRecord
Durable lifecycle of one admitted user input or passive entry write. The Session supplies valid transitions.
Subscription
Removes a listener when called; dropping it keeps the listener.
TaskDefinition
Executable task definition as far as the Session needs it: its registered name, version, and first checkpoint.
TaskId
TaskOptions
Creation options for a durable task.
TaskOutcomeError
TaskQuery
TaskRecord
Complete replacement record for one durable task state machine.
Tx
The transaction of one Session commit callback. Table reads fail with SessionError::ReadAfterWrite after the first table write; document access stays available.
TxScope
Defaults a commit binds to: the create_task conversation and the task attributed to appended entries.

Enums§

AbortReason
CommitChange
One change of a successful commit.
ConversationOwnership
Ownership selected explicitly whenever a conversation is created.
DocSemantics
Ownership and lifetime of a document; only conversation documents declare history and fork behavior.
DocumentContent
Complete checkpoint or Chord operation batch.
DocumentFork
DocumentHistory
DocumentPoint
Current state or one historical commit, for document membership and content reads.
DocumentScope
Who owns a document.
EntryHead
First entry of the active context an entry selects; SelfId is the entry’s own, newly assigned ID.
JoinPolicy
Owner
The owner a document address names; it must match the definition’s scope.
ScanOrder
ID order of a scan: Ascending is oldest first.
SessionEnd
Why a Session ended: close(), or a failed Storage call, whose error it carries.
SessionError
A Session operation failure. name() is the upstream error class name.
StorageError
A Storage failure. Request fails only that read (upstream StorageRequestError, no durable effect); every other error, and any error from commit or mint_id, is fatal to the Session.
StorageWrite
One record or document mutation in an atomic storage commit.
SubmissionSettlement
Terminal status staged for a submission.
SubmissionStatus
SubmissionType
TaskOutcome
Durable reason and optional result recorded when a task becomes terminal.
TaskOwnership
Who owns a task: its conversation (a top-level task) or another task of the same conversation.
TaskState
Complete durable execution state of a task.
TaskStatus

Constants§

MAX_SAFE_ID
Largest ID a JavaScript number holds exactly; minting stops past it so IDs stay interchangeable with upstream.
ROOT_CONVERSATION_ID
The root conversation always uses this reserved ID.

Traits§

Storage
Atomic persistence boundary for Session records.

Type Aliases§

CommitSink
Sees each commit as it will be applied, before it is: an error fails the commit unapplied. A backend that keeps its records elsewhere persists them here (session-core’s journal; a replay log).
Cursor
Backend-owned continuation state that callers only round-trip to the same scan.
JsonObject
JSON object used as the root of every durable document.
Result