fix: feature-detect setVectorBackend before wiring the mmap-vector backend
A production deployment on the native plugin reported the mmap-vector wiring failing one step past the 7.31.3 capacity fix: "this.index.setVectorBackend is not a function". Under the native plugin the active vector index is the provider's own class, which manages vector storage internally and exposes no external-backend hook — only Brainy's built-in JS HNSW index consumes one. Feature-detect the hook before doing any work (same pattern as 7.31.4's setConnectionsCodec guard), checked BEFORE opening the mmap file so no stray vector file is created for an index that will never read it. When the hook is absent the skip is logged at info level as expected behavior rather than surfacing as a scary error: the provider's index serves vectors its own way, and per-entity reads remain the designed fallback path.
This commit is contained in:
parent
a8cbab6dd0
commit
a537b3664b
1 changed files with 18 additions and 0 deletions
|
|
@ -9400,6 +9400,24 @@ export class Brainy<T = any> implements BrainyInterface<T> {
|
||||||
const provider = this.pluginRegistry.getProvider<VectorStoreMmapProvider>('vectorStore:mmap')
|
const provider = this.pluginRegistry.getProvider<VectorStoreMmapProvider>('vectorStore:mmap')
|
||||||
if (!provider) return
|
if (!provider) return
|
||||||
|
|
||||||
|
// Feature-detect: only Brainy's own JS HNSW index consumes an external
|
||||||
|
// vector backend. A native vector-index provider manages its own vector
|
||||||
|
// storage and exposes no setVectorBackend hook — skip silently (same
|
||||||
|
// pattern as the setConnectionsCodec feature-detect). Checked BEFORE
|
||||||
|
// opening the backend so no mmap file is created that nothing will read.
|
||||||
|
const indexWithBackend = this.index as unknown as {
|
||||||
|
setVectorBackend?: (backend: MmapVectorBackend) => void
|
||||||
|
}
|
||||||
|
if (typeof indexWithBackend.setVectorBackend !== 'function') {
|
||||||
|
if (!this.config.silent) {
|
||||||
|
console.log(
|
||||||
|
'[brainy] mmap-vector backend not wired (vector index manages its own ' +
|
||||||
|
'vector storage; no setVectorBackend hook) — per-entity reads in use'
|
||||||
|
)
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
const storageWithBlob = this.storage as unknown as {
|
const storageWithBlob = this.storage as unknown as {
|
||||||
getBinaryBlobPath?: (key: string) => string | null
|
getBinaryBlobPath?: (key: string) => string | null
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue