/**
 * History Types
 *
 * Defines types for tracking certification and scan history over time.
 *
 * @module history/types
 */
import { z } from "zod";
import type { Severity, CertificationLevel, AgentType } from "../certification/types.js";
import type { ComplianceFramework } from "../compliance/types.js";
/**
 * History entry type
 */
export type HistoryEntryType = "certification_started" | "certification_completed" | "scan_completed" | "finding_submitted" | "finding_fixed" | "compliance_report" | "model_run";
/**
 * Actor identity for audit trail
 */
export interface ActorIdentity {
    /** Actor type */
    type: "user" | "service" | "system";
    /** Unique identifier (user ID, service account name, or "system") */
    id: string;
    /** Email address if available */
    email?: string;
    /** Display name */
    name?: string;
    /** IP address or hostname (for audit purposes) */
    source?: string;
}
/**
 * Integrity proof for tamper-evident audit trail
 */
export interface IntegrityProof {
    /** SHA-256 hash of this entry (excluding the integrity field itself) */
    hash: string;
    /** SHA-256 hash of the previous entry (forms hash chain) */
    previousHash: string;
    /** Sigstore signature if signing is enabled */
    signature?: string;
    /** Rekor transparency log index if published */
    rekorLogIndex?: number;
    /** Rekor log ID */
    rekorLogId?: string;
}
/**
 * Base history entry
 */
export interface BaseHistoryEntry {
    id: string;
    timestamp: string;
    type: HistoryEntryType;
    projectPath: string;
    certificationId?: string;
    /** Actor who performed this action (for audit trail) */
    actor?: ActorIdentity;
    /** Integrity proof for tamper-evident audit trail */
    integrity?: IntegrityProof;
}
/**
 * Certification started entry
 */
export interface CertificationStartedEntry extends BaseHistoryEntry {
    type: "certification_started";
    agents: AgentType[];
}
/**
 * Certification completed entry
 */
export interface CertificationCompletedEntry extends BaseHistoryEntry {
    type: "certification_completed";
    certificationId: string;
    level: CertificationLevel;
    score: number;
    findingsCount: number;
    bySeverity: Record<Severity, number>;
    durationMs: number;
}
/**
 * Scan completed entry
 */
export interface ScanCompletedEntry extends BaseHistoryEntry {
    type: "scan_completed";
    scanners: string[];
    findingsCount: number;
    bySeverity: Record<Severity, number>;
    durationMs: number;
}
/**
 * Finding submitted entry
 */
export interface FindingSubmittedEntry extends BaseHistoryEntry {
    type: "finding_submitted";
    certificationId: string;
    agent: AgentType;
    findingId: string;
    severity: Severity;
    category: string;
    file: string;
}
/**
 * Finding fixed entry
 */
export interface FindingFixedEntry extends BaseHistoryEntry {
    type: "finding_fixed";
    findingId: string;
    severity: Severity;
    fixMethod: "autofix" | "manual";
    pattern?: string;
}
/**
 * Compliance report entry
 */
export interface ComplianceReportEntry extends BaseHistoryEntry {
    type: "compliance_report";
    certificationId: string;
    framework: ComplianceFramework;
    complianceScore: number;
    controlsTotal: number;
    controlsCompliant: number;
    controlsAtRisk: number;
    controlsNonCompliant: number;
}
/**
 * Model run entry (for multi-model tracking)
 */
export interface ModelRunEntry extends BaseHistoryEntry {
    type: "model_run";
    certificationId: string;
    model: string;
    agent: AgentType;
    findingsCount: number;
    inputTokens: number;
    outputTokens: number;
    durationMs: number;
    cost?: number;
}
/**
 * Union of all history entry types
 */
export type HistoryEntry = CertificationStartedEntry | CertificationCompletedEntry | ScanCompletedEntry | FindingSubmittedEntry | FindingFixedEntry | ComplianceReportEntry | ModelRunEntry;
/**
 * History query options
 */
export interface HistoryQueryOptions {
    /** Filter by entry type */
    type?: HistoryEntryType | HistoryEntryType[];
    /** Filter by project path */
    projectPath?: string;
    /** Filter by certification ID */
    certificationId?: string;
    /** Start date (ISO string) */
    startDate?: string;
    /** End date (ISO string) */
    endDate?: string;
    /** Maximum number of entries to return */
    limit?: number;
    /** Offset for pagination */
    offset?: number;
    /** Sort order */
    order?: "asc" | "desc";
}
/**
 * History query result
 */
