brainy/.recovery-workspace/dist-backup-20250910-141917/utils/writeBuffer.d.ts
David Snelling 8ff382ca3b 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
2025-09-10 15:18:04 -07:00

93 lines
2.3 KiB
TypeScript

/**
* Write Buffer
* Accumulates writes and flushes them in bulk to reduce S3 operations
* Implements intelligent deduplication and compression
*/
interface FlushResult {
successful: number;
failed: number;
duration: number;
}
/**
* High-performance write buffer for bulk operations
*/
export declare class WriteBuffer<T> {
private logger;
private buffer;
private maxBufferSize;
private flushInterval;
private minFlushSize;
private maxRetries;
private flushTimer;
private isFlushing;
private lastFlush;
private pendingFlush;
private totalWrites;
private totalFlushes;
private failedWrites;
private duplicatesRemoved;
private writeFunction;
private type;
private backpressure;
constructor(type: 'noun' | 'verb' | 'metadata', writeFunction: (items: Map<string, T>) => Promise<void>, options?: {
maxBufferSize?: number;
flushInterval?: number;
minFlushSize?: number;
});
/**
* Add item to buffer
*/
add(id: string, data: T): Promise<void>;
/**
* Check if we should flush
*/
private checkFlush;
/**
* Flush buffer to storage
*/
flush(reason?: string): Promise<FlushResult>;
/**
* Perform the actual flush
*/
private doFlush;
/**
* Start periodic flush timer
*/
private startPeriodicFlush;
/**
* Stop periodic flush timer
*/
stop(): void;
/**
* Force flush all pending writes
*/
forceFlush(): Promise<FlushResult>;
/**
* Get buffer statistics
*/
getStats(): {
bufferSize: number;
totalWrites: number;
totalFlushes: number;
failedWrites: number;
duplicatesRemoved: number;
avgFlushSize: number;
};
/**
* Adjust parameters based on load
*/
adjustForLoad(pendingRequests: number): void;
}
/**
* Get or create a write buffer
*/
export declare function getWriteBuffer<T>(id: string, type: 'noun' | 'verb' | 'metadata', writeFunction: (items: Map<string, T>) => Promise<void>): WriteBuffer<T>;
/**
* Flush all write buffers
*/
export declare function flushAllBuffers(): Promise<void>;
/**
* Clear all write buffers
*/
export declare function clearWriteBuffers(): void;
export {};