Skip to content

armgit / ruflo

Public Imported from GitHub
0

🌊 The original agent harness. Deploy intelligent multi-player swarms, coordinate autonomous workflows, and build conversational AI systems. Features adaptive memory, self-learning intelligence, federation, vector RAG integration, and native Claude Code / Codex / Hermes and many more Integrated

fix(memory): pass a bare mode string to NeuralLearningSystem, not an object (#3336)

rUva65bdf683a73
diff --git a/v3/@claude-flow/memory/src/learning-bridge.test.ts b/v3/@claude-flow/memory/src/learning-bridge.test.ts
index e555f56627..9ed5cdc470 100644
--- a/v3/@claude-flow/memory/src/learning-bridge.test.ts
+++ b/v3/@claude-flow/memory/src/learning-bridge.test.ts
@@ -894,4 +894,43 @@ describe('LearningBridge', () => {
b.destroy();
});
});
+
+ // ===== Real @claude-flow/neural construction shape (no injected loader) =====
+
+ describe('default neural loader (real @claude-flow/neural import)', () => {
+ afterEach(() => {
+ vi.doUnmock('@claude-flow/neural');
+ });
+
+ it('constructs NeuralLearningSystem with a bare mode string, not a config object', async () => {
+ // Regression test: loadNeural() used to call
+ // `new NeuralLearningSystem({ mode, ewcLambda })`, but the real
+ // constructor is `constructor(mode: SONAMode = 'balanced')` — a bare
+ // string. Passing an object never throws (SONAManager's
+ // `MODE_CONFIGS[mode]` lookup just silently misses and falls back to
+ // `{}`), so this had to be caught by inspecting the actual argument,
+ // not by whether construction succeeds.
+ const ctorArgs: unknown[][] = [];
+ vi.doMock('@claude-flow/neural', () => ({
+ NeuralLearningSystem: class {
+ constructor(...args: unknown[]) {
+ ctorArgs.push(args);
+ }
+ initialize = vi.fn().mockResolvedValue(undefined);
+ },
+ }));
+ vi.resetModules();
+
+ const { LearningBridge: FreshLearningBridge } = await import('./learning-bridge.js');
+ const freshBackend = createMockBackend();
+ const b = new FreshLearningBridge(freshBackend, { sonaMode: 'research' });
+
+ await b.onInsightRecorded(createTestInsight(), 'entry-1');
+
+ expect(ctorArgs).toHaveLength(1);
+ expect(ctorArgs[0]).toEqual(['research']);
+ expect(b.getStats().neuralAvailable).toBe(true);
+ b.destroy();
+ });
+ });
});
diff --git a/v3/@claude-flow/memory/src/learning-bridge.ts b/v3/@claude-flow/memory/src/learning-bridge.ts
index f7d01a3c34..ba80e11408 100644
--- a/v3/@claude-flow/memory/src/learning-bridge.ts
+++ b/v3/@claude-flow/memory/src/learning-bridge.ts
@@ -445,10 +445,15 @@ export class LearningBridge extends EventEmitter {
const NeuralLearningSystem = mod.NeuralLearningSystem ?? mod.default;
if (!NeuralLearningSystem) return;
- const instance = new NeuralLearningSystem({
- mode: this.config.sonaMode,
- ewcLambda: this.config.ewcLambda,
- });
+ // NeuralLearningSystem's constructor takes a bare SONAMode string
+ // (see @claude-flow/neural's index.ts / cli's neural-package-bridge.ts
+ // for the reference-correct call shape) — it has no ewcLambda param;
+ // each mode carries its own fixed lambda via MODE_CONFIGS. Passing an
+ // object here (as this used to) doesn't throw: SONAManager's
+ // `MODE_CONFIGS[mode]` lookup coerces the object to the string
+ // "[object Object]", finds nothing, and `{...undefined}` silently
+ // produces an empty config instead of the intended mode's settings.
+ const instance = new NeuralLearningSystem(this.config.sonaMode);
if (typeof instance.initialize === 'function') {
await instance.initialize();