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
54 lines
No EOL
1.3 KiB
JavaScript
54 lines
No EOL
1.3 KiB
JavaScript
/**
|
|
* Bounded Registry with LRU eviction
|
|
* Prevents unbounded memory growth in production
|
|
*/
|
|
export class BoundedRegistry {
|
|
constructor(maxSize = 10000) {
|
|
this.items = new Map(); // item -> last accessed timestamp
|
|
this.maxSize = maxSize;
|
|
}
|
|
/**
|
|
* Add item to registry, evicting oldest if at capacity
|
|
*/
|
|
add(item) {
|
|
// Update timestamp if already exists
|
|
if (this.items.has(item)) {
|
|
this.items.delete(item); // Remove to re-add at end
|
|
this.items.set(item, Date.now());
|
|
return;
|
|
}
|
|
// Evict oldest if at capacity
|
|
if (this.items.size >= this.maxSize) {
|
|
const oldest = this.items.entries().next().value;
|
|
if (oldest) {
|
|
this.items.delete(oldest[0]);
|
|
}
|
|
}
|
|
this.items.set(item, Date.now());
|
|
}
|
|
/**
|
|
* Check if item exists
|
|
*/
|
|
has(item) {
|
|
return this.items.has(item);
|
|
}
|
|
/**
|
|
* Get all items
|
|
*/
|
|
getAll() {
|
|
return Array.from(this.items.keys());
|
|
}
|
|
/**
|
|
* Get size
|
|
*/
|
|
get size() {
|
|
return this.items.size;
|
|
}
|
|
/**
|
|
* Clear all items
|
|
*/
|
|
clear() {
|
|
this.items.clear();
|
|
}
|
|
}
|
|
//# sourceMappingURL=BoundedRegistry.js.map
|