Phase C (Context) and A (Analysis) complete: - Analyzed 11 schemas, ~90 tables, 68+ enums - Identified 15 gaps (4 P0, 4 P1, 7 P2) - Detected 5 conflicts and 3 duplicities - Created validation matrix DDL vs requirements Phase P (Planning) in progress: - 7-phase execution plan with CAPVED compliance - Subtask delegation plan for parallel execution - Estimated effort: 126h (without MT4) Key findings: - GAP-002: financial.refunds missing (P0 - Stripe blocker) - GAP-003: education.instructors missing (P0) - CONF-001: transaction_type enum conflict - DUP-001: timeframe enum duplicated Deliverables created: - 01-CAPTURA.md, 02-ANALISIS.md, 03-PLANIFICACION.md - DDL-GAPS-REGISTRY.yml - DDL-CONFLICTS-REGISTRY.yml - DDL-VALIDATION-MATRIX.yml - DELEGATION-PLAN.yml Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
296 lines
9.0 KiB
YAML
296 lines
9.0 KiB
YAML
# DELEGATION-PLAN.yml
|
|
# Plan de delegación a subagentes para ejecución de la tarea
|
|
# Tarea: TASK-2026-02-03-ANALISIS-DDL-MODELADO
|
|
|
|
metadata:
|
|
fecha_creacion: "2026-02-03"
|
|
orquestador: "claude-opus-4.5"
|
|
total_subagentes: 12
|
|
estrategia: "paralelo_por_fase"
|
|
|
|
# Configuración de tipos de subagentes disponibles
|
|
tipos_subagentes:
|
|
ddl_specialist:
|
|
tipo: "Bash"
|
|
descripcion: "Especialista en operaciones DDL"
|
|
herramientas: ["Read", "Write", "Bash", "Grep", "Glob"]
|
|
permisos:
|
|
- "apps/database/**"
|
|
- "scripts/database/**"
|
|
comandos_permitidos:
|
|
- "psql"
|
|
- "pg_dump"
|
|
- "npm run db:*"
|
|
|
|
backend_sync:
|
|
tipo: "Explore"
|
|
descripcion: "Sincronización DDL-Backend"
|
|
herramientas: ["Read", "Grep", "Glob"]
|
|
permisos:
|
|
- "apps/backend/src/**"
|
|
solo_lectura: true
|
|
|
|
backend_edit:
|
|
tipo: "general-purpose"
|
|
descripcion: "Edición de código backend"
|
|
herramientas: ["Read", "Edit", "Write", "Grep", "Glob"]
|
|
permisos:
|
|
- "apps/backend/src/**"
|
|
|
|
doc_updater:
|
|
tipo: "general-purpose"
|
|
descripcion: "Actualización de documentación"
|
|
herramientas: ["Read", "Edit", "Write"]
|
|
permisos:
|
|
- "docs/**"
|
|
- "orchestration/**"
|
|
|
|
inventory_sync:
|
|
tipo: "general-purpose"
|
|
descripcion: "Sincronización de inventarios"
|
|
herramientas: ["Read", "Edit"]
|
|
permisos:
|
|
- "orchestration/inventarios/**"
|
|
|
|
# Plan de delegación por fase
|
|
delegacion_por_fase:
|
|
|
|
FASE_1:
|
|
nombre: "Gaps Críticos P0"
|
|
estrategia: "paralelo"
|
|
subagentes:
|
|
- id: "SA-1.1"
|
|
tarea: "ST-1.1 FINANCIAL-REFUNDS"
|
|
tipo: "ddl_specialist"
|
|
prompt: |
|
|
Implementar tabla financial.refunds con las siguientes especificaciones:
|
|
|
|
1. Crear archivo: apps/database/ddl/schemas/financial/tables/11-refunds.sql
|
|
2. Campos requeridos:
|
|
- id UUID PK DEFAULT gen_random_uuid()
|
|
- payment_id UUID FK NOT NULL REFERENCES financial.payments(id)
|
|
- amount DECIMAL(18,8) NOT NULL CHECK (amount > 0)
|
|
- reason VARCHAR(500)
|
|
- status financial.refund_status NOT NULL DEFAULT 'pending'
|
|
- stripe_refund_id VARCHAR(100) UNIQUE
|
|
- refunded_by UUID FK REFERENCES auth.users(id)
|
|
- created_at TIMESTAMPTZ DEFAULT NOW()
|
|
- updated_at TIMESTAMPTZ DEFAULT NOW()
|
|
3. Crear enum refund_status si no existe: pending, processing, succeeded, failed
|
|
4. Índices: payment_id, status, created_at
|
|
5. Trigger update_updated_at
|
|
|
|
Validar DDL con: psql -f <archivo> --dry-run
|
|
|
|
- id: "SA-1.2"
|
|
tarea: "ST-1.2 EDUCATION-INSTRUCTORS"
|
|
tipo: "ddl_specialist"
|
|
prompt: |
|
|
Implementar tabla education.instructors con las siguientes especificaciones:
|
|
|
|
1. Crear archivo: apps/database/ddl/schemas/education/tables/17-instructors.sql
|
|
2. Campos:
|
|
- id UUID PK
|
|
- user_id UUID FK UNIQUE NOT NULL REFERENCES auth.users(id)
|
|
- display_name VARCHAR(100) NOT NULL
|
|
- bio TEXT
|
|
- avatar_url VARCHAR(500)
|
|
- expertise TEXT[]
|
|
- social_links JSONB DEFAULT '{}'
|
|
- total_courses INTEGER DEFAULT 0
|
|
- total_students INTEGER DEFAULT 0
|
|
- average_rating DECIMAL(3,2)
|
|
- is_verified BOOLEAN DEFAULT false
|
|
- created_at, updated_at TIMESTAMPTZ
|
|
3. Índices: user_id (unique), is_verified
|
|
4. Agregar FK instructor_id a courses si no existe
|
|
|
|
- id: "SA-1.3"
|
|
tarea: "ST-1.3 TRADING-PRICE-ALERTS-FK"
|
|
tipo: "ddl_specialist"
|
|
prompt: |
|
|
Agregar FK a trading.price_alerts:
|
|
|
|
1. Verificar estructura actual de price_alerts
|
|
2. Crear migración para agregar columna symbol_id UUID
|
|
3. Agregar FK REFERENCES trading.symbols(id)
|
|
4. Crear índice en symbol_id
|
|
5. Script de migración de datos existentes (si hay)
|
|
|
|
- id: "SA-1.4"
|
|
tarea: "ST-1.4 ML-OVERLAY-PREDICCIONES"
|
|
tipo: "ddl_specialist"
|
|
prompt: |
|
|
Completar diseño overlay predicciones ML:
|
|
|
|
1. Revisar estructura actual en ml.predictions
|
|
2. Agregar columnas para overlay si faltan:
|
|
- overlay_data JSONB
|
|
- chart_config JSONB
|
|
- display_priority INTEGER
|
|
3. Crear tabla ml.prediction_overlays si es necesario
|
|
4. Documentar estructura final
|
|
|
|
FASE_2:
|
|
nombre: "Conflictos y Duplicidades"
|
|
estrategia: "secuencial"
|
|
depende_de: ["FASE_1"]
|
|
subagentes:
|
|
- id: "SA-2.1"
|
|
tarea: "ST-2.1 UNIFICAR-ENUMS-TIMEFRAME"
|
|
tipo: "ddl_specialist"
|
|
prompt: |
|
|
Unificar enum timeframe en schema público:
|
|
|
|
1. Crear enum public.trading_timeframe con valores:
|
|
1m, 5m, 15m, 30m, 1h, 4h, 1d, 1w, 1M
|
|
2. Crear migraciones para trading schema
|
|
3. Crear migraciones para market_data schema
|
|
4. Eliminar enums duplicados
|
|
5. Validar integridad post-migración
|
|
|
|
- id: "SA-2.2"
|
|
tarea: "ST-2.2 RESOLVER-TRANSACTION-TYPE"
|
|
tipo: "ddl_specialist"
|
|
depende_de: ["SA-2.1"]
|
|
prompt: |
|
|
Resolver conflicto transaction_type:
|
|
|
|
1. Renombrar financial.transaction_type → financial_tx_type
|
|
2. Renombrar investment.transaction_type → investment_tx_type
|
|
3. Actualizar referencias en tablas
|
|
4. Documentar cambios
|
|
|
|
- id: "SA-2.3"
|
|
tarea: "ST-2.3 UNIFICAR-FUNCIONES"
|
|
tipo: "ddl_specialist"
|
|
depende_de: ["SA-2.2"]
|
|
prompt: |
|
|
Mover funciones comunes a public:
|
|
|
|
1. Crear public.update_updated_at()
|
|
2. Actualizar triggers en todos los schemas
|
|
3. Eliminar funciones duplicadas
|
|
4. Validar triggers funcionan
|
|
|
|
FASE_3:
|
|
nombre: "Gaps Moderados P1"
|
|
estrategia: "paralelo"
|
|
depende_de: ["FASE_2"]
|
|
subagentes:
|
|
- id: "SA-3.1"
|
|
tarea: "ST-3.1 EDUCATION-COURSE-TAGS"
|
|
tipo: "ddl_specialist"
|
|
|
|
- id: "SA-3.2"
|
|
tarea: "ST-3.2 TRADING-DRAWING-TOOLS"
|
|
tipo: "ddl_specialist"
|
|
|
|
- id: "SA-3.3"
|
|
tarea: "ST-3.3 INVESTMENT-AGENT-EXECUTIONS"
|
|
tipo: "ddl_specialist"
|
|
|
|
- id: "SA-3.4"
|
|
tarea: "ST-3.4 ML-INDICES-COMPUESTOS"
|
|
tipo: "ddl_specialist"
|
|
|
|
FASE_5:
|
|
nombre: "Coherencia Backend"
|
|
estrategia: "paralelo"
|
|
depende_de: ["FASE_1", "FASE_2", "FASE_3"]
|
|
subagentes:
|
|
- id: "SA-5.1"
|
|
tarea: "ST-5.1 CREAR-ENTITIES-FALTANTES"
|
|
tipo: "backend_edit"
|
|
prompt: |
|
|
Crear entities TypeORM faltantes:
|
|
|
|
1. education.instructors → instructor.entity.ts
|
|
2. ml.feature_store → feature-store.entity.ts
|
|
3. audit.compliance_logs → compliance-log.entity.ts
|
|
|
|
Seguir patrones existentes en el proyecto.
|
|
Incluir decoradores, validaciones y relaciones.
|
|
|
|
- id: "SA-5.2"
|
|
tarea: "ST-5.2 ACTUALIZAR-ENTITIES"
|
|
tipo: "backend_edit"
|
|
prompt: |
|
|
Actualizar entities existentes para sincronizar con DDL:
|
|
|
|
1. Verificar auth entities vs DDL
|
|
2. Verificar trading entities vs DDL
|
|
3. Verificar financial entities vs DDL
|
|
4. Agregar campos/relaciones faltantes
|
|
|
|
FASE_6:
|
|
nombre: "Documentación"
|
|
estrategia: "paralelo"
|
|
depende_de: ["FASE_5"]
|
|
subagentes:
|
|
- id: "SA-6.1"
|
|
tarea: "ST-6.1 ACTUALIZAR-ESPECIFICACIONES"
|
|
tipo: "doc_updater"
|
|
prompt: |
|
|
Actualizar especificaciones técnicas:
|
|
|
|
1. ET-TRD-003-database.md con tablas actuales
|
|
2. ET-EDU-001-database.md con instructors
|
|
3. Crear ET-FIN-001-database.md (refunds)
|
|
|
|
- id: "SA-6.2"
|
|
tarea: "ST-6.2 ACTUALIZAR-INVENTARIOS"
|
|
tipo: "inventory_sync"
|
|
prompt: |
|
|
Sincronizar inventarios:
|
|
|
|
1. DATABASE_INVENTORY.yml con todos los cambios
|
|
2. BACKEND_INVENTORY.yml con nuevas entities
|
|
3. MASTER_INVENTORY.yml consolidado
|
|
|
|
- id: "SA-6.3"
|
|
tarea: "ST-6.3 PURGAR-OBSOLETOS"
|
|
tipo: "doc_updater"
|
|
prompt: |
|
|
Purgar documentación obsoleta:
|
|
|
|
1. Archivar tareas 2025 a _archive/
|
|
2. Eliminar análisis superados en docs/99-analisis/
|
|
3. Limpiar duplicados en docs/
|
|
|
|
# Coordinación entre subagentes
|
|
coordinacion:
|
|
archivo_bloqueo: "orchestration/trazas/ACTIVE-FILES.yml"
|
|
notificacion_completado: true
|
|
validacion_cruzada: true
|
|
|
|
# Criterios de éxito por subagente
|
|
criterios_exito:
|
|
ddl_specialist:
|
|
- "DDL ejecuta sin errores"
|
|
- "Índices creados correctamente"
|
|
- "Constraints validados"
|
|
|
|
backend_edit:
|
|
- "npm run build pasa"
|
|
- "npm run lint pasa"
|
|
- "Entity exportada en index"
|
|
|
|
doc_updater:
|
|
- "Documentos coherentes con DDL"
|
|
- "Links internos funcionan"
|
|
- "Formato markdown correcto"
|
|
|
|
inventory_sync:
|
|
- "YAML válido"
|
|
- "Conteos actualizados"
|
|
- "Referencias correctas"
|
|
|
|
# Rollback plan
|
|
rollback:
|
|
estrategia: "git_revert_por_fase"
|
|
checkpoints:
|
|
- "post-FASE-1"
|
|
- "post-FASE-2"
|
|
- "post-FASE-3"
|