Critical Versions and Partial Replay
Statement
Definition (Critical Version). A version of event graph is critical iff it partitions into and such that:
Equivalently: every event in either happened at or before , or happened strictly after all events in . There are no events concurrent with any event in that also have descendants in .
Theorem (Partition Independence). Events before a critical version do not affect how events after the critical version are transformed. The internal state can be discarded and rebuilt from a critical version without changing the output.
Visualization
graph TD
subgraph G1["G₁ = Events(V_crit)"]
e1["e₁"] --> e2["e₂"]
e1 --> e3["e₃"]
e2 --> e4["e₄"]
e3 --> e4
end
subgraph G2["G₂ = G \ G₁"]
e5["e₅"] --> e6["e₆"]
e5 --> e7["e₇"]
e6 --> e8["e₈"]
e7 --> e8
end
e4 --> e5
style e4 fill:#51cf66,stroke:#333
Here is critical: all of happened before all of . The internal state at fully determines how is processed — no retreat into is ever needed.
Non-critical Example
A version ceases to be critical if a concurrent event arrives:
graph TD
e1["e₁"] --> e2["e₂"]
e1 --> e3["e₃"]
e2 --> e4["e₄"]
e3 --> e5["e₅ (arrives late)"]
style e4 fill:#ff6b6b,stroke:#333
style e5 fill:#ff6b6b,stroke:#333
was critical when but becomes non-critical once arrives, because yet is in . Now the algorithm must retreat past to process .
Partial Replay from Critical Versions
When the internal state has been discarded (e.g., after closing and reopening a document), eg-walker reconstructs state from the most recent critical version :
- Initialize with a placeholder record representing the unknown document at :
-
Replay events from to the current version (without emitting transformed operations)
-
Continue applying new events normally
Placeholder Splitting
When an insertion at index targets a placeholder covering range :
When a deletion targets a character within a placeholder, the placeholder splits and a tombstone record is created with a locally-unique ID.
Why Critical Versions Matter
| Benefit | Mechanism |
|---|---|
| Memory efficiency | Discard full internal state; keep only the document string at |
| Fast loading | Skip replaying ancient history; start from recent critical version |
| Garbage collection | Tombstones before can be compacted away |
| Independent processing | Sections between critical versions can be replayed in parallel |
Finding Critical Versions
A version is critical iff the frontier has no concurrent events with anything that came after it. In practice:
- Single-user editing (no concurrency) makes every version critical
- Real-time collaboration with brief disconnections produces critical versions at each synchronisation point
- Long offline branches prevent critical versions until the merge event
Complexity Impact
With critical version separating past events from recent events:
The B-tree contains at most entries (from placeholder splits), rather than entries for every character ever inserted.
Connections
Critical versions depend on the Event Graph Convergence ProofEvent Graph Convergence ProofFormal proof that eg-walker produces identical document states regardless of topological sort order — strong eventual consistency.Read more → — they represent the exact points where history can be "forgotten" without affecting future transformations. The Internal State MachineInternal State MachineThe per-character state machine that tracks insertion/deletion across prepare and effect versions in eg-walker.Read more → shows how placeholder records interact with the state transitions. The overall algorithm is described in Eg-walker: Event Graph WalkerEg-walker: Event Graph WalkerA collaboration algorithm for text editing that combines CRDT convergence with OT-competitive memory and merge performance.Read more →.
Referenced by
- Compact Event Graph EncodingDistributed Systems