export interface HistoryQueryResult {
    entries: HistoryEntry[];
    total: number;
    hasMore: boolean;
}
/**
 * Time period for trends
 */
export type TrendPeriod = "day" | "week" | "month" | "quarter" | "year";
/**
 * Trend data point
 */
export interface TrendDataPoint {
    period: string;
    startDate: string;
    endDate: string;
    certificationCount: number;
    scanCount: number;
    findingsTotal: number;
    findingsFixed: number;
    avgScore: number;
    bySeverity: Record<Severity, number>;
}
/**
 * Trend analysis result
 */
export interface TrendAnalysis {
    projectPath: string;
    period: TrendPeriod;
    dataPoints: TrendDataPoint[];
    summary: {
        totalCertifications: number;
        totalScans: number;
        totalFindings: number;
        totalFixed: number;
        avgScore: number;
        scoreChange: number;
        findingsChange: number;
    };
}
/**
 * Zod schemas for validation
 */
export declare const HistoryQueryOptionsSchema: z.ZodObject<{
    type: z.ZodOptional<z.ZodUnion<[z.ZodEnum<["certification_started", "certification_completed", "scan_completed", "finding_submitted", "finding_fixed", "compliance_report", "model_run"]>, z.ZodArray<z.ZodEnum<["certification_started", "certification_completed", "scan_completed", "finding_submitted", "finding_fixed", "compliance_report", "model_run"]>, "many">]>>;
    projectPath: z.ZodOptional<z.ZodString>;
    certificationId: z.ZodOptional<z.ZodString>;
    startDate: z.ZodOptional<z.ZodString>;
    endDate: z.ZodOptional<z.ZodString>;
    limit: z.ZodDefault<z.ZodNumber>;
    offset: z.ZodDefault<z.ZodNumber>;
    order: z.ZodDefault<z.ZodEnum<["asc", "desc"]>>;
}, "strip", z.ZodTypeAny, {
    limit: number;
    offset: number;
    order: "asc" | "desc";
    projectPath?: string | undefined;
    certificationId?: string | undefined;
    type?: "compliance_report" | "certification_started" | "certification_completed" | "scan_completed" | "finding_submitted" | "finding_fixed" | "model_run" | ("compliance_report" | "certification_started" | "certification_completed" | "scan_completed" | "finding_submitted" | "finding_fixed" | "model_run")[] | undefined;
    startDate?: string | undefined;
    endDate?: string | undefined;
}, {
    projectPath?: string | undefined;
    certificationId?: string | undefined;
    type?: "compliance_report" | "certification_started" | "certification_completed" | "scan_completed" | "finding_submitted" | "finding_fixed" | "model_run" | ("compliance_report" | "certification_started" | "certification_completed" | "scan_completed" | "finding_submitted" | "finding_fixed" | "model_run")[] | undefined;
    limit?: number | undefined;
    offset?: number | undefined;
    order?: "asc" | "desc" | undefined;
    startDate?: string | undefined;
    endDate?: string | undefined;
}>;
/**
 * Integrity verification result for a single entry
 */
export interface EntryVerificationResult {
    /** Entry ID */
    entryId: string;
    /** Entry timestamp */
    timestamp: string;
    /** Whether the entry hash is valid */
    hashValid: boolean;
    /** Whether the chain link to previous entry is valid */
    chainValid: boolean;
    /** Whether the signature is valid (if present) */
    signatureValid?: boolean;
    /** Rekor transparency log index (if signed) */
    rekorLogIndex?: number;
    /** Rekor log ID (if signed) */
    rekorLogId?: string;
    /** Failure reason if any check failed */
    failureReason?: string;
}
/**
 * Full history integrity verification result
 */
export interface IntegrityVerificationResult {
    /** Project path verified */
    projectPath: string;
    /** When verification was performed */
    verifiedAt: string;
    /** Overall verification status */
    verified: boolean;
    /** Total entries in history */
    totalEntries: number;
    /** Number of entries verified */
    entriesVerified: number;
    /** Number of entries that passed all checks */
    entriesPassed: number;
    /** Number of entries that failed verification */
    entriesFailed: number;
    /** Chain integrity (no gaps, all links valid) */
    chainIntegrity: boolean;
    /** First failure found (if any) */
    firstFailure?: EntryVerificationResult;
    /** All failures (for detailed report) */
    failures: EntryVerificationResult[];
    /** Genesis entry hash (first entry in chain) */
    genesisHash?: string;
    /** Latest entry hash (head of chain) */
    headHash?: string;
}
//# sourceMappingURL=types.d.ts.map