/**
 * Local failure triage and retry playbooks for tasks, plans, and runs.
 */
import type { Database } from "bun:sqlite";
import { retryAgentRun } from "./agent-run-dispatcher.js";
import type { Task } from "../types/index.js";
export declare const FAILURE_TRIAGE_SCHEMA = "todos.failure_triage.v1";
export declare const FAILURE_CLASSES: readonly ["command_failure", "verification_failure", "timeout", "dependency_blocked", "resource_error", "unknown"];
export type FailureClass = (typeof FAILURE_CLASSES)[number];
export interface FailureTriageItem {
    entity_type: "task" | "run" | "verification" | "agent_run";
    entity_id: string;
    title: string;
    classification: FailureClass;
    reason: string;
    retry_count: number;
    max_retries: number;
    can_retry: boolean;
    playbook: string[];
}
export interface FailureTriageReport {
    schema_version: typeof FAILURE_TRIAGE_SCHEMA;
    generated_at: string;
    project_id: string | null;
    plan_id: string | null;
    items: FailureTriageItem[];
    summary: {
        total: number;
        retriable: number;
        exhausted: number;
        by_class: Record<FailureClass, number>;
    };
}
export interface ApplyFailureTriageInput {
    task_id?: string;
    run_record_id?: string;
    agent_run_id?: string;
    root_cause?: string;
    action?: "annotate" | "retry" | "reopen" | "split" | "escalate";
    agent_id?: string;
    split_title?: string;
    max_retries?: number;
}
export interface ApplyFailureTriageResult {
    schema_version: typeof FAILURE_TRIAGE_SCHEMA;
    action: string;
    classification: FailureClass;
    playbook: string[];
    task?: Task;
    retry_task?: Task;
    comment_id?: string;
    follow_up_task?: Task;
    agent_run?: ReturnType<typeof retryAgentRun>;
    escalated: boolean;
}
export declare function buildFailureTriageReport(filter?: {
    project_id?: string;
    plan_id?: string;
    limit?: number;
}, db?: Database): FailureTriageReport;
export declare function applyFailureTriage(input: ApplyFailureTriageInput, db?: Database): ApplyFailureTriageResult;
export declare function formatFailureTriageMarkdown(report: FailureTriageReport): string;
export declare function getFailureTriageDocs(): string;
//# sourceMappingURL=failure-triage.d.ts.map