feat: export provider contracts for the plugin surface brainy consumes
Native accelerators (cortex) register providers for metadataIndex, graphIndex, hnsw, entityIdMapper, cache, columnStore, and aggregation. Until now the exact method/property surface brainy calls on each was implicit — a provider could drop a member brainy depends on and only fail at runtime when that path ran. This defines and exports the provider contracts from the stable @soulcraft/brainy/plugin entrypoint: - MetadataIndexProvider, GraphIndexProvider, HnswProvider, EntityIdMapperProvider, CacheProvider — each typed as exactly the surface brainy calls (optional/feature-detected members like HNSW setPersistMode and enableCOW are intentionally excluded). - Re-exports ColumnStoreProvider and AggregationProvider (and the aggregate types) from the same entrypoint so a plugin author can import the whole provider surface from one place. Brainy's own baseline classes now `implements` these contracts (MetadataIndexManager, GraphAdjacencyIndex, HNSWIndex, EntityIdMapper, UnifiedCache), so the interfaces can never silently diverge from what brainy ships — and any provider that declares `implements` gets a compile error the moment brainy starts requiring a new member. The embeddings/embedBatch providers stay typed by the existing EmbeddingFunction (no duplicate interface added). Type-only changes; no runtime behavior change.
This commit is contained in:
parent
46fc7f2c4a
commit
4b6f63ed67
6 changed files with 227 additions and 7 deletions
|
|
@ -6,6 +6,7 @@
|
|||
|
||||
import { StorageAdapter, resolveEntityField } from '../coreTypes.js'
|
||||
import { ColumnStore } from '../indexes/columnStore/ColumnStore.js'
|
||||
import type { MetadataIndexProvider } from '../plugin.js'
|
||||
import { MetadataIndexCache, MetadataIndexCacheConfig } from './metadataIndexCache.js'
|
||||
import { compareCodePoints } from './collation.js'
|
||||
import { prodLog } from './logger.js'
|
||||
|
|
@ -103,7 +104,12 @@ interface FieldStats {
|
|||
normalizationStrategy?: 'none' | 'precision' | 'bucket'
|
||||
}
|
||||
|
||||
export class MetadataIndexManager {
|
||||
/**
|
||||
* Implements {@link MetadataIndexProvider}: the metadata-index surface Brainy
|
||||
* calls on whatever the `'metadataIndex'` provider resolves to (its own
|
||||
* manager, or Cortex's native Rust engine).
|
||||
*/
|
||||
export class MetadataIndexManager implements MetadataIndexProvider {
|
||||
private storage: StorageAdapter
|
||||
private config: Required<MetadataIndexConfig>
|
||||
private isRebuilding = false
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue