# `Kotoba.Collab.Document`
[🔗](https://github.com/hattoriai/kotoba/blob/v0.8.0/lib/kotoba/collab/document.ex#L1)

The versioned collaboration document and its semantic operations.

Nodes and Unicode scalar values have persistent identities. Deleted
values remain as anchors, so an offline insertion does not depend on a
current array index.

The wire format uses string keys. Issho orders the transactions, keeps
their receipts and journal (`Kotoba.Issho`); this module is the state
and its operations. A transaction is atomic: its resulting tree must
pass the node, nesting, URL and feature checks.

# `apply_ops`

The state after a transaction's operations, all or none. The resulting
tree is checked by `validate/2`.

# `new`

Creates a collaboration state from server-owned content.

# `random_id`

Returns a cryptographically random identifier suitable for epochs and operations.

# `to_envelope`

Exports the editing state as the existing Kotoba document envelope.

# `upgrade`

A document saved by Kotoba before Issho (its own authority, protocol 1)
as an Issho document: the same epoch, revision, journal and receipts.

# `validate`

Validates and renders a snapshot on the server.

---

*Consult [api-reference.md](api-reference.md) for complete listing*
