354f992c63
Cierra el ciclo brahman-card-wit ↔ runtime: un módulo que tenga su .wit lo parsea, lo manda en Hello, y aparece como "consciente" en el broker y en brahman-status. Cambios coordinados (un solo commit por la cadena de tipos): - brahman-card::WitInterface deriva Serialize/Deserialize/Eq. - brahman-handshake::Hello lleva wit: Option<WitInterface> (#[serde(default)] para tolerar Hellos antiguos en formato JSON aunque postcard exige presencia explícita). - Server's register_session enruta a ResolvedCard::from_conscious cuando viene wit; from_agnostic cuando no. - Client::connect queda como wrapper de connect_with(path, card, wit: Option<WitInterface>) — backward-compatible. - Broker::register acepta Option<WitInterface> como tercer arg; BrokeredCard guarda el wit. 25 sitios de tests actualizados con `, None` (vía perl). - brahman-sidecar::SidecarConfig.wit + helpers SidecarConfig::with_wit y spawn_conscious(card, wit). Log attached reporta conscious=true|false. - brahman-status pretty-print con 🧠 + sección wit (package/world + imports + exports) por sesión consciente. - Example nuevo presence-conscious: parsea protocol.wit y se presenta consciente. Validación end-to-end manual: $ ente-zero & $ presence-conscious demo.conscious shared_wit/protocol.wit & $ brahman-status Sessions (1): 01K... demo.conscious 🧠 lifecycle=Daemon wit: brahman:protocol@0.1.0 / module imports: types, handshake, lifecycle exports: run Tests: 32/32 (broker 11 + card 8 + handshake codec+transport 2 + integ 7 + admin 0 + card-wit 4). Workspace: 0 errores. CHANGELOG.md actualizado. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
71 lines
2.0 KiB
Rust
71 lines
2.0 KiB
Rust
//! `presence` — módulo brahman dummy para pruebas y demos.
|
|
//!
|
|
//! Declara una Card mínima con label tomado del primer argumento (default
|
|
//! `presence-default`) y mantiene la sesión viva hasta SIGTERM/SIGINT.
|
|
//! Útil para poblar el broker con sesiones de prueba.
|
|
//!
|
|
//! Uso:
|
|
//! ```sh
|
|
//! cargo run -p brahman-sidecar --example presence -- mi-modulo
|
|
//! ```
|
|
|
|
use std::collections::BTreeSet;
|
|
use std::time::Duration;
|
|
|
|
use brahman_card::{
|
|
ulid::Ulid, Card, Flow, Flows, Lifecycle, Payload, Priority, Supervision, TypeRef,
|
|
CARD_SCHEMA_VERSION,
|
|
};
|
|
use brahman_sidecar::{spawn_with_handle, SidecarConfig};
|
|
|
|
fn main() {
|
|
tracing_subscriber::fmt()
|
|
.with_env_filter(
|
|
tracing_subscriber::EnvFilter::try_from_default_env()
|
|
.unwrap_or_else(|_| "info".into()),
|
|
)
|
|
.init();
|
|
|
|
let label = std::env::args()
|
|
.nth(1)
|
|
.unwrap_or_else(|| "presence-default".into());
|
|
|
|
let card = Card {
|
|
schema_version: CARD_SCHEMA_VERSION,
|
|
id: Ulid::new(),
|
|
label: label.clone(),
|
|
payload: Payload::Virtual,
|
|
supervision: Supervision::OneShot,
|
|
lifecycle: Lifecycle::Daemon,
|
|
priority: Priority::Normal,
|
|
provides: BTreeSet::new(),
|
|
requires: BTreeSet::new(),
|
|
flow: Flows {
|
|
input: vec![Flow {
|
|
name: "in".into(),
|
|
ty: TypeRef::Primitive {
|
|
name: "json".into(),
|
|
},
|
|
pin_to: None,
|
|
}],
|
|
output: vec![Flow {
|
|
name: "out".into(),
|
|
ty: TypeRef::Primitive {
|
|
name: "json".into(),
|
|
},
|
|
pin_to: None,
|
|
}],
|
|
},
|
|
..Default::default()
|
|
};
|
|
|
|
let _handle = spawn_with_handle(SidecarConfig {
|
|
card,
|
|
wit: None,
|
|
ping_interval: Duration::from_secs(5),
|
|
});
|
|
|
|
eprintln!("presence({label}): sidecar lanzado, durmiendo (Ctrl-C para salir)");
|
|
std::thread::park();
|
|
}
|