workspace/devtools/scripts/validation/validate-inventory-coherence.sh
rckrdmrd 4ac2b7aa0d
Some checks are pending
CI Pipeline / changes (push) Waiting to run
CI Pipeline / core (push) Blocked by required conditions
CI Pipeline / trading-backend (push) Blocked by required conditions
CI Pipeline / trading-data-service (push) Blocked by required conditions
CI Pipeline / trading-frontend (push) Blocked by required conditions
CI Pipeline / erp-core (push) Blocked by required conditions
CI Pipeline / erp-mecanicas (push) Blocked by required conditions
CI Pipeline / gamilit-backend (push) Blocked by required conditions
CI Pipeline / gamilit-frontend (push) Blocked by required conditions
Add orchestration templates, agent profiles, and validation scripts
- New agent profiles: DevOps, Security Auditor, Testing
- New templates: Sprint report, HU derivada, Analysis impact
- Onboarding guide for projects
- Validation scripts for CAPVED gate, inventory coherence, propagation
- Platform marketing content orchestration state files

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-12 07:54:33 -06:00

236 lines
8.0 KiB
Bash
Executable File

#!/bin/bash
# =============================================================================
# SCRIPT: validate-inventory-coherence.sh
# PROPOSITO: Verificar coherencia entre inventarios y archivos reales
# SISTEMA: SIMCO + CAPVED
# VERSION: 1.0.0
# =============================================================================
set -e
WORKSPACE_ROOT="${HOME}/workspace"
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
BLUE='\033[0;34m'
NC='\033[0m'
PROJECT="${1:-}"
echo "=============================================="
echo " VALIDACION DE COHERENCIA DE INVENTARIOS"
echo "=============================================="
echo ""
if [ -z "$PROJECT" ]; then
echo "Uso: $0 <nombre_proyecto>"
echo "Ejemplo: $0 gamilit"
echo ""
echo "Proyectos disponibles:"
ls -1 "${WORKSPACE_ROOT}/projects/"
exit 1
fi
PROJECT_PATH="${WORKSPACE_ROOT}/projects/${PROJECT}"
if [ ! -d "$PROJECT_PATH" ]; then
echo -e "${RED}ERROR: Proyecto no existe: $PROJECT_PATH${NC}"
exit 1
fi
ERRORS=0
WARNINGS=0
# -----------------------------------------------------------------------------
# Funcion: Validar DATABASE_INVENTORY vs DDL real
# -----------------------------------------------------------------------------
validate_database_inventory() {
local inv_file="${PROJECT_PATH}/orchestration/inventarios/DATABASE_INVENTORY.yml"
local ddl_path="${PROJECT_PATH}/apps/database/ddl"
echo ""
echo -e "${BLUE}=== Validando DATABASE_INVENTORY ===${NC}"
if [ ! -f "$inv_file" ]; then
echo -e "${YELLOW}[SKIP]${NC} DATABASE_INVENTORY.yml no existe"
return
fi
if [ ! -d "$ddl_path" ]; then
echo -e "${YELLOW}[SKIP]${NC} Directorio DDL no existe: $ddl_path"
return
fi
# Contar schemas en inventario (simplificado)
local inv_schemas=$(grep -c "^\s*[a-z_]*:$" "$inv_file" 2>/dev/null || echo "0")
# Contar schemas reales
local real_schemas=$(find "$ddl_path/schemas" -maxdepth 1 -type d 2>/dev/null | wc -l)
real_schemas=$((real_schemas - 1)) # Restar el directorio padre
echo "Schemas en inventario: ~$inv_schemas"
echo "Schemas en DDL: $real_schemas"
# Contar archivos SQL
local sql_files=$(find "$ddl_path" -name "*.sql" -type f 2>/dev/null | wc -l)
echo "Archivos SQL totales: $sql_files"
echo -e "${GREEN}[OK]${NC} DATABASE_INVENTORY validado"
}
# -----------------------------------------------------------------------------
# Funcion: Validar BACKEND_INVENTORY vs codigo real
# -----------------------------------------------------------------------------
validate_backend_inventory() {
local inv_file="${PROJECT_PATH}/orchestration/inventarios/BACKEND_INVENTORY.yml"
local backend_path="${PROJECT_PATH}/apps/backend/src"
echo ""
echo -e "${BLUE}=== Validando BACKEND_INVENTORY ===${NC}"
if [ ! -f "$inv_file" ]; then
echo -e "${YELLOW}[SKIP]${NC} BACKEND_INVENTORY.yml no existe"
return
fi
if [ ! -d "$backend_path" ]; then
echo -e "${YELLOW}[SKIP]${NC} Directorio backend no existe: $backend_path"
return
fi
# Contar entities reales
local real_entities=$(find "$backend_path" -name "*.entity.ts" -type f 2>/dev/null | wc -l)
echo "Entities encontradas: $real_entities"
# Contar services reales
local real_services=$(find "$backend_path" -name "*.service.ts" -type f 2>/dev/null | wc -l)
echo "Services encontrados: $real_services"
# Contar controllers reales
local real_controllers=$(find "$backend_path" -name "*.controller.ts" -type f 2>/dev/null | wc -l)
echo "Controllers encontrados: $real_controllers"
# Contar DTOs reales
local real_dtos=$(find "$backend_path" -name "*.dto.ts" -type f 2>/dev/null | wc -l)
echo "DTOs encontrados: $real_dtos"
echo -e "${GREEN}[OK]${NC} BACKEND_INVENTORY validado"
}
# -----------------------------------------------------------------------------
# Funcion: Validar FRONTEND_INVENTORY vs codigo real
# -----------------------------------------------------------------------------
validate_frontend_inventory() {
local inv_file="${PROJECT_PATH}/orchestration/inventarios/FRONTEND_INVENTORY.yml"
local frontend_path="${PROJECT_PATH}/apps/frontend/src"
echo ""
echo -e "${BLUE}=== Validando FRONTEND_INVENTORY ===${NC}"
if [ ! -f "$inv_file" ]; then
echo -e "${YELLOW}[SKIP]${NC} FRONTEND_INVENTORY.yml no existe"
return
fi
if [ ! -d "$frontend_path" ]; then
echo -e "${YELLOW}[SKIP]${NC} Directorio frontend no existe: $frontend_path"
return
fi
# Contar componentes reales (.tsx)
local real_components=$(find "$frontend_path" -name "*.tsx" -type f 2>/dev/null | wc -l)
echo "Archivos TSX encontrados: $real_components"
# Contar hooks reales
local real_hooks=$(find "$frontend_path" -name "use*.ts" -o -name "use*.tsx" -type f 2>/dev/null | wc -l)
echo "Hooks encontrados: $real_hooks"
# Contar stores
local real_stores=$(find "$frontend_path" -name "*store*.ts" -o -name "*Store*.ts" -type f 2>/dev/null | wc -l)
echo "Stores encontrados: $real_stores"
echo -e "${GREEN}[OK]${NC} FRONTEND_INVENTORY validado"
}
# -----------------------------------------------------------------------------
# Funcion: Verificar MASTER_INVENTORY consolidado
# -----------------------------------------------------------------------------
validate_master_inventory() {
local inv_file="${PROJECT_PATH}/orchestration/inventarios/MASTER_INVENTORY.yml"
echo ""
echo -e "${BLUE}=== Validando MASTER_INVENTORY ===${NC}"
if [ ! -f "$inv_file" ]; then
echo -e "${RED}[FAIL]${NC} MASTER_INVENTORY.yml no existe"
((ERRORS++))
return
fi
# Verificar que tiene secciones principales
local has_database=$(grep -c "database:" "$inv_file" 2>/dev/null || echo "0")
local has_backend=$(grep -c "backend:" "$inv_file" 2>/dev/null || echo "0")
local has_frontend=$(grep -c "frontend:" "$inv_file" 2>/dev/null || echo "0")
if [ "$has_database" -gt 0 ]; then
echo -e "${GREEN}[OK]${NC} Seccion database presente"
else
echo -e "${YELLOW}[WARN]${NC} Seccion database no encontrada"
((WARNINGS++))
fi
if [ "$has_backend" -gt 0 ]; then
echo -e "${GREEN}[OK]${NC} Seccion backend presente"
else
echo -e "${YELLOW}[WARN]${NC} Seccion backend no encontrada"
((WARNINGS++))
fi
if [ "$has_frontend" -gt 0 ]; then
echo -e "${GREEN}[OK]${NC} Seccion frontend presente"
else
echo -e "${YELLOW}[WARN]${NC} Seccion frontend no encontrada"
((WARNINGS++))
fi
# Verificar fecha de actualizacion
local last_update=$(grep -oE "fecha_actualizacion:\s*['\"]?[0-9-]+['\"]?" "$inv_file" 2>/dev/null | head -1 || echo "")
if [ -n "$last_update" ]; then
echo "Ultima actualizacion registrada: $last_update"
fi
}
# -----------------------------------------------------------------------------
# MAIN
# -----------------------------------------------------------------------------
echo "Proyecto: $PROJECT"
echo "Path: $PROJECT_PATH"
validate_database_inventory
validate_backend_inventory
validate_frontend_inventory
validate_master_inventory
# -----------------------------------------------------------------------------
# RESUMEN
# -----------------------------------------------------------------------------
echo ""
echo "=============================================="
echo " RESUMEN"
echo "=============================================="
if [ $ERRORS -eq 0 ] && [ $WARNINGS -eq 0 ]; then
echo -e "${GREEN}RESULTADO: INVENTARIOS COHERENTES${NC}"
exit 0
elif [ $ERRORS -eq 0 ]; then
echo -e "${YELLOW}RESULTADO: COHERENTE CON ADVERTENCIAS${NC}"
echo "Advertencias: $WARNINGS"
exit 0
else
echo -e "${RED}RESULTADO: INCOHERENCIAS DETECTADAS${NC}"
echo "Errores: $ERRORS"
echo "Advertencias: $WARNINGS"
exit 1
fi