Skip to content

fix(training): preview candidates safely and preserve Watch label gaps - #866

Merged
ng merged 4 commits into
devfrom
fix/personal-model-safety-1022
Oct 24, 2026
Merged

ng merged 4 commits into
devfrom
fix/personal-model-safety-1022

Conversation

@ng

@ng ng commented Oct 23, 2026 •

Copy link
Copy Markdown
Contributor

The personal-model training command stores a candidate with POST /sleep-stages/models and prints an inline-model preview. Selection requires --select (inactive) or --activate (active), after successful preview; conflicting flags are rejected. The README explains that the singular PUT replaces the selection, preserves activation, and archives both models.

Explicit unlabeled rows break Watch label segments even when the next labeled row has the same stage. Training PR sleepypod/training#11 vendors the reviewed helper byte-for-byte.

Validation: 66 script tests plus 3 subtests passed; the focused 9-test suite covers request methods/bodies, selection flags, failed preview, HTTP errors, command defaults, cleanup, and label gaps. Training-command line coverage is 98.9%; the changed label function is fully covered (the entire research helper is 19.1% in this focused suite). Both synthetic training parity pipelines pass. No model was uploaded or activated on a pod.

Mirror review: ng#34. Full review completed with no remaining findings. Merged through the dev queue.

@vercel

vercel Bot commented Oct 23, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Actions Updated
sleepypod-demo Ignored Ignored Preview Oct 23, 2026 5:19am UTC

@coderabbitai

coderabbitai Bot commented Oct 23, 2026 •

Copy link
Copy Markdown

Warning

Review limit reached

You'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.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

Learn how review limits work.

Review configuration:

⚙️ Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 52d5bfd1-d0d8-4409-9279-a67bd7e7fd52
📥 Commits

Reviewing files that changed from the base of the PR and between 09e1001 and a6eb5c4.

📒 Files selected for processing: 5
  • .github/workflows/python-modules.yml
  • docs/research/sleep-stage-calibration/README.md
  • docs/research/sleep-stage-calibration/personal-models.py
  • scripts/tests/test_personal_models.py
  • scripts/train-personal-models.py
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@codecov

codecov Bot commented Oct 23, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ All tests successful. No failed tests found.

📢 Thoughts on this report? Let us know!

@ng
ng added this pull request to the merge queue Oct 24, 2026
Merged via the queue into dev with commit 60f6093 Oct 24, 2026
17 checks passed
@ng
ng deleted the fix/personal-model-safety-1022 branch October 24, 2026 23:14
ng added a commit that referenced this pull request Oct 30, 2026
…RV and breathing references, and schedule library (#878)

Promotes `dev` to `main` with personal sleep-stage models, a heart-rate estimator that stops guessing on weak signal, beat-to-beat heartbeat detection, Watch HRV and breathing references, a schedule library, and the Next.js 16.4.3 security upgrade.

## Changes
- Personal sleep-stage models: train off the pod from the phone's feature contracts, run them on the pod, keep several per side, upload a `candidate.json` from Settings, and stage a side's nights with its model when switched on. Includes MCP tools (#855, #857–#860, #864, #866).
- Biometrics calibration on one page, with frozen dataset export and profile fitting on a laptop (#836, #837, #841).
- Heart rate: windows scoring below `heart_rate.minimumPeakScore` (default 0.4) now report no heart rate instead of a guess. In local replay this cut Watch HR error from 5.2 to 1.75 bpm on tuning nights and from 4.3 to 3.1 bpm on held-back nights, at about 75% coverage (#840).
- Beat-to-beat heartbeat detection in the piezo-processor, stored per minute in a new `heartbeats` table. Vitals are unchanged. Heartbeat retries now use bounded, ordered backoff (#848, #865).
- Apple Watch references: import breathing rate and HRV (SDNN), add a pod-vs-Watch deviation report with night-by-night charts on the calibration page, render Watch-only nights, and archive pod biometrics off the pod for long-term comparison (#842, #844, #845, #847, #867).
- Read-only analysis snapshot export (DB backup + RAW window) and MCP tool. Health export uploads are no longer truncated at 10 MB (#843, #839).
- Schedule library with switchable curves, alarm snooze length with Snooze taper, and independent tap actions for normal and while-ringing (#835, #861, #849).
- Storage: eMMC endurance card, RAM-only journal, and flash write insights with recording controls (#838, #854).
- Surface the frzWater tank level and sensHealth cover disconnects, and register `sensHealth`, `frzWater` and `lps` as known record types (#872, #877).
- Fix the internet access toggle after a reboot and the false "firewall rules missing" notice. Also fix false high TEC and slow fan warnings on an idle pod, and grant the service user journal read access (#856, #809, #801).
- Security: upgrade Next.js to 16.4.3 for three advisories and require patched Node.js in development and pod installs (#870, #868).
- Add the Europe/Bucharest timezone, update dependencies, fix the Renovate config, and kill surviving mutants (#874, #851, #853, #875, #852).

## Migrations
- Configuration DB: schedule library, stale gesture alarm field cleanup, side stage models and the active model, and alarm snooze (0028–0034).
- Biometrics DB: reference samples, heartbeats, and 0031 (0031–0033).

## Deploy note
#840 bumps the biometrics manifest to 1.1.0. Profile revisions pinned to the old manifest will report `PROFILE_INCOMPATIBLE` and must be re-proposed against the new one.

## Test plan
- [x] GitHub checks on the `dev` head (`1fbb953f`): CI, Build & Package, Dev Release, Publish OpenAPI Spec, Ref Collision Check.
- [ ] After merge, wait for "Analyze & Release" on the `main` merge commit, then `sudo sp-update main` once on a pod and confirm the service starts and migrations apply.
- [ ] Re-propose any active biometric profile against manifest 1.1.0 and confirm it applies.

🤖 Generated with [Claude Code](https://claude.com/claude-code)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant