feat(plan-tuner): Workout Plan Fine Tuner v1 - #60
Merged
Conversation
Implements all Phase 4 frontend deliverables for the workout plan fine tuner feature: - useWorkoutPlan.ts: TanStack Query hooks (useCurrentPlan, useCreatePlan, useTunePlan, useDecideAdjustments) with toast feedback - PlanPage: empty state with inline editor, populated state with day cards and version badge, collapsible version history - PlanEditor: textarea + Parse & Save with loading/error states - PlanDayCard: exercise table with sets × reps × load, fallback notes view - PlanVersionHistory: collapsible version list with source badges - AdjustmentReviewModal: day-grouped diff list, per-row accept/reject, accept all/reject all triage, confidence dots, evidence expand, commit - OptimizePlanButton: enabled/disabled states, tune mutation, modal integration - Unit tests: 22 new tests across 3 test files (all passing) - E2E: 7-test spec covering full create→optimize→review→accept flow Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Implements the complete Workout Plan Fine-Tuner backend: - DB query module (workout-plans.ts) with COLUMNS/mapRow pattern - Plan schema validation (plan-schema.ts) and free-text parser (plan-parser.ts) - Exercise metadata table ~50 exercises (exercise-metadata.ts) - Rules engine: progression rules (2-for-2, double, deload, RPE guardrail), safety caps (±10% load, 1.3× volume, 40% change ratio, injury lock), and candidate generator orchestration - AI tuner prompt builder and main tunePlan service (9-step orchestration) - 7 REST endpoints under /api/plans with full error envelopes - 62 new tests (406 total); build and lint clean Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
H1: applyMaxChangeRatio called post-LLM in tuner.ts step 8a;
applyVolumeCap wired into candidate-generator.ts per-day loop.
H2: Add UNIQUE(user_id) to workout_plans migration; upsertPlan uses
ON CONFLICT (user_id) DO UPDATE instead of DO NOTHING + separate UPDATE.
H3: validatePlanData accepts full 'conservative'|'balanced'|'aggressive'
union; missing value defaults to 'balanced'.
H4: PATCH decide handler validates sourceVersion BEFORE committing status
updates; bulkUpdateAdjustmentStatus now scoped to batchId.
H5: Export flagSuspiciousInput from conversation-service; tuner sanitizes
day names, exercise names/notes, plan notes before building LLM prompt.
H6: Annotate aiProvider as AIProvider and batch as PlanAdjustmentBatch.
H7: useDecideAdjustments response type is DecideAdjustmentsResponse
(versionNumber, data, message?); toast uses ?. fallback.
M1: Injury keyword matching uses word-boundary regex; 'back' narrowed to
'lower back'/'lumbar' to avoid day-name false positives.
M2: insertAdjustmentBatchWithAdjustments wraps batch + adjustments in
a single transaction (partial-batch protection).
M3: bulkUpdateAdjustmentStatus adds AND batch_id = $3 WHERE clause.
M4: POST /api/workout-plans rejects rawText > 50 000 chars with 413;
buildFallback truncates stored notes to 10 000 chars.
M5: Tune endpoint error handler logs {planId, errMsg} instead of full err.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Replace non-atomic insertAdjustmentBatch + insertAdjustment loop in tuner.ts with a single insertAdjustmentBatchWithAdjustments call that wraps both the batch header and all adjustment rows in one transaction. Update tuner.test.ts mocks and assertions accordingly. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Add §7 Workout Plan Fine Tuner to product-capabilities.md with UC-PLAN-01 through UC-PLAN-05, engine architecture, v1 limitations, and future work. Renumber former §7-9 to §8-10. Append implementation update block to actionable-intelligence-features research doc recording F2 slice decisions and open items. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub. |
This was referenced Apr 12, 2026
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.
Summary
First concrete slice of F2 (Workout Training Intelligence) from the 2026-03-22 actionable-intelligence research. Lets users persist a workout plan and, from each weekly report, generate an AI-tuned version for next week with per-change accept/reject.
workout_plans/plan_versions/plan_adjustment_batches/plan_adjustmentstables (migration 011), rule-first candidate-generation engine, LLM-as-selector tuner service with structural evidence validation, full CRUD + tune routes./planpage (create + view + version history),AdjustmentReviewModalwith day-grouped diff + per-row accept/reject,OptimizePlanButtonin expandedReportCard.docs/product-capabilities.md§7 (UC-PLAN-01..05), research update in the 2026-03-22 research doc.Architecture highlights
flagSuspiciousInputapplied to all user-pasted plan fields before prompting; matched fields are stripped with a marker rather than rejected.plan_versionsrow. Prior versions preserved for history/rollback. Transactional batch+adjustments insert.v1 scope discipline
Shipped: paste-only plan source, single plan per user, CTA-only trigger, day count locked, one "balanced" progression personality, no F3 outcome coupling, no Hevy push-back. All per user-approved decisions at the intent gate.
Test plan
Review artifacts
docs/product-capabilities.md§7🤖 Generated with Claude Code