/**
 * RedisEventBus -- Redis pub/sub transport implementing the same public surface
 * as the file-based EventBus.
 *
 * Motivation: the file-based EventBus suffers 3-60 second cross-pod latency on
 * shared NFS/EFS because Linux NFS stat caching delays file-change visibility.
 * Healthcare HA deployments require sub-second event propagation. Redis pub/sub
 * delivers sub-millisecond cross-pod latency.
 *
 * Usage:
 *   REDIS_EVENT_BUS_ENABLED=true   -- activates this transport (default: false)
 *   REDIS_URL=redis://...          -- full connection string (required when enabled)
 *
 * When REDIS_EVENT_BUS_ENABLED is false (the default), this module is never
 * instantiated and the file-based EventBus remains the only transport. The two
 * implementations are additive, not exclusive.
 *
 * Architecture notes:
 *   - One Redis channel per EventType (e.g. "aiag:events:handoff:created").
 *     This scales well: subscribers only receive the event types they care about,
 *     avoiding per-subscriber envelope filtering overhead.
 *   - A wildcard '*' subscriber additionally subscribes to the catch-all channel
 *     "aiag:events:*" via Redis PSUBSCRIBE.
 *   - Disconnect: auto-reconnect with exponential backoff (100ms .. 30s).
 *     During disconnect a local warning is logged; events are NOT spooled to file
 *     (enhancement deferred per Wave B scope).
 *   - The file-based EventBus is NOT replaced. Run both in parallel or choose
 *     one per deployment via env var.
 *
 * @connexum/ai-governance  Wave-B
 */
import type { EventType, EventHandler } from './event-bus';
export declare function isRedisEventBusEnabled(): boolean;
export interface RedisEventBusConfig {
    /** Redis connection string. Reads REDIS_URL env var when not provided. */
    redisUrl?: string;
    /** Agent name for source tagging on emitted events. */
    agentName: string;
    /**
     * Maximum reconnect delay in ms. Default: 30_000 (30 s).
     * Backoff doubles from 100ms up to this cap.
     */
    maxReconnectDelayMs?: number;
}
export declare class RedisEventBus {
    private readonly agentName;
    private readonly redisUrl;
    private readonly maxReconnectDelayMs;
    /** Type-specific handlers (mirrors EventBus.handlers) */
    private handlers;
    /** Publisher client -- used for PUBLISH */
    private pubClient;
    /** Subscriber client -- used for SUBSCRIBE / PSUBSCRIBE */
    private subClient;
    private started;
    private stopped;
    /** The set of EventTypes that have registered handlers (for selective subscription) */
    private subscribedTypes;
    private wildcardSubscribed;
    constructor(config: RedisEventBusConfig);
    /**
     * Subscribe to an event type (or '*' for all events).
     * Handlers registered before start() are effective immediately after start().
     * Handlers registered after start() cause a live SUBSCRIBE on the sub client.
     */
    on(type: EventType | '*', handler: EventHandler): void;
    /**
     * Emit an event -- publishes to the appropriate Redis channel.
     * Also dispatches locally to any local handlers registered on this instance
     * (same pod semantics).
     */
    emit(type: EventType, data: Record<string, unknown>, target?: string): void;
    /**
     * Start the Redis pub/sub transport.
     * Creates publisher + subscriber clients, subscribes to all registered types.
     */
    start(): Promise<void>;
    /**
     * Stop the Redis pub/sub transport.
     * Disconnects both pub and sub clients.
     */
    stop(): Promise<void>;
    /**
     * Create an ioredis client with auto-reconnect backoff.
     * `role` is 'pub' or 'sub' -- used only for log labelling.
     */
    private makeClient;
    /**
     * Subscribe the sub client to the channel for a given EventType (or wildcard).
     * Idempotent: no-ops if already subscribed.
     */
    private subscribeToType;
    /**
     * Handle an incoming Redis message from either SUBSCRIBE or PSUBSCRIBE.
     * Skips events sourced from this agent (already dispatched locally in emit()).
     */
    private handleIncoming;
    /**
     * Dispatch an event to all registered handlers for its type and wildcard handlers.
     */
    private dispatch;
}
//# sourceMappingURL=redis-event-bus.d.ts.map