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
|
|
@ -14,6 +14,7 @@
|
|||
*/
|
||||
|
||||
import type { StorageAdapter } from '../coreTypes.js'
|
||||
import type { EntityIdMapperProvider } from '../plugin.js'
|
||||
|
||||
export interface EntityIdMapperOptions {
|
||||
storage: StorageAdapter
|
||||
|
|
@ -27,9 +28,12 @@ export interface EntityIdMapperData {
|
|||
}
|
||||
|
||||
/**
|
||||
* Maps entity UUIDs to integer IDs for use with Roaring Bitmaps
|
||||
* Maps entity UUIDs to integer IDs for use with Roaring Bitmaps.
|
||||
*
|
||||
* Implements {@link EntityIdMapperProvider}: the surface a registered
|
||||
* `'entityIdMapper'` provider (e.g. Cortex's native mapper) must also satisfy.
|
||||
*/
|
||||
export class EntityIdMapper {
|
||||
export class EntityIdMapper implements EntityIdMapperProvider {
|
||||
private storage: StorageAdapter
|
||||
private storageKey: string
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue