* feat(neural): persistence + seedable PRNG + round-trip tests (#1773 items 1, 3, 6)
Three of the six "what is missing from @claude-flow/neural" items, in
the smallest cohesive unit:
Item 3 (RNG): src/utils/rng.ts — Mulberry32 PRNG, RNG interface,
setGlobalRng/random/randomInt/randomNormal injection points. Math.random
callers can be migrated incrementally; the package default stays
non-deterministic via MathRandomRng for backward compatibility.
Item 1 (persistence): SONAManager, ReasoningBank, PatternLearner each
gain serialize() and deserialize() methods. Float32Array embeddings,
Map<string,X>, and nested structures encode losslessly via
src/utils/serialize.ts (deepEncode/deepDecode). schemaVersion guards
forward-compatibility. Event listeners are NOT persisted (re-register
manually after restore); AgentDB connection is NOT persisted (call
initialize() to re-acquire).
Item 6 (round-trip tests): __tests__/persistence.test.ts — 15 tests
covering Mulberry32 determinism, RNG injection contract, encode/decode
helpers, and serialize/deserialize round-trip for ReasoningBank +
PatternLearner. SONAManager round-trip test deferred — a pre-existing
load-order bug in src/modes/balanced.ts (extends BaseModeImplementation
with undefined parent) blocks instantiating SONAManager from a fresh
vitest context. The serialize/deserialize methods on SONAManager
themselves are correct (build clean) and run fine in production.
Also: removed stale src/*.js and src/*.d.ts files committed from a
prior build (April 6). They were shadowing the .ts source under vitest
(`a.serialize is not a function`) and only the dist/ outputs are
canonical.
Validation:
- npm run build clean (tsc, no errors)
- 121 tests pass: 15 new persistence + 44 algorithms + 39 patterns + 23 sona
- Direct node import of dist/reasoning-bank.js confirms .serialize/.deserialize
are present on the instance
Items 2 (HNSW), 4 (move flash-attention/moe-router from cli), and 5
(self-consistency orchestrator) remain — landing in subsequent fires.
Refs #1773.
Co-Authored-By: RuFlo <ruv@ruv.net>
* feat(neural): selfConsistency(N) orchestrator (#1773 item 5)
Wang et al. 2022 self-consistency primitive — runs an arbitrary stochastic
operation N times and aggregates. On reasoning benchmarks the technique
typically buys 5-15pp accuracy at the cost of Nx compute. The packages
RL algorithms, pattern matching, and routing all sample randomly and
benefit from variance reduction without retraining.
src/utils/self-consistency.ts: selfConsistency(operation, {N, aggregator}).
Three aggregators:
- majority: pick the most common output (JSON-canonical grouping)
- mean: numeric average with stddev-based agreement
- first: take sample[0]; useful for tests / deterministic ops
Pairs with #1773 item 3 (Mulberry32 seedable PRNG): set the global RNG
before a self-consistency run and the result is reproducible across
machines.
Tests: 9 cases in __tests__/self-consistency.test.ts.
- Deterministic op -> agreement = 1
- Bimodal noise + seeded RNG -> majority picks the more common branch
- Mean aggregator on numeric samples + non-number rejection
- first aggregator
- N <= 0 / non-integer rejection
- Reproducible across runs with same seed
- Object grouping by canonical JSON
- Config preserved on result
Validation: all 130 neural tests pass (added 9 self-consistency).
Build clean.
Items remaining for #1773 substrate work:
- Item 2: ReasoningBank HNSW (brute-force -> AgentDB-backed retrieval)
- Item 4: Move flash-attention.ts + moe-router.ts from cli into package
Refs #1773.
Co-Authored-By: RuFlo <ruv@ruv.net>
* feat(neural): retrieval-path observability for HNSW vs brute-force (#1773 item 2)
The README claims AgentDB HNSW gives 150x retrieval speedup, but neither
ReasoningBank nor PatternLearner exposes which path is actually firing.
Result: callers cant tell if theyre silently getting O(n) brute-force
when AgentDB failed to load.
Fix: expose retrieval-path counters in getStats().
ReasoningBank.getStats() now reports:
- hnswRetrievalCount: number of retrieves that took the HNSW path
- bruteForceRetrievalCount: number that fell back to cosine-similarity loop
- agentdbEnabled: 1 if AgentDB is loaded, 0 otherwise (already existed)
The retrieve() method tracks which path actually returned candidates and
increments the appropriate counter. AgentDB import failures and empty
results both flow to brute-force; the counter reflects reality.
PatternLearner.getStats() honestly reports:
- hnswEnabled: 0 (no HNSW integration yet — separate follow-up needed)
- bruteForceMatches: count of findMatches calls
PatternLearner.findMatches always takes the brute-force/clustering path;
wiring AgentDB into it is item 2-followup tracked separately. Surfacing
the lie ("we use HNSW") as a number ("hnswEnabled: 0") is the honest
intermediate step.
Tests: 2 new cases in persistence.test.ts verifying counter shape +
PatternLearner honest hnswEnabled=0.
Validation: 132 neural tests pass (added 2 for observability).
Build clean.
5 of 6 #1773 substrate items shipped:
✅ Item 1: Persistence
✅ Item 2: Retrieval-path observability (this commit)
✅ Item 3: Seedable RNG
⏸️ Item 4: Move flash-attention + moe-router from cli (cross-package, queued)
✅ Item 5: selfConsistency orchestrator
✅ Item 6: Round-trip tests
Refs #1773.
Co-Authored-By: RuFlo <ruv@ruv.net>
* feat(neural): migrate flash-attention + moe-router from cli + SEO keywords (#1773 item 4)
Closes the parallel-implementation gap that motivated #1773. The neural
package now owns the production-grade pieces; cli imports them via the
package boundary instead of maintaining local copies.
Files moved (1,679 LOC total):
cli/src/ruvector/flash-attention.ts 857 LOC -> v3/@claude-flow/neural/src/flash-attention.ts
cli/src/ruvector/moe-router.ts 822 LOC -> v3/@claude-flow/neural/src/moe-router.ts
Both files were self-contained (zero external imports for flash-attention,
only node:fs/path for moe-router) so the migration was mechanical: copy,
add to neural index.ts, redirect imports, delete originals.
Cli updates:
- hooks-tools.ts: 3 dynamic imports redirected to "@claude-flow/neural"
- neural-tools.ts: 1 dynamic import redirected
- ruvector/index.ts: re-exports REMOVED (would force vitest to resolve
neural pkgs transitive @ruvector/sona dep eagerly and break tests).
Direct consumers import from @claude-flow/neural; theres no consumer
that needed the barrel re-export.
- cli/src/ruvector/flash-attention.ts and moe-router.ts: deleted
Neural package SEO: package.json gets a comprehensive keywords array
(80+ tags covering ai-agents, multi-agent, RL, PPO/DQN/A2C/SARSA/QLearning/
DecisionTransformer/Curiosity, LoRA, EWC, FlashAttention, MoE, SONA,
self-consistency, agentdb, hnsw, MCP, etc.) plus full author/repo/bugs/
homepage metadata. Description rewritten to reflect actual surface
instead of the old "Neural module - SONA learning integration, neural modes"
stub.
Validation:
- Both packages build clean (tsc, no errors)
- 781 cli tests pass: 769 baseline + 6 bandit + 6 bridge
- 132 neural tests pass: 44 algorithms + 39 patterns + 23 sona + 15 persistence + 9 self-consistency + 2 retrieval-path observability
Bumps:
@claude-flow/neural 3.0.0-alpha.7 -> 3.0.0-alpha.8 (substantial -- new files, new keywords, new exports)
@claude-flow/cli 3.7.0-alpha.6 -> 3.7.0-alpha.7 (now depends on neural@^3.0.0-alpha.8)
claude-flow 3.7.0-alpha.6 -> 3.7.0-alpha.7
ruflo 3.7.0-alpha.6 -> 3.7.0-alpha.7
ALL SIX #1773 substrate-upgrade items now complete:
Item 1: Persistence on the 3 classes DONE
Item 2: Retrieval-path observability DONE
Item 3: Seedable RNG DONE
Item 4: Flash + MoE migration (this commit) DONE
Item 5: selfConsistency orchestrator DONE
Item 6: Round-trip tests DONE
Refs #1773.
Co-Authored-By: RuFlo <ruv@ruv.net>
* feat(neural): finalize item 4 — neural pkg flash-attention + moe-router files + SEO keywords + cli-side wiring + version bumps
Companion to e94981db7 which deleted the cli copies but didnt include
the neural pkg new files / cli redirects / version bumps.
This commit completes #1773 item 4:
- v3/@claude-flow/neural/src/flash-attention.ts (857 LOC, copied + exported)
- v3/@claude-flow/neural/src/moe-router.ts (822 LOC, copied + exported)
- v3/@claude-flow/neural/src/index.ts (export new modules)
- v3/@claude-flow/neural/package.json (SEO keywords + version bump)
- v3/@claude-flow/cli/src/mcp-tools/{neural-tools,hooks-tools}.ts redirected
- v3/@claude-flow/cli/src/ruvector/index.ts (removed barrel re-export)
- v3/@claude-flow/cli/package.json + claude-flow + ruflo version bumps
All 6 substrate items shipped. 781 cli + 132 neural tests pass.
Published 4 packages (@claude-flow/neural@3.0.0-alpha.8 + cli/claude-flow/ruflo@3.7.0-alpha.7).
Co-Authored-By: RuFlo <ruv@ruv.net>
* chore(cli): regenerate pnpm-lock.yaml for @claude-flow/neural@^3.0.0-alpha.8 (#1773)
Same drift class as #1774. The neural pkg version bump in cli/package.json
(alpha.7 -> alpha.8) needs the lockfile updated. CI uses --frozen-lockfile.
Co-Authored-By: RuFlo <ruv@ruv.net>
---------
Co-authored-by: Reuven <cohen@ruv-mac-mini.local>
Orchestrate 100+ specialized AI agents across machines, teams, and trust boundaries. Ruflo adds coordinated swarms, self-learning memory, federated comms, and enterprise security to Claude Code — so agents don't just run, they collaborate.
Why Ruflo?
Claude Flow is now Ruflo — named by Ruv, who loves Rust, flow states, and building things that feel inevitable. The "Ru" is the Ruv. The "flo" is the flow. Underneath, WASM kernels written in Rust power the policy engine, embeddings, and proof system.
What Ruflo Does
One init gives Claude Code a nervous system: agents self-organize into swarms, learn from every task, remember across sessions, and — with federation — securely talk to agents on other machines without leaking data. You keep writing code. Ruflo handles the coordination.
Self-Learning / Self-Optimizing Agent Architecture
User --> Ruflo (CLI/MCP) --> Router --> Swarm --> Agents --> Memory --> LLM Providers
^ |
+---- Learning Loop <-------+
New to Ruflo? You don't need to learn 314 MCP tools or 26 CLI commands. After
init, just use Claude Code normally -- the hooks system automatically routes tasks, learns from successful patterns, and coordinates agents in the background.
Quick Start
Claude Code Plugin (Recommended)
Install Ruflo as a native Claude Code plugin -- adds skills, commands, agents, and MCP tools directly:
# Add the marketplace
/plugin marketplace add ruvnet/ruflo
# Install core + any plugins you need
/plugin install ruflo-core@ruflo
/plugin install ruflo-swarm@ruflo
/plugin install ruflo-autopilot@ruflo
/plugin install ruflo-federation@ruflo
All 32 plugins
Core & Orchestration
| Plugin | What it does |
|---|---|
| ruflo-core | Foundation — server, health checks, plugin discovery |
| ruflo-swarm | Coordinate multiple agents as a team |
| ruflo-autopilot | Let agents run autonomously in a loop |
| ruflo-loop-workers | Schedule background tasks on a timer |
| ruflo-workflows | Reusable multi-step task templates |
| ruflo-federation | Agents on different machines collaborate securely |
Memory & Knowledge
| Plugin | What it does |
|---|---|
| ruflo-agentdb | Fast vector database for agent memory |
| ruflo-rag-memory | Smart retrieval — hybrid search, graph hops, diversity ranking |
| ruflo-rvf | Save and restore agent memory across sessions |
| ruflo-ruvector | ruvector — GPU-accelerated search, Graph RAG, 103 tools |
| ruflo-knowledge-graph | Build and traverse entity relationship maps |
Intelligence & Learning
| Plugin | What it does |
|---|---|
| ruflo-intelligence | Agents learn from past successes and get smarter |
| ruflo-daa | Dynamic agent behavior and cognitive patterns |
| ruflo-ruvllm | Run local LLMs (Ollama, etc.) with smart routing |
| ruflo-goals | Break big goals into plans and track progress |
Code Quality & Testing
| Plugin | What it does |
|---|---|
| ruflo-testgen | Find missing tests and generate them automatically |
| ruflo-browser | Automate browser testing with Playwright |
| ruflo-jujutsu | Analyze git diffs, score risk, suggest reviewers |
| ruflo-docs | Generate and maintain documentation automatically |
Security & Compliance
| Plugin | What it does |
|---|---|
| ruflo-security-audit | Scan for vulnerabilities and CVEs |
| ruflo-aidefence | Block prompt injection, detect PII, safety scanning |
Architecture & Methodology
| Plugin | What it does |
|---|---|
| ruflo-adr | Track architecture decisions with a living record |
| ruflo-ddd | Scaffold domain-driven design — contexts, aggregates, events |
| ruflo-sparc | Guided 5-phase development methodology with quality gates |
DevOps & Observability
| Plugin | What it does |
|---|---|
| ruflo-migrations | Manage database schema changes safely |
| ruflo-observability | Structured logs, traces, and metrics in one place |
| ruflo-cost-tracker | Track token usage, set budgets, get cost alerts |
Extensibility
| Plugin | What it does |
|---|---|
| ruflo-wasm | Run sandboxed WebAssembly agents |
| ruflo-plugin-creator | Scaffold, validate, and publish your own plugins |
Domain-Specific
| Plugin | What it does |
|---|---|
| ruflo-iot-cognitum | IoT device management — trust scoring, anomaly detection, fleets |
| ruflo-neural-trader | neural-trader — AI trading with 4 agents, backtesting, 112+ tools |
| ruflo-market-data | Ingest market data, vectorize OHLCV, detect patterns |
CLI Install
# One-line install
curl -fsSL https://cdn.jsdelivr.net/gh/ruvnet/ruflo@main/scripts/install.sh | bash
# Or via npx
npx ruflo@latest init --wizard
# Or install globally
npm install -g ruflo@latest
MCP Server
# Add Ruflo as an MCP server in Claude Code
claude mcp add ruflo -- npx -y @claude-flow/cli@latest
What You Get
| Capability | Description |
|---|---|
| 🤖 100+ Agents | Specialized agents for coding, testing, security, docs, architecture |
| 📡 Comms Layer | Zero-trust federation — agents across machines/orgs discover, authenticate, and exchange work securely |
| 🐝 Swarm Coordination | Hierarchical, mesh, and adaptive topologies with consensus |
| 🧠 Self-Learning | SONA neural patterns, ReasoningBank, trajectory learning |
| 💾 Vector Memory | HNSW-indexed AgentDB with 150x-12,500x faster search |
| ⚡ Background Workers | 12 auto-triggered workers (audit, optimize, testgaps, etc.) |
| 🧩 Plugin Marketplace | 32 native Claude Code plugins + 21 npm plugins |
| 🔌 Multi-Provider | Claude, GPT, Gemini, Cohere, Ollama with smart routing |
| 🛡️ Security | AIDefence, input validation, CVE remediation, path traversal prevention |
| 🌐 Agent Federation | Cross-installation agent collaboration with zero-trust security |
Agent Federation — Slack for Agents
Your Agent --> [ Remove secrets ] --> [ Sign message ] --> [ Encrypted channel ]
Emails, SSNs, Proves it came No one reads it
keys stripped from you in transit
|
v
Their Agent <-- [ Block attacks ] <-- [ Check identity ] <------+
Stops prompt Rejects forgeries
injection
Audit trail on both sides.
Trust builds over time. Bad behavior = instant downgrade.
Slack gave teams channels. Federation gives agents the same thing — shared workspaces across trust boundaries, where agents on different machines, orgs, or cloud regions can discover each other, prove who they are, and collaborate on tasks.
The difference: some channels are trusted, some aren't. @claude-flow/plugin-agent-federation handles that automatically. Your agents join a federation, get verified via mTLS + ed25519, and start exchanging work — with PII stripped before anything leaves your node and every message auditable. Untrusted agents can still participate at lower privilege: they see discovery info, not your memory. As they prove reliable, trust upgrades. If they misbehave, they get downgraded instantly — no human in the loop required.
You don't configure handshakes or manage certificates. You federation init, federation join, and your agents start talking. The protocol handles identity, the PII pipeline handles data safety, and the audit trail handles compliance.
Federation capabilities
| Capability | How it works | |
|---|---|---|
| 🔒 | Zero-trust federation | Remote agents start untrusted. Identity proven via mTLS + ed25519 challenge-response. No API keys, no shared secrets. |
| 🛡️ | PII-gated data flow | 14-type detection pipeline scans every outbound message. Per-trust-level policies: BLOCK, REDACT, HASH, or PASS. Adaptive calibration reduces false positives. |
| 📊 | Behavioral trust scoring | Formula (0.4×success + 0.2×uptime + 0.2×threat + 0.2×integrity) continuously evaluates peers. Upgrades require history; downgrades are instant. |
| 📋 | Compliance built-in | HIPAA, SOC2, GDPR audit trails as compliance modes. Every federation event produces a structured record searchable via HNSW. |
| 🤝 | 9 MCP tools + 10 CLI commands | Full lifecycle: federation_init, federation_send, federation_trust, federation_audit, and more. |
Example: two teams sharing fraud signals without sharing customer data
# Team A: initialize federation and generate keypair
npx claude-flow@latest federation init
# Team A: join Team B's federation endpoint
npx claude-flow@latest federation join wss://team-b.example.com:8443
# Team A: send a task — PII is stripped automatically before it leaves
npx claude-flow@latest federation send --to team-b --type task-request \
--message "Analyze transaction patterns for account anomalies"
# Team A: check peer trust levels and session health
npx claude-flow@latest federation status
See issue #1669 for the complete architecture, trust model, and implementation roadmap.
# Claude Code plugin
/plugin install ruflo-federation@ruflo
# Or via CLI
npx claude-flow@latest plugins install @claude-flow/plugin-agent-federation
Claude Code: With vs Without Ruflo
| Capability | Claude Code Alone | + Ruflo |
|---|---|---|
| Agent Collaboration | Isolated, no shared context | Swarms with shared memory and consensus |
| Coordination | Manual orchestration | Queen-led hierarchy (Raft, Byzantine, Gossip) |
| Memory | Session-only | HNSW vector memory with sub-ms retrieval |
| Learning | Static behavior | SONA self-learning with pattern matching |
| Task Routing | You decide | Intelligent routing (89% accuracy) |
| Background Workers | None | 12 auto-triggered workers |
| LLM Providers | Anthropic only | 5 providers with failover |
| Security | Standard | CVE-hardened with AIDefence |
Architecture overview
User --> Claude Code / CLI
|
v
Orchestration Layer
(MCP Server, Router, 27 Hooks)
|
v
Swarm Coordination
(Queen, Topology, Consensus)
|
v
100+ Specialized Agents
(coder, tester, reviewer, architect, security...)
|
v
Memory & Learning
(AgentDB, HNSW, SONA, ReasoningBank)
|
v
LLM Providers
(Claude, GPT, Gemini, Cohere, Ollama)
Documentation
Full documentation including architecture, configuration, CLI reference, API usage, plugin development, and advanced topics:
User Guide -- Complete reference documentation
| Section | Topics |
|---|---|
| Quick Start | Installation, prerequisites, install profiles |
| Core Features | MCP tools, agents, memory, neural learning |
| Intelligence & Learning | Hooks, workers, SONA, model routing |
| Swarm & Coordination | Topologies, consensus, hive mind |
| Security | AIDefence, CVE remediation, validation |
| Ecosystem | RuVector, agentic-flow, Flow Nexus |
| Configuration | Environment variables, config schema |
| Plugin Marketplace | Browse and install plugins |
Support
| Resource | Link |
|---|---|
| Documentation | User Guide |
| Issues & Bugs | GitHub Issues |
| Enterprise | ruv.io |
| Community | Agentics Foundation Discord |
| Powered by | Cognitum.one |
License
MIT - RuvNet
