Skip to content

Piezo processor selects SEQNO.RAW instead of sensor data file #246

@ng

Description

@ng

Bug

RawFileFollower._find_latest() in modules/common/raw_follower.py selects the .RAW file with the most recent mtime. When SEQNO.RAW (a metadata/index file, not sensor data) has the newest mtime, the piezo processor tries to parse it as CBOR sensor data, fails on every byte, and then sits at EOF — processing zero biometric data.

Evidence

User debug logs from eight-pod (2026-03-20 to 2026-03-22) show this pattern repeating across 10+ boots:

[piezo-processor] INFO Switched to RAW file: SEQNO.RAW
[piezo-processor] WARNING Skipping past corrupt data at offset 0 after 5 failures: Expected outer map 0xa2, got 0xa0
[piezo-processor] WARNING Skipping past corrupt data at offset 1 after 5 failures: ...
...
[piezo-processor] WARNING Skipping past corrupt data at offset 15 after 5 failures: ...

After byte-skipping through the 16-byte SEQNO file, the processor hits EOF and polls forever. No HR, HRV, or breathing data is processed.

Root cause

_find_latest() has no exclusion for non-data RAW files:

def _find_latest(self) -> Optional[Path]:
    candidates = [p for p in self.data_dir.glob("*.RAW") if _safe_mtime(p) > 0]
    candidates.sort(key=_safe_mtime, reverse=True)
    return candidates[0] if candidates else None

The prototype code (modules/piezo-processor/prototype_v2.py:511) already filters SEQNO.RAW out, but this was never ported to production:

raw_files = [f for f in raw_files if f.name != "SEQNO.RAW" and f.stat().st_size > 100_000]

Impact

  • Complete loss of biometric data (HR, HRV, breathing rate) for affected devices
  • Race condition: depends on whether the sensor daemon or SEQNO update touches disk last
  • Secondary issue: calibrator also crashes (sqlite3.OperationalError: attempt to write a readonly database) on this device, but that is a separate filesystem-level problem

Fix

Filter SEQNO.RAW from candidates in _find_latest().

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions