mirror of
https://github.com/ruvnet/ruflo.git
synced 2026-11-23 21:59:14 +09:00
* docs(review): empirical capability audit of the intelligence/self-learning system 6 parallel auditors ran real measurements against built dist (not docs). - Self-learning loop is REAL, measured end-to-end (pattern confidence + Q-routing change persist cross-process; MoE gating converges; SONA WASM adapt 0.0042ms; Int8 3.92x; RaBitQ 32x memory — all CONFIRMED). - Performance multipliers largely UNSUBSTANTIATED: HNSW 150x-12,500x measured 1.48x peak; Flash Attention 2.49-7.47x fabricated via Math.random() at runtime; embeddings 75x / RaBitQ 2.70x retrieval never benchmarked. - 1 critical bug: CLI inverts negative reward (route feedback -r -1.0 -> +1.00). - Real-but-inert: WASM MicroLoRA apply(), MCP consolidation gradient (synthetic), hooks_intelligence_learn (cosmetic), CLI trajectory-* (no-op stubs), silent mock-embedding mislabel. No source modified — audit branch only. Prioritized fix list in the report. Co-Authored-By: RuFlo <ruv@ruv.net> * fix+perf(intelligence): harden self-learning system + replace fabricated/unsubstantiated perf numbers with measured ones Implements the prioritized fix list from docs/reviews/intelligence-system-audit-2026-05-29.md. FIXES - CRITICAL (audit #1, #2222 follow-up): CLI inverted negative reward — route feedback -r -1.0 / --reward -1.0 parsed as +1.00, so negative feedback REINFORCED the bad agent. Fixed in src/parser.ts (isFlagValue accepts negative numeric literals). All three syntaxes now yield -1.0; +6 regression assertions; 52/52 parser tests pass. - audit #2: removed fabricated Flash Attention speedup (randomized/midpoint telemetry) in attention-coordinator (swarm + integration) -> unmeasured sentinel + unverified. - audit #3: generateEmbedding returns backend:onnx|mock, surfaced in bridge_status / import_claude so mock embeddings are never mislabeled as real ONNX. - audit #4/#5: trajectory-end no longer feeds EWC a synthetic sine gradient; hooks_intelligence_learn runs a real distill/consolidate cycle. New test added. OPTIMIZE (HNSW, measured): root cause — HNSW never ran (no storagePath -> native DB lock held by daemon -> silent catch{} -> brute force). Fixed vector-db.ts (unique storagePath, hnswConfig m:32/efC:200, visible fallback warning). Same-harness before->after: N=5000 0.92x->3.2-4.7x, N=20000 0.95x->1.89x; N=1000 below crossover (reported honestly); reverted m16/efC64 (recall loss). BENCHMARK: new scripts/benchmark-intelligence.mjs (HNSW N=1k-50k, Int8 3.84x/cos 0.99999, RaBitQ 32x/0.60ms, SONA 0.0043ms, MoE 0.13->0.88, embedding backend). DOCS: README + 3x CLAUDE.md + READMEs perf tables now show MEASURED values or unverified/target; HNSW 150x-12,500x & Flash 2.49-7.47x marked NOT reproduced. Verification: cli build clean (tsc); 161/161 targeted tests pass. Co-Authored-By: RuFlo <ruv@ruv.net> * chore(release): bump 3.10.6 → 3.10.7 (intelligence hardening + honest perf docs) Co-Authored-By: RuFlo <ruv@ruv.net>
@claude-flow/integration
Deep agentic-flow@alpha integration module for Claude Flow V3 - ADR-001 compliance, code deduplication, SONA adapter, and Flash Attention coordinator.
Features
- ADR-001 Compliance - Eliminates 10,000+ duplicate lines by building on agentic-flow
- SONA Adapter - Seamless integration with SONA learning systems
- Flash Attention - 2.49x-7.47x speedup with attention coordination
- SDK Bridge - Version negotiation and API compatibility layer
- Feature Flags - Dynamic feature enabling/disabling
- Runtime Detection - Auto-select optimal runtime (NAPI, WASM, JS)
- Graceful Fallback - Works with or without agentic-flow installed
Installation
npm install @claude-flow/integration
# Optional: Install agentic-flow for optimal performance
npm install agentic-flow@alpha
Quick Start
import { AgenticFlowBridge, createAgenticFlowBridge } from '@claude-flow/integration';
// Create and initialize bridge
const bridge = await createAgenticFlowBridge({
features: {
enableSONA: true,
enableFlashAttention: true,
enableAgentDB: true
}
});
// Check if agentic-flow is connected
if (bridge.isAgenticFlowConnected()) {
console.log('Using optimized agentic-flow implementation');
} else {
console.log('Using local fallback implementation');
}
// Get SONA adapter
const sona = await bridge.getSONAAdapter();
await sona.setMode('balanced');
// Get Attention coordinator
const attention = await bridge.getAttentionCoordinator();
const result = await attention.compute({ query, key, value });
API Reference
AgenticFlowBridge
import { AgenticFlowBridge } from '@claude-flow/integration';
const bridge = new AgenticFlowBridge({
sona: {
mode: 'balanced',
learningRate: 0.001,
similarityThreshold: 0.7
},
attention: {
mechanism: 'flash',
numHeads: 8,
flashOptLevel: 2
},
agentdb: {
dimension: 1536,
indexType: 'hnsw',
metric: 'cosine'
},
features: {
enableSONA: true,
enableFlashAttention: true,
enableAgentDB: true
},
runtimePreference: ['napi', 'wasm', 'js'],
lazyLoad: true,
debug: false
});
await bridge.initialize();
// Component access
const sona = await bridge.getSONAAdapter();
const attention = await bridge.getAttentionCoordinator();
const sdk = await bridge.getSDKBridge();
// Feature management
bridge.isFeatureEnabled('enableSONA');
await bridge.enableFeature('enableFlashAttention');
await bridge.disableFeature('enableAgentDB');
// Health & status
const status = bridge.getStatus();
const health = await bridge.healthCheck();
const flags = bridge.getFeatureFlags();
// Direct agentic-flow access (when available)
const core = bridge.getAgenticFlowCore();
if (core) {
const patterns = await core.sona.findPatterns(query);
}
// Cleanup
await bridge.shutdown();
SONA Adapter
const sona = await bridge.getSONAAdapter();
// Mode management
await sona.setMode('real-time'); // 'real-time' | 'balanced' | 'research' | 'edge' | 'batch'
// Pattern operations
const patternId = await sona.storePattern({
context: 'code-review',
strategy: 'analyze-then-comment',
embedding: vector
});
const patterns = await sona.findPatterns(queryEmbedding, {
limit: 5,
threshold: 0.7
});
// Statistics
const stats = await sona.getStats();
Attention Coordinator
const attention = await bridge.getAttentionCoordinator();
// Set attention mechanism
await attention.setMechanism('flash'); // 'flash' | 'standard' | 'linear'
// Compute attention
const result = await attention.compute({
query: queryTensor,
key: keyTensor,
value: valueTensor,
mask: optionalMask
});
// Get metrics
const metrics = await attention.getMetrics();
// { avgLatencyMs, speedupRatio, memoryUsage }
SDK Bridge
const sdk = await bridge.getSDKBridge();
// Version negotiation
const version = sdk.getVersion();
const isCompatible = sdk.isCompatible('0.1.0');
// Health check
await sdk.ping();
Feature Flags
const flags = bridge.getFeatureFlags();
{
enableSONA: true, // SONA learning integration
enableFlashAttention: true, // Flash Attention optimization
enableAgentDB: true, // AgentDB vector storage
enableTrajectoryTracking: true,// Trajectory recording
enableGNN: true, // Graph Neural Network
enableIntelligenceBridge: true,// Intelligence bridge
enableQUICTransport: false, // QUIC transport (experimental)
enableNightlyLearning: false, // Background learning
enableAutoConsolidation: true // Auto memory consolidation
}
Runtime Detection
The bridge automatically selects the best runtime:
| Runtime | Performance | Requirements |
|---|---|---|
| NAPI | Optimal | Native bindings, non-Windows or x64 |
| WASM | Good | WebAssembly support |
| JS | Fallback | Always available |
const status = bridge.getStatus();
console.log(status.runtime);
// { runtime: 'napi', platform: 'linux', arch: 'x64', performanceTier: 'optimal' }
Event System
bridge.on('initialized', ({ duration, components, agenticFlowConnected }) => {
console.log(`Initialized in ${duration}ms`);
});
bridge.on('agentic-flow:connected', ({ version, features }) => {
console.log(`Connected to agentic-flow ${version}`);
});
bridge.on('agentic-flow:fallback', ({ reason }) => {
console.log(`Using fallback: ${reason}`);
});
bridge.on('feature-enabled', ({ feature }) => {
console.log(`Enabled: ${feature}`);
});
bridge.on('health-check', ({ results }) => {
console.log(`Health: ${JSON.stringify(results)}`);
});
Performance Targets
| Metric | Target |
|---|---|
| Flash Attention speedup | 2.49x-7.47x |
| AgentDB search | 150x-12,500x faster |
| SONA adaptation | <0.05ms |
| Memory reduction | 50-75% |
TypeScript Types
import type {
IntegrationConfig,
IntegrationStatus,
RuntimeInfo,
ComponentHealth,
FeatureFlags,
AgenticFlowCore
} from '@claude-flow/integration';
Peer Dependencies
agentic-flow@^0.1.0(optional, for optimal performance)
Related Packages
- @claude-flow/neural - SONA learning module
- @claude-flow/memory - AgentDB memory
- @claude-flow/performance - Benchmarking
License
MIT