Skip to content

crossday: chronotype pairing + sri on the lived clock - #892

Merged
abdulsaheel merged 1 commit into
mainfrom
fix/auto-crossday-chrono-sri
Nov 21, 2026
Merged

abdulsaheel merged 1 commit into
mainfrom
fix/auto-crossday-chrono-sri

Conversation

@abdulsaheel

@abdulsaheel abdulsaheel commented Nov 21, 2026 •

Copy link
Copy Markdown
Collaborator

two crossday bugs.

  • a free night with a sleep window but no tst added its mid-sleep to chronotype but not its duration, so the lists went unequal and chronotype refused for the whole 90 day window. chronotype now only gets free nights that have both (social jetlag still uses every mid-sleep).
  • the sri grid binned hypnogram minutes on the phone's current zone, so after a trip every earlier night shifted against the later ones and read as irregular. it now uses _nightClockMin (clock_shift_sec), same as mid-sleep and the other cross-day clocks.

tests for both, red before the fix.

Summary by Sourcery

Fix cross-day chronotype pairing and sleep regularity calculations across incomplete sleep data and time-zone changes.

Bug Fixes:

  • Prevent chronotype analysis from rejecting the full observation window when a free night has a sleep window but no total sleep time.
  • Calculate sleep regularity using each night’s lived clock across time-zone changes, avoiding false irregularity after travel.

Tests:

  • Add regression coverage for incomplete free-night chronotype data and sleep regularity across a time-zone change.

Summary by CodeRabbit

  • Bug Fixes
    • Chronotype calculations now exclude free nights without available duration while keeping mid-sleep and duration values aligned. Social jetlag calculations continue to use all available free-night mid-sleeps.
    • Cross-day sleep segments now use the recorded night’s time zone rather than the phone’s current time zone.

@sourcery-ai

sourcery-ai Bot commented Nov 21, 2026

Copy link
Copy Markdown

Sorry @abdulsaheel, you've used your own review budget of 250,000 diff characters for the last 7 days.

You can request another review in 4 days and 6 hours by commenting @sourcery-ai review. Upgrade to get a review now.

@sourcery-ai

sourcery-ai Bot commented Nov 21, 2026

Copy link
Copy Markdown

Reviewer's Guide

Implementation

Keep chronotype midsleep and duration inputs paired by excluding free nights without TST, while leaving social jetlag's midsleep inputs unchanged.

  • lib/compute/crossday_pipeline.dart L202-205, L225-228, L237

Bin SRI hypnogram segments using the clock on which each night was lived, accounting for clock shifts after travel.

  • lib/compute/crossday_pipeline.dart L1287-1292

Tests

Verify that a free night with a sleep window but no TST no longer prevents chronotype from being computed.

  • test/crossday_pipeline_test.dart L639-650

Verify that nights with matching sleep schedules across a time-zone change produce regularity on the lived clock.

  • test/crossday_pipeline_test.dart L651-683

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@coderabbitai

coderabbitai Bot commented Nov 21, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

The cross-day pipeline now pairs free-night mid-sleep times with available durations for chronotype, while social jetlag continues to use all available free-night mid-sleep times. SRI hypnogram segment bounds now use the clock recorded for each night.

Changes: Cross-day sleep calculations

Layer / File(s) Summary
Pair chronotype inputs
lib/compute/crossday_pipeline.dart
Chronotype receives mid-sleep times only for free nights with an available duration. Social jetlag continues to use all available free-night mid-sleep times.
Map SRI bounds to recorded clock
lib/compute/crossday_pipeline.dart
SRI hypnogram segment bounds use each night’s recorded clock instead of the phone’s current local clock.

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix

Possibly related PRs

  • OpenStrap/edge#624: Adds the per-night clock_shift_sec value used by this change to map SRI minutes to the recorded clock.

Suggested reviewers: droptabl

Merge Risk: Minimal · up to c3259

This change keeps chronotype inputs aligned when a free night has no total sleep time, and it computes SRI on the clock the user actually lived. No merge-blocking risk was found.

Pre-merge checks: Passed 4

Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title names both changes in the PR: chronotype calculation now pairs free-night mid-sleep with duration, and the SRI hypnogram binning uses the lived (recorded) clock. It is short and specific to …
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Title check

Explanation

The title names both changes in the PR: chronotype calculation now pairs free-night mid-sleep with duration, and the SRI hypnogram binning uses the lived (recorded) clock. It is short and specific to the crossday pipeline, so it matches the main changes.

Finishing Touches

Generate unit tests (beta)

  • Commit to this branch
  • Create a new PR
  • 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

Recent review info

Run configuration

Commits

Reviewing files that changed from the base of the PR and between da831bd and c325965.

Files ignored due to path filters: 1

  • test/crossday_pipeline_test.dart is excluded by !test/**
Files selected for processing: 1

  • lib/compute/crossday_pipeline.dart

Included review availability: This review used your included allowance. Your plan provides up to 4 included reviews per hour; 2 remain after this review.

@github-actions

Copy link
Copy Markdown
Contributor

Failed to generate code suggestions for PR

@abdulsaheel
abdulsaheel merged commit 67a8cf6 into main Nov 21, 2026
9 of 10 checks passed
mikenrafter added a commit to mikenrafter/edge that referenced this pull request Nov 22, 2026
Merge OpenStrap/edge main @ 0939435
(124 commits since merge-base 7a9f3ed) into fork integrate/next @
d759096.

- Preserve fork schemaVersion 95 (upstream stayed at 62), sibling pins,
  split-part file structure, BundleStore, no-install boundaries, and
  single-log DevLog architecture.
- Bump kAlgoVersion 126 -> 127 covering upstream OpenStrap#631/OpenStrap#899 stress rescale,
  OpenStrap#898 hybrid HMM staging provenance/flags, OpenStrap#892 cross-day SRI clock fix,
  and OpenStrap#797 compact night checkpoints.
- Adopt upstream OpenStrap#896 layout-shift test harness consolidation under
  test/support/ and remove duplicate lib/layout_shift/.
- Merge l10n .arb catalogs (8 locales), BLE/sync/state/DB/repo/coach/ECG
  fixes, and UI2 reliability/accessibility/localization updates.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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