fix(sensing-server): classification.presence contradicting motion_level (#1442) - #1447
Merged
ruvnet merged 1 commit intoJul 27, 2026
Merged
Conversation
…el (#1442) The multi-node vitals path derived `presence` directly from `vitals.presence` independently of the `motion_level` label it computed in the same block, so a frame with motion=true, presence=false produced `{"motion_level": "present_moving", "presence": false}` — internally contradictory, and since every UI gates rendering on `classification.presence`, a moving person could render as an empty room at confidence 1.0 (the multi-node confidence boost applies regardless of the presence flag). Every other classification site in this codebase already derives `presence` from the label instead (main.rs's per-node path: `!matches!(label, "absent")`; csi.rs: `label != "absent"`) — this was the one outlier. Extracted the motion_level + ClassificationInfo assembly into a small pure `classify_vitals` function so the invariant (motion implies presence) is enforced in one place and is unit-testable, with a test pinning the exact contradictory frame from the report. Reported with an exact root-cause analysis and suggested fix by @mattanapol. Fixes #1442 Co-Authored-By: claude-flow <ruv@ruv.net>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #1442.
Root cause
The multi-node vitals path derived
presencedirectly fromvitals.presenceindependently of themotion_levellabel computed in the same block, so a frame withmotion=true, presence=falseproduced{"motion_level": "present_moving", "presence": false}— internally contradictory. Since every UI gates rendering onclassification.presence, a moving person could render as an empty room, at confidence 1.0 (the multi-node confidence boost applies regardless of the presence flag).Every other classification site in this codebase already derives
presencefrom the label instead:main.rs's per-node path:presence: !matches!(ns.current_motion_level.as_str(), "absent")csi.rs:classification.presence = label != "absent"This was the one outlier.
Fix
Extracted the
motion_level+ClassificationInfoassembly into a small pureclassify_vitals(motion, presence, presence_score)function, so the invariant (motion implies presence) is enforced in one place and is unit-testable. Added 4 tests, including one pinning the exact contradictory frame from the report (motion=true, presence=false→ must not yieldpresence: false).Testing
cargo test -p wifi-densepose-sensing-server --no-default-features: 483 + 224 (+4 new) passing, 0 failed, 0 regressions.classify_vitals_tests::{motion_implies_presence_issue_1442, presence_without_motion_is_present_still, neither_motion_nor_presence_is_absent, confidence_passes_through_presence_score}.Did not touch the secondary "presence/presence_score anti-correlation" lead the reporter flagged (possible field-offset issue in the vitals packet decoder) or the "should the multi-node confidence boost apply when presence is false" question — both are explicitly framed as open questions/leads in the report, not concrete bugs, and are out of scope for this fix.
Reported with an exact root-cause analysis and suggested fix by @mattanapol — thank you, this made the fix straightforward.
Co-Authored-By: claude-flow ruv@ruv.net