Skip to content

Graphorin API reference v0.12.1


Graphorin API reference / @graphorin/store-sqlite / / SqliteCheckpointStore

Class: SqliteCheckpointStore

Defined in: packages/store-sqlite/src/checkpoint-store.ts:23

Default CheckpointStore implementation (including the W-009 CheckpointStoreExt retention primitives). Workflow state is encoded as JSON blobs; per-task pending writes survive partial step failure.

Stable

Implements

Constructors

Constructor

ts
new SqliteCheckpointStore(conn): SqliteCheckpointStore;

Defined in: packages/store-sqlite/src/checkpoint-store.ts:25

Parameters

ParameterType
connSqliteConnection

Returns

SqliteCheckpointStore

Methods

compactThread()

ts
compactThread(
   threadId, 
   namespace, 
keepLast): Promise<number>;

Defined in: packages/store-sqlite/src/checkpoint-store.ts:260

W-009 compaction: keep only the keepLast newest checkpoints (by step_number) of one (thread_id, namespace) pair. Resume reads the latest tuple, so keepLast >= 1 never breaks resumability; the oldest surviving checkpoint's parent_id may point at a deleted row, which getTuple/list never resolve and the CAS compares only the latest id - safe, but time-travel/fork targets are gone.

Parameters

ParameterType
threadIdstring
namespacestring
keepLastnumber

Returns

Promise&lt;number&gt;

Implementation of

CheckpointStoreExt.compactThread


deleteThread()

ts
deleteThread(threadId): Promise<void>;

Defined in: packages/store-sqlite/src/checkpoint-store.ts:200

Full erasure primitive: delete every checkpoint and pending write of this thread across ALL namespaces. Namespace-blind by contract - retention sweeps must use CheckpointStoreExt.pruneThreads instead, which is namespace-scoped and protects suspended threads.

Parameters

ParameterType
threadIdstring

Returns

Promise&lt;void&gt;

Implementation of

CheckpointStoreExt.deleteThread


getTuple()

ts
getTuple(
   threadId, 
   namespace, 
   checkpointId?): Promise<
  | CheckpointTuple
| null>;

Defined in: packages/store-sqlite/src/checkpoint-store.ts:109

Parameters

ParameterType
threadIdstring
namespacestring
checkpointId?string

Returns

Promise< | CheckpointTuple | null>

Implementation of

CheckpointStoreExt.getTuple


list()

ts
list(
   threadId, 
   namespace, 
opts?): AsyncIterable<CheckpointTuple>;

Defined in: packages/store-sqlite/src/checkpoint-store.ts:177

Parameters

ParameterType
threadIdstring
namespacestring
opts?ListOptions

Returns

AsyncIterable&lt;CheckpointTuple&gt;

Implementation of

CheckpointStoreExt.list


listSuspended()

ts
listSuspended(namespace, opts?): Promise<readonly {
  threadId: string;
  wakeAt: number;
}[]>;

Defined in: packages/store-sqlite/src/checkpoint-store.ts:150

W-032: enumerate threads whose LATEST checkpoint in namespace is suspended with a due wake_at. Latest-per-thread is decided by max step_number (the same policy as getTuple), so a thread whose newest checkpoint moved on (resumed / completed) never fires.

Parameters

ParameterType
namespacestring
opts?{ dueBefore?: number; limit?: number; }
opts.dueBefore?number
opts.limit?number

Returns

Promise<readonly { threadId: string; wakeAt: number; }[]>

Implementation of

CheckpointStoreExt.listSuspended


pruneThreads()

ts
pruneThreads(opts): Promise<number>;

Defined in: packages/store-sqlite/src/checkpoint-store.ts:222

W-009 retention sweep. Policy: a (thread_id, namespace) pair qualifies when its LATEST checkpoint (by step_number) is older than the cutoff and - unless onlyTerminal: false - terminal ('completed' / 'failed' / 'aborted'); suspended pairs hold live HITL approvals / awakeables and are protected by default.

CRITICAL: never delegates to deleteThread - that primitive is namespace-blind, and with a reused threadId (e.g. a sessionId used by two workflows) pruning workflow A's terminal thread would erase workflow B's suspended checkpoints, breaking the onlyTerminal guarantee. Each qualifying pair is deleted with namespace-scoped statements in its own transaction so a long sweep never holds the writer lock across the whole table.

Parameters

ParameterType
optsPruneThreadsOptions

Returns

Promise&lt;number&gt;

Implementation of

CheckpointStoreExt.pruneThreads


put()

ts
put(
   threadId, 
   namespace, 
   checkpoint, 
   metadata, 
opts?): Promise<string>;

Defined in: packages/store-sqlite/src/checkpoint-store.ts:29

Parameters

ParameterType
threadIdstring
namespacestring
checkpointCheckpoint
metadataCheckpointMetadata
opts?CheckpointPutOptions

Returns

Promise&lt;string&gt;

Implementation of

CheckpointStoreExt.put


putWrites()

ts
putWrites(
   threadId, 
   namespace, 
   checkpointId, 
   writes, 
taskId): Promise<void>;

Defined in: packages/store-sqlite/src/checkpoint-store.ts:88

Parameters

ParameterType
threadIdstring
namespacestring
checkpointIdstring
writesreadonly PendingWrite[]
taskIdstring

Returns

Promise&lt;void&gt;

Implementation of

CheckpointStoreExt.putWrites