|
| 1 | +# ADR-002: RuVector RVF Integration Strategy |
| 2 | + |
| 3 | +## Status |
| 4 | +Proposed |
| 5 | + |
| 6 | +## Date |
| 7 | +2026-02-28 |
| 8 | + |
| 9 | +## Context |
| 10 | + |
| 11 | +### Current System Limitations |
| 12 | + |
| 13 | +The WiFi-DensePose system processes Channel State Information (CSI) from WiFi signals to estimate human body poses. The current architecture (Python v1 + Rust port) has several areas where intelligence and performance could be significantly improved: |
| 14 | + |
| 15 | +1. **No persistent vector storage**: CSI feature vectors are processed transiently. Historical patterns, fingerprints, and learned representations are not persisted in a searchable vector database. |
| 16 | + |
| 17 | +2. **Static inference models**: The modality translation network (`ModalityTranslationNetwork`) and DensePose head use fixed weights loaded at startup. There is no online learning, adaptation, or self-optimization. |
| 18 | + |
| 19 | +3. **Naive pattern matching**: Human detection in `CSIProcessor` uses simple threshold-based confidence scoring (`amplitude_indicator`, `phase_indicator`, `motion_indicator` with fixed weights 0.4, 0.3, 0.3). No similarity search against known patterns. |
| 20 | + |
| 21 | +4. **No cryptographic audit trail**: Life-critical disaster detection (wifi-densepose-mat) lacks tamper-evident logging for survivor detections and triage classifications. |
| 22 | + |
| 23 | +5. **Limited edge deployment**: The WASM crate (`wifi-densepose-wasm`) provides basic bindings but lacks a self-contained runtime capable of offline operation with embedded models. |
| 24 | + |
| 25 | +6. **Single-node architecture**: Multi-AP deployments for disaster scenarios require distributed coordination, but no consensus mechanism exists for cross-node state management. |
| 26 | + |
| 27 | +### RuVector Capabilities |
| 28 | + |
| 29 | +RuVector (github.com/ruvnet/ruvector) provides a comprehensive cognitive computing platform: |
| 30 | + |
| 31 | +- **RVF (Cognitive Containers)**: Self-contained files with 25 segment types (VEC, INDEX, KERNEL, EBPF, WASM, COW_MAP, WITNESS, CRYPTO) that package vectors, models, and runtime into a single deployable artifact |
| 32 | +- **HNSW Vector Search**: Hierarchical Navigable Small World indexing with SIMD acceleration and Hyperbolic extensions for hierarchy-aware search |
| 33 | +- **SONA**: Self-Optimizing Neural Architecture providing <1ms adaptation via LoRA fine-tuning with EWC++ memory preservation |
| 34 | +- **GNN Learning Layer**: Graph Neural Networks that learn from every query through message passing, attention weighting, and representation updates |
| 35 | +- **46 Attention Mechanisms**: Including Flash Attention, Linear Attention, Graph Attention, Hyperbolic Attention, Mincut-gated Attention |
| 36 | +- **Post-Quantum Cryptography**: ML-DSA-65, Ed25519, SLH-DSA-128s signatures with SHAKE-256 hashing |
| 37 | +- **Witness Chains**: Tamper-evident cryptographic hash-linked audit trails |
| 38 | +- **Raft Consensus**: Distributed coordination with multi-master replication and vector clocks |
| 39 | +- **WASM Runtime**: 5.5 KB runtime bootable in 125ms, deployable on servers, browsers, phones, IoT |
| 40 | +- **Git-like Branching**: Copy-on-write structure (1M vectors + 100 edits ≈ 2.5 MB branch) |
| 41 | + |
| 42 | +## Decision |
| 43 | + |
| 44 | +We will integrate RuVector's RVF format and intelligence capabilities into the WiFi-DensePose system through a phased, modular approach across 9 integration domains, each detailed in subsequent ADRs (ADR-003 through ADR-010). |
| 45 | + |
| 46 | +### Integration Architecture Overview |
| 47 | + |
| 48 | +``` |
| 49 | +┌─────────────────────────────────────────────────────────────────────────────┐ |
| 50 | +│ WiFi-DensePose + RuVector │ |
| 51 | +├─────────────────────────────────────────────────────────────────────────────┤ |
| 52 | +│ │ |
| 53 | +│ ┌──────────────┐ ┌──────────────┐ ┌──────────────┐ ┌──────────────┐ │ |
| 54 | +│ │ CSI Input │ │ RVF Store │ │ SONA │ │ GNN Layer │ │ |
| 55 | +│ │ Pipeline │──▶│ (Vectors, │──▶│ Self-Learn │──▶│ Pattern │ │ |
| 56 | +│ │ │ │ Indices) │ │ │ │ Enhancement │ │ |
| 57 | +│ └──────┬───────┘ └──────┬───────┘ └──────┬───────┘ └──────┬───────┘ │ |
| 58 | +│ │ │ │ │ │ |
| 59 | +│ ▼ ▼ ▼ ▼ │ |
| 60 | +│ ┌──────────────┐ ┌──────────────┐ ┌──────────────┐ ┌──────────────┐ │ |
| 61 | +│ │ Feature │ │ HNSW │ │ Adaptive │ │ Pose │ │ |
| 62 | +│ │ Extraction │ │ Search │ │ Weights │ │ Estimation │ │ |
| 63 | +│ └──────┬───────┘ └──────┬───────┘ └──────┬───────┘ └──────┬───────┘ │ |
| 64 | +│ │ │ │ │ │ |
| 65 | +│ └─────────────────┴─────────────────┴─────────────────┘ │ |
| 66 | +│ │ │ |
| 67 | +│ ┌──────────▼──────────┐ │ |
| 68 | +│ │ Output Layer │ │ |
| 69 | +│ │ • Pose Keypoints │ │ |
| 70 | +│ │ • Body Segments │ │ |
| 71 | +│ │ • UV Coordinates │ │ |
| 72 | +│ │ • Confidence Maps │ │ |
| 73 | +│ └──────────┬──────────┘ │ |
| 74 | +│ │ │ |
| 75 | +│ ┌───────────────────────────┼───────────────────────────┐ │ |
| 76 | +│ ▼ ▼ ▼ │ |
| 77 | +│ ┌──────────────┐ ┌──────────────┐ ┌──────────────┐ │ |
| 78 | +│ │ Witness │ │ Raft │ │ WASM │ │ |
| 79 | +│ │ Chains │ │ Consensus │ │ Edge │ │ |
| 80 | +│ │ (Audit) │ │ (Multi-AP) │ │ Runtime │ │ |
| 81 | +│ └──────────────┘ └──────────────┘ └──────────────┘ │ |
| 82 | +│ │ |
| 83 | +│ ┌─────────────────────────────────────────────────────────────────────┐ │ |
| 84 | +│ │ Post-Quantum Crypto Layer │ │ |
| 85 | +│ │ ML-DSA-65 │ Ed25519 │ SLH-DSA-128s │ SHAKE-256 │ │ |
| 86 | +│ └─────────────────────────────────────────────────────────────────────┘ │ |
| 87 | +└─────────────────────────────────────────────────────────────────────────────┘ |
| 88 | +``` |
| 89 | + |
| 90 | +### New Crate: `wifi-densepose-rvf` |
| 91 | + |
| 92 | +A new workspace member crate will serve as the integration layer: |
| 93 | + |
| 94 | +``` |
| 95 | +crates/wifi-densepose-rvf/ |
| 96 | +├── Cargo.toml |
| 97 | +├── src/ |
| 98 | +│ ├── lib.rs # Public API surface |
| 99 | +│ ├── container.rs # RVF cognitive container management |
| 100 | +│ ├── vector_store.rs # HNSW-backed CSI vector storage |
| 101 | +│ ├── search.rs # Similarity search for fingerprinting |
| 102 | +│ ├── learning.rs # SONA integration for online learning |
| 103 | +│ ├── gnn.rs # GNN pattern enhancement layer |
| 104 | +│ ├── attention.rs # Attention mechanism selection |
| 105 | +│ ├── witness.rs # Witness chain audit trails |
| 106 | +│ ├── consensus.rs # Raft consensus for multi-AP |
| 107 | +│ ├── crypto.rs # Post-quantum crypto wrappers |
| 108 | +│ ├── edge.rs # WASM edge runtime integration |
| 109 | +│ └── adapters/ |
| 110 | +│ ├── mod.rs |
| 111 | +│ ├── signal_adapter.rs # Bridges wifi-densepose-signal |
| 112 | +│ ├── nn_adapter.rs # Bridges wifi-densepose-nn |
| 113 | +│ └── mat_adapter.rs # Bridges wifi-densepose-mat |
| 114 | +``` |
| 115 | + |
| 116 | +### Phased Rollout |
| 117 | + |
| 118 | +| Phase | Timeline | ADR | Capability | Priority | |
| 119 | +|-------|----------|-----|------------|----------| |
| 120 | +| 1 | Weeks 1-3 | ADR-003 | RVF Cognitive Containers for CSI Data | Critical | |
| 121 | +| 2 | Weeks 2-4 | ADR-004 | HNSW Vector Search for Signal Fingerprinting | Critical | |
| 122 | +| 3 | Weeks 4-6 | ADR-005 | SONA Self-Learning for Pose Estimation | High | |
| 123 | +| 4 | Weeks 5-7 | ADR-006 | GNN-Enhanced CSI Pattern Recognition | High | |
| 124 | +| 5 | Weeks 6-8 | ADR-007 | Post-Quantum Cryptography for Secure Sensing | Medium | |
| 125 | +| 6 | Weeks 7-9 | ADR-008 | Distributed Consensus for Multi-AP | Medium | |
| 126 | +| 7 | Weeks 8-10 | ADR-009 | RVF WASM Runtime for Edge Deployment | Medium | |
| 127 | +| 8 | Weeks 9-11 | ADR-010 | Witness Chains for Audit Trail Integrity | High (MAT) | |
| 128 | + |
| 129 | +### Dependency Strategy |
| 130 | + |
| 131 | +```toml |
| 132 | +# In Cargo.toml workspace dependencies |
| 133 | +[workspace.dependencies] |
| 134 | +ruvector-core = { version = "0.1", features = ["hnsw", "sona", "gnn"] } |
| 135 | +ruvector-data-framework = { version = "0.1", features = ["rvf", "witness", "crypto"] } |
| 136 | +ruvector-consensus = { version = "0.1", features = ["raft"] } |
| 137 | +ruvector-wasm = { version = "0.1", features = ["edge-runtime"] } |
| 138 | +``` |
| 139 | + |
| 140 | +Feature flags control which RuVector capabilities are compiled in: |
| 141 | + |
| 142 | +```toml |
| 143 | +[features] |
| 144 | +default = ["rvf-store", "hnsw-search"] |
| 145 | +rvf-store = ["ruvector-data-framework/rvf"] |
| 146 | +hnsw-search = ["ruvector-core/hnsw"] |
| 147 | +sona-learning = ["ruvector-core/sona"] |
| 148 | +gnn-patterns = ["ruvector-core/gnn"] |
| 149 | +post-quantum = ["ruvector-data-framework/crypto"] |
| 150 | +witness-chains = ["ruvector-data-framework/witness"] |
| 151 | +raft-consensus = ["ruvector-consensus/raft"] |
| 152 | +wasm-edge = ["ruvector-wasm/edge-runtime"] |
| 153 | +full = ["rvf-store", "hnsw-search", "sona-learning", "gnn-patterns", "post-quantum", "witness-chains", "raft-consensus", "wasm-edge"] |
| 154 | +``` |
| 155 | + |
| 156 | +## Consequences |
| 157 | + |
| 158 | +### Positive |
| 159 | + |
| 160 | +- **10-100x faster pattern lookup**: HNSW replaces linear scan for CSI fingerprint matching |
| 161 | +- **Continuous improvement**: SONA enables online adaptation without full retraining |
| 162 | +- **Self-contained deployment**: RVF containers package everything needed for field operation |
| 163 | +- **Tamper-evident records**: Witness chains provide cryptographic proof for disaster response auditing |
| 164 | +- **Future-proof security**: Post-quantum signatures resist quantum computing attacks |
| 165 | +- **Distributed operation**: Raft consensus enables coordinated multi-AP sensing |
| 166 | +- **Ultra-light edge**: 5.5 KB WASM runtime enables browser and IoT deployment |
| 167 | +- **Git-like versioning**: COW branching enables experimental model variations with minimal storage |
| 168 | + |
| 169 | +### Negative |
| 170 | + |
| 171 | +- **Increased binary size**: Full feature set adds significant dependencies (~15-30 MB) |
| 172 | +- **Complexity**: 9 integration domains require careful coordination |
| 173 | +- **Learning curve**: Team must understand RuVector's cognitive container paradigm |
| 174 | +- **API stability risk**: RuVector is pre-1.0; APIs may change |
| 175 | +- **Testing surface**: Each integration point requires dedicated test suites |
| 176 | + |
| 177 | +### Risks and Mitigations |
| 178 | + |
| 179 | +| Risk | Severity | Mitigation | |
| 180 | +|------|----------|------------| |
| 181 | +| RuVector API breaking changes | High | Pin versions, adapter pattern isolates impact | |
| 182 | +| Performance regression from abstraction layers | Medium | Benchmark each integration point, zero-cost abstractions | |
| 183 | +| Feature flag combinatorial complexity | Medium | CI matrix testing for key feature combinations | |
| 184 | +| Over-engineering for current use cases | Medium | Phased rollout, each phase independently valuable | |
| 185 | +| Binary size bloat for edge targets | Low | Feature flags ensure only needed capabilities compile | |
| 186 | + |
| 187 | +## Related ADRs |
| 188 | + |
| 189 | +- **ADR-001**: WiFi-Mat Disaster Detection Architecture (existing) |
| 190 | +- **ADR-003**: RVF Cognitive Containers for CSI Data |
| 191 | +- **ADR-004**: HNSW Vector Search for Signal Fingerprinting |
| 192 | +- **ADR-005**: SONA Self-Learning for Pose Estimation |
| 193 | +- **ADR-006**: GNN-Enhanced CSI Pattern Recognition |
| 194 | +- **ADR-007**: Post-Quantum Cryptography for Secure Sensing |
| 195 | +- **ADR-008**: Distributed Consensus for Multi-AP Coordination |
| 196 | +- **ADR-009**: RVF WASM Runtime for Edge Deployment |
| 197 | +- **ADR-010**: Witness Chains for Audit Trail Integrity |
| 198 | + |
| 199 | +## References |
| 200 | + |
| 201 | +- [RuVector Repository](https://github.com/ruvnet/ruvector) |
| 202 | +- [HNSW Algorithm](https://arxiv.org/abs/1603.09320) |
| 203 | +- [LoRA: Low-Rank Adaptation](https://arxiv.org/abs/2106.09685) |
| 204 | +- [Elastic Weight Consolidation](https://arxiv.org/abs/1612.00796) |
| 205 | +- [Raft Consensus](https://raft.github.io/raft.pdf) |
| 206 | +- [ML-DSA (FIPS 204)](https://csrc.nist.gov/pubs/fips/204/final) |
| 207 | +- [WiFi-DensePose Rust ADR-001: Workspace Structure](../rust-port/wifi-densepose-rs/docs/adr/ADR-001-workspace-structure.md) |
0 commit comments