Skip to content

feat(calories): price sub-gate walking minutes from measured cadence (CADENCE-Adults) - #52

Open
DropTabl wants to merge 1 commit into
OpenStrap:mainfrom
DropTabl:feat/walking-cadence-energy
Open

feat(calories): price sub-gate walking minutes from measured cadence (CADENCE-Adults)#52
DropTabl wants to merge 1 commit into
OpenStrap:mainfrom
DropTabl:feat/walking-cadence-energy

Conversation

@DropTabl

Copy link
Copy Markdown

The gap

MOT-02 raised the HR-flex gate to the ACSM moderate floor and its own changelog measured the cost: billed wake minutes fell to 4.9%, median daily active energy to 48 kcal. That was the right call for HR — Keytel has no fitted data below the exercise domain — but it left walking priced at zero: a one-hour walk at 95 bpm adds nothing to Active energy for its entire duration. This is now a user-facing bug report on edge ("Walking calories are not counted": the workout and steps record fine, Active Calories never move). MT-05 already established the 1 Hz accel channel cannot fill this gap (Brage's branches can't read a 1 Hz gravity vector).

The fix

Measured cadence is the one signal on this platform that actually resolves gait — the 100 Hz pedometer — and CADENCE-Adults (Tudor-Locke et al. 2019, IJBNPA 16:8) publishes the cadence↔MET line for exactly this region: heuristic thresholds 100/110/120/130 steps/min ↔ 3/4/5/6 METs.

Calories.dailyEnergy gains an optional cadenceSpmPerMin series, index-aligned with hrPerMin (null = nobody measured that minute):

  • A minute the HR gate accepts bills by HR alone, exactly as before — a minute is never billed twice.
  • A minute the HR gate refuses (below flex, or no HR at all — measured gait stands on its own), whose measured cadence is at/above the study's own moderate floor, bills (MET − 1) basal-minutes of surplus via the new metFromCadenceSpm — linear between the published anchors, clamped at both ends of the fitted range: under 100 spm the study does not price it (the same "only exercise-domain minutes bill" philosophy the HR gate already holds); over 130 spm is running, which drives HR over the gate and bills there.
  • The result record gains a walking component (already folded into active) so callers can disclose how much of the day came from measured walking.
  • No cadence series → byte-identical behaviour to today. Misaligned series throws; unusable anchors still abstain, cadence or not.

ALGORITHMS.md gets the row + citation.

Numbers

80 kg / 180 cm / 30 y male (Mifflin 1780 kcal/day): a one-hour walk at 110 spm bills 60 × 3 × 1.24 ≈ 222 kcal of walking surplus — previously 0.

Tests

New walking cadence term (CADENCE-Adults) group: the published MET anchors and clamps, the reported below-gate walk billing, the no-double-billing invariant, unmeasured/ambling/non-finite minutes staying basal, gait-on-off-skin-HR minutes billing, misalignment throwing, and anchor abstention unchanged. dart analyze clean; full suite green (591 tests).

Edge side (per-minute cadence from live_coverage, threading through wakeDayEnergy and the pipeline mirror, kAlgoVersion bump + pin) follows as a draft PR on OpenStrap/edge once this lands.

🤖 Generated with Claude Code

https://claude.ai/code/session_015TxisrChNFxtVMXFFNRGtV

…(CADENCE-Adults)

MOT-02 knowingly traded walking away: the HR-flex gate bills nothing below
the ACSM moderate floor because Keytel has no fitted data there, so a walk at
95 bpm added ZERO active kcal for its entire duration (edge report: "Walking
calories are not counted" — the workout and its steps record fine, Active
energy never moves). MT-05 established the 1 Hz accel cannot fill that gap.

Measured cadence can: it is the one signal on this platform that actually
resolves gait (the 100 Hz pedometer), and CADENCE-Adults (Tudor-Locke et al.
2019, IJBNPA 16:8) publishes the cadence↔MET line for exactly this region —
heuristic thresholds 100/110/120/130 steps/min for 3/4/5/6 METs.

dailyEnergy gains an optional cadenceSpmPerMin series, index-aligned with
hrPerMin (null = nobody measured that minute — which is most minutes; the
pedometer only runs while the phone holds the live link):

- A minute the HR gate accepts bills by HR alone, exactly as before. HR sees
  intensity cadence cannot, and a minute is never billed twice.
- A minute the HR gate refuses (below flex, or no HR at all — measured gait
  stands on its own), whose measured cadence is at/above the study's own
  moderate floor (100 spm), bills (MET − 1) basal-minutes of surplus via the
  new metFromCadenceSpm — linear between the published anchors, clamped at
  both ends of the fitted range (under 100 spm the study does not price it;
  over 130 spm is running, which drives HR over the gate and bills there).
- The result record gains a `walking` component (already included in
  `active`) so callers can disclose how much of the day's active energy came
  from measured walking rather than HR.
- No cadence series → byte-identical behaviour to before.
- Misaligned series throws; unusable anchors still abstain, cadence or not.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_015TxisrChNFxtVMXFFNRGtV
@coderabbitai

coderabbitai Bot commented Aug 25, 2026

Copy link
Copy Markdown

Important

  • 🔍 Trigger review

This repository does not receive automatic reviews because it has fewer than 10 stars.

⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 9e7d0187-3302-400a-9148-80d7f95635a0


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.

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