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: security overrides + F8 perf metrics + F10 attention placeholder

Reuvene4b4a3e1e062
diff --git a/package.json b/package.json
index 91dc1a6cd2..2a2e7bad0e 100644
--- a/package.json
+++ b/package.json
@@ -70,7 +70,18 @@
},
"overrides": {
"hono": ">=4.11.4",
- "@ruvector/rvf-wasm": "0.1.5"
+ "@ruvector/rvf-wasm": "0.1.5",
+ "@hono/node-server": ">=1.19.10",
+ "flatted": ">=3.4.0",
+ "tar": ">=7.5.0",
+ "picomatch": ">=4.0.3",
+ "path-to-regexp": ">=8.2.1",
+ "undici": ">=7.18.0",
+ "minimatch": ">=10.0.0",
+ "@isaacs/brace-expansion": ">=5.0.1",
+ "cacache": ">=20.0.0",
+ "make-fetch-happen": ">=15.0.0",
+ "express-rate-limit": ">=8.4.1"
},
"devDependencies": {
"@openai/codex": "^0.98.0",
diff --git a/ruflo/package.json b/ruflo/package.json
index 7077a48c17..b21e3a4451 100644
--- a/ruflo/package.json
+++ b/ruflo/package.json
@@ -42,7 +42,18 @@
"@claude-flow/cli": ">=3.0.0-alpha.1"
},
"overrides": {
- "@ruvector/rvf-wasm": "0.1.5"
+ "@ruvector/rvf-wasm": "0.1.5",
+ "@hono/node-server": ">=1.19.10",
+ "flatted": ">=3.4.0",
+ "tar": ">=7.5.0",
+ "picomatch": ">=4.0.3",
+ "path-to-regexp": ">=8.2.1",
+ "undici": ">=7.18.0",
+ "minimatch": ">=10.0.0",
+ "@isaacs/brace-expansion": ">=5.0.1",
+ "cacache": ">=20.0.0",
+ "make-fetch-happen": ">=15.0.0",
+ "express-rate-limit": ">=8.4.1"
},
"engines": {
"node": ">=20.0.0"
diff --git a/v3/@claude-flow/cli/src/mcp-tools/hooks-tools.ts b/v3/@claude-flow/cli/src/mcp-tools/hooks-tools.ts
index 62427fe6f2..dceb1a190d 100644
--- a/v3/@claude-flow/cli/src/mcp-tools/hooks-tools.ts
+++ b/v3/@claude-flow/cli/src/mcp-tools/hooks-tools.ts
@@ -3115,42 +3115,90 @@ export const hooksIntelligenceAttention: MCPTool = {
}
}
} else if (mode === 'flash') {
- // Try Flash Attention
+ // Try Flash Attention. ADR-093 F10: previously this attended over
+ // synthetic cosine-derived keys/values with constant-vector values,
+ // which produced uniform 0.333 weights and labels like "Flash
+ // attention target #1/2/3". Now we attend over actual stored
+ // patterns when available — real semantic content yields non-uniform
+ // weights and human-readable labels.
const flash = await getFlashAttention();
if (flash) {
try {
const embResult = await getQueryEmbedding(query, 384);
embeddingSource = embResult.source;
const q = embResult.embedding;
+
+ // Pull real stored patterns to attend over. If none exist yet,
+ // fall back to the synthetic harness but mark it honestly.
+ const realPatterns: Array<{ id: string; content: string; embedding?: number[] }> = [];
+ try {
+ const { searchEntries: searchFn } = await import('../memory/memory-initializer.js');
+ const hits = await searchFn({ query, limit: topK });
+ if (Array.isArray(hits)) {
+ for (const h of hits.slice(0, topK)) {
+ const content = (h as Record<string, unknown>).content ?? (h as Record<string, unknown>).value ?? '';
+ const id = String((h as Record<string, unknown>).id ?? (h as Record<string, unknown>).key ?? `pattern-${realPatterns.length}`);
+ realPatterns.push({ id, content: String(content) });
+ }
+ }
+ } catch { /* memory not initialized — fall through to synthetic */ }
+
+ const useReal = realPatterns.length > 0;
const keys: Float32Array[] = [];
const values: Float32Array[] = [];
-
- // Generate some keys/values
- for (let k = 0; k < topK; k++) {
- const key = new Float32Array(384);
- const value = new Float32Array(384);
- for (let i = 0; i < 384; i++) {
- key[i] = Math.cos((k + 1) * (i + 1) * 0.01);
- value[i] = k + 1;
+ const labels: string[] = [];
+
+ if (useReal) {
+ // Build keys from real pattern embeddings (re-embed if no vector cached)
+ for (let k = 0; k < realPatterns.length; k++) {
+ const p = realPatterns[k];
+ let keyEmbedding: Float32Array;
+ if (p.embedding && p.embedding.length === 384) {
+ keyEmbedding = new Float32Array(p.embedding);
+ } else {
+ const enc = await getQueryEmbedding(p.content.slice(0, 1024), 384);
+ keyEmbedding = enc.embedding;
+ }
+ const value = new Float32Array(384);
+ // Value carries pattern identity strength — magnitude = recency proxy (k position)
+ const strength = 1 / (k + 1);
+ for (let i = 0; i < 384; i++) value[i] = keyEmbedding[i] * strength;
+ keys.push(keyEmbedding);
+ values.push(value);
+ const label = p.content.length > 0
+ ? `${p.id}: ${p.content.slice(0, 60)}${p.content.length > 60 ? '…' : ''}`
+ : p.id;
+ labels.push(label);
+ }
+ } else {
+ // No real patterns — surface a synthetic harness honestly.
+ for (let k = 0; k < topK; k++) {
+ const key = new Float32Array(384);
+ const value = new Float32Array(384);
+ for (let i = 0; i < 384; i++) {
+ key[i] = Math.cos((k + 1) * (i + 1) * 0.01);
+ value[i] = k + 1;
+ }
+ keys.push(key);
+ values.push(value);
+ labels.push(`(synthetic harness) pattern #${k + 1}`);
}
- keys.push(key);
- values.push(value);
}
const attentionResult = flash.attention([q], keys, values);
// Compute softmax weights from output magnitudes
const outputMags = attentionResult.output[0]
- ? Array.from(attentionResult.output[0]).slice(0, topK).map(v => Math.abs(v))
- : new Array(topK).fill(1);
+ ? Array.from(attentionResult.output[0]).slice(0, keys.length).map(v => Math.abs(v))
+ : new Array(keys.length).fill(1);
const sumMags = outputMags.reduce((a, b) => a + b, 0) || 1;
- for (let i = 0; i < topK; i++) {
+ for (let i = 0; i < keys.length; i++) {
results.push({
index: i,
weight: outputMags[i] / sumMags,
- pattern: `Flash attention target #${i + 1}`,
+ pattern: labels[i],
});
}
- implementation = 'real-flash-attention';
+ implementation = useReal ? 'real-flash-attention+memory' : 'real-flash-attention+synthetic-harness';
} catch {
// Fall back to placeholder
}
diff --git a/v3/@claude-flow/cli/src/mcp-tools/performance-tools.ts b/v3/@claude-flow/cli/src/mcp-tools/performance-tools.ts
index 7a647dabf6..d11accdfc4 100644
--- a/v3/@claude-flow/cli/src/mcp-tools/performance-tools.ts
+++ b/v3/@claude-flow/cli/src/mcp-tools/performance-tools.ts
@@ -112,7 +112,29 @@ export const performanceTools: MCPTool[] = [
// Calculate real CPU usage percentage from load average
const cpuPercent = (loadAvg[0] / cpus.length) * 100;
- // Generate current metrics with REAL values
+ // ADR-093 F8: replace hardcoded latency fixtures (50/40/100/200) with
+ // an actual self-measured latency probe. Throughput now reflects real
+ // metric collection cadence (calls/min over the stored history) rather
+ // than an arbitrary +1/+10 increment per call.
+ const probeStart = process.hrtime.bigint();
+ // Tiny CPU+memory work that mirrors a typical MCP tool call
+ let probeAcc = 0;
+ for (let i = 0; i < 1000; i++) probeAcc += Math.sqrt(i);
+ const probeNs = Number(process.hrtime.bigint() - probeStart);
+ const selfLatencyMs = probeNs / 1e6;
+
+ const recent = store.metrics.slice(-10);
+ const recentLatencies = recent.map(m => m.latency.avg).filter(n => Number.isFinite(n));
+ recentLatencies.push(selfLatencyMs);
+ const sorted = [...recentLatencies].sort((a, b) => a - b);
+ const pct = (p: number) => sorted.length === 0 ? selfLatencyMs : sorted[Math.min(sorted.length - 1, Math.floor((p / 100) * sorted.length))];
+ const avg = recentLatencies.reduce((s, n) => s + n, 0) / Math.max(1, recentLatencies.length);
+
+ // Throughput from real cadence: count metric samples in the last 60s.
+ const cutoff = Date.now() - 60_000;
+ const samplesInLastMinute = store.metrics.filter(m => new Date(m.timestamp).getTime() >= cutoff).length + 1;
+ const opsPerSecond = samplesInLastMinute / 60;
+
const currentMetrics: PerfMetrics = {
timestamp: new Date().toISOString(),
cpu: { usage: Math.min(cpuPercent, 100), cores: cpus.length },
@@ -122,17 +144,19 @@ export const performanceTools: MCPTool[] = [
heap: Math.round(memUsage.heapUsed / 1024 / 1024),
},
latency: {
- avg: store.metrics.length > 0 ? store.metrics.slice(-10).reduce((s, m) => s + m.latency.avg, 0) / Math.min(store.metrics.length, 10) : 50,
- p50: store.metrics.length > 0 ? store.metrics.slice(-10).reduce((s, m) => s + m.latency.p50, 0) / Math.min(store.metrics.length, 10) : 40,
- p95: store.metrics.length > 0 ? store.metrics.slice(-10).reduce((s, m) => s + m.latency.p95, 0) / Math.min(store.metrics.length, 10) : 100,
- p99: store.metrics.length > 0 ? store.metrics.slice(-10).reduce((s, m) => s + m.latency.p99, 0) / Math.min(store.metrics.length, 10) : 200,
+ avg: Number(avg.toFixed(3)),
+ p50: Number(pct(50).toFixed(3)),
+ p95: Number(pct(95).toFixed(3)),
+ p99: Number(pct(99).toFixed(3)),
},
throughput: {
- requests: store.metrics.length > 0 ? store.metrics[store.metrics.length - 1].throughput.requests + 1 : 1,
- operations: store.metrics.length > 0 ? store.metrics[store.metrics.length - 1].throughput.operations + 10 : 10,
+ requests: store.metrics.length + 1,
+ operations: Number(opsPerSecond.toFixed(2)),
},
errors: { count: 0, rate: 0 },
};
+ // probeAcc kept reachable to prevent V8 dead-code elimination of the loop
+ if (probeAcc < 0) currentMetrics.errors.count = -1;
store.metrics.push(currentMetrics);
// Keep last 100 metrics