/** * Agentic QE v3 - Causal Weight Matrix * ADR-035: STDP-based spike timing correlation for root cause analysis * * Implements the core STDP (Spike-Timing Dependent Plasticity) learning rule: * - If event A consistently precedes event B (positive dt), weight A->B increases * - If event A consistently follows event B (negative dt), weight A->B decreases * - This naturally encodes Granger-like causality in the weight matrix */ import { CausalDiscoveryConfig, TestEvent, TestEventType, CausalGraph, CausalEdge, WeightEntry, WeightMatrixStats, STDPParams } from './types'; /** * Causal Weight Matrix using STDP learning rule * * The weight matrix W[i][j] represents the causal strength from event i to event j. * Positive weights indicate "causes" relationships, negative weights indicate "prevents". * * STDP Rule: * - W(dt) = A+ * exp(-dt/tau+) for dt > 0 (pre before post -> strengthen) * - W(dt) = -A- * exp(dt/tau-) for dt < 0 (post before pre -> weaken) */ export declare class CausalWeightMatrix { /** Weight entries keyed by "source->target" */ private weights; /** Last spike time for each event type */ private lastSpikeTime; /** STDP parameters */ private readonly stdpParams; /** Configuration */ private readonly config; /** Total observations counter */ private observationCount; constructor(config?: Partial, stdpParams?: Partial); /** * Get the edge key for a source-target pair */ private getKey; /** * Parse an edge key back to source and target */ private parseKey; /** * Get causal weight from source to target */ getWeight(source: TestEventType, target: TestEventType): number; /** * Get full weight entry for a source-target pair */ getWeightEntry(source: TestEventType, target: TestEventType): WeightEntry | undefined; /** * Set causal weight directly (for testing or initialization) */ setWeight(source: TestEventType, target: TestEventType, weight: number): void; /** * STDP positive timing function (pre before post -> potentiation) * Returns weight change for positive timing difference */ private stdpPositive; /** * STDP negative timing function (post before pre -> depression) * Returns weight change for negative timing difference */ private stdpNegative; /** * Update weights based on a new event using asymmetric STDP rule * * For each pair (otherEvent, currentEvent): * - If otherEvent preceded currentEvent (dt > 0), strengthen otherEvent->currentEvent * - If currentEvent preceded otherEvent (dt < 0), weaken currentEvent->otherEvent */ updateWeights(event: TestEvent): void; /** * Apply a weight change to an edge with proper tracking */ private applyWeightChange; /** * Process a batch of events in chronological order */ updateWeightsBatch(events: TestEvent[]): void; /** * Apply decay to all weights to prevent unbounded growth * Should be called periodically (e.g., after each batch of events) */ decay(): void; /** * Apply decay based on elapsed time */ decayByTime(elapsedMs: number): void; /** * Extract causal graph from learned weights * Only includes edges above the causal threshold */ extractCausalGraph(): CausalGraph; /** * Get all edges for a specific source event */ getEdgesFrom(source: TestEventType): CausalEdge[]; /** * Get all edges pointing to a specific target event */ getEdgesTo(target: TestEventType): CausalEdge[]; /** * Get statistics about the weight matrix */ getStats(): WeightMatrixStats; /** * Get the total number of observations */ getObservationCount(): number; /** * Get all unique event types that have been observed */ getObservedEventTypes(): TestEventType[]; /** * Reset the weight matrix to initial state */ reset(): void; /** * Serialize the weight matrix to a JSON-compatible object */ toJSON(): Record; /** * Deserialize from a JSON object */ fromJSON(data: Record): void; /** * Merge weights from another matrix (for distributed learning) */ merge(other: CausalWeightMatrix, mergeRatio?: number): void; } //# sourceMappingURL=weight-matrix.d.ts.map