Commit & versioning

The versioned persistence tier. CommitDatabase keeps the history of mutations in a DAG of commits; two stateless namespaces operate over it, each taking a CommitDatabase as their first argument:

  • CommitStateBuilderreconstruct a CommitState from a chosen commit: CommitStateBuilder.state(db, id), CommitStateBuilder.initialState(db).

  • CommitDatabaseHelperreduce heads and navigate (reduceHeads, forward / fastForward).

CommitDatabase itself answers topology queries (headCommitIds(), lastCommitId(), isAncestor) and holds no “current” state. A CommitStore wraps the persistence layer and both namespaces behind a stateful facade (undo/redo, the dispatch surface) for interactive apps. A reconstructed state is a blind replay of the linearized trace — see the peer Python narrative, Commit.

This bucket also holds the additive merge machinery (CommitMergeAnalyzer and friends): see Merge reconciliation below.

When to use

Reach for this page’s classes when you persist DSM documents with history — every write is a commit, and earlier states stay reconstructible. If you only need flat CRUD without versioning, use Database instead. The Python counterpart is Commit Database.

Quick Start

const {
    CommitDatabase, CommitStateBuilder, CommitMutableState,
} = require('@digitalsubstrate/dsviper');

// Create an in-memory commit database and grow its schema from definitions.
const db = CommitDatabase.createInMemory();
db.extendDefinitions(defs.const());

// Stage writes on a mutable state built from the empty initial snapshot.
const state = new CommitMutableState(CommitStateBuilder.initialState(db));
const mutating = state.attachmentMutating();
mutating.set(attachment, key, document); // a Document_Set opcode is recorded

// Seal the staged mutations into a new commit.
db.commitMutations('Add document', state);

// Read back from a reconstructed snapshot at the latest commit.
const getting = CommitStateBuilder.state(db, db.lastCommitId()).attachmentGetting();
const value = getting.get(attachment, key); // a ValueOptional

db.close();

Note

INT64 documents unwrap to a JS bigint (getting.get(att, key).unwrap() is 42n, not 42). Compare keys and values with .equals, never ==. Operations on a closed CommitDatabase throw a ViperError (a JS Error whose .name === 'ViperError').

Choosing the right class

Use case

Class

Example

Create an in-memory commit database

CommitDatabase

CommitDatabase.createInMemory()

Read state at a specific commit

CommitStateBuilder

CommitStateBuilder.state(db, id)

Prepare mutations

CommitMutableState

new CommitMutableState(CommitStateBuilder.initialState(db))

Write documents (set, update, unionInSet, …)

attachmentMutating()

state.attachmentMutating().set(att, key, doc)

Read documents (get, keys, has)

attachmentGetting()

CommitStateBuilder.state(db, id).attachmentGetting()

Inspect commit metadata

CommitHeader

db.commitHeader(id)

Redux-style store (dispatch, undo/redo)

CommitStore

store.use(db); store.dispatch(label, fn)

Reconcile a merge

CommitMergeAnalyzer

see below

Merge reconciliation

CommitMergeAnalyzer is an additive, application-level supervisor over the public CommitDatabase API. The engine reduces concurrent streams mechanically and signals no conflict; this layer reconstructs a notion of conflict over a merge — already persisted, or computed from the two heads — and lets a caller make a chosen value survive. It adds no engine, storage-format, or runtime change.

const { CommitMergeAnalyzer, CommitMergeResolution } = require('@digitalsubstrate/dsviper');

const merge = db.mergeCommit('merge', ours, theirs);
const analysis = CommitMergeAnalyzer.analyzeMerge(db, merge);

// The supervisor decides per conflict; here, keep ours at every locus.
const resolutions = analysis.conflicts().map(
    (c) => new CommitMergeResolution(c, c.oursValue().unwrap()),
);
const survivor = CommitMergeAnalyzer.reconcile(db, merge, resolutions, 'reconcile');

Accepting the merge for every conflict (resolving each with mergedValue()) makes reconcile return the merge commit unchanged. When the two heads share no unambiguous base, analyzeMerge degrades to a base-free 2-way scan (analysis.twoWay() is true, analysis.base() is undefined) rather than erroring. For the model behind identify / surface / reconcile, see Commit.

Generated from the @digitalsubstrate/dsviper TypeScript declarations (index.d.ts) by TypeDoc.

Summary

Class

Description

Commit

A class used to represent a commit

CommitData

A class used to represent data associated with a commit during the synchronization of two databases

CommitDatabase

A Commit database keeps the history of mutations in a DAG of commit

CommitDatabaseFlattener

Flattens a CommitDatabase commit into a single-commit CommitDatabase

CommitDatabaseHelper

A utility class for a Commit Database

CommitDatabaseRemote

A low-level class used to represent a remote Commit database through the CommitDatabasing interface

CommitDatabaseSQLite

A low-level class used to represent the database based on SQLite3 through the CommitDatabasing interface

CommitDatabaseToDatabaseConverter

Converts a CommitDatabase into a Database

CommitDatabasing

An interface used to abstract the implementation of the persistence layer for a Commit database

CommitEvalAction

A class used by the evaluator to reconstruct a value by executing mutation opcodes

CommitHeader

A class used to represent the header of a commit

CommitMergeAnalysis

The result of a 3-way merge analysis: the merge base and the list of reconstructed conflicts between the two branches

CommitMergeAnalyzer

Additive, post-merge 3-way reconciliation over a CommitDatabase

CommitMergeConflict

A single locus, anchored on a path, where one branch’s intent did not survive the merge, reconstructed as base/ours/theirs/merged values

CommitMergeDocument

All conflicts of one document (attachment, key) — the unit reconcile operates on

CommitMergeResolution

A supervisor’s decree for one conflict: the chosen value should survive at the conflict’s locus

CommitMutableState

A class used to register the mutations of a value executed through the attachmentMutating interface

CommitNode

A class used to represent a node in the commit DAG

CommitNodeGrid

A class used to represent the location of a commit node in the grid

CommitNodeGridBuilder

A class used to build the grid layout of the commit DAG

CommitState

A class used to represent data at a specific commit

CommitStateBuilder

A utility class to build CommitState

CommitStateTrace

A class used to represent traced opcode

CommitStateTraceProgram

A class used to represent traced opcode

CommitStateTracing

An interface used to trace a value (aka document)

CommitStore

