March Docs

VectorClock

VectorClock: causal ordering for distributed actors.

A vector clock is a map from actor-id (String) to logical timestamp (Int). Each actor increments only its own slot. Comparing two clocks determines causal order: one event "happened before" another when every slot in the first clock is <= the corresponding slot in the second and at least one is <.

Types

typeVectorClockVectorClock = VectorClock(Map(String, Int))#
typeClockOrderClockOrder = Before | After | Concurrent | Equal#

Functions

fnadvanceadvance(vc : VectorClock, actor_id : String, ts : Int) : VectorClock#

Advance actor_id's slot to at least ts (no-op if already >= ts).

fncomparecompare(a : VectorClock, b : VectorClock) : ClockOrder#

Compare two vector clocks and return their causal relationship.

fnconcurrentconcurrent(a : VectorClock, b : VectorClock) : Bool#

True when neither clock precedes the other.

fnentriesentries(vc : VectorClock) : List((String, Int))#

All (actor_id, timestamp) pairs in arbitrary order.

fngetget(vc : VectorClock, actor_id : String) : Int#

Return the logical timestamp for actor_id (0 if unseen).

fnhappens_beforehappens_before(a : VectorClock, b : VectorClock) : Bool#

True when a causally precedes b (a happened-before b).

fnincrementincrement(vc : VectorClock, actor_id : String) : VectorClock#

Increment the slot for actor_id, returning the updated clock.

fnmergemerge(a : VectorClock, b : VectorClock) : VectorClock#

Component-wise maximum: keep the higher timestamp for each slot.

fnnewnew() : VectorClock#

An empty vector clock (all timestamps implicitly 0).

fnsumsum(vc : VectorClock) : Int#

Sum of all timestamps (useful as a monotone scalar counter).