Files
ruvnet--RuView/v2/crates/wifi-densepose-signal/Cargo.toml
T
ruv 8504638187 feat(signal): ADR-135 — empty-room baseline calibration
Operator-initiated calibration that records 30 s of stationary CSI,
emits a per-subcarrier baseline (amplitude mean+variance via Welford,
phase via circular sin/cos sums with von Mises dispersion), and gates
downstream stages on a deviation z-score. Plugs into multistatic
coherence gating, motion/presence detection, and the new ADR-134 CIR
estimator as a reference-subtracted input.

API surface (under wifi_densepose_signal):
  CalibrationConfig::{ht20, ht40, he20, he40}
  CalibrationRecorder { record(), finalize(), frames_recorded() }
  BaselineCalibration {
    subcarriers: Vec<SubcarrierBaseline>,
    deviation(&CsiFrame), subtract_in_place(&mut CsiFrame),
    to_bytes(), from_bytes()
  }
  CalibrationDeviationScore { amplitude_z_median, amplitude_z_max,
                              phase_drift_median, motion_flagged }
  CalibrationError { SubcarrierMismatch, TierMismatch,
                     InsufficientFrames, VersionMismatch, TruncatedBuffer }

Binary baseline format: magic 0xCA1B_0001 + u8 version=1 + u8 tier +
captured_at_unix_s (i64) + frame_count (u64) + num_subcarriers (u32) +
[SubcarrierBaseline; N] as 16 bytes each (amp_mean, amp_variance,
phase_mean, phase_dispersion as f32 LE). Hand-written serialisation so
the format is stable across Rust toolchain versions without serde drift.

CLI: new `wifi-densepose calibrate` subcommand binds a UDP listener
(0xC511_0001 frames), streams them through CalibrationRecorder, prints
a real-time z-score banner per ADR-135 §risk 1 (operator-may-be-moving),
aborts on sustained high deviation, and writes the binary baseline to
disk. Local UDP packet parser duplicated from sensing-server (per ADR
discussion — avoids cross-crate API churn).

Witness: cross-platform-deterministic SHA-256 over the per-subcarrier
quantised baseline profile (u16 LE at 1e-2/1e-4/1e-3, no sort) using
the lesson learnt from the CIR PR #837 libm-jitter fix. Hash:
d6bce07ecb1648e6936561df44bf4a3bfc17bb0ba5f692646b2301d105b52f67

CI guard: new "ADR-135 calibration witness proof (determinism guard)"
step under the Rust Workspace Tests job, adjacent to the existing
ADR-134 CIR guard. Regressions are unambiguously attributable.

Hardware-in-loop validation: full 600-frame capture exercised via the
new scripts/synth-csi-udp.py emitter targeting 127.0.0.1:5005. The CLI
binary received 600 frames at 20 Hz, z_med stable at ~0.7, motion
correctly NOT flagged, finalised baseline written to baseline.bin (860
bytes) with correct magic + version + timestamp in the header. Live
ESP32 capture from COM9 is operator follow-up — requires provisioning
the firmware's UDP target IP to match the host running the CLI.

Test results (cargo test -p wifi-densepose-signal --no-default-features):
  lib:                    382 pass / 0 fail / 1 ignored
  calibration_synthetic:   17 pass / 0 fail
  calibration_drift:        5 pass / 0 fail
  calibration_roundtrip:   10 pass / 0 fail
  cir_*:                    9 pass + 6 documented P2 ignores
  doctest:                 10 pass

Bench: 20 Criterion combinations registered
(recorder_record / recorder_finalize / deviation / record_600 /
to_bytes across HT20/HT40/HE20/HE40 tiers).

Witness: bash scripts/verify-calibration-proof.sh → VERDICT: PASS

Co-Authored-By: claude-flow <ruv@ruv.net>
2026-05-28 18:57:08 -04:00

92 lines
2.8 KiB
TOML

[package]
name = "wifi-densepose-signal"
version = "0.3.1"
edition.workspace = true
description = "WiFi CSI signal processing for DensePose estimation"
license.workspace = true
authors = ["rUv <ruv@ruv.net>", "WiFi-DensePose Contributors"]
repository.workspace = true
documentation = "https://docs.rs/wifi-densepose-signal"
keywords = ["wifi", "csi", "signal-processing", "densepose", "rust"]
categories = ["science", "computer-vision"]
readme = "README.md"
[features]
default = ["eigenvalue"]
## Enable eigenvalue-based person counting (requires BLAS via ndarray-linalg).
## Disable with --no-default-features to use the diagonal fallback instead.
eigenvalue = ["ndarray-linalg"]
## ADR-134: CIR sparse recovery module (default-on; zero-cost if never instantiated).
## ruvector-solver is already a mandatory dep so no additional dep needed here.
cir = []
[dependencies]
# Core utilities
thiserror.workspace = true
serde = { workspace = true }
serde_json.workspace = true
chrono = { version = "0.4", features = ["serde"] }
# Signal processing
ndarray = { workspace = true }
ndarray-linalg = { workspace = true, optional = true }
rustfft.workspace = true
num-complex.workspace = true
num-traits.workspace = true
# Graph algorithms
ruvector-mincut = { workspace = true }
ruvector-attn-mincut = { workspace = true }
# Attention and solver integrations (ADR-017)
ruvector-attention = { workspace = true }
ruvector-solver = { workspace = true }
# Midstreamer integrations (ADR-032a)
midstreamer-temporal-compare = { workspace = true }
midstreamer-attractor = { workspace = true }
# Internal
wifi-densepose-core = { version = "0.3.0", path = "../wifi-densepose-core" }
# ADR-084 Pass 2: sketch-prefilter for the EmbeddingHistory search loop.
wifi-densepose-ruvector = { version = "0.3.0", path = "../wifi-densepose-ruvector", default-features = false }
[dev-dependencies]
criterion = { version = "0.5", features = ["html_reports"] }
proptest.workspace = true
[[bench]]
name = "signal_bench"
harness = false
[[bench]]
name = "aether_prefilter_bench"
harness = false
## ADR-134: CIR estimator throughput benchmarks
[[bench]]
name = "cir_bench"
harness = false
required-features = ["cir"]
# ADR-134: CIR deterministic proof runner binary.
[[bin]]
name = "cir_proof_runner"
path = "src/bin/cir_proof_runner.rs"
# sha2 added for cir_proof_runner (ADR-134). In workspace root since v2/Cargo.toml:145.
# Appended here to avoid touching existing [dependencies] entries owned by the
# implementation agent; this addition is purely additive.
[dependencies.sha2]
workspace = true
## ADR-135: calibration module throughput benchmarks
[[bench]]
name = "calibration_bench"
harness = false
# ADR-135: calibration deterministic proof runner binary.
[[bin]]
name = "calibration_proof_runner"
path = "src/bin/calibration_proof_runner.rs"