Honcho: route per-user chat turns onto shared bus, expose to plugins
Nightly Build / build (push) Failing after 6m13s

The honcho memory sink needs to observe every user's completed chat turns
from one subscription, keyed by ChatEvent.user_id. But each UserContext
minted its own per-user ChatEventBus, so a single global subscription saw
nothing.

- UserContext now publishes onto the shared Runtime.event_bus (the one
  Skald::subscribe_chat_events reads) instead of a fresh per-user bus.
- Expose that bus to plugins as PluginContext.chat_bus (distinct from
  system_bus, which carries only infra lifecycle events).
- plugin-honcho subscribes via ctx.chat_bus.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
2026-07-20 00:07:33 +01:00
co-authored by Claude Opus 4.8
parent bee1b4cddb
commit cb1b48a15d
4 changed files with 18 additions and 2 deletions
+6
View File
@@ -5,6 +5,7 @@ use async_trait::async_trait;
use serde_json::Value;
use tokio::sync::RwLock;
use crate::bus::ChatEventBus;
use crate::command::CommandApi;
use crate::config_api::ConfigApi;
use crate::i18n::I18nApi;
@@ -84,6 +85,11 @@ pub struct PluginContext {
pub api_provider_registry: Arc<dyn ApiProviderRegistry>,
pub location: Arc<dyn LocationUpdater>,
pub system_bus: Arc<SystemEventBus>,
/// The single shared chat-turn bus. Every user's completed turns are published
/// here, tagged with `ChatEvent.user_id`. A plugin that builds long-term memory
/// (Honcho) subscribes once and demuxes per user. Distinct from `system_bus`,
/// which carries only infra lifecycle events.
pub chat_bus: Arc<ChatEventBus>,
/// Channel-to-session resolver (blueprint §13). Lets channel plugins
/// (Telegram, mobile, …) look up an unlocked user's chat hub, approval
/// manager and event stream by user id.