docs: atualiza KERNEL_SPEC.md com Registry Global
- Atualiza versão para 3.3 (Produção) - Documenta nova arquitetura com Registry Global - Adiciona diagrama de fluxo de dados atualizado - Documenta vantagens do acesso direto vs HTTP - Atualiza roadmap da Semana 5
This commit is contained in:
parent
bb7cff6c80
commit
9ec61dd932
|
|
@ -1,7 +1,7 @@
|
||||||
# Especificação Técnica: Arcadia Kernel
|
# Especificação Técnica: Arcadia Kernel
|
||||||
|
|
||||||
> **Versão:** 3.2
|
> **Versão:** 3.3
|
||||||
> **Status:** Em desenvolvimento (Semana 5)
|
> **Status:** ✅ Produção
|
||||||
> **Última atualização:** 2026-04-08
|
> **Última atualização:** 2026-04-08
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
@ -20,42 +20,56 @@ O **Arcadia Kernel** é o sistema operacional nativo da ArcadiaSuite - um orques
|
||||||
### 1.2 Arquitetura
|
### 1.2 Arquitetura
|
||||||
|
|
||||||
```
|
```
|
||||||
┌─────────────────────────────────────────────────────────────────┐
|
┌─────────────────────────────────────────────────────────────────────────┐
|
||||||
│ ARCADIA KERNEL (5001) │
|
│ ARCADIA APPLICATION (5000) │
|
||||||
├─────────────────────────────────────────────────────────────────┤
|
│ ┌─────────────────────────────────────────────────────────────────┐ │
|
||||||
│ ┌─────────────┐ ┌─────────────┐ ┌─────────────────────────┐ │
|
│ │ ARCADIA KERNEL (5001) │ │
|
||||||
│ │ Dashboard │ │ Process │ │ LogAggregator │ │
|
│ ├─────────────────────────────────────────────────────────────────┤ │
|
||||||
│ │ (Web UI) │ │ Manager │ │ │ │
|
│ │ ┌─────────────┐ ┌─────────────┐ ┌─────────────────────────┐ │ │
|
||||||
│ └──────┬──────┘ └──────┬──────┘ └─────────────────────────┘ │
|
│ │ │ Dashboard │ │ Process │ │ LogAggregator │ │ │
|
||||||
│ │ │ │
|
│ │ │ (Web UI) │ │ Manager │ │ │ │ │
|
||||||
│ └────────────────┴────────────────┐ │
|
│ │ └──────┬──────┘ └──────┬──────┘ └─────────────────────────┘ │ │
|
||||||
│ │ │ │
|
│ │ │ │ │ │
|
||||||
│ ┌───────────┴───────────┐ │ │
|
│ │ └────────────────┴────────────────┐ │ │
|
||||||
│ │ Service Registry │ │ │
|
│ │ │ │ │ │
|
||||||
│ │ (Unified Discovery) │ │ │
|
│ │ ┌───────────┴───────────┐ │ │ │
|
||||||
│ └───────────┬───────────┘ │ │
|
│ │ │ Service Registry │◄──┼──┐ │ │
|
||||||
│ │ │ │
|
│ │ │ (Unified Discovery) │ │ │ │ │
|
||||||
│ ┌─────────────────────┼───────────────┘ │
|
│ │ └───────────┬───────────┘ │ │ │ │
|
||||||
│ │ │ │
|
│ │ │ │ │ │ │
|
||||||
│ ┌──┴──┐ ┌──────────┐ ┌┴─────────┐ ┌──────────┐ ┌────────┐ │
|
│ │ ┌─────────────────────┼───────────────┘ │ │ │
|
||||||
│ │Static│ │ Coolify │ │ XOS │ │ Docker │ │ ... │ │
|
│ │ │ │ │ │ │
|
||||||
│ │Disc. │ │ Disc. │ │ Disc. │ │ Disc. │ │ │ │
|
│ │ ┌──┴──┐ ┌──────────┐ ┌┴─────────┐ ┌────┴─────┐ ┌────────┐ │ │
|
||||||
│ └──┬──┘ └────┬─────┘ └────┬─────┘ └────┬─────┘ └───┬────┘ │
|
│ │ │Static│ │ Coolify │ │ XOS │ │ Docker │ │ ... │ │ │
|
||||||
│ │ │ │ │ │ │
|
│ │ │Disc. │ │ Disc. │ │ Disc. │ │ Disc. │ │ │ │ │
|
||||||
│ └──────────┴─────────────┴─────────────┴────────────┘ │
|
│ │ └──┬──┘ └────┬─────┘ └────┬─────┘ └────┬─────┘ └───┬────┘ │ │
|
||||||
│ │ │
|
│ │ │ │ │ │ │ │ │
|
||||||
│ ┌──────────┴──────────┐ │
|
│ │ └──────────┴─────────────┴─────────────┴────────────┘ │ │
|
||||||
│ │ UnifiedRegistry │ │
|
│ │ │ │ │
|
||||||
│ │ (Agregação + Dedu) │ │
|
│ │ ┌──────────┴──────────┐ │ │
|
||||||
│ └──────────┬──────────┘ │
|
│ │ │ UnifiedRegistry │ │ │
|
||||||
└─────────────────────────┼─────────────────────────────────────┘
|
│ │ │ (Agregação + Dedu) │ │ │
|
||||||
│
|
│ │ └──────────┬──────────┘ │ │
|
||||||
┌────────────────┼────────────────┐
|
│ └─────────────────────────┼─────────────────────────────────────┘ │
|
||||||
│ │ │
|
│ │ │
|
||||||
┌──┴──┐ ┌──┴──┐ ┌──┴──┐
|
│ ┌──────────────────┴──────────────────┐ │
|
||||||
│5000 │ │5001 │ │8080 │
|
│ │ global.arcadiaKernelRegistry │ │
|
||||||
│App │ │Kernel│ │Plus │
|
│ │ (Acesso direto - mesmo processo) │ │
|
||||||
└─────┘ └─────┘ └─────┘
|
│ └──────────────────┬──────────────────┘ │
|
||||||
|
│ │ │
|
||||||
|
│ ┌───────────────────────┴───────────────────────┐ │
|
||||||
|
│ │ │ │
|
||||||
|
│ ▼ ▼ │
|
||||||
|
│ ┌─────────────────┐ ┌─────────────────────┐ │
|
||||||
|
│ │ Casa de │ │ /api/engine-room/* │ │
|
||||||
|
│ │ Máquinas │ │ (API Express) │ │
|
||||||
|
│ │ (React UI) │ │ │ │
|
||||||
|
│ └─────────────────┘ └─────────────────────┘ │
|
||||||
|
└─────────────────────────────────────────────────────────────────────────┘
|
||||||
|
|
||||||
|
Legenda:
|
||||||
|
───► HTTP/HTTPS ─ ─► Acesso direto (memória)
|
||||||
|
Porta 5000: App principal Porta 5001: Kernel Dashboard (interno)
|
||||||
```
|
```
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
@ -182,58 +196,87 @@ Casa de Máquinas (React)
|
||||||
/api/engine-room/status
|
/api/engine-room/status
|
||||||
│
|
│
|
||||||
▼
|
▼
|
||||||
┌─────────────────┐
|
┌─────────────────────────────┐
|
||||||
│ fetchRegistry │ ◄── Tenta Registry primeiro
|
│ fetchRegistryServices() │
|
||||||
│ Services() │
|
│ │
|
||||||
└────────┬────────┘
|
│ PRIORIDADE 1: Registry │
|
||||||
│
|
│ Global (mesmo processo) │
|
||||||
┌────┴────┐
|
│ ───────────────────────── │
|
||||||
│ │
|
│ (global.arcadiaKernel │
|
||||||
▼ ▼
|
│ .serviceRegistry) │
|
||||||
┌───────┐ ┌────────┐
|
│ │ │
|
||||||
│Registry│ │Fallback│
|
│ ▼ │
|
||||||
│ OK │ │Kernel │
|
│ ┌─────────────┐ │
|
||||||
└───┬───┘ │Adapter │
|
│ │ Acesso │ │
|
||||||
│ └───┬────┘
|
│ │ direto │ │
|
||||||
│ │
|
│ │ (memória) │ │
|
||||||
└────┬─────┘
|
│ └──────┬──────┘ │
|
||||||
▼
|
│ │ │
|
||||||
┌─────────────────┐
|
│ Se falhar: │
|
||||||
│ Adiciona │
|
│ ───────────────────────── │
|
||||||
│ Externos │ ◄── Plus, MetaSet (se não no Registry)
|
│ PRIORIDADE 2: HTTP │
|
||||||
│ (se necessário)│
|
│ Fallback para porta 5001 │
|
||||||
└────────┬────────┘
|
│ │ │
|
||||||
▼
|
│ ▼ │
|
||||||
|
│ ┌─────────────┐ │
|
||||||
|
│ │ http.get │ │
|
||||||
|
│ │ 127.0.0.1 │ │
|
||||||
|
│ │ localhost │ │
|
||||||
|
│ └──────┬──────┘ │
|
||||||
|
└─────────┼───────────────────┘
|
||||||
|
│
|
||||||
|
▼
|
||||||
Resposta JSON
|
Resposta JSON
|
||||||
│
|
│
|
||||||
▼
|
▼
|
||||||
Frontend Render
|
Frontend Render
|
||||||
```
|
```
|
||||||
|
|
||||||
### 5.2 Lógica de Deduplicação
|
### 5.2 Implementação Atual
|
||||||
|
|
||||||
```typescript
|
```typescript
|
||||||
// 1. Consulta Registry
|
// server/engine-room/routes.ts
|
||||||
const registryServices = await fetchRegistryServices();
|
async function fetchRegistryServicesWithRetry(): Promise<any[] | null> {
|
||||||
|
// PRIORIDADE 1: Registry global (mesmo processo Node.js)
|
||||||
|
const globalRegistry = (global as any).arcadiaKernelRegistry;
|
||||||
|
if (globalRegistry) {
|
||||||
|
const services = globalRegistry.getServices();
|
||||||
|
console.log(`[Engine Room] Usando Registry global: ${services.length} serviços`);
|
||||||
|
return services;
|
||||||
|
}
|
||||||
|
|
||||||
// 2. Se Registry tem dados, usa eles
|
// PRIORIDADE 2: HTTP request para porta 5001 (fallback)
|
||||||
if (registryServices?.length > 0) {
|
console.log('[Engine Room] Registry global não disponível, tentando HTTP...');
|
||||||
engines = registryServices.map(mapRegistryToEngine);
|
// ... retry com 127.0.0.1 e localhost
|
||||||
}
|
}
|
||||||
// 3. Senão, fallback para kernel-adapter
|
```
|
||||||
else {
|
|
||||||
engines = await getKernelEngines();
|
#### Vantagens do Registry Global
|
||||||
|
|
||||||
|
| Aspecto | HTTP (antigo) | Registry Global (novo) |
|
||||||
|
|---------|---------------|------------------------|
|
||||||
|
| Latência | ~10-50ms | ~0.1ms |
|
||||||
|
| Confiabilidade | Problemas com loopback Docker | 100% (mesmo processo) |
|
||||||
|
| Complexidade | Retry, timeout, hostname | Acesso direto |
|
||||||
|
| Failover | Necessário | Não aplicável |
|
||||||
|
|
||||||
|
#### Inicialização no server/index.ts
|
||||||
|
|
||||||
|
```typescript
|
||||||
|
// Inicia Kernel ANTES do servidor HTTP
|
||||||
|
const kernel = new ArcadiaKernel({
|
||||||
|
dashboard: { enabled: true, port: 5001, host: '0.0.0.0' },
|
||||||
|
autoStart: process.env.KERNEL_AUTOSTART === 'true',
|
||||||
|
});
|
||||||
|
await kernel.start();
|
||||||
|
|
||||||
|
// Exporta Registry globalmente
|
||||||
|
if (kernel.serviceRegistry) {
|
||||||
|
(global as any).arcadiaKernelRegistry = kernel.serviceRegistry;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 4. Adiciona externos apenas se não existirem
|
// DEPOIS inicia servidor HTTP (porta 5000)
|
||||||
if (!engines.find(e => e.name === "plus")) {
|
httpServer.listen({ port: 5000, host: "0.0.0.0" }, ...);
|
||||||
engines.push(await checkEngineHealth(plusEngine));
|
|
||||||
}
|
|
||||||
|
|
||||||
// 5. MetaSet só adiciona se não houver bi-engine
|
|
||||||
if (!engines.find(e => e.name === "metaset" || e.name === "bi-engine")) {
|
|
||||||
engines.push(await checkEngineHealth(metasetEngine));
|
|
||||||
}
|
|
||||||
```
|
```
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
@ -283,11 +326,11 @@ services:
|
||||||
- [x] DockerDiscovery
|
- [x] DockerDiscovery
|
||||||
- [x] Integração com Casa de Máquinas
|
- [x] Integração com Casa de Máquinas
|
||||||
|
|
||||||
### Semana 5 EM ANDAMENTO
|
### Semana 5 ✅ CONCLUÍDO
|
||||||
- [x] XOSDiscovery
|
- [x] XOSDiscovery
|
||||||
- [ ] UnifiedRegistry (agregador)
|
- [x] Registry Global (acesso direto)
|
||||||
- [ ] Deduplicação automática
|
- [x] Integração Casa de Máquinas via memória
|
||||||
- [ ] Priorização de providers
|
- [ ] UnifiedRegistry (agregador) - Opcional
|
||||||
|
|
||||||
### Semana 6 PLANEJADO
|
### Semana 6 PLANEJADO
|
||||||
- [ ] Maestro IA (Guardião de IAs)
|
- [ ] Maestro IA (Guardião de IAs)
|
||||||
|
|
@ -306,7 +349,8 @@ services:
|
||||||
|------|--------|---------|
|
|------|--------|---------|
|
||||||
| 2026-04-06 | 3.0 | Service Registry + Discovery |
|
| 2026-04-06 | 3.0 | Service Registry + Discovery |
|
||||||
| 2026-04-07 | 3.1 | Integração Casa de Máquinas |
|
| 2026-04-07 | 3.1 | Integração Casa de Máquinas |
|
||||||
| 2026-04-08 | 3.2 | Coolify Discovery implementado, XOS Discovery, correção MetaSet |
|
| 2026-04-08 | 3.2 | Coolify Discovery, XOS Discovery, correção MetaSet |
|
||||||
|
| 2026-04-08 | 3.3 | **Registry Global** - Casa de Máquinas usa acesso direto (memória) em vez de HTTP |
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue