The fastest, cheapest, most efficient open-source agent harness. Run more than 500 agents on a $10 VPS.
Rust agent-orchestrationai-agentsai-assistantdesktopllmlocal-firstmcppersonal-aiprivacyrustsecond-braintauri
fix(mcp): scope supervisor events to their workspace and surface their reason
Shanu5c4c0fc605a1
diff --git a/app/src/components/settings/panels/EventLogPanel.tsx b/app/src/components/settings/panels/EventLogPanel.tsxindex 193488e18f..d4347157fd 100644--- a/app/src/components/settings/panels/EventLogPanel.tsx+++ b/app/src/components/settings/panels/EventLogPanel.tsx@@ -11,6 +11,13 @@ interface EventEntry {domain: string;event: string;agent: string;+ /**+ * One already-redacted line the backend attaches to the variants whose+ * point is a failure reason (`DomainEvent::log_detail`) — an MCP transport+ * that broke and one that timed out are otherwise the same row. Empty for+ * every other event, which renders exactly as it did before (#5931).+ */+ detail: string;timestamp: string;}@@ -135,6 +142,7 @@ const EventLogPanel = () => {domain: data.domain || 'unknown',event: data.event || '',agent: data.agent || '',+ detail: data.detail || '',timestamp: data.timestamp || '',};setEntries(prev => {@@ -200,7 +208,12 @@ const EventLogPanel = () => {if (filterType && e.domain !== filterType) return false;if (filterText) {const q = filterText.toLowerCase();- if (!e.event.toLowerCase().includes(q) && !e.agent.toLowerCase().includes(q)) return false;+ if (+ !e.event.toLowerCase().includes(q) &&+ !e.agent.toLowerCase().includes(q) &&+ !e.detail.toLowerCase().includes(q)+ )+ return false;}return true;});@@ -315,6 +328,13 @@ const EventLogPanel = () => {</span>)}<span className="text-xs text-content truncate">{entry.event}</span>+ {entry.detail && (+ <span+ className="text-[10px] text-content-muted truncate min-w-0 pt-0.5"+ title={entry.detail}>+ {entry.detail}+ </span>+ )}</div>);})}diff --git a/app/src/components/settings/panels/__tests__/EventLogPanel.test.tsx b/app/src/components/settings/panels/__tests__/EventLogPanel.test.tsxindex 3a68f4fc53..83b12e05dc 100644--- a/app/src/components/settings/panels/__tests__/EventLogPanel.test.tsx+++ b/app/src/components/settings/panels/__tests__/EventLogPanel.test.tsx@@ -15,7 +15,7 @@ vi.mock('../../hooks/useSettingsNavigation', () => ({vi.mock('../../../../lib/i18n/I18nContext', () => ({ useT: () => ({ t: (k: string) => k }) }));-function mockFetchSSE(events: Array<{ domain: string; event: string }>) {+function mockFetchSSE(events: Array<{ domain: string; event: string; detail?: string }>) {const lines = events.map(e => `data:${JSON.stringify({ ...e, timestamp: '12:00:00' })}\n`);const body = lines.join('');const encoder = new TextEncoder();@@ -70,6 +70,47 @@ describe('EventLogPanel', () => {expect(screen.getByText('settings.developerMenu.eventLog.badge.agent')).toBeTruthy();});+ it('renders the backend detail line for events that carry one', async () => {+ // The envelope carries the variant name only, so an MCP transport drop+ // reaches the log with its reason in `detail` (#5931).+ mockFetchSSE([+ {+ domain: 'mcp_client',+ event: 'McpServerTransportDropped',+ detail: 'session ended: broken after 1961ms — connection reset',+ },+ { domain: 'tool', event: 'ToolExecuted' },+ ]);+ renderWithProviders(<EventLogPanel />);++ await waitFor(() => {+ expect(screen.getByText('McpServerTransportDropped')).toBeTruthy();+ });+ expect(screen.getByText('session ended: broken after 1961ms — connection reset')).toBeTruthy();+ // An event without a detail renders exactly as it did before.+ expect(screen.getByText('ToolExecuted')).toBeTruthy();+ });++ it('matches the filter text against the detail line', async () => {+ mockFetchSSE([+ { domain: 'mcp_client', event: 'McpServerTransportDropped', detail: 'connection reset' },+ { domain: 'tool', event: 'ToolExecuted' },+ ]);+ const { container } = renderWithProviders(<EventLogPanel />);++ await waitFor(() => {+ expect(screen.getByText('ToolExecuted')).toBeTruthy();+ });++ const filter = container.querySelector('input')!;+ fireEvent.change(filter, { target: { value: 'connection reset' } });++ await waitFor(() => {+ expect(screen.queryByText('ToolExecuted')).toBeNull();+ });+ expect(screen.getByText('McpServerTransportDropped')).toBeTruthy();+ });+it('shows disconnected state when fetch fails', async () => {global.fetch = vi.fn().mockRejectedValue(new Error('network'));renderWithProviders(<EventLogPanel />);diff --git a/docs/TEST-COVERAGE-MATRIX.md b/docs/TEST-COVERAGE-MATRIX.mdindex 2ed68f1c22..8e80d10a54 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_*`), `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) and the notification bridge notifies only on the first failed reconnect of an episode, on recovery after failures, and on a parked server |+| 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.9 Vault Markdown Writes — removed: Knowledge Vaults dropped (vault domain + VaultPanel deleted). -->diff --git a/gitbooks/features/integrations/mcp-and-skills.md b/gitbooks/features/integrations/mcp-and-skills.mdindex f277561f72..e8160b660c 100644--- a/gitbooks/features/integrations/mcp-and-skills.md+++ b/gitbooks/features/integrations/mcp-and-skills.md@@ -17,7 +17,7 @@ OpenHuman has a built-in **MCP registry** that browses the open MCP ecosystem an- **Two upstream registries, merged.** Discovery fans out in parallel to [Smithery.ai](https://smithery.ai) and the official [`registry.modelcontextprotocol.io`](https://registry.modelcontextprotocol.io), then merges the results: thousands of servers across both.- **Search → install → connect.** Search the catalog, view a server's details, and install it. A local install spawns the server as a stdio subprocess; deployed servers connect over HTTP.-- **Supervised connections.** Installed servers are persisted in a local SQLite store (`mcp_clients/mcp_clients.db`) with their command, args, and transport. A supervisor loop keeps enabled servers connected, probing every ~60s with per-server exponential backoff. Every probe outcome (a slow answer, a dropped transport, a reconnect that succeeded or failed) shows up in **Settings → Developer → Event Log** under the `mcp` badge, and a server that stays down, comes back after failing, or cannot start because its launcher runtime is missing raises a notification.+- **Supervised connections.** Installed servers are persisted in a local SQLite store (`mcp_clients/mcp_clients.db`) with their command, args, and transport. A supervisor loop keeps enabled servers connected, probing every ~60s with per-server exponential backoff. Each non-nominal probe outcome (a slow answer, a dropped transport, a reconnect that succeeded or failed) shows up in **Settings → Developer → Event Log** under the `mcp` badge — an answered probe does not, so a healthy server stays silent — and a server that stays down, comes back after failing, or cannot start because its launcher runtime is missing raises a notification.Once connected, an MCP server's tools are available to the agent exactly like native tools.diff --git a/src/core/bus.rs b/src/core/bus.rsindex d03e9c47fa..111092ee70 100644--- a/src/core/bus.rs+++ b/src/core/bus.rs@@ -58,7 +58,9 @@ pub const EVENTS_INTERFACE: &str = "ai.tinyhumans.openhuman.Events";/// you do. Peers exchange this through [`manifest`], so a version skew between/// the kernel and an out-of-process integration is reported at startup with/// both numbers rather than as a decode failure later.-pub const EVENTS_VERSION: Version = Version::new(1, 0, 0);+///+/// `1.1.0` added the MCP reconnect-supervisor variants (#5931).+pub const EVENTS_VERSION: Version = Version::new(1, 1, 0);/// The bus. Initialised once by [`init`]; safe to touch before that.pub static BUS: OnceBus<DomainEvent> = OnceBus::new();diff --git a/src/core/events.rs b/src/core/events.rsindex c7d66dc509..efbd832a40 100644--- a/src/core/events.rs+++ b/src/core/events.rs@@ -1122,6 +1122,16 @@ pub enum DomainEvent {consecutive_timeouts: u32,/// The streak length at which the session is torn down.teardown_after: u32,+ /// Workspace the supervised host belongs to.+ ///+ /// 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.+ workspace_dir: std::path::PathBuf,},/// The supervisor ended an MCP server's session because its liveness/// probe found the transport unusable. A reconnect follows in the same@@ -1144,6 +1154,10 @@ pub enum DomainEvent {/// The timeout streak that ended the session; zero unless `outcome`/// is `"timed_out"`.consecutive_timeouts: u32,+ /// Workspace the supervised host belongs to — see+ /// [`Self::McpServerProbeTimedOut::workspace_dir`] for the rule+ /// subscribers must apply.+ workspace_dir: std::path::PathBuf,},/// The supervisor connected an MCP server, either rebuilding a session/// it had just ended or bringing back one that had stayed down.@@ -1157,6 +1171,10 @@ pub enum DomainEvent {/// unavailable across at least one whole tick, which is what the/// notification bridge keys off to announce a recovery.after_failures: u32,+ /// Workspace the supervised host belongs to — see+ /// [`Self::McpServerProbeTimedOut::workspace_dir`] for the rule+ /// subscribers must apply.+ workspace_dir: std::path::PathBuf,},/// The supervisor failed to connect an MCP server and will retry after/// a backoff. Until a retry succeeds the server's tools are unavailable@@ -1173,6 +1191,10 @@ pub enum DomainEvent {failures: u32,/// Seconds until the next attempt.retry_in_secs: u64,+ /// Workspace the supervised host belongs to — see+ /// [`Self::McpServerProbeTimedOut::workspace_dir`] for the rule+ /// subscribers must apply.+ workspace_dir: std::path::PathBuf,},/// The supervisor gave up on an MCP server because the failure is one/// retrying cannot fix — today, the launcher runtime (`npx` / `uvx`) is@@ -1184,6 +1206,10 @@ pub enum DomainEvent {/// The failure, already rendered, including the install guidance/// `tinymcp` attaches to a missing runtime.error: String,+ /// Workspace the supervised host belongs to — see+ /// [`Self::McpServerProbeTimedOut::workspace_dir`] for the rule+ /// subscribers must apply.+ workspace_dir: std::path::PathBuf,},/// An `OPENHUMAN_APPROVAL_GATE=0` env override was observed but@@ -1670,6 +1696,87 @@ impl DomainEvent {_ => None,}}++ /// A one-line summary for the developer Event Log, for the variants whose+ /// name and [`Self::agent_hint`] are not enough to act on.+ ///+ /// The Event Log envelope (`GET /events/domain`) carries the domain, the+ /// variant name, the agent hint and a timestamp — no payload. A variant+ /// whose whole point is a failure *reason* would otherwise reach the UI+ /// with the reason discarded: a transport that broke and one that timed+ /// out are the same row (#5931). This is the opt-in escape hatch. A+ /// variant with something a reader needs returns a short rendering of it;+ /// every other variant returns `None` and its row is unchanged.+ ///+ /// What comes back is shown verbatim to anyone who can open the Event Log+ /// and lands in the log's NDJSON download, so it carries no payload+ /// content, no credentials and no un-redacted endpoint — the MCP arms+ /// pass through strings `tinymcp` has already rendered and+ /// endpoint-redacted — and no `workspace_dir`, which is on the event for+ /// subscribers to filter on, not for a shared panel to print.+ #[must_use]+ pub fn log_detail(&self) -> Option<String> {+ /// Long enough for a rendered transport error, short enough that one+ /// row cannot push the rest of the log off the screen. Counted in+ /// `char`s, so a multi-byte error cannot be split mid-character.+ const MAX_DETAIL_CHARS: usize = 160;++ fn clip(text: &str) -> String {+ let mut out: String = text.chars().take(MAX_DETAIL_CHARS).collect();+ if text.chars().nth(MAX_DETAIL_CHARS).is_some() {+ out.push('…');+ }+ out+ }++ match self {+ Self::McpServerProbeTimedOut {+ probe_timeout_secs,+ consecutive_timeouts,+ teardown_after,+ ..+ } => Some(format!(+ "no answer in {probe_timeout_secs}s; timeout {consecutive_timeouts} of \+ {teardown_after} before teardown"+ )),+ Self::McpServerTransportDropped {+ outcome,+ detail,+ elapsed_ms,+ ..+ } => {+ let mut summary = format!("session ended: {outcome}");+ if let Some(elapsed_ms) = elapsed_ms {+ summary.push_str(&format!(" after {elapsed_ms}ms"));+ }+ if let Some(detail) = detail {+ summary.push_str(" — ");+ summary.push_str(&clip(detail));+ }+ Some(summary)+ }+ Self::McpServerReconnected {+ tool_count,+ after_failures,+ ..+ } => Some(format!(+ "connected with {tool_count} tools after {after_failures} failed attempt(s)"+ )),+ Self::McpServerReconnectFailed {+ error,+ failures,+ retry_in_secs,+ ..+ } => Some(format!(+ "attempt {failures} failed, retrying in {retry_in_secs}s — {}",+ clip(error)+ )),+ Self::McpServerParked { error, .. } => {+ Some(format!("parked, not retrying — {}", clip(error)))+ }+ _ => None,+ }+ }}#[cfg(test)]diff --git a/src/core/events_tests.rs b/src/core/events_tests.rsindex 27ac86c149..d628452b2a 100644--- a/src/core/events_tests.rs+++ b/src/core/events_tests.rs@@ -1,5 +1,13 @@use super::*;+/// The workspace an MCP supervisor event is attributed to.+///+/// One process supervises every workspace it has opened, so these events name+/// theirs; nothing in these cases depends on which one it is (#5931).+fn mcp_workspace() -> std::path::PathBuf {+ std::path::PathBuf::from("/tmp/openhuman-ws")+}+#[test]fn all_variants_have_correct_domain() {let cases: Vec<(DomainEvent, &str)> = vec![@@ -511,6 +519,7 @@ fn all_variants_have_correct_domain() {probe_timeout_secs: 8,consecutive_timeouts: 1,teardown_after: 3,+ workspace_dir: mcp_workspace(),},"mcp_client",),@@ -522,6 +531,7 @@ fn all_variants_have_correct_domain() {detail: Some("connection reset".into()),elapsed_ms: Some(1961),consecutive_timeouts: 0,+ workspace_dir: mcp_workspace(),},"mcp_client",),@@ -531,6 +541,7 @@ fn all_variants_have_correct_domain() {qualified_name: "ac.inference.sh/mcp".into(),tool_count: 25,after_failures: 0,+ workspace_dir: mcp_workspace(),},"mcp_client",),@@ -541,6 +552,7 @@ fn all_variants_have_correct_domain() {error: "connection refused".into(),failures: 1,retry_in_secs: 5,+ workspace_dir: mcp_workspace(),},"mcp_client",),@@ -549,6 +561,7 @@ fn all_variants_have_correct_domain() {server_id: "srv-1".into(),qualified_name: "@scope/server".into(),error: "the `uvx` launcher is not installed".into(),+ workspace_dir: mcp_workspace(),},"mcp_client",),@@ -624,6 +637,7 @@ fn mcp_supervisor_events_name_themselves_and_hint_the_server() {probe_timeout_secs: 8,consecutive_timeouts: 1,teardown_after: 3,+ workspace_dir: mcp_workspace(),},"McpServerProbeTimedOut",),@@ -635,6 +649,7 @@ fn mcp_supervisor_events_name_themselves_and_hint_the_server() {detail: None,elapsed_ms: Some(8_000),consecutive_timeouts: 3,+ workspace_dir: mcp_workspace(),},"McpServerTransportDropped",),@@ -644,6 +659,7 @@ fn mcp_supervisor_events_name_themselves_and_hint_the_server() {qualified_name: "ac.inference.sh/mcp".into(),tool_count: 25,after_failures: 1,+ workspace_dir: mcp_workspace(),},"McpServerReconnected",),@@ -654,6 +670,7 @@ fn mcp_supervisor_events_name_themselves_and_hint_the_server() {error: "connection refused".into(),failures: 1,retry_in_secs: 5,+ workspace_dir: mcp_workspace(),},"McpServerReconnectFailed",),@@ -662,6 +679,7 @@ fn mcp_supervisor_events_name_themselves_and_hint_the_server() {server_id: "srv-1".into(),qualified_name: "ac.inference.sh/mcp".into(),error: "the `uvx` launcher is not installed".into(),+ workspace_dir: mcp_workspace(),},"McpServerParked",),@@ -704,3 +722,133 @@ fn mcp_lifecycle_events_hint_the_install_id() {);}}++/// The Event Log envelope carries the variant name, the agent hint and a+/// timestamp — no payload — so the supervisor variants attach the one line a+/// reader needs to tell a broken transport from a timed-out one (#5931).+#[test]+fn mcp_supervisor_events_summarise_themselves_for_the_event_log() {+ let cases: Vec<(DomainEvent, Vec<&str>)> = vec![+ (+ DomainEvent::McpServerProbeTimedOut {+ server_id: "srv-1".into(),+ qualified_name: "ac.inference.sh/mcp".into(),+ probe_timeout_secs: 8,+ consecutive_timeouts: 1,+ teardown_after: 3,+ workspace_dir: mcp_workspace(),+ },+ vec!["8s", "1", "3"],+ ),+ (+ DomainEvent::McpServerTransportDropped {+ server_id: "srv-1".into(),+ qualified_name: "ac.inference.sh/mcp".into(),+ outcome: "broken".into(),+ detail: Some("connection reset".into()),+ elapsed_ms: Some(1961),+ consecutive_timeouts: 0,+ workspace_dir: mcp_workspace(),+ },+ vec!["broken", "1961ms", "connection reset"],+ ),+ (+ DomainEvent::McpServerReconnected {+ server_id: "srv-1".into(),+ qualified_name: "ac.inference.sh/mcp".into(),+ tool_count: 25,+ after_failures: 2,+ workspace_dir: mcp_workspace(),+ },+ vec!["25 tools", "2 failed"],+ ),+ (+ DomainEvent::McpServerReconnectFailed {+ server_id: "srv-1".into(),+ qualified_name: "ac.inference.sh/mcp".into(),+ error: "connection refused".into(),+ failures: 1,+ retry_in_secs: 5,+ workspace_dir: mcp_workspace(),+ },+ vec!["attempt 1", "5s", "connection refused"],+ ),+ (+ DomainEvent::McpServerParked {+ server_id: "srv-1".into(),+ qualified_name: "ac.inference.sh/mcp".into(),+ error: "the `uvx` launcher is not installed".into(),+ workspace_dir: mcp_workspace(),+ },+ vec!["parked", "uvx"],+ ),+ ];++ for (event, expected) in cases {+ let detail = event+ .log_detail()+ .unwrap_or_else(|| panic!("{} should summarise itself", event.variant_name()));+ for fragment in expected {+ assert!(+ detail.contains(fragment),+ "{} detail {detail:?} is missing {fragment:?}",+ event.variant_name()+ );+ }+ assert!(+ !detail.contains("/tmp/openhuman-ws"),+ "{} must not print its workspace into a shared panel: {detail:?}",+ event.variant_name()+ );+ }+}++/// A transport drop with nothing measured still says what happened.+#[test]+fn a_missing_entry_drop_summarises_without_a_measurement() {+ let detail = DomainEvent::McpServerTransportDropped {+ server_id: "srv-1".into(),+ qualified_name: "ac.inference.sh/mcp".into(),+ outcome: "missing".into(),+ detail: None,+ elapsed_ms: None,+ consecutive_timeouts: 0,+ workspace_dir: mcp_workspace(),+ }+ .log_detail()+ .expect("a drop always summarises");+ assert_eq!(detail, "session ended: missing");+}++/// One row cannot flood the log, and truncation never splits a character.+#[test]+fn a_long_error_is_clipped_on_a_character_boundary() {+ let detail = DomainEvent::McpServerParked {+ server_id: "srv-1".into(),+ qualified_name: "ac.inference.sh/mcp".into(),+ error: "é".repeat(400),+ workspace_dir: mcp_workspace(),+ }+ .log_detail()+ .expect("a parked server always summarises");+ assert!(detail.ends_with('…'), "{detail:?}");+ assert_eq!(detail.chars().filter(|c| *c == 'é').count(), 160);+}++/// Every other variant is unchanged: no detail, so its row renders as before.+#[test]+fn events_outside_the_supervisor_have_no_event_log_detail() {+ assert!(DomainEvent::CronJobCompleted {+ job_id: "job-1".into(),+ success: true,+ output: "done".into(),+ }+ .log_detail()+ .is_none());+ assert!(DomainEvent::McpServerConnected {+ server_id: "srv-1".into(),+ tool_count: 25,+ }+ .log_detail()+ .is_none());+}diff --git a/src/core/jsonrpc.rs b/src/core/jsonrpc.rsindex 9667265dc5..e7c940a299 100644--- a/src/core/jsonrpc.rs+++ b/src/core/jsonrpc.rs@@ -1619,10 +1619,16 @@ async fn domain_events_handler(headers: axum::http::HeaderMap) -> Response {let domain = event.domain().to_string();let event_name = event.variant_name();let agent = event.agent_hint().unwrap_or("").to_string();+ // Most variants say everything in their name; the ones whose point is+ // a failure *reason* would otherwise reach the log with the reason+ // discarded, so they opt into one already-redacted line (#5931). It is+ // `null` for every other variant, which renders as no change.+ let detail = event.log_detail();let data = json!({"domain": domain,"event": event_name,"agent": agent,+ "detail": detail,"timestamp": chrono::Utc::now().format("%H:%M:%S").to_string(),});let data_str = serde_json::to_string(&data).ok()?;diff --git a/src/openhuman/desktop/notifications/bus.rs b/src/openhuman/desktop/notifications/bus.rsindex 3261a1335d..e36a051cf7 100644--- a/src/openhuman/desktop/notifications/bus.rs+++ b/src/openhuman/desktop/notifications/bus.rs@@ -68,6 +68,53 @@ impl NotificationBridgeSubscriber {config: Some(config),}}++ /// Whether a workspace-bound event belongs to the workspace this bridge+ /// was registered for.+ ///+ /// 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).+ ///+ /// 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;+ }+ log::debug!(+ "{LOG_PREFIX} dropping stale-workspace {} event_ws={} self_ws={}",+ event.variant_name(),+ event_workspace.display(),+ config.workspace_dir.display()+ );+ false+ }+}++/// The workspace an event belongs to, for the variants that name one.+///+/// `None` means the event is not bound to a workspace and any subscriber may+/// act on it. Only the MCP supervisor variants are bound today, because they+/// are the only ones this bridge handles that one process produces for more+/// than one workspace (#5931).+fn workspace_of(event: &DomainEvent) -> Option<&std::path::Path> {+ match event {+ DomainEvent::McpServerProbeTimedOut { workspace_dir, .. }+ | DomainEvent::McpServerTransportDropped { workspace_dir, .. }+ | DomainEvent::McpServerReconnected { workspace_dir, .. }+ | DomainEvent::McpServerReconnectFailed { workspace_dir, .. }+ | DomainEvent::McpServerParked { workspace_dir, .. } => Some(workspace_dir.as_path()),+ _ => None,+ }}fn now_ms() -> u64 {@@ -219,6 +266,7 @@ pub fn event_to_notification(event: &DomainEvent) -> Option<CoreNotificationEvenerror,failures,retry_in_secs,+ ..} if *failures == 1 => Some(CoreNotificationEvent {id: format!("mcp-unavailable:{}:{}", server_id, ts),category: CoreNotificationCategory::System,@@ -237,6 +285,7 @@ pub fn event_to_notification(event: &DomainEvent) -> Option<CoreNotificationEvenqualified_name,tool_count,after_failures,+ ..} if *after_failures > 0 => Some(CoreNotificationEvent {id: format!("mcp-restored:{}:{}", server_id, ts),category: CoreNotificationCategory::System,@@ -253,6 +302,7 @@ pub fn event_to_notification(event: &DomainEvent) -> Option<CoreNotificationEvenserver_id,qualified_name,error,+ ..} => Some(CoreNotificationEvent {id: format!("mcp-parked:{}:{}", server_id, ts),category: CoreNotificationCategory::System,@@ -282,6 +332,11 @@ 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 /diff --git a/src/openhuman/desktop/notifications/bus_tests_2_tests.rs b/src/openhuman/desktop/notifications/bus_tests_2_tests.rsindex 4a2ce54f63..792c24a70c 100644--- a/src/openhuman/desktop/notifications/bus_tests_2_tests.rs+++ b/src/openhuman/desktop/notifications/bus_tests_2_tests.rs@@ -174,6 +174,13 @@ fn notification_triaged_unrouted_escalate_is_silent() {// ── MCP reconnect supervisor (#5931) ────────────────────────────────────────+/// The workspace an MCP supervisor event is attributed to. The pure+/// translator ignores it — the bridge's `is_for_this_workspace` is what reads+/// it — so these cases all use the same one.+fn mcp_workspace() -> std::path::PathBuf {+ std::path::PathBuf::from("/tmp/openhuman-ws")+}+#[test]fn mcp_first_failed_reconnect_tells_the_user_tools_are_unavailable() {let ev = DomainEvent::McpServerReconnectFailed {@@ -182,6 +189,7 @@ fn mcp_first_failed_reconnect_tells_the_user_tools_are_unavailable() {error: "mcp transport failure for `https://api.inference.sh`: connection reset".into(),failures: 1,retry_in_secs: 5,+ workspace_dir: mcp_workspace(),};let n = event_to_notification(&ev).expect("the first failure of an episode notifies");assert_eq!(n.category, CoreNotificationCategory::System);@@ -203,6 +211,7 @@ fn mcp_later_failed_reconnects_stay_quiet() {error: "connection refused".into(),failures: 2,retry_in_secs: 10,+ workspace_dir: mcp_workspace(),};assert!(event_to_notification(&ev).is_none());}@@ -214,6 +223,7 @@ fn mcp_recovery_after_failures_is_announced() {qualified_name: "ac.inference.sh/mcp".into(),tool_count: 25,after_failures: 2,+ workspace_dir: mcp_workspace(),};let n = event_to_notification(&ev).expect("a server that had stayed down coming back notifies");assert_eq!(n.category, CoreNotificationCategory::System);@@ -233,6 +243,7 @@ fn mcp_rebuild_within_the_same_tick_is_not_a_notification() {qualified_name: "ac.inference.sh/mcp".into(),tool_count: 25,after_failures: 0,+ workspace_dir: mcp_workspace(),};assert!(event_to_notification(&ev).is_none());}@@ -243,6 +254,7 @@ fn mcp_parked_server_tells_the_user_how_to_recover() {server_id: "srv-1".into(),qualified_name: "@modelcontextprotocol/server-github".into(),error: "the `uvx` launcher is not installed".into(),+ workspace_dir: mcp_workspace(),};let n = event_to_notification(&ev).expect("a parked server notifies");assert_eq!(n.category, CoreNotificationCategory::System);@@ -266,6 +278,7 @@ fn mcp_probe_timeouts_and_transport_drops_are_event_log_only() {probe_timeout_secs: 8,consecutive_timeouts: 1,teardown_after: 3,+ workspace_dir: mcp_workspace(),};let dropped = DomainEvent::McpServerTransportDropped {server_id: "srv-1".into(),@@ -274,7 +287,149 @@ fn mcp_probe_timeouts_and_transport_drops_are_event_log_only() {detail: Some("connection reset".into()),elapsed_ms: Some(1961),consecutive_timeouts: 0,+ workspace_dir: mcp_workspace(),};assert!(event_to_notification(&timed_out).is_none());assert!(event_to_notification(&dropped).is_none());}++// ── Workspace scoping (#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.++fn bridge_for(workspace: &std::path::Path) -> NotificationBridgeSubscriber {+ let mut config = crate::openhuman::config::Config::default();+ config.workspace_dir = workspace.to_path_buf();+ NotificationBridgeSubscriber::new(config)+}++fn parked_in(workspace: &std::path::Path) -> DomainEvent {+ DomainEvent::McpServerParked {+ server_id: "srv-1".into(),+ qualified_name: "ac.inference.sh/mcp".into(),+ error: "the `uvx` launcher is not installed".into(),+ workspace_dir: workspace.to_path_buf(),+ }+}++#[test]+fn a_supervisor_event_from_this_workspace_is_this_bridge_s() {+ let workspace = std::path::Path::new("/tmp/openhuman-ws-a");+ assert!(bridge_for(workspace).is_for_this_workspace(&parked_in(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"));+ 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());+}++#[test]+fn every_supervisor_variant_is_scoped_not_only_the_notifying_ones() {+ let bridge = bridge_for(std::path::Path::new("/tmp/openhuman-ws-a"));+ let other = mcp_workspace();+ let foreign = [+ DomainEvent::McpServerProbeTimedOut {+ server_id: "srv-1".into(),+ qualified_name: "ac.inference.sh/mcp".into(),+ probe_timeout_secs: 8,+ consecutive_timeouts: 1,+ teardown_after: 3,+ workspace_dir: other.clone(),+ },+ DomainEvent::McpServerTransportDropped {+ server_id: "srv-1".into(),+ qualified_name: "ac.inference.sh/mcp".into(),+ outcome: "broken".into(),+ detail: None,+ elapsed_ms: None,+ consecutive_timeouts: 0,+ workspace_dir: other.clone(),+ },+ DomainEvent::McpServerReconnected {+ server_id: "srv-1".into(),+ qualified_name: "ac.inference.sh/mcp".into(),+ tool_count: 25,+ after_failures: 2,+ workspace_dir: other.clone(),+ },+ DomainEvent::McpServerReconnectFailed {+ server_id: "srv-1".into(),+ qualified_name: "ac.inference.sh/mcp".into(),+ error: "connection refused".into(),+ failures: 1,+ retry_in_secs: 5,+ workspace_dir: other.clone(),+ },+ parked_in(&other),+ ];+ for event in &foreign {+ assert!(+ !bridge.is_for_this_workspace(event),+ "{} should be scoped out",+ event.variant_name()+ );+ }+}++#[test]+fn an_event_that_names_no_workspace_is_never_scoped_out() {+ // 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 {+ job_id: "job-1".into(),+ success: true,+ output: "done".into(),+ })+ );+}++#[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.+#[tokio::test]+async fn a_switched_away_workspace_s_outage_is_neither_stored_nor_announced() {+ 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());++ bridge+ .handle(&parked_in(std::path::Path::new("/tmp/openhuman-ws-b")))+ .await;+ assert!(+ store::list_core_notifications(&config, true, 50)+ .unwrap()+ .is_empty(),+ "a foreign workspace's parked server must not land in this store"+ );++ 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:"));+}diff --git a/src/openhuman/mcp/registry/README.md b/src/openhuman/mcp/registry/README.mdindex c5b6bc028d..12603532c5 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`. The developer Event Log streams them; 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 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/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/mod.rs b/src/openhuman/mcp/registry/mod.rsindex b573bee9da..4fa1541f6e 100644--- a/src/openhuman/mcp/registry/mod.rs+++ b/src/openhuman/mcp/registry/mod.rs@@ -445,7 +445,7 @@ pub mod supervisor {// proxy it was opened with.for (workspace, service, identity, proxy) in host::all_hosts() {let supervisor = supervisors- .entry(workspace)+ .entry(workspace.clone()).or_insert_with(|| tinymcp::Supervisor::new(config.clone(), identity, proxy));let report = supervisor@@ -458,8 +458,11 @@ pub mod supervisor {.await;// What the tick observed becomes this domain's events, so a// probe outcome reaches the Event Log and a server that stays- // down reaches the user (#5931).- super::supervisor_events::publish(&report);+ // down reaches the user (#5931). The workspace goes with them:+ // this loop covers every host the process has opened, and a+ // subscriber that persists or announces one must not take a+ // switched-away workspace's outage for its own.+ super::supervisor_events::publish(&workspace, &report);}}}diff --git a/src/openhuman/mcp/registry/supervisor_events.rs b/src/openhuman/mcp/registry/supervisor_events.rsindex be1a9ab5af..a4660063cb 100644--- a/src/openhuman/mcp/registry/supervisor_events.rs+++ b/src/openhuman/mcp/registry/supervisor_events.rs@@ -9,10 +9,19 @@//! of the notification bridge (`desktop::notifications::bus`), where the//! stays-down, restored and parked cases become user notifications (#5931).//!+//! 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.+//!//! 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.//! `tinymcp` logs it at trace level, and that is enough.+use std::path::Path;+use tinymcp::{ProbeOutcome, SupervisorEvent, TickReport};use crate::core::bus::BUS;@@ -26,14 +35,21 @@ const LOG_PREFIX: &str = "[mcp]";/// Pure, so the mapping is testable without a bus. Observations this host has/// no event for — an answered probe today, and whatever `tinymcp` adds to its/// non-exhaustive report later — map to nothing.-pub fn domain_events_for(events: &[SupervisorEvent]) -> Vec<DomainEvent> {- events.iter().filter_map(domain_event_for).collect()+///+/// `workspace` is the host's workspace, stamped onto every event so a+/// subscriber can reject one that is not its own.+pub fn domain_events_for(workspace: &Path, events: &[SupervisorEvent]) -> Vec<DomainEvent> {+ events+ .iter()+ .filter_map(|event| domain_event_for(workspace, event))+ .collect()}-fn domain_event_for(event: &SupervisorEvent) -> Option<DomainEvent> {+fn domain_event_for(workspace: &Path, event: &SupervisorEvent) -> Option<DomainEvent> {let server = event.server();let server_id = server.server_id.clone();let qualified_name = server.qualified_name.clone();+ let workspace_dir = workspace.to_path_buf();match event {SupervisorEvent::ProbeAnswered { .. } => None,@@ -48,6 +64,7 @@ fn domain_event_for(event: &SupervisorEvent) -> Option<DomainEvent> {probe_timeout_secs: after.as_secs(),consecutive_timeouts: *consecutive,teardown_after: *teardown_after,+ workspace_dir,}),SupervisorEvent::TransportDropped {outcome,@@ -70,6 +87,7 @@ fn domain_event_for(event: &SupervisorEvent) -> Option<DomainEvent> {detail,elapsed_ms,consecutive_timeouts: *consecutive_timeouts,+ workspace_dir,})}SupervisorEvent::Reconnected {@@ -81,6 +99,7 @@ fn domain_event_for(event: &SupervisorEvent) -> Option<DomainEvent> {qualified_name,tool_count: u32::try_from(*tools).unwrap_or(u32::MAX),after_failures: *after_failures,+ workspace_dir,}),SupervisorEvent::ReconnectFailed {error,@@ -93,11 +112,13 @@ fn domain_event_for(event: &SupervisorEvent) -> Option<DomainEvent> {error: error.clone(),failures: *failures,retry_in_secs: retry_in.as_secs(),+ workspace_dir,}),SupervisorEvent::Parked { error, .. } => Some(DomainEvent::McpServerParked {server_id,qualified_name,error: error.clone(),+ workspace_dir,}),// `SupervisorEvent` is non-exhaustive: a report entry this host does// not know yet is logged and skipped rather than mistranslated.@@ -120,8 +141,10 @@ fn millis(duration: std::time::Duration) -> u64 {////// Returns how many were published: zero for a quiet tick. A bus that is not/// initialised drops them, as it does every other publish before startup.-pub fn publish(report: &TickReport) -> usize {- let events = domain_events_for(&report.events);+///+/// `workspace` is the host the report came from, stamped onto every event.+pub fn publish(workspace: &Path, report: &TickReport) -> usize {+ let events = domain_events_for(workspace, &report.events);let published = events.len();if published > 0 {tracing::debug!(diff --git a/src/openhuman/mcp/registry/supervisor_events_tests.rs b/src/openhuman/mcp/registry/supervisor_events_tests.rsindex 1b2bf206a8..b1e672ad1b 100644--- a/src/openhuman/mcp/registry/supervisor_events_tests.rs+++ b/src/openhuman/mcp/registry/supervisor_events_tests.rs@@ -1,3 +1,4 @@+use std::path::{Path, PathBuf};use std::time::Duration;use tinymcp::{ProbeOutcome, ServerRef, SupervisorEvent, TickReport};@@ -5,6 +6,12 @@ use tinymcp::{ProbeOutcome, ServerRef, SupervisorEvent, TickReport};use super::*;use crate::core::events::DomainEvent;+/// The workspace a tick is attributed to. One process supervises every+/// workspace it has opened, so every event has to name the one it came from.+fn workspace() -> &'static Path {+ Path::new("/tmp/openhuman-ws-a")+}+fn server() -> ServerRef {ServerRef {server_id: "srv-1".into(),@@ -16,21 +23,27 @@ fn server() -> ServerRef {#[test]fn an_answered_probe_is_not_an_event() {// One row per server per minute would bury everything else in the log.- let events = domain_events_for(&[SupervisorEvent::ProbeAnswered {- server: server(),- elapsed: Duration::from_millis(190),- }]);+ let events = domain_events_for(+ workspace(),+ &[SupervisorEvent::ProbeAnswered {+ server: server(),+ elapsed: Duration::from_millis(190),+ }],+ );assert!(events.is_empty());}#[test]fn a_kept_timeout_becomes_probe_timed_out_with_its_place_in_the_streak() {- let events = domain_events_for(&[SupervisorEvent::ProbeTimedOut {- server: server(),- after: Duration::from_secs(8),- consecutive: 1,- teardown_after: 3,- }]);+ let events = domain_events_for(+ workspace(),+ &[SupervisorEvent::ProbeTimedOut {+ server: server(),+ after: Duration::from_secs(8),+ consecutive: 1,+ teardown_after: 3,+ }],+ );match events.as_slice() {[DomainEvent::McpServerProbeTimedOut {server_id,@@ -38,6 +51,7 @@ fn a_kept_timeout_becomes_probe_timed_out_with_its_place_in_the_streak() {probe_timeout_secs,consecutive_timeouts,teardown_after,+ ..}] => {assert_eq!(server_id, "srv-1");assert_eq!(qualified_name, "ac.inference.sh/mcp");@@ -53,14 +67,18 @@ fn a_kept_timeout_becomes_probe_timed_out_with_its_place_in_the_streak() {#[test]fn a_broken_drop_carries_the_error_and_how_long_it_took_to_fail() {- let events = domain_events_for(&[SupervisorEvent::TransportDropped {- server: server(),- outcome: ProbeOutcome::Broken {- error: "mcp transport failure for `https://api.inference.sh`: connection reset".into(),- elapsed: Duration::from_millis(1961),- },- consecutive_timeouts: 0,- }]);+ let events = domain_events_for(+ workspace(),+ &[SupervisorEvent::TransportDropped {+ server: server(),+ outcome: ProbeOutcome::Broken {+ error: "mcp transport failure for `https://api.inference.sh`: connection reset"+ .into(),+ elapsed: Duration::from_millis(1961),+ },+ consecutive_timeouts: 0,+ }],+ );match events.as_slice() {[DomainEvent::McpServerTransportDropped {outcome,@@ -83,13 +101,16 @@ fn a_broken_drop_carries_the_error_and_how_long_it_took_to_fail() {#[test]fn a_timeout_drop_carries_the_window_and_the_streak_that_ended_the_session() {- let events = domain_events_for(&[SupervisorEvent::TransportDropped {- server: server(),- outcome: ProbeOutcome::TimedOut {- after: Duration::from_secs(8),- },- consecutive_timeouts: 3,- }]);+ let events = domain_events_for(+ workspace(),+ &[SupervisorEvent::TransportDropped {+ server: server(),+ outcome: ProbeOutcome::TimedOut {+ after: Duration::from_secs(8),+ },+ consecutive_timeouts: 3,+ }],+ );match events.as_slice() {[DomainEvent::McpServerTransportDropped {outcome,@@ -109,11 +130,14 @@ fn a_timeout_drop_carries_the_window_and_the_streak_that_ended_the_session() {#[test]fn a_missing_entry_drop_carries_nothing_measured() {- let events = domain_events_for(&[SupervisorEvent::TransportDropped {- server: server(),- outcome: ProbeOutcome::Missing,- consecutive_timeouts: 0,- }]);+ let events = domain_events_for(+ workspace(),+ &[SupervisorEvent::TransportDropped {+ server: server(),+ outcome: ProbeOutcome::Missing,+ consecutive_timeouts: 0,+ }],+ );match events.as_slice() {[DomainEvent::McpServerTransportDropped {outcome,@@ -131,23 +155,26 @@ fn a_missing_entry_drop_carries_nothing_measured() {#[test]fn a_reconnect_a_failure_and_a_parking_translate_in_order() {- let events = domain_events_for(&[- SupervisorEvent::Reconnected {- server: server(),- tools: 25,- after_failures: 2,- },- SupervisorEvent::ReconnectFailed {- server: server(),- error: "mcp error response: not accepting sessions".into(),- failures: 1,- retry_in: Duration::from_secs(5),- },- SupervisorEvent::Parked {- server: server(),- error: "the `npx` launcher is not installed".into(),- },- ]);+ let events = domain_events_for(+ workspace(),+ &[+ SupervisorEvent::Reconnected {+ server: server(),+ tools: 25,+ after_failures: 2,+ },+ SupervisorEvent::ReconnectFailed {+ server: server(),+ error: "mcp error response: not accepting sessions".into(),+ failures: 1,+ retry_in: Duration::from_secs(5),+ },+ SupervisorEvent::Parked {+ server: server(),+ error: "the `npx` launcher is not installed".into(),+ },+ ],+ );match events.as_slice() {[DomainEvent::McpServerReconnected {@@ -203,6 +230,100 @@ fn publish_counts_only_what_became_an_event() {},],};- assert_eq!(publish(&report), 1);- assert_eq!(publish(&TickReport::default()), 0);+ assert_eq!(publish(workspace(), &report), 1);+ assert_eq!(publish(workspace(), &TickReport::default()), 0);+}++/// Every translated event names the workspace whose host was ticked.+///+/// The supervisor walks every workspace the process has opened, so an event+/// that did not say which one it came from would let a switched-away+/// account's outage be stored in, and announced from, the current one+/// (#5931).+#[test]+fn every_event_is_stamped_with_the_workspace_it_came_from() {+ let events = domain_events_for(+ workspace(),+ &[+ SupervisorEvent::ProbeTimedOut {+ server: server(),+ after: Duration::from_secs(8),+ consecutive: 1,+ teardown_after: 3,+ },+ SupervisorEvent::TransportDropped {+ server: server(),+ outcome: ProbeOutcome::Missing,+ consecutive_timeouts: 0,+ },+ SupervisorEvent::Reconnected {+ server: server(),+ tools: 25,+ after_failures: 2,+ },+ SupervisorEvent::ReconnectFailed {+ server: server(),+ error: "connection refused".into(),+ failures: 1,+ retry_in: Duration::from_secs(5),+ },+ SupervisorEvent::Parked {+ server: server(),+ error: "the `npx` launcher is not installed".into(),+ },+ ],+ );++ let expected = PathBuf::from(workspace());+ let stamps: Vec<&PathBuf> = events+ .iter()+ .map(|event| match event {+ DomainEvent::McpServerProbeTimedOut { workspace_dir, .. }+ | DomainEvent::McpServerTransportDropped { workspace_dir, .. }+ | DomainEvent::McpServerReconnected { workspace_dir, .. }+ | DomainEvent::McpServerReconnectFailed { workspace_dir, .. }+ | DomainEvent::McpServerParked { workspace_dir, .. } => workspace_dir,+ other => panic!("not a supervisor event: {other:?}"),+ })+ .collect();+ assert_eq!(stamps.len(), 5);+ assert!(stamps.iter().all(|stamp| **stamp == expected));+}++/// A second workspace's tick is stamped with *its* workspace, not the first's.+#[test]+fn two_workspaces_ticked_in_one_pass_keep_their_own_stamps() {+ let other = Path::new("/tmp/openhuman-ws-b");+ let one = domain_events_for(+ workspace(),+ &[SupervisorEvent::Parked {+ server: server(),+ error: "the `npx` launcher is not installed".into(),+ }],+ );+ let two = domain_events_for(+ other,+ &[SupervisorEvent::Parked {+ server: server(),+ error: "the `npx` launcher is not installed".into(),+ }],+ );++ match (one.as_slice(), two.as_slice()) {+ (+ [DomainEvent::McpServerParked {+ workspace_dir: first,+ ..+ }],+ [DomainEvent::McpServerParked {+ workspace_dir: second,+ ..+ }],+ ) => {+ assert_eq!(first, workspace());+ assert_eq!(second, other);+ assert_ne!(first, second);+ }+ other => panic!("expected one parked event each, got {other:?}"),+ }}diff --git a/src/openhuman/platform/about_app/catalog_part_02.rs b/src/openhuman/platform/about_app/catalog_part_02.rsindex 9161a79f40..225c6bebfa 100644--- a/src/openhuman/platform/about_app/catalog_part_02.rs+++ b/src/openhuman/platform/about_app/catalog_part_02.rs@@ -511,7 +511,7 @@ Capability {name: "MCP Connection Health Alerts",domain: "channels",category: CapabilityCategory::Channels,- description: "Watch installed MCP servers in the background. Every liveness-probe outcome (a slow answer, a dropped transport, a reconnect that succeeded or failed) is recorded in the developer Event Log, and a server that stays down, comes back after failing, or cannot start because its launcher runtime is missing raises a notification.",+ description: "Watch installed MCP servers in the background. Each non-nominal liveness-probe outcome (a slow answer, a dropped transport, a reconnect that succeeded or failed) is recorded in the developer Event Log — an answered probe is not, so a healthy server stays silent — and a server that stays down, comes back after failing, or cannot start because its launcher runtime is missing raises a notification.",how_to: "Automatic. Settings > Developer > Event Log (filter: mcp) for the stream; Notifications for the alerts",status: CapabilityStatus::Beta,privacy: None,