/**
 * REPLAY - Simulation Engine
 *
 * Provides "what-if" policy testing and bulk simulation
 * for policy impact analysis before deployment.
 */
import type { ID, ControlAction, TrustLevel, TrustScore, Timestamp } from '../../common/types.js';
import type { Policy } from '../../policy/types.js';
/**
 * Input for creating a simulation intent
 */
export interface CreateIntent {
    entityId: ID;
    goal: string;
    intentType?: string;
    context?: Record<string, unknown>;
    metadata?: Record<string, unknown>;
    priority?: number;
}
/**
 * Context for simulation
 */
export interface SimulationContext {
    tenantId: ID;
    /** Trust score to use for simulation (0-1000) */
    trustScore: TrustScore;
    /** Trust level to use for simulation (0-5) */
    trustLevel: TrustLevel;
    /** Policies to evaluate against */
    policies: Policy[];
    /** Entity attributes */
    entityAttributes?: Record<string, unknown>;
    /** Environment overrides */
    environment?: {
        timestamp?: Timestamp;
        timezone?: string;
        custom?: Record<string, unknown>;
    };
}
/**
 * Result of simulating a single intent
 */
export interface SimulationResult {
    simulationId: ID;
    intentId: ID;
    tenantId: ID;
    simulatedAt: Timestamp;
    /** Whether the simulation completed successfully */
    success: boolean;
    /** The simulated outcome */
    outcome: {
        action: ControlAction;
        reason?: string;
        policiesMatched: number;
        policiesEvaluated: number;
    };
    /** Policy evaluation details */
    policyDetails: Array<{
        policyId: ID;
        policyName: string;
        matched: boolean;
        action?: ControlAction;
        reason?: string;
        rulesMatched: number;
        rulesEvaluated: number;
    }>;
    /** Input used for simulation */
    input: {
        intent: CreateIntent;
        trustScore: TrustScore;
        trustLevel: TrustLevel;
    };
    /** Timing information */
    timing: {
        durationMs: number;
    };
    /** Error information if simulation failed */
    error?: {
        message: string;
        code?: string;
    };
}
/**
 * Options for bulk simulation
 */
export interface BulkSimulationOptions {
    /** Continue processing on individual simulation failures */
    continueOnError?: boolean;
    /** Maximum concurrent simulations */
    concurrency?: number;
    /** Timeout per simulation in milliseconds */
    timeoutMs?: number;
}
/**
 * Result of bulk simulation
 */
export interface BulkSimulationResult {
    batchId: ID;
    startedAt: Timestamp;
    completedAt: Timestamp;
    totalDurationMs: number;
    /** Summary statistics */
    summary: {
        total: number;
        succeeded: number;
        failed: number;
        allowCount: number;
        denyCount: number;
        escalateCount: number;
        otherCount: number;
    };
    /** Individual simulation results */
    results: SimulationResult[];
    /** Aggregate policy impact */
    policyImpact: Array<{
        policyId: ID;
        policyName: string;
        timesMatched: number;
        timesEvaluated: number;
        matchRate: number;
        actionBreakdown: Record<ControlAction, number>;
    }>;
}
/**
 * SimulationEngine - Runs "what-if" simulations for policy testing
 */
export declare class SimulationEngine {
    private readonly defaultConcurrency;
    private readonly defaultTimeoutMs;
    /**
     * Simulate a single intent with given context
     */
    simulate(intent: CreateIntent, context: SimulationContext): Promise<SimulationResult>;
    /**
     * Run bulk simulation for policy impact analysis
     */
    simulateBulk(intents: CreateIntent[], context: SimulationContext, options?: BulkSimulationOptions): Promise<BulkSimulationResult>;
    /**
     * Calculate policy impact from simulation results
     */
    private calculatePolicyImpact;
    /**
     * Split array into chunks for concurrent processing
     */
    private chunkArray;
    /**
     * Run what-if analysis with policy modifications
     */
    whatIf(intent: CreateIntent, baseContext: SimulationContext, modifications: {
        /** Modified policies to test */
        modifiedPolicies?: Policy[];
        /** Additional policies to add */
        additionalPolicies?: Policy[];
        /** Policy IDs to exclude */
        excludePolicies?: ID[];
        /** Trust score override */
        trustScoreOverride?: TrustScore;
        /** Trust level override */
        trustLevelOverride?: TrustLevel;
    }): Promise<{
        baseline: SimulationResult;
        modified: SimulationResult;
        comparison: {
            actionChanged: boolean;
            originalAction: ControlAction;
            modifiedAction: ControlAction;
            policyDifferences: Array<{
                policyId: ID;
                policyName: string;
                baselineMatched: boolean;
                modifiedMatched: boolean;
                actionChange?: {
                    from: ControlAction;
                    to: ControlAction;
                };
            }>;
        };
    }>;
}
/**
 * Create a new SimulationEngine instance
 */
export declare function createSimulationEngine(): SimulationEngine;
//# sourceMappingURL=simulator.d.ts.map