/**
 * Monitor evaluate/fire loop.
 *
 * Modeled on the routines daemon: a single MonitorEngine lives inside runDaemon()
 * beside the cron JobScheduler. On each tick it evaluates every enabled monitor
 * that is DUE and owned by this device, applies the condition through the native
 * state-diff store, and on a fire dispatches the action, writes a fire record, and
 * updates state. A per-monitor rate limit auto-pauses a firehose.
 *
 * v1 covers the poll model (command, poll, poll-http, file, device). Push sources
 * (ws, webhook) return null from `evaluate` — they deliver through `subscribe` /
 * the webhook receiver, wired in a follow-up; the engine treats them as inert.
 */
import { type MonitorConfig, type MonitorEvent } from './config.js';
import { type Observation } from './sources/index.js';
/** How often the engine wakes to check which monitors are due. */
export declare const MONITOR_ENGINE_TICK_MS = 5000;
/** Poll-model source types the engine actually evaluates on a cadence; ws/webhook are push-only and inert here. */
export declare const POLL_SOURCE_TYPES: Set<string>;
/**
 * Whether a monitor's liveness has crossed into a drought worth notifying the
 * owner about: enough consecutive failed checks, and not already notified for
 * this drought. Pure so the branch is unit-testable without a real notify.
 */
export declare function shouldEscalateDrought(liveness: MonitorLivenessLike): boolean;
/** The liveness fields the drought predicate reads. */
interface MonitorLivenessLike {
    consecutiveErrors: number;
    droughtNotifiedAt?: string;
}
/** The fire/no-fire decision for one observation, plus what to persist. */
export interface FireDecision {
    fire: boolean;
    /** The value whose de-dupe signature is stored on persist. */
    value: string;
    /** The de-dupe key (regex) applied to the value, if any. */
    dedupeKey?: string;
    /** Persist `value` as the new baseline even when not firing (on-change baseline). */
    persist: boolean;
    /** The event to dispatch, present iff `fire`. */
    event: MonitorEvent | null;
}
/**
 * Apply a monitor's condition to an observation. Pure (reads state, never
 * writes), so both the tick loop and the `test` dry-run share it.
 */
export declare function decideFire(monitor: MonitorConfig, observation: Observation): FireDecision;
/** One evaluation of a monitor's source + condition, without side effects. Used by `test`. */
export declare function evaluateMonitorOnce(monitor: MonitorConfig): Promise<{
    observation: Observation | null;
    decision: FireDecision | null;
}>;
type LogFn = (level: string, message: string) => void;
/** The durable monitor engine. One instance per daemon. */
export declare class MonitorEngine {
    private logFn;
    private timer;
    private monitors;
    private lastEval;
    private ticking;
    private running;
    constructor(logFn?: LogFn);
    /** Load owned+enabled monitors and start the tick loop. */
    start(options?: {
        externalScheduler?: boolean;
    }): void;
    /** Reload monitor configs (SIGHUP). */
    reload(): void;
    /** Stop the tick loop. No monitor dispatches after this until `start()`. */
    stop(): void;
    private loadAll;
    private intervalMs;
    private isDue;
    /** Evaluate every due monitor once. Overlap-guarded so a slow cycle never stacks. */
    tick(): Promise<void>;
    /**
     * Evaluate one monitor once and record the outcome. Public so the daemon tick
     * and tests drive the exact same path. A "failed check" is an evaluation that
     * produced no observation, threw, OR fired an action that failed — all three
     * are "the monitor ran and accomplished nothing", the drought signal. A poll
     * that observes and either fires cleanly or matches nothing is a success and
     * resets the streak.
     */
    runMonitor(monitor: MonitorConfig): Promise<void>;
    /**
     * Record the poll heartbeat and, on a sustained failure streak, escalate a
     * drought to the owner exactly once. The heartbeat is what makes a
     * polling-but-not-matching monitor visibly distinct from one the engine never
     * touched (RUSH-2485); the streak is what turns "every poll fails and the owner
     * never hears about it" into one notification.
     */
    private afterCheck;
    /** Notify the owner that an enabled monitor has failed N checks in a row and done nothing. */
    private escalateDrought;
    private fire;
}
export {};
