Skip to content

fix: temp_circadian fabricated 0.0 on flat series - #76

Merged
abdulsaheel merged 1 commit into
mainfrom
fix/review-findings-2026-09-21
Sep 22, 2026
Merged

abdulsaheel merged 1 commit into
mainfrom
fix/review-findings-2026-09-21

Conversation

@abdulsaheel

@abdulsaheel abdulsaheel commented Sep 21, 2026

Copy link
Copy Markdown
Contributor

found during a full-codebase pass. _nonparam() in temp_circadian.dart was
missing the zero-variance guard circadian_np.dart already has — a flat or
heavily-quantized skin-temp window came back with IS=0.0/IV=0.0 like a real
"perfectly stable" reading instead of absent.

also left a ponytail comment on a dormant zero-baseline fallback in
ewma_baselines.dart — unreachable today (no metric has minVal <= 0) so not
worth a real fix, just flagged for later.

660 passing locally (dart test), one new regression test added.

🤖 Generated with Claude Code

Summary by Sourcery

Prevent flat temperature windows from being misreported as valid zero-valued circadian stability metrics.

Bug Fixes:

  • Return circadian nonparametric metrics as absent for zero-variance or otherwise undefined flat temperature windows instead of reporting fabricated zero values.

Tests:

  • Add regression coverage confirming nonparametric circadian results are withheld for flat temperature series.

Chores:

  • Flag the dormant zero-baseline deviation fallback for future review.

Summary by CodeRabbit

  • Bug Fixes

    • Improved circadian rhythm analysis for flat or zero-variance temperature data by withholding undefined metrics instead of reporting misleading zero values.
    • Preserved the overall wellness metric when detailed circadian calculations cannot be determined.
  • Documentation

    • Clarified baseline deviation behavior when the baseline is exactly zero.

…lat series

_nonparam divided by varTot/diffN without the zero-variance guard that
circadian_np.dart already has, so a flat or heavily-quantized skin-temp
window reported interdailyStability=0.0 / intradailyVariability=0.0 as
if measured, instead of null. Matches the sibling file's existing
`if (ssTot == 0) return absent` discipline.

Also marked the dormant zero-baseline ratio fallback in
ewma_baselines.dart with a ponytail comment — unreachable today since
every metricCfg has minVal > 0, but worth flagging before a future
metric legitimately crosses zero.

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 3 days and 23 hours by commenting @sourcery-ai review. Upgrade to get a review now.

@coderabbitai

coderabbitai Bot commented Sep 21, 2026

Copy link
Copy Markdown

Review Change StackReview Change Stack

Understand this PR’s impact

Explore downstream dependencies and potential security impact with Blast Radius.

View blast radius →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Advanced

Run ID: b64de652-4a07-428e-8b73-8a134061205d

📥 Commits

Reviewing files that changed from the base of the PR and between 01e8b6e and 0c19d86.

📒 Files selected for processing (3)
  • lib/src/onehz/foundations/ewma_baselines.dart
  • lib/src/onehz/wellness/temp_circadian.dart
  • test/onehz/wellness_test.dart

Included review availability: Your plan provides up to 1 included review per hour; 0 remain after this review.


📝 Walkthrough

Walkthrough

The change treats flat temperature data as undefined for nonparametric circadian metrics, adds regression coverage, and documents zero-baseline behavior in EWMA calculations.

Changes

Metric handling

Layer / File(s) Summary
Circadian zero-variance handling
lib/src/onehz/wellness/temp_circadian.dart, test/onehz/wellness_test.dart
_nonparam returns null when variance or consecutive-difference energy is zero. The test verifies that the overall metric remains available while nonparametric metrics remain absent.
EWMA baseline documentation
lib/src/onehz/foundations/ewma_baselines.dart
Documentation describes the 0.0 ratio fallback for an exactly zero baseline and the current constraint that prevents update from creating that baseline.

Priority: ⬇️ Low

Estimated code review effort: 1 (Trivial) | ~5 minutes

Change: Bug fix

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the main change: preventing fabricated 0.0 values in temp_circadian for flat temperature series.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff. Analyzed 0 functions across 0…
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.

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.

@sourcery-ai

sourcery-ai Bot commented Sep 21, 2026

Copy link
Copy Markdown

Reviewer's Guide

The PR fixes temp circadian analysis so flat or quantized windows produce an absent nonparametric result rather than fabricated IS/IV values of 0.0, adds regression coverage, and documents an unrelated dormant zero-baseline fallback for future review.

Flow diagram for flat temperature circadian handling

flowchart TD
    A[Temperature window] --> B["_nonparam()"]
    B --> C[Compute total variance and difference energy]
    C --> D{varTot == 0 or diffN == 0?}
    D -- Yes --> E[Return absent CircadianNonparam]
    D -- No --> F[Compute IV and IS]
    F --> G[Return CircadianNonparam]
Loading

File-Level Changes

Change Details Files
Withhold nonparametric circadian metrics when the input window has no usable variance.
  • Return null before IS/IV normalization when total variance or consecutive-difference data is unavailable.
  • Remove zero-valued fallback branches that misrepresented undefined divisions as stable readings.
  • Align the guard behavior with the existing nonparametric circadian implementation.
lib/src/onehz/wellness/temp_circadian.dart
Add regression coverage for flat temperature series.
  • Verify a zero-variance multi-day ADC series leaves the nonparametric result absent while the overall metric remains present.
test/onehz/wellness_test.dart
Document a dormant zero-baseline ratio fallback for future follow-up.
  • Flag the silent ratio=0 behavior as unreachable with current positive metric ranges and recommend making the ratio nullable if zero-crossing metrics are introduced.
lib/src/onehz/foundations/ewma_baselines.dart

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

@abdulsaheel
abdulsaheel merged commit 0441ef9 into main Sep 22, 2026
4 checks passed
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