github ilyakruchinin/SomnoTrace v2.0.4

3 hours ago

SomnoTrace v2.0.4

Highlights & Changes

1. SleepHQ Cloud: Fixed Import Finalization Failures on Multi-Session Days (Issue #151)

  • What was happening: Uploads on days with more than ~35 files (e.g. multiple therapy sessions, or days with many EDF components) consistently failed at the finalization stage with unparseable status body. SomnoTrace kept the day in pending status and re-uploaded the files on every retry loop, even though SleepHQ had actually received all files and marked the import as complete on its dashboard.
  • The Root Cause: Cloudflare and Rails return massive HTTP response headers (~3.2 KB of security/CSP headers alone). The firmware's internal response buffer was capped at 5,120 bytes, leaving only ~1,940 bytes for the JSON body. Imports with 36+ files produced JSON bodies larger than 1,940 bytes, which silently overflowed the buffer ceiling, truncated the JSON mid-stream, and caused the status parser to fail on missing closing brackets.
  • The Fix: Expanded the response buffer to 40 KB allocated strictly in PSRAM (32 KB for response payloads, supporting 700+ files per import, and 8 KB for headers). Added guaranteed safe null-termination, explicit error logging on buffer overflow or socket drop, and polling retry resilience so momentary network hiccups no longer abort entire uploads. Zero impact on internal DRAM.

2. Dashboard: Fixed Phantom Diagonal Line Across Session Gaps

  • What was happening: On days with multiple sessions separated by an off-period (e.g. taking a break, tube drying, or split sleep), the pressure panel rendered a phantom green diagonal line starting in the middle of the gap and ramping up to the start of the second session. Zooming into a 21-minute window made it disappear, but zooming out showed the glitch.
  • The Root Cause: In uPlot, all series on a chart share a single X-axis timestamp array. Because Mask Pressure fluctuates while EPAP is often flat, decimating them in separate passes caused their array lengths to diverge. Over an inter-session gap, EPAP entered the gap one index earlier than pressure, causing uPlot to pair the first data point of Session 2 with the gap midpoint timestamp.
  • The Fix: Mask Pressure and EPAP are now decimated concurrently in a single pass on the exact same column grid. Both channels emit points in strict lockstep and break at the exact same midpoint index, completely eliminating phantom lines across session gaps and guaranteeing accurate tooltip hover values.

3. Host Mutation Testing: Explicit Coverage Scope (PR #250)

  • What changed: scripts/mutate_host.py now explicitly prints its test scope denominator on every run (e.g. SCOPE: 3 of 80 C sources are linked by a wired host test; 77 are INVISIBLE to this harness). This prevents a clean mutation report ("0 unasserted survivors") from being mistaken for repository-wide coverage when only wired translation units were exercised.

Contributors & Acknowledgements

Special thanks to our community members for their invaluable help in diagnosing, testing, and resolving these issues:

  • Irfan Guder (@irfanguder) — For patient, thorough stress-testing across 77, 88, 99, 110, and 121-day upload batches, providing the detailed v2.0.3 log files and SleepHQ dashboard captures that made solving the buffer truncation bug possible.
  • Beren (@beren) — For spotting and reporting the pressure overlay visual bug, testing graph zoom behaviors, and providing the raw .snt session captures and logs that enabled 100% reproduction and verification.
  • Michal Planicka (@Plantucha) — For contributing PR #250 to bring transparency to host mutation testing, and for key diagnostic insights into SleepHQ response framing.

Don't miss a new SomnoTrace release

NewReleases is sending notifications on new releases.