Skip to content

fix(workout): publish Idle on manual summary continue so SetReady can navigate (#1413) - #1414

Merged
9thLevelSoftware merged 4 commits into
mainfrom
fix/1413-manual-summary-continue-authority
Nov 18, 2026
Merged

9thLevelSoftware merged 4 commits into
mainfrom
fix/1413-manual-summary-continue-authority

Conversation

@9thLevelSoftware

@9thLevelSoftware 9thLevelSoftware commented Nov 18, 2026 •

Copy link
Copy Markdown
Owner

Problem

Fixes #1413.

With Profile → Set summary duration = Manual, the Set Summary holds as designed after a completed set, but every tap on its visible Next Set button is rejected app-side: Rest transition install failed reason=AUTHORITY_REJECTED per tap and the screen stays frozen (51 taps on the iPad simulator / Phantom provider = 1 silent successful tap + 50 rejections; evidence in the issue and the recreation packet).

Root cause

The explicit continue installs the rest transition and runs the successor through ActiveSessionEngine.startNextSetOrExerciseFor, which advances _currentExerciseIndex/_currentSetIndex and then enters SetReady via startWorkoutOrSetReady(autoplay = false) — but never publishes WorkoutState.Idle. ActiveWorkoutScreen only navigates to SetReady when workoutState leaves SetSummary/Resting/Active, so the summary card strands on screen; every retry tap re-enters the rest-plan install with the completion identity frozen at the completed set and dies in hasCompletionRestAuthority (_currentSetIndex no longer matches the claimed identity), logging reason=AUTHORITY_REJECTED forever.

The sibling deferManualStart arm already publishes Idle after enterSetReady + applyPendingRestRackSelection (Issue #572 / #1394 comment) — the two autoplay-off successor arms (distinct exercise without deferManualStart, and within-entry next set) were missing that publication.

Fix (reworked per the architecture review on the issue)

Publish WorkoutState.Idle in both autoplay-off successor arms of startNextSetOrExerciseFor, after enterSetReady and applyPendingRestRackSelection, guarded by hasExpectedAuthority(lease, …) — mirroring the existing deferManualStart arm. Navigation-only: one shared-engine function, no schema/Supabase/portal/persistence/BLE change, and no authority relaxation — hasCompletionRestAuthority and executionGuard are untouched, so superseded/stale completions are still rejected (pinned by a dedicated guard test).

PR history note: the branch's first commit (f040282) is the earlier anchored-position authority-relaxation attempt, which the architecture review rejected as the fix. Commit dd009d0 reverts it wholesale; the net diff of this PR against main is exactly the Idle publication + regression tests. This PR was also brought up to current main (ca2fefe1, the arch-review baseline).

Tests

Issue1413ManualSummaryContinueIdleTest (new, 4 tests, commonTest, Kotlin/Native-safe names) — all driving the real production tap handler (DefaultWorkoutSessionManager.proceedFromSummary) with DWSMTestHarness:

  • Within-entry (2-set entry) — after set 1, one tap gives WorkoutState.Idle (not SetSummary), routineFlowState = SetReady(0, 1), _currentSetIndex = 1, and no unsolicited successor CONFIG before explicit Start.
  • Distinct-exercise boundary — same result with SetReady(1, 0) / _currentExerciseIndex = 1.
  • No install-failure warnings — zero Rest transition install failed log entries across the first and any later taps.
  • Stale-completion guard — after the workout genuinely reaches the successor position, a superseded completion's rest install is still InitialRestPlanInstallResult.AuthorityRejected.

RED → GREEN on the recreation's exact signature: on the pre-fix tree the two boundary tests fail (Expected … WorkoutState.Idle, actual … WorkoutState$SetSummary) and the no-warning test fails (expected:<0> but was:<1> — the live AUTHORITY_REJECTED retry tap); with the fix all 4 pass. The guard test passes on both.

Guard suites (arch-review binding): Issue1394ConsecutiveDuplicateAutoAdvanceTest (27), Issue656ReproTest (2), DropSetRestTransitionTest (13), DWSMRoutineFlowTest (58), Issue1360RestControlOutcomeTest (10 — the PostWriteDrift contract is preserved) — all green.

Full unit gate: ./gradlew -Pskip.supabase.check=true :shared:testAndroidHostTest :androidApp:testDebugUnitTest :androidApp:testReleaseDexTypes --continue — BUILD SUCCESSFUL, 6047 shared host + 26 androidApp tests, 0 failures.

Risk & scope

  • Narrow: ActiveSessionEngine.kt (+16 lines) and one new test file. Navigation-only; no persistence, BLE, schema, Supabase or portal change.
  • Autoplay and deferManualStart arms are unchanged. Manual summaries that already worked keep their exact behavior.
  • The optional idempotent-retry quiet no-op (secondary RCA suggestion) is deliberately NOT included — minimal fix only; stale-completion rejection semantics are unchanged.

Not merged by design: the merge gate is phoenix-rca.

…n while a SetSummary is held (#1413)

Manual "Next Set" on a held Set Summary (Set summary duration = Manual) was
rejected with AUTHORITY_REJECTED on every tap once the raw live mirror flows
(currentRoutineId / currentRoutineSessionId / _currentExerciseIndex /
_currentSetIndex) drifted silently during the hold, freezing the workout on
the summary. The same check had passed when the completion job installed the
rest plan at set-completion time.

The duplicated raw-coordinate conjuncts at the four rest-transition authority
gates are replaced by liveRoutinePositionMatchesSource: while a SetSummary is
still displayed the position is anchored on the loaded routine and the last
explicitly entered RoutineFlowState.SetReady coordinates (written atomically
with the index flows by every legitimate transition); in every other state the
raw mirrors stay fully authoritative, preserving #1398's PostWriteDrift
rest-control revalidation contract exactly.

Instrumentation: connection-log diagnostics name the rejecting conjunct and
the drifting mirror (privacy-safe; index values only).

Tests: Issue1413ManualSummaryDelayedContinueTest — delayed-tap contract, 4
drift regressions (RED pre-fix / GREEN post-fix, sabotage-verified), and a
stale-completion guard test proving a genuine successor transition still
rejects the superseded completion.
Copilot AI balanced review requested due to automatic review settings November 18, 2026 02:27

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

Devil added 3 commits November 17, 2026 22:07
… position while a SetSummary is held (#1413)"

This reverts commit f040282.
… navigate (#1413)

With Set summary duration = Manual, the explicit 'Next Set' continue runs the
successor through startNextSetOrExerciseFor, which advances the set/exercise
indexes and enters SetReady via startWorkoutOrSetReady(autoplay=false) but
never publishes WorkoutState.Idle. ActiveWorkoutScreen only navigates to
SetReady when workoutState leaves SetSummary/Resting/Active, so the summary
card strands and every retry tap dies in hasCompletionRestAuthority
(Rest transition install failed reason=AUTHORITY_REJECTED).

Publish WorkoutState.Idle in both autoplay-off successor arms (distinct
exercise without deferManualStart, and within-entry next set) after
enterSetReady and applyPendingRestRackSelection, guarded by
hasExpectedAuthority, mirroring the existing deferManualStart arm. The
authority checks (hasCompletionRestAuthority / executionGuard) are untouched:
superseded completions are still rejected.

RED/GREEN: Issue1413ManualSummaryContinueIdleTest (4 tests) fails on main
exactly on the live signature (stuck SetSummary, AUTHORITY_REJECTED on the
retry tap) and passes with this fix. Issue1394ConsecutiveDuplicateAutoAdvance,
Issue656Repro, DropSetRestTransition, DWSMRoutineFlow and
Issue1360RestControlOutcome suites stay green; full unit gate green
(6047 shared host + 26 androidApp tests).

Fixes #1413
@9thLevelSoftware 9thLevelSoftware changed the title fix(workout): anchor rest-transition authority to the entered position while a SetSummary is held (#1413) fix(workout): publish Idle on manual summary continue so SetReady can navigate (#1413) Nov 18, 2026
@9thLevelSoftware

Copy link
Copy Markdown
Owner Author

Reworked per the architecture review (issue comment on #1413).

This PR has been reworked from the anchored-position authority relaxation to the approved WorkoutState.Idle publication direction:

  • f040282 (original attempt) — authority relaxation; rejected by the architecture review as the fix.
  • dd009d0 — reverts f040282 wholesale (the liveRoutinePositionMatchesSource relaxation and its drift tests are gone).
  • 6e6eaa5 — the approved fix: WorkoutState.Idle published in both autoplay-off successor arms of startNextSetOrExerciseFor (distinct exercise without deferManualStart, within-entry next set) after enterSetReady + applyPendingRestRackSelection, guarded by hasExpectedAuthority, mirroring the deferManualStart arm. Plus Issue1413ManualSummaryContinueIdleTest (4 tests).

Net diff vs main = the Idle publication (+16 lines in ActiveSessionEngine.kt) + the new test file only. hasCompletionRestAuthority / executionGuard are untouched (superseded completions still rejected — pinned by the guard test). Binding constraints (1)–(5) verified in code and tests; for (6), the host RED/GREEN reproduces the live 51-tap capture deterministically (first tap advances, later taps log no warning), so no new simulator run is required. Fixes #1413 retained.

Verification: RED→GREEN on the recreation signature (stuck WorkoutState.SetSummary + AUTHORITY_REJECTED retry tap on pre-fix, all green with the fix); Issue1394 (27) / Issue656 (2) / DropSetRestTransition (13) / DWSMRoutineFlow (58) / Issue1360 (10) guard suites green; full unit gate green (6047 shared host + 26 androidApp tests, 0 failures).

@9thLevelSoftware
9thLevelSoftware merged commit 75b5fc2 into main Nov 18, 2026
12 checks passed
@9thLevelSoftware
9thLevelSoftware deleted the fix/1413-manual-summary-continue-authority branch November 18, 2026 04:11
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.

Manual "Next Set" on a held Set Summary is rejected (AUTHORITY_REJECTED) — workout frozen after first completed set (Set summary duration = Manual)

2 participants