Skip to content

Production integration

Colla supplies deterministic content transitions and a small in-process Document state machine. Your system still defines delivery, identity, storage, and product policy.

The boundary map

LayerOwnsDoes not own
CoreValues, Changes, codecs, and OT algebraUsers, revisions, transport, or storage
DocumentVisible/confirmed values, pending locals, rebase, and eventsNetwork sessions, retries, or global deduplication
Application protocolDocument identity, requests, auth, retry, and recoveryCore Change semantics
ServerDurable ordering, accepted history, and checkpointsEditor rendering and local Wasm handles
Editor adapterUI transactions, selections, and render schedulingServer revision assignment

Keep these responsibilities separate so a protocol migration does not require rewriting the editor reducer, and an editor migration does not change the wire format.

End-to-end flow

text
editor input
    -> Document.transact(tx => ...)
    -> update.bytes (Uint8Array)
    -> application queue and transport
    -> server authentication, ordering, and persistence
    -> ordered Update bytes
    -> Document.applyRemote(bytes)
    -> immutable editSteps
    -> editor render

The visible value changes when transact() succeeds, before a server acknowledgement. The server acknowledgement only advances confirmed state; it does not create another visible edit. A remote Update must name the next confirmed revision, or the application must recover through replay or a new Snapshot.

A minimal controller boundary

ts
import { Document } from 'colla-ot'

// `queue`, `transport`, and `editor` are application-owned.
const document = Document.fromJS(initialValue, initialRevision)
const stop = document.subscribe(event => {
  if (event.origin === 'remote') editor.applyEditSteps(event.editSteps)
})

const update = document.transact(tx => {
  tx.set(['title'], 'New Title')
})
await queue.append({ requestId: crypto.randomUUID(), bytes: update.bytes })
const accepted = await transport.receiveOrdered()
document.applyRemote(accepted)
document.ack(update.updateId)

The sample shows ownership, not a required transport API. Add authorization, request identity, retry state, and durable queue records in the controller. Never use the instance-local updateId as a server-wide operation identity.

Read the production guides

Next: Synchronization protocol.

Colla v0.3.0 · Released under the MIT License.