/**
 * HealthMetricsStore -- Storage abstraction for destination health metrics.
 *
 * v1 ships an in-memory implementation only. Future drop-ins:
 *   - RedisHealthMetricsStore   (key-prefix: governance:health:<adapterId>)
 *   - PrismaHealthMetricsStore  (table: destination_health_records)
 *
 * Limitation (v1): all data is lost on process restart. Use the Redis or
 * Prisma backing store in production deployments that require persistence.
 *
 * @connexum/ai-governance
 */
/**
 * Latency statistics computed via Welford's online algorithm.
 * Supports p50/p99 estimation via a fixed-size reservoir sample (N=1024).
 * Zero external dependencies.
 */
export interface LatencyStats {
    /** Total number of latency samples recorded. */
    count: number;
    /** Running mean in milliseconds (Welford). */
    meanMs: number;
    /** Running variance (Welford M2 accumulator -- not exposed directly). */
    _m2: number;
    /** Reservoir sample array (capped at RESERVOIR_SIZE). */
    _reservoir: number[];
    /** Reservoir write cursor for replacement phase. */
    _reservoirCursor: number;
}
/** Create a fresh LatencyStats accumulator. */
export declare function createLatencyStats(): LatencyStats;
/**
 * Record one latency sample using Welford's online algorithm.
 * Reservoir is updated via Algorithm R for order-independent sampling.
 */
export declare function recordLatencySample(stats: LatencyStats, latencyMs: number): void;
/**
 * Compute an approximate percentile from the reservoir sample.
 * Returns null when no samples have been recorded yet.
 */
export declare function estimatePercentile(stats: LatencyStats, p: number): number | null;
export interface AdapterHealthRecord {
    adapterId: string;
    /** Unix timestamp (ms) when the adapter was first registered. */
    registeredAt: number;
    totalAttempted: number;
    totalSucceeded: number;
    totalFailed: number;
    totalRetried: number;
    dlqDepth: number;
    latency: LatencyStats;
    packAttempts: Map<string, number>;
    lastErrorAt: number | null;
    lastErrorMessage: string | null;
    lastSuccessAt: number | null;
    circuitBreakerState: 'open' | 'half-open' | 'closed' | null;
}
export interface DestinationHealthSummary {
    adapterId: string;
    registeredAt: string;
    totalAttempted: number;
    totalSucceeded: number;
    totalFailed: number;
    totalRetried: number;
    dlqDepth: number;
    latency: {
        count: number;
        meanMs: number;
        p50Ms: number | null;
        p99Ms: number | null;
    };
    /** Pack attempt breakdown: packId -> count */
    packAttempts: Record<string, number>;
    lastErrorAt: string | null;
    lastErrorMessage: string | null;
    lastSuccessAt: string | null;
    circuitBreakerState: 'open' | 'half-open' | 'closed' | null;
}
/**
 * Storage interface for destination health records.
 *
 * Implementations must be safe for single-process concurrent calls
 * (the in-memory default is synchronous; async stores should serialize
 * writes per adapterId).
 */
export interface HealthMetricsStore {
    /** Ensure a record exists for adapterId; no-op if already present. */
    register(adapterId: string): void;
    /** Retrieve the mutable record for mutation (internal use only). */
    getMutable(adapterId: string): AdapterHealthRecord | undefined;
    /** Return an immutable snapshot summary for one adapter. */
    getSummary(adapterId: string): DestinationHealthSummary | null;
    /** Return summaries for all registered adapters. */
    getAllSummaries(): DestinationHealthSummary[];
    /** Reset health record for an adapter (testing / drain scenarios). */
    reset(adapterId: string): void;
}
/**
 * Default in-memory implementation of HealthMetricsStore.
 *
 * All data is process-local and lost on restart.
 * Swap for RedisHealthMetricsStore or PrismaHealthMetricsStore in production.
 */
export declare class InMemoryHealthMetricsStore implements HealthMetricsStore {
    private readonly records;
    register(adapterId: string): void;
    getMutable(adapterId: string): AdapterHealthRecord | undefined;
    getSummary(adapterId: string): DestinationHealthSummary | null;
    getAllSummaries(): DestinationHealthSummary[];
    reset(adapterId: string): void;
}
//# sourceMappingURL=health-metrics-store.d.ts.map