A high-level application class used to implement the store, dispatch, undo/redo and notification concepts inspired by the redux approach

CommitStoreNotifying

An interface used to represent the notification emitted by a store

CommitSyncData

A class used to represent data exchanged during the synchronization of two databases

CommitSynchronizer

A class used to synchronize two concrete databases through the CommitDatabasing interface (low-level driver interface)

CommitSynchronizerInfo

A class used to represent data exchanged during the synchronization of two databases

CommitSynchronizerInfoTransmit

A class used to represent statistics of data exchanged during the synchronization of two databases

Reference

class Commit()

A class used to represent a commit.

Note: Not directly instantiable.

exported from index.d

Commit.header()

Return the header.

Returns:

CommitHeader

Commit.program()

Return the program or null

Returns:

ValueProgram | undefined

class CommitData()
A class used to represent data associated with a commit during the

synchronization of two databases.

Note: Not directly instantiable.

exported from index.d

CommitData.blobIds(streamCodecInstancing, definitions)

Return the set of blob_id referenced by the opcodes.

Arguments:
  • streamCodecInstancing (StreamCodecInstancing)

  • definitions (DefinitionsConst)

Returns:

ValueBlobId[]

CommitData.data()

Return the blob of the encoded opcodes.

Returns:

CommitData

CommitData.header()

Return the header.

Returns:

CommitHeader

CommitData.opcodes(streamCodecInstancing, definitions)

Return the list of opcodes.

Arguments:
  • streamCodecInstancing (StreamCodecInstancing)

  • definitions (DefinitionsConst)

Returns:

ValueOpcode[]

static CommitData.sort(commitDatas)

Return the list of CommitDatas topologically sorted.

Arguments:
  • commitDatas (CommitData[])

Returns:

CommitData[]

class CommitDatabase(commitDatabasing)

A Commit database keeps the history of mutations in a DAG of commit.

Use the static factory method createInMemory(), create(…), open(…), connect(…) or connectLocal(…).

exported from index.d

Arguments:
  • commitDatabasing (CommitDatabasing)

CommitDatabase.blob(blobId)

Return a blob or null.

Arguments:
  • blobId (ValueBlobId)

Returns:

ValueBlob

CommitDatabase.blobGetting()

Return the BlobGetting interface.

Returns:

BlobGetting

CommitDatabase.blobIds()

Return the set of blob_id of all available blobs.

Returns:

ValueBlobId[]

CommitDatabase.blobInfo(blobId)

Return the information of the blob.

Arguments:
  • blobId (ValueBlobId)

Returns:

BlobInfo

CommitDatabase.blobInfos(blobIds)

Return a list of BlobInfo.

Arguments:
  • blobIds (ValueBlobId[])

Returns:

BlobInfo[]

CommitDatabase.blobStatistics()

Return the statistics for blobs.

Returns:

BlobStatistics

CommitDatabase.blobStreamAppend(blobStream, blob)

Append the blob to the stream.

Arguments:
  • blobStream (BlobStream)

  • blob (ValueBlob)

CommitDatabase.blobStreamClose(blobStream)

Return the computed blob_id and close the stream.

Arguments:
  • blobStream (BlobStream)

Returns:

ValueBlobId

CommitDatabase.blobStreamCreate(blobLayout, size)

Return a stream to fill a blob.

Arguments:
  • blobLayout (BlobLayout)

  • size (number)

Returns:

BlobStream

CommitDatabase.childrenCommitIds(commitId)

Return a set of commit_id for the children of the commit.

Arguments:
  • commitId (ValueCommitId)

Returns:

ValueCommitId[]

CommitDatabase.close()

Close the database.

CommitDatabase.codecName()

Return the name of the codec.

Returns:

string

CommitDatabase.commit(commitId)

Return the commit.

Arguments:
  • commitId (ValueCommitId)

Returns:

Commit

CommitDatabase.commitDatabasing()

Return the CommitDatabasing interface.

Returns:

CommitDatabasing

CommitDatabase.commitExists(commitId)

Return true if the commit exists.

Arguments:
  • commitId (ValueCommitId)

Returns:

boolean

CommitDatabase.commitHeader(commitId)

Return the header associated with the commit.

Arguments:
  • commitId (ValueCommitId)

Returns:

CommitHeader

CommitDatabase.commitIds()

Return a set of commit_id for all available commits.

Returns:

ValueCommitId[]

CommitDatabase.commitMutations(label, commitMutableState)

Create a new commit and return the commit_id.

Arguments:
  • label (string)

  • commitMutableState (CommitMutableState)

Returns:

ValueCommitId

CommitDatabase.createBlob(blobLayout, blob)

Compute and return the blob_id for a blob and the layout.

Arguments:
  • blobLayout (BlobLayout)

  • blob (ValueBlob)

Returns:

ValueBlobId

CommitDatabase.createBlobFromBuffer(buffer)

Compute and return the blob_id for an object implementing the buffer protocol.

Arguments:
  • buffer (Buffer)

Returns:

ValueBlobId

CommitDatabase.definitions()

Return the definitions.

Returns:

DefinitionsConst

CommitDatabase.definitionsHexdigest()

Return the hexdigest of the definitions.

Returns:

string

CommitDatabase.deleteCommit(commitId)

Delete a commit.

WARNING: It’s not a feature!, it’s a trick used during interactive presentation.

Arguments:
  • commitId (ValueCommitId)

CommitDatabase.disableCommit(label, parentCommitId, disabledCommitId)

Return the commit_id of a new commit that disables another commit.

Arguments:
  • label (string)

  • parentCommitId (ValueCommitId)

  • disabledCommitId (ValueCommitId)

Returns:

ValueCommitId

CommitDatabase.documentation()

Return the documentation.

Returns:

string

CommitDatabase.enableCommit(label, parentCommitId, enabledCommitId)

Return the commit_id of the new commit that enables another commit.

Arguments:
  • label (string)

  • parentCommitId (ValueCommitId)

  • enabledCommitId (ValueCommitId)

Returns:

ValueCommitId

CommitDatabase.extendDefinitions(other)

Extend the definitions.

Arguments:
  • other (DefinitionsConst)

Returns:

DefinitionsExtendInfo

CommitDatabase.firstCommitId()

Return the commit_id of the first commit or null.

Returns:

ValueCommitId | undefined

CommitDatabase.headCommitIds()

Return a set of commit_id for the available heads.

Returns:

