mirror of
https://github.com/ruvnet/ruflo.git
synced 2026-11-25 06:36:49 +09:00
fix(memory): reject 128-dim bridge results — MCP no longer emits mock embeddings (#2395)
Closes #2395 — MCP `memory_store` emitted persistent 128-dim mock (hash-fallback) embeddings instead of the real 384-dim ONNX embeddings, while the standalone CLI worked correctly. The CLI vs MCP divergence wasted any benefit of vector memory and silently corrupted similarity recall. ROOT CAUSE `bridgeGenerateEmbedding` (v3/@claude-flow/cli/src/memory/memory-bridge.ts) called `embedder.embed(text)` and unconditionally returned the result labeled `model: 'Xenova/all-MiniLM-L6-v2', backend: 'onnx'`. The model name promises 384-dim, but AgentDB's vectorBackend controller may initialize as `enabled: false` (e.g., when ruvector isn't yet wired into its neural substrate) and silently substitute a 128-dim hash stub. The stub doesn't expose `isMock=true`, so the existing `isMock` check let it through with a wrong `'onnx'` label. Downstream `generateEmbedding` saw the non-null bridge result and returned it immediately, skipping the local ONNX chain (transformers.js / ruvector) which DOES produce 384-dim correctly. FIX Add a dimensional sanity check: if `emb.length !== 384`, the bridge result is definitively a stub (the model name we hardcode always produces 384). Return null instead. Caller falls through to `generateLocalEmbedding` which routes via the local ONNX chain. This is conservative: the only behavior change is that a previously- misclassified 128-dim "onnx" path now becomes a 384-dim real-ONNX path (when the local chain has transformers.js or ruvector) OR a clearly-labeled 128-dim hash fallback (when local ONNX also fails). Either way the backend label now matches the actual semantics. Co-Authored-By: RuFlo <ruv@ruv.net>
This commit is contained in:
1 parent
1b788705b0
commit
04f4744506
1 file changed
+13
@@ -1191,6 +1191,19 @@ export async function bridgeGenerateEmbedding(
|
||||
const isMock = (embedder as { isMock?: boolean; backend?: string }).isMock === true
|
||||
|| (embedder as { backend?: string }).backend === 'mock';
|
||||
|
||||
// #2395 — AgentDB's vectorBackend controller may initialize as
|
||||
// `enabled: false` (e.g., ruvector isn't wired into its neural substrate
|
||||
// yet) and silently fall back to a 128-dim hash stub. The embedder doesn't
|
||||
// expose isMock=true in that path, so the wrapper above was reporting
|
||||
// backend='onnx' on what's actually 128-dim hash garbage. The model name
|
||||
// we hardcode ('Xenova/all-MiniLM-L6-v2') always produces 384-dim, so a
|
||||
// dimensions mismatch is a definitive stub signal: return null and let
|
||||
// the caller fall through to generateLocalEmbedding which routes to
|
||||
// transformers.js / ruvector ONNX directly.
|
||||
if (emb.length !== 384) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return {
|
||||
embedding: Array.from(emb),
|
||||
dimensions: emb.length,
|
||||
|
||||
Reference in new issue
Block a user