mirror of
https://github.com/ruvnet/ruflo.git
synced 2026-11-23 21:59:14 +09:00
* docs(adr): ADR-111 — federation network mesh via WireGuard Optional in-tree WG mesh layer for the federation plugin. Replaces Tailscale Inc. dependency for the common case (≤50 peers, direct UDP reachable, no NAT traversal needed) while keeping Tailscale as the right answer when its specific value-adds are needed. Key design choices: - OPT-IN via config.wgMesh — existing tailnet+ws path remains default - WG public keys exchanged via existing federation manifests (same Ed25519 trust chain we already ship) - Trust levels (UNTRUSTED → PRIVILEGED) project to packet-layer AllowedIPs slices — no two-system drift between federation trust + network access - Breaker SUSPEND/EVICT instantly removes peer from mesh (Tailscale fundamentally lacks this — compromised tailnet device stays in the network until manual admin action) - Every coordination change witness-signed (Ed25519, append-only) — cryptographic provenance Tailscale's central panel can't offer Anti-goals explicitly documented: - NAT traversal (use Tailscale) - DERP relays (use Tailscale) - MagicDNS, SSO (federation already has identity) - Windows/mobile (v1 = Linux + macOS) 7-phase implementation plan, 14-18 days for v1, 30 with full firewall hardening across linux nftables + macOS pf. Co-Authored-By: RuFlo <ruv@ruv.net> * feat(federation): ADR-111 Phases 1-3 — opt-in WG mesh layer Implements the in-tree WireGuard control plane laid out in v3/docs/adr/ADR-111-federation-wg-mesh.md. Closes the federation-trust ↔ packet-layer-reachability gap: when the breaker SUSPENDs or EVICTs a peer, the same transition propagates to WG AllowedIPs, so a peer the trust layer just blocked can't reach the rest of the mesh at L3 either. OPT-IN (config.wgMesh + integrations.wgMesh) — the default tailnet+ws path remains untouched. No new runtime deps; X25519 keypair generation uses Node's core crypto. ## Phase 1 — Manifest extension + key generation - `domain/value-objects/wg-config.ts` - `WgManifestSection` (publicKey, endpoint, meshIP), `WgLocalKey` - `generateWgKeyPair()` — X25519 via Node `generateKeyPairSync`, extracts raw 32-byte key from PKCS8/SPKI DER → base64 (the WG wire format). - `deriveMeshIP(nodeId, subnet, usedIPs)` — sha256(nodeId) → host octets, clamps .0/.255 to avoid network/broadcast collisions, rotates the hash input on usedIPs hit (bounded 1024-probe retry). - `FederationManifest.wg?` — optional manifest section; Ed25519 sig already covers the block since it's part of `Omit<FM, 'signature'>`. ## Phase 2 — WgMeshService - `domain/services/wg-mesh-service.ts` - `WG_NETWORK_GATES`: trust-level → port-rule table (ADR section). - `buildInterfaceConfig(peers)` — pure-projection wg-quick config string. Operator writes + runs `wg-quick up`; service never shells out per CLAUDE.md destructive-actions guidance. - Breaker hooks: `removeAllowedIPs` (soft-block via empty AllowedIPs), `restoreAllowedIPs` (set-allowed-ips), `removePeer` (terminal). - Defense-in-depth: `formatCmd` regex-validates every arg before splicing — refuses any string with shell metachars. - `summarize()` for the eventual `federation_wg_status` MCP tool (Phase 6). ## Phase 3 — Coordinator/breaker wiring - `FederationCoordinatorIntegrations.wgMesh` + `wgCommandSink`. - `evictPeer()` → after successful evict: `wgMesh.removePeer()` + audit. - `reactivatePeer()` → after successful reactivate: `wgMesh.restoreAllowedIPs()` + audit. - `FederationBreakerService` gains optional `BreakerTransitionListener` 3rd constructor arg — fires post-transition (apply mode only); errors are swallowed so failing WG propagation can't unwind a successful entity transition. Coordinator wires this to drive auto-suspend WG ops. - No-op for peers without `metadata.wgPublicKey` / `metadata.wgMeshIP`, so mixed-deployment safety preserved. ## ADR doc fixes - Status flipped: Proposed → Accepted (Phases 1-3 Implemented). - Phase 4 firewall: inconsistent "Phase 2 add" → "Phase 4 add". - Subnet rationale: documented 10.50.0.0/16 choice vs tailscale's 100.64.0.0/10, birthday-collision thresholds, and the collision-handling probe loop. Also notes 10.50.0.0/12 jump for larger deployments. ## Tests - 33 new unit tests across 3 files; all 513 pre-existing tests still pass. - `wg-config.test.ts` — keygen format/uniqueness, IP determinism, .0/.255 clamping, custom subnets, collision handling, error paths. - `wg-mesh-service.test.ts` — config generation, trust filtering, suspend/restore/evict commands, shell-injection rejection, summarize(). - `wg-coordinator-integration.test.ts` — evictPeer/reactivatePeer emit WG commands; no-op for peers without wg metadata; breaker onTransition listener fires on successful transition. ## Not in this PR (separate phases tracked in #1879) - Phase 4 — trust-graded firewall (nftables/pf projection) - Phase 5 — witness attestation chain for mesh changes - Phase 6 — operator MCP tools (federation_wg_status / _attest / _keyrotate) - Phase 7 — cross-OS validation (mac↔ruvultra), federation alpha bump Co-Authored-By: RuFlo <ruv@ruv.net> --------- Co-authored-by: Reuven <cohen@ruv-mac-mini.local>
Claude Flow V3 - Architecture Decision Records
All ADRs are located in /v3/implementation/adrs/.
Quick Links
| ADR | Title | Status |
|---|---|---|
| ADR-001 | Adopt agentic-flow as Core Foundation | Complete |
| ADR-002 | Domain-Driven Design Structure | Complete |
| ADR-003 | Single Coordination Engine | Complete |
| ADR-004 | Plugin Architecture | Complete |
| ADR-005 | MCP-First API Design | Complete |
| ADR-006 | Unified Memory Service | Complete |
| ADR-007 | Event Sourcing | Complete |
| ADR-008 | Vitest Testing | Complete |
| ADR-009 | Hybrid Memory Backend | Complete |
| ADR-010 | Node.js Only | Complete |
| ADR-011 | LLM Provider System | Complete |
| ADR-012 | MCP Security Features | Complete |
| ADR-013 | Core Security Module | Complete |
| ADR-014 | Workers System | Complete |
| ADR-015 | Unified Plugin System | Complete |
| ADR-016 | Collaborative Issue Claims | Complete |
| ADR-017 | RuVector Integration | Complete |
| ADR-018 | Claude Code Integration | Complete |
| ADR-019 | Headless Runtime Package | Complete |
| ADR-020 | Headless Worker Integration | Complete |
| ADR-046 | Dual Umbrella: claude-flow + ruflo | Accepted |
| ADR-047 | Fast Mode Integration | Proposed |
Summary Documents
- ADR Status Summary - Implementation status overview
- V3 ADRs Master - Complete ADR document
- Full README - Detailed index with roadmap
Performance Targets
| Metric | Target | Status |
|---|---|---|
| HNSW Search | 150x-12,500x faster | ✅ Achieved |
| Flash Attention | 2.49x-7.47x speedup | ✅ Achieved (alpha.102) |
| Memory Reduction | 50-75% | ✅ Achieved |
| MCP Response | <100ms | ✅ Achieved |
| CLI Startup | <500ms | ✅ Achieved |
Neural Features (alpha.102+)
| Component | Status | Lines | Notes |
|---|---|---|---|
| SONA Optimizer | ✅ Real | 841 | Pattern learning from trajectories |
| EWC++ Consolidation | ✅ Real | ~600 | Fisher matrix, prevents forgetting |
| MoE Router | ✅ Real | ~500 | 8 experts with gating network |
| Flash Attention | ✅ Real | ~500 | O(N) block attention |
| LoRA Adapter | ✅ Real | ~400 | 128x compression (rank=8) |
| Hyperbolic Embeddings | ✅ Real | - | Poincaré ball model |
| Int8 Quantization | ✅ Real | - | 3.92x memory savings |
Security Status
| CVE | Severity | Status |
|---|---|---|
| CVE-2 | Critical | ✅ Fixed |
| CVE-3 | Critical | ✅ Fixed |
| HIGH-1 | High | ✅ Fixed |
| HIGH-2 | High | ✅ Fixed |
Security Score: 10/10
Last Updated: 2026-01-14 CLI Version: @claude-flow/cli@3.0.0-alpha.104