From 6d15abcb1a7657bb28536dcf0c7c7335f8bf906b Mon Sep 17 00:00:00 2001 From: ARCHITECT Date: Wed, 24 Dec 2025 17:58:03 +0000 Subject: [PATCH] docs(v5): Complete system documentation MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Comprehensive documentation for TZZR system v5 including: - 00_VISION: Glossary and foundational philosophy - 01_ARQUITECTURA: System overview and server specs - 02_MODELO_DATOS: Entity definitions and data planes (T0, MST, BCK) - 03_COMPONENTES: Agent docs (CLARA, MARGARET, FELDMAN, GRACE) - 04_SEGURIDAD: Threat model and secrets management - 05_OPERACIONES: Infrastructure and backup/recovery - 06_INTEGRACIONES: GPU services (RunPod status: blocked) - 99_ANEXOS: Repository inventory (24 repos) Key findings documented: - CRITICAL: UFW inactive on CORP/HST - CRITICAL: PostgreSQL 5432 exposed - CRITICAL: .env files with 644 permissions - RunPod workers not starting (code ready in R2) - Infisical designated as single source of secrets (D-001) πŸ€– Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 --- 00_VISION/filosofia.md | 105 ++++++ 00_VISION/glosario.md | 129 ++++++++ 01_ARQUITECTURA/overview.md | 154 +++++++++ 01_ARQUITECTURA/servidores.md | 230 +++++++++++++ 02_MODELO_DATOS/entidades.md | 237 +++++++++++++ 02_MODELO_DATOS/planos.md | 309 +++++++++++++++++ 03_COMPONENTES/agentes/clara-margaret.md | 311 +++++++++++++++++ 03_COMPONENTES/agentes/feldman.md | 390 ++++++++++++++++++++++ 03_COMPONENTES/servicios/grace.md | 403 +++++++++++++++++++++++ 04_SEGURIDAD/modelo-amenazas.md | 177 ++++++++++ 04_SEGURIDAD/secretos.md | 292 ++++++++++++++++ 05_OPERACIONES/backup-recovery.md | 359 ++++++++++++++++++++ 05_OPERACIONES/infraestructura.md | 383 +++++++++++++++++++++ 06_INTEGRACIONES/gpu-services.md | 179 ++++++++++ 99_ANEXOS/inventario-repos.md | 387 ++++++++++++++++++++++ README.md | 121 ++++++- 16 files changed, 4164 insertions(+), 2 deletions(-) create mode 100644 00_VISION/filosofia.md create mode 100644 00_VISION/glosario.md create mode 100644 01_ARQUITECTURA/overview.md create mode 100644 01_ARQUITECTURA/servidores.md create mode 100644 02_MODELO_DATOS/entidades.md create mode 100644 02_MODELO_DATOS/planos.md create mode 100644 03_COMPONENTES/agentes/clara-margaret.md create mode 100644 03_COMPONENTES/agentes/feldman.md create mode 100644 03_COMPONENTES/servicios/grace.md create mode 100644 04_SEGURIDAD/modelo-amenazas.md create mode 100644 04_SEGURIDAD/secretos.md create mode 100644 05_OPERACIONES/backup-recovery.md create mode 100644 05_OPERACIONES/infraestructura.md create mode 100644 06_INTEGRACIONES/gpu-services.md create mode 100644 99_ANEXOS/inventario-repos.md diff --git a/00_VISION/filosofia.md b/00_VISION/filosofia.md new file mode 100644 index 0000000..bfc90c7 --- /dev/null +++ b/00_VISION/filosofia.md @@ -0,0 +1,105 @@ +# FilosofΓ­a del Sistema TZZR + +**VersiΓ³n:** 5.0 +**Fecha:** 2024-12-24 + +--- + +## 10 Principios Fundacionales + +### 1. Constructores, no gestores + +Las instancias Claude son **constructores de arquitecturas**, no gestores permanentes. + +- Cada instancia diseΓ±a y construye la arquitectura de un servidor +- Cuando la arquitectura estΓ© madura, el servidor serΓ‘ **clonable e independiente** +- FuncionarΓ‘ sin necesidad de su instancia Claude +- Solo los servidores del propietario original mantienen conexiΓ³n con Claude + +### 2. DescentralizaciΓ³n operativa + +``` +Architect App (centralizado) β†’ DiseΓ±a moldes + ↓ + Instancias reales (descentralizadas) + ↓ + Cada una con su CORP, su DECK, sus agentes +``` + +### 3. Referencias ligeras mediante hashes + +``` +DEFINICIΓ“N ORIGINAL β†’ SHA-256 β†’ HASH UNÍVOCO (64 chars) +``` + +El hash es una referencia ligera que arrastra toda la informaciΓ³n del original sin duplicarla. + +### 4. SeparaciΓ³n de planos + +| Plano | Nombre | FunciΓ³n | +|-------|--------|---------| +| **T-N β†’ T0** | ITM (Ítems) | Lo ideal, la partitura | +| **BurocrΓ‘tico** | MST (Milestones) | Documentos, hitos, estados | +| **FΓ­sico** | BCK (Bloques) | Acciones, evidencias, trabajo real | + +### 5. PerΓ­odo flotante antes de inmutabilidad + +Los datos pasan por un perΓ­odo flotante que permite mejora antes del sellado definitivo. + +``` +Dato nuevo β†’ PerΓ­odo flotante (24h) β†’ VerificaciΓ³n SENTINEL β†’ Sellado FELDMAN β†’ Inmutable +``` + +### 6. Renombrabilidad de agentes + +Los componentes marcados como renombrables pueden personalizarse: + +``` +CLARA β†’ "LucΓ­a" +ALFRED β†’ "Pepe" +PENNY β†’ "Asistente" +``` + +Esto permite que cada usuario sienta el sistema como propio. + +### 7. GRACE nunca modifica + +GRACE extrae y comprende, pero **nunca modifica** el contenido original. + +> "Solo extrae y comprende, nunca modifica el contenido original." + +### 8. AuditorΓ­a dual: confΓ­a pero verifica + +SENTINEL opera en dos modos: + +| Modo | Frecuencia | Alcance | TecnologΓ­a | +|------|------------|---------|------------| +| **LIGHT** | Cada 5 min | Todos los registros | Reglas automΓ‘ticas | +| **DEEP** | Cada 1 hora | Muestreo | LLM anΓ‘lisis | + +### 9. Zero-retention en interfaces mΓ³viles + +PACKET no almacena datos localmente. Todo va directo al servidor. + +### 10. CuraciΓ³n humana en Vision Builder + +``` +VALORES β†’ OBJETIVOS β†’ IMÁGENES IA β†’ CURACIΓ“N HUMANA β†’ LO QUE SOBREVIVE DEFINE QUIΓ‰N ERES +``` + +--- + +## Modelo de Instancias + +**DECK** y **CORP** son plantillas. En producciΓ³n habrΓ‘ mΓΊltiples instancias: + +| Tipo | Ejemplos | +|------|----------| +| **DECK** | "Deck de Juan", "Deck de Victoria", "Deck de Pablo" | +| **CORP** | "Lacitos de Colores SL", "TZR Tech", "Acme Corp" | + +Cada instancia: +- Tiene su propio bucket de almacenamiento +- Puede renombrar sus agentes +- Opera de forma descentralizada +- Se conecta a servicios compartidos (GRACE, THE FACTORY, CIRCLE) diff --git a/00_VISION/glosario.md b/00_VISION/glosario.md new file mode 100644 index 0000000..3071f88 --- /dev/null +++ b/00_VISION/glosario.md @@ -0,0 +1,129 @@ +# Glosario TZZR + +**VersiΓ³n:** 5.0 +**Fecha:** 2024-12-24 + +--- + +## Entidades Base + +| TΓ©rmino | Hash | DescripciΓ³n | Estado | +|---------|------|-------------|--------| +| **HST** | h_maestro | Hash Semantic Tagging - Etiquetas semΓ‘nticas visuales | Implementado | +| **ITM** | h_item | Ítems ideales - Definiciones del plano T0 | Planificado | +| **PLY** | h_player | Players - Identidad de actores | Planificado | +| **LOC** | h_loc | Locations - Ubicaciones geogrΓ‘ficas | Planificado | +| **FLG** | h_flag | Flags - Marcos jurΓ­dicos y banderas | Planificado | + +--- + +## Planos de Datos + +| Plano | Tabla | DescripciΓ³n | +|-------|-------|-------------| +| **T0** | items | Lo ideal, la partitura, estado futuro deseado | +| **MST** | milestones | Plano burocrΓ‘tico - documentos, hitos, estados | +| **BCK** | bloques | Plano fΓ­sico - acciones, evidencias, trabajo real | + +--- + +## Agentes + +### Ingesta +| Agente | Servidor | Puerto | DescripciΓ³n | +|--------|----------|--------|-------------| +| **CLARA** | DECK | 5051 | Recoge informaciΓ³n personal, log inmutable | +| **MARGARET** | CORP | 5051 | Recoge informaciΓ³n corporativa, log inmutable | + +### OrquestaciΓ³n +| Agente | Servidor | Puerto | DescripciΓ³n | +|--------|----------|--------|-------------| +| **ALFRED** | DECK | 5052 | Flujos predefinidos personales | +| **JARED** | CORP | 5052 | Flujos predefinidos corporativos (mΓ‘s potente) | + +### Procesamiento +| Agente | Servidor | Puerto | DescripciΓ³n | +|--------|----------|--------|-------------| +| **MASON** | CORP | 5053 | Enriquecimiento, ventana flotante 24h | +| **FELDMAN** | CORP | 5054 | ConsolidaciΓ³n final, blockchain, inmutable | +| **SENTINEL** | - | - | AuditorΓ­a LIGHT (5min) + DEEP (1h) [planificado] | + +--- + +## Servicios GPU (RunPod) + +| Servicio | Endpoint | DescripciΓ³n | Estado | +|----------|----------|-------------|--------| +| **GRACE** | r00x4g3rrwkbyh | IA cognitiva, extracciΓ³n (18 mΓ³dulos) | Bloqueado | +| **PENNY** | 0mxhaokgsmgee3 | Asistente personal, generaciΓ³n texto | Planificado | +| **FACTORY** | ddnuk6y35zi56a | GeneraciΓ³n iterativa | Planificado | + +--- + +## Servidores + +| Servidor | IP | Rol | +|----------|-----|-----| +| **ARCHITECT** | 69.62.126.110 | Coordinador central, Gitea, PostgreSQL | +| **DECK** | 72.62.1.113 | Servidor personal | +| **CORP** | 92.112.181.188 | Servidor empresarial | +| **HST** | 72.62.2.84 | API tags semΓ‘nticos | +| **LOCKER** | Cloudflare R2 | Almacenamiento (5 buckets) | + +--- + +## Hashes y Identificadores + +| Prefijo | Tipo | Ejemplo | DescripciΓ³n | +|---------|------|---------|-------------| +| **h_maestro** | SHA-256 | `a1b2c3...` | Hash de tag HST | +| **h_instancia** | SHA-256 | `d4e5f6...` | Identidad servidor/contexto | +| **h_entrada** | SHA-256 | `g7h8i9...` | Hash contenedor ingesta | +| **h_bloque** | SHA-256 | `j0k1l2...` | Hash de bloque BCK | +| **h_milestone** | SHA-256 | `m3n4o5...` | Hash de milestone MST | +| **H_proyecto** | Prefijo | `H_tzzr_genesis` | Identificador proyecto legible | + +--- + +## Interfaces + +| Interfaz | Tipo | DescripciΓ³n | +|----------|------|-------------| +| **PACKET** | App mΓ³vil | Captura multimedia, zero-retention | +| **Vision Builder** | Web | DiseΓ±o de vida mediante curaciΓ³n visual | +| **Mind Link** | Web | ComparticiΓ³n de informaciΓ³n | + +--- + +## Protocolos + +| Protocolo | VersiΓ³n | DescripciΓ³n | +|-----------|---------|-------------| +| **S-CONTRACT** | v2.1 | ComunicaciΓ³n con IAs (context, deployment, envelope, payload) | +| **locker://** | - | Referencias almacenamiento R2 | + +--- + +## Grupos HST + +| Grupo | Cantidad | DescripciΓ³n | +|-------|----------|-------------| +| **hst** | 639 | Tags del sistema base | +| **spe** | 145 | Tags especΓ­ficos | +| **vsn** | 84 | Visiones | +| **flg** | 65 | Banderas/paΓ­ses | +| **vue** | 21 | Vistas | +| **hsu** | - | Tags usuario (extensiΓ³n) | + +--- + +## Estados de Pipeline + +| Estado | Etapa | DescripciΓ³n | +|--------|-------|-------------| +| **recibido** | CLARA/MARGARET | Contenedor ingresado, inmutable | +| **en_edicion** | MASON | Usuario enriqueciendo datos | +| **listo** | MASON | Listo para consolidar | +| **pendiente** | FELDMAN | En cola de consolidaciΓ³n | +| **consolidado** | FELDMAN | Registrado en milestone/bloque | +| **sellado** | NOTARIO | Blockchain confirmado | diff --git a/01_ARQUITECTURA/overview.md b/01_ARQUITECTURA/overview.md new file mode 100644 index 0000000..e918db3 --- /dev/null +++ b/01_ARQUITECTURA/overview.md @@ -0,0 +1,154 @@ +# Arquitectura Overview + +**VersiΓ³n:** 5.0 +**Fecha:** 2024-12-24 + +--- + +## Diagrama General + +``` +β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” +β”‚ CAPA DE COORDINACIΓ“N β”‚ +β”‚ β”‚ +β”‚ β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”‚ +β”‚ β”‚ ARCHITECT (69.62.126.110) β”‚ β”‚ +β”‚ β”‚ β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”‚ β”‚ +β”‚ β”‚ β”‚PostgreSQLβ”‚ β”‚ Gitea β”‚ β”‚Orchestratorβ”‚ β”‚ Infisical β”‚ β”‚ β”‚ +β”‚ β”‚ β”‚ central β”‚ β”‚ 25 repos β”‚ β”‚ v5 β”‚ β”‚ Secrets β”‚ β”‚ β”‚ +β”‚ β”‚ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β”‚ β”‚ +β”‚ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β”‚ +β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ + β”‚ β”‚ β”‚ + β–Ό β–Ό β–Ό +β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” +β”‚ CAPA DE SERVIDORES β”‚ +β”‚ β”‚ +β”‚ β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”‚ +β”‚ β”‚ DECK β”‚ β”‚ CORP β”‚ β”‚ HST β”‚ β”‚ +β”‚ β”‚ 72.62.1.113 β”‚ β”‚ 92.112.181.188 β”‚ β”‚ 72.62.2.84 β”‚ β”‚ +β”‚ β”‚ β”‚ β”‚ β”‚ β”‚ β”‚ β”‚ +β”‚ β”‚ CLARA :5051 β”‚ β”‚ MARGARET :5051 β”‚ β”‚ 973 tags β”‚ β”‚ +β”‚ β”‚ ALFRED :5052 β”‚ β”‚ JARED :5052 β”‚ β”‚ API pΓΊblica β”‚ β”‚ +β”‚ β”‚ β”‚ β”‚ MASON :5053 β”‚ β”‚ Directus :8055 β”‚ β”‚ +β”‚ β”‚ Mailcow β”‚ β”‚ FELDMAN :5054 β”‚ β”‚ β”‚ β”‚ +β”‚ β”‚ Vaultwarden β”‚ β”‚ β”‚ β”‚ β”‚ β”‚ +β”‚ β”‚ Directus β”‚ β”‚ Odoo β”‚ β”‚ β”‚ β”‚ +β”‚ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β”‚ Nextcloud β”‚ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β”‚ +β”‚ β”‚ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β”‚ β”‚ +β”‚ β”‚ β”‚ β”‚ β”‚ +β”‚ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β”‚ +β”‚ β”‚ β”‚ +β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ + β–Ό +β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” +β”‚ CAPA DE ALMACENAMIENTO β”‚ +β”‚ β”‚ +β”‚ β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”‚ +β”‚ β”‚ Cloudflare R2 β”‚ β”‚ +β”‚ β”‚ β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β” β”‚ β”‚ +β”‚ β”‚ β”‚architect β”‚ β”‚ deck β”‚ β”‚ corp β”‚ β”‚ hst β”‚ β”‚ locker β”‚ β”‚ β”‚ +β”‚ β”‚ β”‚ backups β”‚ β”‚ archivos β”‚ β”‚ archivos β”‚ β”‚ imΓ‘genes β”‚ β”‚ generalβ”‚ β”‚ β”‚ +β”‚ β”‚ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β”‚ β”‚ +β”‚ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β”‚ +β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ + β”‚ + β–Ό +β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” +β”‚ CAPA GPU (RunPod) β”‚ +β”‚ Estado: BLOQUEADO - Workers no inician β”‚ +β”‚ β”‚ +β”‚ β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”‚ +β”‚ β”‚ GRACE β”‚ β”‚ PENNY β”‚ β”‚ FACTORY β”‚ β”‚ +β”‚ β”‚ 18 mΓ³dulosβ”‚ β”‚ texto β”‚ β”‚generaciΓ³nβ”‚ β”‚ +β”‚ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β”‚ +β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ +``` + +--- + +## Flujo de Datos + +``` +PACKET (App mΓ³vil) + β”‚ + β”‚ POST /ingest + β”‚ Content-Type: multipart/form-data + β”‚ X-Auth-Key: {h_instancia} + β”‚ + β–Ό +β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” +β”‚ CLARA (DECK) / MARGARET (CORP) β”‚ +β”‚ β”‚ +β”‚ 1. Validar h_instancia β”‚ +β”‚ 2. Calcular h_entrada (SHA-256) β”‚ +β”‚ 3. Subir archivos a R2 β”‚ +β”‚ 4. Insertar en clara_log/margaret_log β”‚ +β”‚ 5. Estado: 'recibido' (inmutable) β”‚ +β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ + β”‚ + β–Ό +β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” +β”‚ ALFRED (DECK) / JARED (CORP) β”‚ +β”‚ β”‚ +β”‚ 1. Aplicar flujos predefinidos β”‚ +β”‚ 2. Ejecutar reglas automΓ‘ticas β”‚ +β”‚ 3. Enviar a MASON si requiere mejora β”‚ +β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ + β”‚ + β–Ό +β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” +β”‚ MASON β”‚ +β”‚ β”‚ +β”‚ 1. Recibir de ALFRED/JARED β”‚ +β”‚ 2. Ventana flotante 24h β”‚ +β”‚ 3. Usuario enriquece datos β”‚ +β”‚ 4. [Futuro] GRACE extrae informaciΓ³n β”‚ +β”‚ 5. Enviar a FELDMAN cuando listo β”‚ +β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ + β”‚ + β–Ό +β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” +β”‚ FELDMAN β”‚ +β”‚ β”‚ +β”‚ 1. Recibir en feldman_cola β”‚ +β”‚ 2. Validar reglas (M-001, M-002, M-003)β”‚ +β”‚ 3. Crear milestone o bloque β”‚ +β”‚ 4. Calcular hash_contenido β”‚ +β”‚ 5. Encadenar (hash_previo) β”‚ +β”‚ 6. [Futuro] Merkle tree, blockchain β”‚ +β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ + β”‚ + β–Ό +β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” +β”‚ SENTINEL (planificado) β”‚ +β”‚ β”‚ +β”‚ LIGHT: Cada 5 min, reglas automΓ‘ticas β”‚ +β”‚ DEEP: Cada 1 hora, muestreo con LLM β”‚ +β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ +``` + +--- + +## ComunicaciΓ³n Entre Servidores + +| Origen | Destino | Protocolo | Puerto | PropΓ³sito | +|--------|---------|-----------|--------|-----------| +| DECK | ARCHITECT | SSH/Git | 2222 | Push repos | +| DECK | R2 | HTTPS | 443 | Almacenamiento | +| CORP | ARCHITECT | SSH/Git | 2222 | Push repos | +| CORP | R2 | HTTPS | 443 | Almacenamiento | +| HST | ARCHITECT | SSH | 22 | AdministraciΓ³n | +| ARCHITECT | DECK | SSH | 22 | Deploy | +| ARCHITECT | CORP | SSH | 22 | Deploy | + +--- + +## Bases de Datos + +| Servidor | Database | Tablas Principales | +|----------|----------|--------------------| +| ARCHITECT | architect | context_blocks, agents, creds_* | +| DECK | tzzr | clara_log, alfred_executions | +| CORP | corp | margaret_log, mason_workspace, feldman_* | +| HST | hst_images | hst_tags, hst_trees | diff --git a/01_ARQUITECTURA/servidores.md b/01_ARQUITECTURA/servidores.md new file mode 100644 index 0000000..00b4f8f --- /dev/null +++ b/01_ARQUITECTURA/servidores.md @@ -0,0 +1,230 @@ +# Servidores TZZR + +**VersiΓ³n:** 5.0 +**Fecha:** 2024-12-24 + +--- + +## ARCHITECT (69.62.126.110) + +**Rol:** Coordinador central del sistema + +### Servicios + +| Servicio | Puerto | Estado | +|----------|--------|--------| +| PostgreSQL | 5432 | Operativo | +| Gitea | 3000 (HTTP), 2222 (SSH) | Operativo | +| Orchestrator App | 5050 | Operativo | +| Infisical | 8082 | Operativo | + +### PostgreSQL (database: architect) + +| Tabla | DescripciΓ³n | +|-------|-------------| +| context_blocks | 30 bloques de contexto atΓ³micos | +| agent_context_index | Asignaciones agente-bloque | +| agents | 6 agentes definidos | +| creds_* | 6 tablas de credenciales | +| s_contract_contexts | Contextos IA | +| s_contract_datasets | Datasets IA | + +### Acceso + +```bash +# SSH +ssh orchestrator@69.62.126.110 + +# PostgreSQL +sudo -u postgres psql -d architect + +# Gitea +http://localhost:3000 +``` + +--- + +## DECK (72.62.1.113) + +**Rol:** Servidor personal + +### Servicios + +| Servicio | Puerto | Estado | +|----------|--------|--------| +| CLARA | 5051 | Operativo | +| ALFRED | 5052 | Operativo | +| Mailcow (15 containers) | SMTP, IMAP | Operativo | +| Directus | 8055 | Operativo | +| FileBrowser | 8082 | Operativo | +| Shlink | 8083 | Operativo | +| Vaultwarden | 8085 | Operativo | +| ntfy | 8080 | Operativo | + +### PostgreSQL (database: tzzr) + +| Tabla | DescripciΓ³n | +|-------|-------------| +| clara_log | Log inmutable de ingesta | +| deck_visiones | Visiones personales | +| deck_milestones | Milestones personales | +| deck_acciones | Acciones | +| deck_habitos | HΓ‘bitos | +| deck_bck | Bloques | + +### Docker Containers + +``` +mailcowdockerized-acme-mailcow-1 +mailcowdockerized-clamd-mailcow-1 +mailcowdockerized-dovecot-mailcow-1 +mailcowdockerized-mysql-mailcow-1 +mailcowdockerized-netfilter-mailcow-1 +mailcowdockerized-nginx-mailcow-1 +mailcowdockerized-olefy-mailcow-1 +mailcowdockerized-php-fpm-mailcow-1 +mailcowdockerized-postfix-mailcow-1 +mailcowdockerized-redis-mailcow-1 +mailcowdockerized-rspamd-mailcow-1 +mailcowdockerized-sogo-mailcow-1 +mailcowdockerized-solr-mailcow-1 +mailcowdockerized-unbound-mailcow-1 +mailcowdockerized-watchdog-mailcow-1 +clara-clara +alfred-alfred +directus +filebrowser +shlink +vaultwarden +ntfy +``` + +### Acceso + +```bash +ssh -i ~/.ssh/tzzr root@72.62.1.113 +``` + +--- + +## CORP (92.112.181.188) + +**Rol:** Servidor empresarial + +### Servicios + +| Servicio | Puerto | Estado | +|----------|--------|--------| +| MARGARET | 5051 | Operativo | +| JARED | 5052 | Operativo | +| MASON | 5053 | Operativo | +| FELDMAN | 5054 | Operativo | +| PostgreSQL | 5432 | Operativo | +| Directus | 8055 | Operativo | +| Nextcloud | 8080 | Operativo | +| Vaultwarden | 8081 | Operativo | +| Odoo | 8069 | Operativo | +| Caddy | 80/443 | Operativo | + +### PostgreSQL (database: corp) + +| Tabla | DescripciΓ³n | +|-------|-------------| +| margaret_log | Log inmutable de ingesta | +| mason_workspace | Espacio de enriquecimiento | +| feldman_cola | Cola de consolidaciΓ³n | +| feldman_bloques | Bloques inmutables | +| feldman_validaciones | AuditorΓ­a validaciones | +| milestones | Plano MST | +| bloques | Plano BCK | +| hst_mirror | Mirror de tags HST | + +### Acceso + +```bash +ssh -i ~/.ssh/tzzr root@92.112.181.188 +``` + +--- + +## HST (72.62.2.84) + +**Rol:** API de tags semΓ‘nticos + +### Servicios + +| Servicio | Puerto | Estado | +|----------|--------|--------| +| Nginx | 80/443 | Operativo | +| Directus | 8055 | Operativo | +| PostgreSQL | 5432 | Operativo | + +### EstadΓ­sticas HST + +| Grupo | Cantidad | +|-------|----------| +| hst | 639 | +| spe | 145 | +| vsn | 84 | +| flg | 65 | +| vue | 21 | +| **Total** | **973** | + +### API + +``` +https://tzrtech.org/{h_maestro}.png # Imagen de tag +``` + +### Acceso + +```bash +ssh -i ~/.ssh/tzzr root@72.62.2.84 +``` + +--- + +## LOCKER (Cloudflare R2) + +**Rol:** Almacenamiento distribuido + +### Endpoint + +``` +https://7dedae6030f5554d99d37e98a5232996.r2.cloudflarestorage.com +``` + +### Buckets + +| Bucket | Uso | +|--------|-----| +| architect | Backups Gitea, configs, GPU services | +| deck | Archivos personales (CLARA) | +| corp | Archivos empresariales (MARGARET) | +| hst | ImΓ‘genes de tags | +| locker | Almacenamiento general/temporal | + +### Estructura GPU Services + +``` +s3://architect/gpu-services/ +β”œβ”€β”€ base/ +β”‚ └── bootstrap.sh +β”œβ”€β”€ grace/ +β”‚ └── code/handler.py +β”œβ”€β”€ penny/ +β”‚ └── code/handler.py +└── factory/ + └── code/handler.py +``` + +--- + +## Resumen de IPs + +| Servidor | IP PΓΊblica | IP Interna | +|----------|------------|------------| +| ARCHITECT | 69.62.126.110 | localhost | +| DECK | 72.62.1.113 | - | +| CORP | 92.112.181.188 | - | +| HST | 72.62.2.84 | - | diff --git a/02_MODELO_DATOS/entidades.md b/02_MODELO_DATOS/entidades.md new file mode 100644 index 0000000..eeee58c --- /dev/null +++ b/02_MODELO_DATOS/entidades.md @@ -0,0 +1,237 @@ +# Entidades Base TZZR + +**VersiΓ³n:** 5.0 +**Fecha:** 2024-12-24 + +--- + +## VisiΓ³n General + +Las entidades base son los bloques fundamentales del sistema. Cada una tiene un hash ΓΊnico SHA-256 que la identifica de forma unΓ­voca. + +``` +DEFINICIΓ“N ORIGINAL β†’ SHA-256 β†’ h_{tipo} (64 chars) +``` + +--- + +## HST (Hash Semantic Tagging) + +**Estado:** Implementado +**Servidor:** HST (72.62.2.84) +**Hash:** h_maestro + +### FΓ³rmula + +``` +h_maestro = SHA-256(grupo:ref) +``` + +### Grupos + +| Grupo | Cantidad | DescripciΓ³n | +|-------|----------|-------------| +| hst | 639 | Tags del sistema base | +| spe | 145 | Tags especΓ­ficos | +| vsn | 84 | Visiones | +| flg | 65 | Banderas/paΓ­ses | +| vue | 21 | Vistas | + +### Schema + +```sql +CREATE TABLE hst_tags ( + id SERIAL PRIMARY KEY, + ref VARCHAR(100) UNIQUE NOT NULL, + h_maestro VARCHAR(64) UNIQUE NOT NULL, + grupo VARCHAR(50) NOT NULL, + nombre_es VARCHAR(255), + nombre_en VARCHAR(255), + descripcion TEXT, + imagen_url TEXT, + activo BOOLEAN DEFAULT true, + version INTEGER DEFAULT 1, + created_at TIMESTAMP DEFAULT NOW() +); +``` + +### Ejemplo + +```json +{ + "ref": "person", + "h_maestro": "a1b2c3d4e5f6...", + "grupo": "hst", + "nombre_es": "Persona", + "nombre_en": "Person", + "imagen_url": "https://tzrtech.org/a1b2c3d4e5f6...png" +} +``` + +--- + +## ITM (Items - Plano Ideal) + +**Estado:** Planificado +**Servidor:** Por definir +**Hash:** h_item + +### Concepto + +Los ITM representan el estado ideal futuro. Son la "partitura" que guΓ­a las acciones. + +### Schema Propuesto + +```sql +CREATE TABLE items ( + id BIGSERIAL PRIMARY KEY, + h_item VARCHAR(64) UNIQUE NOT NULL, + h_instancia VARCHAR(64) NOT NULL, + secuencia BIGINT NOT NULL, + hash_previo VARCHAR(64), + hash_contenido VARCHAR(64), + tipo_item VARCHAR(50) NOT NULL, -- accion_ideal, objetivo, requerimiento + titulo VARCHAR(255) NOT NULL, + descripcion TEXT, + criterios_aceptacion JSONB, + metadata JSONB, + proyecto_tag VARCHAR(64), + etiquetas JSONB, + estado VARCHAR(20) DEFAULT 'draft', -- draft, vigente, obsoleto + created_at TIMESTAMPTZ DEFAULT NOW(), + created_by VARCHAR(64), + UNIQUE (h_instancia, secuencia) +); +``` + +--- + +## PLY (Players - Identidad) + +**Estado:** Planificado +**Servidor:** Por definir +**Hash:** h_player + +### Concepto + +Los PLY representan la identidad de actores en el sistema (personas, empresas, agentes). + +### Schema Propuesto + +```sql +CREATE TABLE players ( + id BIGSERIAL PRIMARY KEY, + h_player VARCHAR(64) UNIQUE NOT NULL, + tipo VARCHAR(50) NOT NULL, -- persona, empresa, agente + nombre VARCHAR(255) NOT NULL, + email VARCHAR(255), + metadata JSONB, + activo BOOLEAN DEFAULT true, + created_at TIMESTAMPTZ DEFAULT NOW() +); +``` + +--- + +## LOC (Locations - Ubicaciones) + +**Estado:** Planificado +**Servidor:** Por definir +**Hash:** h_loc + +### Concepto + +Los LOC representan ubicaciones geogrΓ‘ficas con precisiΓ³n variable. + +### Schema Propuesto + +```sql +CREATE TABLE locations ( + id BIGSERIAL PRIMARY KEY, + h_loc VARCHAR(64) UNIQUE NOT NULL, + nombre VARCHAR(255), + lat DECIMAL(10, 8), + lon DECIMAL(11, 8), + precision_metros INTEGER, + tipo VARCHAR(50), -- punto, area, ruta + metadata JSONB, + created_at TIMESTAMPTZ DEFAULT NOW() +); +``` + +### FΓ³rmula Hash + +``` +h_loc = SHA-256(lat:lon:precision) +``` + +--- + +## FLG (Flags - Marcos JurΓ­dicos) + +**Estado:** Planificado +**Servidor:** Por definir +**Hash:** h_flag + +### Concepto + +Los FLG representan marcos jurΓ­dicos, normativas, paΓ­ses. + +### Notas + +Actualmente existe un grupo `flg` en HST con 65 tags de paΓ­ses, pero no como entidad independiente. + +--- + +## Tags de Usuario (Extensiones) + +Los usuarios pueden crear sus propios tags como extensiones de HST. + +| Tabla | DescripciΓ³n | +|-------|-------------| +| hsu | HST Usuario | +| spu | SPE Usuario | +| vsu | VSN Usuario | +| vuu | VUE Usuario | +| pju | Proyectos Usuario | +| flu | FLG Usuario | + +### Schema + +```sql +CREATE TABLE hsu ( + id SERIAL PRIMARY KEY, + ref VARCHAR(10) NOT NULL, + h_usuario VARCHAR(64) NOT NULL, + nombre VARCHAR(255) NOT NULL, + user_id INTEGER REFERENCES users(id), + metadata JSONB, + activo BOOLEAN DEFAULT true, + created_at TIMESTAMP DEFAULT NOW(), + UNIQUE (user_id, ref) +); +``` + +--- + +## Relaciones Entre Entidades + +``` +ITM (ideal) + β”‚ + β”œβ”€β”€β–Ί h_maestro (HST tags) + β”œβ”€β”€β–Ί h_player (PLY responsable) + β”œβ”€β”€β–Ί h_loc (LOC ubicaciΓ³n) + └──► h_flag (FLG normativa) + +MST (milestone) + β”‚ + β”œβ”€β”€β–Ί item_asociado (ITM) + └──► h_maestro (HST tags) + +BCK (bloque) + β”‚ + β”œβ”€β”€β–Ί item_asociado (ITM) + β”œβ”€β”€β–Ί milestone_asociado (MST) + └──► h_maestro (HST tags) +``` diff --git a/02_MODELO_DATOS/planos.md b/02_MODELO_DATOS/planos.md new file mode 100644 index 0000000..0f90073 --- /dev/null +++ b/02_MODELO_DATOS/planos.md @@ -0,0 +1,309 @@ +# Planos de Datos TZZR + +**VersiΓ³n:** 5.0 +**Fecha:** 2024-12-24 + +--- + +## VisiΓ³n General + +El sistema TZZR utiliza tres planos conceptuales para organizar la informaciΓ³n: + +``` +β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” +β”‚ T0 - PLANO IDEAL β”‚ +β”‚ ITM (Items): Objetivos, acciones ideales, requerimientos β”‚ +β”‚ Estado: PLANIFICADO - Sin implementaciΓ³n actual β”‚ +β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ + β”‚ + β–Ό materializa +β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” +β”‚ MST - MILESTONES β”‚ +β”‚ Compromisos futuros con fecha de vencimiento β”‚ +β”‚ Estado: IMPLEMENTADO en CORP (tabla milestones) β”‚ +β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ + β”‚ + β–Ό cumple/genera +β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” +β”‚ BCK - BLOQUES β”‚ +β”‚ Hechos inmutables del pasado (blockchain-ready) β”‚ +β”‚ Estado: IMPLEMENTADO en CORP (tabla bloques) β”‚ +β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ +``` + +--- + +## T0 - Plano Ideal (ITM) + +### Concepto + +El plano T0 contiene los Items (ITM) que representan el estado ideal futuro. Son la "partitura" que guΓ­a las acciones. + +### Tipos de Items + +| Tipo | DescripciΓ³n | +|------|-------------| +| accion_ideal | AcciΓ³n que deberΓ­a ejecutarse | +| objetivo | Meta a alcanzar | +| requerimiento | Requisito a cumplir | + +### Estado de ImplementaciΓ³n + +**PLANIFICADO** - Schema definido pero sin tablas creadas. + +### Schema Propuesto + +```sql +CREATE TABLE items ( + id BIGSERIAL PRIMARY KEY, + h_item VARCHAR(64) UNIQUE NOT NULL, + h_instancia VARCHAR(64) NOT NULL, + secuencia BIGINT NOT NULL, + hash_previo VARCHAR(64), + hash_contenido VARCHAR(64), + tipo_item VARCHAR(50) NOT NULL, + titulo VARCHAR(255) NOT NULL, + descripcion TEXT, + criterios_aceptacion JSONB, + metadata JSONB, + proyecto_tag VARCHAR(64), + etiquetas JSONB, + estado VARCHAR(20) DEFAULT 'draft', + created_at TIMESTAMPTZ DEFAULT NOW(), + created_by VARCHAR(64), + UNIQUE (h_instancia, secuencia) +); +``` + +--- + +## MST - Milestones + +### Concepto + +Los milestones representan compromisos con fecha futura. Tienen un perΓ­odo flotante de 24 horas antes de consolidarse. + +### Estado de ImplementaciΓ³n + +**IMPLEMENTADO** en CORP (database: corp). + +### Schema Actual + +```sql +-- Tabla: milestones (CORP) +CREATE TABLE milestones ( + id BIGSERIAL PRIMARY KEY, + h_milestone VARCHAR(64) UNIQUE NOT NULL, + h_instancia VARCHAR(64) NOT NULL, + secuencia BIGINT NOT NULL, + hash_previo VARCHAR(64), + hash_contenido VARCHAR(64), + tipo_milestone VARCHAR(50) NOT NULL, + fecha_vencimiento DATE NOT NULL, + descripcion TEXT, + metadata JSONB, + proyecto_tag VARCHAR(64), + etiquetas JSONB, + estado VARCHAR(20) DEFAULT 'draft', + created_at TIMESTAMPTZ DEFAULT NOW(), + modified_at TIMESTAMPTZ, + created_by VARCHAR(64), + UNIQUE (h_instancia, secuencia) +); +``` + +### Tipos de Milestones + +| Tipo | DescripciΓ³n | +|------|-------------| +| compromiso | Compromiso de entrega | +| deadline | Fecha lΓ­mite | +| evento | Evento programado | +| recordatorio | Recordatorio futuro | + +### FΓ³rmula Hash + +``` +h_milestone = SHA-256(h_instancia:secuencia:tipo:contenido) +``` + +### PerΓ­odo Flotante + +- **DuraciΓ³n:** 24 horas desde creaciΓ³n +- **Durante perΓ­odo:** Modificable vΓ­a MASON +- **DespuΓ©s:** Inmutable, solo lectura + +**Nota:** Actualmente no hay scheduler que procese la expiraciΓ³n automΓ‘ticamente. + +--- + +## BCK - Bloques + +### Concepto + +Los bloques son registros inmutables de hechos pasados. Cada bloque estΓ‘ encadenado al anterior mediante hash, preparando la infraestructura para blockchain. + +### Estado de ImplementaciΓ³n + +**IMPLEMENTADO** en CORP (database: corp). + +### Schema Actual + +```sql +-- Tabla: bloques (CORP) +CREATE TABLE bloques ( + id BIGSERIAL PRIMARY KEY, + h_bloque VARCHAR(64) UNIQUE NOT NULL, + h_instancia VARCHAR(64) NOT NULL, + secuencia BIGINT NOT NULL, + hash_previo VARCHAR(64), + hash_contenido VARCHAR(64) NOT NULL, + tipo_bloque VARCHAR(50) NOT NULL, + contenido JSONB NOT NULL, + metadata JSONB, + item_asociado VARCHAR(64), + milestone_asociado VARCHAR(64), + h_maestro JSONB, + h_player VARCHAR(64), + h_loc VARCHAR(64), + h_flag VARCHAR(64), + estado VARCHAR(20) DEFAULT 'consolidado', + created_at TIMESTAMPTZ DEFAULT NOW(), + validated_at TIMESTAMPTZ, + validated_by VARCHAR(64), + UNIQUE (h_instancia, secuencia) +); +``` + +### Tipos de Bloques + +| Tipo | DescripciΓ³n | +|------|-------------| +| transaccion | TransacciΓ³n econΓ³mica | +| documento | Documento consolidado | +| evento | Evento registrado | +| milestone_cumplido | Milestone que se cumpliΓ³ | + +### FΓ³rmula Hash + +``` +h_bloque = SHA-256(h_instancia:secuencia:hash_previo:hash_contenido) +hash_contenido = SHA-256(contenido_serializado) +``` + +### Encadenamiento + +``` +Bloque N-1 Bloque N +β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” +β”‚ h_bloque: abc123 β”‚ ──────► β”‚ hash_previo: β”‚ +β”‚ hash_contenido: β”‚ β”‚ abc123 β”‚ +β”‚ def456 β”‚ β”‚ h_bloque: ghi789 β”‚ +β”‚ secuencia: 1 β”‚ β”‚ secuencia: 2 β”‚ +β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ +``` + +--- + +## Flujo Entre Planos + +``` +Usuario crea ITM + β”‚ + β–Ό +ITM (T0) "Objetivo: Completar proyecto X" + β”‚ + β”‚ materializa + β–Ό +MST "Milestone: Entrega mΓ³dulo 1 - 2024-01-15" + β”‚ + β”‚ [perΓ­odo flotante 24h] + β”‚ + β–Ό +MASON (enriquecimiento) + β”‚ + β–Ό +FELDMAN (validaciΓ³n) + β”‚ + β”‚ cumple/genera + β–Ό +BCK "Bloque: MΓ³dulo 1 entregado - 2024-01-14" + β”‚ + β–Ό +Inmutable βœ“ +``` + +--- + +## Tablas de Procesamiento + +### FELDMAN Cola + +```sql +-- feldman_cola: Elementos pendientes de validaciΓ³n +CREATE TABLE feldman_cola ( + id BIGSERIAL PRIMARY KEY, + tipo VARCHAR(50) NOT NULL, -- 'milestone' o 'bloque' + h_entrada VARCHAR(64) NOT NULL, + contenido JSONB NOT NULL, + prioridad INTEGER DEFAULT 0, + estado VARCHAR(20) DEFAULT 'pendiente', + created_at TIMESTAMPTZ DEFAULT NOW(), + processed_at TIMESTAMPTZ +); +``` + +### FELDMAN Validaciones + +```sql +-- feldman_validaciones: AuditorΓ­a de validaciones +CREATE TABLE feldman_validaciones ( + id BIGSERIAL PRIMARY KEY, + h_entrada VARCHAR(64) NOT NULL, + regla VARCHAR(50) NOT NULL, -- M-001, M-002, M-003 + resultado BOOLEAN NOT NULL, + mensaje TEXT, + validated_at TIMESTAMPTZ DEFAULT NOW() +); +``` + +--- + +## Reglas de ValidaciΓ³n FELDMAN + +| Regla | Nombre | DescripciΓ³n | +|-------|--------|-------------| +| M-001 | Hash ΓΊnico | h_bloque/h_milestone no existe previamente | +| M-002 | Encadenamiento | hash_previo apunta a bloque existente | +| M-003 | Integridad | hash_contenido = SHA-256(contenido) | + +--- + +## Decisiones de DiseΓ±o + +### D-004: Eliminar columnas duplicadas + +**Problema:** Milestones tienen columnas + JSONB duplicados. + +**DecisiΓ³n:** Mantener metadatos solo en JSONB `metadata`. + +### D-007: Timestamps UTC + +**Problema:** Inconsistencia en zonas horarias. + +**DecisiΓ³n:** Usar `TIMESTAMPTZ` y almacenar en UTC. + +--- + +## Roadmap + +### Implementado +- [x] Tabla milestones en CORP +- [x] Tabla bloques en CORP +- [x] FΓ³rmulas hash definidas + +### Pendiente +- [ ] Tabla items (T0) +- [ ] Scheduler para perΓ­odo flotante +- [ ] Merkle tree para verificaciΓ³n +- [ ] Smart contract blockchain (futuro) diff --git a/03_COMPONENTES/agentes/clara-margaret.md b/03_COMPONENTES/agentes/clara-margaret.md new file mode 100644 index 0000000..2d47bc6 --- /dev/null +++ b/03_COMPONENTES/agentes/clara-margaret.md @@ -0,0 +1,311 @@ +# CLARA y MARGARET - Agentes de Ingesta + +**VersiΓ³n:** 5.0 +**Fecha:** 2024-12-24 + +--- + +## Resumen + +| Aspecto | CLARA | MARGARET | +|---------|-------|----------| +| Servidor | DECK (72.62.1.113) | CORP (92.112.181.188) | +| Puerto | 5051 | 5051 | +| Dominio | Personal | Empresarial | +| Base de datos | tzzr | corp | +| Tabla log | clara_log | margaret_log | +| Bucket R2 | deck | corp | +| Estado | Operativo | Operativo | + +--- + +## Arquitectura + +``` +PACKET (App mΓ³vil) + β”‚ + β”‚ POST /ingest + β”‚ Content-Type: multipart/form-data + β”‚ X-Auth-Key: {h_instancia} + β”‚ + β–Ό +β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” +β”‚ CLARA (Personal) / MARGARET (Corp) β”‚ +β”‚ β”‚ +β”‚ 1. Validar h_instancia β”‚ +β”‚ 2. Calcular h_entrada (SHA-256) β”‚ +β”‚ 3. Subir archivos a R2 β”‚ +β”‚ 4. Insertar en log (inmutable) β”‚ +β”‚ 5. Estado: 'recibido' β”‚ +β”‚ 6. Responder con h_entrada β”‚ +β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ + β”‚ + β–Ό + ALFRED / JARED (siguiente paso) +``` + +--- + +## Endpoint de Ingesta + +### Request + +```http +POST /ingest HTTP/1.1 +Host: deck.example.com:5051 +Content-Type: multipart/form-data +X-Auth-Key: {h_instancia} + +--boundary +Content-Disposition: form-data; name="tipo" + +documento +--boundary +Content-Disposition: form-data; name="archivo"; filename="doc.pdf" +Content-Type: application/pdf + +{binary data} +--boundary-- +``` + +### Response + +```json +{ + "success": true, + "h_entrada": "a1b2c3d4e5f6...", + "estado": "recibido", + "timestamp": "2024-12-24T12:00:00Z" +} +``` + +--- + +## CΓ‘lculo de h_entrada + +```python +import hashlib +import json + +def calcular_h_entrada(h_instancia, tipo, contenido_bytes, timestamp): + """ + Calcula el hash ΓΊnico de entrada. + + h_entrada = SHA-256(h_instancia:tipo:sha256(contenido):timestamp) + """ + hash_contenido = hashlib.sha256(contenido_bytes).hexdigest() + + data = f"{h_instancia}:{tipo}:{hash_contenido}:{timestamp}" + + return hashlib.sha256(data.encode()).hexdigest() +``` + +--- + +## Schema: clara_log / margaret_log + +```sql +CREATE TABLE clara_log ( + id BIGSERIAL PRIMARY KEY, + h_entrada VARCHAR(64) UNIQUE NOT NULL, + h_instancia VARCHAR(64) NOT NULL, + tipo VARCHAR(50) NOT NULL, + contenido_url TEXT, -- locker://deck/{h_entrada}/archivo + contenido_hash VARCHAR(64), -- SHA-256 del contenido + metadata JSONB, + estado VARCHAR(20) DEFAULT 'recibido', + created_at TIMESTAMPTZ DEFAULT NOW(), + processed_at TIMESTAMPTZ, + processed_by VARCHAR(50) -- 'alfred' o 'manual' +); + +-- margaret_log tiene schema idΓ©ntico +CREATE TABLE margaret_log ( + id BIGSERIAL PRIMARY KEY, + h_entrada VARCHAR(64) UNIQUE NOT NULL, + h_instancia VARCHAR(64) NOT NULL, + tipo VARCHAR(50) NOT NULL, + contenido_url TEXT, + contenido_hash VARCHAR(64), + metadata JSONB, + estado VARCHAR(20) DEFAULT 'recibido', + created_at TIMESTAMPTZ DEFAULT NOW(), + processed_at TIMESTAMPTZ, + processed_by VARCHAR(50) +); +``` + +--- + +## Estados del Log + +| Estado | DescripciΓ³n | +|--------|-------------| +| recibido | Ingesta completada, pendiente procesamiento | +| procesando | ALFRED/JARED estΓ‘ procesando | +| enviado_mason | Enviado a MASON para enriquecimiento | +| consolidado | Procesado por FELDMAN | +| error | Error en procesamiento | + +--- + +## Almacenamiento en R2 + +### Estructura de URLs + +``` +locker://deck/{h_entrada}/archivo.ext +locker://corp/{h_entrada}/archivo.ext +``` + +### ImplementaciΓ³n + +```python +import boto3 + +def subir_a_r2(bucket, h_entrada, archivo_bytes, filename): + """Sube archivo a Cloudflare R2.""" + + s3 = boto3.client( + 's3', + endpoint_url='https://7dedae6030f5554d99d37e98a5232996.r2.cloudflarestorage.com', + aws_access_key_id=R2_ACCESS_KEY, + aws_secret_access_key=R2_SECRET_KEY + ) + + key = f"{h_entrada}/{filename}" + + s3.put_object( + Bucket=bucket, + Key=key, + Body=archivo_bytes + ) + + return f"locker://{bucket}/{key}" +``` + +--- + +## ValidaciΓ³n de h_instancia + +```python +def validar_instancia(h_instancia): + """ + Valida que h_instancia exista y estΓ© activa. + + TODO: Implementar tabla de instancias activas. + Actualmente: ValidaciΓ³n bΓ‘sica de formato. + """ + if not h_instancia: + return False + + if len(h_instancia) != 64: + return False + + # TODO: Consultar tabla de instancias + return True +``` + +--- + +## Tipos de Ingesta Soportados + +| Tipo | DescripciΓ³n | Extensiones | +|------|-------------|-------------| +| documento | Documentos | pdf, doc, docx | +| imagen | ImΓ‘genes | jpg, png, gif | +| audio | Audio | mp3, wav, m4a | +| video | Video | mp4, mov | +| texto | Texto plano | txt, md | +| json | Datos estructurados | json | + +--- + +## ConfiguraciΓ³n + +### Variables de Entorno + +```bash +# CLARA (.env en /opt/clara/) +DB_HOST=localhost +DB_PORT=5432 +DB_NAME=tzzr +DB_USER=clara +DB_PASSWORD=**** + +R2_ENDPOINT=https://7dedae6030f5554d99d37e98a5232996.r2.cloudflarestorage.com +R2_ACCESS_KEY=**** +R2_SECRET_KEY=**** +R2_BUCKET=deck + +# MARGARET (.env en /opt/margaret/) +DB_HOST=localhost +DB_PORT=5432 +DB_NAME=corp +DB_USER=margaret +DB_PASSWORD=**** + +R2_BUCKET=corp +``` + +### Docker Compose + +```yaml +# CLARA +version: '3.8' +services: + clara: + container_name: clara-clara + image: tzzr/clara:latest + ports: + - "5051:5051" + env_file: + - .env + restart: unless-stopped +``` + +--- + +## Diferencias CLARA vs MARGARET + +| Aspecto | CLARA | MARGARET | +|---------|-------|----------| +| Uso | Personal | Empresarial | +| Volumen | Bajo | Alto | +| Privacidad | MΓ‘xima | Compartida (empresa) | +| IntegraciΓ³n | ALFRED | JARED β†’ MASON β†’ FELDMAN | +| Backup | deck bucket | corp bucket | + +--- + +## Seguridad + +### Actual +- AutenticaciΓ³n por h_instancia +- ComunicaciΓ³n HTTP (sin TLS interno) +- .env con permisos 644 (**CRÍTICO: cambiar a 600**) + +### Recomendado +- TLS interno con certificados +- Rate limiting +- ValidaciΓ³n de tipos MIME +- Escaneo antivirus (ClamAV) + +--- + +## Monitoreo + +### Logs +```bash +# CLARA +docker logs clara-clara -f + +# MARGARET +docker logs margaret-margaret -f +``` + +### MΓ©tricas Sugeridas +- Ingestas por minuto +- TamaΓ±o promedio de archivos +- Tiempo de procesamiento +- Errores por tipo diff --git a/03_COMPONENTES/agentes/feldman.md b/03_COMPONENTES/agentes/feldman.md new file mode 100644 index 0000000..2cdaabd --- /dev/null +++ b/03_COMPONENTES/agentes/feldman.md @@ -0,0 +1,390 @@ +# FELDMAN - Agente de ConsolidaciΓ³n + +**VersiΓ³n:** 5.0 +**Fecha:** 2024-12-24 + +--- + +## Resumen + +| Aspecto | Valor | +|---------|-------| +| Servidor | CORP (92.112.181.188) | +| Puerto | 5054 | +| Base de datos | corp | +| Tablas | feldman_cola, feldman_bloques, feldman_validaciones | +| Estado | Operativo | + +--- + +## Rol en el Sistema + +FELDMAN es el "notario" del sistema: valida y consolida datos en bloques inmutables. + +``` +MASON (enriquecido) + β”‚ + β–Ό +β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” +β”‚ FELDMAN β”‚ +β”‚ β”‚ +β”‚ 1. Recibir en feldman_cola β”‚ +β”‚ 2. Validar reglas (M-001, M-002, M-003)β”‚ +β”‚ 3. Calcular hash_contenido β”‚ +β”‚ 4. Encadenar (hash_previo) β”‚ +β”‚ 5. Crear milestone o bloque β”‚ +β”‚ 6. Marcar como consolidado β”‚ +β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ + β”‚ + β–Ό +β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” +β”‚ milestones / bloques (inmutables) β”‚ +β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ + β”‚ + β–Ό + SENTINEL (auditorΓ­a futura) +``` + +--- + +## Reglas de ValidaciΓ³n + +| Regla | Nombre | DescripciΓ³n | AcciΓ³n si falla | +|-------|--------|-------------|-----------------| +| M-001 | Hash ΓΊnico | h_bloque/h_milestone no existe previamente | Rechazar | +| M-002 | Encadenamiento | hash_previo apunta a bloque existente | Rechazar | +| M-003 | Integridad | hash_contenido = SHA-256(contenido) | Rechazar | + +### ImplementaciΓ³n + +```python +def validar_m001(h_bloque): + """M-001: Hash debe ser ΓΊnico.""" + existe = db.execute( + "SELECT 1 FROM bloques WHERE h_bloque = %s", + [h_bloque] + ).fetchone() + return existe is None + +def validar_m002(hash_previo, h_instancia): + """M-002: hash_previo debe existir (excepto gΓ©nesis).""" + if hash_previo is None: + # Primer bloque de la instancia (gΓ©nesis) + existe = db.execute( + "SELECT 1 FROM bloques WHERE h_instancia = %s", + [h_instancia] + ).fetchone() + return existe is None # OK si no hay bloques previos + + existe = db.execute( + "SELECT 1 FROM bloques WHERE h_bloque = %s", + [hash_previo] + ).fetchone() + return existe is not None + +def validar_m003(hash_contenido, contenido): + """M-003: Hash debe coincidir con contenido.""" + import hashlib + import json + + contenido_serializado = json.dumps(contenido, sort_keys=True) + hash_calculado = hashlib.sha256(contenido_serializado.encode()).hexdigest() + + return hash_contenido == hash_calculado +``` + +--- + +## Schema de Tablas + +### feldman_cola + +```sql +CREATE TABLE feldman_cola ( + id BIGSERIAL PRIMARY KEY, + tipo VARCHAR(50) NOT NULL, -- 'milestone' o 'bloque' + h_entrada VARCHAR(64) NOT NULL, -- Referencia a origen + h_instancia VARCHAR(64) NOT NULL, + contenido JSONB NOT NULL, + prioridad INTEGER DEFAULT 0, + estado VARCHAR(20) DEFAULT 'pendiente', + intentos INTEGER DEFAULT 0, + ultimo_error TEXT, + created_at TIMESTAMPTZ DEFAULT NOW(), + processed_at TIMESTAMPTZ +); + +CREATE INDEX idx_feldman_cola_estado ON feldman_cola(estado); +CREATE INDEX idx_feldman_cola_prioridad ON feldman_cola(prioridad DESC); +``` + +### feldman_bloques (alias de bloques) + +```sql +-- Ver 02_MODELO_DATOS/planos.md para schema completo +CREATE TABLE bloques ( + id BIGSERIAL PRIMARY KEY, + h_bloque VARCHAR(64) UNIQUE NOT NULL, + h_instancia VARCHAR(64) NOT NULL, + secuencia BIGINT NOT NULL, + hash_previo VARCHAR(64), + hash_contenido VARCHAR(64) NOT NULL, + tipo_bloque VARCHAR(50) NOT NULL, + contenido JSONB NOT NULL, + -- ... campos adicionales + UNIQUE (h_instancia, secuencia) +); +``` + +### feldman_validaciones + +```sql +CREATE TABLE feldman_validaciones ( + id BIGSERIAL PRIMARY KEY, + h_entrada VARCHAR(64) NOT NULL, + tipo_destino VARCHAR(50) NOT NULL, -- 'milestone' o 'bloque' + h_destino VARCHAR(64), -- h_milestone o h_bloque + regla VARCHAR(50) NOT NULL, -- M-001, M-002, M-003 + resultado BOOLEAN NOT NULL, + mensaje TEXT, + validated_at TIMESTAMPTZ DEFAULT NOW() +); + +CREATE INDEX idx_feldman_val_entrada ON feldman_validaciones(h_entrada); +``` + +--- + +## Flujo de ConsolidaciΓ³n + +``` +1. Entrada en feldman_cola + β”‚ + β–Ό +2. FELDMAN procesa (poll cada N segundos) + β”‚ + β”œβ”€β–Ί Validar M-001 (hash ΓΊnico) + β”‚ β”œβ”€ PASS β†’ continuar + β”‚ └─ FAIL β†’ registrar error, marcar 'rechazado' + β”‚ + β”œβ”€β–Ί Validar M-002 (encadenamiento) + β”‚ β”œβ”€ PASS β†’ continuar + β”‚ └─ FAIL β†’ registrar error, marcar 'rechazado' + β”‚ + β”œβ”€β–Ί Validar M-003 (integridad) + β”‚ β”œβ”€ PASS β†’ continuar + β”‚ └─ FAIL β†’ registrar error, marcar 'rechazado' + β”‚ + β–Ό +3. Todas las validaciones PASS + β”‚ + β–Ό +4. Obtener ΓΊltima secuencia de h_instancia + β”‚ + β–Ό +5. Calcular h_bloque/h_milestone + β”‚ + β–Ό +6. INSERT en bloques/milestones + β”‚ + β–Ό +7. Actualizar feldman_cola β†’ 'consolidado' + β”‚ + β–Ό +8. Registrar en feldman_validaciones +``` + +--- + +## CΓ‘lculo de Hashes + +### h_bloque + +```python +def calcular_h_bloque(h_instancia, secuencia, hash_previo, hash_contenido): + """ + Calcula el hash del bloque. + + h_bloque = SHA-256(h_instancia:secuencia:hash_previo:hash_contenido) + """ + import hashlib + + # hash_previo puede ser None para bloque gΓ©nesis + previo = hash_previo or "genesis" + + data = f"{h_instancia}:{secuencia}:{previo}:{hash_contenido}" + + return hashlib.sha256(data.encode()).hexdigest() +``` + +### hash_contenido + +```python +def calcular_hash_contenido(contenido): + """ + Calcula el hash del contenido. + + hash_contenido = SHA-256(contenido_serializado) + """ + import hashlib + import json + + # SerializaciΓ³n determinista + contenido_str = json.dumps(contenido, sort_keys=True, ensure_ascii=False) + + return hashlib.sha256(contenido_str.encode()).hexdigest() +``` + +--- + +## API Endpoints + +### POST /consolidar + +```http +POST /consolidar HTTP/1.1 +Host: corp.example.com:5054 +Content-Type: application/json + +{ + "tipo": "bloque", + "h_entrada": "abc123...", + "h_instancia": "def456...", + "contenido": { + "tipo_bloque": "transaccion", + "monto": 1000, + "descripcion": "Pago factura #123" + } +} +``` + +### Response (Γ©xito) + +```json +{ + "success": true, + "h_bloque": "ghi789...", + "secuencia": 42, + "hash_contenido": "jkl012...", + "validaciones": { + "M-001": true, + "M-002": true, + "M-003": true + } +} +``` + +### Response (error) + +```json +{ + "success": false, + "error": "ValidaciΓ³n fallida", + "validaciones": { + "M-001": true, + "M-002": false, + "M-003": true + }, + "mensaje": "M-002: hash_previo no existe en cadena" +} +``` + +--- + +## ConfiguraciΓ³n + +### Variables de Entorno + +```bash +# /opt/feldman/.env +DB_HOST=localhost +DB_PORT=5432 +DB_NAME=corp +DB_USER=feldman +DB_PASSWORD=**** + +POLL_INTERVAL=5 # Segundos entre polls +MAX_BATCH=10 # Elementos por lote +MAX_RETRIES=3 # Reintentos antes de rechazar +``` + +--- + +## Estados de la Cola + +| Estado | DescripciΓ³n | +|--------|-------------| +| pendiente | En espera de procesamiento | +| procesando | FELDMAN estΓ‘ validando | +| consolidado | Validado y creado bloque/milestone | +| rechazado | FallΓ³ validaciΓ³n, no se reintentarΓ‘ | +| error | Error tΓ©cnico, puede reintentarse | + +--- + +## AuditorΓ­a + +Cada validaciΓ³n se registra en `feldman_validaciones`: + +```sql +-- Consultar historial de validaciones +SELECT + h_entrada, + regla, + resultado, + mensaje, + validated_at +FROM feldman_validaciones +WHERE h_entrada = 'abc123...' +ORDER BY validated_at; +``` + +--- + +## Futuro: Blockchain + +FELDMAN estΓ‘ diseΓ±ado para evolucionar hacia blockchain: + +1. **Actual:** Encadenamiento por hash_previo en PostgreSQL +2. **Fase 2:** Merkle tree para verificaciΓ³n eficiente +3. **Fase 3:** Smart contract en blockchain (Ethereum/Polygon) + +``` + Merkle Root + β”‚ + β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” + β”‚ β”‚ + Hash(AB) Hash(CD) + β”‚ β”‚ + β”Œβ”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β” + β”‚ β”‚ β”‚ β”‚ + Hash(A) Hash(B) Hash(C) Hash(D) + β”‚ β”‚ β”‚ β”‚ + Bloque A Bloque B Bloque C Bloque D +``` + +--- + +## Monitoreo + +### Logs +```bash +docker logs feldman-feldman -f +``` + +### Consultas de Estado + +```sql +-- Elementos pendientes +SELECT COUNT(*) FROM feldman_cola WHERE estado = 'pendiente'; + +-- Últimas validaciones fallidas +SELECT * FROM feldman_validaciones +WHERE resultado = false +ORDER BY validated_at DESC +LIMIT 10; + +-- Bloques creados hoy +SELECT COUNT(*) FROM bloques +WHERE created_at >= CURRENT_DATE; +``` diff --git a/03_COMPONENTES/servicios/grace.md b/03_COMPONENTES/servicios/grace.md new file mode 100644 index 0000000..821cd2f --- /dev/null +++ b/03_COMPONENTES/servicios/grace.md @@ -0,0 +1,403 @@ +# GRACE - Servicio de IA Cognitiva + +**VersiΓ³n:** 5.0 +**Fecha:** 2024-12-24 + +--- + +## Estado Actual + +**BLOQUEADO:** RunPod no inicia workers. + +| Aspecto | Valor | +|---------|-------| +| Plataforma | RunPod Serverless | +| Endpoint ID | r00x4g3rrwkbyh | +| Balance | ~$72 USD | +| Workers activos | 0 | +| Estado | Inoperativo | + +--- + +## DescripciΓ³n + +GRACE es el servicio de extracciΓ³n de informaciΓ³n mediante IA. Procesa contenido multimedia para extraer datos estructurados. + +``` +Contenido Raw +(audio, imagen, video, documento) + β”‚ + β–Ό +β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” +β”‚ GRACE (GPU) β”‚ +β”‚ β”‚ +β”‚ β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”‚ +β”‚ β”‚ ASR β”‚ β”‚ OCR β”‚ β”‚ TTS β”‚ β”‚ +β”‚ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β”‚ +β”‚ β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”‚ +β”‚ β”‚ Face β”‚ β”‚Embeddingsβ”‚ β”‚ Avatar β”‚ β”‚ +β”‚ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β”‚ +β”‚ β”‚ +β”‚ + 12 mΓ³dulos pendientes β”‚ +β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ + β”‚ + β–Ό +Datos Estructurados +(JSON, vectores, metadatos) +``` + +--- + +## MΓ³dulos Implementados (6 de 18) + +### ASR - Automatic Speech Recognition + +| Campo | Valor | +|-------|-------| +| Modelo | Whisper Large v3 | +| Input | Audio (mp3, wav, m4a) | +| Output | Texto + timestamps | +| GPU | A10G recomendado | + +```python +@grace.module("asr") +def process_asr(audio_bytes: bytes) -> dict: + """Transcribe audio a texto.""" + model = whisper.load_model("large-v3") + result = model.transcribe(audio_bytes) + return { + "text": result["text"], + "segments": result["segments"], + "language": result["language"] + } +``` + +### OCR - Optical Character Recognition + +| Campo | Valor | +|-------|-------| +| Modelo | EasyOCR + Tesseract | +| Input | Imagen (jpg, png) | +| Output | Texto + bounding boxes | +| GPU | A10G recomendado | + +```python +@grace.module("ocr") +def process_ocr(image_bytes: bytes) -> dict: + """Extrae texto de imagen.""" + reader = easyocr.Reader(['es', 'en']) + result = reader.readtext(image_bytes) + return { + "text": " ".join([r[1] for r in result]), + "boxes": [{"text": r[1], "bbox": r[0], "confidence": r[2]} for r in result] + } +``` + +### TTS - Text to Speech + +| Campo | Valor | +|-------|-------| +| Modelo | Coqui TTS | +| Input | Texto | +| Output | Audio (wav) | +| GPU | A10G recomendado | + +### Face - Reconocimiento Facial + +| Campo | Valor | +|-------|-------| +| Modelo | InsightFace | +| Input | Imagen | +| Output | Embeddings faciales | +| GPU | A10G recomendado | + +### Embeddings - Vectores SemΓ‘nticos + +| Campo | Valor | +|-------|-------| +| Modelo | Sentence Transformers | +| Input | Texto | +| Output | Vector 384/768 dims | +| GPU | A10G recomendado | + +### Avatar - GeneraciΓ³n de Avatares + +| Campo | Valor | +|-------|-------| +| Modelo | StyleGAN | +| Input | Imagen facial | +| Output | Avatar estilizado | +| GPU | A10G recomendado | + +--- + +## MΓ³dulos Pendientes (12) + +| MΓ³dulo | DescripciΓ³n | Prioridad | +|--------|-------------|-----------| +| Document parsing | ExtracciΓ³n de PDFs | Alta | +| Image classification | ClasificaciΓ³n de imΓ‘genes | Media | +| Object detection | DetecciΓ³n de objetos | Media | +| Sentiment analysis | AnΓ‘lisis de sentimiento | Media | +| Named entity recognition | ExtracciΓ³n de entidades | Alta | +| Translation | TraducciΓ³n de texto | Media | +| Summarization | Resumen de texto | Media | +| Question answering | Respuestas a preguntas | Baja | +| Code generation | GeneraciΓ³n de cΓ³digo | Baja | +| Audio classification | ClasificaciΓ³n de audio | Baja | +| Video analysis | AnΓ‘lisis de video | Baja | +| Multimodal fusion | FusiΓ³n multimodal | Baja | + +--- + +## CΓ³digo en R2 + +El cΓ³digo estΓ‘ listo y disponible: + +``` +s3://architect/gpu-services/ +β”œβ”€β”€ base/ +β”‚ └── bootstrap.sh # Script de inicializaciΓ³n +β”œβ”€β”€ grace/ +β”‚ └── code/ +β”‚ └── handler.py # Handler principal +β”œβ”€β”€ penny/ +β”‚ └── code/ +β”‚ └── handler.py +└── factory/ + └── code/ + └── handler.py +``` + +### Descargar CΓ³digo + +```bash +source /home/orchestrator/orchestrator/.env +export AWS_ACCESS_KEY_ID="$R2_ACCESS_KEY" +export AWS_SECRET_ACCESS_KEY="$R2_SECRET_KEY" + +aws s3 sync s3://architect/gpu-services/grace/ ./grace/ \ + --endpoint-url https://7dedae6030f5554d99d37e98a5232996.r2.cloudflarestorage.com +``` + +--- + +## Handler RunPod + +```python +import runpod + +def handler(event): + """ + Handler principal de GRACE para RunPod Serverless. + + Input: + { + "input": { + "module": "asr|ocr|tts|face|embeddings|avatar", + "data": "base64 encoded content", + "options": {} + } + } + + Output: + { + "output": { ... resultado del mΓ³dulo ... }, + "error": null + } + """ + try: + module = event["input"]["module"] + data = base64.b64decode(event["input"]["data"]) + options = event["input"].get("options", {}) + + if module == "asr": + result = process_asr(data, **options) + elif module == "ocr": + result = process_ocr(data, **options) + elif module == "tts": + result = process_tts(data, **options) + elif module == "face": + result = process_face(data, **options) + elif module == "embeddings": + result = process_embeddings(data, **options) + elif module == "avatar": + result = process_avatar(data, **options) + else: + return {"error": f"MΓ³dulo desconocido: {module}"} + + return {"output": result, "error": None} + + except Exception as e: + return {"error": str(e)} + +runpod.serverless.start({"handler": handler}) +``` + +--- + +## Uso desde MASON + +```python +import runpod +import base64 + +runpod.api_key = "..." # Desde Infisical + +def call_grace(module: str, content: bytes, options: dict = None) -> dict: + """Llama a GRACE para procesar contenido.""" + + job = runpod.run( + endpoint_id="r00x4g3rrwkbyh", + input={ + "module": module, + "data": base64.b64encode(content).decode(), + "options": options or {} + } + ) + + # Polling hasta completar + while True: + status = runpod.status(job["id"]) + if status["status"] == "COMPLETED": + return status["output"] + elif status["status"] == "FAILED": + raise Exception(status.get("error", "Job failed")) + time.sleep(1) +``` + +--- + +## Problema Actual: Workers No Inician + +### Incidente 2024-12-24 + +- **SΓ­ntoma:** 0 workers activos a pesar de jobs en cola +- **Balance:** $72+ (suficiente) +- **ConfiguraciΓ³n:** Correcta +- **Causa probable:** Problema de capacidad RunPod + +### Intentos de DiagnΓ³stico + +1. Verificado endpoint activo en dashboard +2. Verificado balance suficiente +3. Verificado configuraciΓ³n de scaling +4. Jobs quedan en estado "IN_QUEUE" indefinidamente + +### Log de Errores + +``` +No hay logs disponibles - workers nunca inician +``` + +--- + +## Alternativas Evaluadas + +### 1. Modal (Recomendado) + +```python +import modal + +stub = modal.Stub("grace") +image = modal.Image.debian_slim().pip_install("whisper", "easyocr") + +@stub.function(gpu="A10G", image=image) +def process_asr(audio_bytes: bytes) -> dict: + import whisper + model = whisper.load_model("large-v3") + result = model.transcribe(audio_bytes) + return {"text": result["text"]} +``` + +**Pros:** +- Serverless real +- Buen DX (developer experience) +- Python-native +- Cold start rΓ‘pido + +**Contras:** +- Menos GPUs disponibles que RunPod +- Pricing puede ser mayor + +### 2. Replicate + +```python +import replicate + +output = replicate.run( + "openai/whisper:large-v3", + input={"audio": audio_url} +) +``` + +**Pros:** +- Modelos pre-entrenados +- API simple +- Sin gestiΓ³n de infraestructura + +**Contras:** +- Menos control +- MΓ‘s caro a escala +- Dependencia de modelos de terceros + +### 3. Lambda Labs + +**Pros:** +- Hardware dedicado +- GPUs disponibles + +**Contras:** +- Menos flexible +- Reserva manual +- No serverless + +### 4. Self-Hosted + +**Pros:** +- Control total +- Sin dependencias externas +- Costo fijo a largo plazo + +**Contras:** +- CapEx alto +- Mantenimiento +- Requiere expertise + +--- + +## Plan de MigraciΓ³n + +### Fase 1: EvaluaciΓ³n + +- [ ] Crear cuenta Modal +- [ ] Portar mΓ³dulo ASR a Modal +- [ ] Comparar latencia con RunPod (cuando funcione) +- [ ] Comparar costos + +### Fase 2: MigraciΓ³n + +- [ ] Portar 6 handlers a Modal +- [ ] Actualizar endpoints en MASON +- [ ] Actualizar documentaciΓ³n +- [ ] Testing end-to-end + +### Fase 3: ProducciΓ³n + +- [ ] Desplegar en Modal +- [ ] Monitorear costos y performance +- [ ] Deprecar RunPod endpoints +- [ ] Cancelar cuenta RunPod + +--- + +## Principio Fundamental + +**GRACE nunca modifica datos.** + +GRACE es read-only: extrae informaciΓ³n pero no puede modificar el contenido original ni los datos del sistema. Las extracciones se almacenan como metadatos asociados al contenido original. + +``` +Contenido Original ────► GRACE ────► Metadatos ExtraΓ­dos + (inmutable) (nuevos datos) +``` diff --git a/04_SEGURIDAD/modelo-amenazas.md b/04_SEGURIDAD/modelo-amenazas.md new file mode 100644 index 0000000..1de8902 --- /dev/null +++ b/04_SEGURIDAD/modelo-amenazas.md @@ -0,0 +1,177 @@ +# Modelo de Amenazas TZZR + +**VersiΓ³n:** 5.0 +**Fecha:** 2024-12-24 + +--- + +## Resumen Ejecutivo + +El sistema TZZR tiene una base de seguridad sΓ³lida (SSH keys, PostgreSQL SSL, tokens de autenticaciΓ³n) pero presenta exposiciones crΓ­ticas que requieren atenciΓ³n inmediata. + +--- + +## Hallazgos CrΓ­ticos + +### CRÍTICO-001: CORP/HST sin Firewall + +**DescripciΓ³n:** UFW inactivo en servidores CORP y HST. +**Impacto:** Todos los puertos expuestos a Internet. +**Evidencia:** `ufw status` devuelve "inactive". + +**MitigaciΓ³n:** +```bash +# CORP +ufw default deny incoming +ufw allow 22/tcp +ufw allow 80/tcp +ufw allow 443/tcp +ufw enable + +# HST +ufw default deny incoming +ufw allow 22/tcp +ufw allow 80/tcp +ufw allow 443/tcp +ufw enable +``` + +### CRÍTICO-002: PostgreSQL 5432 Expuesto + +**DescripciΓ³n:** PostgreSQL en ARCHITECT escucha en 0.0.0.0:5432. +**Impacto:** Accesible desde cualquier IP (aunque requiere autenticaciΓ³n). + +**MitigaciΓ³n:** +``` +# /etc/postgresql/16/main/postgresql.conf +listen_addresses = '127.0.0.1,172.17.0.1' +``` + +### CRÍTICO-003: Archivos .env Legibles + +**DescripciΓ³n:** Archivos .env con permisos 644 (legibles por todos). +**Impacto:** Credenciales accesibles a cualquier usuario del sistema. + +**MitigaciΓ³n:** +```bash +chmod 600 /opt/clara/.env +chmod 600 /opt/alfred/.env +chmod 600 /opt/margaret/.env +chmod 600 /opt/mason/.env +``` + +--- + +## Hallazgos Altos + +### ALTO-001: fail2ban No Configurado + +**DescripciΓ³n:** fail2ban failed en DECK, inactive en CORP. +**Impacto:** SSH bruteforce sin mitigaciΓ³n automΓ‘tica. +**Evidencia:** Ataques activos desde 165.232.81.204, 188.166.115.48. + +**MitigaciΓ³n:** +```bash +apt install fail2ban +systemctl enable fail2ban +# jail: sshd, maxretry=3, bantime=1h +``` + +### ALTO-002: Triple GestiΓ³n de Secretos + +**DescripciΓ³n:** Credenciales en Infisical, tablas creds_*, y archivos .env. +**Impacto:** No hay fuente ΓΊnica de verdad, riesgo de desincronizaciΓ³n. + +**MitigaciΓ³n:** +- Migrar todas las credenciales a Infisical +- Eliminar .env hardcodeados +- creds_* solo para referencia + +### ALTO-003: Servicios sin TLS Interno + +**DescripciΓ³n:** CLARA, MARGARET, MASON, FELDMAN en HTTP plano. +**Impacto:** TrΓ‘fico interno sin cifrar. + +**MitigaciΓ³n:** +- Configurar mTLS entre servicios +- Usar Caddy como reverse proxy con TLS + +--- + +## Hallazgos Medios + +### MEDIO-001: No hay Backup PostgreSQL + +**DescripciΓ³n:** Solo Gitea tiene backup en R2, PostgreSQL sin backup. +**Impacto:** PΓ©rdida de datos en caso de fallo. + +**MitigaciΓ³n:** +```bash +# Cron diario +pg_dump architect | gzip | aws s3 cp - s3://architect/backups/architect_$(date +%F).sql.gz +``` + +### MEDIO-002: SENTINEL No Desplegado + +**DescripciΓ³n:** Sistema de auditorΓ­a planificado pero no implementado. +**Impacto:** Sin visibilidad de anomalΓ­as. + +**MitigaciΓ³n:** Implementar SENTINEL LIGHT mode bΓ‘sico. + +### MEDIO-003: No hay RotaciΓ³n de Secretos + +**DescripciΓ³n:** Sin polΓ­tica de rotaciΓ³n de credenciales. +**Impacto:** Credenciales comprometidas persisten indefinidamente. + +**MitigaciΓ³n:** +- API keys: 90 dΓ­as +- DB passwords: 180 dΓ­as +- SSH keys: 365 dΓ­as + +--- + +## Controles Existentes + +| Control | Estado | Notas | +|---------|--------|-------| +| SSH Keys | Activo | Permisos 600 correctos | +| PostgreSQL SSL | Activo | SCRAM-SHA-256 | +| H_INSTANCIA Auth | Activo | CLARA/MARGARET | +| Gitea Tokens | Activo | Lectura/Escritura separados | +| DECK UFW | Activo | PolΓ­tica deny incoming | + +--- + +## Matriz de Riesgos + +| ID | Riesgo | Probabilidad | Impacto | Prioridad | +|----|--------|--------------|---------|-----------| +| CRÍTICO-001 | Firewall desactivado | Alta | Alto | Semana 1 | +| CRÍTICO-002 | PostgreSQL expuesto | Media | Alto | Semana 1 | +| CRÍTICO-003 | .env legibles | Alta | Alto | Semana 1 | +| ALTO-001 | Sin fail2ban | Alta | Medio | Semana 1 | +| ALTO-002 | Secretos duplicados | Media | Medio | Mes 1 | +| ALTO-003 | Sin TLS interno | Baja | Medio | Mes 1 | +| MEDIO-001 | Sin backup PG | Baja | Alto | Mes 1 | +| MEDIO-002 | Sin SENTINEL | Baja | Medio | Mes 2 | +| MEDIO-003 | Sin rotaciΓ³n | Baja | Medio | Mes 2 | + +--- + +## Plan de RemediaciΓ³n + +### Semana 1 (Urgente) +- [ ] Activar UFW en CORP y HST +- [ ] chmod 600 en todos los .env +- [ ] Instalar fail2ban +- [ ] PostgreSQL bind 127.0.0.1 + +### Mes 1 (Alta) +- [ ] Migrar secretos a Infisical +- [ ] TLS interno +- [ ] Backup PostgreSQL automatizado + +### Mes 2 (Media) +- [ ] SENTINEL LIGHT mode +- [ ] PolΓ­tica de rotaciΓ³n +- [ ] Monitoreo de certificados diff --git a/04_SEGURIDAD/secretos.md b/04_SEGURIDAD/secretos.md new file mode 100644 index 0000000..355b789 --- /dev/null +++ b/04_SEGURIDAD/secretos.md @@ -0,0 +1,292 @@ +# GestiΓ³n de Secretos TZZR + +**VersiΓ³n:** 5.0 +**Fecha:** 2024-12-24 + +--- + +## Estado Actual: Triple GestiΓ³n + +**PROBLEMA CRÍTICO:** Actualmente existen tres fuentes de secretos sin sincronizaciΓ³n. + +``` +β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” +β”‚ FUENTES DE SECRETOS β”‚ +β”‚ β”‚ +β”‚ β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”‚ +β”‚ β”‚ Infisical β”‚ β”‚ creds_* β”‚ β”‚ .env β”‚ β”‚ +β”‚ β”‚ (central) β”‚ β”‚ (PostgreSQL)β”‚ β”‚ (archivos) β”‚ β”‚ +β”‚ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β”‚ +β”‚ β”‚ β”‚ β”‚ β”‚ +β”‚ β–Ό β–Ό β–Ό β”‚ +β”‚ β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”‚ +β”‚ β”‚ ❌ SIN SINCRONIZACIΓ“N - Riesgo de inconsistencia β”‚ β”‚ +β”‚ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β”‚ +β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ +``` + +--- + +## Fuente 1: Infisical + +**URL:** http://localhost:8082 (ARCHITECT) +**Estado:** Operativo + +### ConfiguraciΓ³n + +```bash +# Acceso a Infisical +infisical login +infisical secrets --env=prod +``` + +### Ventajas +- Centralizado +- Versionado +- Auditable +- SDK para mΓΊltiples lenguajes + +### Uso Actual +- Parcial - no todos los servicios lo usan + +--- + +## Fuente 2: Tablas creds_* (PostgreSQL) + +**Base de datos:** architect +**Estado:** Activo + +### Tablas + +| Tabla | Contenido | +|-------|-----------| +| creds_ia | APIs de IA (OpenAI, Anthropic, etc.) | +| creds_runpod | API keys de RunPod | +| creds_r2 | Credenciales Cloudflare R2 | +| creds_gitea | Tokens Gitea | +| creds_mail | Credenciales SMTP | +| creds_apis | APIs externas varias | + +### Schema TΓ­pico + +```sql +CREATE TABLE creds_ia ( + id SERIAL PRIMARY KEY, + servicio VARCHAR(50) NOT NULL, + api_key TEXT NOT NULL, + descripcion TEXT, + activo BOOLEAN DEFAULT true, + created_at TIMESTAMP DEFAULT NOW(), + updated_at TIMESTAMP DEFAULT NOW() +); +``` + +### Acceso + +```sql +-- Consultar credenciales +sudo -u postgres psql -d architect -c "SELECT servicio, descripcion FROM creds_ia;" +``` + +--- + +## Fuente 3: Archivos .env + +**Ubicaciones:** +- /opt/clara/.env +- /opt/alfred/.env +- /opt/margaret/.env +- /opt/mason/.env +- /opt/feldman/.env + +### ALERTA CRÍTICA + +``` +Permisos actuales: 644 (legibles por todos) +Permisos correctos: 600 (solo propietario) +``` + +### Contenido TΓ­pico + +```bash +# Ejemplo .env +DB_HOST=localhost +DB_PORT=5432 +DB_NAME=corp +DB_USER=margaret +DB_PASSWORD=secreto_aqui # ⚠️ Expuesto si 644 + +R2_ACCESS_KEY=access_key_aqui +R2_SECRET_KEY=secret_key_aqui # ⚠️ Expuesto si 644 +``` + +--- + +## DecisiΓ³n D-001: MigraciΓ³n a Infisical + +### Objetivo +Infisical como **ΓΊnica fuente de verdad** para todos los secretos. + +### Plan de MigraciΓ³n + +``` +Fase 1: Inventario +β”œβ”€β”€ Catalogar todos los secretos en creds_* +β”œβ”€β”€ Catalogar todos los secretos en .env +└── Identificar duplicados/inconsistencias + +Fase 2: CentralizaciΓ³n +β”œβ”€β”€ Migrar todos los secretos a Infisical +β”œβ”€β”€ Organizar por proyecto/ambiente +└── Establecer polΓ­ticas de acceso + +Fase 3: ActualizaciΓ³n de Servicios +β”œβ”€β”€ CLARA: Usar Infisical SDK +β”œβ”€β”€ MARGARET: Usar Infisical SDK +β”œβ”€β”€ MASON: Usar Infisical SDK +β”œβ”€β”€ FELDMAN: Usar Infisical SDK +└── ALFRED/JARED: Usar Infisical SDK + +Fase 4: DeprecaciΓ³n +β”œβ”€β”€ Eliminar archivos .env +β”œβ”€β”€ Marcar creds_* como "solo referencia" +└── Documentar proceso de rotaciΓ³n +``` + +### ImplementaciΓ³n con SDK + +```python +from infisical_client import InfisicalClient + +client = InfisicalClient( + host="http://localhost:8082", + token=INFISICAL_TOKEN +) + +# Obtener secreto +db_password = client.get_secret( + secret_name="DB_PASSWORD", + project_id="tzzr", + environment="production" +) +``` + +--- + +## RotaciΓ³n de Secretos + +### PolΓ­tica Propuesta + +| Tipo | Frecuencia | Responsable | +|------|------------|-------------| +| API Keys externas | 90 dΓ­as | Orchestrator | +| ContraseΓ±as DB | 180 dΓ­as | DBA | +| SSH Keys | 365 dΓ­as | SysAdmin | +| Tokens Gitea | 180 dΓ­as | DevOps | + +### Proceso de RotaciΓ³n + +``` +1. Generar nuevo secreto +2. Actualizar en Infisical +3. Desplegar servicios afectados +4. Verificar funcionamiento +5. Revocar secreto anterior +6. Documentar en changelog +``` + +--- + +## MitigaciΓ³n Inmediata + +### Paso 1: Permisos .env + +```bash +# Ejecutar en todos los servidores + +# DECK +ssh -i ~/.ssh/tzzr root@72.62.1.113 'chmod 600 /opt/clara/.env /opt/alfred/.env' + +# CORP +ssh -i ~/.ssh/tzzr root@92.112.181.188 'chmod 600 /opt/margaret/.env /opt/mason/.env /opt/feldman/.env' +``` + +### Paso 2: AuditorΓ­a + +```bash +# Verificar permisos +ls -la /opt/*/.env + +# Buscar secretos expuestos +grep -r "password\|secret\|key" /opt/*/ 2>/dev/null +``` + +--- + +## Inventario de Secretos + +### APIs de IA + +| Servicio | UbicaciΓ³n Actual | Notas | +|----------|------------------|-------| +| OpenAI | creds_ia | GPT-4 | +| Anthropic | creds_ia | Claude | +| Replicate | creds_ia | Modelos varios | +| RunPod | creds_runpod | GRACE, PENNY, FACTORY | + +### Infraestructura + +| Servicio | UbicaciΓ³n Actual | Notas | +|----------|------------------|-------| +| PostgreSQL | .env + creds_* | MΓΊltiples usuarios | +| R2/Cloudflare | .env + creds_r2 | Access + Secret key | +| Gitea | .env + creds_gitea | Read + Write tokens | +| SMTP | creds_mail | Mailcow | + +### Servicios Externos + +| Servicio | UbicaciΓ³n Actual | Notas | +|----------|------------------|-------| +| Stripe | creds_apis | (si aplica) | +| Twilio | creds_apis | (si aplica) | +| AWS | creds_apis | (si aplica) | + +--- + +## VerificaciΓ³n de Seguridad + +### Checklist Diario + +- [ ] Permisos .env son 600 +- [ ] No hay secretos en logs +- [ ] No hay secretos en commits git +- [ ] Infisical accesible + +### Comandos de VerificaciΓ³n + +```bash +# Verificar permisos +find /opt -name ".env" -exec ls -la {} \; + +# Buscar secretos en git history +git log -p | grep -i "password\|secret\|key\|token" + +# Verificar Infisical +curl -s http://localhost:8082/api/v1/health +``` + +--- + +## Buenas PrΓ‘cticas + +### DO (Hacer) +- Usar Infisical para todos los secretos nuevos +- Rotar secretos segΓΊn polΓ­tica +- Auditar accesos regularmente +- Cifrar secretos en reposo + +### DON'T (No Hacer) +- Hardcodear secretos en cΓ³digo +- Commitear .env a repositorios +- Compartir secretos por chat/email +- Usar el mismo secreto en mΓΊltiples servicios diff --git a/05_OPERACIONES/backup-recovery.md b/05_OPERACIONES/backup-recovery.md new file mode 100644 index 0000000..d21bddc --- /dev/null +++ b/05_OPERACIONES/backup-recovery.md @@ -0,0 +1,359 @@ +# Backup y Recovery TZZR + +**VersiΓ³n:** 5.0 +**Fecha:** 2024-12-24 + +--- + +## Estado Actual + +### Backups Existentes + +| Sistema | Backup | Destino | Frecuencia | Estado | +|---------|--------|---------|------------|--------| +| Gitea | SΓ­ | R2 | Manual | Operativo | +| PostgreSQL ARCHITECT | No | - | - | **CRÍTICO** | +| PostgreSQL DECK | No | - | - | **CRÍTICO** | +| PostgreSQL CORP | No | - | - | **CRÍTICO** | +| PostgreSQL HST | No | - | - | **CRÍTICO** | +| R2 buckets | Built-in | R2 | AutomΓ‘tico | Operativo | + +--- + +## Plan de Backup Propuesto + +### PostgreSQL - Backup Diario + +```bash +#!/bin/bash +# /opt/scripts/backup_postgres.sh + +set -e + +DATE=$(date +%F) +BACKUP_DIR="/tmp/pg_backup" + +# Cargar credenciales R2 +source /home/orchestrator/orchestrator/.env +export AWS_ACCESS_KEY_ID="$R2_ACCESS_KEY" +export AWS_SECRET_ACCESS_KEY="$R2_SECRET_KEY" + +R2_ENDPOINT="https://7dedae6030f5554d99d37e98a5232996.r2.cloudflarestorage.com" + +mkdir -p $BACKUP_DIR + +# Backup ARCHITECT +echo "Backing up ARCHITECT..." +sudo -u postgres pg_dump architect | gzip > $BACKUP_DIR/architect_$DATE.sql.gz +aws s3 cp $BACKUP_DIR/architect_$DATE.sql.gz s3://architect/backups/postgres/ \ + --endpoint-url $R2_ENDPOINT + +# Cleanup local +rm -rf $BACKUP_DIR + +echo "Backup completado: $DATE" +``` + +### Cron Configuration + +```bash +# /etc/cron.d/tzzr-backup +# Backup diario a las 3:00 AM +0 3 * * * orchestrator /opt/scripts/backup_postgres.sh >> /var/log/tzzr-backup.log 2>&1 +``` + +--- + +## Backup por Servidor + +### ARCHITECT (69.62.126.110) + +```bash +# Base de datos: architect +sudo -u postgres pg_dump architect | gzip > architect_$(date +%F).sql.gz + +# Subir a R2 +aws s3 cp architect_$(date +%F).sql.gz s3://architect/backups/postgres/ \ + --endpoint-url $R2_ENDPOINT +``` + +### DECK (72.62.1.113) + +```bash +# Base de datos: tzzr +ssh deck 'sudo -u postgres pg_dump tzzr | gzip' > deck_tzzr_$(date +%F).sql.gz + +# Subir a R2 +aws s3 cp deck_tzzr_$(date +%F).sql.gz s3://architect/backups/deck/ \ + --endpoint-url $R2_ENDPOINT +``` + +### CORP (92.112.181.188) + +```bash +# Base de datos: corp +ssh corp 'sudo -u postgres pg_dump corp | gzip' > corp_$(date +%F).sql.gz + +# Subir a R2 +aws s3 cp corp_$(date +%F).sql.gz s3://architect/backups/corp/ \ + --endpoint-url $R2_ENDPOINT +``` + +### HST (72.62.2.84) + +```bash +# Base de datos: hst_images +ssh hst 'sudo -u postgres pg_dump hst_images | gzip' > hst_$(date +%F).sql.gz + +# Subir a R2 +aws s3 cp hst_$(date +%F).sql.gz s3://architect/backups/hst/ \ + --endpoint-url $R2_ENDPOINT +``` + +--- + +## Gitea Backup + +### Backup Manual + +```bash +# En ARCHITECT +docker exec -t gitea bash -c 'gitea dump -c /data/gitea/conf/app.ini' +docker cp gitea:/app/gitea/gitea-dump-*.zip ./ + +# Subir a R2 +aws s3 cp gitea-dump-*.zip s3://architect/backups/gitea/ \ + --endpoint-url $R2_ENDPOINT +``` + +### Backup AutomΓ‘tico + +```bash +#!/bin/bash +# /opt/scripts/backup_gitea.sh + +DATE=$(date +%F_%H%M) + +# Crear dump +docker exec -t gitea bash -c "gitea dump -c /data/gitea/conf/app.ini -f /tmp/gitea-dump-$DATE.zip" + +# Copiar fuera del container +docker cp gitea:/tmp/gitea-dump-$DATE.zip /tmp/ + +# Subir a R2 +source /home/orchestrator/orchestrator/.env +export AWS_ACCESS_KEY_ID="$R2_ACCESS_KEY" +export AWS_SECRET_ACCESS_KEY="$R2_SECRET_KEY" + +aws s3 cp /tmp/gitea-dump-$DATE.zip s3://architect/backups/gitea/ \ + --endpoint-url https://7dedae6030f5554d99d37e98a5232996.r2.cloudflarestorage.com + +# Cleanup +rm /tmp/gitea-dump-$DATE.zip +docker exec gitea rm /tmp/gitea-dump-$DATE.zip +``` + +--- + +## Estructura de Backups en R2 + +``` +s3://architect/backups/ +β”œβ”€β”€ postgres/ +β”‚ β”œβ”€β”€ architect_2024-12-24.sql.gz +β”‚ β”œβ”€β”€ architect_2024-12-23.sql.gz +β”‚ └── ... +β”œβ”€β”€ deck/ +β”‚ β”œβ”€β”€ deck_tzzr_2024-12-24.sql.gz +β”‚ └── ... +β”œβ”€β”€ corp/ +β”‚ β”œβ”€β”€ corp_2024-12-24.sql.gz +β”‚ └── ... +β”œβ”€β”€ hst/ +β”‚ β”œβ”€β”€ hst_2024-12-24.sql.gz +β”‚ └── ... +└── gitea/ + β”œβ”€β”€ gitea-dump-2024-12-24_0300.zip + └── ... +``` + +--- + +## RetenciΓ³n de Backups + +### PolΓ­tica Propuesta + +| Tipo | RetenciΓ³n | Notas | +|------|-----------|-------| +| Diario | 7 dΓ­as | Últimos 7 backups | +| Semanal | 4 semanas | Domingos | +| Mensual | 12 meses | Primer dΓ­a del mes | + +### Script de Limpieza + +```bash +#!/bin/bash +# /opt/scripts/cleanup_backups.sh + +source /home/orchestrator/orchestrator/.env +export AWS_ACCESS_KEY_ID="$R2_ACCESS_KEY" +export AWS_SECRET_ACCESS_KEY="$R2_SECRET_KEY" + +R2_ENDPOINT="https://7dedae6030f5554d99d37e98a5232996.r2.cloudflarestorage.com" + +# Eliminar backups mΓ‘s antiguos de 30 dΓ­as +# (Implementar con lifecycle rules de R2 preferentemente) + +aws s3 ls s3://architect/backups/postgres/ --endpoint-url $R2_ENDPOINT | \ + while read -r line; do + createDate=$(echo $line | awk '{print $1}') + fileName=$(echo $line | awk '{print $4}') + + # Comparar fechas y eliminar si > 30 dΓ­as + # ... + done +``` + +--- + +## Recovery + +### PostgreSQL - Restaurar Base de Datos + +```bash +# Descargar backup +aws s3 cp s3://architect/backups/postgres/architect_2024-12-24.sql.gz . \ + --endpoint-url $R2_ENDPOINT + +# Descomprimir +gunzip architect_2024-12-24.sql.gz + +# Restaurar (Β‘CUIDADO! Sobrescribe datos existentes) +sudo -u postgres psql -d architect < architect_2024-12-24.sql +``` + +### PostgreSQL - Restaurar a Nueva Base + +```bash +# Crear nueva base de datos +sudo -u postgres createdb architect_restored + +# Restaurar +gunzip -c architect_2024-12-24.sql.gz | sudo -u postgres psql -d architect_restored +``` + +### Gitea - Restaurar + +```bash +# Descargar backup +aws s3 cp s3://architect/backups/gitea/gitea-dump-2024-12-24_0300.zip . \ + --endpoint-url $R2_ENDPOINT + +# Detener Gitea +docker stop gitea + +# Copiar al container +docker cp gitea-dump-2024-12-24_0300.zip gitea:/tmp/ + +# Restaurar +docker exec gitea bash -c "cd /tmp && unzip gitea-dump-2024-12-24_0300.zip" +# Seguir instrucciones de Gitea para restore + +# Iniciar Gitea +docker start gitea +``` + +--- + +## Disaster Recovery Plan + +### Escenario 1: PΓ©rdida de ARCHITECT + +1. Provisionar nuevo VPS con misma IP (si posible) +2. Instalar Ubuntu 22.04 +3. Configurar usuario orchestrator +4. Restaurar PostgreSQL desde R2 +5. Restaurar Gitea desde R2 +6. Reinstalar Docker y servicios +7. Verificar conectividad con DECK/CORP/HST + +### Escenario 2: PΓ©rdida de DECK + +1. Provisionar nuevo VPS +2. Restaurar PostgreSQL (tzzr) desde backup +3. Reinstalar CLARA, ALFRED +4. Reinstalar Mailcow (requiere backup separado) +5. Actualizar DNS si IP cambiΓ³ + +### Escenario 3: PΓ©rdida de CORP + +1. Provisionar nuevo VPS +2. Restaurar PostgreSQL (corp) desde backup +3. Reinstalar MARGARET, JARED, MASON, FELDMAN +4. Reinstalar Odoo, Nextcloud +5. Activar UFW (nuevo servidor) + +### Escenario 4: PΓ©rdida de R2 + +**IMPROBABLE** - Cloudflare tiene redundancia multi-regiΓ³n. + +MitigaciΓ³n: Backup mensual a segundo proveedor (AWS S3 Glacier). + +--- + +## VerificaciΓ³n de Backups + +### Test Mensual + +```bash +#!/bin/bash +# /opt/scripts/verify_backup.sh + +# Descargar ΓΊltimo backup +LATEST=$(aws s3 ls s3://architect/backups/postgres/ --endpoint-url $R2_ENDPOINT | \ + sort | tail -1 | awk '{print $4}') + +aws s3 cp s3://architect/backups/postgres/$LATEST /tmp/ \ + --endpoint-url $R2_ENDPOINT + +# Verificar integridad +gunzip -t /tmp/$LATEST +if [ $? -eq 0 ]; then + echo "Backup vΓ‘lido: $LATEST" +else + echo "ERROR: Backup corrupto: $LATEST" + # Enviar alerta +fi + +rm /tmp/$LATEST +``` + +### Checklist de VerificaciΓ³n + +- [ ] Backup PostgreSQL ARCHITECT existe (< 24h) +- [ ] Backup PostgreSQL DECK existe (< 24h) +- [ ] Backup PostgreSQL CORP existe (< 24h) +- [ ] Backup Gitea existe (< 7d) +- [ ] Integridad verificada (gunzip -t) +- [ ] Restore test exitoso (mensual) + +--- + +## Alertas + +### ConfiguraciΓ³n ntfy + +```bash +# Notificar si backup falla +if [ $? -ne 0 ]; then + curl -d "Backup FALLIDO: $DATE" ntfy.sh/tzzr-alerts +fi +``` + +### Monitoreo + +```bash +# Verificar ΓΊltimo backup +aws s3 ls s3://architect/backups/postgres/ --endpoint-url $R2_ENDPOINT | \ + sort | tail -5 +``` diff --git a/05_OPERACIONES/infraestructura.md b/05_OPERACIONES/infraestructura.md new file mode 100644 index 0000000..34f47c0 --- /dev/null +++ b/05_OPERACIONES/infraestructura.md @@ -0,0 +1,383 @@ +# Infraestructura TZZR + +**VersiΓ³n:** 5.0 +**Fecha:** 2024-12-24 + +--- + +## Resumen de Servidores + +| Servidor | IP PΓΊblica | Rol | Proveedor | +|----------|------------|-----|-----------| +| ARCHITECT | 69.62.126.110 | Coordinador central | VPS | +| DECK | 72.62.1.113 | Personal | VPS | +| CORP | 92.112.181.188 | Empresarial | VPS | +| HST | 72.62.2.84 | API Tags | VPS | +| LOCKER | R2 | Almacenamiento | Cloudflare | + +--- + +## ARCHITECT (69.62.126.110) + +### Especificaciones +- **OS:** Ubuntu 22.04 LTS +- **Usuario:** orchestrator +- **Servicios:** PostgreSQL, Gitea, Orchestrator, Infisical + +### Puertos + +| Puerto | Servicio | Estado | +|--------|----------|--------| +| 22 | SSH | Abierto | +| 2222 | Gitea SSH | Abierto | +| 3000 | Gitea HTTP | Abierto | +| 5050 | Orchestrator | Abierto | +| 5432 | PostgreSQL | **CRÍTICO: 0.0.0.0** | +| 8082 | Infisical | Abierto | + +### Acceso + +```bash +ssh orchestrator@69.62.126.110 +``` + +### PostgreSQL + +```bash +sudo -u postgres psql -d architect +``` + +### Gitea + +``` +URL: http://localhost:3000 +Token lectura: 5ca10e5b71d41f9b22f12d0f96bfc2e6de5c2c7f +Token escritura: ac5a604b9aac5cee81192a656fc918f9efa3834b +``` + +--- + +## DECK (72.62.1.113) + +### Especificaciones +- **OS:** Ubuntu 22.04 LTS +- **Usuario:** root +- **Servicios:** CLARA, ALFRED, Mailcow, Directus, etc. + +### Puertos + +| Puerto | Servicio | Estado | +|--------|----------|--------| +| 22 | SSH | Abierto | +| 25 | SMTP | Abierto | +| 143 | IMAP | Abierto | +| 465 | SMTPS | Abierto | +| 587 | Submission | Abierto | +| 993 | IMAPS | Abierto | +| 5051 | CLARA | Abierto | +| 5052 | ALFRED | Abierto | +| 8055 | Directus | Abierto | +| 8080 | ntfy | Abierto | +| 8082 | FileBrowser | Abierto | +| 8083 | Shlink | Abierto | +| 8085 | Vaultwarden | Abierto | + +### Acceso + +```bash +ssh -i ~/.ssh/tzzr root@72.62.1.113 +``` + +### Docker Containers + +```bash +docker ps --format "table {{.Names}}\t{{.Status}}\t{{.Ports}}" +``` + +--- + +## CORP (92.112.181.188) + +### Especificaciones +- **OS:** Ubuntu 22.04 LTS +- **Usuario:** root +- **Servicios:** MARGARET, JARED, MASON, FELDMAN, Odoo, Nextcloud + +### Puertos + +| Puerto | Servicio | Estado | +|--------|----------|--------| +| 22 | SSH | Abierto | +| 80 | Caddy HTTP | Abierto | +| 443 | Caddy HTTPS | Abierto | +| 5051 | MARGARET | Abierto | +| 5052 | JARED | Abierto | +| 5053 | MASON | Abierto | +| 5054 | FELDMAN | Abierto | +| 5432 | PostgreSQL | Local | +| 8055 | Directus | Abierto | +| 8069 | Odoo | Abierto | +| 8080 | Nextcloud | Abierto | +| 8081 | Vaultwarden | Abierto | + +### Acceso + +```bash +ssh -i ~/.ssh/tzzr root@92.112.181.188 +``` + +### Firewall + +**ALERTA CRÍTICA: UFW INACTIVO** + +```bash +# Verificar estado +ufw status + +# Activar (cuando se autorice) +ufw default deny incoming +ufw allow 22/tcp +ufw allow 80/tcp +ufw allow 443/tcp +ufw enable +``` + +--- + +## HST (72.62.2.84) + +### Especificaciones +- **OS:** Ubuntu 22.04 LTS +- **Usuario:** root +- **Servicios:** Nginx, Directus, PostgreSQL + +### Puertos + +| Puerto | Servicio | Estado | +|--------|----------|--------| +| 22 | SSH | Abierto | +| 80 | Nginx HTTP | Abierto | +| 443 | Nginx HTTPS | Abierto | +| 5432 | PostgreSQL | Local | +| 8055 | Directus | Abierto | + +### Acceso + +```bash +ssh -i ~/.ssh/tzzr root@72.62.2.84 +``` + +### API PΓΊblica + +``` +https://tzrtech.org/{h_maestro}.png +``` + +### EstadΓ­sticas HST + +| Grupo | Cantidad | +|-------|----------| +| hst | 639 | +| spe | 145 | +| vsn | 84 | +| flg | 65 | +| vue | 21 | +| **Total** | **973** | + +--- + +## LOCKER (Cloudflare R2) + +### Endpoint + +``` +https://7dedae6030f5554d99d37e98a5232996.r2.cloudflarestorage.com +``` + +### Buckets + +| Bucket | Uso | TamaΓ±o Aprox | +|--------|-----|--------------| +| architect | Backups, configs, GPU services | ~500 MB | +| deck | Archivos personales (CLARA) | Variable | +| corp | Archivos empresariales (MARGARET) | Variable | +| hst | ImΓ‘genes de tags | ~100 MB | +| locker | Almacenamiento general | Variable | + +### Acceso + +```bash +source /home/orchestrator/orchestrator/.env +export AWS_ACCESS_KEY_ID="$R2_ACCESS_KEY" +export AWS_SECRET_ACCESS_KEY="$R2_SECRET_KEY" + +aws s3 ls s3://architect/ \ + --endpoint-url https://7dedae6030f5554d99d37e98a5232996.r2.cloudflarestorage.com +``` + +--- + +## SSH Keys + +### UbicaciΓ³n + +``` +/home/orchestrator/.ssh/tzzr # Private key +/home/orchestrator/.ssh/tzzr.pub # Public key +``` + +### Permisos + +```bash +chmod 600 ~/.ssh/tzzr +chmod 644 ~/.ssh/tzzr.pub +``` + +### ConfiguraciΓ³n SSH + +```bash +# ~/.ssh/config +Host deck + HostName 72.62.1.113 + User root + IdentityFile ~/.ssh/tzzr + +Host corp + HostName 92.112.181.188 + User root + IdentityFile ~/.ssh/tzzr + +Host hst + HostName 72.62.2.84 + User root + IdentityFile ~/.ssh/tzzr +``` + +--- + +## Bases de Datos + +### architect (ARCHITECT) + +``` +Host: localhost +Port: 5432 +Database: architect +User: postgres +``` + +Tablas principales: +- context_blocks +- agents +- creds_* + +### tzzr (DECK) + +``` +Host: localhost +Port: 5432 +Database: tzzr +``` + +Tablas principales: +- clara_log +- deck_visiones +- deck_milestones + +### corp (CORP) + +``` +Host: localhost +Port: 5432 +Database: corp +``` + +Tablas principales: +- margaret_log +- mason_workspace +- feldman_cola +- milestones +- bloques + +### hst_images (HST) + +``` +Host: localhost +Port: 5432 +Database: hst_images +``` + +Tablas principales: +- hst_tags +- hst_trees + +--- + +## Monitoreo + +### Comandos de Estado + +```bash +# Verificar servicios ARCHITECT +systemctl status postgresql +docker ps + +# Verificar servicios DECK +ssh deck 'docker ps' +ssh deck 'systemctl status fail2ban' + +# Verificar servicios CORP +ssh corp 'docker ps' +ssh corp 'ufw status' + +# Verificar servicios HST +ssh hst 'systemctl status nginx' +ssh hst 'systemctl status postgresql' +``` + +### Logs Importantes + +```bash +# PostgreSQL +journalctl -u postgresql -f + +# Docker containers +docker logs -f + +# Nginx (HST) +tail -f /var/log/nginx/access.log +tail -f /var/log/nginx/error.log + +# SSH auth +tail -f /var/log/auth.log +``` + +--- + +## Diagrama de Red + +``` + Internet + β”‚ + β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” + β”‚ β”‚ β”‚ + β–Ό β–Ό β–Ό + β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” + β”‚ ARCHITECT β”‚ β”‚ DECK β”‚ β”‚ CORP β”‚ + β”‚ 69.62.126.110 │◄────────│ 72.62.1.113 │────────►│92.112.181.188 β”‚ + β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ SSH β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ SSH β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ + β”‚ β”‚ β”‚ + β”‚ β”‚ β”‚ + β”‚ β–Ό β”‚ + β”‚ β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”‚ + β”‚ β”‚ HST β”‚ β”‚ + └────────────────►│ 72.62.2.84 β”‚β—„β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ + SSH β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ + β”‚ + β”‚ HTTPS + β–Ό + β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” + β”‚ Cloudflare β”‚ + β”‚ R2 β”‚ + β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ +``` diff --git a/06_INTEGRACIONES/gpu-services.md b/06_INTEGRACIONES/gpu-services.md new file mode 100644 index 0000000..1561f52 --- /dev/null +++ b/06_INTEGRACIONES/gpu-services.md @@ -0,0 +1,179 @@ +# GPU Services - RunPod + +**VersiΓ³n:** 5.0 +**Fecha:** 2024-12-24 + +--- + +## Estado CrΓ­tico + +**ALERTA: RunPod NO es confiable para producciΓ³n.** + +### Incidente 2024-12-24 + +RunPod fallΓ³ en provisionar workers a pesar de: +- ConfiguraciΓ³n correcta +- Balance suficiente ($72+) +- Jobs en cola + +**Resultado:** 0 workers activos. Servicio GPU inoperativo. + +--- + +## Endpoints Configurados + +| Servicio | Endpoint ID | Estado | +|----------|-------------|--------| +| GRACE | r00x4g3rrwkbyh | Inactivo | +| PENNY | 0mxhaokgsmgee3 | Inactivo | +| FACTORY | ddnuk6y35zi56a | Inactivo | + +--- + +## GRACE (ExtracciΓ³n IA) + +### MΓ³dulos Implementados (6 de 18) + +| MΓ³dulo | DescripciΓ³n | +|--------|-------------| +| ASR | Speech-to-text | +| OCR | Reconocimiento texto | +| TTS | Text-to-speech | +| Face | Reconocimiento facial | +| Embeddings | Vectores semΓ‘nticos | +| Avatar | GeneraciΓ³n avatares | + +### MΓ³dulos Pendientes (12) + +- Document parsing +- Image classification +- Object detection +- Sentiment analysis +- Named entity recognition +- Translation +- Summarization +- Question answering +- Code generation +- Audio classification +- Video analysis +- Multimodal fusion + +--- + +## CΓ³digo Disponible en R2 + +Los handlers estΓ‘n listos y son portables: + +``` +s3://architect/gpu-services/ +β”œβ”€β”€ base/ +β”‚ └── bootstrap.sh +β”œβ”€β”€ grace/ +β”‚ └── code/handler.py +β”œβ”€β”€ penny/ +β”‚ └── code/handler.py +└── factory/ + └── code/handler.py +``` + +### Descargar CΓ³digo + +```bash +source /home/orchestrator/orchestrator/.env +export AWS_ACCESS_KEY_ID="$R2_ACCESS_KEY" +export AWS_SECRET_ACCESS_KEY="$R2_SECRET_KEY" + +aws s3 sync s3://architect/gpu-services/ ./gpu-services/ \ + --endpoint-url https://7dedae6030f5554d99d37e98a5232996.r2.cloudflarestorage.com +``` + +--- + +## Alternativas a Evaluar + +### 1. Modal (Recomendado) + +- Pricing: Pay-per-use +- Pros: Serverless real, buen DX, Python-native +- Contras: Menos GPUs disponibles que RunPod + +```python +import modal + +stub = modal.Stub("grace") + +@stub.function(gpu="A10G") +def process_asr(audio_bytes): + # Whisper inference + pass +``` + +### 2. Replicate + +- Pricing: Per-inference +- Pros: Modelos pre-entrenados, API simple +- Contras: Menos control, mΓ‘s caro a escala + +### 3. Lambda Labs + +- Pricing: Hourly +- Pros: Hardware dedicado +- Contras: Menos flexible, reserva manual + +### 4. Self-Hosted + +- Pricing: Upfront + hosting +- Pros: Control total, sin dependencias +- Contras: CapEx alto, mantenimiento + +--- + +## MigraciΓ³n Propuesta + +### Fase 1: EvaluaciΓ³n (1 semana) +- [ ] Probar Modal con ASR handler +- [ ] Comparar latencia y costo + +### Fase 2: MigraciΓ³n (2 semanas) +- [ ] Portar 6 handlers a Modal +- [ ] Actualizar endpoints en MASON + +### Fase 3: ProducciΓ³n +- [ ] Desplegar en Modal +- [ ] Deprecar RunPod endpoints + +--- + +## ConfiguraciΓ³n Actual RunPod + +### API Key + +``` +Almacenada en: creds_runpod (PostgreSQL ARCHITECT) +Campo: api_key_runpod +``` + +### SDK + +```python +import runpod + +runpod.api_key = "..." + +# Crear job +job = runpod.run( + endpoint_id="r00x4g3rrwkbyh", + input={"audio": "base64..."} +) + +# Check status +status = runpod.status(job["id"]) +``` + +--- + +## RecomendaciΓ³n + +**NO confiar en RunPod para producciΓ³n.** + +Migrar a Modal como prioridad alta una vez resueltos los issues de seguridad crΓ­ticos. diff --git a/99_ANEXOS/inventario-repos.md b/99_ANEXOS/inventario-repos.md new file mode 100644 index 0000000..947adc4 --- /dev/null +++ b/99_ANEXOS/inventario-repos.md @@ -0,0 +1,387 @@ +# Inventario de Repositorios TZZR + +**VersiΓ³n:** 5.0 +**Fecha:** 2024-12-24 +**Fuente:** Gitea (http://localhost:3000/tzzr) + +--- + +## Resumen + +| CategorΓ­a | Cantidad | +|-----------|----------| +| Infraestructura | 6 | +| Data Services | 6 | +| Security/Ops | 6 | +| Interfaces | 6 | +| **Total** | **24** | + +--- + +## Infraestructura + +### orchestrator + +| Campo | Valor | +|-------|-------| +| URL | http://localhost:3000/tzzr/orchestrator | +| Estado | Activo | +| DescripciΓ³n | Sistema de orquestaciΓ³n central | +| Prioridad | Alta | + +**Archivos clave:** +- `main.py` - Entrada principal +- `.env` - ConfiguraciΓ³n +- `docker-compose.yml` - Despliegue + +--- + +### hst-api + +| Campo | Valor | +|-------|-------| +| URL | http://localhost:3000/tzzr/hst-api | +| Estado | Activo | +| DescripciΓ³n | API de tags HST (973 tags) | +| Prioridad | Alta | + +**Archivos clave:** +- `api/routes.py` - Endpoints +- `db/schema.sql` - Schema + +--- + +### clara + +| Campo | Valor | +|-------|-------| +| URL | http://localhost:3000/tzzr/clara | +| Estado | Activo | +| DescripciΓ³n | Agente de ingesta personal | +| Prioridad | Alta | + +**Archivos clave:** +- `app.py` - API FastAPI +- `ingest.py` - LΓ³gica de ingesta +- `Dockerfile` - Container + +--- + +### margaret + +| Campo | Valor | +|-------|-------| +| URL | http://localhost:3000/tzzr/margaret | +| Estado | Activo | +| DescripciΓ³n | Agente de ingesta corporativo | +| Prioridad | Alta | + +**Archivos clave:** +- `app.py` - API FastAPI +- `ingest.py` - LΓ³gica de ingesta +- `Dockerfile` - Container + +--- + +### alfred + +| Campo | Valor | +|-------|-------| +| URL | http://localhost:3000/tzzr/alfred | +| Estado | Activo | +| DescripciΓ³n | Flujos predefinidos DECK | +| Prioridad | Media | + +**Archivos clave:** +- `flows/` - Definiciones de flujos +- `executor.py` - Motor de ejecuciΓ³n + +--- + +### jared + +| Campo | Valor | +|-------|-------| +| URL | http://localhost:3000/tzzr/jared | +| Estado | Activo | +| DescripciΓ³n | Flujos predefinidos CORP | +| Prioridad | Media | + +**Archivos clave:** +- `flows/` - Definiciones de flujos +- `executor.py` - Motor de ejecuciΓ³n + +--- + +## Data Services + +### mason + +| Campo | Valor | +|-------|-------| +| URL | http://localhost:3000/tzzr/mason | +| Estado | Activo | +| DescripciΓ³n | Enriquecimiento de datos | +| Prioridad | Alta | + +**Archivos clave:** +- `workspace.py` - GestiΓ³n workspace +- `enrichment.py` - LΓ³gica de enriquecimiento + +--- + +### feldman + +| Campo | Valor | +|-------|-------| +| URL | http://localhost:3000/tzzr/feldman | +| Estado | Activo | +| DescripciΓ³n | ConsolidaciΓ³n blockchain | +| Prioridad | Alta | + +**Archivos clave:** +- `validator.py` - Reglas M-001, M-002, M-003 +- `consolidator.py` - CreaciΓ³n de bloques + +--- + +### grace-handler + +| Campo | Valor | +|-------|-------| +| URL | http://localhost:3000/tzzr/grace-handler | +| Estado | Bloqueado (RunPod) | +| DescripciΓ³n | Handler GPU para GRACE | +| Prioridad | Alta | + +**Archivos clave:** +- `handler.py` - RunPod handler +- `modules/` - 6 mΓ³dulos IA + +--- + +### penny-handler + +| Campo | Valor | +|-------|-------| +| URL | http://localhost:3000/tzzr/penny-handler | +| Estado | Planificado | +| DescripciΓ³n | Handler GPU para PENNY | +| Prioridad | Baja | + +--- + +### factory-handler + +| Campo | Valor | +|-------|-------| +| URL | http://localhost:3000/tzzr/factory-handler | +| Estado | Planificado | +| DescripciΓ³n | Handler GPU para FACTORY | +| Prioridad | Baja | + +--- + +### s-contract + +| Campo | Valor | +|-------|-------| +| URL | http://localhost:3000/tzzr/s-contract | +| Estado | En desarrollo | +| DescripciΓ³n | Contextos y datasets IA | +| Prioridad | Media | + +--- + +## Security/Ops + +### sentinel + +| Campo | Valor | +|-------|-------| +| URL | http://localhost:3000/tzzr/sentinel | +| Estado | Planificado | +| DescripciΓ³n | AuditorΓ­a del sistema | +| Prioridad | Media | + +**Modos:** +- LIGHT: Cada 5 min, reglas automΓ‘ticas +- DEEP: Cada 1 hora, muestreo con LLM + +--- + +### infisical-config + +| Campo | Valor | +|-------|-------| +| URL | http://localhost:3000/tzzr/infisical-config | +| Estado | Activo | +| DescripciΓ³n | ConfiguraciΓ³n Infisical | +| Prioridad | Alta | + +--- + +### backup-scripts + +| Campo | Valor | +|-------|-------| +| URL | http://localhost:3000/tzzr/backup-scripts | +| Estado | En desarrollo | +| DescripciΓ³n | Scripts de backup R2 | +| Prioridad | Alta | + +--- + +### deploy-configs + +| Campo | Valor | +|-------|-------| +| URL | http://localhost:3000/tzzr/deploy-configs | +| Estado | Activo | +| DescripciΓ³n | Configuraciones de despliegue | +| Prioridad | Media | + +--- + +### monitoring + +| Campo | Valor | +|-------|-------| +| URL | http://localhost:3000/tzzr/monitoring | +| Estado | Planificado | +| DescripciΓ³n | Dashboards y alertas | +| Prioridad | Media | + +--- + +### security-audit + +| Campo | Valor | +|-------|-------| +| URL | http://localhost:3000/tzzr/security-audit | +| Estado | En desarrollo | +| DescripciΓ³n | Scripts de auditorΓ­a | +| Prioridad | Alta | + +--- + +## Interfaces + +### packet-app + +| Campo | Valor | +|-------|-------| +| URL | http://localhost:3000/tzzr/packet-app | +| Estado | En desarrollo | +| DescripciΓ³n | App mΓ³vil Flutter | +| Prioridad | Alta | + +**TecnologΓ­a:** Flutter/Dart + +--- + +### vision-builder + +| Campo | Valor | +|-------|-------| +| URL | http://localhost:3000/tzzr/vision-builder | +| Estado | En desarrollo | +| DescripciΓ³n | DiseΓ±ador de visiones | +| Prioridad | Media | + +--- + +### admin-dashboard + +| Campo | Valor | +|-------|-------| +| URL | http://localhost:3000/tzzr/admin-dashboard | +| Estado | Planificado | +| DescripciΓ³n | Dashboard administrativo | +| Prioridad | Baja | + +--- + +### api-gateway + +| Campo | Valor | +|-------|-------| +| URL | http://localhost:3000/tzzr/api-gateway | +| Estado | Planificado | +| DescripciΓ³n | Gateway API unificado | +| Prioridad | Media | + +--- + +### docs-site + +| Campo | Valor | +|-------|-------| +| URL | http://localhost:3000/tzzr/docs-site | +| Estado | En desarrollo | +| DescripciΓ³n | Sitio de documentaciΓ³n | +| Prioridad | Media | + +--- + +### system-docs + +| Campo | Valor | +|-------|-------| +| URL | http://localhost:3000/tzzr/system-docs | +| Estado | Activo (este repo) | +| DescripciΓ³n | DocumentaciΓ³n System v5 | +| Prioridad | Alta | + +--- + +## EstadΓ­sticas + +### Por Estado + +| Estado | Cantidad | +|--------|----------| +| Activo | 12 | +| En desarrollo | 6 | +| Planificado | 5 | +| Bloqueado | 1 | + +### Por Prioridad + +| Prioridad | Cantidad | +|-----------|----------| +| Alta | 12 | +| Media | 8 | +| Baja | 4 | + +--- + +## Dependencias Entre Repos + +``` +packet-app + β”‚ + β–Ό +clara / margaret + β”‚ + β–Ό +alfred / jared + β”‚ + β–Ό +mason ◄──── grace-handler (bloqueado) + β”‚ + β–Ό +feldman + β”‚ + β–Ό +sentinel (planificado) +``` + +--- + +## Notas + +1. **grace-handler**: CΓ³digo listo en R2, RunPod no inicia workers +2. **sentinel**: Solo documentaciΓ³n, sin implementaciΓ³n +3. **system-docs**: Este repositorio, documentaciΓ³n v5 +4. **orchestrator**: Coordinador central en ARCHITECT diff --git a/README.md b/README.md index a73ce15..2dd626c 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,120 @@ -# system-docs +# TZZR System Documentation v5 -DocumentaciΓ³n oficial del sistema TZZR - System v5 \ No newline at end of file +**VersiΓ³n:** 5.0 +**Fecha:** 2024-12-24 +**Estado:** ConsolidaciΓ³n completa + +--- + +## QuΓ© es TZZR + +TZZR es un sistema de construcciΓ³n de arquitecturas personales y empresariales mediante instancias Claude. Los agentes IA actΓΊan como constructores que diseΓ±an y edifican servidores clonables e independientes. + +--- + +## Arquitectura General + +``` +β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” +β”‚ ARCHITECT (69.62.126.110) β”‚ +β”‚ PostgreSQL central β”‚ Gitea β”‚ Orchestrator β”‚ Infisical β”‚ +β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ + β”‚ β”‚ β”‚ + β–Ό β–Ό β–Ό +β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” +β”‚ DECK β”‚ β”‚ CORP β”‚ β”‚ HST β”‚ +β”‚ 72.62.1.113 β”‚ β”‚ 92.112.181.188 β”‚ β”‚ 72.62.2.84 β”‚ +β”‚ β”‚ β”‚ β”‚ β”‚ β”‚ +β”‚ CLARA, ALFRED β”‚ β”‚ MARGARET, JARED β”‚ β”‚ 973 tags β”‚ +β”‚ Servidor β”‚ β”‚ MASON, FELDMAN β”‚ β”‚ API pΓΊblica β”‚ +β”‚ Personal β”‚ β”‚ Empresarial β”‚ β”‚ β”‚ +β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ + β”‚ β”‚ + β””β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ + β–Ό +β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” +β”‚ Cloudflare R2 (5 buckets) β”‚ +β”‚ architect β”‚ deck β”‚ corp β”‚ hst β”‚ locker β”‚ +β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ +``` + +--- + +## Flujo de Datos Principal + +``` +PACKET (mΓ³vil) + ↓ +CLARA (DECK) / MARGARET (CORP) ← Ingesta inmutable + ↓ +ALFRED / JARED ← Flujos predefinidos + ↓ +MASON ← Enriquecimiento (24h) + ↓ +FELDMAN ← ConsolidaciΓ³n blockchain + ↓ +SENTINEL ← AuditorΓ­a (planificado) +``` + +--- + +## Índice de DocumentaciΓ³n + +### 00_VISION +- [FilosofΓ­a](00_VISION/filosofia.md) - 10 principios fundacionales +- [Glosario](00_VISION/glosario.md) - TΓ©rminos tΓ©cnicos A-Z + +### 01_ARQUITECTURA +- [Overview](01_ARQUITECTURA/overview.md) - Vista general consolidada +- [Servidores](01_ARQUITECTURA/servidores.md) - ARCHITECT, DECK, CORP, HST + +### 02_MODELO_DATOS +- [Entidades](02_MODELO_DATOS/entidades.md) - HST, ITM, PLY, LOC, FLG +- [Planos](02_MODELO_DATOS/planos.md) - T0 (ITM), MST, BCK + +### 03_COMPONENTES +- [CLARA/MARGARET](03_COMPONENTES/agentes/clara-margaret.md) - Ingesta +- [FELDMAN](03_COMPONENTES/agentes/feldman.md) - ConsolidaciΓ³n +- [GRACE](03_COMPONENTES/servicios/grace.md) - IA cognitiva + +### 04_SEGURIDAD +- [Modelo de Amenazas](04_SEGURIDAD/modelo-amenazas.md) - Riesgos +- [Secretos](04_SEGURIDAD/secretos.md) - GestiΓ³n credenciales + +### 05_OPERACIONES +- [Infraestructura](05_OPERACIONES/infraestructura.md) - Servidores +- [Backup/Recovery](05_OPERACIONES/backup-recovery.md) - DR plan + +### 06_INTEGRACIONES +- [GPU Services](06_INTEGRACIONES/gpu-services.md) - RunPod + +### 99_ANEXOS +- [Inventario Repos](99_ANEXOS/inventario-repos.md) - 24 repos + +--- + +## Estado Actual + +| Componente | Estado | Notas | +|------------|--------|-------| +| CLARA | Operativo | DECK:5051 | +| MARGARET | Operativo | CORP:5051 | +| ALFRED | Operativo | DECK:5052 | +| JARED | Operativo | CORP:5052 | +| MASON | Operativo | CORP:5053 | +| FELDMAN | Operativo | CORP:5054 | +| HST | Operativo | 973 tags | +| SENTINEL | Planificado | Sin implementar | +| GRACE | Bloqueado | RunPod no inicia | +| NOTARIO | Planificado | Sin implementar | + +--- + +## GeneraciΓ³n + +DocumentaciΓ³n generada mediante proceso de auditorΓ­a colaborativa: +- 3 auditores especializados (Arquitectura, Datos, Seguridad) +- Cross-review y resoluciΓ³n de conflictos +- SΓ­ntesis consolidada + +**Fecha generaciΓ³n:** 2024-12-24