/** * Pure codecs for the two lease ownership keys (`lease:epoch` and `lease:holder`). * Extracted from `lease-manager.ts` to keep that file under the `max-lines` ceiling; * these functions have no engine state, so they live and test cleanly on their own. * * @module core/engine/lease-codec */ /** The decoded `lease:holder` record. */ export type LeaseHolderRecord = { holderId: string; /** Wall-clock ms (from the engine's `getNow`) after which the lease may be stolen. */ expiresAt: number; /** The ownership epoch this holder acquired. Mirrors `lease:epoch`. */ epoch: number; }; /** * Encode an 8-byte big-endian uint64 epoch. `DataView.setBigUint64` is the * standard, overflow-safe encoder — preferred over a hand-rolled byte loop. */ export declare function encodeEpoch(epoch: number): Uint8Array; /** * Decode an 8-byte big-endian uint64 epoch, or `null` when the stored value is * not a usable epoch — not exactly 8 bytes, or outside `[1, MAX_SAFE_INTEGER)`. * The epoch is the monotonic fencing high-water mark, so it must stay exactly * comparable AND have room to increment: acquisition always mints `epoch + 1`, so * `Number.MAX_SAFE_INTEGER` itself is rejected too — minting `2^53` would fail * `Number.isSafeInteger` on the next boot and brick the lease. A value at or above * the safe-integer ceiling (or below `1`) routes to the corruption path * (fail-closed at boot) rather than silently re-minting an imprecise generation. */ export declare function decodeEpoch(raw: Uint8Array): number | null; /** Encode a holder record to its stored JSON bytes. */ export declare function encodeHolder(record: LeaseHolderRecord): Uint8Array; /** Decode a stored holder record, tolerating any malformed/foreign value as `null`. */ export declare function decodeHolder(raw: Uint8Array): LeaseHolderRecord | null;