ValueCommitId[]

CommitDatabase.inMemory()

Return true if the database is in memory.

Returns:

boolean

CommitDatabase.isAncestor(commitId, descendantId)

Return true if commit_id is a descendant of descendant_id.

Arguments:
  • commitId (ValueCommitId)

  • descendantId (ValueCommitId)

Returns:

boolean

CommitDatabase.isClosed()

Return true is the database is closed.

Returns:

boolean

CommitDatabase.isMergeable(parentCommitId, mergedCommitId)

Return true if a merge is valid.

Arguments:
  • parentCommitId (ValueCommitId)

  • mergedCommitId (ValueCommitId)

Returns:

boolean

CommitDatabase.lastCommitId()

Return the commit_id of the last commit or null.

Returns:

ValueCommitId | undefined

CommitDatabase.mergeCommit(label, parentCommitId, mergedCommitId)

Return the commit_id of the new commit that merges another commit.

Arguments:
  • label (string)

  • parentCommitId (ValueCommitId)

  • mergedCommitId (ValueCommitId)

Returns:

ValueCommitId

CommitDatabase.nephewCommitIds(commitId)

Return a set of commit_id for the nephew of the commit.

Arguments:
  • commitId (ValueCommitId)

Returns:

ValueCommitId[]

CommitDatabase.path()

Return the path.

Returns:

string

CommitDatabase.readBlob(blobId, size, offset)

Return a region of the blob.

Arguments:
  • blobId (ValueBlobId)

  • size (number)

  • offset (number)

Returns:

ValueBlob

CommitDatabase.resetCommits()

Remove all commits except the first one.

WARNING: It’s not a feature!, it’s a trick used during interactive presentation.

CommitDatabase.streamCodecInstancing()
Return the StreamCodecInstancing interface used to encode the binary

data.

Returns:

StreamCodecInstancing

CommitDatabase.uuid()

Return the uuid.

Returns:

ValueUUId

static CommitDatabase.connect(host, service)

Connect to a remote commit server.

Arguments:
  • host (string)

  • service (string)

Returns:

CommitDatabase

static CommitDatabase.connectLocal(socketPath)

Connect to a socket located at socket_path.

Arguments:
  • socketPath (string)

Returns:

CommitDatabase

static CommitDatabase.create(filePath, documentation)

Create a database.

Arguments:
  • filePath (string)

  • documentation (string)

Returns:

CommitDatabase

static CommitDatabase.createInMemory()

Create a database in memory.

Returns:

CommitDatabase

static CommitDatabase.isCompatible(filePath)

Return true if the SQL schema contains the required tables.

Arguments:
  • filePath (string)

Returns:

boolean

static CommitDatabase.open(filePath, readonly)

Open a database.

Arguments:
  • filePath (string)

  • readonly (boolean)

Returns:

CommitDatabase

class CommitDatabaseFlattener()

Flattens a CommitDatabase commit into a single-commit CommitDatabase.

exported from index.d

CommitDatabaseFlattener.flatten(source, commitId, target, label, progress)
Flatten the state of commit_id from a CommitDatabase into target, a

CommitDatabase holding a single commit labelled label (history discarded). progress is an optional StepperDelegate. Return a DatabaseTransferInfo.

Arguments:
  • source (CommitDatabase)

  • commitId (ValueCommitId)

  • target (CommitDatabase)

  • label (string)

  • progress ((action: string, percent: number) => void | undefined)

Returns:

DatabaseTransferInfo

class CommitDatabaseHelper()
A utility class for a Commit Database.

Note: Not directly instantiable.

exported from index.d

static CommitDatabaseHelper.fastForward(commitDatabase, commitId)

Return the commit_id of the most plausible head.

Arguments:
  • commitDatabase (CommitDatabase)

  • commitId (ValueCommitId)

Returns:

ValueCommitId

static CommitDatabaseHelper.forward(commitDatabase, commitId)

Return the commit_id of the uniq head or fast_forward.

Arguments:
  • commitDatabase (CommitDatabase)

  • commitId (ValueCommitId)

Returns:

ValueCommitId

static CommitDatabaseHelper.reduceHeads(commitDatabase, commitId)
Reduce to a single head by iteratively merging the other heads into the

anchor commit_id (which must be a head; default: last_commit_id). Return the new commit_id or null.

Arguments:
  • commitDatabase (CommitDatabase)

  • commitId (ValueCommitId)

Returns:

ValueCommitId | undefined

class CommitDatabaseRemote()
A low-level class used to represent a remote Commit database through the

CommitDatabasing interface. Use the high-level static factory method CommitDatabase.connect(…) or CommitDatabase.connectLocal(…).

Note: Not directly instantiable.

exported from index.d

CommitDatabaseRemote.close()

Close the connection.

CommitDatabaseRemote.commitDatabasing()

Return the CommitDatabasing interface.

Returns:

CommitDatabasing

CommitDatabaseRemote.downloadSpeed(size)
Return the download speed in MBps (Mega Bytes per second)

The size is expressed in Mega Bytes [1-1000].

Arguments:
  • size (number)

Returns:

number

CommitDatabaseRemote.isClosed()

Return true if the server is closed.

Returns:

boolean

CommitDatabaseRemote.ping()
Ping (latency is the technically more correct term) means the time it

takes for a small data set to be transmitted from your device to a server and back to your device again. The ping time is measured in milliseconds (ms).

Returns:

number

CommitDatabaseRemote.uploadSpeed(size)
Return the upload speed in MBps (Mega Bytes per second)

The size is expressed in Mega Bytes [1-1000].

Arguments:
  • size (number)

Returns:

number

static CommitDatabaseRemote.connect(host, service)

Connect to a remote commit server.

Arguments:
  • host (string)

  • service (string)

Returns:

CommitDatabaseRemote

static CommitDatabaseRemote.connectLocal(socketPath)

Connect to the socket located at socket_path.

Arguments:
  • socketPath (string)

Returns:

CommitDatabaseRemote

class CommitDatabaseSQLite()
A low-level class used to represent the database based on SQLite3 through the

CommitDatabasing interface. Use the high-level static factory method CommitDatabase.create(…) or CommitDatabase.open(…).

Note: Not directly instantiable.

exported from index.d

CommitDatabaseSQLite.beginTransaction()

Create a transaction to boost the creation of many blobs.

CommitDatabaseSQLite.close()

Close the database.

