refactor(infra): split de drivers pesados a subpaquetes + fix TestSSEHandler

Mueve duckdb_open, clickhouse_open, postgres_open, matrix_* y keyring_token_store
del paquete monolitico functions/infra a subpaquetes propios
(functions/infra/{duckdb,clickhouse,postgres,matrix,keyring}). El paquete infra ya
no importa los drivers (go-duckdb, clickhouse-go, pgx, mautrix, go-keyring), por lo
que las apps que solo usan funciones ligeras (process, cron, http, sqlite) dejan de
arrastrarlos. Reduccion de binarios: dag_engine 72->10MB, registry_api 70->8.7MB,
services_api 70->9MB, call_monitor 68->6.6MB, sqlite_api 70->8.9MB.

Los IDs del registry se mantienen estables (domain: infra en frontmatter). Se
preservan los build tags goolm/libolm de matrix_crypto_init.

Tambien corrige TestSSEHandler: el test leia el body con un unico Read() que con
HTTP chunked solo capturaba el primer evento; ahora usa io.ReadAll hasta EOF.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-06-02 23:48:59 +02:00
parent 4461875b18
commit e22c33ee6d
25 changed files with 55 additions and 51 deletions
+11 -3
View File
@@ -2,6 +2,7 @@ package infra
import (
"context"
"io"
"net/http"
"net/http/httptest"
"strings"
@@ -210,9 +211,16 @@ func TestSSEHandler(t *testing.T) {
}
defer resp.Body.Close()
buf := make([]byte, 4096)
n, _ := resp.Body.Read(buf)
body := string(buf[:n])
// Leer el body completo hasta EOF. El canal se cierra antes de la
// peticion, asi que el handler envia ambos eventos y termina, cerrando
// el stream. Un unico Read podria devolver solo el primer chunk
// (event: first), porque io.Reader.Read no garantiza llenar el buffer;
// io.ReadAll consume todos los chunks emitidos por el handler.
raw, err := io.ReadAll(resp.Body)
if err != nil {
t.Fatalf("read body failed: %v", err)
}
body := string(raw)
for _, want := range []string{"event: first", "event: second", "data: 1", "data: 2"} {
if !strings.Contains(body, want) {