export type FaultLink = 'pi→provider' | 'viewer↔broker' | 'relay↔broker' | 'viewer↔crtrd' | 'daemon→node' | 'crtr→pi'; export type FaultKind = 'rate-limit' | 'overloaded' | 'connection' | 'auth' | 'protocol' | 'context-overflow' | 'other' | 'wedged' | 'model-not-found'; export interface FaultRetry { disposition: 'auto' | 'manual' | 'fatal'; by?: 'sdk' | 'daemon' | 'client'; attempt?: number; max?: number; nextAt?: string; } export interface FaultProviderError { provider: string; model: string; status?: number; code?: string | number; errno?: string; body?: string; causes?: Array<{ message?: string; status?: number; code?: string | number; errno?: string; body?: string; }>; } export interface RecoveryFaultDTO { fault_id: string; link: FaultLink; op: string; kind: FaultKind; retry: FaultRetry; message: string; since: string; operation_id: string; anchor_entry_id?: string; provider_error?: FaultProviderError; } export interface ExecutionExitDiagnosticDTO { schema: 'crtr.execution-exit-diagnostic/v1'; transport_poison: { consecutive_passes: number; routes: string[]; }; } export interface BrokerTurnResultDTO { applied: boolean; } export interface BrokerTurnRequest { expected_execution_id: string; event: 'started' | 'progress' | 'closed' | 'interrupted' | 'exit-diagnostic'; end_reason?: 'settled' | 'teardown-aborted'; exit_diagnostic?: ExecutionExitDiagnosticDTO; } export interface BrokerFaultInputDTO { link: FaultLink; op: string; kind: FaultKind; retry: FaultRetry; message: string; operation_id?: string; since?: string; anchor_entry_id?: string; provider_error?: FaultProviderError; } export interface BrokerFaultResultDTO { fault: RecoveryFaultDTO | null; } export interface BrokerFaultRequest { expected_execution_id: string; op: 'record' | 'clear'; link?: FaultLink; preserve_episode?: boolean; input?: BrokerFaultInputDTO; } export interface BrokerProviderRetryResultDTO { applied: boolean; episode: RecoveryStateDTO['episode']; } export interface BrokerProviderRetryRequest { expected_execution_id: string; op: 'record-pending' | 'admit' | 'reopen' | 'invalidate' | 'clear'; session_id: string; fault_id?: string; retry?: FaultRetry; input?: BrokerFaultInputDTO; } export interface RecoveryStateDTO { fault: RecoveryFaultDTO | null; episode: { state: 'pending' | 'admitted' | 'invalidated'; session_id: string | null; fault: RecoveryFaultDTO; } | null; } export interface NodeFaultClearResultDTO { cleared: boolean; }