feat(ente-zero): enchufa el handshake server al Init real

ente-zero (PID 1 del fractal arje) ahora levanta el server de
brahman-handshake junto al ente-bus existente, escuchando en
\$BRAHMAN_INIT_SOCKET (default \$XDG_RUNTIME_DIR/brahman-init.sock).
Es un canal paralelo dedicado a módulos brahman-conscientes que se
presentan con una Card y declaran flujos tipados.

Cambios:

- crates/core/brahman-handshake/src/transport.rs: helper nuevo con
  resolución XDG_RUNTIME_DIR → TMPDIR, override por var de entorno
  BRAHMAN_INIT_SOCKET. Test unitario para el override.
- crates/core/brahman-handshake/Cargo.toml: example "probe" + dev-dep
  anyhow. Probe sirve como herramienta de diagnóstico para conectar
  contra cualquier server vivo.
- crates/core/brahman-handshake/examples/probe.rs: cliente mínimo que
  hace Hello → Ping → Farewell e imprime el HelloAck recibido.
- crates/core/ente-zero/Cargo.toml: dependencias brahman-handshake
  + brahman-broker.
- crates/core/ente-zero/src/main.rs: en primordial_loop, tras spawn
  del ente-bus, crea Arc<Mutex<Broker>> compartido y llama
  Server::bind. Si el bind falla (FS no escribible, socket en uso),
  loggea y degrada a "modo bus-only" — la doctrina PID 1 no rompe por
  subsistemas opcionales (mismo patrón que uevents).

Validación end-to-end manual:
  $ BRAHMAN_INIT_SOCKET=/tmp/e2e.sock ./target/debug/ente-zero &
  $ BRAHMAN_INIT_SOCKET=/tmp/e2e.sock cargo run --example probe
    HelloAck: session=01KR41Q8... server=0.1.0 protocol=0.1.0 init_attached=true
    Pong: ts=1778252489714ms
    Farewell OK

Tests: 27/27 (broker 11 + card 8 + handshake codec+transport 2 + integ 6).
cargo check --workspace: 0 errores.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
Sergio
2026-05-08 15:02:29 +00:00
parent 07d77a335f
commit df9d10cc52
7 changed files with 147 additions and 0 deletions
+31
View File
@@ -138,6 +138,37 @@ async fn primordial_loop(
let bus_path = bus::spawn_bus(bus_sock, graph_tx.clone())?;
ente_soma::set_bus_sock(bus_path.to_string_lossy().into_owned());
// Brahman protocol: handshake socket + broker compartido.
//
// Es un canal paralelo al ente-bus, dedicado a módulos "brahman
// conscientes" que se presentan con una Card y declaran flujos
// tipados. Si el bind falla (socket en uso, FS no escribible),
// degradamos a "modo bus-only" — la doctrina de PID 1 no rompe
// por subsistemas opcionales.
let brahman_broker = std::sync::Arc::new(tokio::sync::Mutex::new(
brahman_broker::Broker::new(brahman_broker::BrokerConfig::default()),
));
let brahman_sock = brahman_handshake::transport::default_socket_path();
match brahman_handshake::server::Server::bind(
&brahman_sock,
brahman_handshake::server::ServerConfig {
init_attached: true,
broker: Some(brahman_broker.clone()),
},
) {
Ok(server) => {
info!(socket = %brahman_sock.display(), "brahman handshake escuchando");
tokio::spawn(async move {
if let Err(e) = server.run().await {
warn!(?e, "brahman handshake server cayó");
}
});
}
Err(e) => {
warn!(?e, socket = %brahman_sock.display(), "brahman handshake deshabilitado");
}
}
let mut graph = EnteGraph::new(seed_card);
graph.instantiate_seed_dependencies(&graph_tx).await?;