Comprehensive analysis of 101 DDL tables across 11 schemas: - Phase 1-2: Schema validation, 37 gaps cataloged (3 resolved) - Phase 3: Integrity audit (80 FKs, 89 CHECKs, 17 issues: 2 CRIT/5 HIGH) - Phase 4: DDL-Backend mapping (84% interfaces, 75% services, 61% controllers) - Phase 5: Documentation purge catalog (201 files analyzed) - Phase 6: Remediation plan (4 sprints, 204h) Key finding: Backend uses raw SQL + pg Pool (NOT TypeORM). 13 deliverables + updated inventories to v2.0.0. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
440 lines
16 KiB
YAML
440 lines
16 KiB
YAML
# ═══════════════════════════════════════════════════════════════
|
|
# GAPS-CONSOLIDADO.yml
|
|
# Trading Platform - Inventario Consolidado de Gaps de Modelado
|
|
# ═══════════════════════════════════════════════════════════════
|
|
|
|
version: "1.0.0"
|
|
fecha: "2026-02-05"
|
|
tarea: "TASK-2026-02-05-ANALISIS-VALIDACION-MODELADO-BD"
|
|
|
|
resumen:
|
|
total_gaps: 37
|
|
gaps_p0: 2
|
|
gaps_p1: 14
|
|
gaps_p2: 16
|
|
gaps_p3: 5
|
|
|
|
# ═══════════════════════════════════════════════════════════════
|
|
# P0 - BLOQUEANTES (impiden deployment/creacion de objetos)
|
|
# ═══════════════════════════════════════════════════════════════
|
|
|
|
gaps_p0:
|
|
|
|
- id: "GAP-DDL-P0-001"
|
|
tipo: "FK_ERROR"
|
|
descripcion: "FK incorrecta en price_alerts referencia auth.user_profiles(id) en lugar de auth.users(id)"
|
|
schema: trading
|
|
tabla: price_alerts
|
|
archivo: "apps/database/ddl/schemas/trading/tables/11-price_alerts.sql"
|
|
linea: 15
|
|
impacto: "Tabla NO se puede crear - BLOQUEANTE para deployment"
|
|
correccion: "Cambiar REFERENCES auth.user_profiles(id) -> REFERENCES auth.users(id)"
|
|
esfuerzo: "0.5h"
|
|
estado: RESUELTO
|
|
resuelto_en: "2026-02-05"
|
|
resuelto_por: "Claude Code (Opus 4.6)"
|
|
evidencia: "FK corregida a auth.users(id), comentarios actualizados"
|
|
|
|
- id: "GAP-DDL-P0-002"
|
|
tipo: "SCHEMA_NO_DOCUMENTADO"
|
|
descripcion: "Schema feature_flags completo sin documentar en ningun inventario"
|
|
schema: feature_flags
|
|
tablas_afectadas: ["flags"]
|
|
archivos: ["apps/database/ddl/schemas/feature_flags/tables/01-flags.sql"]
|
|
impacto: "Schema invisible para backend integration"
|
|
correccion: "Documentar en DATABASE_INVENTORY.yml, crear definiciones en docs/"
|
|
esfuerzo: "3h"
|
|
estado: PENDIENTE
|
|
|
|
# ═══════════════════════════════════════════════════════════════
|
|
# P1 - CRITICOS (afectan coherencia y funcionalidad)
|
|
# ═══════════════════════════════════════════════════════════════
|
|
|
|
gaps_p1:
|
|
|
|
# --- TABLAS NO DOCUMENTADAS ---
|
|
|
|
- id: "GAP-INV-P1-001"
|
|
tipo: "TABLA_NO_DOCUMENTADA"
|
|
descripcion: "7 tablas education no documentadas en inventario"
|
|
schema: education
|
|
tablas:
|
|
- instructors
|
|
- course_tags
|
|
- course_tag_assignments
|
|
- review_helpful_votes
|
|
- user_activity_log
|
|
- course_reviews
|
|
- progress
|
|
impacto: "Education schema peor coherencia (63%)"
|
|
esfuerzo: "4h"
|
|
estado: PENDIENTE
|
|
|
|
- id: "GAP-INV-P1-002"
|
|
tipo: "TABLA_NO_DOCUMENTADA"
|
|
descripcion: "2 tablas trading no documentadas"
|
|
schema: trading
|
|
tablas: ["drawing_tools", "drawing_templates"]
|
|
impacto: "Funcionalidad charts sin doc"
|
|
esfuerzo: "2h"
|
|
estado: PENDIENTE
|
|
|
|
- id: "GAP-INV-P1-003"
|
|
tipo: "TABLA_NO_DOCUMENTADA"
|
|
descripcion: "2 tablas financial no documentadas"
|
|
schema: financial
|
|
tablas: ["refunds", "currency_exchange_rates"]
|
|
impacto: "Pagos incompletos sin doc"
|
|
esfuerzo: "2h"
|
|
estado: PENDIENTE
|
|
|
|
- id: "GAP-INV-P1-004"
|
|
tipo: "TABLA_NO_DOCUMENTADA"
|
|
descripcion: "2 tablas ml no documentadas"
|
|
schema: ml
|
|
tablas: ["llm_signals", "prediction_overlays"]
|
|
impacto: "ML overlays sin doc"
|
|
esfuerzo: "2h"
|
|
estado: PENDIENTE
|
|
|
|
- id: "GAP-INV-P1-005"
|
|
tipo: "TABLA_NO_DOCUMENTADA"
|
|
descripcion: "Tablas menores no documentadas en auth, investment, llm, portfolio"
|
|
schemas: ["auth", "investment", "llm", "portfolio", "market_data"]
|
|
tablas:
|
|
auth: ["notifications", "user_push_tokens"]
|
|
investment: ["agent_executions", "risk_questionnaire"]
|
|
llm: ["user_preferences"]
|
|
portfolio: ["portfolio_snapshots"]
|
|
market_data: ["staging"]
|
|
impacto: "Inventarios desactualizados"
|
|
esfuerzo: "4h"
|
|
estado: PENDIENTE
|
|
|
|
# --- CONFLICTOS DE ENUMS ---
|
|
|
|
- id: "GAP-ENUM-P1-001"
|
|
tipo: "ENUM_DUPLICADO"
|
|
descripcion: "transaction_type duplicado en financial e investment"
|
|
schemas: ["financial", "investment"]
|
|
valores_financial: ["deposit", "withdrawal", "transfer_in", "transfer_out", "fee", "refund", "earning", "distribution", "bonus"]
|
|
valores_investment: ["deposit", "withdrawal", "distribution"]
|
|
resolucion: "Opcion B: Mantener separados con calificacion de schema estricta (no-breaking)"
|
|
migracion_referencia: "migrations/2026-02-03_rename_transaction_type_enums.sql"
|
|
estado_migracion: "EXISTE pero solo documentacion (SQL comentado, NO ejecutado)"
|
|
severidad: "ALTA - Valores diferentes, breaking change si se renombra"
|
|
esfuerzo: "2h (documentar) o 8h (renombrar con blue-green deployment)"
|
|
estado: PENDIENTE
|
|
|
|
- id: "GAP-ENUM-P1-002"
|
|
tipo: "ENUM_DUPLICADO"
|
|
descripcion: "risk_profile duplicado en investment y portfolio (valores identicos)"
|
|
schemas: ["investment", "portfolio"]
|
|
valores: ["conservative", "moderate", "aggressive"]
|
|
resolucion: "Crear public.risk_profile para consistencia (opcional, baja prioridad)"
|
|
migracion_existente: false
|
|
sin_documentacion_deprecation: true
|
|
severidad: "BAJA - Valores identicos, no causa conflicto en practica"
|
|
esfuerzo: "2h"
|
|
estado: PENDIENTE
|
|
|
|
- id: "GAP-ENUM-P1-003"
|
|
tipo: "ENUM_INCOMPLETO"
|
|
descripcion: "timeframe: public.trading_timeframe creado pero tablas NO migradas"
|
|
schemas: ["trading", "market_data"]
|
|
tipo_unificado: "public.trading_timeframe (9 valores, ya existe en 00-global-types.sql)"
|
|
tablas_a_migrar:
|
|
- "trading.bots.timeframe -> public.trading_timeframe"
|
|
- "trading.signals.timeframe -> public.trading_timeframe"
|
|
- "trading.drawing_tools.timeframe -> public.trading_timeframe"
|
|
migracion: "migrations/2026-02-03_unify_timeframe_enum.sql (PARCIAL - tipo creado, tablas no)"
|
|
severidad: "MEDIA - Non-breaking, valores compatibles"
|
|
esfuerzo: "2h"
|
|
estado: PENDIENTE
|
|
|
|
# --- DUPLICACION FUNCIONAL ---
|
|
|
|
- id: "GAP-DUP-P1-001"
|
|
tipo: "DUPLICACION_FUNCIONAL"
|
|
descripcion: "Catalogo de simbolos duplicado: trading.symbols vs market_data.tickers"
|
|
objetos:
|
|
- tabla: "trading.symbols"
|
|
pk_tipo: "UUID"
|
|
campos_unicos: ["price_precision", "quantity_precision", "min_quantity", "max_quantity", "min_notional"]
|
|
- tabla: "market_data.tickers"
|
|
pk_tipo: "SERIAL (integer)"
|
|
campos_unicos: ["is_ml_enabled", "supported_timeframes", "polygon_ticker"]
|
|
problema: "PKs de tipo diferente impiden consolidacion simple"
|
|
resolucion: "Consolidar en trading.symbols como master, agregar campos ML"
|
|
esfuerzo: "4h (analisis) + 8h (implementacion)"
|
|
estado: PENDIENTE
|
|
|
|
# --- RELACIONES DEBILES ---
|
|
|
|
- id: "GAP-REL-P1-001"
|
|
tipo: "RELACION_FALTANTE"
|
|
descripcion: "investment.accounts sin FK a financial.wallets"
|
|
tablas: ["investment.accounts", "financial.wallets"]
|
|
impacto: "Cuentas inversion sin wallet vinculado para movimiento de fondos"
|
|
resolucion: "Agregar wallet_id FK en investment.accounts o crear tabla de vinculacion"
|
|
esfuerzo: "2h"
|
|
estado: PENDIENTE
|
|
|
|
- id: "GAP-REL-P1-002"
|
|
tipo: "RELACION_FALTANTE"
|
|
descripcion: "trading.bots sin FK a financial.wallets"
|
|
tablas: ["trading.bots", "financial.wallets"]
|
|
impacto: "Bots sin tracking formal de capital en wallet"
|
|
resolucion: "Agregar wallet_id FK en trading.bots"
|
|
esfuerzo: "1h"
|
|
estado: PENDIENTE
|
|
|
|
- id: "GAP-REL-P1-003"
|
|
tipo: "RELACION_FALTANTE"
|
|
descripcion: "market_data.tickers sin FK a trading.symbols"
|
|
tablas: ["market_data.tickers", "trading.symbols"]
|
|
impacto: "Catalogos desvinculados, inconsistencia de datos"
|
|
resolucion: "Agregar symbol_id FK en market_data.tickers -> trading.symbols"
|
|
esfuerzo: "1h"
|
|
estado: PENDIENTE
|
|
|
|
# ═══════════════════════════════════════════════════════════════
|
|
# P2 - IMPORTANTES (mejoran calidad y mantenibilidad)
|
|
# ═══════════════════════════════════════════════════════════════
|
|
|
|
gaps_p2:
|
|
|
|
# --- BACKEND ENTITIES FALTANTES ---
|
|
|
|
- id: "GAP-BE-P2-001"
|
|
tipo: "ENTITY_FALTANTE"
|
|
descripcion: "Entities backend faltantes para tablas DDL existentes"
|
|
entities_faltantes:
|
|
auth:
|
|
- tabla: "rate_limiting_config"
|
|
- tabla: "user_push_tokens"
|
|
trading:
|
|
- tabla: "price_alerts"
|
|
- tabla: "drawing_tools"
|
|
- tabla: "drawing_templates"
|
|
education:
|
|
- tabla: "user_activity_log"
|
|
- tabla: "review_helpful_votes"
|
|
- tabla: "course_tags"
|
|
- tabla: "course_tag_assignments"
|
|
- tabla: "videos"
|
|
financial:
|
|
- tabla: "wallet_limits"
|
|
- tabla: "currency_exchange_rates"
|
|
- tabla: "refunds"
|
|
investment:
|
|
- tabla: "distribution_history"
|
|
- tabla: "distribution_runs"
|
|
- tabla: "agent_executions"
|
|
ml:
|
|
- tabla: "llm_signals"
|
|
- tabla: "prediction_overlays"
|
|
portfolio:
|
|
- tabla: "rebalance_history"
|
|
- tabla: "portfolio_snapshots"
|
|
market_data:
|
|
- tabla: "ohlcv_5m"
|
|
- tabla: "ohlcv_15m"
|
|
- tabla: "staging"
|
|
audit:
|
|
- tabla: "audit_logs"
|
|
- tabla: "security_events"
|
|
- tabla: "system_events"
|
|
- tabla: "trading_audit"
|
|
- tabla: "api_request_logs"
|
|
- tabla: "data_access_logs"
|
|
- tabla: "compliance_logs"
|
|
feature_flags:
|
|
- tabla: "flags"
|
|
total_entities_faltantes: 31
|
|
esfuerzo_estimado: "62h (2h por entity promedio)"
|
|
estado: PENDIENTE
|
|
|
|
# --- DEFINICIONES DOCUMENTALES FALTANTES ---
|
|
|
|
- id: "GAP-DOC-P2-001"
|
|
tipo: "DEFINICION_FALTANTE"
|
|
descripcion: "Especificaciones tecnicas faltantes para tablas nuevas"
|
|
definiciones:
|
|
- tipo: "ET"
|
|
contenido: "feature_flags schema"
|
|
modulo: "Transversal"
|
|
- tipo: "ET + US"
|
|
contenido: "drawing_tools/templates"
|
|
modulo: "OQI-003"
|
|
- tipo: "US + RF"
|
|
contenido: "price_alerts"
|
|
modulo: "OQI-003"
|
|
- tipo: "ET + US + RF"
|
|
contenido: "refunds"
|
|
modulo: "OQI-005"
|
|
- tipo: "ET + US"
|
|
contenido: "course_tags, instructors"
|
|
modulo: "OQI-002"
|
|
- tipo: "ET + US"
|
|
contenido: "agent_executions"
|
|
modulo: "OQI-004"
|
|
- tipo: "ET"
|
|
contenido: "prediction_overlays, llm_signals"
|
|
modulo: "OQI-006"
|
|
- tipo: "ET"
|
|
contenido: "portfolio_snapshots"
|
|
modulo: "OQI-008"
|
|
total_definiciones: 8
|
|
esfuerzo: "15h"
|
|
estado: PENDIENTE
|
|
|
|
# --- INVENTARIOS DESACTUALIZADOS ---
|
|
|
|
- id: "GAP-DOC-P2-002"
|
|
tipo: "INVENTARIO_DESACTUALIZADO"
|
|
descripcion: "DATABASE_INVENTORY.yml no refleja estado real (81 vs 100 tablas)"
|
|
archivo: "orchestration/inventarios/DATABASE_INVENTORY.yml"
|
|
discrepancia: "19 tablas no registradas"
|
|
esfuerzo: "3h"
|
|
estado: RESUELTO
|
|
resuelto_en: "2026-02-05"
|
|
resuelto_por: "Claude Code (Opus 4.6)"
|
|
evidencia: "DATABASE_INVENTORY.yml actualizado a v2.0.0 con 100 tablas"
|
|
|
|
- id: "GAP-DOC-P2-003"
|
|
tipo: "INVENTARIO_DESACTUALIZADO"
|
|
descripcion: "DDL-COMPLETE-MATRIX.yml incompleto (93 vs 100 tablas)"
|
|
archivo: "orchestration/analisis/coherencia/DDL-COMPLETE-MATRIX.yml"
|
|
discrepancia: "7 tablas no registradas"
|
|
esfuerzo: "2h"
|
|
estado: RESUELTO
|
|
resuelto_en: "2026-02-05"
|
|
resuelto_por: "Claude Code (Opus 4.6)"
|
|
evidencia: "DDL-COMPLETE-MATRIX.yml actualizado a v2.0.0 con 100 tablas, 11 schemas"
|
|
|
|
# --- NAMING INCONSISTENCIES ---
|
|
|
|
- id: "GAP-NAME-P2-001"
|
|
tipo: "NOMENCLATURA_INCONSISTENTE"
|
|
descripcion: "asset_type vs asset_class para mismo concepto"
|
|
tablas:
|
|
- "market_data.tickers usa 'asset_type'"
|
|
- "trading.symbols usa 'asset_class'"
|
|
resolucion: "Estandarizar a 'asset_class' (mas descriptivo)"
|
|
esfuerzo: "1h"
|
|
estado: PENDIENTE
|
|
|
|
# --- SERVICES FALTANTES ---
|
|
|
|
- id: "GAP-SVC-P2-001"
|
|
tipo: "SERVICE_FALTANTE"
|
|
descripcion: "audit schema completo sin servicios backend (7 tablas)"
|
|
schema: audit
|
|
tablas: 7
|
|
servicios_existentes: 0
|
|
esfuerzo: "32h"
|
|
estado: PENDIENTE
|
|
|
|
- id: "GAP-SVC-P2-002"
|
|
tipo: "SERVICE_FALTANTE"
|
|
descripcion: "market_data sin servicio completo de OHLCV"
|
|
schema: market_data
|
|
tablas_afectadas: ["ohlcv_5m", "ohlcv_15m"]
|
|
esfuerzo: "16h"
|
|
estado: PENDIENTE
|
|
|
|
- id: "GAP-SVC-P2-003"
|
|
tipo: "SERVICE_FALTANTE"
|
|
descripcion: "currency_exchange_rates sin servicio de conversion"
|
|
schema: financial
|
|
tabla: currency_exchange_rates
|
|
esfuerzo: "16h"
|
|
estado: PENDIENTE
|
|
|
|
- id: "GAP-SVC-P2-004"
|
|
tipo: "SERVICE_INCOMPLETO"
|
|
descripcion: "bots.service.ts solo 60% implementado"
|
|
schema: trading
|
|
tabla: bots
|
|
faltante: "Operaciones CRUD completas, WebSocket monitoring"
|
|
esfuerzo: "16h"
|
|
estado: PENDIENTE
|
|
|
|
- id: "GAP-SVC-P2-005"
|
|
tipo: "SERVICE_FALTANTE"
|
|
descripcion: "risk assessment service no conectado"
|
|
schema: investment
|
|
tabla: risk_questionnaire
|
|
esfuerzo: "12h"
|
|
estado: PENDIENTE
|
|
|
|
- id: "GAP-SVC-P2-006"
|
|
tipo: "SERVICE_FALTANTE"
|
|
descripcion: "feature_flags sin integracion backend"
|
|
schema: feature_flags
|
|
esfuerzo: "8h"
|
|
estado: PENDIENTE
|
|
|
|
# --- DOCUMENTACION OBSOLETA ---
|
|
|
|
- id: "GAP-PURGE-P2-001"
|
|
tipo: "DOC_OBSOLETA"
|
|
descripcion: "Documentacion obsoleta pendiente de purga"
|
|
archivos:
|
|
- "docs/_archive/04-fase-backlog/ (links rotos)"
|
|
- "docs/_archive/00-notas/NOTA-DISCREPANCIA-PUERTOS-2025-12-08.md (resuelta)"
|
|
- "orchestration/analisis/coherencia/COHERENCE-BASELINE-2026-01-28.md (superseded)"
|
|
esfuerzo: "1h"
|
|
estado: PENDIENTE
|
|
|
|
- id: "GAP-PURGE-P2-002"
|
|
tipo: "TAREAS_SIN_ARCHIVAR"
|
|
descripcion: "Tareas antiguas en carpetas de fecha sin archivar completamente"
|
|
carpetas: ["2026-01-25", "2026-01-27"]
|
|
esfuerzo: "2h"
|
|
estado: PENDIENTE
|
|
|
|
# ═══════════════════════════════════════════════════════════════
|
|
# P3 - MENORES (optimizacion y mejoras)
|
|
# ═══════════════════════════════════════════════════════════════
|
|
|
|
gaps_p3:
|
|
|
|
- id: "GAP-IDX-P3-001"
|
|
tipo: "INDEX_FALTANTE"
|
|
descripcion: "Indices compuestos faltantes para queries frecuentes"
|
|
tablas_afectadas: ["trading.price_alerts", "education.instructors"]
|
|
esfuerzo: "2h"
|
|
estado: PENDIENTE
|
|
|
|
- id: "GAP-DEL-P3-001"
|
|
tipo: "ON_DELETE_REVIEW"
|
|
descripcion: "financial.wallets usa ON DELETE RESTRICT en FK a users"
|
|
impacto: "Impide eliminacion de usuarios con wallet"
|
|
resolucion: "Documentar como decision arquitectural o cambiar a SOFT DELETE"
|
|
esfuerzo: "1h"
|
|
estado: PENDIENTE
|
|
|
|
- id: "GAP-ORPHAN-P3-001"
|
|
tipo: "TABLA_SUBUTILIZADA"
|
|
descripcion: "market_data.staging tabla ETL posiblemente huerfana"
|
|
impacto: "Solo usada por data-service (20% implementado)"
|
|
esfuerzo: "0.5h"
|
|
estado: PENDIENTE
|
|
|
|
- id: "GAP-ORPHAN-P3-002"
|
|
tipo: "TABLA_SUBUTILIZADA"
|
|
descripcion: "auth.rate_limiting_config posiblemente no usado (config hardcoded)"
|
|
impacto: "Tabla existe pero middleware puede usar config estatica"
|
|
esfuerzo: "0.5h"
|
|
estado: PENDIENTE
|
|
|
|
- id: "GAP-ARCH-P3-001"
|
|
tipo: "DECISION_ARQUITECTURAL"
|
|
descripcion: "trading.bots.strategy_type es VARCHAR, no referencia investment.trading_agent"
|
|
impacto: "Acoplamiento debil entre bots y agentes de inversion"
|
|
resolucion: "Evaluar si vincular o mantener separado"
|
|
esfuerzo: "1h"
|
|
estado: PENDIENTE
|