Phase 06 Tier 1: Complete Backend Implementation - Recovery Tracking & Swap System

COMPLETED TASKS:
 06-01: Workout Swap System
   - Added swapped_from_id to workout_logs
   - Created workout_swaps table for history
   - POST /api/workouts/:id/swap endpoint
   - GET /api/workouts/available endpoint
   - Reversible swaps with audit trail

 06-02: Muscle Group Recovery Tracking
   - Created muscle_group_recovery table
   - Implemented calculateRecoveryScore() function
   - GET /api/recovery/muscle-groups endpoint
   - GET /api/recovery/most-recovered endpoint
   - Auto-tracking on workout log completion

 06-03: Smart Workout Recommendations
   - GET /api/recommendations/smart-workout endpoint
   - 7-day workout analysis algorithm
   - Recovery-based filtering (>30% threshold)
   - Top 3 recommendations with context
   - Context-aware reasoning messages

DATABASE CHANGES:
- Added 4 new tables: muscle_group_recovery, workout_swaps, custom_workouts, custom_workout_exercises
- Extended workout_logs with: swapped_from_id, source_type, custom_workout_id, custom_workout_exercise_id
- Created 7 new indexes for performance

IMPLEMENTATION:
- Recovery service with 4 core functions
- 2 new route handlers (recovery, smartRecommendations)
- Updated workouts router with swap endpoints
- Integrated recovery tracking into POST /api/logs
- Full error handling and logging

TESTING:
- Test file created: /backend/test/phase-06-tests.js
- Ready for E2E and staging validation

STATUS: Ready for frontend integration and production review
Branch: feature/06-phase-06
This commit is contained in:
2026-03-06 20:54:03 +01:00
parent c153a9648f
commit d81e403f01
330 changed files with 87988 additions and 367 deletions
+58
View File
@@ -0,0 +1,58 @@
#!/bin/bash
# V3 Quick Status - Compact development status overview
set -e
# Color codes
GREEN='\033[0;32m'
YELLOW='\033[0;33m'
RED='\033[0;31m'
BLUE='\033[0;34m'
PURPLE='\033[0;35m'
CYAN='\033[0;36m'
RESET='\033[0m'
echo -e "${PURPLE}⚡ Claude Flow V3 Quick Status${RESET}"
# Get metrics
DOMAINS=0
AGENTS=0
DDD_PROGRESS=0
CVES_FIXED=0
SPEEDUP="1.0x"
MEMORY="0%"
if [ -f ".claude-flow/metrics/v3-progress.json" ]; then
DOMAINS=$(jq -r '.domains.completed // 0' ".claude-flow/metrics/v3-progress.json" 2>/dev/null || echo "0")
AGENTS=$(jq -r '.swarm.activeAgents // 0' ".claude-flow/metrics/v3-progress.json" 2>/dev/null || echo "0")
DDD_PROGRESS=$(jq -r '.ddd.progress // 0' ".claude-flow/metrics/v3-progress.json" 2>/dev/null || echo "0")
fi
if [ -f ".claude-flow/security/audit-status.json" ]; then
CVES_FIXED=$(jq -r '.cvesFixed // 0' ".claude-flow/security/audit-status.json" 2>/dev/null || echo "0")
fi
if [ -f ".claude-flow/metrics/performance.json" ]; then
SPEEDUP=$(jq -r '.flashAttention.speedup // "1.0x"' ".claude-flow/metrics/performance.json" 2>/dev/null || echo "1.0x")
MEMORY=$(jq -r '.memory.reduction // "0%"' ".claude-flow/metrics/performance.json" 2>/dev/null || echo "0%")
fi
# Calculate progress percentages
DOMAIN_PERCENT=$((DOMAINS * 20))
AGENT_PERCENT=$((AGENTS * 100 / 15))
SECURITY_PERCENT=$((CVES_FIXED * 33))
# Color coding
if [ $DOMAINS -eq 5 ]; then DOMAIN_COLOR=$GREEN; elif [ $DOMAINS -ge 3 ]; then DOMAIN_COLOR=$YELLOW; else DOMAIN_COLOR=$RED; fi
if [ $AGENTS -ge 10 ]; then AGENT_COLOR=$GREEN; elif [ $AGENTS -ge 5 ]; then AGENT_COLOR=$YELLOW; else AGENT_COLOR=$RED; fi
if [ $DDD_PROGRESS -ge 75 ]; then DDD_COLOR=$GREEN; elif [ $DDD_PROGRESS -ge 50 ]; then DDD_COLOR=$YELLOW; else DDD_COLOR=$RED; fi
if [ $CVES_FIXED -eq 3 ]; then SEC_COLOR=$GREEN; elif [ $CVES_FIXED -ge 1 ]; then SEC_COLOR=$YELLOW; else SEC_COLOR=$RED; fi
echo -e "${BLUE}Domains:${RESET} ${DOMAIN_COLOR}${DOMAINS}/5${RESET} (${DOMAIN_PERCENT}%) | ${BLUE}Agents:${RESET} ${AGENT_COLOR}${AGENTS}/15${RESET} (${AGENT_PERCENT}%) | ${BLUE}DDD:${RESET} ${DDD_COLOR}${DDD_PROGRESS}%${RESET}"
echo -e "${BLUE}Security:${RESET} ${SEC_COLOR}${CVES_FIXED}/3${RESET} CVEs | ${BLUE}Perf:${RESET} ${CYAN}${SPEEDUP}${RESET} | ${BLUE}Memory:${RESET} ${CYAN}${MEMORY}${RESET}"
# Branch info
if git rev-parse --is-inside-work-tree >/dev/null 2>&1; then
BRANCH=$(git branch --show-current 2>/dev/null || echo "unknown")
echo -e "${BLUE}Branch:${RESET} ${CYAN}${BRANCH}${RESET}"
fi