Skip to content

Rulvar API reference


Rulvar API reference / @rulvar/store-sqlite / SqliteStore

Class: SqliteStore ​

Defined in: packages/store-sqlite/src/store.ts:137

@rulvar/store-sqlite: SqliteStore implementing JournalStore and LeasableStore with fencing epochs over the builtin node:sqlite driver; the reference implementation for community stores (M5-T02). Requires a Node.js with node:sqlite available (unflagged in the 22.13+/23.4+ lines).

Implements ​

Constructors ​

Constructor ​

ts
new SqliteStore(options): SqliteStore;

Defined in: packages/store-sqlite/src/store.ts:161

Parameters ​

ParameterType
optionsSqliteStoreOptions

Returns ​

SqliteStore

Properties ​

PropertyModifierTypeDescriptionDefined in
effectLanereadonlytrueEffect lane capability (plan 45, rfcs/effects.md section 4.5, item 3): the restoration generation lives OUTSIDE the journal bytes in the same database file. The restore runbook is one rule: after restoring the file from a backup, run bumpRestorationGeneration() BEFORE the restored file becomes reachable to any worker, so the effect lane comes up with dispatch disabled until an operator appends a fresh effect_epoch citing the bumped generation.packages/store-sqlite/src/store.ts:155
fencedWritesreadonlytrueThe fenced writes promise (fenced run state RFC, phase 2): every lease-carrying mutation of this store (append, putMeta, delete) verifies the lease is the current holder FOR THE MUTATED RUN, atomically with the mutation, and rejects stale or mismatched holders with the typed LeaseHeldError leaving nothing changed.packages/store-sqlite/src/store.ts:145

Accessors ​

leaseTtlMs ​

Get Signature ​

ts
get leaseTtlMs(): number;

Defined in: packages/store-sqlite/src/store.ts:560

TTL introspection (the LeasableStore optional capability): lets createWorker verify at construction that its renew cadence matches this store's expiry instead of trusting two config sources to agree.

Returns ​

number

Optional TTL introspection (v1.35.0 review P2-4): the configured lease ttl in milliseconds. A store exposing it lets createWorker VERIFY at construction that the worker's renew cadence matches the store's expiry instead of trusting two config sources to agree; stores without it are accepted with the worker's own ttl.

Implementation of ​

EffectLaneStore.leaseTtlMs

Methods ​

acquire() ​

ts
acquire(runId, owner): Promise<Lease>;

Defined in: packages/store-sqlite/src/store.ts:565

Parameters ​

ParameterType
runIdstring
ownerstring

Returns ​

Promise&lt;Lease&gt;

Implementation of ​

EffectLaneStore.acquire


append() ​

ts
append(
   runId, 
   e, 
lease?): Promise<void>;

Defined in: packages/store-sqlite/src/store.ts:352

Parameters ​

ParameterType
runIdstring
eJournalEntry
lease?Lease

Returns ​

Promise&lt;void&gt;

Implementation of ​

EffectLaneStore.append


bumpRestorationGeneration() ​

ts
bumpRestorationGeneration(): Promise<number>;

Defined in: packages/store-sqlite/src/store.ts:259

The restore procedure's one mutation (see effectLane above): bumps the generation atomically and returns the new value. Idempotent in effect: every extra bump only widens the fence, never re-enables anything.

Returns ​

Promise&lt;number&gt;


close() ​

ts
close(): void;

Defined in: packages/store-sqlite/src/store.ts:242

Returns ​

void


delete() ​

ts
delete(runId, lease?): Promise<void>;

Defined in: packages/store-sqlite/src/store.ts:452

Parameters ​

ParameterType
runIdstring
lease?Lease

Returns ​

Promise&lt;void&gt;

Implementation of ​

EffectLaneStore.delete


getMeta() ​

ts
getMeta(runId): Promise<RunMeta | undefined>;

Defined in: packages/store-sqlite/src/store.ts:397

Parameters ​

ParameterType
runIdstring

Returns ​

Promise&lt;RunMeta | undefined&gt;

Implementation of ​

MetaLookupStore.getMeta


listRuns() ​

ts
listRuns(f?): Promise<RunMeta[]>;

Defined in: packages/store-sqlite/src/store.ts:406

Parameters ​

ParameterType
f?RunFilter

Returns ​

Promise&lt;RunMeta[]&gt;

Implementation of ​

EffectLaneStore.listRuns


load() ​

ts
load(runId): Promise<JournalEntry[]>;

Defined in: packages/store-sqlite/src/store.ts:364

Parameters ​

ParameterType
runIdstring

Returns ​

Promise&lt;JournalEntry[]&gt;

Implementation of ​

EffectLaneStore.load


putMeta() ​

ts
putMeta(m, lease?): Promise<void>;

Defined in: packages/store-sqlite/src/store.ts:381

Parameters ​

ParameterType
mRunMeta
lease?Lease

Returns ​

Promise&lt;void&gt;

Implementation of ​

EffectLaneStore.putMeta


release() ​

ts
release(l): Promise<void>;

Defined in: packages/store-sqlite/src/store.ts:613

Parameters ​

ParameterType
lLease

Returns ​

Promise&lt;void&gt;

Implementation of ​

EffectLaneStore.release


renew() ​

ts
renew(l): Promise<void>;

Defined in: packages/store-sqlite/src/store.ts:602

Parameters ​

ParameterType
lLease

Returns ​

Promise&lt;void&gt;

Implementation of ​

EffectLaneStore.renew


restorationGeneration() ​

ts
restorationGeneration(): Promise<number>;

Defined in: packages/store-sqlite/src/store.ts:247

The current restoration generation; 0 until a restore ever ran.

Returns ​

Promise&lt;number&gt;

Implementation of ​

EffectLaneStore.restorationGeneration


transcripts() ​

ts
transcripts(): SqliteTranscriptStore;

Defined in: packages/store-sqlite/src/store.ts:491

The fenced transcript twin (fenced run state RFC, F2): a TranscriptStore whose blobs live in THIS store's database, beside the lease rows, so a lease-carrying put or delete verifies the current holder of the run the ref's leading path segment names atomically with the blob mutation, in the same one-immediate- transaction shape as the journal side. Sharing the connection is what makes the capability implementable at all (a blob write and a lease check in different domains cannot commit as one unit; with ':memory:' a separate connection would not even see the leases) and keeps one close() lifecycle. Wire it as the engine's transcript store next to this store as the journal: over the pair every durable run mutation is fenced, which is what assertFencedWrites({ journal, transcripts }) verifies. The blob cascade of deleteRun/pruneRun stays ENGINE-side, exactly as the TranscriptStore contract says; the journal-side delete(runId) never touches blob rows.

Returns ​

SqliteTranscriptStore