fix(intelligence): make Flash Attention + ruvllm coordinator stats truthful (#1770) (#1771)

Fix 1: neural_status.flashAttention was hardcoded false (neural-tools.ts:699).
Now probes ../ruvector/flash-attention.js loader so it agrees with
hooks_intelligence_stats on a single source of truth.

Fix 2: ruvllm SonaCoordinator reported unavailable despite @ruvector/ruvllm
being resolvable. Root cause: getIntelligenceStats() read ruvllmCoordinator
synchronously but it was populated only by an async init path the MCP
dashboard never awaits. Fix: lazy-init on stats query via sync createRequire,
gated on ruvllmLoaded. Cost: 7.7ms first call, 0.24us steady-state.

Also: CLAUDE_FLOW_DEBUG-gated log at the catch site so future regressions
of this shape do not disappear silently.

Verified: neural_status.features.flashAttention=true (was false);
hooks_intelligence_stats.ruvllm.coordinator=active (was unavailable);
769 cli tests pass.

Bumps all three packages to 3.7.0-alpha.4. Closes #1770

Co-authored-by: Reuven <cohen@ruv-mac-mini.local>
This commit is contained in:
rUvandReuven authored and GitHub committed 2026-05-05 22:05:38 -04:00
1 parent 55ae6ca57b
commit a7122a50e3
5 files changed
+44 -7

No files matched your search

+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "claude-flow",
"version": "3.7.0-alpha.3",
"version": "3.7.0-alpha.4",
"description": "Ruflo - Enterprise AI agent orchestration for Claude Code. Deploy 60+ specialized agents in coordinated swarms with self-learning, fault-tolerant consensus, vector memory, and MCP integration",
"main": "dist/index.js",
"type": "module",
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "ruflo",
"version": "3.7.0-alpha.3",
"version": "3.7.0-alpha.4",
"description": "Ruflo - Enterprise AI agent orchestration platform. Deploy 60+ specialized agents in coordinated swarms with self-learning, fault-tolerant consensus, vector memory, and MCP integration",
"main": "bin/ruflo.js",
"type": "module",
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "@claude-flow/cli",
"version": "3.7.0-alpha.3",
"version": "3.7.0-alpha.4",
"type": "module",
"description": "Ruflo CLI - Enterprise AI agent orchestration with 60+ specialized agents, swarm coordination, MCP server, self-learning hooks, and vector memory for Claude Code",
"main": "dist/src/index.js",
@@ -696,7 +696,18 @@ export const neuralTools: MCPTool[] = [
features: {
hnsw: true,
quantization: true,
flashAttention: false,
// #1770: probe the real loader instead of returning a literal false.
// Was hardcoded false, which contradicted hooks_intelligence_stats's
// simultaneous claim of `implementation: real-flash-attention`.
// The two surfaces now agree on a single source of truth.
flashAttention: await (async () => {
try {
const { getFlashAttention } = await import('../ruvector/flash-attention.js');
return getFlashAttention() !== null;
} catch {
return false;
}
})(),
reasoningBank: true,
},
};
+29 -3
View File
@@ -13,6 +13,7 @@
import { existsSync, mkdirSync, readFileSync, writeFileSync } from 'node:fs';
import { homedir } from 'node:os';
import { createRequire } from 'node:module';
import { dirname, join } from 'node:path';
// ============================================================================
@@ -717,20 +718,37 @@ class LocalReasoningBank {
let ruvllmCoordinator: any = null;
let ruvllmLoaded = false;
async function loadRuvllmCoordinator(): Promise<any> {
/**
* Synchronously load the @ruvector/ruvllm SonaCoordinator. Used both by the
* async init path (initializeIntelligence) and by sync stat readers like
* getIntelligenceStats — the dashboard would otherwise report "unavailable"
* when stats are queried before any async init has fired (#1770).
*/
function loadRuvllmCoordinatorSync(): any {
if (ruvllmLoaded) return ruvllmCoordinator;
ruvllmLoaded = true;
try {
const { createRequire } = await import('module');
const requireCjs = createRequire(import.meta.url);
const ruvllm = requireCjs('@ruvector/ruvllm');
ruvllmCoordinator = new ruvllm.SonaCoordinator(ruvllm.DEFAULT_SONA_CONFIG);
return ruvllmCoordinator;
} catch {
} catch (err) {
// Surface the reason on debug builds so future regressions of #1770 don't
// disappear silently. Stays quiet by default to avoid noise on the cli's
// hot path (e.g., npx invocations).
if (process.env.CLAUDE_FLOW_DEBUG) {
// eslint-disable-next-line no-console
console.error('[ruvllm] SonaCoordinator load failed, falling back to JS:', (err as Error).message);
}
ruvllmCoordinator = null;
return null;
}
}
async function loadRuvllmCoordinator(): Promise<any> {
return loadRuvllmCoordinatorSync();
}
// ============================================================================
// Module State
// ============================================================================
@@ -1078,6 +1096,14 @@ export function getIntelligenceStats(): IntelligenceStats & {
const sonaStats = sonaCoordinator?.stats();
const bankStats = reasoningBank?.stats();
// Lazy-init the ruvllm coordinator if it hasn't been loaded yet. The MCP
// dashboard (`hooks_intelligence_stats`) hits this path before any
// initializeIntelligence() call has fired, so the coordinator field would
// otherwise stay null and the dashboard would report "unavailable" even
// when @ruvector/ruvllm is fully resolvable. Sync require — cheap, idempotent.
if (!ruvllmLoaded) {
loadRuvllmCoordinatorSync();
}
const ruvllmStats = ruvllmCoordinator?.stats?.() || null;
// Fetch cross-module stats for unified reporting