/** * Command retry logic: deterministic backoff schedules (fixed, linear, exponential) * with optional jitter, and retryable error classification. * * Spec: docs/spec/semantics.md § "Retry Logic" */ /** * Configuration for command retry (from IR). */ export interface RetryConfig { maxAttempts: number; backoff: 'fixed' | 'linear' | 'exponential'; delay: number; /** Optional cap applied to each computed backoff delay (ms). */ maxDelay?: number; jitter?: boolean; retryOn: string[]; } /** * Result from computing retry delays. */ export interface RetryDelayResult { delaysMs: number[]; maxDelayMs: number; } /** * Compute deterministic retry delay schedule. * Returns delays for each retry attempt (attempt 2, 3, ..., maxAttempts). * * @param config - Retry configuration * @param maxAttempts - Maximum number of attempts (overrides config if provided) * @returns { delaysMs, maxDelayMs } * * @example * ``` * // Fixed: [1000, 1000, 1000] for 3 retries * computeRetryDelays({ backoff: 'fixed', delay: 1000, ... }, 3) * * // Linear: [1000, 2000, 3000] for 3 retries * computeRetryDelays({ backoff: 'linear', delay: 1000, ... }, 3) * * // Exponential: [1000, 2000, 4000] for 3 retries * computeRetryDelays({ backoff: 'exponential', delay: 1000, ... }, 3) * ``` */ export declare function computeRetryDelays(config: RetryConfig, maxAttempts?: number): RetryDelayResult; /** * Determine if an error code is retryable given the retry config. * An error code is retryable when it appears in `config.retryOn`. The two * built-in codes (CONCURRENCY_CONFLICT, TIMEOUT) are surfaced by * `extractRetryErrorCode`, but any structured error code a command raises * (e.g. SUPPLIER_UNAVAILABLE) is equally retryable once listed in `retryOn`. * * @param errorCode - The error code (from CommandResult, via extractRetryErrorCode) * @param config - Retry configuration * @returns true if the error should trigger a retry */ export declare function isRetryableError(errorCode: string, config: RetryConfig): boolean; /** * Apply optional jitter to a delay. * Jitter introduces randomness to prevent thundering herd. * * @param delayMs - Base delay in milliseconds * @param jitterFn - Optional jitter function; if not provided, no jitter is applied * @returns Jittered delay in milliseconds */ export declare function applyJitter(delayMs: number, jitterFn?: (delayMs: number) => number): number; /** * Default jitter function: random ±10%. * Safe for deterministic testing when overridden with a deterministic callback. */ export declare function defaultJitterFn(delayMs: number): number; //# sourceMappingURL=runtime-retry.d.ts.map