{"record":{"id":"1191ab73f991fc11","repo":"ruvnet/RuView","slug":"failed-to-detect-human-presence-e","errorCode":null,"errorMessage":"Failed to detect human presence: {e}","messagePattern":"Failed to detect human presence: (.+?)","errorType":"exception","errorClass":"CSIProcessingError","httpStatus":null,"severity":"error","filePath":"archive/v1/src/core/csi_processor.py","lineNumber":232,"sourceCode":"            smoothed_confidence = self._apply_temporal_smoothing(raw_confidence)\n            \n            # Determine if human is detected\n            human_detected = smoothed_confidence >= self.human_detection_threshold\n            \n            if human_detected:\n                self._human_detections += 1\n            \n            return HumanDetectionResult(\n                human_detected=human_detected,\n                confidence=smoothed_confidence,\n                motion_score=motion_score,\n                timestamp=datetime.now(timezone.utc),\n                features=features,\n                metadata={'threshold': self.human_detection_threshold}\n            )\n            \n        except Exception as e:\n            raise CSIProcessingError(f\"Failed to detect human presence: {e}\")\n    \n    async def process_csi_data(self, csi_data: CSIData) -> HumanDetectionResult:\n        \"\"\"Process CSI data through the complete pipeline.\n        \n        Args:\n            csi_data: Raw CSI data\n            \n        Returns:\n            Human detection result\n            \n        Raises:\n            CSIProcessingError: If processing fails\n        \"\"\"\n        try:\n            self._total_processed += 1\n            \n            # Preprocess the data\n            preprocessed_data = self.preprocess_csi_data(csi_data)","sourceCodeStart":214,"sourceCodeEnd":250,"githubUrl":"https://github.com/ruvnet/RuView/blob/4685618388a5e49fad5b3005806f3bdd6a7c25c3/archive/v1/src/core/csi_processor.py#L214-L250","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Only pass CSIFeatures obtained from extract_features on the same processor instance; do not hand-build them.","Check the wrapped original exception text and align the offending array shapes.","Avoid sharing one CSIProcessor across concurrent tasks; give each consumer its own instance.","If deserializing stored features, validate array shapes against a freshly extracted sample before detection."],"exampleFix":"# before\nfeatures = CSIFeatures(...mismatched arrays...)  # hand-built\ndetection = processor.detect_human_presence(features)  # wrapped failure\n\n# after\nfeatures = processor.extract_features(processor.preprocess_csi_data(csi))\ndetection = processor.detect_human_presence(features)","handlingStrategy":"try-catch","validationCode":"features = processor.extract_features(prepped)  # same processor instance\nlengths = {a.size for a in (features.amplitude_mean, features.phase_difference,\n                            features.correlation_matrix, features.doppler_shift,\n                            features.power_spectral_density)}\nif len(lengths) <= 1:  # heuristic consistency check\n    detection = processor.detect_human_presence(features)","typeGuard":null,"tryCatchPattern":"try:\n    detection = processor.detect_human_presence(features)\nexcept CSIProcessingError as e:\n    logger.warning('detection failed (%s); emitting no-motion result', e)\n    continue","preventionTips":["Never hand-construct CSIFeatures in production code paths; derive them from extract_features.","Do not share one CSIProcessor between concurrent tasks — smoothing/history state is not synchronized.","If features come from storage, re-extract on live data instead of replaying old schemas."],"tags":["csi-processing","runtime","detection","wrapper-exception"],"backgroundTag":null,"analyzedSha":"4685618388a5e49fad5b3005806f3bdd6a7c25c3","analyzedAt":"2026-08-16T06:09:40.886Z","schemaVersion":2},"datasetVersion":"2026-08-16T08:17:34.114Z"}