workspace-v1/orchestration/analisis/PLAN-EJECUCION-REFINADO-2026-Q1.md
rckrdmrd ff3038f183 feat(orchestration): Add subagent token management system
Sistema completo de gestión de tokens para subagentes NEXUS v4.0:

Nuevas directivas SIMCO:
- SIMCO-SUBAGENTE.md: Protocolo para agentes en modo subagente
- SIMCO-CCA-SUBAGENTE.md: CCA ligero para subagentes (~1,500 tokens)
- SIMCO-CONTROL-TOKENS.md: Gestión de límites de tokens
- SIMCO-DELEGACION-PARALELA.md: Delegación paralela

Perfiles compact (~250 tokens cada uno):
- PERFIL-BACKEND-COMPACT.md
- PERFIL-FRONTEND-COMPACT.md
- PERFIL-DATABASE-COMPACT.md
- PERFIL-DEVOPS-COMPACT.md
- PERFIL-ML-COMPACT.md
- PERFIL-GENERIC-SUBAGENT.md

Templates de delegación escalonados:
- TEMPLATE-DELEGACION-MINIMA.md (~250 tokens)
- TEMPLATE-DELEGACION-ESTANDAR.md (~600 tokens)
- TEMPLATE-DELEGACION-COMPLETA.md (~1,800 tokens)

Nuevos perfiles especializados:
- PERFIL-MCP-ARCHITECT.md
- PERFIL-MCP-DEVELOPER.md
- PERFIL-RAG-ENGINEER.md
- PERFIL-CICD-SPECIALIST.md
- PERFIL-PRODUCTION-MANAGER.md
- PERFIL-MONITORING-AGENT.md
- PERFIL-SECRETS-MANAGER.md
- PERFIL-PROPAGATION-TRACKER.md

Checklists y documentación:
- CHECKLIST-PRE-DELEGACION.md
- Análisis y planes de implementación

Métricas de mejora:
- ~59% reducción de tokens por delegación
- Perfiles compact: 69% más ligeros
- CCA subagente: 85% más ligero

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

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-07 04:43:01 -06:00

407 lines
12 KiB
Markdown

# PLAN DE EJECUCION REFINADO - WORKSPACE-V1 Q1 2026
**Sistema:** NEXUS v4.0 + SIMCO
**Fecha:** 2026-01-04
**Version:** 1.1.0 (Refinado)
**Estado:** APROBADO PARA EJECUCION
---
## RESUMEN EJECUTIVO
### Prioridades Confirmadas
```
1. GAMILIT - Concluir desarrollo (65% → 85%+)
2. TRADING PLATFORM - ML + MT4 + LLM + Backtesting (90% → 100%)
3. ERP CONSTRUCCION - Desarrollo vertical (35% → 60%)
4. ERP MECANICAS - MVP completo (40% → 100% frontend)
```
### Alcances Especificos
#### Trading Platform (Confirmado por Usuario)
```yaml
INCLUIDO:
- Plataforma web visualizacion predicciones ML
- Integracion MT4 via MetaAPI
- LLM Agent para analisis de predicciones
- Fine-tuning LLM con estrategias TRADING-STRATEGIST
- Backtesting (excluir 2025 para validacion)
- Decisiones automaticas ML + LLM + MT4
EXCLUIDO:
- Modulos de educacion (OQI-002)
- Contenido educativo
- Cursos y certificados
```
---
## CRONOGRAMA REFINADO
### Vista General
```
S1 S2 S3 S4 S5+
┌──────────┬──────────┬──────────┬──────────┬──────────┐
│ FASE 1 │ FASE 2 │ FASE 4 (ERPs) │
│ Gamilit │ Trading ├──────────┬──────────┤ │
│ P0 │ Core │ ERP-C │ ERP-C │ Review │
│ │ │ Backend │ Backend │ │
├──────────┼──────────┼──────────┼──────────┤ │
│ │ GATE │ ERP-D │ ERP-D │ │
│ │ TRADING │ Frontend │ Frontend │ │
├──────────┼──────────┼──────────┴──────────┤ │
│ │ FASE 3 │ FASE 5 (Gamilit P1) │
│ │ Trading │ (Paralelo) │
│ │ Integ │ │
└──────────┴──────────┴───────────────────────────────┘
```
### Detalle por Semana
#### SEMANA 1: Estabilizacion + Inicio Trading
| Dia | Proyecto | Tarea | Agente | Entregable |
|-----|----------|-------|--------|------------|
| 1-2 | Gamilit | P0 Bloqueadores | Database + Backend | Enums sync, routes fix, guards |
| 2 | Gamilit | Token Refresh | Backend-Agent | Endpoint funcional |
| 3 | Trading | MT4 Gateway setup | Backend + DevOps | Estructura MetaAPI |
| 4-5 | Trading | Backtesting config | ML-Specialist | Excluir 2025, walk-forward |
**Gate S1:** Gamilit P0 100% resuelto
#### SEMANA 2: Trading Core + Gate Validacion
| Dia | Proyecto | Tarea | Agente | Entregable |
|-----|----------|-------|--------|------------|
| 1-2 | Trading | MT4 Gateway impl | Backend-Agent | Endpoints funcionales |
| 2-3 | Trading | LLM Fine-tuning | LLM-Agent + T-Strategist | Modelo ajustado |
| 4 | Trading | **GATE TRADING** | Trading-Strategist | Metricas validadas |
| 5 | Trading | Integracion | Architecture-Analyst | Sistema conectado |
**Gate Trading (OBLIGATORIO):**
```yaml
metricas_requeridas:
sharpe_ratio: ">= 1.0"
sortino_ratio: ">= 1.5"
max_drawdown: "<= 20%"
win_rate: ">= 40%"
profit_factor: ">= 1.5"
validacion_requerida:
- Walk-forward: OK
- Out-of-sample: Positivo
- Overfitting: No detectado
decision:
- APROBADO: Continuar a Fase 3
- RECHAZADO: Iterar con ML-Specialist
```
#### SEMANA 3-4: ERPs + Gamilit P1 (Paralelo)
| Track | Proyecto | Tarea | Agente | Entregable |
|-------|----------|-------|--------|------------|
| A | ERP-Construccion | Controllers REST | Backend-Agent | 6 modulos nuevos |
| A | ERP-Construccion | Tests | Testing-Agent | Coverage 60%+ |
| B | ERP-Diesel | Frontend MMD-001 | Frontend-Agent | Fundamentos UI |
| B | ERP-Diesel | Frontend MMD-002-006 | Frontend-Agent | 5 modulos UI |
| C | Gamilit | Type Safety | Frontend-Agent | 80% coverage |
| C | Gamilit | Audit Module | Backend-Agent | Logging funcional |
**Gates S3-S4:**
- ERP-Construccion: Backend 60%+
- ERP-Diesel: Frontend MVP 100%
- Gamilit: Type safety 80%+
---
## ASIGNACION DE AGENTES POR FASE
### FASE 1: Gamilit P0 (2 dias)
```yaml
equipo:
lider: Tech-Leader
ejecutores:
- Database-Agent:
tarea: "Migracion SQL enums"
archivos:
- apps/database/migrations/sync-enums.sql
estimacion: 2-3h
- Backend-Agent:
tarea: "Route order fix + Token refresh"
archivos:
- apps/backend/src/modules/educational/educational.controller.ts
- apps/backend/src/modules/social/social.controller.ts
- apps/backend/src/modules/auth/session-management.service.ts
estimacion: 3-4h
- Security-Auditor:
tarea: "Habilitar guards"
archivos:
- apps/backend/src/modules/gamification/user-stats.controller.ts
- apps/backend/src/modules/gamification/achievements.controller.ts
estimacion: 15min
validador: Testing-Agent
```
### FASE 2: Trading Core (5 dias)
```yaml
equipo:
lider: Tech-Leader
ejecutores:
- Backend-Agent:
tarea: "MT4 Gateway"
archivos:
- apps/mt4-gateway/src/main.py
- apps/mt4-gateway/src/metaapi_client.py
- apps/mt4-gateway/src/trade_manager.py
referencia: docs/01-arquitectura/INTEGRACION-METATRADER4.md
- ML-Specialist:
tarea: "Backtesting configuracion"
archivos:
- apps/ml-engine/src/backtesting/config.yaml
- apps/ml-engine/src/pipelines/phase2_pipeline.py
config:
exclude_year: 2025
walk_forward: true
- LLM-Agent:
tarea: "Fine-tuning con estrategias"
archivos:
- apps/llm-agent/src/prompts/system.txt
- apps/llm-agent/src/tools/trading_tools.py
referencia: docs/.../estrategias/ESTRATEGIA-AMD-COMPLETA.md
- Trading-Strategist:
tarea: "Validar estrategias + metricas"
referencia: orchestration/agents/perfiles/PERFIL-TRADING-STRATEGIST.md
validador: Trading-Strategist (Gate Trading)
```
### FASE 3: Trading Integration (3 dias)
```yaml
equipo:
lider: Trading-Strategist
ejecutores:
- Backend-Agent:
tarea: "Conectar ML + LLM + MT4"
- DevOps-Agent:
tarea: "Docker compose servicios"
- Testing-Agent:
tarea: "Tests E2E integracion"
validador: Architecture-Analyst
```
### FASE 4: ERPs (10 dias, paralelo)
```yaml
track_construccion:
lider: Backend-Agent
tarea: "Controllers REST + Services"
modulos_target:
- MAI-004 Compras
- MAI-009 Calidad
- MAI-011 INFONAVIT
- MAI-012 Contratos
validador: Testing-Agent
track_diesel:
lider: Frontend-Agent
tarea: "Frontend MVP completo"
modulos_target:
- MMD-001 Fundamentos
- MMD-002 Ordenes Servicio
- MMD-003 Diagnosticos
- MMD-004 Inventario
- MMD-005 Vehiculos
- MMD-006 Cotizaciones
validador: Testing-Agent
```
### FASE 5: Gamilit P1 (10 dias, paralelo con FASE 4)
```yaml
equipo:
lider: Frontend-Agent
ejecutores:
- Frontend-Agent:
tarea: "Type Safety 80%+"
archivos:
- apps/frontend/src/types/gamification.types.ts (crear)
- apps/frontend/src/types/educational.types.ts (expandir)
- apps/frontend/src/types/admin.types.ts (crear)
- Backend-Agent:
tarea: "Audit Logging Module"
archivos:
- apps/backend/src/modules/audit/ (nuevo)
validador: Code-Reviewer + Testing-Agent
```
---
## PROTOCOLO DE GATES
### Gate 1: Pre-Desarrollo (Cada tarea)
```yaml
checklist:
- [ ] CONTEXTO-PROYECTO.md cargado
- [ ] PROXIMA-ACCION.md actualizado
- [ ] Archivos a modificar identificados
- [ ] Dependencias verificadas
- [ ] Tests actuales pasan
```
### Gate 2: Pre-Ejecucion (Cada subtarea)
```yaml
checklist:
- [ ] Plan detallado escrito
- [ ] Agente asignado correcto
- [ ] Archivos dependientes identificados
- [ ] Build pasa
- [ ] Lint pasa
```
### Gate 3: Post-Ejecucion (Cada subtarea)
```yaml
checklist:
- [ ] Cambios implementados
- [ ] Build pasa
- [ ] Lint pasa
- [ ] Tests nuevos escritos
- [ ] Tests pasan
- [ ] Documentacion actualizada
- [ ] Inventario actualizado
```
### Gate Trading (Especifico - Fin FASE 2)
```yaml
metricas_obligatorias:
sharpe_ratio: ">= 1.0"
sortino_ratio: ">= 1.5"
max_drawdown: "<= 20%"
win_rate: ">= 40%"
profit_factor: ">= 1.5"
validaciones_obligatorias:
- [ ] Backtest minimo 2 años
- [ ] Año 2025 excluido de training
- [ ] Walk-forward validation OK
- [ ] Out-of-sample positivo
- [ ] Sin overfitting detectado
- [ ] Parametros documentados
decision:
APROBADO:
condicion: "Todas las metricas dentro de umbrales"
accion: "Continuar a FASE 3 (Integracion)"
RECHAZADO:
condicion: "Alguna metrica fuera de umbral"
accion: "Iterar con ML-Specialist"
max_iteraciones: 3
```
---
## ROLLBACK Y CONTINGENCIAS
### Rollback MT4 Gateway
```yaml
si_metaapi_falla:
opcion_1: "Usar Binance Testnet directo"
opcion_2: "Implementar broker mock"
opcion_3: "Escalar a plan MetaAPI superior"
decision: "Documentar en REGISTRO-ERRORES.yml"
```
### Rollback LLM Fine-tuning
```yaml
si_llama3_insuficiente:
opcion_1: "Fallback a Claude API"
opcion_2: "Usar modelo Mistral 7B"
opcion_3: "Aumentar contexto en prompts"
decision: "Consultar con Trading-Strategist"
```
### Rollback Metricas Trading
```yaml
si_metricas_no_cumplen:
iteracion_1: "Revisar feature engineering"
iteracion_2: "Reducir complejidad modelo"
iteracion_3: "Cambiar estrategia base"
max_iteraciones: 3
decision_final: "Consultar con usuario"
```
---
## METRICAS DE EXITO REFINADAS
### Por Proyecto (Fin Q1)
| Proyecto | Metrica | Actual | Objetivo | Prioridad |
|----------|---------|--------|----------|-----------|
| Gamilit | Progreso | 65% | 85% | P0 |
| Gamilit | Type Safety | 28% | 80% | P1 |
| Gamilit | P0 Bloqueadores | 4 | 0 | P0 |
| Trading | Sharpe Ratio | TBD | >= 1.0 | P0 |
| Trading | MT4 Integracion | 0% | 100% | P0 |
| Trading | LLM Fine-tuned | 0% | 100% | P0 |
| ERP Const | Backend | 40% | 60% | P1 |
| ERP Diesel | Frontend | 0% | 100% | P1 |
### Por Semana
| Semana | Hito | Criterio de Exito |
|--------|------|-------------------|
| S1 | Gamilit P0 | 4/4 bloqueadores resueltos |
| S1 | Trading Setup | MT4 estructura + Backtest config |
| S2 | Trading Validado | Gate Trading APROBADO |
| S3 | ERP Diesel 50% | 3/6 modulos frontend |
| S4 | ERP Diesel 100% | 6/6 modulos frontend |
| S4 | ERP Const 60% | 6 controllers nuevos |
| S4 | Gamilit P1 50% | Type safety 50%+ |
---
## DOCUMENTOS GENERADOS
| Documento | Path | Proposito |
|-----------|------|-----------|
| Planificacion Principal | `orchestration/analisis/PLANIFICACION-WORKSPACE-2026-Q1.md` | Plan detallado |
| Validacion | `orchestration/analisis/VALIDACION-PLANIFICACION-2026-Q1.md` | Verificacion requisitos |
| Plan Refinado | `orchestration/analisis/PLAN-EJECUCION-REFINADO-2026-Q1.md` | Este documento |
---
## PROXIMA ACCION INMEDIATA
```yaml
tarea: "Iniciar FASE 1 - Gamilit P0"
agente_principal: Database-Agent
primera_subtarea: "Sincronizar Enums Database"
archivos:
- projects/gamilit/apps/database/migrations/
comando_inicial: |
# Verificar estado actual
cd /home/isem/workspace-v1/projects/gamilit
cat orchestration/PROXIMA-ACCION.md
# Cargar contexto
cat orchestration/00-guidelines/CONTEXTO-PROYECTO.md
```
---
**Plan refinado:** 2026-01-04
**Sistema:** NEXUS v4.0 + SIMCO
**Estado:** LISTO PARA EJECUCION
**Revisor:** Agente Orquestador