/** * A vector clock implementation for tracking causality in distributed systems. * * Vector clocks are used to determine the ordering of events in a distributed system * without relying on synchronized physical clocks. Each node maintains a counter for * every node in the system. * * Usage: * - Increment your node's counter when a local event occurs * - Merge with received vector clocks when receiving messages * - Compare vector clocks to determine causality relationships */ export declare class VectorClock { private clock; constructor(clock?: Map); /** * Increments the counter for the given node ID. * Call this when the node performs a local event (e.g., actor registration). * @param nodeId The ID of the node to increment */ increment(nodeId: string): void; /** * Gets the counter value for a specific node. * @param nodeId The ID of the node * @returns The counter value, or 0 if the node is not in the clock */ get(nodeId: string): number; /** * Merges another vector clock into this one. * Takes the maximum counter value for each node. * Call this when receiving a message from another node. * @param other The vector clock to merge */ merge(other: VectorClock): void; /** * Compares this vector clock with another to determine causality. * * Returns: * - 'before': this happened before other (this < other) * - 'after': this happened after other (this > other) * - 'concurrent': events are concurrent (neither dominates) * * @param other The vector clock to compare with */ compare(other: VectorClock): 'before' | 'after' | 'concurrent'; /** * Checks if this vector clock is strictly less than another. * True if all counters are less than or equal, and at least one is strictly less. */ isLessThan(other: VectorClock): boolean; /** * Checks if this vector clock is strictly greater than another. * True if all counters are greater than or equal, and at least one is strictly greater. */ isGreaterThan(other: VectorClock): boolean; /** * Checks if this vector clock is concurrent with another. * True if some counters are greater and some are less. */ isConcurrent(other: VectorClock): boolean; /** * Creates a deep copy of this vector clock. */ clone(): VectorClock; /** * Converts the vector clock to a plain JSON object for serialization. */ toJSON(): { [nodeId: string]: number; }; /** * Creates a vector clock from a JSON object. */ static fromJSON(obj: { [nodeId: string]: number; }): VectorClock; /** * Returns a string representation of the vector clock. */ toString(): string; /** * Checks if the vector clock is empty (all counters are 0 or no entries). */ isEmpty(): boolean; } //# sourceMappingURL=vector_clock.d.ts.map