trading-platform/orchestration/tareas/TASK-2026-02-05-ANALISIS-VALIDACION-MODELADO-BD/entregables/REMEDIATION-CHECKLIST.md
Adrian Flores Cortes b9098ca91c [TASK-2026-02-05-ANALISIS-VALIDACION-MODELADO-BD] docs: Complete 6-phase database modeling analysis
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>
2026-02-05 16:48:45 -06:00

6.5 KiB

REMEDIATION CHECKLIST - Trading Platform Database Modeling

TASK-2026-02-05-ANALISIS-VALIDACION-MODELADO-BD - Fase 6

Fecha: 2026-02-05 Agente: Claude Code (Opus 4.6) Referencia: PLAN-MAESTRO-REMEDIACION.yml


Sprint 1: Quick Wins DDL + Enum Resolution (5 dias, 24h)

DDL Corrections

  • S1-T1 Migrar timeframe enum en 3 tablas (GAP-ENUM-P1-003)

    • trading.bots.timeframe -> public.trading_timeframe
    • trading.signals.timeframe -> public.trading_timeframe
    • trading.drawing_tools.timeframe -> public.trading_timeframe
    • DROP TYPE trading.timeframe
    • DROP TYPE market_data.timeframe (si no tiene dependencias)
  • S1-T2 Agregar FK trading.bots -> financial.wallets (GAP-REL-P1-002)

    • ALTER TABLE trading.bots ADD COLUMN wallet_id UUID REFERENCES financial.wallets(id)
    • Verificar ON DELETE behavior
  • S1-T3 Agregar FK market_data.tickers -> trading.symbols (GAP-REL-P1-003)

    • ALTER TABLE market_data.tickers ADD COLUMN symbol_id UUID REFERENCES trading.symbols(id)
  • S1-T4 Agregar FK investment.accounts -> financial.wallets (GAP-REL-P1-001)

    • Verificar si wallet_id ya existe en DDL
    • Agregar FK si falta
  • S1-T6 Estandarizar asset_type -> asset_class (GAP-NAME-P2-001)

    • Renombrar columna en market_data.tickers

Documentation

  • S1-T5 Documentar decision transaction_type separados (GAP-ENUM-P1-001)

    • Crear ADR en docs/90-adr/
    • Documentar enforcement de schema qualification en backend
  • S1-T7 Documentar feature_flags schema (GAP-DDL-P0-002)

    • ET en docs/02-definicion-modulos/
    • Actualizar CLAUDE.md del proyecto
    • Documentar: flags, user_flags, evaluations
    • Documentar: flag_status, rollout_stage enums
    • Documentar: evaluate_flag() function
  • S1-T9 Crear definiciones para tablas no documentadas

    • education (7): instructors, course_tags, course_tag_assignments, review_helpful_votes, user_activity_log, course_reviews, progress
    • trading (2): drawing_tools, drawing_templates
    • financial (2): refunds, currency_exchange_rates
    • ml (2): llm_signals, prediction_overlays
    • auth (2): notifications, user_push_tokens
    • investment (2): agent_executions, risk_questionnaire
    • llm (1): user_preferences
    • portfolio (1): portfolio_snapshots
    • market_data (1): staging

Operations

  • S1-T8 Ejecutar purga documental
    • Eliminar orchestration/tareas/2026-01-28/ (vacio)
    • Archivar tareas/2026-01-25/TASK-2026-01-25-002-FRONTEND-COMPREHENSIVE-AUDIT/
    • Archivar tareas/2026-01-25/TASK-2026-01-25-FRONTEND-MODULE-DOCS/
    • Archivar tareas/2026-01-27/TASK-2026-01-27-MASTER-ANALYSIS-PLAN/
    • Archivar tareas/2026-02-03/TASK-2026-02-03-DDL-VALIDATION/
    • Archivar coherencia/COHERENCE-BASELINE-2026-01-28.md
    • Archivar coherencia/COHERENCE-FINAL-2026-01-28.md
    • Actualizar _INDEX.yml

