Skip to content

round 3: hr ceiling corroboration bug + doc cleanup - #57

Closed
abdulsaheel wants to merge 1 commit into
audit/fixes-round2-analyticsfrom
audit/fixes-round3-analytics
Closed

round 3: hr ceiling corroboration bug + doc cleanup#57
abdulsaheel wants to merge 1 commit into
audit/fixes-round2-analyticsfrom
audit/fixes-round3-analytics

Conversation

@abdulsaheel

@abdulsaheel abdulsaheel commented Aug 29, 2026

Copy link
Copy Markdown
Contributor

fixes the round-2 finding that the burst-corroboration check only looked at the current trailing 3s window, so a burst at the start of a hold (or anywhere before a quiet tail) got dropped once the window swept past it. now tracks the best trailing average over the whole span. added two tests for it.

also cleaned up docs that drifted from deleted code (edwards trimp, dailyStepEstimate, sleepRegularityIndex, vo2maxEstimate/physiologicalAge), linked the 1hz catalog doc from ALGORITHMS.md, fixed the stale test count line, and swapped a hand-rolled mean/stddev in advanced_stager for the shared util helpers.

Summary by Sourcery

Ensure heart-rate ceiling detection retains corroboration from anywhere in a qualifying hold while aligning documentation and statistical calculations with the current implementation.

Bug Fixes:

  • Preserve qualifying heart-rate corroboration bursts throughout the hold span so bursts followed by a quiet tail are not missed.

Enhancements:

  • Use shared mean and population-standard-deviation utilities in advanced sleep staging.

Documentation:

  • Update algorithm documentation and catalog entries to remove deleted methods and outdated TRIMP references, link the 1 Hz catalog, and remove the stale test count.

Tests:

  • Add coverage for corroboration bursts at the start of a hold and in the middle of a hold followed by a quiet tail.

burst corroboration only looked at the current trailing window so a burst
early in a hold got forgotten once the window swept past it. now tracks
the best trailing average seen over the whole span. added tests for
start-edge and mid-window bursts.

also cleaned up ALGORITHMS.md/catalog docs that still cited deleted
functions (edwards trimp, dailyStepEstimate, sleepRegularityIndex,
vo2maxEstimate/physiologicalAge), linked the 1hz catalog from
ALGORITHMS.md, fixed the stale test count in README, and swapped the
hand-rolled mean/stddev in advanced_stager's zfun for the shared helpers.
@sourcery-ai

sourcery-ai Bot commented Aug 29, 2026

Copy link
Copy Markdown

Reviewer's Guide

Fixes HR-ceiling corroboration by remembering the strongest trailing activity average throughout each qualifying hold, with regression tests for early and mid-span bursts. The PR also removes stale documentation entries, links the 1 Hz algorithm catalog, updates the test-count wording, and standardizes sleep-stager statistics on shared utilities.

Flow diagram for HR ceiling burst corroboration

flowchart LR
    A[Start hold at i] --> B[Extend through contiguous HR rows]
    B --> C[Update trailing activity window]
    C --> D[Compute trailAvg]
    D --> E[Keep bestTrail maximum]
    E --> F{Hold duration qualifies?}
    F -- No --> B
    F -- Yes --> G{bestTrail >= gate?}
    G -- Yes --> H[Record HrCeiling using sustained lo]
    G -- No --> I{Within maxSpanMs?}
    I -- Yes --> B
    I -- No --> J[Reject hold]
Loading

File-Level Changes

Change Details Files
Preserve corroborating activity bursts across the full sustained-HR span instead of only the current trailing window.
  • Track the maximum trailing-window acceleration average as the span advances.
  • Use the retained maximum to qualify HR ceilings after the hold duration.
  • Add regression coverage for bursts at the hold start and mid-span followed by quiet tails.
lib/src/onehz/workout/observed_max_hr.dart
test/onehz/observed_max_hr_test.dart
Remove stale algorithm documentation and align published catalogs with the implemented API.
  • Delete entries for removed Edwards TRIMP, daily step estimate, sleep regularity, VO2max, and physiological-age APIs.
  • Document the remaining active-minutes metric and Banister-only TRIMP.
  • Link the 1 Hz algorithm catalog from the main index and remove outdated test totals.
ALGORITHMS.md
docs/ALGORITHM_CATALOG_1HZ.md
README.md
Reuse shared statistical utilities in advanced sleep staging.
  • Replace local population mean and standard-deviation calculations with shared mean and stddevPop helpers while preserving zero-variance handling.
lib/src/onehz/sleep/advanced_stager.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

@coderabbitai

coderabbitai Bot commented Aug 29, 2026

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: b3cada3b-c578-4a80-854d-54c2f5ff6551

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

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

Hey - I've reviewed your changes and they look great!

Sourcery assessment

Approved.


Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

@abdulsaheel

Copy link
Copy Markdown
Contributor Author

squashed into #59 for one clean review — closing this round.

@abdulsaheel
abdulsaheel deleted the audit/fixes-round3-analytics branch August 29, 2026 13:16
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