// src/backend-contract/connection-lifecycle.ts import type { ConnectionState } from './backend' import type { AttachmentRecord } from './identity' import type { AttachmentId, ConnectionId, GenerationId, LeaseId, PeerId } from './primitives' export type ConnectionLifecycleCause = | 'connected' | 'backend-transition' | 'requested-disconnect' | 'peer-link-loss' | 'adapter-loss' | 'backend-restart' | 'released' | 'manager-destroyed' | 'backend-failure' export type ConnectionLifecycleTerminalCause = Exclude /** One attachment-, lease-, and generation-bound public connection transition. */ export interface ConnectionLifecycleEvent { readonly kind: 'connection-lifecycle' readonly attachment: AttachmentRecord readonly attachmentId: AttachmentId readonly peerId: PeerId readonly connectionId: ConnectionId readonly connectionGeneration: GenerationId<'connection-generation', string> readonly ownerLeaseId: LeaseId readonly sequence: number readonly backendIngressOrdinal: number | null readonly previous: ConnectionState readonly current: ConnectionState readonly cause: ConnectionLifecycleCause }