/** * Speculative Cache for UAM Memory System * * Pre-computes likely next queries based on task patterns. * Reduces latency by predicting and caching memory retrievals. * * Enhanced with task classifier integration for smarter prefetching */ export interface CacheEntry { query: string; result: unknown[]; embedding?: number[]; usageCount: number; lastUsed: Date; createdAt: Date; predictedBy?: string; taskCategory?: string; } export interface CacheConfig { maxEntries: number; ttlMs: number; preWarmEnabled: boolean; predictionDepth: number; } /** * Speculative Memory Cache */ export declare class SpeculativeCache { private config; private cache; private queryHistory; private taskPatterns; constructor(config?: Partial); /** * Get from cache with automatic staleness check */ get(query: string): CacheEntry | null; /** * Set cache entry */ set(query: string, result: unknown[], predictedBy?: string): void; /** * Record query for pattern analysis */ private recordQuery; /** * Detect task category from query */ private detectCategory; /** * Get predicted queries based on current context * Enhanced with seeded transition chains for faster cache warming */ getPredictedQueries(currentQuery: string): string[]; /** * Analyze query sequences for patterns */ private analyzeQuerySequences; /** * Pre-warm cache with predicted queries */ preWarm(currentQuery: string, fetcher: (query: string) => Promise): Promise; /** * Evict least recently used entry */ private evictLRU; /** * Normalize query for cache key */ private normalizeQuery; /** * Get cache statistics */ getStats(): { size: number; hitRate: number; avgUsage: number; topPatterns: Array<{ category: string; count: number; }>; }; /** * Clear expired entries */ cleanup(): number; /** * Clear all cache */ clear(): void; /** * OPTIMIZATION 6: Load historical query patterns from SQLite database * Pre-warms queryHistory and taskPatterns from persisted memory data */ loadFromDb(dbPath: string): Promise; } export declare function getSpeculativeCache(config?: Partial): SpeculativeCache; /** * OPTIMIZATION 6: Initialize cache with historical data from database * Call this at startup to warm the cache from persisted memories */ export declare function initializeCacheFromDb(dbPath: string, config?: Partial): Promise<{ cache: SpeculativeCache; entriesLoaded: number; }>; /** * OPTIMIZATION 10: Auto-warm cache with high-value Terminal-Bench patterns * Call this at startup to pre-populate cache with proven knowledge chains */ export declare function autoWarmCache(cache?: SpeculativeCache): number; //# sourceMappingURL=speculative-cache.d.ts.map