Skip to content

ConflictResolver

Defined in: src/persistence/replicated/ConflictResolver.ts:23

Resolution strategy for two events that VectorClock flags as concurrent — neither happens-before the other. The replicated- event-sourced actor consults this when merging divergent histories so every replica converges to the same state.

Two contracts:

  • The resolver is deterministic for a given (a, b) pair — given the same inputs, every replica must pick the same winner / merge result.
  • The resolver MUST be commutative: resolve(a, b) === resolve(b, a). Otherwise different replicas would diverge based on which event arrived first.

The simplest deterministic resolver is last-writer-wins (LWW) keyed on (timestamp, replicaId) — that’s what we ship as the default. Domain-aware resolvers can do something smarter (e.g. additive merge for counters, set union for tag sets).

E

resolve(a, b): E

Defined in: src/persistence/replicated/ConflictResolver.ts:31

Pick a single event from a concurrent pair. Implementations MUST be commutative — resolve(a, b) must equal resolve(b, a). Return one of the inputs, or a synthesised merge of both — either is fine as long as the result is deterministic across replicas.

ConflictCandidate<E>

ConflictCandidate<E>

E