/**
 * Rate-limit state — `state/last-self-restart-at.json`.
 *
 * Tracks wall-clock of the last self-restart, ring-buffer history, and
 * rate-limit decisions across buckets. Atomic writes via tmp+rename.
 *
 * Fail-closed read semantics per spec:
 *   - missing → clear to restart
 *   - malformed / unreadable → block (treat as "just restarted")
 *   - future timestamp → ALLOW and overwrite (previous "block" was a deadlock)
 */
export type RestartBucket = 'watchdog' | 'versionSkew' | 'plannedUpgrade';
export interface RestartHistoryEntry {
    at: string;
    reason: string;
    bucket: RestartBucket;
}
export interface RateLimitState {
    lastRestartAt: string;
    lastReason: string;
    history: RestartHistoryEntry[];
}
export declare const HISTORY_CAP = 50;
export declare const WATCHDOG_COOLDOWN_MS: number;
export declare const VERSION_SKEW_COOLDOWN_MS: number;
export declare const VERSION_SKEW_DAILY_CAP = 3;
export declare const RESTART_STORM_WINDOW_MS: number;
export declare const RESTART_STORM_THRESHOLD = 6;
export declare function statePath(stateDir: string): string;
export type ReadOutcome = {
    kind: 'clear';
    state: null;
} | {
    kind: 'corrupt';
    state: null;
    errorSignal: 'rateLimitFileCorrupt';
} | {
    kind: 'skew';
    state: RateLimitState | null;
    errorSignal: 'rateLimitFileSkew';
} | {
    kind: 'ok';
    state: RateLimitState;
};
/**
 * Read + classify the rate-limit file.
 *
 * - Missing            → { clear }
 * - Parse error / bad  → { corrupt } (signal + block)
 * - Future timestamp   → { skew } (signal + ALLOW — overwrite avoids deadlock)
 * - Otherwise          → { ok, state }
 */
export declare function readRateLimitState(stateDir: string, now?: number): ReadOutcome;
export interface RateLimitDecision {
    allowed: boolean;
    reason?: string;
    stormActive?: boolean;
}
/** Decide whether a restart in the given bucket is allowed right now. */
export declare function decide(outcome: ReadOutcome, bucket: RestartBucket, now?: number): RateLimitDecision;
export declare function writeRateLimitState(stateDir: string, reason: string, bucket: RestartBucket, prior: RateLimitState | null, now?: number): RateLimitState;
export declare function isRestartStorm(state: RateLimitState | null, now?: number): boolean;
//# sourceMappingURL=rateLimitState.d.ts.map