# 03-PLANIFICACIÓN (P) - Plan de Subtareas **Tarea:** TASK-2026-02-03-ANALISIS-DDL-MODELADO **Fase:** Planificación (P) **Estado:** EN PROGRESO **Fecha:** 2026-02-03 --- ## 1. ESTRUCTURA JERÁRQUICA DE TAREAS ``` TASK-2026-02-03-ANALISIS-DDL-MODELADO (RAÍZ) │ ├── FASE-1: GAPS CRÍTICOS (P0) ────────────────────────────────────── │ │ │ ├── 1.1 FINANCIAL-REFUNDS │ │ ├── 1.1.1 Diseñar tabla refunds (DDL) │ │ ├── 1.1.2 Crear entity backend │ │ ├── 1.1.3 Documentar especificación │ │ └── 1.1.4 Actualizar inventarios │ │ │ ├── 1.2 EDUCATION-INSTRUCTORS │ │ ├── 1.2.1 Diseñar tabla instructors (DDL) │ │ ├── 1.2.2 Crear entity backend │ │ ├── 1.2.3 Agregar FK a courses │ │ └── 1.2.4 Documentar │ │ │ ├── 1.3 TRADING-PRICE-ALERTS-FK │ │ ├── 1.3.1 Agregar FK symbol_id │ │ ├── 1.3.2 Migración datos existentes │ │ └── 1.3.3 Actualizar entity │ │ │ └── 1.4 ML-OVERLAY-PREDICCIONES │ ├── 1.4.1 Diseñar estructura overlay │ ├── 1.4.2 Crear tablas auxiliares │ └── 1.4.3 Documentar │ ├── FASE-2: CONFLICTOS Y DUPLICIDADES ─────────────────────────────── │ │ │ ├── 2.1 UNIFICAR-ENUMS-TIMEFRAME │ │ ├── 2.1.1 Crear enum público trading_timeframe │ │ ├── 2.1.2 Migrar referencias trading │ │ ├── 2.1.3 Migrar referencias market_data │ │ └── 2.1.4 Eliminar duplicados │ │ │ ├── 2.2 RESOLVER-TRANSACTION-TYPE-CONFLICT │ │ ├── 2.2.1 Renombrar financial.transaction_type │ │ ├── 2.2.2 Renombrar investment.transaction_type │ │ └── 2.2.3 Actualizar referencias backend │ │ │ └── 2.3 UNIFICAR-FUNCIONES-COMUNES │ ├── 2.3.1 Mover update_updated_at() a public │ ├── 2.3.2 Actualizar triggers │ └── 2.3.3 Eliminar duplicados │ ├── FASE-3: GAPS MODERADOS (P1) ───────────────────────────────────── │ │ │ ├── 3.1 EDUCATION-COURSE-TAGS │ │ ├── 3.1.1 Diseñar tabla course_tags │ │ ├── 3.1.2 Crear tabla course_tag_assignments (M:N) │ │ └── 3.1.3 Agregar índices GIN │ │ │ ├── 3.2 TRADING-DRAWING-TOOLS │ │ ├── 3.2.1 Diseñar tabla drawing_tools │ │ ├── 3.2.2 Diseñar tabla user_drawings │ │ └── 3.2.3 Crear entity backend │ │ │ ├── 3.3 INVESTMENT-AGENT-EXECUTIONS │ │ ├── 3.3.1 Completar columnas faltantes │ │ ├── 3.3.2 Agregar índices performance │ │ └── 3.3.3 Actualizar entity │ │ │ └── 3.4 ML-INDICES-COMPUESTOS │ ├── 3.4.1 Crear índice symbol+timeframe+created │ └── 3.4.2 Optimizar queries existentes │ ├── FASE-4: GAPS MENORES (P2) ─────────────────────────────────────── │ │ │ ├── 4.1 AUTH-INDICE-LOCKED-UNTIL │ │ │ ├── 4.2 EDUCATION-REVIEW-SOFT-DELETE │ │ │ ├── 4.3 AUDIT-PARTICIONAMIENTO │ │ │ ├── 4.4 LLM-INDICE-GIN-TAGS │ │ │ └── 4.5 ESTANDARIZAR-TIMESTAMPS │ ├── FASE-5: COHERENCIA BACKEND ────────────────────────────────────── │ │ │ ├── 5.1 CREAR-ENTITIES-FALTANTES │ │ ├── 5.1.1 education.instructors entity │ │ ├── 5.1.2 ml.feature_store entity │ │ └── 5.1.3 audit.compliance_logs entity │ │ │ └── 5.2 ACTUALIZAR-ENTITIES-EXISTENTES │ ├── 5.2.1 Sincronizar auth entities │ ├── 5.2.2 Sincronizar trading entities │ └── 5.2.3 Sincronizar financial entities │ ├── FASE-6: DOCUMENTACIÓN ─────────────────────────────────────────── │ │ │ ├── 6.1 ACTUALIZAR-ESPECIFICACIONES │ │ ├── 6.1.1 ET-TRD-003-database.md │ │ ├── 6.1.2 ET-EDU-001-database.md │ │ └── 6.1.3 ET-FIN-001-database.md (crear) │ │ │ ├── 6.2 ACTUALIZAR-INVENTARIOS │ │ ├── 6.2.1 DATABASE_INVENTORY.yml │ │ ├── 6.2.2 BACKEND_INVENTORY.yml │ │ └── 6.2.3 MASTER_INVENTORY.yml │ │ │ └── 6.3 PURGAR-OBSOLETOS │ ├── 6.3.1 Archivar tareas 2025 │ ├── 6.3.2 Eliminar análisis superados │ └── 6.3.3 Limpiar duplicados docs │ └── FASE-7: MT4 (CONDICIONAL) ─────────────────────────────────────── │ └── 7.1 OQI-009-DDL (si se aprueba) ├── 7.1.1 Diseñar schema mt4 ├── 7.1.2 Crear tablas conexiones ├── 7.1.3 Crear tablas ejecuciones └── 7.1.4 Documentar ``` --- ## 2. DETALLE DE SUBTAREAS NIVEL 1 ### FASE-1: GAPS CRÍTICOS (P0) #### 1.1 FINANCIAL-REFUNDS ```yaml id: "ST-1.1" nombre: "Implementar tabla financial.refunds" tipo: "DDL + Backend" prioridad: P0 esfuerzo: 8h bloquea: ["OQI-005 Stripe refunds"] bloqueada_por: [] subtareas: 1.1.1: nombre: "Diseñar tabla refunds (DDL)" esfuerzo: 2h entregable: "ddl/schemas/financial/tables/11-refunds.sql" criterios: - Campos: id, payment_id FK, amount, reason, status, stripe_refund_id - Índices: payment_id, status, created_at - Constraints: amount > 0, status enum 1.1.2: nombre: "Crear entity backend" esfuerzo: 3h entregable: "apps/backend/src/modules/payments/entities/refund.entity.ts" depende_de: ["1.1.1"] criterios: - TypeORM entity completa - Relación con Payment - Validaciones DTO 1.1.3: nombre: "Documentar especificación" esfuerzo: 2h entregable: "docs/02-definicion-modulos/OQI-005-pagos-stripe/especificaciones/ET-PAY-005-refunds.md" depende_de: ["1.1.1"] 1.1.4: nombre: "Actualizar inventarios" esfuerzo: 1h entregable: "orchestration/inventarios/*.yml" depende_de: ["1.1.2", "1.1.3"] capved: C: Vincular a OQI-005 A: Gap confirmado en análisis P: Este plan V: Build + lint + test E: Ejecutar 1.1.1 → 1.1.4 D: Actualizar inventarios ``` #### 1.2 EDUCATION-INSTRUCTORS ```yaml id: "ST-1.2" nombre: "Implementar tabla education.instructors" tipo: "DDL + Backend" prioridad: P0 esfuerzo: 10h bloquea: ["OQI-002 Video upload"] bloqueada_por: [] subtareas: 1.2.1: nombre: "Diseñar tabla instructors (DDL)" esfuerzo: 2h entregable: "ddl/schemas/education/tables/17-instructors.sql" criterios: - Campos: id, user_id FK, display_name, bio, avatar_url, expertise, social_links JSONB - Índices: user_id unique - Relación 1:1 con auth.users 1.2.2: nombre: "Crear entity backend" esfuerzo: 3h entregable: "apps/backend/src/modules/education/entities/instructor.entity.ts" depende_de: ["1.2.1"] 1.2.3: nombre: "Agregar FK instructor_id a courses" esfuerzo: 3h entregable: "Migración courses" depende_de: ["1.2.1"] 1.2.4: nombre: "Documentar" esfuerzo: 2h entregable: "ET-EDU-001-database.md actualizado" depende_de: ["1.2.2", "1.2.3"] ``` #### 1.3 TRADING-PRICE-ALERTS-FK ```yaml id: "ST-1.3" nombre: "Agregar FK a trading.price_alerts" tipo: "DDL + Migration" prioridad: P0 esfuerzo: 6h bloquea: [] bloqueada_por: [] subtareas: 1.3.1: nombre: "Agregar FK symbol_id" esfuerzo: 2h entregable: "Migración DDL" 1.3.2: nombre: "Migrar datos existentes" esfuerzo: 2h entregable: "Script migración" depende_de: ["1.3.1"] 1.3.3: nombre: "Actualizar entity" esfuerzo: 2h entregable: "price-alert.entity.ts" depende_de: ["1.3.2"] ``` #### 1.4 ML-OVERLAY-PREDICCIONES ```yaml id: "ST-1.4" nombre: "Completar overlay predicciones ML" tipo: "DDL" prioridad: P0 esfuerzo: 8h bloquea: ["OQI-006 señales overlay"] bloqueada_por: [] subtareas: 1.4.1: nombre: "Diseñar estructura overlay" esfuerzo: 3h entregable: "Especificación técnica" 1.4.2: nombre: "Crear tablas auxiliares" esfuerzo: 3h entregable: "DDL files" depende_de: ["1.4.1"] 1.4.3: nombre: "Documentar" esfuerzo: 2h entregable: "ET-ML-003-overlay.md" depende_de: ["1.4.2"] ``` --- ### FASE-2: CONFLICTOS Y DUPLICIDADES #### 2.1 UNIFICAR-ENUMS-TIMEFRAME ```yaml id: "ST-2.1" nombre: "Unificar enum timeframe en schema público" tipo: "DDL + Migration" prioridad: P1 esfuerzo: 8h bloquea: [] bloqueada_por: ["ST-1.3", "ST-1.4"] subtareas: 2.1.1: nombre: "Crear enum público trading_timeframe" esfuerzo: 1h entregable: "ddl/00-types.sql" 2.1.2: nombre: "Migrar referencias trading" esfuerzo: 3h entregable: "Migración trading schema" depende_de: ["2.1.1"] 2.1.3: nombre: "Migrar referencias market_data" esfuerzo: 3h entregable: "Migración market_data schema" depende_de: ["2.1.1"] 2.1.4: nombre: "Eliminar duplicados" esfuerzo: 1h entregable: "DDL cleanup" depende_de: ["2.1.2", "2.1.3"] ``` #### 2.2 RESOLVER-TRANSACTION-TYPE-CONFLICT ```yaml id: "ST-2.2" nombre: "Resolver conflicto transaction_type" tipo: "DDL + Backend" prioridad: P1 esfuerzo: 6h subtareas: 2.2.1: nombre: "Renombrar financial.transaction_type → financial_tx_type" esfuerzo: 2h 2.2.2: nombre: "Renombrar investment.transaction_type → investment_tx_type" esfuerzo: 2h 2.2.3: nombre: "Actualizar referencias backend" esfuerzo: 2h depende_de: ["2.2.1", "2.2.2"] ``` #### 2.3 UNIFICAR-FUNCIONES-COMUNES ```yaml id: "ST-2.3" nombre: "Mover funciones comunes a public" tipo: "DDL" prioridad: P2 esfuerzo: 4h subtareas: 2.3.1: nombre: "Mover update_updated_at() a public" esfuerzo: 1h 2.3.2: nombre: "Actualizar triggers" esfuerzo: 2h depende_de: ["2.3.1"] 2.3.3: nombre: "Eliminar duplicados en schemas" esfuerzo: 1h depende_de: ["2.3.2"] ``` --- ### FASE-3: GAPS MODERADOS (P1) ```yaml subtareas: 3.1: "EDUCATION-COURSE-TAGS" (6h) 3.2: "TRADING-DRAWING-TOOLS" (12h) 3.3: "INVESTMENT-AGENT-EXECUTIONS" (4h) 3.4: "ML-INDICES-COMPUESTOS" (2h) total_fase: 24h depende_de: ["FASE-1", "FASE-2"] ``` --- ### FASE-4: GAPS MENORES (P2) ```yaml subtareas: 4.1: "AUTH-INDICE-LOCKED-UNTIL" (1h) 4.2: "EDUCATION-REVIEW-SOFT-DELETE" (2h) 4.3: "AUDIT-PARTICIONAMIENTO" (8h) 4.4: "LLM-INDICE-GIN-TAGS" (1h) 4.5: "ESTANDARIZAR-TIMESTAMPS" (4h) total_fase: 16h depende_de: ["FASE-3"] ``` --- ### FASE-5: COHERENCIA BACKEND ```yaml subtareas: 5.1: "CREAR-ENTITIES-FALTANTES" (12h) 5.2: "ACTUALIZAR-ENTITIES-EXISTENTES" (8h) total_fase: 20h depende_de: ["FASE-1", "FASE-2", "FASE-3"] ``` --- ### FASE-6: DOCUMENTACIÓN ```yaml subtareas: 6.1: "ACTUALIZAR-ESPECIFICACIONES" (8h) 6.2: "ACTUALIZAR-INVENTARIOS" (4h) 6.3: "PURGAR-OBSOLETOS" (4h) total_fase: 16h ejecutar: "Paralelo con FASE-4 y FASE-5" ``` --- ### FASE-7: MT4 (CONDICIONAL) ```yaml condicion: "Si stakeholder aprueba implementación MT4" subtareas: 7.1: "OQI-009-DDL" (40h) total_fase: 40h (condicional) depende_de: ["Decisión stakeholder"] ``` --- ## 3. ORDEN DE EJECUCIÓN ``` ┌─────────────┐ │ FASE-1 │ ← Gaps Críticos (P0) │ 32h │ Paralelo: 1.1 || 1.2 || 1.3 || 1.4 └──────┬──────┘ │ ▼ ┌─────────────┐ │ FASE-2 │ ← Conflictos │ 18h │ Secuencial: 2.1 → 2.2 → 2.3 └──────┬──────┘ │ ▼ ┌─────────────┐ │ FASE-3 │ ← Gaps Moderados (P1) │ 24h │ Paralelo: 3.1 || 3.2 || 3.3 || 3.4 └──────┬──────┘ │ ┌──────┴──────┐ │ │ ▼ ▼ ┌─────────┐ ┌─────────┐ │ FASE-4 │ │ FASE-5 │ ← Paralelo │ 16h │ │ 20h │ └────┬────┘ └────┬────┘ │ │ └──────┬──────┘ │ ▼ ┌─────────────┐ │ FASE-6 │ ← Documentación (paralelo parcial) │ 16h │ └──────┬──────┘ │ ▼ (condicional) ┌─────────────┐ │ FASE-7 │ ← MT4 (si aprobado) │ 40h │ └─────────────┘ TOTAL SIN MT4: ~126h (~16 días-hombre) TOTAL CON MT4: ~166h (~21 días-hombre) ``` --- ## 4. ASIGNACIÓN DE SUBAGENTES ### 4.1 Por Fase | Fase | Subagente | Tipo | Ejecución | |------|-----------|------|-----------| | FASE-1 | 4 subagentes | Explore + Plan | Paralelo | | FASE-2 | 1 subagente | Bash (DDL) | Secuencial | | FASE-3 | 4 subagentes | Explore + Plan | Paralelo | | FASE-4 | 2 subagentes | Bash (DDL) | Paralelo | | FASE-5 | 2 subagentes | Explore + Edit | Paralelo | | FASE-6 | 3 subagentes | Explore + Edit | Paralelo | | FASE-7 | 1 subagente | Plan | Condicional | ### 4.2 Configuración Subagentes ```yaml subagentes: ddl-specialist: tipo: "Bash" herramientas: ["Read", "Write", "Bash", "Grep"] permisos: ["apps/database/**"] backend-sync: tipo: "Explore" herramientas: ["Read", "Grep", "Glob"] permisos: ["apps/backend/**"] doc-updater: tipo: "Edit" herramientas: ["Read", "Edit", "Write"] permisos: ["docs/**", "orchestration/**"] inventory-sync: tipo: "Edit" herramientas: ["Read", "Edit"] permisos: ["orchestration/inventarios/**"] ``` --- ## 5. CRITERIOS DE ACEPTACIÓN GLOBALES ```yaml validaciones_obligatorias: - DDL ejecuta sin errores en PostgreSQL 16+ - Backend compila (npm run build) - Lint pasa (npm run lint) - Inventarios actualizados y coherentes - Especificaciones técnicas actualizadas - No quedan gaps P0 abiertos gates: FASE-1_done: "Todos los gaps P0 cerrados" FASE-2_done: "Cero conflictos de nomenclatura" FASE-3_done: "Todos los gaps P1 cerrados" FASE-4_done: "Todos los gaps P2 cerrados" FASE-5_done: "100% coherencia DDL↔Backend" FASE-6_done: "Inventarios 100% sincronizados" ``` --- ## 6. RIESGOS Y MITIGACIÓN | Riesgo | Probabilidad | Impacto | Mitigación | |--------|--------------|---------|------------| | Migración datos rompe integridad | Media | Alto | Ejecutar en BD de prueba primero | | Backend no compila post-cambios | Media | Alto | Ejecutar build incremental | | Conflictos en parallel execution | Baja | Medio | Coordinar via ACTIVE-FILES.yml | | MT4 aprobado sin recursos | Media | Medio | Estimar recursos antes de aprobar | --- ## 7. PRÓXIMOS PASOS 1. **VALIDACIÓN (V):** Revisar este plan con stakeholders 2. **APROBACIÓN:** Confirmar prioridades y orden 3. **EJECUCIÓN (E):** Iniciar FASE-1 con subagentes paralelos 4. **DOCUMENTACIÓN (D):** Actualizar al cierre de cada fase --- **Fase P EN PROGRESO** | Fecha: 2026-02-03 | Agente: claude-opus-4.5