/**
 * 失败报告 — 问题十三 (Failure / Recovery Policy)。
 *
 * 核心规则:
 * - 失败必须分类为明确 FailureClass
 * - deterministic 不无限重试
 * - scope_insufficient 不静默扩大
 * - external_side_effect 部分成功必须记录已发生动作
 * - retry 必须有预算、原因和新证据
 * - unknown failure 不标记 completed
 */
import { type DiagnosticEvent } from "./diagnostic_registry.js";
export type FailureClass = "deterministic" | "fixable" | "scope_insufficient" | "external_side_effect" | "state_inconsistent" | "human_required" | "unknown";
export type RecoveryAction = "retry" | "escalate" | "expand_scope" | "require_human" | "rollback" | "abort";
export interface FailureReport {
    failure_id: string;
    task_id: string;
    contract_id?: string;
    failure_class: FailureClass;
    /** 脱敏后的摘要，不含 raw output */
    redacted_summary: string;
    /** 稳定内容哈希，用于去重和追溯 */
    error_output_hash: string;
    /** 原始输出不保留，只存 evidence ref */
    evidence_ref?: string;
    retry_count: number;
    retry_budget: number;
    retry_remaining: number;
    occurred_at: string;
    actions_taken: string[];
    external_side_effects?: string[];
    diagnostic_event: DiagnosticEvent | null;
}
export interface RecoveryPolicy {
    policy_id: string;
    failure_class: FailureClass;
    max_retries: number;
    action: RecoveryAction;
    requires_new_evidence: boolean;
    requires_human_confirmation: boolean;
    diagnostic_code: string;
}
export interface RecoveryAttempt {
    attempt_id: string;
    failure_id: string;
    policy_id: string;
    action: RecoveryAction;
    new_evidence_ids: string[];
    result: "success" | "failure" | "in_progress";
    attempted_at: string;
}
/** 按 FailureClass 获取恢复策略 */
export declare function getRecoveryPolicy(failureClass: FailureClass): RecoveryPolicy | undefined;
/** 列出所有恢复策略 */
export declare function listRecoveryPolicies(): RecoveryPolicy[];
/** 检查是否包含敏感内容 */
export declare function containsSensitiveContent(content: string): boolean;
/** 创建失败报告（含自检: 脱敏后仍含敏感内容时强制二次脱敏） */
export declare function createFailureReport(taskId: string, failureClass: FailureClass, errorOutput: string, retryCount: number, retryBudget: number, contractId?: string, externalSideEffects?: string[]): FailureReport;
/**
 * 判断是否允许重试。
 * - deterministic 不允许
 * - 超预算不允许
 * - human_required 不允许
 */
export declare function canRetry(failureClass: FailureClass, retryCount: number, retryBudget: number): boolean;
/**
 * 验证失败处理规则。
 */
export declare function validateFailureHandling(report: FailureReport): Array<{
    error: string;
    severity: "hard_fail" | "warning";
}>;
//# sourceMappingURL=failure_report.d.ts.map