Pausa: 11 crates del fractal Ente #0 con cerebro completo

PID 1 boot + bus interno autenticado + cerebro KCL/Rust:
- 6 lib crates de infra (card, bus, cas, kernel, soma, wasm, snapshot)
- ente-brain: motor de reglas O(1), observer Shannon, cristalización,
  audit hash-chain, persistencia rules.k, Prometheus /metrics
- KCL schemas card.k + rule.k como gramática autoritativa
- compat-logind D-Bus, ente-echo demo provider, ente-zero PID 1
- 22 tests OK, ~3.8k LOC Rust + ~300 LOC KCL

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
Sergio
2026-05-03 22:57:44 +00:00
parent dc9c99528d
commit d6b8f18b43
53 changed files with 7753 additions and 0 deletions
+22
View File
@@ -0,0 +1,22 @@
[package]
name = "ente-echo"
version = "0.0.1"
edition.workspace = true
license.workspace = true
publish.workspace = true
[lib]
name = "ente_echo"
path = "src/lib.rs"
[[bin]]
name = "ente-echo"
path = "src/main.rs"
[dependencies]
ente-card = { path = "../ente-card" }
ente-bus = { path = "../ente-bus" }
anyhow = { workspace = true }
tokio = { workspace = true }
tracing = { workspace = true }
tracing-subscriber = { workspace = true }
+18
View File
@@ -0,0 +1,18 @@
//! Constantes públicas del Ente echo. Lib aparte del bin para que `busctl`
//! y otros consumidores puedan importar el InterfaceId sin enlazar el binario.
use ente_card::{Capability, InterfaceId};
/// UUID estable del interface "echo". Genera nuevo por sed si forkeas.
pub const ECHO_IFACE: InterfaceId = InterfaceId([
0xec, 0x40, 0xa1, 0x00, 0x00, 0x00, 0x00, 0x01,
0x80, 0x00, 0xde, 0xad, 0xbe, 0xef, 0xca, 0xfe,
]);
pub const ECHO_VERSION: u16 = 1;
pub fn echo_capability() -> Capability {
Capability::Endpoint {
interface: ECHO_IFACE,
version: ECHO_VERSION,
}
}
+46
View File
@@ -0,0 +1,46 @@
//! ente-echo: Ente proveedor mínimo. Anuncia Capability::Endpoint(ECHO) y
//! responde a invokes echando el blob recibido. Vehículo para validar el
//! forwarding bus → proveedor → bus → originator.
use ente_bus::{BusResponse, BusServer, InvokeHandler};
use ente_card::Capability;
use ente_echo::{echo_capability, ECHO_IFACE, ECHO_VERSION};
use tracing::{info, warn};
use tracing_subscriber::EnvFilter;
struct EchoHandler;
impl InvokeHandler for EchoHandler {
fn handle(&mut self, cap: Capability, blob: Vec<u8>) -> BusResponse {
match cap {
Capability::Endpoint { interface, version }
if interface == ECHO_IFACE && version == ECHO_VERSION =>
{
let preview = String::from_utf8_lossy(&blob).into_owned();
info!(text = %preview, len = blob.len(), "echo invoke");
BusResponse::Invoked { result: blob }
}
other => {
warn!(?other, "ente-echo: capacidad no soportada");
BusResponse::Error("ente-echo solo maneja ECHO_IFACE".into())
}
}
}
}
#[tokio::main(flavor = "current_thread")]
async fn main() -> anyhow::Result<()> {
let filter = EnvFilter::try_from_default_env()
.unwrap_or_else(|_| EnvFilter::new("ente_echo=info"));
tracing_subscriber::fmt().with_env_filter(filter).with_target(true).init();
info!("ente-echo arrancando");
let mut server = BusServer::from_env().await?;
server.announce(vec![echo_capability()]).await?;
info!("Announce OK, sirviendo invokes");
if let Err(e) = server.serve(EchoHandler).await {
warn!(?e, "serve terminó");
}
Ok(())
}