Repository navigation
fix(piezo-processor): no vitals while the bed reads empty - #768
Conversation
Piezo presence looks only at vibration energy and rhythm, so a prime or the pump shaking an empty bed passed it and wrote vitals with nobody there (on a Pod 4, ~20% of a day's vitals minutes fell outside any bed session, clustered around the daily prime). A side now also asks the sleep-detector, whose capacitance-based presence is committed and saved to its state file (common/bed_presence.py): if it says the side is empty, the window counts as absent. With one side away it asks about the home side, where the readings are stored. A missing, unreadable or stale state file leaves piezo presence to decide, as before. Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
@jasonlarue is attempting to deploy a commit to the therealng's projects Team on Vercel. A member of the Team first needs to authorize it. |
|
Warning Review limit reachedYou've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Next included review available in 54 minutes. View limit detailsLimit details: You’ve used the included review currently available. Review configuration: ⚙️ Run configuration
📒 Files selected for processing (7)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
48436ea to
c4233a7
Compare
|
Scope: full branch at Full-depth adversarial review completed with two independent Optimizers and two independent Skeptics using the inherited GPT-6 runtime (the skill’s legacy models are unavailable). Recommendation: request changes; do not merge this head.
At The repair needs an explicit, persisted trustworthy-absence/readiness and per-side valid-evidence freshness contract. A non-null baseline check does not fix occupied bootstrap; Mechanical verification: locked uv runtime dependencies; 110 piezo and 224 common tests pass, as do exact-head CI lint, typecheck, unit tests, Python matrix and codecov/patch. These tests miss the reproduced regressions. Source build and artifact upload succeeded; the red build result is the final PR-description GraphQL permission error, not compilation. Vercel’s separate failure is deployment authorization. No Critical, additional lower-confidence blocking, or separately retained pre-existing findings. No device deployment performed. |
…tions, 3D temperature Stage and experimental Base (#783) Promote `dev` to `main`: power-off and alarm fixes, hardware recovery and diagnostics, a 24-hour time option, keeping temperature after a schedule ends, a 3D temperature Stage, hosted demo mode, and experimental adjustable-base controls. OFF now clears the side's active firmware timer before resetting its temperature level, and reports a failure if the timer cannot be cleared (#713). This addresses the hub continuing to regulate after OFF. ## Release scope - **Alarms:** fix snooze, the wake window and warm-up (#766, #779). A snooze is no longer lost when the firmware write that confirms a tap fails (#790). - **Hardware:** DAC connections recover after firmware restarts (#782); pump stalls are no longer reported falsely during startup (#786); the installer separates socket discovery from hardware identity (#785). - **Settings:** a pod-wide 12-hour / 24-hour time format, used by every clock, chart and time editor (#788). Solo bed setup is now separate from partner away mode (#767). - **Schedules:** "After schedule ends" can keep the final temperature instead of turning the Pod off. There is a device default and a per-curve choice, and the setting is available over REST/tRPC and MCP (#789). - **Temperature:** a 3D thermal bed, a temperature Stage view and a sweep-mode piezo waveform (#787). - **Performance and diagnostics:** piezo vitals are suppressed while the bed reads empty; the temperature controller does less work; the firmware probe is cached; V8 and native memory counters are reported (#768, #772, #770, #773). - **Demo:** a hosted demo mode (#765, #781). - **Base (experimental):** controls, presets, schedules and a 3D bed view with a 2D fallback (#780, #784). Physical movement is unverified, and independent per-side movement stays locked until the firmware is validated. - **Tests:** coverage for the Stage, ThermalBed, Base and piezo views (#790), plus automation and sensor-stream tests. **Database migrations:** - `0017_majestic_enchantress` - `0018_amazing_captain_marvel` - `0019_closed_psynapse` - `0020_mature_puff_adder`: schedule end action, which defaults to `turn_off` - `0021_device_time_format`: `time_format`, which defaults to `12h` The iOS companion change for end actions is sleepypod/ios#51. It should be merged after this deploy.
## Summary sleepypod#769 added `system.getSensorSource` (used by `SensorSourceCard`) but no demo handler, so `src/demo/tests/coverage.test.ts` fails on `dev` and blocks every PR (e.g. sleepypod#779, the sleepypod#768 merge-queue run). Adds a demo handler that reports NATS firmware with a fresh piezo frame, reusing `FIRMWARE_LABELS` and `DEMO_UPTIME_START`. ## Test plan - [x] `vitest run src/demo` — 77 passed (coverage + contract tests) - [ ] CI green 🤖 Generated with [Claude Code](https://claude.com/claude-code)
…it stage models (#948) Promotes `dev` to `main`. ## Changes - **Pod 5 presence fixes (#944, #947):** - A Pod 5 hub with a J57 cover on NATS firmware no longer shows the cover as disconnected while its frames are streaming. - Presence scores Pod 3-dialect capSense against its own calibration. - The sleep-detector drops capSense frames that NATS firmware republishes one second later. Before, these made an empty side read as moving. - Pod 5's whole-second frame timestamps no longer stop a side from ever learning what an empty bed looks like, so the #768 empty-bed vitals veto now runs on Pod 5. - **Alarms (#869, #923):** a single sleeper's alarm vibrates both sides, and each side's next alarm is published to Home Assistant over MQTT. - **Biometrics charts (#919, #921, #926):** - Movement is charted in 15-minute buckets of larger movements. - Breathing is drawn as a 15-minute rolling floor. - Adds 3D flow, movement and schedule charts and per-side piezo lanes. - **Local fit and stage models (#928, #929, #930, #927):** - Archived nights replay through local-fit with one pinned profile. - Fits rank by breathing error with REM/light separation. - Stage models are stored with modelset-v1 manifests (migration 0036 adds a nullable `stage_model_library.model_set` column). - Saved profiles rebase onto a new engine instead of falling back to defaults. - **Scripts and tooling (#943, #925, #946, #924, #922):** - The other boot slot is neutralized so a U-Boot fallback stays reachable and offline. - Archive pulls gain a `--curl` transport. - Slash-named branches no longer create Vercel demo previews. - Fixes saved-profile title layout. ## Test plan - [x] CI, Build & Package and Dev Release green on `dev` tip `3094a8c9` - [x] `dev` @ `3094a8c` running on pod .88 (Pod 5 J55): all four services active with 0 restarts, occupancy API 200, both sides read empty with 0 zones lit, right-side capacitance `absence_ready` flipped 0 → 1 - [x] Required checks green on this PR - [ ] After merge, wait for "Analyze & Release" on the `main` merge commit, then `sp-update main` on pod .88 and confirm `.git-info` matches the release
Strong bed vibration can pass piezo-only presence detection and produce vitals for an empty bed. This PR lets capacitance evidence from the sleep-detector veto those windows, while preserving independent piezo processing whenever capacitance presence is unknown.
The review found that the original gate could suppress an occupied cold start or a side with missing sensor input indefinitely. The producer now publishes explicit
vitals_presenceand per-side evidence timestamps. Absence requires a trustworthy baseline established by sustained unloading and baseline convergence; a stable initial frame alone cannot establish emptiness. Readiness survives checkpoints and adaptive-profile reuse, is cleared by reseeding, and must be paired with fresh usable readings after restart. Partial, nonfinite, missing and sentinel readings are unknown. In single-sleeper mode, absence requires valid evidence from both sides, while either side can establish presence.The reader treats legacy or malformed checkpoints and stale per-side evidence as unknown, regardless of file modification time. Unknown leaves piezo presence in control. Before the detector observes an unloading, empty-bed vibration may still pass; this is the deliberate fallback that avoids losing a sleeper's first night.
Validation: locked Python runtime dependencies; 239 common, 87 sleep-detector, and 121 piezo tests pass. Eleven integration cases use the actual detector, checkpoint writer, reader and unmocked piezo computation. They cover occupied bootstrap, missing/lost/invalid input, trustworthy empty-bed suppression, restart and profile reuse, reseeding, and merged-side behavior. TypeScript, full ESLint, both Drizzle schema checks and 2,843 related TypeScript tests also pass. No Pod deployment was performed.