/** * Optimization Module Types * ADR-024: Self-Optimization Engine * * Types for auto-tuning system parameters based on performance metrics. */ /** * Base interface for tunable parameters */ export interface TunableParameterBase { /** Unique parameter name (dot notation: 'hnsw.efSearch') */ name: string; /** Human-readable description */ description: string; /** Metric used to evaluate parameter effectiveness */ metric: string; /** Target value for the metric */ target: number; /** Whether higher metric values are better */ higherIsBetter: boolean; /** Weight for multi-objective optimization (0-1) */ weight: number; /** Whether the parameter is currently being tuned */ enabled: boolean; } /** * Numeric tunable parameter */ export interface NumericTunableParameter extends TunableParameterBase { type: 'numeric'; current: number; min: number; max: number; step?: number; } /** * Categorical tunable parameter */ export interface CategoricalTunableParameter extends TunableParameterBase { type: 'categorical'; current: string; options: string[]; } /** * Union type for all tunable parameters */ export type TunableParameter = NumericTunableParameter | CategoricalTunableParameter; /** * A collected metric sample */ export interface MetricSample { name: string; value: number; timestamp: Date; tags?: Record; } /** * Aggregated metric statistics */ export interface MetricStats { name: string; count: number; min: number; max: number; mean: number; median: number; stdDev: number; p95: number; p99: number; trend: 'improving' | 'stable' | 'degrading'; periodStart: Date; periodEnd: Date; } /** * Metric collector interface */ export interface MetricCollector { /** Unique collector ID */ id: string; /** Metric name this collector handles */ metricName: string; /** Collect current metric value */ collect(): Promise; /** Get aggregated stats for a time period */ getStats(periodMs: number): Promise; } /** * Result of evaluating a parameter configuration */ export interface EvaluationResult { /** Parameter values used */ parameterValues: Record; /** Metric values achieved */ metricValues: Record; /** Overall score (weighted combination) */ overallScore: number; /** When this evaluation was performed */ timestamp: Date; /** Duration of evaluation */ durationMs: number; } /** * Suggested parameter adjustment */ export interface ParameterSuggestion { parameterName: string; currentValue: number | string; suggestedValue: number | string; expectedImprovement: number; confidence: number; reasoning: string; } /** * Tuning cycle result */ export interface TuningCycleResult { cycleId: string; startedAt: Date; completedAt: Date; evaluationsPerformed: number; bestConfiguration: Record; bestScore: number; suggestions: ParameterSuggestion[]; appliedChanges: Array<{ parameter: string; oldValue: number | string; newValue: number | string; }>; } /** * Tuning algorithm configuration */ export interface TuningConfig { /** Minimum samples before tuning */ minSamplesBeforeTuning: number; /** How often to run tuning cycles (ms) */ tuningIntervalMs: number; /** Maximum parameter change per cycle (as fraction) */ maxChangePerCycle: number; /** Exploration vs exploitation balance (0-1) */ explorationRate: number; /** Number of evaluations per tuning cycle */ evaluationsPerCycle: number; /** Minimum improvement required to apply change */ minImprovementThreshold: number; /** Enable automatic parameter updates */ autoApply: boolean; } /** * Interface for applying parameter changes to actual systems * This bridges the gap between tuning suggestions and real system configuration */ export interface ParameterApplicator { /** Parameter name this applicator handles */ parameterName: string; /** Get the current value from the real system */ getCurrentValue(): Promise; /** Apply a new value to the real system */ setValue(value: number | string): Promise; /** Validate a value before applying (optional) */ validate?(value: number | string): boolean; } /** * Registry of parameter applicators */ export interface ParameterApplicatorRegistry { register(applicator: ParameterApplicator): void; get(parameterName: string): ParameterApplicator | undefined; getAll(): ParameterApplicator[]; applyConfiguration(config: Record): Promise; } /** * Auto-tuner state */ export interface AutoTunerState { status: 'idle' | 'collecting' | 'tuning' | 'applying' | 'error'; lastTuningCycle?: TuningCycleResult; totalCycles: number; totalImprovements: number; currentParameters: Record; parameterHistory: Array<{ timestamp: Date; parameter: string; oldValue: number | string; newValue: number | string; reason: string; }>; } /** * Auto-tuner statistics */ export interface AutoTunerStats { totalCycles: number; successfulCycles: number; failedCycles: number; totalImprovements: number; avgImprovementPerCycle: number; parametersTracked: number; metricsCollected: number; lastCycleAt?: Date; nextCycleAt?: Date; } /** * Default tunable parameters for AQE */ export declare const DEFAULT_TUNABLE_PARAMETERS: TunableParameter[]; /** * Default tuning configuration */ export declare const DEFAULT_TUNING_CONFIG: TuningConfig; //# sourceMappingURL=types.d.ts.map