When concurrent mutations update shared state, the commit phase must reconcile divergent results. A three-way merge compares the mutation’s starting state, the current state, and its proposed next state. section 5.2
Use the three states to choose the reconciliation path:
- Previous is the state used for calculation; current is the state at commit time; next is the calculation result. section 5.2
- If current and previous are identical, fast-forward by returning next. section 5.5
- Otherwise, calculate changes from previous to current and from previous to next. Disjoint changes can be patched into current; overlapping changes conflict. section 5.5
- Abort conflicting mutations instead of requiring manual conflict resolution. section 5.2
A mutation commit
SystemConsistency.reconcile(current, previous, next) first checks for a fast-forward, then invokes threeWayMerge when another mutation changed the state. The implementation uses immutable data so identical references can be compared quickly; its shown implementation is safe for a single-threaded event-loop environment, while multi-threaded safety is deferred. section 5.5
