export type OrderingStatus = 'apply' | 'duplicate' | 'stale' | 'out-of-order' | 'invalid'; /** * Compare a message's base version with the receiver's current version. Authority-ordered streams * must be applied strictly in order: older is `stale` (already seen), newer is `out-of-order` * (a gap: the receiver must fetch the missing versions first). */ export declare function classifyVersion(messageVersion: number, currentVersion: number): 'apply' | 'stale' | 'out-of-order' | 'invalid'; /** A Map that forgets its oldest entries beyond `limit`, keeping memory bounded in long sessions. */ export declare class BoundedMap { private readonly limit; private readonly entries; constructor(limit: number); get size(): number; get(key: K): V | undefined; has(key: K): boolean; set(key: K, value: V): void; delete(key: K): boolean; clear(): void; } /** * Idempotency cache for request/ack protocols: a retried message with the same id and the same * content is a `duplicate` (replay the earlier result), the same id with different content is * `reused` (a client bug or an attack), anything else is `fresh`. */ export declare class IdempotencyCache { private readonly seen; constructor(limit?: number); check(clientId: string, messageId: string, fingerprint: string): { status: 'fresh'; } | { status: 'duplicate'; value: V; } | { status: 'reused'; }; remember(clientId: string, messageId: string, fingerprint: string, value: V): void; } /** * Per-peer monotonic sequence tracker for transient streams such as presence: a lower sequence is * `stale`, an equal one is a `duplicate` of the same content or `invalid` when the content differs * (sequence reuse), and a higher one is accepted and remembered. */ export declare class SequenceTracker { private readonly last; constructor(limit?: number); /** Classify without recording; call {@link commit} once the message was actually applied. */ classify(peerId: string, sequence: number, fingerprint: string): OrderingStatus; commit(peerId: string, sequence: number, fingerprint: string): void; forget(peerId: string): void; } /** Recursively freeze a JSON-like value so a retained envelope cannot be mutated by a transport. */ export declare function freezeDeep(value: T): T; //# sourceMappingURL=ordering.d.ts.map