/**
 * redis-circuit-breaker — Redis-backed OODA RiskGuard.
 *
 * V5 anti-pattern #4 fix: resetVia is EXPLICIT ('cron-rth' | 'admin-endpoint' |
 * 'never') — NOT TTL-based blind expiry. A tripped circuit stays tripped until
 * an explicit reset action fires (cron job at RTH open, admin endpoint call, or
 * never — for manual-only recovery).
 *
 * Redis key: `cb:<name>:tripped` = "1" when tripped, absent when clear.
 *
 * Decoupled from src/router/circuit-breaker.ts — the agent SDK must not import
 * from the CC server layer. This is a standalone, minimal implementation.
 *
 * @public
 */
import type { RiskGuard } from "../types.js";
/**
 * How the circuit breaker is reset after being tripped.
 *
 * - `cron-rth`       : reset by a cron job aligned with RTH session open
 *                      (e.g. 09:30 ET Mon-Fri — implemented externally).
 * - `admin-endpoint` : reset only via an explicit admin API call.
 * - `never`          : manual Redis delete only — no automated reset.
 *
 * Anti-pattern #4: NO TTL-based blind reset. The key never expires on its own.
 */
export type CircuitBreakerResetMode = "cron-rth" | "admin-endpoint" | "never";
export interface RedisCircuitBreakerOptions {
    /** Unique name per agent+rule — becomes the Redis key segment. */
    name: string;
    /**
     * Redis URL. Defaults to `process.env.REDIS_URL`.
     * Inject a custom client factory via `redisClientFactory` for tests.
     */
    redisUrl?: string;
    /**
     * Number of consecutive failures before the circuit trips.
     * Not auto-tripped by the guard itself (tripping is done by callers via
     * `tripCircuitBreaker`). This field is informational / for external
     * monitoring tooling.
     */
    failureThreshold: number;
    /**
     * V5 anti-pattern #4: explicit reset mode — NOT TTL aveugle.
     * Included in the `reason` string for observability.
     */
    resetVia: CircuitBreakerResetMode;
    /**
     * Optional Redis client factory — inject for unit tests.
     * Factory receives the resolved Redis URL and returns a minimal client.
     *
     * @internal
     */
    _redisClientFactory?: (url: string) => MinimalRedisClient;
}
/**
 * Minimal Redis client interface — satisfied by ioredis and Map-based mocks.
 */
export interface MinimalRedisClient {
    get(key: string): Promise<string | null>;
    set(key: string, value: string): Promise<unknown>;
    del(key: string): Promise<unknown>;
    quit(): Promise<unknown>;
}
/**
 * Returns a RiskGuard that blocks the OODA cycle when the named circuit
 * breaker is tripped in Redis.
 *
 * The guard itself is read-only — it never trips or resets the breaker.
 * Use `tripCircuitBreaker` / `resetCircuitBreaker` from external code
 * (failure handlers, admin endpoints, cron jobs).
 */
export declare function redisCircuitBreaker(opts: RedisCircuitBreakerOptions): RiskGuard;
/**
 * Trip the named circuit breaker in Redis.
 * The key has NO expiry — reset is always explicit (anti-pattern #4).
 */
export declare function tripCircuitBreaker(redisUrl: string, name: string, redisClientFactory?: (url: string) => MinimalRedisClient): Promise<void>;
/**
 * Reset the named circuit breaker in Redis (remove the trip key).
 * Called by cron-rth jobs, admin endpoints, or manual ops.
 */
export declare function resetCircuitBreaker(redisUrl: string, name: string, redisClientFactory?: (url: string) => MinimalRedisClient): Promise<void>;
//# sourceMappingURL=redis-circuit-breaker.d.ts.map