🌊 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
TypeScript agentic-aiagentic-frameworkagentic-workflowagentsai-agentsai-assistantai-skillsautonomous-agentsclaudecodexdsh-pluginharnessmcp-servermulti-agentmulti-agent-systemsnpmskillsswarmswarm-intelligencetypescript
fix(sona): reject inherited keys in env mode validation
takagibit180f8a934dbdf1
diff --git a/v3/@claude-flow/integration/src/__tests__/sona-adapter.test.ts b/v3/@claude-flow/integration/src/__tests__/sona-adapter.test.tsindex f08de68cc1..d9d867f591 100644--- a/v3/@claude-flow/integration/src/__tests__/sona-adapter.test.ts+++ b/v3/@claude-flow/integration/src/__tests__/sona-adapter.test.ts@@ -27,10 +27,19 @@ describe('sonaModeFromEnv', () => {expect(sonaModeFromEnv()).toBeUndefined();});- it('returns the mode for a recognised value', () => {- process.env[ENV_KEY] = 'research';- expect(sonaModeFromEnv()).toBe('research');- });+ it.each(['real-time', 'balanced', 'research', 'edge', 'batch'])(+ 'returns the mode for recognised value %s', (mode) => {+ process.env[ENV_KEY] = mode;+ expect(sonaModeFromEnv()).toBe(mode);+ },+ );++ it.each(['constructor', 'toString', '__proto__', 'hasOwnProperty', 'valueOf'])(+ 'ignores inherited object key %s', (value) => {+ process.env[ENV_KEY] = value;+ expect(sonaModeFromEnv()).toBeUndefined();+ },+ );it('trims whitespace around the value', () => {process.env[ENV_KEY] = ' edge ';@@ -75,10 +84,53 @@ describe('SONAAdapter mode resolution', () => {expect(adapter.getMode()).toBe('research');});- it('an explicit config.mode wins over RUFLO_INTELLIGENCE_MODE', () => {- process.env[ENV_KEY] = 'research';- const adapter = new SONAAdapter({ mode: 'edge' });- expect(adapter.getMode()).toBe('edge');+ it.each(['research', 'constructor'])(+ 'an explicit config.mode wins over env value %s', (value) => {+ process.env[ENV_KEY] = value;+ const adapter = new SONAAdapter({ mode: 'edge' });+ expect(adapter.getMode()).toBe('edge');+ },+ );++ it('falls back to balanced for an inherited key before and after initialization', async () => {+ process.env[ENV_KEY] = 'constructor';+ const adapter = new SONAAdapter();+ try {+ expect(adapter.getMode()).toBe('balanced');+ await adapter.initialize();+ expect(adapter.getMode()).toBe('balanced');+ } finally {+ await adapter.shutdown();+ }+ });++ it.each([+ { env: undefined, mode: 'balanced', matches: 0 },+ { env: 'research', mode: 'research', matches: 1 },+ { env: 'garbage', mode: 'balanced', matches: 0 },+ { env: 'constructor', mode: 'balanced', matches: 0 },+ { env: 'toString', mode: 'balanced', matches: 0 },+ { env: '__proto__', mode: 'balanced', matches: 0 },+ ])('applies the resolved profile for env=$env', async ({ env, mode, matches }) => {+ if (env === undefined) delete process.env[ENV_KEY];+ else process.env[ENV_KEY] = env;+ const adapter = new SONAAdapter({ similarityThreshold: 0.5 });+ try {+ await adapter.initialize();+ await adapter.storePattern({+ pattern: 'one two three four five six seven eight nine ten',+ solution: 'test solution',+ category: 'test',+ confidence: 0.9,+ });+ // Similarity is 0.6: research accepts it, balanced rejects it.+ // A skipped profile would leave the supplied 0.5 threshold in place.+ const results = await adapter.findSimilarPatterns({ query: 'one two three four five six' });+ expect(results).toHaveLength(matches);+ expect(adapter.getMode()).toBe(mode);+ } finally {+ await adapter.shutdown();+ }});it('reads RUFLO_INTELLIGENCE_MODE freshly on each construction', () => {diff --git a/v3/@claude-flow/integration/src/sona-adapter.ts b/v3/@claude-flow/integration/src/sona-adapter.tsindex cdfc3ea956..5ae97580fa 100644--- a/v3/@claude-flow/integration/src/sona-adapter.ts+++ b/v3/@claude-flow/integration/src/sona-adapter.ts@@ -107,7 +107,7 @@ const MODE_CONFIGS: Record<SONALearningMode, Partial<SONAConfiguration>> = {*/export function sonaModeFromEnv(): SONALearningMode | undefined {const raw = process.env.RUFLO_INTELLIGENCE_MODE?.trim();- return raw && raw in MODE_CONFIGS ? (raw as SONALearningMode) : undefined;+ return raw && Object.hasOwn(MODE_CONFIGS, raw) ? (raw as SONALearningMode) : undefined;}/**