- Add orchestration/directivas/ with proyecto-triggers - TRIGGER-COHERENCIA-CAPAS.md for DDL/Backend coherence - TRIGGER-INVENTARIOS.md for inventory synchronization - Add orchestration/agents/ with perfiles - PERFIL-DDL-AGENT.md - PERFIL-BACKEND-AGENT.md - PERFIL-FRONTEND-AGENT.md - PERFIL-MOBILE-AGENT.md (specific to mobile POS) - Add MAPA-DOCUMENTACION.yml as central reference Inheritance: INTEGRATES from template-saas Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2.7 KiB
2.7 KiB
TRIGGER: Coherencia Entre Capas
ID: TRIGGER-MC-COHERENCIA Version: 1.0.0 Prioridad: P1 (Bloqueante) Activacion: Automatica en cambios DDL/Backend Hereda de: template-saas (INTEGRATES)
Proposito
Garantizar coherencia entre las capas DDL, Backend y Frontend del proyecto MiChangarrito. Cada tabla DDL debe tener su entity correspondiente en el backend.
Contexto del Proyecto
MiChangarrito es una plataforma POS multi-tenant con:
- Backend: NestJS + TypeScript
- Frontend: React + Vite
- Mobile: React Native
- Database: PostgreSQL 16+ con RLS
Activacion
Este trigger se activa cuando:
- Se crea/modifica archivo en
database/schemas/*/tables/*.sql - Se crea/modifica archivo en
apps/backend/src/modules/*/entities/*.entity.ts - Se ejecuta validacion manual con
@MC_VALIDATE_COHERENCIA
Validaciones
1. DDL -> Entity (Obligatorio)
Para cada tabla en DDL:
├── Verificar que existe entity correspondiente
├── Verificar que columnas coincidan (nombre, tipo)
├── Verificar que relaciones esten mapeadas
└── Documentar excepciones justificadas
Excepciones Permitidas:
- Tablas M:N gestionadas por TypeORM (documentar en ENTITIES-CATALOG)
- Tablas de auditoria automatica (documentar en DATABASE-SCHEMA)
- Tablas de sistema/migracion
2. Entity -> Service (Recomendado)
Para cada entity:
├── Verificar que existe service que la usa
└── Verificar que operaciones CRUD estan implementadas (si aplica)
3. Service -> Controller (Si expone API)
Para cada service expuesto:
├── Verificar que existe controller
├── Verificar que endpoints estan documentados
└── Verificar que DTOs existen para request/response
Ubicaciones Especificas
| Capa | Ubicacion |
|---|---|
| DDL | database/schemas/{schema}/tables/ |
| Entities | apps/backend/src/modules/{mod}/entities/ |
| Services | apps/backend/src/modules/{mod}/ |
| Controllers | apps/backend/src/modules/{mod}/ |
Resultado de Validacion
Exito
status: "pass"
ddl_tables: <total>
entities: <total>
coverage: 100%
exceptions: 0
Fallo (Bloqueante)
status: "fail"
ddl_tables: <total+1>
entities: <total>
coverage: <porcentaje>
missing:
- tabla: "new_table"
schema: "new_schema"
accion_requerida: "Crear entity o documentar excepcion"
Acciones Correctivas
- Si falta entity: Crear entity en
apps/backend/src/modules/{modulo}/entities/ - Si es excepcion: Documentar en
docs/_definitions/ENTITIES-CATALOG.md - Si es tabla temporal: Agregar a lista de exclusiones
Referencias
@MC_DEF_ENTITIES- Catalogo de entities@MC_DEF_DB- Schema de base de datos@MC_INV_BE- Inventario backend