/** * Index Augmentation - Optional Metadata Indexing * * Replaces the hardcoded MetadataIndex in Brainy with an optional augmentation. * Provides O(1) metadata filtering and field lookups. * * Zero-config: Automatically enabled for better search performance * Can be disabled or customized via augmentation registry */ import { BaseAugmentation } from './brainyAugmentation.js'; import { MetadataIndexManager } from '../utils/metadataIndex.js'; export interface IndexConfig { enabled?: boolean; maxFieldValues?: number; maxIndexSize?: number; autoRebuild?: boolean; rebuildThreshold?: number; flushInterval?: number; } /** * IndexAugmentation - Makes metadata indexing optional and pluggable * * Features: * - O(1) metadata field lookups * - Fast pre-filtering for searches * - Automatic index maintenance * - Zero-config with smart defaults */ export declare class IndexAugmentation extends BaseAugmentation { readonly metadata: "readonly"; readonly name = "index"; readonly timing: "after"; operations: ("add" | "update" | "updateMetadata" | "delete" | "clear" | "all")[]; readonly priority = 60; readonly category: "core"; readonly description = "Fast metadata field indexing for O(1) filtering and lookups"; private metadataIndex; protected config: IndexConfig; private flushTimer; constructor(config?: IndexConfig); protected onInitialize(): Promise; protected onShutdown(): Promise; /** * Execute augmentation - maintain index on data operations */ execute(operation: string, params: any, next: () => Promise): Promise; /** * Handle add operation - index new metadata */ private handleAdd; /** * Handle update operation - reindex metadata */ private handleUpdate; /** * Handle delete operation - remove from index */ private handleDelete; /** * Handle clear operation - clear index */ private handleClear; /** * Start periodic flush timer */ private startFlushTimer; /** * Get IDs that match metadata filter (for pre-filtering) */ getIdsForFilter(filter: Record): Promise; /** * Get available values for a field */ getFilterValues(field: string): Promise; /** * Get all indexed fields */ getFilterFields(): Promise; /** * Get index statistics */ getStats(): Promise<{ enabled: boolean; totalEntries: number; fieldsIndexed: never[]; memoryUsage: number; } | { totalEntries: number; totalIds: number; fieldsIndexed: string[]; lastRebuild: number; indexSize: number; enabled: boolean; memoryUsage?: undefined; }>; /** * Rebuild the index from storage */ rebuild(): Promise; /** * Flush index to storage */ flush(): Promise; /** * Add entry to index (public method for direct access) */ addToIndex(id: string, metadata: Record): Promise; /** * Remove entry from index (public method for direct access) */ removeFromIndex(id: string, metadata: Record): Promise; /** * Get the underlying MetadataIndexManager instance */ getMetadataIndex(): MetadataIndexManager | null; } /** * Factory function for zero-config index augmentation */ export declare function createIndexAugmentation(config?: IndexConfig): IndexAugmentation;