/** * @module memory/async-processor * @description Async background processor for memory maintenance tasks. * * Runs periodic maintenance on the memory database without blocking the main * event loop: * - Relevance decay application (every 1 hour) * - Stream buffer eviction (every 5 minutes) * - Tool call archiving (every 1 hour) * - Memory pruning (every 6 hours) * - WAL checkpoint (every 10 minutes) * * Uses setImmediate + setTimeout for non-blocking scheduling. The processor * is a singleton that starts when the MCP server boots and stops on shutdown. */ /** * @name MaintenanceSchedule * @description Interval configuration for each maintenance task. */ interface MaintenanceSchedule { /** Apply relevance decay to all memories. */ decayIntervalMs: number; /** Evict old consumed stream events. */ evictIntervalMs: number; /** Archive old tool call records. */ archiveIntervalMs: number; /** Prune expired + low-relevance memories. */ pruneIntervalMs: number; /** WAL checkpoint to prevent WAL file growth. */ checkpointIntervalMs: number; } /** * @name AsyncMemoryProcessor * @description Background processor for memory maintenance. * * Runs non-blocking periodic tasks using setTimeout chains (not setInterval, * to avoid overlapping executions). Each task catches its own errors and logs * them — a failure in one task doesn't stop the others. */ export declare class AsyncMemoryProcessor { private timers; private running; private readonly schedule; constructor(schedule?: Partial); /** * @name start * @description Starts all background maintenance tasks. */ start(): void; /** * @name stop * @description Stops all background tasks and clears timers. */ stop(): void; /** * @name isRunning * @description Returns whether the processor is running. */ isRunning(): boolean; /** * @name scheduleTask * @description Schedules a recurring task using setTimeout chains. * Uses setImmediate for the first run to avoid blocking server startup. * @internal */ private scheduleTask; /** * @name runDecay * @description Applies relevance decay to all agent memories. * The decay is computed in JS (better-sqlite3 is synchronous) and applied * as a batch UPDATE. * @internal */ private runDecay; /** * @name runEvict * @description Evicts old consumed stream events to keep the buffer bounded. * @internal */ private runEvict; /** * @name runArchive * @description Archives tool call records older than the retention period. * @internal */ private runArchive; /** * @name runPrune * @description Prunes expired and low-relevance memories. * @internal */ private runPrune; /** * @name runCheckpoint * @description Forces a WAL checkpoint to prevent the WAL file from growing * unbounded. Uses PASSIVE mode to avoid blocking readers. * @internal */ private runCheckpoint; } /** * @name asyncMemoryProcessor * @description Singleton instance of the async memory processor. */ export declare const asyncMemoryProcessor: AsyncMemoryProcessor; export {}; //# sourceMappingURL=async-processor.d.ts.map