Skip to content

ChangeLog

Defined in: libs/runtime/src/change-log.ts:184

A store’s change log: every committed change as a revision, in commit order, with each thing’s revision tree, its conflicts, compaction, and the full-text index kept with it. Reached as db.changeLog. It is what replicateOnce and TypeDBLiteReplicator read from and apply to.

Properties

Name Description
fullText Full-text search over the projected state (Goal 6).

Methods

Name Description
applyRemote() Apply a revision that originated elsewhere.
applyRemoteBatch() Apply a batch of pushed revisions all or none, and return how many were new.
canonicalOf() Canonical form of an entity’s current state — exposed for tests and diagnostics.
compact() Drop revision history that nothing can read, keeping every leaf.
conflictsOf() Every losing leaf — the equivalent of CouchDB’s _conflicts.
ensureSchema() Creates the log’s tables if they do not exist, and migrates an older one.
identify() Resolve a thing to its node-independent identity and state.
keyTypes() The attribute types that carry @key.
leavesOf() The leaves of an entity’s revision tree — every revision that is nobody’s parent.
projectWinner() Make the winning revision visible to TypeQLite.
recordTombstone() Record that a thing was deleted, as a tombstone revision.
recordWrite() Record a write to the thing with this local iid, as a revision of its current state.
rememberKeys() Remember which attribute types carry @key.
since() Everything after cursor, in commit order.
stateOf() The state a revision carried, if it carried any.
vacuum() Return freed pages to the filesystem.
winnerOf() The winning leaf, by ADR-003 D3’s total rule.

readonly fullText: FullTextIndex

Defined in: libs/runtime/src/change-log.ts:186

Full-text search over the projected state (Goal 6). Kept current inside projection.

applyRemote(record): boolean

Defined in: libs/runtime/src/change-log.ts:585

Apply a revision that originated elsewhere.

Its parent may be any revision in the tree, not the local winner — which is precisely how a branch appears. Idempotent: UNIQUE (entity_id, rev) absorbs a revision delivered twice, which an at-least-once transport will do.

boolean

string

string | null

string

EntityState

boolean


applyRemoteBatch(records): number

Defined in: libs/runtime/src/change-log.ts:664

Apply a batch of pushed revisions all or none, and return how many were new.

readonly object[]

number


canonicalOf(iid): string | undefined

Defined in: libs/runtime/src/change-log.ts:817

Canonical form of an entity’s current state — exposed for tests and diagnostics.

number

string | undefined


compact(options?): CompactionReport

Defined in: libs/runtime/src/change-log.ts:748

Drop revision history that nothing can read, keeping every leaf.

keepAncestors retains the most recent N non-leaf revisions per entity, for anyone who wants a shallow tree rather than none. It defaults to 0, which is what a single node wants.

CompactionOptions = {}

CompactionReport


conflictsOf(id): readonly Leaf[]

Defined in: libs/runtime/src/change-log.ts:346

Every losing leaf — the equivalent of CouchDB’s _conflicts.

string

readonly Leaf[]


ensureSchema(): void

Defined in: libs/runtime/src/change-log.ts:202

Creates the log’s tables if they do not exist, and migrates an older one. Safe to repeat.

void


identify(iid): EntityIdentity | undefined

Defined in: libs/runtime/src/change-log.ts:248

Resolve a thing to its node-independent identity and state.

Returns undefined when the thing does not exist — which is normal, not an error: a delete cascade may already have removed it.

number

EntityIdentity | undefined


keyTypes(): ReadonlySet<string>

Defined in: libs/runtime/src/change-log.ts:235

The attribute types that carry @key. loadSchema derives key ownerships from it for a database that predates schema_key_owns.

ReadonlySet<string>


leavesOf(id): readonly Leaf[]

Defined in: libs/runtime/src/change-log.ts:319

The leaves of an entity’s revision tree — every revision that is nobody’s parent.

string

readonly Leaf[]


projectWinner(id): void

Defined in: libs/runtime/src/change-log.ts:489

Make the winning revision visible to TypeQLite.

string

void


recordTombstone(identity): void

Defined in: libs/runtime/src/change-log.ts:412

Record that a thing was deleted, as a tombstone revision. Takes an identity captured before the delete ran, because afterwards there is nothing left to read.

EntityIdentity

void


recordWrite(iid): void

Defined in: libs/runtime/src/change-log.ts:364

Record a write to the thing with this local iid, as a revision of its current state. Idempotent by construction: a revision is derived from its state and parent, so re-recording an unchanged entity computes the same rev and the UNIQUE (entity_id, rev) constraint absorbs it. That matters because one TypeQLite insert touches a thing, then each of its attributes, then each of its roles — the same entity is “touched” several times per pipeline.

number

void


rememberKeys(keys): void

Defined in: libs/runtime/src/change-log.ts:227

Remember which attribute types carry @key. Identity depends on this, and loadSchema only restores types and attributes — so without persisting it, a reopened database could not tell which attribute names an entity.

readonly string[]

void


since(cursor?, limit?): readonly ChangeRecord[]

Defined in: libs/runtime/src/change-log.ts:698

Everything after cursor, in commit order.

No gap handling, and that is safe rather than lazy: SQLite permits one writer at a time, so write transactions commit serially and seq allocation order equals commit order. There is no window where seq 6 is visible while seq 5 is still uncommitted.

number = 0

number = 500

readonly ChangeRecord[]


stateOf(id, rev): EntityState | undefined

Defined in: libs/runtime/src/change-log.ts:351

The state a revision carried, if it carried any.

string

string

EntityState | undefined


vacuum(): void

Defined in: libs/runtime/src/change-log.ts:803

Return freed pages to the filesystem. Not part of compact because VACUUM cannot run inside a transaction, and because a caller may reasonably want the rows gone without paying for a whole-file rewrite.

void


winnerOf(id): Leaf | undefined

Defined in: libs/runtime/src/change-log.ts:335

The winning leaf, by ADR-003 D3’s total rule.

string

Leaf | undefined

TypeDBLite is an independent open-source project, built on TypeDB with thanks. It is not affiliated with, sponsored by, or endorsed by TypeDB Ltd. Released under the MPL-2.0 license.