CommitDatabaseSQLite.commit()

Commit the transaction.

CommitDatabaseSQLite.commitDatabasing()

Return the CommitDatabasing interface.

Returns:

CommitDatabasing

CommitDatabaseSQLite.inTransaction()

Return true if a transaction is running.

Returns:

boolean

CommitDatabaseSQLite.isClosed()

Return true if the database is closed.

Returns:

boolean

CommitDatabaseSQLite.rollback()

Roll back the transaction.

CommitDatabaseSQLite.sqlite()

Return a SQLite.

Returns:

SQLite

static CommitDatabaseSQLite.create(filePath, documentation)

Create a database.

Arguments:
  • filePath (string)

  • documentation (string)

Returns:

CommitDatabaseSQLite

static CommitDatabaseSQLite.createInMemory()

Create a database in memory.

Returns:

CommitDatabaseSQLite

static CommitDatabaseSQLite.isCompatible(filePath)

Return true if the SQL schema contains the required tables.

Arguments:
  • filePath (string)

Returns:

boolean

static CommitDatabaseSQLite.open(filePath, readonly)

Open a database.

Arguments:
  • filePath (string)

  • readonly (boolean)

Returns:

CommitDatabaseSQLite

class CommitDatabaseToDatabaseConverter()

Converts a CommitDatabase into a Database.

exported from index.d

CommitDatabaseToDatabaseConverter.convert(source, commitId, target, progress)
Materialize the state of commit_id from a CommitDatabase into a Database.

progress is an optional StepperDelegate. Return a DatabaseTransferInfo.

Arguments:
  • source (CommitDatabase)

  • commitId (ValueCommitId)

  • target (Database)

  • progress ((action: string, percent: number) => void | undefined)

Returns:

DatabaseTransferInfo

class CommitDatabasing()
An interface used to abstract the implementation of the persistence layer for a

Commit database. This is a low-level interface (a driver) and requires a deep understanding of Commit to be used correctly.

Note: Not directly instantiable.

exported from index.d

CommitDatabasing.beginTransaction(mode)
Begin a transaction where the mode is ‘Deferred’, ‘Immediate’ or

‘Exclusive’.

Arguments:
  • mode (string)

CommitDatabasing.blob(blobId)

Return a blob or null.

Arguments:
  • blobId (ValueBlobId)

Returns:

ValueBlob | undefined

CommitDatabasing.blobDatas(blobIds)

Return a list of BlobData.

Arguments:
  • blobIds (ValueBlobId[])

Returns:

BlobData[]

CommitDatabasing.blobIds()

Return a set of blob_id for all available blobs.

Returns:

ValueBlobId[]

CommitDatabasing.blobInfo(blobId)

Return the information of a blob.

Arguments:
  • blobId (ValueBlobId)

Returns:

BlobInfo | undefined

CommitDatabasing.blobInfos(blobIds)

Return a list of BlobInfo.

Arguments:
  • blobIds (ValueBlobId[])

Returns:

BlobInfo[]

CommitDatabasing.blobStatistics()

Return the statistics for blobs.

Returns:

BlobStatistics

CommitDatabasing.blobStreamClose(streamId, blobId)

Close the stream.

Arguments:
  • streamId (ValueUUId)

  • blobId (ValueBlobId)

CommitDatabasing.blobStreamCreate(blobLayout, size)

Return the uuid of the stream.

Arguments:
  • blobLayout (BlobLayout)

  • size (number)

Returns:

ValueUUId

CommitDatabasing.blobStreamDelete(streamId)

Delete the stream.

Arguments:
  • streamId (ValueUUId)

CommitDatabasing.blobStreamWrite(streamId, blob, offset)

Write a region of the blob.

Arguments:
  • streamId (ValueUUId)

  • blob (ValueBlob)

  • offset (number)

CommitDatabasing.childrenCommitIds(commitId)

Return the set of commit_id for the children of the commit.

Arguments:
  • commitId (ValueCommitId)

Returns:

ValueCommitId[]

CommitDatabasing.close()

Close the connection.

CommitDatabasing.codecName()

Return the name of the codec.

Returns:

string

CommitDatabasing.commit()

Commit the transaction.

CommitDatabasing.commitData(commitId)

Return a CommitData or null.

Arguments:
  • commitId (ValueCommitId)

Returns:

CommitData | undefined

CommitDatabasing.commitDatas(commitIds)

Return the list of CommitData.

Arguments:
  • commitIds (ValueCommitId[])

Returns:

CommitData[]

CommitDatabasing.commitExists(commitId)

Return true if the commit exists.

Arguments:
  • commitId (ValueCommitId)

Returns:

boolean

CommitDatabasing.commitHeader(commitId)

Return the header of the commit associated with the commit_id.

Arguments:
  • commitId (ValueCommitId)

Returns:

CommitHeader

CommitDatabasing.commitIds()

Return the set of commit_ids.

Returns:

ValueCommitId[]

CommitDatabasing.createBlob(blobId, blobLayout, blob)

Create a blob.

Arguments:
  • blobId (ValueBlobId)

  • blobLayout (BlobLayout)

  • blob (ValueBlob)

Returns:

boolean

CommitDatabasing.createBlobs(blobDatas)

Create blobs from a list of BlobDatas and return a set of blob_id.

Arguments:
  • blobDatas (BlobData[])

Returns:

ValueBlobId[]

CommitDatabasing.createCommitData(commitData)

Create a commit if not present or return false.

Arguments:
  • commitData (CommitData)

Returns:

boolean

CommitDatabasing.createZeroBlob(blobId, blobLayout, size)

Return the true if the blob was created.

Arguments:
  • blobId (ValueBlobId)

  • blobLayout (BlobLayout)

  • size (number)

Returns:

boolean

CommitDatabasing.dataVersion()

Return the data version.

Returns:

number

CommitDatabasing.definitions()

Return the definitions.

Returns:

DefinitionsConst

CommitDatabasing.definitionsHexdigest()

Return the hexdigest of the definitions.

Returns:

string

CommitDatabasing.deleteCommit(commitId)

Delete a commit.

WARNING: It’s not a feature!, it’s a trick used during interactive presentation.

Arguments:
  • commitId (ValueCommitId)

CommitDatabasing.documentation()

Return the documentation.

Returns:

string

CommitDatabasing.extendDefinitions(other)

Extend the definitions.

Arguments:
  • other (DefinitionsConst)

