Skip to content

Glossary, errors, and limits

Reference

Use the same words at the Core, Document, and protocol boundaries. This page is the quick lookup for terms, stable error classifications, coordinate conventions, and resource policy.

For operation semantics, see the Data model and the OT guide. For byte-level details, see the Protocol reference.

Data model

TermMeaning
ValueAn immutable, closed recursive tree: Null, Bool, Int, Float, String, Text, RichText, List, or Map.
Core ValueAn immutable Value used by the Rust colla crate and JavaScript colla-ot package.
StringAn atomic UTF-8 value replaced as a whole; it is not character-level OT.
TextA collaborative sequence whose operation lengths count Unicode scalar values.
RichTextText and atomic embed spans with canonical attributes and formatting patches.
EmbedOne atomic Value inside RichText; it counts as one sequence unit and cannot be recursively edited there.
ListAn ordered sequence of nested Values. List Modify consumes one base element.
MapA string-keyed collection with unique keys and canonical lexical ordering.
AttrsRichText formatting attributes; values are Bool, Int, finite Float, or String.
AttrPatchExplicit Set/Remove changes applied to retained RichText content.
PathA temporary Snapshot-relative sequence of map keys and list indexes; never part of a Change or body.

Operations and state

TermMeaning
ChangeOne immutable forward operation relative to a base Value. It carries no old values, revision, author, or ID.
NoopThe identity Change. Empty typed changes and IntAdd(0) normalize to Noop.
ReplaceReplaces a complete target Value, including its type.
ApplyExecutes a Change against a concrete base and returns a new Value.
ComposeCombines sequential Changes so the result has the same effect as applying them in order.
InvertBuilds an undo Change; the original base is required because a Change has no old values.
TransformRewrites concurrent Changes from one common base. Colla exposes pairwise transform_pair/transformPair.
TieBreakDeterministic LeftFirst/RightFirst ordering for otherwise unresolved concurrent conflicts.
TP1Pairwise convergence: applying transformed operations in either order yields the same result when both are applicable.
TP2Path independence across three or more transform paths; Colla does not guarantee it.
DocumentJavaScript mutable state: visible Value, confirmed revision, pending Updates, and events.
SnapshotA persistable content checkpoint containing revision and visible Value.
UpdateOne Change plus its base revision and local updateId, suitable for an outer application transport.
Confirmed revisionThe latest server-ordered revision incorporated into a Document's confirmed state.
Pending updateA local Update applied optimistically but not yet acknowledged in FIFO order.
RebaseTransforming pending local Changes over an accepted remote Update while preserving visible edits.

Codec vocabulary

TermMeaning
Core bodyA versionless canonical Value or Change byte sequence produced by encode.
CanonicalA unique byte representation plus constructor-normalized semantic operation form.
cocodecThe shared low-level codec machinery for tags, varints, UTF-8, ordering, and decoder defenses.
EnvelopeA versioned wrapper around a body. COLLAS wraps Snapshot data; COLLAU wraps Update data.
MagicThe six ASCII bytes identifying an envelope type: COLLAS or COLLAU.
Protocol versionThe little-endian u16 in an envelope header; the current version is 1.
Trailing bytesAny bytes left after one complete value, Change, Snapshot, or Update; strict decoders reject them.
Byte canonicalityStructural wire rules such as shortest varints, valid UTF-8, known tags, key order, and complete input.
Semantic normalizationConstructor/algebra cleanup such as merging adjacent operations and dropping empty retains.

Snapshot and Update envelopes are not interchangeable with raw Value and Change bodies. A Snapshot payload is (revision, content); an Update payload is (revision, updateId, change). See Protocol reference.

Stable error codes

The JavaScript facade throws CollaError with a stable string code. Rust keeps rich typed error families and exposes .code()/ErrorCode::as_str() for the families that participate in the shared taxonomy.

CodeMeaningCommon source
invalid_encodingInput bytes are malformed, unsupported, non-canonical, or incomplete.Value.decode, Change.decode, Snapshot.decode, Update.decode; Rust CodecError.
limit_exceededA configured or built-in resource/length limit was exceeded.Structured input, sequence arithmetic, or decoder depth.
type_mismatchChange kind does not match the target Value kind.apply.
missing_keyA Map delete/modify targeted an absent key.apply.
key_already_existsA Map insert targeted an existing key.apply.
out_of_boundsA list index or sequence range is outside the base.apply; JavaScript coordinate conversion also uses this classification.
integer_overflowChecked signed integer addition overflowed.IntChange::Add / intAdd.
incompatible_changeSequential or concurrent Changes cannot share the required context.compose, transformPair, or remote revision checks.
invalid_valueValue construction violated a model invariant.Non-finite float, duplicate key, invalid attribute/value.
invalid_stateA JavaScript resource was disposed or a lifecycle operation is no longer valid.Document, Snapshot, Update, ValueHandle, or Change.
invalid_argumentJavaScript facade received the wrong runtime type or option shape.Public JS constructors and methods.
invalid_utf16_boundaryA JavaScript/editor position splits a UTF-16 surrogate pair.JavaScript resolveUtf16Position and projections; Rust uses Utf16PositionError::InvalidUtf16Boundary.

The first ten codes (including invalid_utf16_boundary) are shared with the Rust crate. invalid_state and invalid_argument are additionally surfaced by the JavaScript facade. Human-readable error messages and detailed paths are diagnostics; branch on the stable code.

Structured input limits

JavaScript InputOptions can override these defaults for fromJS and builder input. Rust's InputLimits names the same receiver-policy fields.

LimitJavaScript fieldDefaultCounts
DepthmaxDepth / max_depth128Recursive Value and Change nesting.
Value nodesmaxValueNodes / max_value_nodes1,000,000Raw Value nodes.
Change nodesmaxChangeNodes / max_change_nodes1,000,000Raw Change nodes.
Container lengthmaxContainerLength / max_container_len1,000,000Map, List, and attribute entries.
String bytesmaxStringBytes / max_string_bytes16 MiBOne UTF-8 string.
Sequence operationsmaxSequenceOps / max_sequence_ops1,000,000Raw operation count before normalization.
Sequence lengthmaxSequenceLength / max_sequence_len1,000,000Logical input/output sequence length.

These are receiver policy, not a change to the Value type's semantics. They are checked on structured input before normalization. Canonical byte decoding relies on cocodec's fixed recursion and safe length handling; algebra results and editor projections do not consume InputLimits.

Coordinates and ownership

  • Core Text and RichText operations use Unicode scalar positions.
  • JavaScript editor projections use Snapshot-relative UTF-16 positions.
  • A UTF-16 index inside a surrogate pair is invalid; do not silently round it.
  • RichText embeds count as one unit in both coordinate systems.
  • ValueHandle, Change, Snapshot, and Update own Wasm-backed resources in JavaScript; clones own independent resources.
  • Returned JavaScript values, event payloads, paths, and edit steps are recursively frozen.
  • Document disposal is idempotent; using a disposed resource reports invalid_state.

Quick lookup

Colla v0.3.0 · Released under the MIT License.