export interface RegisteredClient { clientId: string; nodeId: number; connectionId: string; processId?: string; connectedAt: number; metadata: TMeta; } export interface OrphanedClientDelivery { id: string; nodeId: number; clients: RegisteredClient[]; claimToken: string; } export interface MeshClientListPage { clients: RegisteredClient[]; /** Opaque continuation cursor. Absent when the scan is complete. */ cursor?: string; } export type MeshClientRegistrationState = 'active' | 'pending'; /** Internal/raw registry view used only to reconcile an indeterminate claim commit. */ export interface MeshClientRecord extends RegisteredClient { state: MeshClientRegistrationState; /** Exact two-phase claim that installed this record, when applicable. */ claimId?: string; } /** Result of a register call. */ export type RegisterResult = { status: 'ok'; supersededNodeId: number | null; /** Exact superseded generation, absent for old unfenced records. */ supersededConnectionId?: string; } | { status: 'conflict'; ownerNodeId: number | null; }; /** * A private ownership claim. Claims deliberately do not replace the active * record: callers must fence `previous` and then commit the exact claim. */ export type MeshClientClaim = { status: 'conflict'; ownerNodeId: number | null; } | { status: 'ok'; claimId: string; previous?: MeshClientRecord; }; /** A changed exact prior generation must be reconciled before commit retries. */ export type MeshClientClaimCommitResult = boolean | 'previous-changed'; export interface MeshClientRegistryBackend { register(clientId: string, nodeId: number, metadata: TMeta, allowSupersede: boolean, connectionId: string, processId?: string): Promise; reserve(clientId: string, nodeId: number, metadata: TMeta, allowSupersede: boolean, connectionId: string, processId?: string): Promise; activate(clientId: string, nodeId: number, metadata: TMeta, connectionId: string): Promise; unregister(clientId: string, nodeId: number, connectionId: string): Promise; updateMetadata(clientId: string, nodeId: number, metadata: TMeta, connectionId: string): Promise; getClient(clientId: string): Promise | undefined>; /** Includes a private pending registration; never use for client delivery. */ getClientIncludingPending?(clientId: string): Promise | undefined>; listClients(): Promise[]>; listClientsForNode(nodeId: number): Promise[]>; listClientsPage?(cursor?: string): Promise>; listClientsForNodePage?(nodeId: number, cursor?: string): Promise>; cleanupNode(nodeId: number): Promise[]>; /** * Atomically computes the exact active-only cleanup snapshot, rejects * before mutation when a non-empty snapshot cannot consume one item or * exceeds the supplied byte limit, and otherwise removes all node records * and returns that exact active-only snapshot. An empty snapshot consumes * no item or bytes. Required for safe local fallback orphan delivery. */ cleanupNodeForFallback?(nodeId: number, maxItems: number, maxBytes: number): Promise[]>; refreshNode?(nodeId: number): Promise; /** Two-phase takeover primitives. Optional for custom backends. */ claim?(clientId: string, nodeId: number, metadata: TMeta, state: MeshClientRegistrationState, allowSupersede: boolean, connectionId: string, processId?: string, /** Caller-stable identity for retries of this exact claim operation. */ operationId?: string): Promise>; /** * Commits an exact claim. Retrying the same committed `claimId` after a * lost response must return true while that exact record remains current. */ commitClaim?(clientId: string, nodeId: number, claimId: string): Promise; /** * Removes only the previous generation captured by an extant claim. A * stable claim token may authorize state/metadata changes by that same * generation, but never a different reconnect. */ removeClaimPrevious?(clientId: string, nodeId: number, claimId: string): Promise; abortClaim?(clientId: string, nodeId: number, claimId: string): Promise; /** Removes only the pending/committed result installed by this exact claim. */ removeClaimResult?(clientId: string, nodeId: number, claimId: string): Promise; /** Atomically removes a dead node and persists its active-only orphan snapshot. */ cleanupNodeAndEnqueueOrphaned?(nodeId: number): Promise[]>; enqueueOrphaned?(nodeId: number, clients: RegisteredClient[]): Promise; claimOrphaned?(claimerId: string): Promise | undefined>; ackOrphaned?(id: string, claimToken: string): Promise; nackOrphaned?(id: string, claimToken: string): Promise; /** Optional cross-instance authentication replay consumer. */ consumeAuthNonce?(principal: string, nonce: string, expiresAt: number): Promise; } export declare class ClientNotFoundError extends Error { constructor(clientId: string); } export declare class ClientDisconnectedError extends Error { constructor(clientId: string); } export declare class ClientInvocationError extends Error { constructor(message: string); } //# sourceMappingURL=types.d.ts.map