Returns:

DefinitionsExtendInfo

CommitDatabasing.firstCommitId()

Return the commit_id of the first commit or null.

Returns:

ValueCommitId | undefined

CommitDatabasing.freezeBlob(blobId)

Return true if the blob was frozen.

Arguments:
  • blobId (ValueBlobId)

Returns:

boolean

CommitDatabasing.headCommitIds()

Return the set of commit_id for the heads.

Returns:

ValueCommitId[]

CommitDatabasing.inTransaction()

Return true if a transaction is running.

Returns:

boolean

CommitDatabasing.isClosed()

Return true is the connection to the database is closed.

Returns:

boolean

CommitDatabasing.lastCommitId()

Return the commit_id of the last commit or null.

Returns:

ValueCommitId | undefined

CommitDatabasing.nephewCommitIds(commitId)

Return the set of commit_id for the nephew of the commit.

Arguments:
  • commitId (ValueCommitId)

Returns:

ValueCommitId[]

CommitDatabasing.path()

Return the path.

Returns:

string

CommitDatabasing.readBlob(blobId, size, offset)

Return the blob at offset.

Arguments:
  • blobId (ValueBlobId)

  • size (number)

  • offset (number)

Returns:

ValueBlob

CommitDatabasing.resetCommits()

Remove all commits except the first one.

WARNING: It’s not a feature!, it’s a trick used during interactive presentation.

CommitDatabasing.rollback()

Roll back the transaction.

CommitDatabasing.syncData(commitIds)

Return a CommitSyncData.

Arguments:
  • commitIds (ValueCommitId[])

Returns:

CommitSyncData

CommitDatabasing.unknownBlobIds(blobIds)

Return a set of blob_id for all unknown blobId found in blob_ids.

Arguments:
  • blobIds (ValueBlobId[])

Returns:

ValueBlobId[]

CommitDatabasing.uuid()

Return the uuid.

Returns:

ValueUUId

CommitDatabasing.writeBlob(blobId, blob, offset)

Write a blob at offset.

Arguments:
  • blobId (ValueBlobId)

  • blob (ValueBlob)

  • offset (number)

class CommitEvalAction()
A class used by the evaluator to reconstruct a value by executing mutation

opcodes.

Note: Not directly instantiable.

exported from index.d

CommitEvalAction.enabled()

Return true if the commit is enabled.

Returns:

boolean

CommitEvalAction.header()

Return the header of the commit.

Returns:

CommitHeader

CommitEvalAction.program()

Return the program.

Returns:

ValueProgram

class CommitHeader()

A class used to represent the header of a commit.

Note: Not directly instantiable.

exported from index.d

CommitHeader.commitId()

Return the commit_id of the commit.

Returns:

ValueCommitId

CommitHeader.commitType()

Return the type (‘Mutations’, ‘Disable’, ‘Enable’ or ‘Merge’).

Returns:

string

CommitHeader.label()

Return the label.

Returns:

string

CommitHeader.parentCommitId()

Return the commit_id of the parent commit.

Returns:

ValueCommitId

CommitHeader.targetCommitId()

Return the commit_id of the target commit.

Returns:

ValueCommitId

CommitHeader.timestamp()

Return the timestamp.

Returns:

number

class CommitMergeAnalysis()
The result of a 3-way merge analysis: the merge base and the list of

reconstructed conflicts between the two branches.

Note: Not directly instantiable.

exported from index.d

CommitMergeAnalysis.base()
Return the structural merge base commit identifier, or null when the

analysis fell back to a base-free 2-way scan.

Returns:

ValueCommitId | undefined

CommitMergeAnalysis.conflicts()

Return all conflicts flattened across documents.

Returns:

CommitMergeConflict[]

CommitMergeAnalysis.documents()
Return the list of CommitMergeDocument — the conflicts grouped per

document (attachment, key), the unit reconcile operates on.

Returns:

CommitMergeDocument[]

CommitMergeAnalysis.hasConflicts()

Return true if the merge has at least one conflict.

Returns:

boolean

CommitMergeAnalysis.mergeCommit()
Return the merge commit identifier this analysis read, or null for a

virtual (pre-merge) analysis computed without a persisted merge commit.

Returns:

ValueCommitId | undefined

CommitMergeAnalysis.ours()

Return the parent (ours) commit identifier.

Returns:

ValueCommitId

CommitMergeAnalysis.theirs()

Return the target (theirs) commit identifier.

Returns:

ValueCommitId

CommitMergeAnalysis.twoWay()
Return true when no unambiguous structural base existed and detection

fell back to a base-free 2-way divergence scan.

Returns:

boolean

class CommitMergeAnalyzer()
Additive, post-merge 3-way reconciliation over a CommitDatabase. Static

methods only; the Commit Engine itself is not modified.

Note: Not directly instantiable.

exported from index.d

static CommitMergeAnalyzer.analyzeMerge(db, mergeCommit)
Read the state of merge_commit and return a CommitMergeAnalysis: the loci

where one branch’s intent did not survive the merge. 3-way when a unique structural base exists, base-free 2-way fallback otherwise. Throws when merge_commit is not a merge commit.

Arguments:
  • db (CommitDatabase)

  • mergeCommit (ValueCommitId)

Returns:

CommitMergeAnalysis

static CommitMergeAnalyzer.analyzeVirtualMerge(db, ours, theirs)
Pre-merge analysis: the same classification against the computed merge state

of (ours, theirs), without persisting a merge commit. The result’s mergeCommit() is null (it cannot feed reconcile until materialized).

Arguments:
  • db (CommitDatabase)

  • ours (ValueCommitId)

  • theirs (ValueCommitId)

Returns:

CommitMergeAnalysis

static CommitMergeAnalyzer.materializeMerge(db, ours, theirs, resolutions, mergeLabel, survivalLabel)
Pre-merge materialization: write the Merge join of (ours, theirs), then the

survival commit against it. Returns (merge_commit, survival); survival == merge_commit when every decree accepts the merge.

Arguments:
  • db (CommitDatabase)

  • ours (ValueCommitId)

  • theirs (ValueCommitId)

  • resolutions (CommitMergeResolution[])

  • mergeLabel (string)

  • survivalLabel (string)

Returns:

[ValueCommitId, ValueCommitId]

static CommitMergeAnalyzer.mergeBase(db, a, b)
Return the structural merge base of two commits, or null when there is

