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.createwhose content is a delta is rejected at commit (upstream’s types forbid it).
Structs§
- Checkpoint
Info - Stored replay state supplied to a document’s checkpoint predicate.
- Commit
Publication - Every change of one successful commit.
- Conversation
Id - Conversation
Owner - Conversation
Parent - Conversation
Query - Conversation
Record - Doc
- A shared document definition passed explicitly to typed access.
- DocDefinition
- A document definition.
initialreceivesnull(upstream’s family seed) and runs only when the document is absent;migrateconverts a stored value of an older version;checkpoint_whenreturning true stores an ordinary change as a complete base instead of a delta. - Document
Address - Exact logical identity of a singleton (
keyabsent) or one keyed family member. - Document
Copy Source - Exact persisted source of a definition-free document copy.
- Document
Create - Fields supplied when storage creates and stamps a new
DocumentRecord. - Document
Id - Document
Query - Incarnations alive in one exact scope at one point.
- Document
Record - Persisted lifecycle record of one create-to-retire document incarnation.
- Entry
Draft - Entry content supplied before the Session assigns identity and task attribution.
- EntryId
- Entry
Query - Inclusive ID bounds for a scan of one conversation’s fork-aware history.
- Entry
Record - Immutable transcript event.
modelandeditsstay JSON until the message model is ported (phase 4). - Memory
Storage - Detached in-memory reference implementation of
Storage. Reads return owned copies. - Page
- One ordered scan result and its optional continuation.
- Prepared
Commit - 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.
- Stored
Document - Materialized value and stored definition version at a selected point.
- Stored
Entry - An entry and the sequence of the commit that persisted it.
- Submission
Create - Submission fields supplied before the Session assigns an ID. No admission rules apply to a raw creation.
- Submission
Id - Submission
Query - Submission
Record - 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.
- Task
Definition - Executable task definition as far as the Session needs it: its registered name, version, and first checkpoint.
- TaskId
- Task
Options - Creation options for a durable task.
- Task
Outcome Error - Task
Query - Task
Record - Complete replacement record for one durable task state machine.
- Tx
- The transaction of one Session commit callback. Table reads fail with
SessionError::ReadAfterWriteafter the first table write; document access stays available. - TxScope
- Defaults a commit binds to: the
create_taskconversation and the task attributed to appended entries.
Enums§
- Abort
Reason - Commit
Change - One change of a successful commit.
- Conversation
Ownership - Ownership selected explicitly whenever a conversation is created.
- DocSemantics
- Ownership and lifetime of a document; only conversation documents declare history and fork behavior.
- Document
Content - Complete checkpoint or Chord operation batch.
- Document
Fork - Document
History - Document
Point - Current state or one historical commit, for document membership and content reads.
- Document
Scope - Who owns a document.
- Entry
Head - First entry of the active context an entry selects;
SelfIdis the entry’s own, newly assigned ID. - Join
Policy - Owner
- The owner a document address names; it must match the definition’s scope.
- Scan
Order - ID order of a scan:
Ascendingis oldest first. - Session
End - Why a Session ended:
close(), or a failed Storage call, whose error it carries. - Session
Error - A Session operation failure.
name()is the upstream error class name. - Storage
Error - A Storage failure.
Requestfails only that read (upstreamStorageRequestError, no durable effect); every other error, and any error fromcommitormint_id, is fatal to the Session. - Storage
Write - One record or document mutation in an atomic storage commit.
- Submission
Settlement - Terminal status staged for a submission.
- Submission
Status - Submission
Type - Task
Outcome - Durable reason and optional result recorded when a task becomes terminal.
- Task
Ownership - Who owns a task: its conversation (a top-level task) or another task of the same conversation.
- Task
State - Complete durable execution state of a task.
- Task
Status
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§
- Commit
Sink - 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.
- Json
Object - JSON object used as the root of every durable document.
- Result