Skip to content

quantum guard vs averaged rhr, glassbox narrative direction - #83

Merged
abdulsaheel merged 4 commits into
mainfrom
fix/sweep-r3-analytics-main-1
Oct 3, 2026
Merged

abdulsaheel merged 4 commits into
mainfrom
fix/sweep-r3-analytics-main-1

Conversation

@abdulsaheel

@abdulsaheel abdulsaheel commented Oct 2, 2026 •

Copy link
Copy Markdown
Contributor

dispersionBelowQuantum treated nightly rhr as whole bpm, but nocturnalRhr gives a 30-min mean so it's continuous. a tight real baseline (sd under 1 bpm) got rhr refused from readiness on the night it rose, same for illness/anomaly/event/overreaching. guard now only fires when the baseline actually sits on the quantum grid, integer baselines behave as before.

glassbox narrative took up/down from the oriented contribution so a lower rhr read as "up". uses the raw delta now, and the low band says "a low-readiness day" instead of telling people to take it easy.

edge needs an algo bump when it repins this.

Summary by Sourcery

Refine readiness dispersion guards and glassbox narratives to correctly handle continuous averaged metrics and report driver direction accurately.

Bug Fixes:

  • Preserve readiness inputs from tight, genuinely continuous averaged baselines while retaining quantum-dispersion protection for mostly quantized histories.
  • Correct readiness narratives to describe metric movement using raw deltas, including lower-is-better metrics such as resting heart rate.
  • Use non-prescriptive wording for the low-readiness narrative band.

Enhancements:

  • Add coverage for continuous and mixed baseline dispersion behavior and raw-direction narrative generation.

Tests:

  • Add regression tests covering averaged RHR baselines, mixed quantized histories, and readiness narrative direction and wording.

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

@coderabbitai

coderabbitai Bot commented Oct 2, 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 48 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
  • Configuration used: Organization UI
  • Review profile: ASSERTIVE
  • Plan: Advanced
  • Run ID: dd942118-68ef-47ad-9ef5-b021974d19cf
📥 Commits

Reviewing files that changed from the base of the PR and between f548542 and ffb7805.

📒 Files selected for processing (4)
  • lib/src/onehz/foundations/baseline.dart
  • lib/src/onehz/human/readiness_glassbox.dart
  • test/dispersion_guard_test.dart
  • test/onehz/human_test.dart
  • Autopilot · 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.

@sourcery-ai

sourcery-ai Bot commented Oct 2, 2026

Copy link
Copy Markdown

Reviewer's Guide

The PR differentiates continuous averaged physiological baselines from quantized whole-unit data before applying the dispersion refusal guard, preventing valid RHR inputs from being excluded, and corrects glassbox narratives to report raw metric direction with less prescriptive low-readiness language.

Sequence diagram for raw-direction glassbox readiness narrative

sequenceDiagram
    participant Inputs
    participant Readiness as glassBoxReadiness
    participant Narrative as _buildNarrative
    Inputs->>Readiness: collect metric delta
    Readiness->>Readiness: create _RawItem with delta
    Readiness->>Readiness: rank drivers by contribution
    Readiness->>Narrative: _buildNarrative(score, drivers, topDelta)
    Narrative->>Narrative: choose direction from topDelta
    Narrative-->>Readiness: readiness narrative
Loading

Flow diagram for the quantum dispersion guard

flowchart TD
    A[Baseline values] --> B{All values sit on quantum grid?}
    B -->|No| C[Accept continuous baseline dispersion]
    B -->|Yes| D[Compute standard deviation]
    D --> E{SD below quantum?}
    E -->|Yes| F[Refuse baseline for readiness]
    E -->|No| G[Accept baseline]
    C --> H[Use physiological input in readiness]
    G --> H
Loading

File-Level Changes

Change Details Files
Restrict the low-dispersion refusal guard to genuinely quantized baselines.
  • Detect any baseline value that is off the quantum grid and bypass the quantization guard.
  • Preserve existing refusal behavior for integer/grid-aligned baselines.
  • Add coverage for continuous averaged RHR baselines and ensure RHR remains usable in readiness scoring.
lib/src/onehz/foundations/baseline.dart
test/dispersion_guard_test.dart
Make readiness narratives describe raw metric movement and use non-prescriptive low-readiness wording.
  • Carry each input's raw delta through driver selection.
  • Use the highest-ranked significant driver's raw delta for up/down wording instead of oriented contribution.
  • Rename the low score band to “A low-readiness day” and verify lower-is-better RHR direction and wording.
lib/src/onehz/human/readiness_glassbox.dart
test/onehz/human_test.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 c21a038 into main Oct 3, 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