/**
 * Health Check Service for INTENT Module
 *
 * Provides /health (liveness) and /ready (readiness) endpoints
 * for Kubernetes probes and load balancer health checks.
 *
 * Features:
 * - Component-level health status for Kubernetes probes
 * - Timeout protection for all health checks
 * - INTENT-specific dependency validation (queues, policies)
 * - Memory and resource usage reporting
 * - Graceful degradation support
 *
 * @packageDocumentation
 */
/**
 * Detailed health status for the INTENT module
 */
export interface HealthStatus {
    status: 'healthy' | 'degraded' | 'unhealthy';
    timestamp: string;
    version: string;
    uptime: number;
    checks: {
        database: ComponentHealth;
        redis: ComponentHealth;
        queues: ComponentHealth;
        policies?: ComponentHealth;
    };
}
/**
 * Global health status including all components
 */
export interface GlobalHealthStatus {
    status: 'healthy' | 'degraded' | 'unhealthy' | 'shutting_down';
    version: string;
    environment: string;
    timestamp: string;
    process: {
        uptimeSeconds: number;
        memoryUsageMb: {
            rss: number;
            heapTotal: number;
            heapUsed: number;
            external: number;
        };
        activeRequests: number;
    };
    components: {
        intent: ComponentHealth;
        database?: ComponentHealth;
        redis?: ComponentHealth;
        queues?: ComponentHealth;
    };
    latencyMs: number;
}
/**
 * Readiness status with detailed component checks
 */
export interface ReadinessStatus {
    status: 'ready' | 'degraded' | 'unhealthy';
    timestamp: string;
    checks: {
        database: ComponentCheckResult;
        redis: ComponentCheckResult;
        queues: ComponentCheckResult;
        intent: ComponentCheckResult;
    };
    timedOut?: boolean;
    error?: string;
}
export interface ComponentHealth {
    status: 'ok' | 'degraded' | 'error' | 'timeout';
    latencyMs?: number;
    message?: string;
}
export interface ComponentCheckResult {
    status: 'ok' | 'error' | 'timeout';
    latencyMs?: number;
    error?: string;
    details?: Record<string, unknown>;
}
/**
 * Check database health using the existing connection pool
 *
 * Uses the shared pool instead of creating a new connection to avoid:
 * - Connection exhaustion under load
 * - Unnecessary connection overhead
 * - Pool starvation during health check storms
 *
 * Includes a query timeout to prevent hanging health checks.
 */
export declare function checkDatabaseHealth(): Promise<ComponentHealth>;
export declare function checkRedisHealth(): Promise<ComponentHealth>;
export declare function checkQueueHealth(): Promise<ComponentHealth>;
/**
 * Check policy loader health - verifies policy cache and loading capability
 */
export declare function checkPolicyLoaderHealth(): Promise<ComponentHealth>;
/**
 * Check detailed queue health with stats
 */
export declare function checkDetailedQueueHealth(): Promise<ComponentCheckResult>;
/**
 * Liveness check - is the process alive?
 * Should return quickly and only fail if process is deadlocked
 */
export declare function livenessCheck(): Promise<{
    alive: boolean;
}>;
/**
 * Readiness check - can the service handle requests?
 * Checks all dependencies
 */
export declare function readinessCheck(): Promise<HealthStatus>;
/**
 * INTENT module specific readiness check
 * Checks INTENT-specific dependencies like queues and policy loader
 */
export declare function intentReadinessCheck(): Promise<{
    status: 'healthy' | 'degraded' | 'unhealthy';
    timestamp: string;
    checks: {
        queues: ComponentHealth;
        policies: ComponentHealth;
    };
}>;
/**
 * Global health check combining all system components
 * Returns 503 if any critical component is unhealthy
 */
export declare function globalHealthCheck(activeRequests: number, isShuttingDown: boolean): Promise<GlobalHealthStatus>;
/**
 * Global readiness check with all dependency validation
 */
export declare function globalReadinessCheck(): Promise<ReadinessStatus>;
/**
 * Startup validation - checks DB and Redis connectivity before accepting requests.
 * Throws an error if connectivity fails (causing process exit with code 1).
 */
export declare function validateStartupDependencies(): Promise<void>;
/**
 * Get the uptime in seconds since the module was loaded
 */
export declare function getUptimeSeconds(): number;
/**
 * Liveness probe - fast, process-level check.
 *
 * This probe should return as quickly as possible and only fail if the process
 * is fundamentally broken (e.g., deadlocked). It should NOT check external
 * dependencies like databases or Redis.
 *
 * Kubernetes uses this to determine if the container needs to be restarted.
 *
 * @returns Simple alive status
 */
export declare function livenessProbe(): Promise<{
    alive: boolean;
}>;
/**
 * Startup probe result
 */
export interface StartupProbeResult {
    ready: boolean;
    checks: Record<string, boolean>;
    timestamp: string;
    durationMs: number;
}
/**
 * Startup probe - one-time initialization check.
 *
 * This probe is used during container startup to verify that all required
 * dependencies are available before the container is marked as ready to
 * receive traffic. It runs once during startup.
 *
 * In lite mode, only database is checked. In full mode, Redis is also checked.
 *
 * @param liteMode - Whether to run in lite mode (no Redis check)
 * @returns Startup probe result with detailed checks
 */
export declare function startupProbe(liteMode?: boolean): Promise<StartupProbeResult>;
/**
 * Readiness probe result for lite mode
 */
export interface LiteModeReadinessResult {
    healthy: boolean;
    checks: {
        database: boolean;
        redis?: boolean;
        queues?: boolean;
    };
    timestamp: string;
}
/**
 * Readiness probe for lite mode deployment.
 *
 * In lite mode, only the database is required. Redis and queues are optional
 * and their failures will be logged but won't mark the service as unhealthy.
 *
 * @param liteMode - Whether to run in lite mode
 * @returns Health status with component checks
 */
export declare function readinessProbe(liteMode?: boolean): Promise<LiteModeReadinessResult>;
/**
 * Validate startup dependencies for lite mode.
 *
 * Similar to validateStartupDependencies but supports lite mode
 * where Redis is optional.
 *
 * @param liteMode - Whether to run in lite mode
 * @throws Error if required dependencies are unavailable
 */
export declare function validateStartupDependenciesLite(liteMode?: boolean): Promise<void>;
//# sourceMappingURL=health.d.ts.map