Operational transformation
Operational transformation is a technology for supporting a range of collaboration functionalities in advanced collaborative software systems. OT was originally invented for consistency maintenance and concurrency control in collaborative editing of plain text documents. Its capabilities have been extended and its applications expanded to include group undo, locking, conflict resolution, operation notification and compression, group-awareness, HTML/XML and tree-structured document editing, collaborative office productivity tools, application-sharing, and collaborative computer-aided media design tools. In 2009 OT was adopted as a core technique behind the collaboration features in Apache Wave and Google Docs.
History
Operational Transformation was pioneered by C. Ellis and S. Gibbs in the GROVE system in 1989. Several years later, some correctness issues were identified and several approaches were independently proposed to solve these issues, which was followed by another decade of continuous efforts of extending and improving OT by a community of dedicated researchers. In 1998, a Special Interest Group on Collaborative Editing was set up to promote communication and collaboration among CE and OT researchers. Since then, SIGCE holds annual CE workshops in conjunction with major CSCW conferences, such as ACM, CSCW, GROUP and ECSCW.System architecture
Collaboration systems utilizing Operational Transformations typically use replicated document storage, where each client has their own copy of the document; clients operate on their local copies in a lock-free, non-blocking manner, and the changes are then propagated to the rest of the clients; this ensures the client high responsiveness in an otherwise high-latency environment such as the Internet. When a client receives the changes propagated from another client, it typically transforms the changes before executing them; the transformation ensures that application-dependent consistency criteria are maintained by all sites. This mode of operation results in a system particularly suited for implementing collaboration features, like simultaneous document editing, in a high-latency environment such as the web.Basics
The basic idea of OT can be illustrated by using a simple text editing scenario as follows. Given a text document with a string "abc" replicated at two collaborating sites; and two concurrent operations:- O1 = Insert
- O2 = Delete
Consistency models
One functionality of OT is to support consistency maintenance in collaborative editing systems. A number of consistency models have been proposed in the research community, some generally for collaborative editing systems, and some specifically for OT algorithms.The CC model
In Ellis and Gibbs 1989 paper "Concurrency control in groupware systems", two consistency properties are required for collaborative editing systems:- Causality preservation: ensures the execution order of causally dependent operations be the same as their natural cause-effect order during the process of collaboration. The causal relationship between two operations is defined formally by Lamport's "happened-before" relation. When two operations are not causally dependent, they are concurrent. Two concurrent operations can be executed in different order on two different document copies.
- Convergence: ensures the replicated copies of the shared document be identical at all sites at quiescence.
The CCI model
The CCI model was proposed as a consistency management in collaborative editing systems. Under the CCI model, three consistency properties are grouped together:- Causality preservation : the same as in the CC model.
- Convergence: the same as in the CC model.
- Intention preservation: ensures that the effect of executing an operation on any document state be the same as the intention of the operation. The intention of an operation O is defined as the execution effect which can be achieved by applying O on the document state from which O was generated.
The CCI model is independent of document types or data models, operation types, or supporting techniques. It was not intended for correctness verification for techniques that are designed for specific data and operation models and for specific applications. In, the notion of intention preservation was defined and refined at three levels: First, it was defined as a generic consistency requirement for collaborative editing systems; Second, it was defined as operation context-based pre- and post- transformation conditions for generic OT functions; Third, it was defined as specific operation verification criteria to guide the design of OT functions for two primitive operations: string-wise insert and delete, in collaborative plain text editors.
The CSM model
The condition of intention preservation was not formally specified in the CCI model for purposes of formal proofs. The SDT and LBT approaches try to formalize an alternative conditions that can be proved. The consistency model proposed in these two approaches consist of the following formal conditions:- Causality: the same definition as in CC model
- Single-operation effects: the effect of executing any operation in any execution state achieves the same effect as in its generation state
- Multi-operation effects: the effects relation of any two operations is maintained after they are both executed in any states
The CA model
Alternatively, the CA model is based on the admissibility theory. The CA model includes two aspects:
- Causality: the same definition as in CC model
- Admissibility: The invocation of every operation is admissible in its execution state, i.e., every invocation must not violate any effects relation that has been established by earlier invocations.
OT system structure
OT is a system of multiple components. One established strategy of designing OT systems is to separate the high-level transformation control algorithms from the low-level transformation functions.OT Control Algorithms |
OT properties and conditions |
OT Transformation Functions |
The transformation control algorithm is concerned with determining:
- Which operation should be transformed against a causally ready new operation
- The order of the transformations
The other alternative approach was proposed in. In their approach, an OT algorithm is correct if it satisfies two formalized correctness criteria:
- Causality preservation
- Admissibility preservation
OT data and operation models
There exist two underlying models in each OT system: the data model that defines the way data objects in a document are addressed by operations, and the operation model that defines the set of operations that can be directly transformed by OT functions. Different OT systems may have different data and operation models. For example, the data model of the first OT system is a single linear address space; and its operation model consists of two primitive operations: character-wise insert and delete. The basic operation model has been extended to include a third primitive operation update to support collaborative Word document processing and 3D model editing. The basic OT data model has been extended into a hierarchy of multiple linear addressing domains, which is capable of modeling a broad range of documents. A data adaptation process is often required to map application-specific data models to an OT-compliant data model.There exist two approaches to supporting application level operations in an OT system:
- Generic operation model approach: which is to devise transformation functions for three primitive operations: insert, delete, and update. This approach needs an operation adaptation process to map application operations to these primitive operations. In this approach, the OT operation model is generic, so transformation functions can be reused for different applications.
- Application-specific operation model approach: which is to devise transformation functions for each pair of application operations. For an application with m different operations, m x m transformation functions are needed for supporting this application. In this approach, transformation functions are application-specific and cannot be reused in different applications.
OT functions
- Inclusion transformation : IT or, which transforms operation Oa against another operation Ob in such a way that the impact of Ob is effectively included.
- Exclusion transformation : ET or, which transforms operation Oa against another operation Ob in such a way that the impact of Ob is effectively excluded.
T,ins) :-
if return ins
else if return ins
else return ins
,ins) :-
if return ins
else if return ins
else return ins
Some OT systems use both IT and ET functions, and some use only IT functions. The complexity of OT function design is determined by various factors:
- the functionality of the OT system: whether the OT system supports do, undo, locking, awareness, application sharing, etc.;
- the correctness responsibility in the OT system: what transformation properties to meet; whether ET is used;
- the operation model of the OT system: whether the OT operation model is generic, or application-specific ; and
- the data model of the OT system: whether the data in each operation is character-wise, string-wise, hierarchical, or other structures.
Transformation properties
Convergence properties
The following two properties are related to achieving convergence.- CP1/TP1: For every pair of concurrent operations and defined on the same state, the transformation function T satisfies CP1/TP1 property if and only if: where denotes the sequence of operations containing followed by ;and where denotes equivalence of the two sequences of operations. CP1/TP1 precondition: CP1/TP1 is required only if the OT system allows any two operations to be executed in different orders.
- CP2/TP2: For every three concurrent operations and defined on the same document state, the transformation function T satisfies CP2/TP2 property if and only if:. CP2/TP2 stipulates equality between two operations transformed with regard to two equivalent sequences of operations: the transformation of against the sequence of operation followed by must give the same operation as the transformation of against the sequence formed by and. CP2/TP2 precondition: CP2/TP2 is required only if the OT systems allows two operations and be IT-transformed in two different document states.
Inverse properties
- IP1: Given any document state S and the sequence, we have, which means the sequence is equivalent to a single identity operation I with respect to the effect on the document state. This property is required in an OT system for achieving the correct undo effect, but is not related to IT functions.
- IP2: The property IP2 expresses that the sequence has no effect on the transformation of other operations. The transformation functions satisfy IP2 if and only if:, which means that the outcome of transforming against the sequence is equivalent to the outcome of transforming against the identity operation I. IP2 precondition: IP2 is required only if the OT systems allows an operation to be transformed against a pair of do and undo operations, one-by-one.
- IP3: Given two concurrent operations and defined on the same document state, if and. The transformation functions satisfy the property IP3 if and only if, which means that the transformed inverse operation is equal to the inverse of the transformed operation. IP3 precondition: IP3 is required only if the OT system allows an inverse operation to be transformed against an operation that is concurrent and defined on the same document state as .
OT control (integration) algorithms
- assigning correctness responsibilities among the control algorithm and transformation functions, and
- time-space complexity of the OT system.
The following table gives an overview of some existing OT control/integration algorithms
OT control/integration algorithms | Required transformation function types | Support OT-based Do? | Support OT-based Undo? | Transformation properties supported by control algorithm | Transformation properties supported by transformation functions | Transformation ordering and propagation constraints | Timestamp |
dOPT | T | Yes | No | - | CP1/TP1, CP2/TP2 | Causal order | State vector |
selective-undo | Transpose | No | Selective Undo | NA | CP1/TP1, CP2/TP2, RP, IP1, IP2, IP3 | Causal order | ?? |
adOPTed | LTransformation | Yes | Chronological Undo | IP2, IP3 | CP1/TP1, CP2/TP2, IP1 | Causal order | State vector |
Jupiter | xform | Yes | No | CP2/TP2 | CP1/TP1 | Causal order + Central transformation server | Scalar |
Google Wave OT | transform and composition | Yes | No | CP2/TP2 | CP1/TP1 | Causal order + Central transformation server + stop'n'wait propagation protocol | Scalar |
GOT | IT and ET | Yes | No | CP1/TP1, CP2/TP2 | - | Causal order + Discontinuous total order | State vector |
GOTO | IT and ET | Yes | No | - | CP1/TP1, CP2/TP2 | Causal order | State vector |
AnyUndo | IT and ET | No | Undo any operation | IP2, IP3, RP | IP1, CP1/TP1, CP2/TP2 | Causal order | State vector |
SCOP | IT | Yes | No | CP2/TP2 | CP1/TP1 | Causal order + Central transformation server | Scalar |
COT | IT | Yes | Undo any operation | CP2/TP2, IP2, IP3 | CP1/TP1, | Causal order + Discontinuous total order | Context vector |
TIBOT | IT | Yes | No | CP2/TP2 | CP1/TP1 | Causal order | Scalar |
SOCT4 | Forward transformation | Yes | No | CP2/TP2 | CP1/TP1 | Causal order + Continuous total order | Scalar |
SOCT2 | Forward Transformation and Backward Transformation | Yes | No | - | CP1/TP1, CP2/TP2, RP | Causal order | State vector |
MOT2 | Forward transformation | Yes | No | ?? | CP1/TP1, CP2/TP2 | ?? | scalar |
A continuous total order is a strict total order where it is possible to detect a missing element i.e. 1,2,3,4,... is a continuous total order, 1,2,3,5,... is not a continuous total order.
The transformation-based algorithms proposed in are based on the alternative consistency models "CSM" and "CA" as described above. Their approaches differ from those listed in the table. They use vector timestamps for causality preservation. The other correctness conditions are "single-"/"multi-" operation effects relation preservation or "admissibility" preservation. Those conditions are ensured by the control procedure and transformation functions synergistically. There is no need to discuss TP1/TP2 in their work. Hence they are not listed in the above table.
There exist some other optimistic consistency control algorithms that seek alternative ways to design transformation algorithms, but do not fit well with the above taxonomy and characterization. For example, Mark and Retrace
The correctness problems of OT led to introduction of transformationless post-OT schemes, such as WOOT, Logoot and Causal Trees. "Post-OT" schemes decompose the document into atomic operations, but they workaround the need to transform operations by employing a combination of unique symbol identifiers, vector timestamps and/or tombstones.
Critique of OT
While the classic OT approach of defining operations through their offsets in the text seems to be simple and natural, real-world distributed systems raise serious issues. Namely, that operations propagate with finite speed, states of participants are often different, thus the resulting combinations of states and operations are extremely hard to foresee and understand. As Li and Li put it, "Due to the need to consider complicated case coverage, formal proofs are very complicated and error-prone, even for OT algorithms that only treat two characterwise primitives ".Similarly, Joseph Gentle who is a former Google Wave engineer and an author of the Share.JS library wrote, "Unfortunately, implementing OT sucks. There's a million algorithms with different tradeoffs, mostly trapped in academic papers. Wave took 2 years to write and if we rewrote it today, it would take almost as long to write a second time." But later he amends his comment with "I no longer believe that wave would take 2 years to implement now - mostly because of advances in web frameworks and web browsers."
For OT to work, every single change to the data needs to be captured: "Obtaining a snapshot of the state is usually trivial, but capturing edits is a different matter altogether. The richness of modern user interfaces can make this problematic, especially within a browser-based environment." An alternative to OT is differential synchronization.
Another alternative to OT is using sequence types of conflict-free replicated data type.