- Prefijo v2: MCH - TRACEABILITY-MASTER.yml creado - Listo para integracion como submodulo Workspace: v2.0.0 | SIMCO: v4.0.0
231 lines
6.1 KiB
Markdown
231 lines
6.1 KiB
Markdown
# FASE 3: PLAN DE CORRECCIONES DE INTEGRIDAD
|
|
## Planeacion Detallada de Validacion y Correcciones
|
|
|
|
**Version:** 1.0.0
|
|
**Fecha:** 2026-01-10
|
|
**Ejecutado por:** Agente Orquestador (PERFIL-ORQUESTADOR)
|
|
**Sistema:** SIMCO v3.8.0 + CAPVED
|
|
|
|
---
|
|
|
|
## 1. RESUMEN DE HALLAZGOS
|
|
|
|
### Del Analisis F2
|
|
|
|
| Prioridad | Cantidad | Descripcion |
|
|
|-----------|----------|-------------|
|
|
| P0 (Criticos) | 0 | Sin problemas criticos |
|
|
| P1 (Altos) | 2 | Discrepancias en inventarios |
|
|
| P2 (Medios) | 2 | Entity faltante, inventario incompleto |
|
|
| P3 (Bajos) | 1 | Rol de BD opcional |
|
|
|
|
---
|
|
|
|
## 2. PLAN DE CORRECCIONES
|
|
|
|
### BLOQUE A: Correccion de Inventarios (P1)
|
|
|
|
#### A.1 DATABASE_INVENTORY.yml
|
|
|
|
**Archivo:** `orchestration/inventarios/DATABASE_INVENTORY.yml`
|
|
|
|
**Correccion 1:** Linea 22, cambiar `total_tablas: 53` a `total_tablas: 47`
|
|
|
|
```yaml
|
|
# ANTES
|
|
resumen:
|
|
total_schemas: 11
|
|
total_tablas: 53 # <-- INCORRECTO
|
|
|
|
# DESPUES
|
|
resumen:
|
|
total_schemas: 11
|
|
total_tablas: 47 # <-- CORRECTO
|
|
```
|
|
|
|
**Justificacion:** La base de datos real tiene 47 tablas, no 53. Las notas del mismo inventario (linea 903) ya dicen correctamente 47.
|
|
|
|
#### A.2 BACKEND_INVENTORY.yml
|
|
|
|
**Archivo:** `orchestration/inventarios/BACKEND_INVENTORY.yml`
|
|
|
|
**Correccion 2:** Linea 39, cambiar `total_entities: 35` a `total_entities: 37`
|
|
|
|
```yaml
|
|
# ANTES
|
|
resumen:
|
|
total_modulos: 17
|
|
total_controllers: 20
|
|
total_services: 22
|
|
total_entities: 35 # <-- INCORRECTO
|
|
|
|
# DESPUES
|
|
resumen:
|
|
total_modulos: 17
|
|
total_controllers: 20
|
|
total_services: 22
|
|
total_entities: 37 # <-- CORRECTO
|
|
```
|
|
|
|
**Correccion 3:** Agregar entidades faltantes en modulo marketplace (linea ~409)
|
|
|
|
```yaml
|
|
# ANTES (modulo marketplace)
|
|
entities:
|
|
- Supplier (entities/supplier.entity.ts)
|
|
- SupplierProduct (entities/supplier-product.entity.ts)
|
|
- SupplierOrder (entities/supplier-order.entity.ts)
|
|
|
|
# DESPUES
|
|
entities:
|
|
- Supplier (entities/supplier.entity.ts)
|
|
- SupplierProduct (entities/supplier-product.entity.ts)
|
|
- SupplierOrder (entities/supplier-order.entity.ts)
|
|
- SupplierOrderItem (entities/supplier-order-item.entity.ts)
|
|
- SupplierReview (entities/supplier-review.entity.ts)
|
|
```
|
|
|
|
---
|
|
|
|
### BLOQUE B: Entity Faltante (P2)
|
|
|
|
**Archivo a crear:** `apps/backend/src/modules/marketplace/entities/supplier-favorites.entity.ts`
|
|
|
|
**Contenido:**
|
|
|
|
```typescript
|
|
import { Entity, PrimaryGeneratedColumn, Column, CreateDateColumn, ManyToOne, JoinColumn, Unique } from 'typeorm';
|
|
import { Supplier } from './supplier.entity';
|
|
|
|
@Entity({ name: 'supplier_favorites', schema: 'marketplace' })
|
|
@Unique(['tenant_id', 'supplier_id'])
|
|
export class SupplierFavorites {
|
|
@PrimaryGeneratedColumn('uuid')
|
|
id: string;
|
|
|
|
@Column('uuid')
|
|
tenant_id: string;
|
|
|
|
@Column('uuid')
|
|
supplier_id: string;
|
|
|
|
@CreateDateColumn()
|
|
created_at: Date;
|
|
|
|
@ManyToOne(() => Supplier)
|
|
@JoinColumn({ name: 'supplier_id' })
|
|
supplier: Supplier;
|
|
}
|
|
```
|
|
|
|
**Registro en marketplace.module.ts:**
|
|
|
|
Agregar `SupplierFavorites` al array de entities en TypeOrmModule.forFeature([...])
|
|
|
|
---
|
|
|
|
### BLOQUE C: Rol de Base de Datos (P3 - Opcional)
|
|
|
|
**Opcion 1:** Crear rol (recomendado si se usara)
|
|
|
|
```sql
|
|
-- Agregar a 01-schemas.sql o crear nuevo archivo
|
|
CREATE ROLE michangarrito_app WITH LOGIN PASSWORD 'secure_password';
|
|
GRANT USAGE ON SCHEMA marketplace TO michangarrito_app;
|
|
GRANT SELECT, INSERT, UPDATE, DELETE ON ALL TABLES IN SCHEMA marketplace TO michangarrito_app;
|
|
```
|
|
|
|
**Opcion 2:** Remover referencias (si no se usara)
|
|
|
|
En `16-marketplace.sql`, remover o comentar las lineas:
|
|
```sql
|
|
-- GRANT SELECT ON marketplace.suppliers TO michangarrito_app;
|
|
-- GRANT SELECT ON marketplace.supplier_products TO michangarrito_app;
|
|
```
|
|
|
|
**Recomendacion:** Postergar para cuando se implemente control de acceso granular.
|
|
|
|
---
|
|
|
|
## 3. ORDEN DE EJECUCION
|
|
|
|
| Orden | Bloque | Archivo | Accion | Dependencia |
|
|
|-------|--------|---------|--------|-------------|
|
|
| 1 | A.1 | DATABASE_INVENTORY.yml | Editar total_tablas | Ninguna |
|
|
| 2 | A.2 | BACKEND_INVENTORY.yml | Editar total_entities | Ninguna |
|
|
| 3 | A.2 | BACKEND_INVENTORY.yml | Agregar entities marketplace | Ninguna |
|
|
| 4 | B | supplier-favorites.entity.ts | Crear archivo | Ninguna |
|
|
| 5 | B | marketplace.module.ts | Registrar entity | Paso 4 |
|
|
| 6 | A.2 | BACKEND_INVENTORY.yml | Agregar SupplierFavorites | Paso 4 |
|
|
|
|
---
|
|
|
|
## 4. CHECKPOINTS DE VALIDACION
|
|
|
|
### Checkpoint 1: Post-Inventarios (Bloques A.1, A.2)
|
|
|
|
- [ ] DATABASE_INVENTORY.yml tiene total_tablas: 47
|
|
- [ ] BACKEND_INVENTORY.yml tiene total_entities: 37
|
|
- [ ] BACKEND_INVENTORY.yml lista 5 entities en marketplace
|
|
|
|
### Checkpoint 2: Post-Entity (Bloque B)
|
|
|
|
- [ ] supplier-favorites.entity.ts existe
|
|
- [ ] marketplace.module.ts importa SupplierFavorites
|
|
- [ ] BACKEND_INVENTORY.yml lista SupplierFavorites
|
|
|
|
### Checkpoint 3: Validacion Final
|
|
|
|
- [ ] Inventarios sincronizados con realidad
|
|
- [ ] Backend compila sin errores
|
|
- [ ] Todas las entidades corresponden a tablas
|
|
|
|
---
|
|
|
|
## 5. RIESGOS Y MITIGACIONES
|
|
|
|
| Riesgo | Probabilidad | Impacto | Mitigacion |
|
|
|--------|--------------|---------|------------|
|
|
| Error de sintaxis YAML | Baja | Media | Validar con yamllint |
|
|
| Entity mal formateada | Baja | Media | Copiar patron existente |
|
|
| Import circular | Muy Baja | Alta | Revisar dependencias |
|
|
| Falta de registro en module | Media | Alta | Verificar forFeature([]) |
|
|
|
|
---
|
|
|
|
## 6. ROLLBACK
|
|
|
|
Si algo falla durante la ejecucion:
|
|
|
|
1. **Inventarios:** Git checkout del archivo modificado
|
|
2. **Entity nueva:** Eliminar archivo y remover import
|
|
3. **Module:** Revertir cambio en forFeature
|
|
|
|
---
|
|
|
|
## 7. TIEMPO ESTIMADO
|
|
|
|
| Bloque | Archivos | Cambios | Tiempo |
|
|
|--------|----------|---------|--------|
|
|
| A | 2 | 3 ediciones menores | ~5 min |
|
|
| B | 2 | 1 archivo nuevo + 1 edicion | ~10 min |
|
|
| C | 1 | Opcional | ~5 min |
|
|
| **Total** | **5** | **~5 cambios** | **~20 min** |
|
|
|
|
---
|
|
|
|
## 8. PROXIMOS PASOS
|
|
|
|
1. **F4:** Validar este plan contra el analisis F2
|
|
2. **F5:** Analizar dependencias de archivos afectados
|
|
3. **F6:** Refinar plan si es necesario
|
|
4. **F7:** Ejecutar correcciones
|
|
5. **F8:** Validar ejecucion
|
|
|
|
---
|
|
|
|
**Documento generado:** 2026-01-10
|
|
**Agente:** Orquestador (PERFIL-ORQUESTADOR)
|
|
**Sistema:** SIMCO v3.8.0 + CAPVED
|
|
**Proxima Fase:** F4 - Validacion del Plan
|