workout generator audit: rules engine, structure rules, split patterns, injury UX, metadata cleanup

- Add rules_engine.py with quantitative rules for all 8 workout types
- Add quality gate retry loop in generate_single_workout()
- Expand calibrate_structure_rules to all 120 combinations (8 types × 5 goals × 3 sections)
- Wire WeeklySplitPattern DB records into _pick_weekly_split()
- Enforce movement patterns from WorkoutStructureRule in exercise selection
- Add straight-set strength support (single main lift, 4-6 rounds)
- Add modality consistency check for duration-dominant workout types
- Add InjuryStep component to onboarding and preferences
- Add sibling exercise exclusion in regenerate and preview_day endpoints
- Display generator warnings on dashboard
- Expand fix_rep_durations, fix_exercise_flags, fix_movement_pattern_typo
- Add audit_exercise_data and check_rules_drift management commands
- Add Next.js frontend with dashboard, onboarding, preferences, history pages
- Add generator app with ML-powered workout generation pipeline
- 96 new tests across 7 test modules

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Trey t
2026-02-22 20:07:40 -06:00
parent 2a16b75c4b
commit 1c61b80731
111 changed files with 28108 additions and 30 deletions

View File

@@ -0,0 +1,79 @@
import Link from "next/link";
import { Badge } from "@/components/ui/Badge";
import type { SupersetExercise } from "@/lib/types";
function mediaUrl(path: string): string {
if (typeof window === "undefined") return path;
return `${window.location.protocol}//${window.location.hostname}:8001${path}`;
}
interface ExerciseRowProps {
exercise: SupersetExercise;
}
export function ExerciseRow({ exercise }: ExerciseRowProps) {
const ex = exercise.exercise;
const details: string[] = [];
if (exercise.reps) {
details.push(`${exercise.reps} reps`);
}
if (exercise.duration) {
details.push(`${exercise.duration}s`);
}
if (exercise.weight) {
details.push(`${exercise.weight} lbs`);
}
const muscles = ex.muscles?.map((m) => m.name) || [];
return (
<div className="flex items-center justify-between px-4 py-3 border-b border-zinc-800/50 last:border-b-0">
<div className="flex-1 min-w-0">
<div className="flex items-center gap-2">
<span className="text-sm font-medium text-zinc-100 truncate">
{ex.name}
</span>
{ex.video_url && (
<Link
href={mediaUrl(ex.video_url)}
target="_blank"
rel="noopener noreferrer"
className="flex-shrink-0 text-[#39FF14] hover:text-[#39FF14]/80 transition-colors"
title="Watch video"
>
<svg
xmlns="http://www.w3.org/2000/svg"
width="16"
height="16"
viewBox="0 0 24 24"
fill="currentColor"
stroke="none"
>
<polygon points="5 3 19 12 5 21 5 3" />
</svg>
</Link>
)}
</div>
{details.length > 0 && (
<p className="text-xs text-zinc-400 mt-0.5">{details.join(" / ")}</p>
)}
{muscles.length > 0 && (
<div className="flex flex-wrap gap-1 mt-1.5">
{muscles.map((name) => (
<Badge
key={name}
variant="default"
className="text-[10px] px-1.5 py-0"
>
{name}
</Badge>
))}
</div>
)}
</div>
</div>
);
}

View File

@@ -0,0 +1,71 @@
"use client";
import { useState } from "react";
import { Card } from "@/components/ui/Card";
import { Badge } from "@/components/ui/Badge";
import { ExerciseRow } from "@/components/workout/ExerciseRow";
import type { Superset } from "@/lib/types";
interface SupersetCardProps {
superset: Superset;
defaultOpen?: boolean;
}
function formatTime(seconds: number | null): string {
if (!seconds) return "";
const mins = Math.round(seconds / 60);
return `${mins}m`;
}
export function SupersetCard({ superset, defaultOpen = false }: SupersetCardProps) {
const [open, setOpen] = useState(defaultOpen);
const sortedExercises = [...superset.exercises].sort(
(a, b) => a.order - b.order
);
const displayName = superset.name || `Superset ${superset.order}`;
return (
<Card className="overflow-hidden">
<button
onClick={() => setOpen(!open)}
className="w-full flex items-center justify-between p-4 text-left hover:bg-zinc-800/50 transition-colors duration-150"
>
<div className="flex items-center gap-3">
<h3 className="text-sm font-semibold text-zinc-100">{displayName}</h3>
<Badge variant="accent">{superset.rounds}x</Badge>
{superset.estimated_time && (
<span className="text-xs text-zinc-500">
{formatTime(superset.estimated_time)}
</span>
)}
</div>
<svg
xmlns="http://www.w3.org/2000/svg"
width="20"
height="20"
viewBox="0 0 24 24"
fill="none"
stroke="currentColor"
strokeWidth="2"
strokeLinecap="round"
strokeLinejoin="round"
className={`text-zinc-500 transition-transform duration-200 ${
open ? "rotate-180" : ""
}`}
>
<polyline points="6 9 12 15 18 9" />
</svg>
</button>
{open && (
<div className="border-t border-zinc-700/50">
{sortedExercises.map((exercise) => (
<ExerciseRow key={exercise.id} exercise={exercise} />
))}
</div>
)}
</Card>
);
}

View File

@@ -0,0 +1,52 @@
"use client";
import { useEffect, useRef } from "react";
import Hls from "hls.js";
interface VideoPlayerProps {
src: string;
poster?: string;
}
export function VideoPlayer({ src, poster }: VideoPlayerProps) {
const videoRef = useRef<HTMLVideoElement>(null);
const hlsRef = useRef<Hls | null>(null);
useEffect(() => {
const video = videoRef.current;
if (!video) return;
const isHLS = src.endsWith(".m3u8");
if (isHLS) {
if (Hls.isSupported()) {
const hls = new Hls();
hlsRef.current = hls;
hls.loadSource(src);
hls.attachMedia(video);
} else if (video.canPlayType("application/vnd.apple.mpegurl")) {
// Native HLS support (Safari)
video.src = src;
}
} else {
video.src = src;
}
return () => {
if (hlsRef.current) {
hlsRef.current.destroy();
hlsRef.current = null;
}
};
}, [src]);
return (
<video
ref={videoRef}
poster={poster}
controls
playsInline
className="w-full rounded-lg bg-zinc-900"
/>
);
}