Skip to content

feat(sensing-server): wire wifi-densepose-vitals 4-stage pipeline#485

Open
schwarztim wants to merge 1 commit into
ruvnet:mainfrom
schwarztim:pr/vitals-4-stage-pipeline-clean
Open

feat(sensing-server): wire wifi-densepose-vitals 4-stage pipeline#485
schwarztim wants to merge 1 commit into
ruvnet:mainfrom
schwarztim:pr/vitals-4-stage-pipeline-clean

Conversation

@schwarztim
Copy link
Copy Markdown
Contributor

Motivation

The sensing server's vital_signs module previously used an in-process FFT heuristic that produced jittery heart-rate readings (varying ±15 bpm minute-to-minute) and inconsistent confidence scores. The workspace already includes the wifi-densepose-vitals crate (4-stage IIR + autocorrelation pipeline), but it wasn't wired into the live REST path.

Design rationale

  • Why a wrapper (CrateVitalsPipeline) instead of replacing the heuristic outright? Confidence-based fallback. The crate produces high-quality estimates only when the input signal has good SNR. Below confidence 0.05 the legacy heuristic outperforms the crate output, so we fall back. This preserves availability under poor signal conditions.
  • Why threshold 0.05? Empirically calibrated against the test fixture set in wifi-densepose-vitals/tests/. Confidence below 0.05 corresponds to autocorrelation peaks indistinguishable from noise.
  • Why call per-frame instead of batched? The legacy path is also per-frame; matching the call cadence simplifies the swap and avoids buffer-management changes.

Changes

  • v2/crates/wifi-densepose-sensing-server/src/vital_signs.rs: add CrateVitalsPipeline struct wrapping wifi_densepose_vitals::VitalsPipeline; insert into extract_vitals() flow with confidence threshold; fallback to existing heuristic on low confidence.
  • v2/crates/wifi-densepose-sensing-server/src/types.rs: replace VitalSignDetector with CrateVitalsPipeline in NodeState and AppStateInner (both struct fields and initializers).
  • v2/crates/wifi-densepose-sensing-server/Cargo.toml: add wifi-densepose-vitals workspace dep.

Test results

  • cargo test --workspace --no-default-features: 1632 passed, 0 failed
  • python verify.py: pre-existing hash mismatch on this machine due to numpy/scipy version delta (hash generated on a different platform); our changes make no modifications to archive/v1/data/proof/ — confirmed by git diff origin/main..HEAD -- archive/v1/data/proof/

ADR / docs

  • References ADR-045 (vitals jitter investigation); design rationale above is the implementation decision record for this wrapper.
  • No new ADR needed; the wifi-densepose-vitals crate already has its own design notes.

Add CrateVitalsPipeline wrapping the wifi-densepose-vitals crate's
IIR + autocorrelation pipeline. Uses crate output when confidence > 0.05,
falls back to FFT heuristic below threshold. Reduces HR jitter and
unstable confidence readings (ADR-045 §4.2).
yahyasaqban-lab pushed a commit to yahyasaqban-lab/RuView that referenced this pull request May 17, 2026
Phase values from atan2(i_val, q_val) are wrapped to (-pi, pi]. Linear
variance treats values near +pi and -pi as ~2pi apart when they are
physically ~0.003 rad apart, producing variance of ~pi^2 instead of ~1e-6.

Replace with circular variance (1 - R, mean resultant length) which
correctly handles wrapped circular data. This fixes the +/-15 bpm jitter
in heart-rate detection and the jumpy vitals reported in issues ruvnet#485, ruvnet#519.

Fixes ruvnet#593
@ruvnet
Copy link
Copy Markdown
Owner

ruvnet commented May 17, 2026

Hi @schwarztim — current main has moved (mergeable=DIRTY/UNKNOWN). Key landings since this PR opened that you'll want to pull in:

The PRs were all evaluated thoughtful and well-described. Once you rebase against main, I'll do a focused review and merge if the test plan still passes locally. If you'd like me to rebase one of these on your behalf, say which (I can push back to your fork since maintainerCanModify is enabled).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants