Skip to content

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

fix(mcp): file a supervisor notification under its own workspace, never drop it\n\nCodeRabbit was right that the previous commit's drop was the wrong half of the\ntrade. `NotificationBridgeSubscriber` is registered once, from\n`bootstrap_core_runtime`'s per-`DomainGroup` first-time set, with the workspace\nthat booted — and the MCP supervisor ticks every workspace the process has\nopened. Comparing the event against that binding fixes the case where the\nbinding is the active workspace and breaks the case where it is the stale one:\nafter a switch, the workspace the user is actually in would get no unavailable,\nreconnected or parked notification at all. That is worse than the bug it was\nmeant to fix.\n\nNeither answer works while the store is addressed by the subscriber, so it is\naddressed by the event instead. `store_target` redirects\n`Config::workspace_dir` — the only field `store::with_connection` reads — to\nthe workspace the event names, and nothing is dropped. One account's outage no\nlonger lands in another's inbox, the active workspace is never silenced, and\nthe binding's freshness stops being load-bearing.\n\nBroadcast is deliberately unchanged: `NOTIFICATION_BUS` is process-wide and\nalways has been, so this commit does not narrow what a connected client sees.\n\n`an_outage_is_filed_under_its_own_workspace_not_the_bridge_s` is the A-to-B\nregression test the review asked for, driven through `handle` over two real\ntemp workspaces: B's outage lands in B's store, A's store stays empty, and A's\nown outage still works. The `store_target` unit tests cover all five variants\nplus the process-wide events, which keep this bridge's store.\n\nClaude-Session: https://claude.ai/code/session_01933KF1SGNrJtQ9RhoDxY9i\n

