import type { Intent, ControlAction, ID, Timestamp, TrustLevel, TrustScore, Decision } from '../common/types.js';
/**
 * Decision source types
 */
export type DecisionSourceType = 'policy-engine' | 'constraint-evaluator' | 'escalation-engine' | 'governance-engine' | 'external' | 'override';
/**
 * Source-specific decision
 */
export interface SourceDecision {
    /** Source identifier */
    sourceId: ID;
    /** Source type */
    sourceType: DecisionSourceType;
    /** Source name */
    sourceName: string;
    /** The decision action */
    action: ControlAction;
    /** Decision confidence (0-1) */
    confidence: number;
    /** Decision weight for aggregation */
    weight: number;
    /** Reason for decision */
    reason: string;
    /** Additional details */
    details?: Record<string, unknown>;
    /** Constraints to apply if action is 'limit' */
    constraints?: string[];
    /** Decision timestamp */
    decidedAt: Timestamp;
    /** Evaluation duration */
    durationMs?: number;
}
/**
 * Conflict resolution strategies
 */
export type ConflictStrategy = 'deny-overrides' | 'allow-overrides' | 'most-restrictive' | 'least-restrictive' | 'weighted-average' | 'unanimous-allow' | 'majority-rules' | 'priority-based';
/**
 * Aggregated decision result
 */
export interface AggregatedDecision {
    /** Final action */
    action: ControlAction;
    /** Aggregation confidence (0-1) */
    confidence: number;
    /** Source decisions that contributed */
    sourceDecisions: SourceDecision[];
    /** Which sources agreed with final decision */
    agreingSources: ID[];
    /** Which sources disagreed with final decision */
    disagreingSources: ID[];
    /** Conflict resolution details */
    conflictResolution?: ConflictResolutionDetails;
    /** Combined constraints from all sources */
    appliedConstraints: string[];
    /** Combined reasons */
    reasons: string[];
    /** Aggregation timestamp */
    aggregatedAt: Timestamp;
    /** Total aggregation duration */
    durationMs: number;
}
/**
 * Details about conflict resolution
 */
export interface ConflictResolutionDetails {
    /** Strategy used */
    strategy: ConflictStrategy;
    /** Whether there was a conflict */
    hadConflict: boolean;
    /** Conflicting actions */
    conflictingActions: ControlAction[];
    /** How the conflict was resolved */
    resolutionReason: string;
}
/**
 * Audit trail entry
 */
export interface AuditEntry {
    /** Unique audit entry ID */
    id: ID;
    /** Intent ID */
    intentId: ID;
    /** Tenant ID */
    tenantId: ID;
    /** Entity ID */
    entityId: ID;
    /** Final decision */
    decision: AggregatedDecision;
    /** Trust score at decision time */
    trustScore: TrustScore;
    /** Trust level at decision time */
    trustLevel: TrustLevel;
    /** Request context snapshot */
    contextSnapshot: Record<string, unknown>;
    /** Audit timestamp */
    timestamp: Timestamp;
    /** Audit metadata */
    metadata?: Record<string, unknown>;
}
/**
 * Audit query options
 */
export interface AuditQueryOptions {
    /** Filter by intent ID */
    intentId?: ID;
    /** Filter by entity ID */
    entityId?: ID;
    /** Filter by tenant ID */
    tenantId?: ID;
    /** Filter by action */
    action?: ControlAction;
    /** Filter by source type */
    sourceType?: DecisionSourceType;
    /** Start time */
    startTime?: Timestamp;
    /** End time */
    endTime?: Timestamp;
    /** Maximum results */
    limit?: number;
    /** Offset for pagination */
    offset?: number;
}
/**
 * Decision aggregator options
 */
