> whoami
Todd Kennedy
@whale_eat_squid
CTO, Scripto
Beard grower
>
Keeping multiple remote clients in sync requires 5 copies PER user
Developed at MCTC in Austin, TX 1989 & Xerox Parc in 1995 & Google in mid 2000s
Serialization and broadcast of specific operations performed on a shared document of equal length, with respect to the document cursor
How do we use them though?
All the characters in the retain, insert & delete operations must add up to the length of the current document the transform is being applied to
Or, in transforms:
retain(2), insertCharacters('o')
retain(2), insertCharacters('p')
The document has changed in the client and the server, but to two different states.
State A adds o to the document. State B adds p
Now we need to reconcile the two states so that the unified document is in agreement again
const [a2, b2] = transform(a, b)
...but only because they're based on the same HEAD revision
retain(3), insertCharacters('o')
Now we can apply to document state A and b2 to B and achieve singularity!
By doing that to the document (which is now Tap) and we end up with Tapo!
No, but it's a conflict-free resolution to the issue — better than git telling you that your head is detacted and you need a three-way merge!
In a more complex scenario you'll be dealing with a lot more changesets with the same parent revision that will conflict. Most OT systems resolve this with a first-to-the-server strategy...
When the server accepts a commit message it
In the simple example we discarded state b2 since the client was disinterested in it and only sent a2 to the server. Here, we need to use that to generate a new "bridge" transform.
It is! Not only that but it's Big O is O(n log n)!
This complexity makes it difficult to support large numbers of clients performing operations on the same document.
Wave's improvement on this process is the compose function which is O(n).
Composes takes changesets performed on the same document and combines them into one changeset.
So instead of transforming c against b2 and a2 we can compose the latter into ab2 and just transform(ab2, c)
@whale_eat_squid | Todd Kennedy