no common ancestor or several maximal common ancestors (criss-cross).

Arguments:
  • db (CommitDatabase)

  • a (ValueCommitId)

  • b (ValueCommitId)

Returns:

ValueCommitId | undefined

static CommitMergeAnalyzer.reconcile(db, mergeCommit, resolutions, label)
Author the survival commit for a merge: per document, copy the merge

state, place each decree at its path, then diff against the merge state. Returns a Mutations commit child of merge_commit, or merge_commit itself when every decree accepts the merge (no surviving opcode).

Arguments:
  • db (CommitDatabase)

  • mergeCommit (ValueCommitId)

  • resolutions (CommitMergeResolution[])

  • label (string)

Returns:

ValueCommitId

static CommitMergeAnalyzer.reconcileState(mergeState, resolutions)
Pure compose: per document, copy merge_state, place each decree at its

path, diff into a working CommitMutableState. No commit is written; the returned state is what a UI renders and edits live. reconcile is this followed by commit_mutations.

Arguments:
  • mergeState (CommitState)

  • resolutions (CommitMergeResolution[])

Returns:

CommitMutableState

class CommitMergeConflict()
A single locus, anchored on a path, where one branch’s intent did not

survive the merge, reconstructed as base/ours/theirs/merged values.

Note: Not directly instantiable.

exported from index.d

CommitMergeConflict.attachment()

Return the attachment the conflicting key belongs to.

Returns:

Attachment

CommitMergeConflict.baseValue()

Return the value at the merge base (nil in 2-way mode).

Returns:

ValueOptional

CommitMergeConflict.key()

Return the conflicting key.

Returns:

ValueKey

CommitMergeConflict.mergedValue()

Return the value the merge actually produced at this locus.

Returns:

ValueOptional

CommitMergeConflict.oursValue()

Return the value on the parent (ours) side.

Returns:

ValueOptional

CommitMergeConflict.path()
Return the locus inside the document where the intent was lost (root

for a scalar attachment).

Returns:

PathConst

CommitMergeConflict.theirsValue()

Return the value on the target (theirs) side.

Returns:

ValueOptional

class CommitMergeDocument()
All conflicts of one document (attachment, key) — the unit reconcile

operates on. Carries the whole merged document as context.

Note: Not directly instantiable.

exported from index.d

CommitMergeDocument.attachment()

Return the attachment of this document.

Returns:

Attachment

CommitMergeDocument.conflicts()

Return the list of CommitMergeConflict localised in this document.

Returns:

CommitMergeConflict[]

CommitMergeDocument.key()

Return the key of this document.

Returns:

ValueKey

CommitMergeDocument.mergedValue()

Return the whole merged document, as context for its conflicts.

Returns:

ValueOptional

class CommitMergeResolution(conflict, chosen)
A supervisor’s decree for one conflict: the chosen value should survive

at the conflict’s locus. A root locus decrees the whole document.

exported from index.d

Arguments:
  • conflict (CommitMergeConflict)

  • chosen (Value)

CommitMergeResolution.chosen()

Return the dictated value at the conflict’s locus.

Returns:

Value

CommitMergeResolution.conflict()

Return the conflict this resolution decrees.

Returns:

CommitMergeConflict

class CommitMutableState(state)
A class used to register the mutations of a value executed through the

attachmentMutating interface.

exported from index.d

Arguments:
  • state (CommitState)

CommitMutableState.attachmentGetting()

Return the AttachmentGetting interface.

Returns:

AttachmentGetting

CommitMutableState.attachmentMutating()

Return the attachmentMutating interface.

Returns:

AttachmentMutating

CommitMutableState.commitState()

Return the CommitState.

Returns:

CommitState

CommitMutableState.commitStateTracing()

Return the AttachmentGetting interface.

Returns:

CommitStateTracing

CommitMutableState.mutations()

Return the program for the current mutations.

Returns:

ValueProgram

class CommitNode()

A class used to represent a node in the commit DAG.

Note: Not directly instantiable.

exported from index.d

CommitNode.children()

Return the list of childs.

Returns:

CommitNode[]

CommitNode.header()

Return the header.

Returns:

CommitHeader

static CommitNode.build(commitDatabase)

Create and return the DAG of commit.

Arguments:
  • commitDatabase (CommitDatabase)

Returns:

CommitNode

class CommitNodeGrid()

A class used to represent the location of a commit node in the grid.

Note: Not directly instantiable.

exported from index.d

CommitNodeGrid.childCount()

Return the number of children.

Returns:

number

CommitNodeGrid.children()

Return the list of childs.

Returns:

CommitNodeGrid[]

CommitNodeGrid.column()

Return the column.

Returns:

number

CommitNodeGrid.commitId()

Return the commitId.

Returns:

ValueCommitId

CommitNodeGrid.hasChildren()

Return true if the node have children.

Returns:

boolean

CommitNodeGrid.header()

Return the header.

Returns:

CommitHeader

CommitNodeGrid.parent()

Return the parent or null.

Returns:

CommitNodeGrid | undefined

CommitNodeGrid.row()

Return the row.

Returns:

number

class CommitNodeGridBuilder()

A class used to build the grid layout of the commit DAG.

Note: Not directly instantiable.

exported from index.d

CommitNodeGridBuilder.columnMax()

Return the max index for a column.

Returns:

number

CommitNodeGridBuilder.nodes()

Return a dict[uuid, CommitNodeGrid].

Returns:

[ValueCommitId, CommitNodeGrid][]

CommitNodeGridBuilder.root()

Return the root node or null.

Returns:

CommitNodeGrid | undefined

CommitNodeGridBuilder.rowMax()

Return the max index for row.

Returns:

number

static CommitNodeGridBuilder.build(commitNode)

Create and return the builder.

Arguments:
  • commitNode (CommitNode)

Returns:

CommitNodeGridBuilder

class CommitState(definitions)
A class used to represent data at a specific commit. Use the attachmentGetting

interface to retrieve value by key from attachments.

Note: Not directly instantiable.

exported from index.d

Arguments:
  • definitions (DefinitionsConst)

CommitState.attachmentGetting()

Return the AttachmentGetting interface.

Returns:

AttachmentGetting

CommitState.cacheHitRate()

Return the cache hit rate.

Returns:

number

CommitState.cacheHits()

Return the count of value return from the cache.

Returns:

number

CommitState.cachePreload()

Return the tuple time to get all documents.

