chore: recovery checkpoint - v3.0 API successfully recovered

CRITICAL CHECKPOINT - DO NOT PUSH TO GITHUB

Recovery Status:
- Successfully recovered brainy.ts from compiled JavaScript
- All core v3.0 API methods functional (add, get, update, delete, relate, find, etc.)
- Neural subsystem intact (562KB embedded patterns, NLP working)
- Augmentation pipeline operational (20+ augmentations)
- HNSW clustering system complete
- Triple Intelligence compiled (needs constructor fix)
- Test suite validates functionality

Changes preserved:
- 898 files with changes from last 3 days
- 144,475 insertions
- All augmentation improvements
- All test coverage enhancements
- Complete v3.0 feature set

This is a LOCAL checkpoint only - contains recovered work after corruption incident.
Created backup in .backups/brainy-full-20250910-151314.tar.gz

Branch: recovery-checkpoint-20250910-151433
Date: Wed Sep 10 03:18:04 PM PDT 2025
This commit is contained in:
David Snelling 2025-09-10 15:18:04 -07:00
parent f65455fb22
commit 8ff382ca3b
895 changed files with 143654 additions and 28268 deletions

View file

@ -0,0 +1,130 @@
/**
* Universal Display Augmentation - Intelligent Caching System
*
* High-performance LRU cache with smart eviction and batch optimization
* Designed for minimal memory footprint and maximum hit ratio
*/
import type { ComputedDisplayFields, DisplayAugmentationStats } from './types.js';
/**
* LRU (Least Recently Used) Cache for computed display fields
* Optimized for the display augmentation use case
*/
export declare class DisplayCache {
private cache;
private readonly maxSize;
private stats;
constructor(maxSize?: number);
/**
* Get cached display fields with LRU update
* @param key Cache key
* @returns Cached fields or null if not found
*/
get(key: string): ComputedDisplayFields | null;
/**
* Store computed display fields in cache
* @param key Cache key
* @param fields Computed display fields
* @param computationTime Time taken to compute (for stats)
*/
set(key: string, fields: ComputedDisplayFields, computationTime?: number): void;
/**
* Check if a key exists in cache without affecting LRU order
* @param key Cache key
* @returns True if key exists
*/
has(key: string): boolean;
/**
* Generate cache key from data
* @param id Entity ID (preferred)
* @param data Fallback data for key generation
* @param entityType Type of entity (noun/verb)
* @returns Cache key string
*/
generateKey(id?: string, data?: any, entityType?: 'noun' | 'verb'): string;
/**
* Clear all cached entries
*/
clear(): void;
/**
* Get cache statistics
* @returns Cache performance statistics
*/
getStats(): DisplayAugmentationStats;
/**
* Get current cache size
* @returns Number of cached entries
*/
size(): number;
/**
* Get cache capacity
* @returns Maximum cache size
*/
capacity(): number;
/**
* Evict least recently used entry
*/
private evictOldest;
/**
* Simple hash function for cache keys
* @param str String to hash
* @returns Simple hash number
*/
private simpleHash;
/**
* Optimize cache by removing stale entries
* Called periodically to maintain cache health
*/
optimizeCache(): void;
/**
* Precompute display fields for a batch of entities
* @param entities Array of entities with their compute functions
* @returns Promise resolving when batch is complete
*/
batchPrecompute<T>(entities: Array<{
key: string;
computeFn: () => Promise<ComputedDisplayFields>;
}>): Promise<void>;
}
/**
* Request deduplicator for batch processing
* Prevents duplicate computations for the same data
*/
export declare class RequestDeduplicator {
private pendingRequests;
private readonly batchSize;
constructor(batchSize?: number);
/**
* Deduplicate computation request
* @param key Unique key for the computation
* @param computeFn Function to compute the result
* @returns Promise that resolves to the computed fields
*/
deduplicate(key: string, computeFn: () => Promise<ComputedDisplayFields>): Promise<ComputedDisplayFields>;
/**
* Get number of pending requests
* @returns Number of pending computations
*/
getPendingCount(): number;
/**
* Clear all pending requests
*/
clear(): void;
/**
* Shutdown the deduplicator
*/
shutdown(): void;
}
/**
* Get global display cache instance
* @param maxSize Optional cache size (only used on first call)
* @returns Shared display cache instance
*/
export declare function getGlobalDisplayCache(maxSize?: number): DisplayCache;
/**
* Clear global cache (for testing or memory management)
*/
export declare function clearGlobalDisplayCache(): void;
/**
* Shutdown global cache and cleanup
*/
export declare function shutdownGlobalDisplayCache(): void;