ruvnet/ruflo · error
SONA adaptation failed: ${error}
Error message
SONA adaptation failed: ${error} What it means
Thrown by the SONA query-adaptation path in @claude-flow/neural: the whole adaptQuery body (query transform, pattern retrieval, route inference, confidence scoring) is wrapped in one try/catch, and any lower-level failure is re-thrown as this umbrella error with the original message appended after the colon. The prefix is only an annotation; the suffix is the real cause. The adaptation-time metric is only recorded on success, so this throw also means no timing was captured.
Source
Thrown at v3/@claude-flow/neural/src/sona-integration.ts:237
const patterns = this.engine.findPatterns(
Array.from(context.queryEmbedding),
5
);
// Determine suggested route from patterns
const suggestedRoute = this.inferRoute(patterns, context);
const confidence = patterns.length > 0 ? patterns[0].avgQuality : 0.5;
this.adaptationTimeMs = performance.now() - startTime;
return {
transformedQuery: new Float32Array(transformedQuery),
patterns,
suggestedRoute,
confidence,
};
} catch (error) {
throw new Error(`SONA adaptation failed: ${error}`);
}
}
/**
* Get last adaptation time
*
* @returns Adaptation time in milliseconds
*/
getAdaptationTime(): number {
return this.adaptationTimeMs;
}
/**
* Get last learning time
*
* @returns Learning time in milliseconds
*/
getLearningTime(): number {View on GitHub (pinned to fa13ee4ad6)
Solutions
- Read the text after 'SONA adaptation failed:' — it names the actual failing operation; debug that, not the wrapper
- Ensure initialization (pattern store load, mode implementation) has completed before the first adaptQuery call
- Validate the query up front: finite values, expected dimensionality, Float32Array
- If the inner error indicates corrupted state, rebuild patterns from trajectories or re-serialize with the current package version
- Reproduce with logging around the transform/pattern-retrieval steps to pinpoint the throw site
Example fix
// before
const r = await sona.adaptQuery(anyOldVector, ctx);
// after
if (!(query instanceof Float32Array) || !query.every(Number.isFinite)) {
throw new TypeError('query must be a finite Float32Array');
}
try {
const r = await sona.adaptQuery(query, ctx);
} catch (e) {
throw new Error(String(e).replace('SONA adaptation failed: ', ''), { cause: e });
} Defensive patterns
Strategy: try-catch
Validate before calling
// validate the query before adaptation
const ok =
query instanceof Float32Array &&
query.length > 0 &&
query.every(Number.isFinite);
if (!ok) throw new TypeError('query must be a non-empty finite Float32Array');
const r = await sona.adaptQuery(query, ctx); Type guard
function isFiniteVector(v: unknown): v is Float32Array {
return v instanceof Float32Array && v.every(Number.isFinite);
} Try / catch
try {
const r = await sona.adaptQuery(query, ctx);
} catch (e) {
const msg = e instanceof Error ? e.message : String(e);
if (msg.startsWith('SONA adaptation failed:')) {
// the suffix is the real cause — surface it, keep the original as cause
throw new Error(msg.slice('SONA adaptation failed:'.length).trim(), { cause: e });
}
throw e;
} Prevention
- Complete initialization and pattern-store loading before the first adaptQuery call
- Validate vector type, length, and finiteness at the call boundary
- Keep persisted SONA state on the same package version as the code using it
- Log the unwrapped inner message, not just the SONA prefix, when it throws
When it happens
Trigger: Any exception raised inside the try block: calling adaptQuery before the integration/pattern store is initialized, passing a query vector with non-finite values or wrong dimensionality, corrupted or version-skewed persisted patterns making transformQuery or pattern retrieval throw, or inferRoute failing on inconsistent mode/EWC state.
Common situations: Reusing a SonaIntegration instance after the underlying neural store was closed or reloaded mid-flight; loading SONA state written by a different package version so internal shape checks fail; passing Float64Array or a plain array where a Float32Array is expected; concurrent close() during an in-flight adaptation.
Related errors
- SONA learning failed: ${error}
- Failed to execute MCP tool '${toolName}': ${error instanceof
- Unknown algorithm: ${algorithm}
- FlashAttention: Empty input arrays
- FlashAttention: Keys and values must have same count. Got ${
AI-assisted analysis of ruvnet/ruflo@fa13ee4ad6 (2026-08-18).
Data as JSON: /api/errors/fec338389ff2a950.
Report an issue: GitHub.