From f35a94aca0ecadf277aee3d194c3261f08c2adde Mon Sep 17 00:00:00 2001 From: MentaNew <217579172+MentaNew@users.noreply.github.com> Date: Thu, 5 Nov 2026 13:53:58 -0500 Subject: [PATCH 1/2] fix(embeddings): honour 0 for decayRate and driftThreshold in embeddings_neural init --- .../embeddings-search-zero-threshold.test.ts | 31 ++++++++++++++++++- 1 file changed, 30 insertions(+), 1 deletion(-) diff --git a/v3/@claude-flow/cli/__tests__/embeddings-search-zero-threshold.test.ts b/v3/@claude-flow/cli/__tests__/embeddings-search-zero-threshold.test.ts index a781f958e3..d9093b71bf 100644 --- a/v3/@claude-flow/cli/__tests__/embeddings-search-zero-threshold.test.ts +++ b/v3/@claude-flow/cli/__tests__/embeddings-search-zero-threshold.test.ts @@ -1,5 +1,5 @@ import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'; -import { mkdtempSync, rmSync } from 'node:fs'; +import { mkdtempSync, readFileSync, rmSync } from 'node:fs'; import { join } from 'node:path'; import { tmpdir } from 'node:os'; @@ -18,6 +18,7 @@ vi.mock('../src/memory/memory-initializer.js', () => ({ const { embeddingsTools } = await import('../src/mcp-tools/embeddings-tools.js'); const init = embeddingsTools.find(tool => tool.name === 'embeddings_init')!; const search = embeddingsTools.find(tool => tool.name === 'embeddings_search')!; +const neural = embeddingsTools.find(tool => tool.name === 'embeddings_neural')!; let originalCwd: string; let workdir: string; @@ -48,3 +49,31 @@ describe('embeddings_search threshold', () => { expect(result.metadata.threshold).toBe(0.5); }); }); + +describe('embeddings_neural init', () => { + it('honours an explicit 0 for decayRate and driftThreshold', async () => { + const result = await neural.handler({ action: 'init', decayRate: 0, driftThreshold: 0 }) as any; + expect(result.success).toBe(true); + expect(result.neural.decayRate).toBe(0); + expect(result.neural.driftThreshold).toBe(0); + }); + + it('persists the 0 values to the embeddings config', async () => { + await neural.handler({ action: 'init', decayRate: 0, driftThreshold: 0 }); + const saved = JSON.parse(readFileSync(join(workdir, '.claude-flow', 'embeddings.json'), 'utf-8')); + expect(saved.neural.decayRate).toBe(0); + expect(saved.neural.driftThreshold).toBe(0); + }); + + it('still defaults to 0.3 and 0.01 when the values are omitted', async () => { + const result = await neural.handler({ action: 'init' }) as any; + expect(result.neural.driftThreshold).toBe(0.3); + expect(result.neural.decayRate).toBe(0.01); + }); + + it('keeps non-zero values as given', async () => { + const result = await neural.handler({ action: 'init', decayRate: 0.05, driftThreshold: 0.7 }) as any; + expect(result.neural.decayRate).toBe(0.05); + expect(result.neural.driftThreshold).toBe(0.7); + }); +}); From 89e5637f8829c0e1b574b950c5cf4e2db4036631 Mon Sep 17 00:00:00 2001 From: MentaNew <217579172+MentaNew@users.noreply.github.com> Date: Thu, 5 Nov 2026 13:55:17 -0500 Subject: [PATCH 2/2] fix(embeddings): use ?? for decayRate and driftThreshold defaults in embeddings_neural init --- v3/@claude-flow/cli/src/mcp-tools/embeddings-tools.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/v3/@claude-flow/cli/src/mcp-tools/embeddings-tools.ts b/v3/@claude-flow/cli/src/mcp-tools/embeddings-tools.ts index 71fe81793f..3837894284 100644 --- a/v3/@claude-flow/cli/src/mcp-tools/embeddings-tools.ts +++ b/v3/@claude-flow/cli/src/mcp-tools/embeddings-tools.ts @@ -621,8 +621,9 @@ export const embeddingsTools: MCPTool[] = [ case 'init': config.neural = { enabled: true, - driftThreshold: (input.driftThreshold as number) || 0.3, - decayRate: (input.decayRate as number) || 0.01, + // `??`, not `||`: an explicit 0 is a valid value for both. + driftThreshold: (input.driftThreshold as number) ?? 0.3, + decayRate: (input.decayRate as number) ?? 0.01, ruvector: { enabled: true, sona: true,