Returns:

number

CommitState.cacheRequests()

Return the count of value requested.

Returns:

number

CommitState.commitId()

Return the identifier of the commit.

Returns:

ValueCommitId

CommitState.commitStateTracing()

Return the AttachmentGetting interface.

Returns:

CommitStateTracing

CommitState.definitions()

Return the definitions.

Returns:

DefinitionsConst

CommitState.evalActions()

Return a list of CommitEvalAction.

Returns:

CommitEvalAction[]

CommitState.tracedOpcodes()

Return the list of opcodes from the commit trace.

Returns:

ValueOpcode[]

class CommitStateBuilder()
A utility class to build CommitState.

Target Wins linearization is used. Note: Not directly instantiable.

exported from index.d

static CommitStateBuilder.enabledByCommitId(commitDatabase, commitId)

Return a dict[ValueCommitId, bool].

Arguments:
  • commitDatabase (CommitDatabase)

  • commitId (ValueCommitId)

Returns:

[ValueCommitId, boolean][]

static CommitStateBuilder.initialState(commitDatabase)

Return the initial state.

Arguments:
  • commitDatabase (CommitDatabase)

Returns:

CommitState

static CommitStateBuilder.mergeEnabledByCommitId(commitDatabase, ours, theirs)
Return the enabled/disabled dict[ValueCommitId, bool] of the virtual merge of

(ours, theirs), without persisting a merge commit.

Arguments:
  • commitDatabase (CommitDatabase)

  • ours (ValueCommitId)

  • theirs (ValueCommitId)

Returns:

[ValueCommitId, boolean][]

static CommitStateBuilder.mergeState(commitDatabase, ours, theirs)

Return the computed merge state of (ours, theirs) without persisting a merge commit. Value-identical to state(mergeCommit(ours, theirs)).

Arguments:
  • commitDatabase (CommitDatabase)

  • ours (ValueCommitId)

  • theirs (ValueCommitId)

Returns:

CommitState

static CommitStateBuilder.state(commitDatabase, commitId)

Return a new state for a commit.

Arguments:
  • commitDatabase (CommitDatabase)

  • commitId (ValueCommitId)

Returns:

CommitState

class CommitStateTrace()

A class used to represent traced opcode.

Note: Not directly instantiable.

exported from index.d

CommitStateTrace.attachment()

Return the attachment.

Returns:

Attachment

CommitStateTrace.key()

Return the key.

Returns:

ValueKey

CommitStateTrace.programs()

Return the list of programs.

Returns:

CommitStateTraceProgram[]

CommitStateTrace.value()

Return the value.

Returns:

ValueOptional

class CommitStateTraceProgram()

A class used to represent traced opcode.

Note: Not directly instantiable.

exported from index.d

CommitStateTraceProgram.header()

Return the commit header or null.

Returns:

CommitHeader | undefined

CommitStateTraceProgram.trace()

Return the trace.

Returns:

ValueProcessorTrace

class CommitStateTracing()

An interface used to trace a value (aka document).

Note: Not directly instantiable.

exported from index.d

CommitStateTracing.trace(attachment, key)
Return an CommitStateTrace associated with the key in the

attachment.

Arguments:
  • attachment (Attachment)

  • key (ValueKey)

Returns:

CommitStateTrace

class CommitStore()
A high-level application class used to implement the store, dispatch,

undo/redo and notification concepts inspired by the redux approach.

The implementation used a Commit database for the persistence layer.

exported from index.d

CommitStore.attachmentGetting()

Return the AttachmentGetting interface of the current state or throw.

Returns:

AttachmentGetting

CommitStore.canRedo()

Return true if the store can redo.

Returns:

boolean

CommitStore.canUndo()

Return true if the store can undo.

Returns:

boolean

CommitStore.clearUndoRedo()

clear the undo redo stack.

CommitStore.close()

Close the database.

CommitStore.commitMutations(label, commitMutableState)

Commit the mutations tracked by the mutable state.

Arguments:
  • label (string)

  • commitMutableState (CommitMutableState)

CommitStore.database()

Return the database or throw.

Returns:

CommitDatabase

CommitStore.definitions()

Return the definitions.

Returns:

DefinitionsConst

CommitStore.deleteCommit(commitId)

Delete a commit.

WARNING: It’s not a feature!, it’s a trick used during interactive presentation.

Arguments:
  • commitId (ValueCommitId)

CommitStore.disableCommit(commitId)

Disable a commit.

Arguments:
  • commitId (ValueCommitId)

CommitStore.dispatch<T>(label, callable, ...args)
Dispatch a callable. The callable receives an AttachmentMutating handle

followed by the extra args; its return value is returned by dispatch.

Type parameters:

T

Arguments:
  • label (string)

  • callable ((mutating: AttachmentMutating, args: any[]) => T)

  • args (any[])

Returns:

T

CommitStore.dispatchDiff(label, attachment, key, value, recursive)

Dispatch a mutating diff(…).

Arguments:
  • label (string)

  • attachment (Attachment)

  • key (ValueKey)

  • value (InputValue)

  • recursive (boolean)

CommitStore.dispatchEnableCommit(commitId, enabled)

Dispatch the act of enabling/disabling a commit.

Arguments:
  • commitId (ValueCommitId)

  • enabled (boolean)

CommitStore.dispatchSet(label, attachment, key, value)

Dispatch a mutating set(…).

Arguments:
  • label (string)

  • attachment (Attachment)

  • key (ValueKey)

  • value (InputValue)

CommitStore.dispatchUpdate(label, attachment, key, path, value)

Dispatch a mutating update(…).

Arguments:
  • label (string)

  • attachment (Attachment)

  • key (ValueKey)

  • path (PathConst)

  • value (InputValue)

CommitStore.enableCommit(commitId)

Enable a commit.

Arguments:
  • commitId (ValueCommitId)

CommitStore.extendDefinitions(definitions)

Extend the database definitions and notify.

Arguments:
  • definitions (DefinitionsConst)

Returns:

DefinitionsExtendInfo

CommitStore.forward()

Move to the most plausible head.

CommitStore.hasDatabase()

Return true there is a database.

Returns:

boolean

CommitStore.hasState()

Return true there is a state.

Returns:

boolean

CommitStore.mergeCommit(commitId)

Merge a commit.

Arguments:
  • commitId (ValueCommitId)

CommitStore.mutableState()