export interface DecisionAggregatorOptions {
    /** Default conflict resolution strategy */
    defaultStrategy?: ConflictStrategy;
    /** Enable OpenTelemetry tracing */
    enableTracing?: boolean;
    /** Enable audit trail */
    enableAudit?: boolean;
    /** Maximum audit entries to keep in memory */
    maxAuditEntries?: number;
    /** Source priority map (for priority-based strategy) */
    sourcePriorities?: Map<DecisionSourceType, number>;
    /** Default source weights */
    defaultWeights?: Map<DecisionSourceType, number>;
    /** Minimum confidence threshold to include decision */
    minConfidenceThreshold?: number;
}
/**
 * Context for decision aggregation
 */
export interface AggregationContext {
    /** The intent */
    intent: Intent;
    /** Trust score */
    trustScore: TrustScore;
    /** Trust level */
    trustLevel: TrustLevel;
    /** Additional context */
    context?: Record<string, unknown>;
}
/**
 * DecisionAggregator class for combining decisions from multiple sources
 */
export declare class DecisionAggregator {
    private options;
    private auditTrail;
    private sourcePriorities;
    private sourceWeights;
    constructor(options?: DecisionAggregatorOptions);
    /**
     * Aggregate decisions from multiple sources
     */
    aggregate(decisions: SourceDecision[], context: AggregationContext, strategy?: ConflictStrategy): AggregatedDecision;
    /**
     * Aggregate with OpenTelemetry tracing
     */
    aggregateWithTracing(decisions: SourceDecision[], context: AggregationContext, strategy?: ConflictStrategy): Promise<AggregatedDecision>;
    /**
     * Convert aggregated decision to standard Decision type
     */
    toDecision(aggregated: AggregatedDecision, context: AggregationContext): Decision;
    /**
     * Resolve conflict between decisions
     */
    private resolveConflict;
    private resolveDenyOverrides;
    private resolveAllowOverrides;
    private resolveMostRestrictive;
    private resolveLeastRestrictive;
    private resolveWeightedAverage;
    private resolveUnanimousAllow;
    private resolveMajorityRules;
    private resolvePriorityBased;
    /**
     * Collect constraints from decisions based on final action
     */
    private collectConstraints;
    /**
     * Create empty decision when no valid sources
     */
    private createEmptyDecision;
    /**
     * Record audit entry
     */
    private recordAudit;
    /**
     * Query audit trail
     */
    queryAudit(options?: AuditQueryOptions): AuditEntry[];
    /**
     * Get audit entry by ID
     */
    getAuditEntry(auditId: ID): AuditEntry | undefined;
    /**
     * Get audit statistics
     */
    getAuditStats(): {
        totalEntries: number;
        byAction: Record<ControlAction, number>;
        bySourceType: Record<string, number>;
        conflictRate: number;
    };
    /**
     * Clear audit trail
     */
    clearAudit(): void;
    /**
     * Export audit trail
     */
    exportAudit(): AuditEntry[];
    /**
     * Set source priority
     */
    setSourcePriority(sourceType: DecisionSourceType, priority: number): void;
    /**
     * Set source weight
     */
    setSourceWeight(sourceType: DecisionSourceType, weight: number): void;
    /**
     * Get source priorities
     */
    getSourcePriorities(): Map<DecisionSourceType, number>;
    /**
     * Get source weights
     */
    getSourceWeights(): Map<DecisionSourceType, number>;
    /**
     * Get aggregator statistics
     */
    getStats(): {
        auditEntries: number;
        sourcePriorities: [DecisionSourceType, number][];
        sourceWeights: [DecisionSourceType, number][];
        defaultStrategy: ConflictStrategy;
    };
}
/**
 * Create a new decision aggregator instance
 */
export declare function createDecisionAggregator(options?: DecisionAggregatorOptions): DecisionAggregator;
/**
 * Create a source decision
 */
export declare function createSourceDecision(partial: Partial<SourceDecision> & Pick<SourceDecision, 'sourceId' | 'sourceType' | 'sourceName' | 'action' | 'reason'>): SourceDecision;
//# sourceMappingURL=decision-aggregator.d.ts.map