ruvnet/RuView · error · CSIProcessingError

Failed to detect human presence: {e}

Error message

Failed to detect human presence: {e}

What it means

CSIProcessingError raised by CSIProcessor.detect_human_presence when the detection step (thresholding motion score, confidence smoothing against history) throws. The result object is built from CSIFeatures, so inconsistent feature arrays or history/state problems surface here, wrapped with the original exception text.

Source

Thrown at archive/v1/src/core/csi_processor.py:232

            smoothed_confidence = self._apply_temporal_smoothing(raw_confidence)
            
            # Determine if human is detected
            human_detected = smoothed_confidence >= self.human_detection_threshold
            
            if human_detected:
                self._human_detections += 1
            
            return HumanDetectionResult(
                human_detected=human_detected,
                confidence=smoothed_confidence,
                motion_score=motion_score,
                timestamp=datetime.now(timezone.utc),
                features=features,
                metadata={'threshold': self.human_detection_threshold}
            )
            
        except Exception as e:
            raise CSIProcessingError(f"Failed to detect human presence: {e}")
    
    async def process_csi_data(self, csi_data: CSIData) -> HumanDetectionResult:
        """Process CSI data through the complete pipeline.
        
        Args:
            csi_data: Raw CSI data
            
        Returns:
            Human detection result
            
        Raises:
            CSIProcessingError: If processing fails
        """
        try:
            self._total_processed += 1
            
            # Preprocess the data
            preprocessed_data = self.preprocess_csi_data(csi_data)

View on GitHub (pinned to 4685618388)

Solutions

  1. Only pass CSIFeatures obtained from extract_features on the same processor instance; do not hand-build them.
  2. Check the wrapped original exception text and align the offending array shapes.
  3. Avoid sharing one CSIProcessor across concurrent tasks; give each consumer its own instance.
  4. If deserializing stored features, validate array shapes against a freshly extracted sample before detection.

Example fix

# before
features = CSIFeatures(...mismatched arrays...)  # hand-built
detection = processor.detect_human_presence(features)  # wrapped failure

# after
features = processor.extract_features(processor.preprocess_csi_data(csi))
detection = processor.detect_human_presence(features)
Defensive patterns

Strategy: try-catch

Validate before calling

features = processor.extract_features(prepped)  # same processor instance
lengths = {a.size for a in (features.amplitude_mean, features.phase_difference,
                            features.correlation_matrix, features.doppler_shift,
                            features.power_spectral_density)}
if len(lengths) <= 1:  # heuristic consistency check
    detection = processor.detect_human_presence(features)

Try / catch

try:
    detection = processor.detect_human_presence(features)
except CSIProcessingError as e:
    logger.warning('detection failed (%s); emitting no-motion result', e)
    continue

Prevention

When it happens

Trigger: Calling detect_human_presence(features) with a corrupted CSIFeatures (mismatched array lengths from a hand-built features object), or when smoothing/history state has degenerate values (empty history combined with edge-case smoothing_factor). Features are normally produced by extract_features; hand-constructing or mutating them is the usual trigger.

Common situations: Building CSIFeatures manually in tests or benchmarks with arrays of different lengths; reusing one processor across threads so smoothing state races; deserializing stored features with older schema lengths; human_detection_threshold tuned to a value that makes downstream math degenerate.

Related errors


AI-assisted analysis of ruvnet/RuView@4685618388 (2026-08-16). Data as JSON: /api/errors/1191ab73f991fc11. Report an issue: GitHub.