/**
 * RetentionManager -- Enforces data retention policies per compliance framework.
 *
 * Manages lifecycle of audit logs, session data, and incident records
 * with framework-specific retention periods.
 *
 * Retention periods (configurable per pack):
 *   - HIPAA: 6 years (45 CFR 164.530(j))
 *   - PCI DSS: 12 months (Req 10.7)
 *   - SOC 2: 12 months (CC7.4)
 *   - GDPR: Purpose-dependent (Art. 5(1)(e))
 *   - SOX: 7 years (SOX Act Section 802)
 *
 * P4-RET-04 upgrade (AC 11):
 *   - enforce() now consults PolicyMatrix.resolve() per file for dynamic
 *     retention days and action (replaces per-category config lookup).
 *   - enforce() queries LegalHoldStore.findHoldsMatching() before each
 *     delete. Any active hold aborts the delete and emits
 *     'retention:blocked-by-legal-hold' via the audit emitter.
 *   - Every actual delete emits 'retention:deleted' via the audit emitter.
 *   - Audit-chain append is fail-closed: if append throws, the delete does
 *     NOT proceed (prevents orphaned deletes -- AC 16).
 *   - Per-file DataClassTag is read from a sidecar '<file>.meta.json'
 *     when present; falls back to category-level tag from managedDir config.
 *
 * @connexum/ai-governance
 */
import type { PolicyMatrix } from '../retention/policy-matrix';
import type { LegalHoldStore } from '../retention/legal-hold-store';
import type { DataClassTag } from '../retention/data-class';
export type RetentionAuditEmitter = (eventName: string, payload: Record<string, unknown>) => Promise<void>;
/** Shape of the .meta.json sidecar placed next to a managed file. */
export interface FileMeta {
    dataClassTag?: DataClassTag;
    tenantId?: string;
    contractId?: string;
}
export interface RetentionPolicy {
    /** Category of data (e.g., 'audit-logs', 'session-state', 'incidents') */
    category: string;
    /** Retention period in days */
    retentionDays: number;
    /** Regulatory reference */
    reference: string;
    /** Action after retention: 'delete' | 'archive' */
    action: 'delete' | 'archive';
    /** Archive directory (required if action is 'archive') */
    archiveDir?: string;
}
export interface RetentionManagerConfig {
    /** Directories to manage */
    managedDirs: Array<{
        path: string;
        category: string;
        filePattern?: string;
        /** Default DataClassTag for files in this dir when no sidecar is present. */
        defaultTag?: DataClassTag;
    }>;
    /** Retention policies per category (legacy: used when PolicyMatrix is absent) */
    policies: RetentionPolicy[];
    /** Directory for retention action logs */
    logDir: string;
    /** Dry run mode (log actions but don't execute) */
    dryRun?: boolean;
    /**
     * P4-RET-04 (AC 11): Optional PolicyMatrix for dynamic per-tenant resolution.
     * When provided, PolicyMatrix.resolve() is called per file using the file's
     * DataClassTag. When absent, the legacy category-based policy map is used.
     */
    policyMatrix?: PolicyMatrix;
    /**
     * P4-RET-04 (AC 11): Optional LegalHoldStore for pre-delete hold checks.
     * When provided, findHoldsMatching() is called before every delete.
     * When absent, no hold check is performed (legacy behaviour).
     */
    legalHoldStore?: LegalHoldStore;
    /**
     * P4-RET-04 (AC 11, 16): Optional audit emitter.
     * retention:deleted events are emitted per delete.
     * retention:blocked-by-legal-hold events are emitted per hold block.
     * Fail-closed: if emitter throws, the delete does NOT proceed.
     */
    auditEmitter?: RetentionAuditEmitter;
    /**
     * Unique job ID for this enforcement run. Used in audit events.
     * Defaults to a random UUID if not set.
     */
    jobId?: string;
}
export interface RetentionAction {
    timestamp: string;
    file: string;
    category: string;
    action: 'deleted' | 'archived' | 'retained' | 'skipped';
    reason: string;
    fileAgeDays: number;
    retentionDays: number;
    dryRun: boolean;
    /**
     * P4-RET-01: DataClassTag embedded in this retention action record.
     * For JSONL stores, the tag is embedded as a field in each action record.
     *
     * TODO(P4-RET-04 migration): When Prisma gains a RetentionAction model,
     * surface packBinding/dataClass as DB columns instead.
     * Prisma model diff (add to schema.prisma when P4-RET-04 lands):
     *   dataClass      String?
     *   packBinding    String[]
     *   sovereigntyZone String?
     *   classifiedAt   DateTime?
     */
    dataClassTag?: import('../retention/data-class').DataClassTag;
}
export interface RetentionReport {
    timestamp: string;
    totalFilesScanned: number;
    filesDeleted: number;
    filesArchived: number;
    filesRetained: number;
    actions: RetentionAction[];
    policiesApplied: string[];
}
export declare class RetentionManager {
    private config;
    private policyMap;
    constructor(config: RetentionManagerConfig);
    /**
     * Run retention enforcement across all managed directories.
     *
     * Legacy sync path (no PolicyMatrix / LegalHoldStore). When P4-RET-04
     * options (policyMatrix, legalHoldStore, auditEmitter) are configured,
     * use enforceAsync() instead to get hold-checked, audit-chained enforcement.
     *
     * This method is preserved for backward compatibility with existing tests
     * and callers that do not yet need P4-RET-04 semantics.
     */
    enforce(): RetentionReport;
    /**
     * Async enforcement (P4-RET-04). Returns a Promise<RetentionReport>.
     * This is the primary method when PolicyMatrix + LegalHoldStore are wired.
     *
     * For backward compat, callers that do not need P4-RET-04 semantics can
     * call enforceSync() which has the old behaviour (no hold check, no matrix).
     */
    enforceAsync(): Promise<RetentionReport>;
    /**
     * Legacy synchronous enforcement. No PolicyMatrix, no LegalHoldStore,
     * no audit emission. Maintained for backward compatibility with callers
     * that have not yet migrated to P4-RET-04.
     */
    enforceSync(): RetentionReport;
    /**
     * Check what would happen without executing (dry run).
     * Uses enforceSync() for backward compat.
     */
    preview(): RetentionReport;
    /**
     * Get the effective retention policy for a category.
     */
    getPolicy(category: string): RetentionPolicy | null;
    /**
     * Get all policies.
     */
    getPolicies(): RetentionPolicy[];
    /**
     * Check if a specific file should be retained or expired.
     */
    checkFile(filePath: string, category: string): {
        expired: boolean;
        ageDays: number;
        retentionDays: number;
    };
    /**
     * Read per-file DataClassTag from a sidecar <file>.meta.json.
     * Falls back to the managedDir's defaultTag if no sidecar exists.
     * Returns null if neither is available.
     */
    private readSidecarTag;
    /**
     * P4-RET-04 async file processor. Handles PolicyMatrix resolution,
     * LegalHoldStore check, and fail-closed audit emission before delete.
     */
    private processFileAsync;
    private processFile;
    private archiveFile;
    private deleteFile;
    private getFileAgeDays;
    private listFiles;
}
//# sourceMappingURL=retention-manager.d.ts.map