wifi-densepose/v2/crates/wifi-densepose-ruvector
rUv f756a8af49
feat(ADR-261): ruvector HNSW graph-ANN (25x measured vs linear) + honest SymphonyQG-direction refutation (#1063)
* feat(ruvector): real float HNSW + SymphonyQG-style quantized-traversal index (ADR-261)

Adds the graph-ANN index the ruvector retrieval path was missing (ADR-156
§5 #1 noted there was no HNSW baseline to measure SymphonyQG against).

- hnsw.rs: correct float HNSW (Malkov & Yashunin) — multi-layer NSW graph,
  ef_construction/ef_search, Algorithm-4 neighbour selection, seeded-
  deterministic level assignment (SplitMix64, reused from rotation.rs),
  L2 + cosine, brute-force ground truth, full degenerate-case guards.
  recall@10 correctness gate >=0.95 vs brute force (L2 + cosine).
- hnsw_quantized.rs: SymphonyQG-style variant — same graph, traversal scored
  by cheap 1-bit Hamming over the RaBitQ Pass-2 rotated sign code, final
  exact-float rerank.
- ann_measure.rs: shared deterministic planted-cluster fixture + recall/QPS
  measurement (ann_bench_report is the ADR source of truth).

Fixes an index-out-of-bounds bug the recall gate caught: insert wired
bidirectional edges before pushing the node's own link row. +20 tests,
ruvector lib 131->151, 0 failed.

Co-Authored-By: claude-flow <ruv@ruv.net>

* bench(ruvector): criterion ann_bench for HNSW vs quantized vs linear (ADR-261)

Times the same shared ann_measure fixture/indices through criterion so the
bench and the report test can never measure different graphs.

Co-Authored-By: claude-flow <ruv@ruv.net>

* docs(adr-261): graph-ANN index ADR with MEASURED HNSW vs quantized verdict

ADR-261 (Accepted): float HNSW ~25x QPS over linear scan at recall >=0.99
(the baseline ADR-156 said was missing). Honest negative: the 1-bit
quantized traversal is too coarse to beat float HNSW at equal recall at
N=10k (best recall 0.738, no >=0.90 equal-recall point) — the SymphonyQG
3.5-17x is NOT reproduced by our 1-bit construction; expected crossover at
large N + a multi-bit code. Caveat: our HNSW + our quant, not SymphonyQG's
system — direction tested, not a 1:1 reproduction.

ADR-156 §5 #1 + §8 backlog: CLAIMED -> MEASURED-direction-tested.
CHANGELOG [Unreleased] entry.

Co-Authored-By: claude-flow <ruv@ruv.net>
2026-06-14 02:33:32 -04:00
..
benches feat(ADR-261): ruvector HNSW graph-ANN (25x measured vs linear) + honest SymphonyQG-direction refutation (#1063) 2026-06-14 02:33:32 -04:00
src feat(ADR-261): ruvector HNSW graph-ANN (25x measured vs linear) + honest SymphonyQG-direction refutation (#1063) 2026-06-14 02:33:32 -04:00
Cargo.toml feat(ADR-261): ruvector HNSW graph-ANN (25x measured vs linear) + honest SymphonyQG-direction refutation (#1063) 2026-06-14 02:33:32 -04:00
README.md chore(repo): rename rust-port/wifi-densepose-rs → v2/ (flatten to one level) (#427) 2026-04-25 21:28:13 -04:00

README.md

wifi-densepose-ruvector

RuVector v2.0.4 integration layer for WiFi-DensePose — ADR-017.

This crate implements all 7 ADR-017 ruvector integration points for the signal-processing pipeline and the Multi-AP Triage (MAT) disaster-detection module.

Integration Points

File ruvector crate What it does Benefit
signal/subcarrier ruvector-mincut Graph min-cut partitions subcarriers into sensitive / insensitive groups based on body-motion correlation Automatic subcarrier selection without hand-tuned thresholds
signal/spectrogram ruvector-attn-mincut Attention-guided min-cut gating suppresses noise frames, amplifies body-motion periods Cleaner Doppler spectrogram input to DensePose head
signal/bvp ruvector-attention Scaled dot-product attention aggregates per-subcarrier STFT rows weighted by sensitivity Robust body velocity profile even with missing subcarriers
signal/fresnel ruvector-solver Sparse regularized least-squares estimates TX-body (d1) and body-RX (d2) distances from multi-subcarrier Fresnel amplitude observations Physics-grounded geometry without extra hardware
mat/triangulation ruvector-solver Neumann series solver linearises TDoA hyperbolic equations to estimate 2-D survivor position across multi-AP deployments Sub-5 m accuracy from ≥3 TDoA pairs
mat/breathing ruvector-temporal-tensor Tiered quantized streaming buffer: hot ~10 frames at 8-bit, warm at 57-bit, cold at 3-bit 13.4 MB raw → 3.46.7 MB for 56 sc × 60 s × 100 Hz
mat/heartbeat ruvector-temporal-tensor Per-frequency-bin tiered compressor for heartbeat spectrogram; band_power() extracts mean squared energy in any band Independent tiering per bin; no cross-bin quantization coupling

Usage

Add to your Cargo.toml (workspace member or direct dependency):

[dependencies]
wifi-densepose-ruvector = { path = "../wifi-densepose-ruvector" }

Signal processing

use wifi_densepose_ruvector::signal::{
    mincut_subcarrier_partition,
    gate_spectrogram,
    attention_weighted_bvp,
    solve_fresnel_geometry,
};

// Partition 56 subcarriers by body-motion sensitivity.
let (sensitive, insensitive) = mincut_subcarrier_partition(&sensitivity_scores);

// Gate a 32×64 Doppler spectrogram (mild).
let gated = gate_spectrogram(&flat_spectrogram, 32, 64, 0.1);

// Aggregate 56 STFT rows into one BVP vector.
let bvp = attention_weighted_bvp(&stft_rows, &sensitivity_scores, 128);

// Solve TX-body / body-RX geometry from 5-subcarrier Fresnel observations.
if let Some((d1, d2)) = solve_fresnel_geometry(&observations, d_total) {
    println!("d1={d1:.2} m, d2={d2:.2} m");
}

MAT disaster detection

use wifi_densepose_ruvector::mat::{
    solve_triangulation,
    CompressedBreathingBuffer,
    CompressedHeartbeatSpectrogram,
};

// Localise a survivor from 4 TDoA measurements.
let pos = solve_triangulation(&tdoa_measurements, &ap_positions);

// Stream 6000 breathing frames at < 50% memory cost.
let mut buf = CompressedBreathingBuffer::new(56, zone_id);
for frame in frames {
    buf.push_frame(&frame);
}

// 128-bin heartbeat spectrogram with band-power extraction.
let mut hb = CompressedHeartbeatSpectrogram::new(128);
hb.push_column(&freq_column);
let cardiac_power = hb.band_power(10, 30); // ~0.82.0 Hz range

Memory Reduction

Breathing buffer for 56 subcarriers × 60 s × 100 Hz:

Tier Bits/value Size
Raw f32 32 13.4 MB
Hot (8-bit) 8 3.4 MB
Mixed hot/warm/cold 38 3.46.7 MB