Skip to content

The fastest, cheapest, most efficient open-source agent harness. Run more than 500 agents on a $10 VPS.

fix(core): keep event payloads out of the bus debug log

M3gA-Mind3578b40100a2
diff --git a/crates/openhuman-core/src/core/bus.rs b/crates/openhuman-core/src/core/bus.rs
index 7ff1eacc2f..9cbe94b1dd 100644
--- a/crates/openhuman-core/src/core/bus.rs
+++ b/crates/openhuman-core/src/core/bus.rs
@@ -175,6 +175,10 @@ pub async fn init() -> tinybus::Result<()> {
/// Registered once at startup by the channel runtime. It subscribes to every
/// domain deliberately — its whole purpose is answering "was this event ever
/// published", which a filtered subscriber cannot.
+///
+/// It logs the variant name and [`DomainEvent::log_detail`], never the event
+/// itself: payloads carry user content (a channel message, a dictated voice
+/// transcript, a committed turn), which must not reach the log at any level.
pub struct TracingSubscriber;
#[async_trait::async_trait]
@@ -184,7 +188,12 @@ impl tinybus::EventHandler<DomainEvent> for TracingSubscriber {
}
async fn handle(&self, event: &DomainEvent) {
- tracing::debug!(domain = event.domain(), "[bus] {event:?}");
+ tracing::debug!(
+ domain = event.domain(),
+ event = event.variant_name(),
+ detail = event.log_detail().as_deref(),
+ "[bus] event published"
+ );
}
}
diff --git a/crates/openhuman-core/src/core/bus_tests.rs b/crates/openhuman-core/src/core/bus_tests.rs
index fe60d74e38..f9e1fe5e5e 100644
--- a/crates/openhuman-core/src/core/bus_tests.rs
+++ b/crates/openhuman-core/src/core/bus_tests.rs
@@ -113,3 +113,82 @@ async fn isolated_bus_delivers() {
tokio::task::yield_now().await;
}
}
+
+/// The bus logger runs at `debug`, so it is on whenever a developer turns
+/// logging up. It must name each event without printing its payload: a channel
+/// message or a dictated voice transcript is user content.
+#[tokio::test]
+async fn the_bus_logger_names_events_without_their_user_content() {
+ use tinybus::EventHandler;
+
+ #[derive(Clone, Default)]
+ struct Logs(std::sync::Arc<std::sync::Mutex<Vec<u8>>>);
+
+ impl std::io::Write for Logs {
+ fn write(&mut self, bytes: &[u8]) -> std::io::Result<usize> {
+ self.0.lock().unwrap().extend_from_slice(bytes);
+ Ok(bytes.len())
+ }
+ fn flush(&mut self) -> std::io::Result<()> {
+ Ok(())
+ }
+ }
+
+ const USER_TEXT: &str = "the dictated voice request";
+ let events = [
+ DomainEvent::ConversationTurnCommitted {
+ thread_id: "thread".into(),
+ agent_id: Some("orchestrator".into()),
+ workspace: None,
+ channel: Some("telegram".into()),
+ user_text: USER_TEXT.into(),
+ assistant_text: "reply".into(),
+ tool_calls: Vec::new(),
+ workspace_dir: std::path::PathBuf::from("/workspace"),
+ },
+ DomainEvent::ChannelMessageProcessed {
+ channel: "telegram".into(),
+ message_id: "telegram_42_20".into(),
+ sender: "42".into(),
+ reply_target: "42".into(),
+ content: USER_TEXT.into(),
+ thread_ts: None,
+ response: "reply".into(),
+ provider: "agent:orchestrator".into(),
+ model: "gpt-4o".into(),
+ elapsed_ms: 1,
+ success: true,
+ workspace_dir: std::path::PathBuf::from("/workspace"),
+ },
+ ];
+
+ let logs = Logs::default();
+ let writer = logs.clone();
+ let subscriber = tracing_subscriber::fmt()
+ .with_writer(move || writer.clone())
+ .with_max_level(tracing::Level::TRACE)
+ .with_ansi(false)
+ .finish();
+ let _guard = tracing::subscriber::set_default(subscriber);
+ tracing::callsite::rebuild_interest_cache();
+
+ for event in &events {
+ TracingSubscriber.handle(event).await;
+ }
+
+ let text = String::from_utf8(logs.0.lock().unwrap().clone()).unwrap();
+ for name in ["ConversationTurnCommitted", "ChannelMessageProcessed"] {
+ assert!(
+ text.contains(name),
+ "the bus logger must still name {name}: {text}"
+ );
+ }
+ assert!(
+ !text.contains(USER_TEXT),
+ "user content reached the log: {text}"
+ );
+ assert!(
+ !text.contains("reply"),
+ "the reply is user-facing content too: {text}"
+ );
+}