Skip to content

Feature: Apply deload percentages to AMRAP sets using last session's reps #1408

Closed

Description

@9thLevelSoftware

Summary

  • Reporter: shredness_10860 (Discord)
  • Type: Enhancement (feature request)
  • Repo: 9thlevelsoftware/project-phoenix-mp (mobile)
  • Source: Discord #feature-requests, thread 1572315372235923557

When a routine is set to a heavy deload, the app scales work by cutting set reps to the offered deload percentage while leaving weight unchanged. For exercises programmed as AMRAP there are no prescribed reps to cut, so the deload percentage cannot be applied and the set effectively stays the same. The reporter requests that deload percentages be applied to AMRAP sets by scaling the reps achieved in the last session instead of the (nonexistent) programmed rep target.

Request details

  • Trigger: select a routine, set it to heavy deload at one of the offered percentages (e.g. 60%).
  • Current behavior for fixed-rep sets: weight stays the same, reps are cut to the offered percentage.
  • Problem: for AMRAP exercises there is no programmed rep count to cut, so the percentage has no effect on the set.
  • Suggested behavior: take the reps from the last session and set the percentage against that number.
  • Reporter's example: "I curled 45lbs at AMRAP for 10 reps the week before. I select the same routine, set it for heavy DELOAD at 60%, the app would set the exercise for six reps." (10 reps x 60% = 6 reps; weight stays 45 lbs.)

Expected behavior

Deload percentages apply to every exercise in the routine, including AMRAP sets. Example: heavy deload at 60% on an exercise whose last session AMRAP set was 45 lbs x 10 reps programs 45 lbs x 6 reps.

Actual behavior

Deload only cuts programmed reps. AMRAP sets have no programmed reps, so the deload percentage is not applied and the set is unchanged from the previous session.

Impact / notes

  • Users who program AMRAP sets (a common progression tool) cannot use the deload feature on those exercises.
  • Assumption: "last session" means the most recent completed session containing that exercise. Where no prior session exists there is no scaling source; implementation should define fallback behavior (e.g. leave the AMRAP set unscaled when no history exists).
  • Assumption: deload continues to leave weight unchanged and scales reps only, matching the reporter's example.
  • Scope: mobile app routine/deload logic (routine selection -> deload percentage application).

Attachments

No attachments recorded.

Original Discord Report

<@&1509574103043145931> When setting a routine to heavy deload, weight remains the same but set reps are cut to the offered percentages. However, if exercise is set to AMRAP there are no reps to cut. Suggestion: take reps from last session and set percentage against that number. For example, I curled 45lbs at AMRAP for 10 reps the week before. I select the same routine, set it for heavy DELOAD at 60%, the app would set the exercise for six reps.

Discord-Message-ID: 1572315372235923557

