mirror of
https://github.com/ruvnet/RuView
synced 2026-07-27 18:11:43 +00:00
4b1005524e
- Add 154 missing vendor files (gitignore was filtering them) - vendor/midstream: 564 files (was 561) - vendor/sublinear-time-solver: 1190 files (was 1039) - Add ESP32 edge processing (ADR-039): presence, vitals, fall detection - Add WASM programmable sensing (ADR-040/041) with wasm3 runtime - Add firmware CI workflow (.github/workflows/firmware-ci.yml) - Add wifi-densepose-wasm-edge crate for edge WASM modules - Update sensing server, provision.py, UI components Co-Authored-By: claude-flow <ruv@ruv.net>
110 lines
2.6 KiB
TypeScript
110 lines
2.6 KiB
TypeScript
/**
|
|
* High-Performance Reasoning Cache for Psycho-Symbolic Analysis
|
|
* Reduces reasoning overhead from 25% to <10% through intelligent pre-computation
|
|
*/
|
|
interface CacheEntry {
|
|
result: any;
|
|
timestamp: number;
|
|
hitCount: number;
|
|
computeTime: number;
|
|
patterns: string[];
|
|
confidence: number;
|
|
ttl: number;
|
|
}
|
|
interface CacheMetrics {
|
|
hits: number;
|
|
misses: number;
|
|
totalQueries: number;
|
|
avgComputeTime: number;
|
|
cacheSize: number;
|
|
hitRatio: number;
|
|
overhead: number;
|
|
}
|
|
export declare class ReasoningCache {
|
|
private cache;
|
|
private patternCache;
|
|
private metrics;
|
|
private precomputedPatterns;
|
|
private maxCacheSize;
|
|
private defaultTTL;
|
|
private warmupEnabled;
|
|
constructor(options?: {
|
|
maxSize?: number;
|
|
defaultTTL?: number;
|
|
enableWarmup?: boolean;
|
|
});
|
|
/**
|
|
* Get cached result or mark as cache miss
|
|
*/
|
|
get(query: string, context?: any, depth?: number): CacheEntry | null;
|
|
/**
|
|
* Store result in cache with intelligent TTL
|
|
*/
|
|
set(query: string, context: any, depth: number, result: any, computeTime: number): void;
|
|
/**
|
|
* Pre-compute common reasoning patterns
|
|
*/
|
|
private initializeCommonPatterns;
|
|
/**
|
|
* Warm up cache with pre-computed results
|
|
*/
|
|
private warmupCache;
|
|
/**
|
|
* Generate cache key with content-based hashing
|
|
*/
|
|
private generateCacheKey;
|
|
/**
|
|
* Check if cache entry is still valid
|
|
*/
|
|
private isValidEntry;
|
|
/**
|
|
* Find pattern match for similar queries
|
|
*/
|
|
private findPatternMatch;
|
|
/**
|
|
* Extract reasoning patterns from query
|
|
*/
|
|
private extractPatterns;
|
|
/**
|
|
* Calculate pattern overlap between two pattern sets
|
|
*/
|
|
private calculatePatternOverlap;
|
|
/**
|
|
* Adapt cached pattern result to new query
|
|
*/
|
|
private adaptPatternResult;
|
|
/**
|
|
* Calculate dynamic TTL based on result quality
|
|
*/
|
|
private calculateTTL;
|
|
/**
|
|
* Evict least useful cache entries
|
|
*/
|
|
private evictLeastUseful;
|
|
/**
|
|
* Update pattern frequency for optimization
|
|
*/
|
|
private updatePatternFrequency;
|
|
/**
|
|
* Generate mock result for cache warming
|
|
*/
|
|
private generateMockResult;
|
|
/**
|
|
* Update performance metrics
|
|
*/
|
|
private updateMetrics;
|
|
/**
|
|
* Get current cache metrics
|
|
*/
|
|
getMetrics(): CacheMetrics;
|
|
/**
|
|
* Clear cache (for testing/maintenance)
|
|
*/
|
|
clear(): void;
|
|
/**
|
|
* Get cache status for debugging
|
|
*/
|
|
getStatus(): any;
|
|
}
|
|
export {};
|