/**
 * WorkflowDeadlineDetector: periodic DB scanner enforcing the workflow-level
 * run deadline.
 *
 * A workflow `timeout` caps the whole run's wall-clock across all jobs.
 * Because jobs span multiple agents, the cap is a run-level deadline owned by
 * the orchestrator. This scanner finds non-terminal runs whose
 * `started_at + workflow_timeout_ms` has passed and cancels them through the
 * canonical run-cancel path, recording the distinct
 * TimeoutReason.workflow_timeout so the dashboard labels the run "timed out"
 * rather than a generic cancel.
 */
import { type Kysely } from 'kysely';
import type { Database } from '../db/types.js';
import type { JobQueue } from '../queue/job-queue.js';
export interface WorkflowDeadlineDetectorDeps {
    db: Kysely<Database>;
    /**
     * Canonical "cancel this whole run with a reason" callback — the same
     * implementation the user-initiated `kici cancel` route uses
     * (cancelRunWithReason bound to the orchestrator's deps).
     */
    cancelRun: (runId: string, reason: string) => Promise<unknown>;
    jobQueue: JobQueue;
    /** How often to scan in ms. Default supplied by the caller (reuses the stale-detector interval). */
    scanIntervalMs: number;
}
export declare class WorkflowDeadlineDetector {
    private readonly db;
    private readonly cancelRun;
    private readonly jobQueue;
    private readonly scanIntervalMs;
    private interval;
    constructor(deps: WorkflowDeadlineDetectorDeps);
    /**
     * Start the detector: an immediate scan (crash recovery — catch runs that
     * blew their deadline while the orchestrator was down), then periodic scans.
     */
    start(): Promise<void>;
    stop(): void;
    /**
     * Run a single deadline scan: find non-terminal runs with a configured
     * workflow timeout whose `started_at + workflow_timeout_ms` has passed and
     * cancel each one.
     */
    scan(): Promise<void>;
    private cancelOverdueRun;
}
//# sourceMappingURL=workflow-deadline-detector.d.ts.map