Validation

  • S1-T10 Recrear BD en WSL
    • wsl unified-recreate-db.sh trading-platform --drop
    • Verificar 101 tablas se crean sin error
    • Verificar 3 nuevas FKs existen
    • Verificar timeframe enum migrado

Sprint 1 Exit Criteria

  • BD recrea sin errores
  • 0 conflictos de enum activos
  • 3 FKs cross-schema agregadas
  • feature_flags documentado
  • Purga documental ejecutada
  • git commit + push

Sprint 2: Backend Entities (10 dias, 62h)

Entity Creation by Schema

  • S2-T1 Audit (7 entities)

    • AuditLog entity
    • SecurityEvent entity
    • SystemEvent entity
    • TradingAudit entity
    • ApiRequestLog entity
    • DataAccessLog entity
    • ComplianceLog entity
  • S2-T2 Education (5 entities)

    • UserActivityLog entity
    • ReviewHelpfulVote entity
    • CourseTag entity
    • CourseTagAssignment entity
    • Video entity
  • S2-T3 Trading (3 entities)

    • PriceAlert entity
    • DrawingTool entity
    • DrawingTemplate entity
  • S2-T4 Financial (3 entities)

    • WalletLimit entity
    • CurrencyExchangeRate entity
    • Refund entity
  • S2-T5 Investment (3 entities)

    • DistributionHistory entity
    • DistributionRun entity
    • AgentExecution entity
  • S2-T6 Minor schemas (10 entities)

    • ml: LlmSignal, PredictionOverlay
    • portfolio: RebalanceHistory, PortfolioSnapshot
    • market_data: Ohlcv5m, Ohlcv15m, Staging
    • auth: RateLimitingConfig, UserPushToken
    • feature_flags: Flag

Sprint 2 Exit Criteria

  • npm run build exitoso
  • 31 entities creadas
  • Entity coverage >= 95%
  • BACKEND_INVENTORY actualizado
  • git commit + push

Sprint 3: Backend Services (10 dias, 68h)

  • S3-T1 AuditService + SecurityEventService + TradingAuditService + ComplianceService (32h)

    • 5 admin-only endpoints operativos
    • Paginacion + filtros
    • Export CSV/JSON
  • S3-T2 FeatureFlagService (8h)

    • Cache Redis implementado
    • Middleware para route gating
    • 3 endpoints admin + 1 evaluacion
  • S3-T3 BotsService completado (16h)

    • CRUD completo
    • WebSocket monitoring
    • Wallet integration
  • S3-T4 RiskAssessmentService (12h)

    • Cuestionario + scoring
    • 3 endpoints

Sprint 3 Exit Criteria

  • Audit endpoints respondiendo
  • Feature flags con cache
  • Bots service 100%
  • Risk assessment calculando
  • npm run build exitoso
  • git commit + push

Sprint 4: Consolidation (10 dias, 50h)

  • S4-T1 Consolidar symbols/tickers (12h)

    • Campos ML agregados a trading.symbols
    • Migracion de datos
    • Referencias actualizadas
    • BD recreada y validada
  • S4-T2 Market Data OHLCV Service (16h)

  • S4-T3 Currency Exchange Service (8h)

  • S4-T4 Definiciones documentales completas (10h)

  • S4-T5 Gaps P3 resueltos (4h)

Sprint 4 Exit Criteria

  • 1 catalogo simbolos unificado
  • 0 gaps pendientes (37/37 resueltos)
  • Coherencia global >= 90%
  • COHERENCE-MASTER-REPORT v2.0 generado
  • ROADMAP-2026-Q1 v2.0 actualizado
  • git commit + push

Post-Remediacion

  • Actualizar COHERENCE-MASTER-REPORT.md con metricas finales
  • Actualizar ROADMAP-2026-Q1.yml a v2.0.0
  • Actualizar MASTER_INVENTORY.yml
  • Actualizar DDL-BACKEND-COHERENCE.yml
  • Generar ANALISIS-FINAL-REMEDIACION.md
  • Marcar TASK como COMPLETADA en METADATA.yml

Generado por Claude Code (Opus 4.6) - TASK-2026-02-05-ANALISIS-VALIDACION-MODELADO-BD