Shanud0dd1d142db9
diff --git a/docs/TEST-COVERAGE-MATRIX.md b/docs/TEST-COVERAGE-MATRIX.md
index 8e80d10a54..2f7856cd21 100644
--- a/docs/TEST-COVERAGE-MATRIX.md
+++ b/docs/TEST-COVERAGE-MATRIX.md
@@ -485,7 +485,7 @@ End-to-end coverage of the agent harness via the web-chat RPC surface against an
| 11.1.13 | MCP HTTP-remote auth (token / Bearer / OAuth) + redirect resolution | RU/VU | `src/openhuman/mcp/registry/connections.rs` (`build_http_auth*`, `resolve_final_url`), `src/openhuman/mcp/registry/oauth.rs` (PKCE/token/bundle/callback port), `app/src/components/channels/mcp/ConnectAuthModal.test.tsx` (#3495) | ✅ | Bearer/raw scheme + custom headers; redirect-final-URL resolved before auth; OAuth dynamic client registration + PKCE + refresh; tokens MERGED into stored env; credentials stored encrypted locally, never sent to backend |
| 11.1.14 | MCP "Help & configure" assistant | VU/RU | `app/src/components/channels/mcp/ConfigAssistantPanel.test.tsx`, `app/src/components/channels/mcp/ConfigHelpModal.test.tsx`, `src/openhuman/mcp/registry/ops.rs` (`invoke_config_assist_agent`) (#3495) | ✅ | Server-specific prompt offered as a one-click "Get step-by-step setup help" action (on-demand, no longer auto-run on open — #4272), running an agentic turn scoped to web_search_tool/web_fetch/curl only; markdown-rendered reply; per-MCP chat persisted while on the detail page |
| 11.1.15 | Agent uses connected MCP servers in chat | RU | `src/openhuman/agent/registry/agents/loader.rs` (`orchestrator_subagents_include_mcp_agent`, `mcp_agent_drives_connected_servers_without_install_or_shell`, `planner_has_readonly_mcp_discovery_not_execute`), `src/openhuman/agent/registry/agents/orchestrator/prompt.rs` (`connected_mcp_block_*`), `src/openhuman/agent/harness/session/turn_tests.rs` (`mcp_announcement_fires_once_for_new_server`), `src/openhuman/mcp/registry/{tools,connections}.rs` (#3495) | ✅ | `use_mcp_server` delegate → `mcp_agent` worker (discover→list→call); `mcp_registry_list_tools` read-only discovery; orchestrator `## Connected MCP Servers` prompt block + mid-session connect announcement on the user turn; planner read-only MCP discovery (no `tool_call`) |
-| 11.1.16 | MCP supervisor observability (Event Log + notifications) | RU | `src/openhuman/mcp/registry/supervisor_events_tests.rs`, `src/core/events_tests.rs` (`mcp_supervisor_events_*`, `mcp_lifecycle_events_*`), `src/openhuman/desktop/notifications/bus_tests_2_tests.rs` (`mcp_*`, `*_workspace_*`), `app/src/components/settings/panels/__tests__/EventLogPanel.test.tsx` (detail line + filter), `vendor/tinymcp/crates/tinymcp/src/registry/supervisor/test.rs` ("The report" section) (#5931) | ✅ | `tinymcp::Supervisor::tick` returns a `TickReport`; the host maps it to `McpServer{ProbeTimedOut,TransportDropped,Reconnected,ReconnectFailed,Parked}` domain events (Event Log, `mcp_client` domain, server name in the agent column, failure reason via `DomainEvent::log_detail`) and the notification bridge notifies only on the first failed reconnect of an episode, on recovery after failures, and on a parked server — and only for its own workspace, since one process supervises every workspace it has opened |
+| 11.1.16 | MCP supervisor observability (Event Log + notifications) | RU | `src/openhuman/mcp/registry/supervisor_events_tests.rs`, `src/core/events_tests.rs` (`mcp_supervisor_events_*`, `mcp_lifecycle_events_*`), `src/openhuman/desktop/notifications/bus_tests_2_tests.rs` (`mcp_*`, `*_workspace*`, `an_outage_is_filed_under_its_own_workspace_not_the_bridge_s`), `app/src/components/settings/panels/__tests__/EventLogPanel.test.tsx` (detail line + filter), `vendor/tinymcp/crates/tinymcp/src/registry/supervisor/test.rs` ("The report" section) (#5931) | ✅ | `tinymcp::Supervisor::tick` returns a `TickReport`; the host maps it to `McpServer{ProbeTimedOut,TransportDropped,Reconnected,ReconnectFailed,Parked}` domain events (Event Log, `mcp_client` domain, server name in the agent column, failure reason via `DomainEvent::log_detail`) and the notification bridge notifies only on the first failed reconnect of an episode, on recovery after failures, and on a parked server — filing each under the workspace the event names, since one process supervises every workspace it has opened and the bridge's own binding may be the stale half after a switch |
<!-- 11.1.9 Vault Markdown Writes — removed: Knowledge Vaults dropped (vault domain + VaultPanel deleted). -->
diff --git a/src/core/events.rs b/src/core/events.rs
index efbd832a40..22456f2c99 100644
--- a/src/core/events.rs
+++ b/src/core/events.rs
@@ -1126,11 +1126,11 @@ pub enum DomainEvent {
///
/// One process supervises every workspace it has opened over its life
/// (`mcp::host::all_hosts`), and a workspace switch leaves the old
- /// host open and still supervised. A subscriber that persists or
- /// shows one of these must therefore reject an event whose
- /// `workspace_dir` is not its own binding — otherwise a switched-away
- /// account's outage is stored in, and announced from, the current
- /// workspace.
+ /// host open and still supervised. A subscriber that persists one of
+ /// these must therefore address the store by *this* field rather than
+ /// by its own workspace binding: the two disagree after a switch, in
+ /// whichever direction, and using the binding files one account's
+ /// outage under another's.
workspace_dir: std::path::PathBuf,
},
/// The supervisor ended an MCP server's session because its liveness
diff --git a/src/openhuman/desktop/notifications/bus.rs b/src/openhuman/desktop/notifications/bus.rs
index e36a051cf7..c87791ec99 100644
--- a/src/openhuman/desktop/notifications/bus.rs
+++ b/src/openhuman/desktop/notifications/bus.rs
@@ -10,6 +10,7 @@
//! as `core_notification` / `core:notification` Socket.IO messages.
use once_cell::sync::Lazy;
+use std::borrow::Cow;
use std::time::{SystemTime, UNIX_EPOCH};
use tokio::sync::broadcast;
@@ -69,34 +70,42 @@ impl NotificationBridgeSubscriber {
}
}
- /// Whether a workspace-bound event belongs to the workspace this bridge
- /// was registered for.
+ /// The workspace store a notification belongs in.
///
- /// The bridge is registered once, with the workspace that booted, but the
- /// MCP reconnect supervisor ticks *every* workspace the process has opened
- /// and a workspace switch leaves the old one open and still supervised.
- /// Without this check, switching accounts would announce — and persist
- /// into the current workspace's store — an outage belonging to the account
- /// the user has left (#5931).
+ /// Normally this bridge's own: it is registered once, with the workspace
+ /// that booted, and every event it handled before #5931 is process-wide.
///
- /// An event that names no workspace is not workspace-bound and passes, as
- /// every event this bridge handled before #5931 does. So does everything
- /// when `config` is `None`, which is unit tests only — see the field.
- fn is_for_this_workspace(&self, event: &DomainEvent) -> bool {
- let (Some(event_workspace), Some(config)) = (workspace_of(event), self.config.as_ref())
- else {
- return true;
- };
- if event_workspace == config.workspace_dir.as_path() {
- return true;
+ /// The MCP supervisor variants are the exception. One process supervises
+ /// every workspace it has opened (`mcp::host::all_hosts`), and a workspace
+ /// switch leaves the old one open and still supervised, so a supervisor
+ /// event can belong to a workspace that is not this bridge's — including
+ /// the *active* one, once the boot binding is the stale half of the pair.
+ /// Neither answer to that is right on its own: filing it under this
+ /// bridge's workspace puts one account's outage in another's inbox, and
+ /// dropping it silences the workspace the user is actually in. So the
+ /// event says where it belongs and nothing is dropped — the binding's
+ /// freshness stops mattering.
+ ///
+ /// Only `workspace_dir` is redirected because it is the only field the
+ /// notification store reads: `store::with_connection` opens
+ /// `<workspace_dir>/notifications/notifications.db` and looks at nothing
+ /// else. Broadcast is unaffected — `NOTIFICATION_BUS` is process-wide and
+ /// always has been.
+ fn store_target<'a>(&self, config: &'a Config, event: &DomainEvent) -> Cow<'a, Config> {
+ match workspace_of(event) {
+ Some(event_workspace) if event_workspace != config.workspace_dir.as_path() => {
+ log::debug!(
+ "{LOG_PREFIX} filing {} under its own workspace event_ws={} self_ws={}",
+ event.variant_name(),
+ event_workspace.display(),
+ config.workspace_dir.display()
+ );
+ let mut redirected = config.clone();
+ redirected.workspace_dir = event_workspace.to_path_buf();
+ Cow::Owned(redirected)
+ }
+ _ => Cow::Borrowed(config),
}
- log::debug!(
- "{LOG_PREFIX} dropping stale-workspace {} event_ws={} self_ws={}",
- event.variant_name(),
- event_workspace.display(),
- config.workspace_dir.display()
- );
- false
}
}
@@ -332,11 +341,6 @@ impl EventHandler<DomainEvent> for NotificationBridgeSubscriber {
// correctness boundary.
async fn handle(&self, event: &DomainEvent) {
- // A workspace-bound event from a workspace that is not this bridge's
- // is not this bridge's to announce or store (#5931).
- if !self.is_for_this_workspace(event) {
- return;
- }
if let Some(notification) = event_to_notification(event) {
// #3805: persist BEFORE broadcasting so the event is durable even
// when no client is currently subscribed (app closed / minimised /
@@ -344,7 +348,10 @@ impl EventHandler<DomainEvent> for NotificationBridgeSubscriber {
// receivers and the notification is lost forever. Best-effort: a
// store failure must not suppress the live broadcast.
if let Some(config) = &self.config {
- match super::store::insert_core_notification(config, &notification) {
+ // A workspace-bound event is stored in ITS OWN workspace, not
+ // whichever one this bridge was registered with (#5931).
+ let config = self.store_target(config, event);
+ match super::store::insert_core_notification(&config, &notification) {
Ok(true) => log::debug!(
"{LOG_PREFIX} persisted core notification id={}",
notification.id
diff --git a/src/openhuman/desktop/notifications/bus_tests_2_tests.rs b/src/openhuman/desktop/notifications/bus_tests_2_tests.rs
index 792c24a70c..4d5009fd59 100644
--- a/src/openhuman/desktop/notifications/bus_tests_2_tests.rs
+++ b/src/openhuman/desktop/notifications/bus_tests_2_tests.rs
@@ -293,17 +293,23 @@ fn mcp_probe_timeouts_and_transport_drops_are_event_log_only() {
assert!(event_to_notification(&dropped).is_none());
}
-// ── Workspace scoping (#5931) ───────────────────────────────────────────────
+// ── Workspace routing (#5931) ───────────────────────────────────────────────
//
// One process supervises every workspace it has opened, and this bridge is
-// registered once with the workspace that booted. A supervisor event from a
-// workspace the user has switched away from must not be announced from — or
-// persisted into — the current one.
+// registered once with the workspace that booted. A supervisor event is
+// therefore stored under the workspace it names — not this bridge's, which
+// would file one account's outage in another's inbox, and not nowhere, which
+// would silence the workspace the user is actually in once the boot binding
+// is the stale one.
fn bridge_for(workspace: &std::path::Path) -> NotificationBridgeSubscriber {
+ NotificationBridgeSubscriber::new(config_for(workspace))
+}
+
+fn config_for(workspace: &std::path::Path) -> crate::openhuman::config::Config {
let mut config = crate::openhuman::config::Config::default();
config.workspace_dir = workspace.to_path_buf();
- NotificationBridgeSubscriber::new(config)
+ config
}
fn parked_in(workspace: &std::path::Path) -> DomainEvent {
@@ -316,24 +322,30 @@ fn parked_in(workspace: &std::path::Path) -> DomainEvent {
}
#[test]
-fn a_supervisor_event_from_this_workspace_is_this_bridge_s() {
+fn an_event_from_this_workspace_uses_this_bridge_s_own_store() {
let workspace = std::path::Path::new("/tmp/openhuman-ws-a");
- assert!(bridge_for(workspace).is_for_this_workspace(&parked_in(workspace)));
+ let config = config_for(workspace);
+ let target = bridge_for(workspace).store_target(&config, &parked_in(workspace));
+ assert_eq!(target.workspace_dir, workspace);
}
#[test]
-fn a_supervisor_event_from_a_switched_away_workspace_is_dropped() {
- let bridge = bridge_for(std::path::Path::new("/tmp/openhuman-ws-a"));
+fn an_event_from_another_workspace_is_filed_under_that_workspace() {
+ let own = std::path::Path::new("/tmp/openhuman-ws-a");
let other = std::path::Path::new("/tmp/openhuman-ws-b");
- assert!(!bridge.is_for_this_workspace(&parked_in(other)));
- // The pure translator would still have produced one — the drop is the
- // bridge's decision, not the translator's.
- assert!(event_to_notification(&parked_in(other)).is_some());
+ let config = config_for(own);
+ let target = bridge_for(own).store_target(&config, &parked_in(other));
+ assert_eq!(
+ target.workspace_dir, other,
+ "the event's workspace decides the store, not the bridge's binding"
+ );
}
#[test]
-fn every_supervisor_variant_is_scoped_not_only_the_notifying_ones() {
- let bridge = bridge_for(std::path::Path::new("/tmp/openhuman-ws-a"));
+fn every_supervisor_variant_is_routed_not_only_the_notifying_ones() {
+ let own = std::path::Path::new("/tmp/openhuman-ws-a");
+ let config = config_for(own);
+ let bridge = bridge_for(own);
let other = mcp_workspace();
let foreign = [
DomainEvent::McpServerProbeTimedOut {
@@ -371,65 +383,68 @@ fn every_supervisor_variant_is_scoped_not_only_the_notifying_ones() {
parked_in(&other),
];
for event in &foreign {
- assert!(
- !bridge.is_for_this_workspace(event),
- "{} should be scoped out",
+ assert_eq!(
+ bridge.store_target(&config, event).workspace_dir,
+ other,
+ "{} should be routed to its own workspace",
event.variant_name()
);
}
}
#[test]
-fn an_event_that_names_no_workspace_is_never_scoped_out() {
+fn an_event_that_names_no_workspace_uses_this_bridge_s_store() {
// Every variant this bridge handled before #5931 — a cron job, a webhook,
- // a rejected API key — is process-wide and must keep reaching it.
- let bridge = bridge_for(std::path::Path::new("/tmp/openhuman-ws-a"));
- assert!(
- bridge.is_for_this_workspace(&DomainEvent::CronJobCompleted {
+ // a rejected API key — is process-wide and keeps this bridge's store.
+ let own = std::path::Path::new("/tmp/openhuman-ws-a");
+ let config = config_for(own);
+ let target = bridge_for(own).store_target(
+ &config,
+ &DomainEvent::CronJobCompleted {
job_id: "job-1".into(),
success: true,
output: "done".into(),
- })
+ },
);
+ assert_eq!(target.workspace_dir, own);
}
-#[test]
-fn a_bridge_with_no_config_scopes_nothing_out() {
- // `config: None` is the unit-test-only shape; with no workspace binding
- // there is nothing to compare against, so nothing is dropped.
- let bridge = NotificationBridgeSubscriber::default();
- assert!(bridge.is_for_this_workspace(&parked_in(&mcp_workspace())));
-}
-
-/// End to end through `handle`: a foreign workspace's outage is neither
-/// persisted into this workspace's store nor broadcast, while this
-/// workspace's own is.
-///
-/// Asserted on the store rather than on `NOTIFICATION_BUS`: that broadcast
-/// channel is a process-wide static every test in this binary publishes to,
-/// so a receiver here would also see other tests' notifications.
+/// End to end through `handle`, across a workspace switch: the bridge is bound
+/// to A, the user has moved to B, and B's supervisor is what reports. B's
+/// outage must reach B's store — not A's, and not nowhere.
#[tokio::test]
-async fn a_switched_away_workspace_s_outage_is_neither_stored_nor_announced() {
+async fn an_outage_is_filed_under_its_own_workspace_not_the_bridge_s() {
use crate::openhuman::desktop::notifications::store;
use tempfile::TempDir;
- let dir = TempDir::new().unwrap();
- let mut config = crate::openhuman::config::Config::default();
- config.workspace_dir = dir.path().to_path_buf();
- let bridge = NotificationBridgeSubscriber::new(config.clone());
+ let booted = TempDir::new().unwrap();
+ let switched_to = TempDir::new().unwrap();
+ let booted_config = config_for(booted.path());
+ let switched_config = config_for(switched_to.path());
+ let bridge = NotificationBridgeSubscriber::new(booted_config.clone());
+
+ bridge.handle(&parked_in(switched_to.path())).await;
- bridge
- .handle(&parked_in(std::path::Path::new("/tmp/openhuman-ws-b")))
- .await;
+ let landed = store::list_core_notifications(&switched_config, true, 50).unwrap();
+ assert_eq!(
+ landed.len(),
+ 1,
+ "the active workspace's outage must not be dropped"
+ );
+ assert!(landed[0].id.starts_with("mcp-parked:srv-1:"));
assert!(
- store::list_core_notifications(&config, true, 50)
+ store::list_core_notifications(&booted_config, true, 50)
.unwrap()
.is_empty(),
- "a foreign workspace's parked server must not land in this store"
+ "and must not land in the workspace the bridge happens to be bound to"
);
- bridge.handle(&parked_in(dir.path())).await;
- let items = store::list_core_notifications(&config, true, 50).unwrap();
- assert_eq!(items.len(), 1, "this workspace's own outage still notifies");
- assert!(items[0].id.starts_with("mcp-parked:srv-1:"));
+ // The bridge's own workspace still works the way it always did.
+ bridge.handle(&parked_in(booted.path())).await;
+ assert_eq!(
+ store::list_core_notifications(&booted_config, true, 50)
+ .unwrap()
+ .len(),
+ 1
+ );
}
diff --git a/src/openhuman/mcp/registry/README.md b/src/openhuman/mcp/registry/README.md
index 12603532c5..dd4c028277 100644
--- a/src/openhuman/mcp/registry/README.md
+++ b/src/openhuman/mcp/registry/README.md
@@ -29,7 +29,7 @@ The transport primitives themselves (stdio + HTTP MCP clients) live in the sibli
| `src/openhuman/mcp/registry/connections.rs` | Global in-process connection registry; `connect`/`disconnect`/`call_tool`/`all_status`/`all_connected_tools`; dispatches stdio vs HTTP via `ActiveClient`. |
| `src/openhuman/mcp/registry/boot.rs` | `spawn_installed_servers` — boot-time connect of all installs; per-server failures logged, never fatal. |
| `src/openhuman/mcp/registry/mod.rs` (`supervisor`) | Background reconnect loop (#3312): every 60s drives `tinymcp::Supervisor::tick` for every open workspace host — probes each connected transport and reconnects dropped / never-connected enabled servers with per-server exponential backoff (the cycle itself lives in `tinymcp`). Missed ticks are delayed, not burst. Hands each tick's `TickReport` to `supervisor_events`. |
-| `src/openhuman/mcp/registry/supervisor_events.rs` | Translates a `tinymcp::TickReport` into this domain's events (#5931): `McpServerProbeTimedOut`, `McpServerTransportDropped`, `McpServerReconnected`, `McpServerReconnectFailed`, `McpServerParked`. Every event is stamped with the workspace whose host was ticked — one process supervises every workspace it has opened, so the notification bridge drops one that is not its own. The developer Event Log streams them (with a one-line `DomainEvent::log_detail` summary, since the envelope carries no payload); the notification bridge turns stays-down / restored / parked into user notifications. An answered probe is deliberately not an event. |
+| `src/openhuman/mcp/registry/supervisor_events.rs` | Translates a `tinymcp::TickReport` into this domain's events (#5931): `McpServerProbeTimedOut`, `McpServerTransportDropped`, `McpServerReconnected`, `McpServerReconnectFailed`, `McpServerParked`. Every event is stamped with the workspace whose host was ticked — one process supervises every workspace it has opened, so the notification bridge files one under the workspace it names rather than under whichever one the bridge was registered with. The developer Event Log streams them (with a one-line `DomainEvent::log_detail` summary, since the envelope carries no payload); the notification bridge turns stays-down / restored / parked into user notifications. An answered probe is deliberately not an event. |
| `src/openhuman/mcp/registry/ops.rs` | `mcp_clients_*` RPC handler implementations + `resolve_command` + `config_assist` inference call. |
| `src/openhuman/mcp/registry/setup.rs` | Opaque secret-ref machinery (`SecretRef`, mint/fulfill/await/resolve/consume/gc) for the setup agent. |
| `src/openhuman/mcp/registry/setup_ops.rs` | `mcp_setup_*` RPC handlers (search/get/request_secret/submit_secret/test_connection/install_and_connect) + connection `pick_connection`. |
diff --git a/src/openhuman/mcp/registry/supervisor_events.rs b/src/openhuman/mcp/registry/supervisor_events.rs
index a4660063cb..20a8b99afa 100644
--- a/src/openhuman/mcp/registry/supervisor_events.rs
+++ b/src/openhuman/mcp/registry/supervisor_events.rs
@@ -12,9 +12,10 @@
//! Every event is stamped with the workspace whose host was ticked. One
//! process supervises every workspace it has opened over its life, and a
//! workspace switch leaves the old one open and still supervised, so a
-//! subscriber that persists or announces one of these — the notification
-//! bridge — needs the stamp to tell a live outage from a switched-away
-//! account's.
+//! subscriber that persists one of these — the notification bridge — needs
+//! the stamp to file it under the right workspace. It cannot infer that from
+//! its own binding: the bridge is registered once, with whichever workspace
+//! booted, which may no longer be the one the user is in.
//!
//! An answered probe is the nominal case and is deliberately *not* an event:
//! one row per server per minute would bury everything else in the log.