Activity

  1. 9thLevelSoftware commented on Nov 17, 2026

    @9thLevelSoftware
    OwnerAuthor

    Feasibility assessment — ACCEPT ✅

    Verdict: accept (feasible, contained, high user value). Artifact: feasibility.md in the enhancement evidence dir.

    Confirmed gap (code evidence at origin/main 6f95247): ApplyRoutineModifierUseCase.applyHeavyDeload scales only non-null setReps entries — AMRAP sets (null setReps entries) pass through the deload transform untouched, so the percentage has no effect on them. Exactly as reported.

    Why feasible: achieved-reps history is already first-class (CompletedSetRepository.getRecentCompletedSetsForExercise, CompletedSet.actualReps), the use case is already suspend and already receives the completed-set repository, and the modifier is a non-persisted launch-time transform — so the change is contained to one use case + its existing unit-test file.

    Planned semantics (assumptions, per the reporter's example):

    1. "Last session" = most recent completed working sets for that exercise (latest logical attempt).
    2. Weight unchanged; reps scaled — 10 AMRAP reps x 60% = 6 reps.
    3. The deloaded session programs the scaled count as the set's rep target; the stored routine is not modified.
    4. No history -> the AMRAP set stays unscaled (nothing to scale from).
    5. Scope: mobile app only (project-phoenix-mp), no portal/schema/sync changes.

    Rough effort: 1-2 bounded implementation packets (~0.5-1.5 days), implementation + unit tests.

    Routing next to architecture/integration modelling on the enhancement board.

  2. 9thLevelSoftware commented on Nov 17, 2026

    @9thLevelSoftware
    OwnerAuthor

    Architecture — #1408 Heavy Deload for AMRAP sets (stage: architecture ✅)

    Code baseline: origin/main 6f95247. Full design: architecture.md in the enhancement artifact dir.

    Behavior: when Heavy Deload at P% is applied at launch, each AMRAP set (a null setReps entry, or the last set when the exercise-level isAMRAP flag is on) uses the reps from the user's most recent completed AMRAP set for that exercise and profile. That number is scaled with the existing scaleReps, and the set becomes a fixed-rep set for this session only. Example: 10 reps × 60% = 6 reps at the same weight. If there is no AMRAP history, the set stays AMRAP and unchanged. The routine template is never modified.

    Reference set: CompletedSetRepository.getRecentCompletedSetsForExercise. This already uses the latest logical attempt, is profile-scoped, and excludes deleted sessions. It is filtered to setType == AMRAP && actualReps > 0, preferring same routine-exercise + set number, then same routine-exercise, then any. Deloaded sets now run and record as STANDARD, so a deload's reduced reps can never become the next "last session" (no feedback loop, no schema change). The design deliberately does not filter on routineModifierApplied: migration 62 marks all pre-upgrade sessions as "unknown → applied", and filtering on it would disable the feature for the first cycle after the update.

    Scope: only ApplyRoutineModifierUseCase changes: applyHeavyDeload becomes suspend and receives profileId. No change to the repository/SQL, DI, RoutineFlowManager, schema, sync, portal or UI, and no feature flag. Bodyweight and timed-cable sets are excluded.

    Acceptance (unit tests in ApplyRoutineModifierUseCaseTest):

    • per-set AMRAP with 10-rep history at 60% → 6; no history → unchanged AMRAP
    • last-set-flag case clears isAMRAP on the copy only
    • reference precedence; STANDARD rows and 0-rep rows are ignored
    • profile isolation; rounding floor of 1
    • all existing deload and Active Recovery tests unchanged
    • iOS test-target compile green

    Accepted limitation: an AMRAP set done during Active Recovery can be used as the reference. The follow-up, if needed, is a read-only query, with no migration.

    Effort: one bounded implementation packet (~0.5–1 day). No UI → no prototype stage needed.

  3. 9thLevelSoftware commented on Nov 17, 2026

    @9thLevelSoftware
    OwnerAuthor

    Integration model complete (enhancement pipeline, stage integration_model; code baseline main @ 6f95247)

    The planned change fits the existing code with a single production file touched.

    • Production change: ApplyRoutineModifierUseCase.kt only. Heavy Deload looks up the latest AMRAP sets for each AMRAP exercise (existing, profile-scoped getRecentCompletedSetsForExercise), picks the reference in order of same routine exercise + same set number, then same routine exercise, then any, and converts the AMRAP set to round(reps × percent) fixed reps (minimum 1) with the weight unchanged. Without AMRAP history the set stays AMRAP, as it does today. Bodyweight and timed sets are unchanged.
    • Verified seams: CompletedSet.setNumber is the 0-based set index, routineExerciseId equals RoutineExercise.id, and deloaded sets record as STANDARD, so they never feed back into later deloads. The only caller (RoutineFlowManager.enterRoutineOverview) already passes the profile. DI and constructors are unchanged.
    • No change to: schema, migrations, SQL, sync, portal or UI.
    • Tests: 11 new cases in ApplyRoutineModifierUseCaseTest (reporter example 10 → 6 @ 60%, no-history, last-set flag, reference precedence, STANDARD/0-rep rows ignored, profile isolation, bodyweight/timed, rounding, one query per exercise, Active Recovery untouched). FakeCompletedSetRepository also needs a small fix so it honors profileId.
    • Gates: required CI must be green, including iOS Test Target Compile, and the PR uses Fixes #1408.

    Next: implementation packet (one bounded packet, ~0.5–1 day).

  4. 9thLevelSoftware commented on Nov 17, 2026

    @9thLevelSoftware
    OwnerAuthor

    Signoff decision: APPROVED ✅ (stage: signoff)

    Verdict: approved for implementation specification and development. This is not release or merge approval.
    Decided by: escalated-model review (phoenix-rca, Claude Opus 5.5). No human feedback was on record. Full decision: signoff.md in the enhancement evidence dir.

    What changes: Heavy Deload now covers AMRAP sets. For each AMRAP set, the app takes the reps from your most recent completed AMRAP set for that exercise and applies the deload percentage: 10 reps at 60% gives 6 reps at the same weight. If there is no AMRAP history, the set stays AMRAP as it is today.

    Why approved: I re-checked the design against main @ 6f95247. The gap is in ApplyRoutineModifierUseCase.kt:104-115, where null (AMRAP) reps pass through. The fix touches one production file and uses an existing query that is profile-scoped and reads the latest attempt per set. Filtering references to AMRAP-type sets avoids a feedback loop, because deloaded sets record as STANDARD. There is no schema, sync, UI or portal change. The existing deload test ([10,8,null] → [5,4,null] with no history) still holds.

    Binding conditions (from signoff.md):

    • Allowed files: ApplyRoutineModifierUseCase.kt, ApplyRoutineModifierUseCaseTest.kt and testutil/FakeCompletedSetRepository.kt. The DWSM integration test is optional. Any other file counts as scope drift.
    • Bodyweight and timed-cable exercises must produce output identical to today. Warm-ups, durations and Active Recovery are unchanged, and Active Recovery must not read history.
    • The last-set AMRAP flag only clears on the session copy when history exists. Without history, the placeholder stays unscaled.
    • At most one history query per exercise per launch (limit 50, AMRAP rows with reps > 0). No try/catch, flag, UI hint or telemetry.
    • All 11 planned tests use Kotlin/Native-safe names, and existing tests stay green. Host tests, compileTestKotlinIosArm64 and required CI must be green. Simulator/host evidence is enough, and GitGuardian is not a gate.
    • The PR body must include Fixes #1408.

    Next stage: implementation_spec.

  5. 9thLevelSoftware commented on Nov 17, 2026

    @9thLevelSoftware
    OwnerAuthor

    Implementation plan (spec complete) — Heavy Deload scales AMRAP sets from last session's reps.

    Single bounded packet, no UI, no schema/sync/DI/portal change. Baseline: main 6f95247, verified unchanged across all upstream stages; signoff (claude-opus-5-5) approved with binding conditions.

    Allowed files (exactly 3):

    1. ApplyRoutineModifierUseCase.kt — applyHeavyDeload becomes suspend + profileId; per eligible exercise (non-bodyweight, non-timed), each AMRAP set (isAmrapSet) resolves R = reps of the most recent completed AMRAP-typed set (setType==AMRAP && actualReps>0, profile-scoped, limit 50, one query per exercise, memoized) with precedence same routine-exercise+set-number → same routine-exercise → any; target = scaleReps(R, P) (10 × 60% = 6), weight unchanged; isAMRAP cleared on the session copy only when resolved. No history → set stays AMRAP unchanged. No try/catch, no flag, no telemetry.
    2. ApplyRoutineModifierUseCaseTest.kt — 11 new cases (Kotlin/Native-safe names) covering history/no-history, last-set flag, precedence, STANDARD/zero-rep exclusion, profile isolation, bodyweight/timed byte-identical output, rounding floor, one-query-per-exercise, Active Recovery untouched.
    3. testutil/FakeCompletedSetRepository.kt — honor profileId and record calls.

    Guards: deloaded sets record as STANDARD (no feedback loop); routineModifierApplied deliberately not filtered (m62 fail-closed would void pre-upgrade history). Accepted limitations documented in KDoc: Active Recovery AMRAP rows may be a reference; history capped at 50 recent sets.

    Acceptance: 11 new tests + all existing tests green (incl. [10,8,null]→[5,4,null] unchanged), :shared:testAndroidHostTest, :shared:compileTestKotlinIosArm64, required CI (Unit Tests / Build Android / iOS Test Target Compile) green; PR will carry Fixes #1408.

    Docs: implementation-spec.md + user-instructions.md (with release-note draft) in the enhancement artifact directory. Next stage: implementation + PR.

  6. 9thLevelSoftware commented on Nov 17, 2026

    @9thLevelSoftware
    OwnerAuthor

    Implementation + PR ready: #1410

    Heavy Deload now scales AMRAP sets from the last session's achieved reps exactly as requested: 10 AMRAP reps at 60% → 6 reps, weight unchanged; with no AMRAP history the set stays AMRAP; the saved routine is never modified (session-only copy).

    • Branch feat/1408-deload-amrap-history @ 2b3189cd, base origin/main 6f95247 — diff limited to the 3 signoff-allowed files (ApplyRoutineModifierUseCase.kt, ApplyRoutineModifierUseCaseTest.kt, testutil/FakeCompletedSetRepository.kt).
    • Verified: 281 host tests green (11 new cases + all pre-existing unchanged), :shared:compileTestKotlinIosArm64 green. PR body carries Fixes #1408.
    • CI note: the Unit Tests check currently shows one failure — ExerciseMediaWiringTest > noMigrationTouchesExerciseImage, a stale migration-count ratchet (maxSeen <= 63) that already fails on main's own CI for base commit 6f95247 (run 44193888713) and is untouched by this PR (migration 64.sqm from [Bug]: Velocity is 10x too low (stored as cm/s, labelled mm/s); set MCV and velocity loss include calibration and ramp reps #1400 landed on main without bumping the guard). Full evidence on the PR. Once main bumps the guard, CI turns green on re-run.
  7. 9thLevelSoftware commented on Nov 18, 2026

    @9thLevelSoftware
    OwnerAuthor

    PR follow-up complete — CI green, ready for merge gate

    Branch: feat/1408-deload-amrap-history @ acf2d485 (base main @ c28f5094) · PR #1410 · MERGEABLE / CLEAN, Fixes #1408 intact, zero unresolved review threads.

    The one CI failure was pre-existing on main and is now fixed main-side:

    Final CI on acf2d485:

    Check Result
    Unit Tests ✅ pass (7m23s)
    Build Android ✅ pass
    iOS Test Target Compile ✅ pass
    Lint Check ✅ pass
    iOS Schema Sync Check ✅ pass
    Security Hygiene ✅ pass
    Shared Module / Android App Test Results (tvOS workflow) ✅ pass
    native-tv / native-tv-device ✅ pass (native-tv had one flaky PhantomBleRepositoryTest timeout on first run — BLE code untouched by this diff, passed on rerun)
    iOS Simulator Tests (non-blocking) skipping (non-blocking)
    GitGuardian not a gate

    No UI (ui_required=false), so no visual evidence gate applies. Next stage: merge gate (escalated model) — merge decision is intentionally left to it.

  8. 9thLevelSoftware commented on Nov 18, 2026

    @9thLevelSoftware
    OwnerAuthor

    Merge gate: merged ✅

    PR #1410 was squash-merged to main as a6a659d09bfd45ba77c76ebe2f93d9eedebf6f38. This issue was closed automatically by Fixes #1408.

    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 acf2d485):

    • Signoff approved (escalated-model review). The feasibility, architecture, integration-model, spec, signoff and user-instructions artifacts are all present.
    • The PR diff is exactly the 3 signoff-allowed files. I checked it against all 11 signoff bindings: eligibility, placeholder and isAMRAP handling, one memoized query per exercise (limit 50) with an AMRAP && actualReps > 0 filter, no try/catch, Active Recovery untouched, and KDoc limitations.
    • All required checks are green: Unit Tests, Build Android, iOS Test Target Compile, Lint, and iOS Schema Sync. Security Hygiene, native-tv and native-tv-device also pass. The iOS Simulator job is non-blocking and was skipped.
    • PR state was MERGEABLE/CLEAN with 0 review threads. The only bot review was a Copilot quota notice, not a requested change.
    • main moved ahead by 2 commits after follow-up (test(media): real picker-dialog photo-attach forwarding coverage (Refs #1358) #1409, fix: auto-advance equivalent consecutive duplicate routine entries (#1394) #1396). Neither touches the modifier or deload path, and git merge-tree showed a clean merge.
    • No UI change (ui_required=false), so no visual evidence was required.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions