Repository navigation
feat: Heavy Deload scales AMRAP sets from last session reps (issue #1408) - #1410
Conversation
Heavy Deload previously left AMRAP sets untouched (null setReps entries are not scaled), so the deload had no effect on them. Eligible exercises (not bodyweight, not timed-cable) now convert each AMRAP set into a session-only fixed-rep set at scaleReps(R, P) where R is the achieved reps of the most recent completed AMRAP-typed set for the same exercise (profile-scoped, latest logical attempt; precedence same routine-exercise + set slot, then same routine-exercise, then any). 10 AMRAP reps at 60% -> 6 reps, weight unchanged. Without AMRAP history the set stays AMRAP and unchanged; bodyweight and timed-cable rows keep today's exact output. The routine template is never mutated and deloaded sets record as STANDARD, so no history feedback loop.
Verification evidence (implementation stage)Local gates (host: macOS, Android SDK + JDK 21):
CI status — one failure, PRE-EXISTING ON MAIN, not caused by this PR:
Evidence it is pre-existing: main's own CI run on this PR's exact base commit The one-line fix (bump the ratchet |
CI follow-up: pre-existing
|
Merge gate: merged ✅PR #1410 was squash-merged to What changed: When Heavy Deload is on, each AMRAP set on a weighted cable exercise now becomes a fixed-rep set for that session only. Its rep target is your reps from the most recent AMRAP set for that exercise, times the deload percent. For example, 10 reps at 60% gives 6 reps, and the weight stays the same. If there is no AMRAP history, the set stays AMRAP with no change. Bodyweight and timed exercises are not affected, and the saved routine is never modified. Gate audit (head
|
Heavy Deload scales AMRAP sets from last session's reps (#1408)
Fixes #1408
Problem
When a routine launches with Heavy Deload at P%, working reps are cut to the offered percentages — but AMRAP sets have no programmed reps to cut, so they passed through the deload transform untouched (null
setRepsentries are never scaled).Behavior (reporter's example: 45 lb curls, AMRAP 10 reps last week, Heavy Deload 60%)
scaleReps(R, P), whereR= the achieved reps of the most recent completed AMRAP-typed set for the same exercise (profile-scoped, latest logical attempt). 10 reps × 60% = 6 reps, weight unchanged.STANDARD, so deload history can never feed back into later deloads.(reps * percent / 100).roundToInt().coerceAtLeast(1)— 7 × 60% → 4; 1 × 10% → 1.Scope
Per the signed-off design (
signoff.md,implementation-spec.md): diff limited to exactly 3 files.ApplyRoutineModifierUseCase.kt—applyHeavyDeloadbecomessuspend+profileId; one bounded history lookup per exercise per launch (getRecentCompletedSetsForExercise, limit 50, filtered toSetType.AMRAP && actualReps > 0). No schema/SQL/sync/DI/UI/portal change, no feature flag, no try/catch.ApplyRoutineModifierUseCaseTest.kt— 11 new Kotlin/Native-safe test cases (conversion, no-history fallback, flag clearing on copy only, placeholder semantics, reference precedence, STANDARD/zero-rep filtering, profile isolation, bodyweight/timed exclusion, rounding, single query per exercise, Active Recovery reads no history).testutil/FakeCompletedSetRepository.kt— the fake now honorsprofileIdand records history-query calls.Accepted limitations (documented in KDoc): Active Recovery AMRAP rows may serve as a reference; history beyond the 50 most recent sets of an exercise is not consulted.
Verification
./gradlew -Pskip.supabase.check=true :shared:testAndroidHostTest --tests '…ApplyRoutineModifierUseCaseTest' --tests '…DWSMWorkoutLifecycleTest'— 281 tests, 0 failures (32 in ApplyRoutineModifierUseCaseTest incl. the 11 new; 249 in DWSMWorkoutLifecycleTest, all pre-existing cases unchanged)../gradlew -Pskip.supabase.check=true :shared:compileTestKotlinIosArm64— BUILD SUCCESSFUL (backtick test names are KN-safe).Release note (from user-instructions.md)
Design artifacts:
~/.hermes/phoenix-enhancements/issue-1408-1572315372235923557/(implementation-spec.md,user-instructions.md). No UI change (ui_required=false), so no visual evidence is required for this PR.