Skip to content

fix: supersede old active program when regenerating via coach#90

Merged
cipher813 merged 1 commit into
mainfrom
fix/supersede-old-program-on-regenerate
Jul 9, 2026
Merged

fix: supersede old active program when regenerating via coach#90
cipher813 merged 1 commit into
mainfrom
fix/supersede-old-program-on-regenerate

Conversation

@cipher813

Copy link
Copy Markdown
Contributor

When Regenerate plan creates a new program via POST /coach/programs, any previously-active program stays status='active' and its future workouts (e.g. W/Sa from an old schedule) remain in the database. The calendar query fetches all PlannedWorkout regardless of program, so orphan workouts from a superseded generation continue to appear alongside the new ones.

Fix: before adding the new program, deactivate all existing active programs (set to status='superseded') and drop their future (non-completed) workouts — matching the same cutover semantics that apply_program already uses for the modify path.

Test plan

  • All 81 existing tests pass
  • No behavioral change for first-generation plans (no old program to supersede)
  • Verified the fix matches apply_program's cutover semantics

When 'Regenerate plan' creates a new program via POST /coach/programs,
any previously-active program stays status='active' and its future
(non-completed) workouts remain in the database. The calendar query
shows ALL PlannedWorkout regardless of program, so old workouts from
a superseded generation (e.g. W/Sa from a now-T/Th schedule) continue
to appear alongside the new ones.

Fix: deactivate old active programs (status='superseded') and drop
their future planned workouts before adding the new one, matching the
semantics of apply_program's cutover.

Co-Authored-By: Claude <noreply@anthropic.com>
@cipher813 cipher813 merged commit 908b64c into main Jul 9, 2026
3 checks passed
@cipher813 cipher813 deleted the fix/supersede-old-program-on-regenerate branch July 9, 2026 18:12
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