@@ -117,6 +117,31 @@ export const maxNodeId = "ffffffffffffffff" as NodeId;
117117 * Timestamps serve as globally unique, causally ordered identifiers for CRDT
118118 * messages in Evolu's sync protocol.
119119 *
120+ * ### Why Hybrid Logical Clocks
121+ *
122+ * Evolu uses Hybrid Logical Clocks (HLC), which combine physical time (millis)
123+ * with a logical counter. This hybrid approach preserves causality like logical
124+ * clocks while staying close to physical time for better human
125+ * interpretability.
126+ *
127+ * The counter component ensures causality is maintained even when physical
128+ * clocks are imperfect. When clocks drift or operations occur concurrently, the
129+ * counter increments to establish a total order. This means Evolu achieves
130+ * well-defined, eventually-consistent behavior regardless of physical clock
131+ * accuracy.
132+ *
133+ * Vector clocks can accurately track causality and detect concurrent
134+ * operations, but they require unbounded space in peer-to-peer systems and
135+ * crucially, still don't solve our fundamental problem: when they detect
136+ * operations as concurrent, we still need a deterministic way to choose a
137+ * winner. Additionally, any deterministic conflict resolution can be gamed by
138+ * malicious actors.
139+ *
140+ * HLC timestamps work well in practice because modern device clocks accurately
141+ * reflect the order of sequential edits in the common case. Evolu's `maxDrift`
142+ * configuration protects against buggy clocks and prevents problematic
143+ * future-dated entries from propagating through the network.
144+ *
120145 * ### References
121146 *
122147 * - https://muratbuffalo.blogspot.com/2014/07/hybrid-logical-clocks.html
0 commit comments