Return a new mutable state for the current state.

Returns:

CommitMutableState

CommitStore.notifier()

Return the notifier or null.

Returns:

CommitStoreNotifying | undefined

CommitStore.notifyDatabaseDidClose()

Send a notification to inform that the database was closed.

CommitStore.notifyDatabaseDidOpen()

Send a notification to inform that the database was opened.

CommitStore.notifyDatabaseDidReset()

Send a notification to inform that the database did reset.

CommitStore.notifyDatabaseWillReset()

Send a notification to inform that the database will reset.

CommitStore.notifyDefinitionsDidChange()

Send a notification to inform that the definitions has changed.

CommitStore.notifyDispatchError(error)

Send a notification to inform that an error occurred during a dispatch.

Arguments:
  • error (Error)

CommitStore.notifyResetDatabase()

Send a notification to reset the database.

CommitStore.notifyStateDidChange()

Send a notification to inform that the current state has changed.

CommitStore.notifyStopLive()

Send a notification to stop the live mode.

CommitStore.redo()

Implement the undo idiom for a Commit database.

CommitStore.reduceHeads()
Reduce to a single head by iteratively merging heads, starting from

the last_commit_id.

CommitStore.reset()

Remove all commits except the first one.

WARNING: It’s not a feature!, it’s a trick used during interactive presentation.

CommitStore.resetUndoRedo()

Reset the undo redo stack.

CommitStore.setDatabase(commitDatabase)

set the database.

Arguments:
  • commitDatabase (CommitDatabase)

CommitStore.setNotifier(notifier)

Set the notifier.

Arguments:
  • notifier (CommitStoreNotifying)

CommitStore.setState(commitState)

set the state.

Arguments:
  • commitState (CommitState)

CommitStore.state()

Return the current state or throw.

Returns:

CommitState | undefined

CommitStore.undo()

Implement the undo idiom for a Commit database.

CommitStore.undoStackIds()

Return (commit_ids, current_commit_id).

Returns:

[ValueCommitId[], number | undefined]

CommitStore.use(commitDatabase)

Use a Commit database.

Arguments:
  • commitDatabase (CommitDatabase)

CommitStore.useCommit(commitId)

Use a commit.

Arguments:
  • commitId (ValueCommitId)

class CommitStoreNotifying()

An interface used to represent the notification emitted by a store.

Note: Not directly instantiable.

exported from index.d

CommitStoreNotifying.notifyDatabaseDidClose()

Send a notification to inform that the database was closed.

CommitStoreNotifying.notifyDatabaseDidOpen()

Send a notification to inform that the database was opened.

CommitStoreNotifying.notifyDatabaseDidReset()

Send a notification to inform that the database did reset.

CommitStoreNotifying.notifyDatabaseWillReset()

Send a notification to inform that the database will be reset.

CommitStoreNotifying.notifyDefinitionsDidChange()

Send a notification to inform that the definitions have changed.

CommitStoreNotifying.notifyDispatchError(error)

Send a notification to inform that an error occurred during a dispatch.

Arguments:
  • error (Error)

CommitStoreNotifying.notifyResetDatabase()

Send a notification to reset the database.

CommitStoreNotifying.notifyStateDidChange()

Send a notification to inform that the current state has changed.

CommitStoreNotifying.notifyStopLive()

Send a notification to stop the live mode.

static CommitStoreNotifying.create(object)
Return a new CommitStoreStoringBaseNotifying if the Python object

responds to the interface or throw.

Arguments:
  • object (NativeValue)

Returns:

CommitStoreNotifying

class CommitSyncData()
A class used to represent data exchanged during the synchronization of two

databases.

Note: Not directly instantiable.

exported from index.d

CommitSyncData.codecName()

Return the name of the codec.

Returns:

string

CommitSyncData.commitDatas()

Return the list of CommitData.

Returns:

CommitData[]

CommitSyncData.definitionsHexdigest()

Return the hexdigest of the definitions.

Returns:

string

class CommitSynchronizer(source, target, mode, sizeOfPackedBlobs)
A class used to synchronize two concrete databases through the

CommitDatabasing interface (low-level driver interface).

exported from index.d

Arguments:
  • source (CommitDatabasing)

  • target (CommitDatabasing)

  • mode (string)

  • sizeOfPackedBlobs (number)

CommitSynchronizer.MODE_FETCH

type: readonly string

CommitSynchronizer.MODE_PUSH

type: readonly string

CommitSynchronizer.MODE_SYNC

type: readonly string

CommitSynchronizer.mode()

Return the mode.

Returns:

string

CommitSynchronizer.sizeOfPackedBlobs()

Return the size of the blob used to pack smaller blobs together.

Returns:

number

CommitSynchronizer.source()

Return the CommitDatabasing interface for the source.

Returns:

CommitDatabasing

CommitSynchronizer.sync(logging)

Synchronize the content of the source and the target.

Arguments:
  • logging (Logging)

Returns:

CommitSynchronizerInfo

CommitSynchronizer.target()

Return the CommitDatabasing interface for the target.

Returns:

CommitDatabasing

class CommitSynchronizerInfo()
A class used to represent data exchanged during the synchronization of two

databases.

Note: Not directly instantiable.

exported from index.d

CommitSynchronizerInfo.fetch()

Return information for fetched resources.

Returns:

CommitSynchronizerInfoTransmit

CommitSynchronizerInfo.needTransmit()

Return true if the synchronization requires exchanging data.

Returns:

boolean

CommitSynchronizerInfo.push()

Return information for pushed resources.

Returns:

CommitSynchronizerInfoTransmit

CommitSynchronizerInfo.updatedDefinitions()

Return true if the definitions has updated.

Returns:

boolean

class CommitSynchronizerInfoTransmit()
A class used to represent statistics of data exchanged during the

synchronization of two databases.

Note: Not directly instantiable.

exported from index.d

CommitSynchronizerInfoTransmit.blobBytes()

Return the number of bytes for blobs.

Returns:

number

CommitSynchronizerInfoTransmit.blobs()

Return the number of blobs.

Returns:

number

CommitSynchronizerInfoTransmit.commitBytes()

Return the number of commit bytes fetched.

Returns:

number

CommitSynchronizerInfoTransmit.commits()

Return the number of commits fetched.

Returns:

number

CommitSynchronizerInfoTransmit.extendInfo()

Return the information to extend.

Returns:

DefinitionsExtendInfo