Repository navigation
refactor(effort): resolve the day's HRmax in one place (#2438) - #1
Open
bartmuskala wants to merge 1 commit into
Open
bartmuskala wants to merge 1 commit into
bartmuskala wants to merge 1 commit into
Conversation
The HRmax a day's Effort is scored against ("manual override, else Tanaka
from age, else the default") was written out by hand at six call sites
across Swift and Kotlin. Two such copies had already dropped the override
(ryanbr#2460). Step 0 of ryanbr#2438 changes what the effective HRmax means, so every
reader has to change together.
- Add StrainScorer.effortHRmax(override:age:) and its Kotlin twin, returning
the value and its source (override / tanaka / default).
- Route AnalyticsEngine (both), DayCycleIntelligenceIntegration,
PhysiologicalStepCycleEngine, TodayScreen and ProfileStore.effortHRmax
through it. The effort calib line's src field now comes from the same
call instead of a second hand-written branch.
- Tools/test_effort_hrmax_resolver.py fails on any new hand-written
override-else-formula fallback in product source, and asserts each
day-Effort reader names the resolver.
- Refresh the parity authority for the new twin pair (226 -> 227).
No scoring change: the resolver returns exactly what each replaced
expression returned. No recipe bump, no rescore.
Refs ryanbr#2438, ryanbr#2460
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
refactor(effort): resolve the day's HRmax in one place (ryanbr#2438)
What this PR does
Prepares ryanbr#2438 step 0 without changing any score.
The HRmax a day's Effort is scored against ("manual override, else Tanaka from age, else the default") was written out by hand at six call sites. Two such copies had already dropped the override, which became ryanbr#2460. In the thread, @ryanbr noted that step 0 changes what "the effective HRmax" means, so every one of these sites has to move together or they drift apart. This PR gives them one place to move.
StrainScorer.effortHRmax(override:age:)(Swift) andStrainScorer.effortHRmax(override, age)(Kotlin). Each returns the value and its source:override,tanakaordefault.AnalyticsEngineon both platforms,DayCycleIntelligenceIntegration,PhysiologicalStepCycleEngine,TodayScreen.ktandProfileStore.effortHRmax(which the two iOS Today views already read since ios: score today's Effort against the same HRmax as the day it belongs to (#2460) ryanbr/noop#2461).src=field on theeffort calibline (feat(diag): name the day's HRmax source and its observed peak (#2438) ryanbr/noop#2459) now comes from the same call that produces the HRmax, instead of a second hand-written branch beside it. The value and its label can no longer disagree.Tools/test_effort_hrmax_resolver.py. The existingEffortHRmaxOverrideTestsheader says plainly that it cannot see the view call sites, so a hand-rolled Tanaka in a view would leave it green. This guard closes that gap from source, following AGENTS.md's "assert the single resolver":Tools/parity_twin_map.json). The new resolver registers as a twin pair: function pairs 226 → 227.Not a scoring change. The resolver returns exactly what each replaced expression returned, so there is no recipe bump, no rescore, and
docs/VALIDATION_PROTOCOL.mddoes not apply.Type of change
How it was tested
linux-capture): the fullTools/suite passes (346 tests), including the new guard andtest_parity_governance_acceptance.doc_comment_lintandparity_ledgerreport nothing new.main: run againstmain's copies of the six routed files, it flags every original hand-written site (AnalyticsEngine.swift 920/943, AnalyticsEngine.kt 832/864, DayCycleIntelligenceIntegration 203, PhysiologicalStepCycleEngine 219, TodayScreen 1042, Profile 203). It passes on this branch.StrainScorer.ktwas compiled standalone (kotlinc 2.0.21) and run over the shared case table, plus 100 ages againsttanakaHRmax. It was also checked for exact==equality against the old hand-written expression, value and source, on a 5 × 8 grid of overrides and ages that includes negative, zero and fractional ages.EffortHRmaxResolverTests.swiftandEffortHRmaxResolverTest.ktcarry the same literal case table, so each platform guards the other.swift-packages,app-build,android). The Swift change is small: one function, plus three call sites that now destructure a labelled tuple.Checklist
StrandDesigntokens: no UI changesdocs/CONTRIBUTING.md(both platforms in one PR, per the parity contract)Out of scope, and found while doing this
The audit for this PR found HRmax resolved in more places than the six listed in the thread. These sites score workouts, not days. Routing them through the resolver would change stored values, so they are left alone here and proposed as a separate issue (draft attached to this PR's discussion):
ProfileStore.hrMax. That value rounds Tanaka to an Int and returns 208 for an age-less profile, so a manual workout and an auto-detected bout in the same day use different HRmax values.Double(profile.hrMax)on Swift (IntelligenceEngine.swift,rescoreManualWorkouts) but the unrounded208.0 - 0.7 * profile.ageon Kotlin (IntelligenceEngine.kt:2334, whose comment says it matchesendWorkout; it does not). The two platforms can store different Effort values for the same manual workout. That site is the one named exemption in the guard, with this reason attached.Refs ryanbr#2438, ryanbr#2460