ADR-003:RVF 认知容器用于 CSI 数据¶
状态¶
已提议
日期¶
2026-02-28
上下文¶
问题¶
WiFi-DensePose 通过多阶段流水线处理 CSI(信道状态信息)数据:原始采集 → 预处理 → 特征提取 → 神经推理 → 姿态输出。每个阶段都会产生中间数据,而这些数据目前都是临时的:
-
原始 CSI 测量值(
CsiData):幅度矩阵(num_antennas x num_subcarriers)、相位数组、SNR 值、元数据。仅存储在一个有界的VecDeque中(Python 中最多 500 条,Rust 中类似)。 -
提取的特征(
CsiFeatures):幅度均值/方差、相位差、相关矩阵、多普勒频移、功率谱密度。在单次推理后被丢弃。 -
训练好的模型权重:从磁盘加载的静态 ONNX/PyTorch 文件。没有机制来持久化适配后的权重或实验变体。
-
检测结果(
HumanDetectionResult):置信度分数、运动分数、检测布尔值。已记录日志,但未建立索引以用于模式检索。 -
环境指纹:每个物理空间都有独特的 CSI 特征,受房间几何形状、家具和建筑材料影响。目前不存在持久化的指纹数据库。
机会¶
RuVector 的 RVF(认知容器)格式提供了一种单文件打包方案,包含 25 种段类型,可以封装整个 WiFi-DensePose 运行状态:
RVF Cognitive Container Structure:
┌─────────────────────────────────────────────┐
│ HEADER │ Magic, version, segment count │
├───────────┼─────────────────────────────────┤
│ VEC │ CSI feature vectors │
│ INDEX │ HNSW index over vectors │
│ WASM │ Inference runtime │
│ COW_MAP │ Copy-on-write branch state │
│ WITNESS │ Audit chain entries │
│ CRYPTO │ Signature keys, attestations │
│ KERNEL │ Bootable runtime (optional) │
│ EBPF │ Hardware-accelerated filters │
│ ... │ (25 total segment types) │
└─────────────────────────────────────────────┘
决策¶
我们将采用 RVF 认知容器格式作为 WiFi-DensePose 运行数据的主要持久化和部署单元,并实现以下容器类型:
1. CSI 指纹容器(.rvf.csi)¶
封装特定环境的 CSI 特征,用于位置识别:
/// CSI Fingerprint container storing environment signatures
pub struct CsiFingerprintContainer {
/// Container metadata
metadata: ContainerMetadata,
/// VEC segment: Normalized CSI feature vectors
/// Each vector = [amplitude_mean(N) | amplitude_var(N) | phase_diff(N-1) | doppler(10) | psd(128)]
/// Typical dimensionality: 64 subcarriers → 64+64+63+10+128 = 329 dimensions
fingerprint_vectors: VecSegment,
/// INDEX segment: HNSW index for O(log n) nearest-neighbor lookup
hnsw_index: IndexSegment,
/// COW_MAP: Branches for different times-of-day, occupancy levels
branches: CowMapSegment,
/// Metadata per vector: room_id, timestamp, occupancy_count, furniture_hash
annotations: AnnotationSegment,
}
向量编码:每个 CSI 快照都被编码为固定维度向量:
CSI Feature Vector (329-dim for 64 subcarriers):
┌──────────────────┬──────────────────┬─────────────────┬──────────┬─────────┐
│ amplitude_mean │ amplitude_var │ phase_diff │ doppler │ psd │
│ [f32; 64] │ [f32; 64] │ [f32; 63] │ [f32; 10]│ [f32;128│
└──────────────────┴──────────────────┴─────────────────┴──────────┴─────────┘
2. 模型容器(.rvf.model)¶
封装带有版本管理的神经网络权重:
/// Model container with version tracking and A/B comparison
pub struct ModelContainer {
/// Container metadata with model version history
metadata: ContainerMetadata,
/// Primary model weights (ONNX serialized)
primary_weights: BlobSegment,
/// SONA adaptation deltas (LoRA low-rank matrices)
adaptation_deltas: VecSegment,
/// COW branches for model experiments
/// e.g., "baseline", "adapted-office-env", "adapted-warehouse"
branches: CowMapSegment,
/// Performance metrics per branch
metrics: AnnotationSegment,
/// Witness chain: every weight update recorded
audit_trail: WitnessSegment,
}
3. 会话容器(.rvf.session)¶
捕获完整的感知会话,用于回放和分析:
/// Session container for recording and replaying sensing sessions
pub struct SessionContainer {
/// Session metadata (start time, duration, hardware config)
metadata: ContainerMetadata,
/// Time-series CSI vectors at capture rate
csi_timeseries: VecSegment,
/// Detection results aligned to CSI timestamps
detections: AnnotationSegment,
/// Pose estimation outputs
poses: VecSegment,
/// Index for temporal range queries
temporal_index: IndexSegment,
/// Cryptographic integrity proof
witness_chain: WitnessSegment,
}
容器生命周期¶
┌──────────┐ ┌──────────┐ ┌──────────┐ ┌──────────┐
│ Create │───▶│ Ingest │───▶│ Query │───▶│ Branch │
│ Container │ │ Vectors │ │ (HNSW) │ │ (COW) │
└──────────┘ └──────────┘ └──────────┘ └──────────┘
│ │
│ ┌──────────┐ ┌──────────┐ │
│ │ Merge │◀───│ Compare │◀─────────┘
│ │ Branches │ │ Results │
│ └────┬─────┘ └──────────┘
│ │
▼ ▼
┌──────────┐ ┌──────────┐
│ Export │ │ Deploy │
│ (.rvf) │ │ (Edge) │
└──────────┘ └──────────┘
与现有 crate 的集成¶
容器系统通过适配器 trait 进行集成:
/// Trait for types that can be vectorized into RVF containers
pub trait RvfVectorizable {
/// Encode self as a fixed-dimension f32 vector
fn to_rvf_vector(&self) -> Vec<f32>;
/// Reconstruct from an RVF vector
fn from_rvf_vector(vec: &[f32]) -> Result<Self, RvfError> where Self: Sized;
/// Vector dimensionality
fn vector_dim() -> usize;
}
// Implementation for existing types
impl RvfVectorizable for CsiFeatures {
fn to_rvf_vector(&self) -> Vec<f32> {
let mut vec = Vec::with_capacity(Self::vector_dim());
vec.extend(self.amplitude_mean.iter().map(|&x| x as f32));
vec.extend(self.amplitude_variance.iter().map(|&x| x as f32));
vec.extend(self.phase_difference.iter().map(|&x| x as f32));
vec.extend(self.doppler_shift.iter().map(|&x| x as f32));
vec.extend(self.power_spectral_density.iter().map(|&x| x as f32));
vec
}
fn vector_dim() -> usize {
// 64 + 64 + 63 + 10 + 128 = 329 (for 64 subcarriers)
329
}
// ...
}
存储特性¶
| 容器类型 | 典型大小 | 向量数量 | 用例 |
|---|---|---|---|
| Fingerprint | 5-50 MB | 10K-100K | 房间/建筑指纹数据库 |
| Model | 50-500 MB | N/A(blob) | 神经网络部署 |
| Session | 10-200 MB | 50K-500K | 100 Hz 下 1 小时录音 |
用于环境适应的 COW 分支¶
写时复制机制可实现零开销实验:
main (office baseline: 50K vectors)
├── branch/morning (delta: 500 vectors, ~15 KB)
├── branch/afternoon (delta: 800 vectors, ~24 KB)
├── branch/occupied-10 (delta: 2K vectors, ~60 KB)
└── branch/furniture-moved (delta: 5K vectors, ~150 KB)
在 50K 向量容器中,4 个分支的总开销:额外约 250 KB(0.5%)。
影响¶
积极影响¶
- 单文件部署:通过复制一个
.rvf文件,即可在站点之间迁移指纹数据库 - 版本化模型:无需复制完整权重集即可对模型变体进行 A/B 测试
- 会话回放:从记录的 CSI 数据中复现检测结果
- 原子操作:容器写入是事务性的;不会出现部分状态损坏
- 跨平台:相同的容器格式可在服务器、WASM 和嵌入式环境中使用
- 存储高效:COW 分支可避免重复未更改的数据
消极影响¶
- 格式锁定:RVF 尚未成为广泛采用的标准
- 序列化开销:在原生类型与 RVF 向量之间转换会增加延迟(每个向量约 0.1-0.5 ms)
- 学习曲线:团队必须理解段类型和容器生命周期
- 会话文件大小:高频率 CSI 捕获(1000 Hz)会生成大型会话容器
性能目标¶
| 操作 | 目标延迟 | 备注 |
|---|---|---|
| 容器打开 | <10 ms | 内存映射 I/O |
| 向量插入 | <0.1 ms | 追加到 VEC 段 |
| HNSW 查询(100K 向量) | <1 ms | 参见 ADR-004 |
| 分支创建 | <1 ms | 仅 COW 元数据 |
| 分支合并 | <100 ms | 增量应用 |
| 容器导出 | ~1 ms/MB | 顺序写入 |
参考资料¶
- RuVector 认知容器规范
- Rust 中的内存映射 I/O
- 写时复制数据结构
- ADR-002:RuVector RVF 集成策略
本页原文 Markdown:在 AtomGit 查看·内容源自开源项目 wi/RuView