/**
 * Multi-Model Consensus Types
 *
 * Types for running certification agents across multiple LLM providers
 * and calculating inter-model consensus.
 *
 * @module multimodel/types
 */
import type { AgentType, Finding, Severity } from "../certification/types.js";
import type { ModelId, ModelProvider } from "../cost/types.js";
/**
 * Configuration for a model in multi-model runs
 */
export interface ModelConfig {
    /** Model identifier */
    id: ModelId;
    /** Provider (anthropic, openai, google) */
    provider: ModelProvider;
    /** Optional custom endpoint */
    endpoint?: string;
    /** Optional API key (defaults to env var) */
    apiKey?: string;
    /** Weight for consensus voting (default: 1.0) */
    weight?: number;
    /** Whether this model is enabled */
    enabled?: boolean;
}
/**
 * Result from a single model run
 */
export interface ModelRunResult {
    /** Model used */
    model: ModelId;
    /** Provider */
    provider: ModelProvider;
    /** Agent type */
    agent: AgentType;
    /** Findings from this model */
    findings: Finding[];
    /** Execution time in ms */
    duration: number;
    /** Token usage */
    tokens: {
        input: number;
        output: number;
        total: number;
    };
    /** Cost in USD */
    cost: number;
    /** Whether run was successful */
    success: boolean;
    /** Error message if failed */
    error?: string;
    /** Timestamp */
    timestamp: string;
}
/**
 * Finding match between models
 */
export interface FindingMatch {
    /** Finding ID from reference model */
    referenceId: string;
    /** Matched finding IDs from other models (partial since not all models may be in the run) */
    matchedIds: Partial<Record<ModelId, string | null>>;
    /** Match confidence (0-100) */
    confidence: number;
    /** Match type */
    matchType: "exact" | "similar" | "partial" | "none";
    /** The finding data */
    finding: Finding;
    /** Models that found this issue */
    foundBy: ModelId[];
    /** Models that missed this issue */
    missedBy: ModelId[];
}
/**
 * Disagreement between models
 */
export interface ModelDisagreement {
    /** Type of disagreement */
    type: "severity" | "existence" | "location" | "description";
    /** Finding ID */
    findingId: string;
    /** Models involved */
    models: ModelId[];
    /** Details of disagreement */
    details: {
        /** What each model reported (partial since not all models may report) */
        values: Partial<Record<ModelId, string | number | null>>;
        /** Recommended resolution */
        resolution?: string;
    };
    /** Severity of the disagreement */
    severity: "high" | "medium" | "low";
}
/**
 * Inter-model consensus result
 */
export interface MultiModelConsensus {
    /** Certification ID */
    certificationId: string;
    /** Agent type */
    agent: AgentType;
    /** Models used */
    models: ModelId[];
    /** Individual model results */
    results: ModelRunResult[];
    /** Matched findings across models */
    matches: FindingMatch[];
    /** Disagreements between models */
    disagreements: ModelDisagreement[];
    /** Consensus metrics */
    metrics: {
        /** Agreement rate (0-100) */
        agreementRate: number;
        /** Number of unanimous findings */
        unanimousFindings: number;
        /** Number of majority findings */
        majorityFindings: number;
        /** Number of disputed findings */
        disputedFindings: number;
        /** Number of unique findings (only one model found) */
        uniqueFindings: number;
        /** Fleiss' kappa for inter-rater reliability */
        fleissKappa: number;
        /** By severity breakdown */
        bySeverity: Record<Severity, {
            unanimous: number;
            majority: number;
            disputed: number;
        }>;
    };
    /** Final merged findings (after consensus) */
    mergedFindings: Finding[];
    /** Timestamp */
    calculatedAt: string;
}
/**
 * Multi-model run options
 */
export interface MultiModelRunOptions {
    /** Models to use (defaults to all enabled) */
    models?: ModelId[];
    /** Agents to run */
    agents?: AgentType[];
    /** Whether to run models in parallel */
    parallel?: boolean;
    /** Timeout per model in ms */
    timeout?: number;
    /** Stop on first model failure */
    failFast?: boolean;
    /** Minimum models required for consensus */
    minModels?: number;
    /** Threshold for considering findings as matching (0-100) */
    matchThreshold?: number;
    /** Whether to include cost tracking */
    trackCosts?: boolean;
}
/**
 * Configuration for multi-model certification
 */
export interface MultiModelConfig {
    /** Available models */
    models: ModelConfig[];
    /** Default run options */
    defaults?: MultiModelRunOptions;
    /** Consensus thresholds */
    thresholds?: {
        /** Minimum agreement for unanimous (default: 100) */
        unanimous: number;
        /** Minimum agreement for majority (default: 50) */
        majority: number;
        /** Fleiss' kappa threshold for good agreement (default: 0.6) */
        goodAgreement: number;
    };
}
/**
 * Summary of multi-model certification
 */
export interface MultiModelSummary {
    /** Total models used */
    totalModels: number;
    /** Successful models */
    successfulModels: number;
    /** Total findings across all models */
    totalFindings: number;
    /** Unique findings after dedup */
    uniqueFindings: number;
    /** Agreement rate */
    agreementRate: number;
    /** Inter-rater reliability (Fleiss' kappa) */
    reliability: number;
    /** Total cost */
    totalCost: number;
    /** Total tokens */
    totalTokens: number;
    /** High-confidence findings (found by majority) */
    highConfidenceFindings: number;
    /** Disputed findings */
    disputedFindings: number;
}
//# sourceMappingURL=types.d.ts.map