Skip to content

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

fix(observability): gate crash-reporting helpers behind the feature flag

Steven Enamakelecb219433f96
diff --git a/crates/openhuman-core/src/core/observability.rs b/crates/openhuman-core/src/core/observability.rs
index 2b151a2f5e..802f217bdc 100644
--- a/crates/openhuman-core/src/core/observability.rs
+++ b/crates/openhuman-core/src/core/observability.rs
@@ -366,14 +366,7 @@ pub enum ExpectedErrorKind {
/// constant so producer and classifier cannot drift.
WalletNotConfigured,
}
-
-include!("observability_expected_error_classification.rs");
-include!("observability_plan_and_session_errors.rs");
-include!("observability_provider_local_errors.rs");
-include!("observability_network_provider_errors.rs");
-include!("observability_reporting.rs");
-include!("observability_event_classification.rs");
-include!("observability_backend_event_classification.rs");
+include!("observability_expected_error_classification.rs");include!("observability_plan_and_session_errors.rs");include!("observability_provider_local_errors.rs");include!("observability_network_provider_errors.rs");include!("observability_reporting.rs");include!("observability_event_classification.rs");include!("observability_backend_event_classification.rs");
#[cfg(test)]
#[path = "observability_tests.rs"]
mod tests;
diff --git a/crates/openhuman-core/src/core/observability_backend_event_classification.rs b/crates/openhuman-core/src/core/observability_backend_event_classification.rs
index 41de461bdf..48fa912645 100644
--- a/crates/openhuman-core/src/core/observability_backend_event_classification.rs
+++ b/crates/openhuman-core/src/core/observability_backend_event_classification.rs
@@ -1,3 +1,4 @@
+#[cfg(feature = "crash-reporting")]
pub fn is_transient_backend_api_failure(event: &sentry::protocol::Event<'_>) -> bool {
is_transient_domain_failure(event, "backend_api")
}
diff --git a/crates/openhuman-core/src/core/observability_event_classification.rs b/crates/openhuman-core/src/core/observability_event_classification.rs
index 61afafde59..25cb1f51ab 100644
--- a/crates/openhuman-core/src/core/observability_event_classification.rs
+++ b/crates/openhuman-core/src/core/observability_event_classification.rs
@@ -1,3 +1,4 @@
+#[cfg(feature = "crash-reporting")]
pub fn is_transient_provider_http_failure(event: &sentry::protocol::Event<'_>) -> bool {
let tags = &event.tags;
if tags.get("domain").map(String::as_str) != Some("llm_provider") {
@@ -285,4 +286,3 @@ fn is_transient_domain_failure(event: &sentry::protocol::Event<'_>, domain: &str
/// Transient backend API failures (gateway hiccups, scheduled downtime).
/// Match by event tags written by report_error at the authed_json call site.
-#[cfg(feature = "crash-reporting")]
diff --git a/crates/openhuman-core/src/core/observability_expected_error_classification.rs b/crates/openhuman-core/src/core/observability_expected_error_classification.rs
index d83c6e380d..dd1de31a17 100644
--- a/crates/openhuman-core/src/core/observability_expected_error_classification.rs
+++ b/crates/openhuman-core/src/core/observability_expected_error_classification.rs
@@ -1,3 +1,4 @@
+
pub fn expected_error_kind(message: &str) -> Option<ExpectedErrorKind> {
let lower = message.to_ascii_lowercase();
// Explicit host ownership/reportability metadata precedes text heuristics.
@@ -524,9 +525,3 @@ pub(crate) fn is_embedding_endpoint_absent(lower: &str) -> bool {
fn is_embedding_model_rejected(lower: &str) -> bool {
tinyinference_embeddings::probe::is_embedding_model_rejected(lower)
}
-
-/// Whether `msg` is the hosted backend refusing a feature the account's plan
-/// does not include (#8081): a `[…_PLAN_REQUIRED]` code in the head
-/// TinyMemory gives a hosted failure, `[CODE] memory API {route} …`. Matched
-/// as that delimited code, so a description that merely mentions the code
-/// is not a plan refusal. User state, never an expired session.
diff --git a/crates/openhuman-core/src/core/observability_network_provider_errors.rs b/crates/openhuman-core/src/core/observability_network_provider_errors.rs
index ac1b6676f9..7104605297 100644
--- a/crates/openhuman-core/src/core/observability_network_provider_errors.rs
+++ b/crates/openhuman-core/src/core/observability_network_provider_errors.rs
@@ -1,3 +1,58 @@
+
+/// Detect transport-level connection failures that fire before any HTTP status
+/// is observed — DNS resolution failures, TCP connect refused/reset, TLS
+/// handshake failures, or ISP/firewall blocks. The canonical shape is
+/// reqwest's `"error sending request for url (…)"`, which surfaces from any
+/// HTTP call site (provider chat, embeddings, backend RPC) when the request
+/// can't reach the server at all.
+///
+/// These are user-environment problems — VPN drop, captive portal, ISP-level
+/// block (OPENHUMAN-TAURI-32: user in RU couldn't reach the managed backend),
+/// firewall — that no amount of retry / fallback on our side can resolve.
+/// Sentry has no signal to act on (no status, no trace, no payload), so each
+/// occurrence is pure noise. Classify them as expected so the report site
+/// logs a breadcrumb rather than spawning an error event.
+///
+/// Loopback `127.0.0.1:<port>` `Connection refused` shapes are routed
+/// through [`is_loopback_unavailable`] *before* this matcher so the
+/// boot-window race against the embedded core keeps its own bucket — see
+/// the precedence comment in [`expected_error_kind`].
+///
+/// Three additional substrings cover wire-shape variants observed in
+/// Wave 4 that the original `"dns error"` / status-code matchers miss:
+///
+/// - `"failed to lookup address"` / `"nodename nor servname"` —
+/// `getaddrinfo()` failure renderings on macOS / BSD libc and POSIX
+/// resolvers (`OPENHUMAN-TAURI-44` ~50 events,
+/// `[socket] Connection failed: WebSocket connect: IO error: failed to
+/// lookup address information: nodename nor servname provided, or not
+/// known`).
+/// - `"http error: 200 ok"` — tungstenite's `WsError::Http(200)` render
+/// when a corporate proxy / captive portal intercepts the WebSocket
+/// handshake and returns a plain HTML 200 page (`OPENHUMAN-TAURI-4P`
+/// ~66 events). Tungstenite-only — reqwest renders HTTP 200 as
+/// `"HTTP status server error (200)"`, so this can't collide with the
+/// regular HTTP call path.
+/// - `"unexpected eof during handshake"` — `native-tls`'s render when the
+/// peer (or an intercepting firewall / antivirus / corporate TLS proxy)
+/// closes the TCP connection mid-TLS-handshake, surfacing as
+/// `"TLS error: native-tls error: unexpected EOF during handshake"`
+/// wrapped by `socket::ws_loop::run_connection` into
+/// `"WebSocket connect: …"` (`TAURI-RUST-4ZD`, first seen on
+/// `[email protected]`, Windows). The existing `"tls handshake"` anchor
+/// misses it because the words aren't contiguous (`"tls error"` …
+/// `"during handshake"`). Same user-environment shape as the other
+/// handshake-stage entries — the socket supervisor already retries with
+/// exponential backoff and Sentry has no actionable signal.
+/// - `"http version must be 1.1 or higher"` — tungstenite's
+/// `ProtocolError::WrongHttpVersion` render. Fires when a server (or
+/// intermediary proxy / HTTP/2-only edge) responds to the WebSocket
+/// upgrade with HTTP/2+, which the WS spec forbids — the handshake
+/// requires HTTP/1.1 (`CORE-RUST-DP`, ~2 events / 24h, first seen on
+/// `[email protected]`). Same shape as the existing handshake-stage
+/// entries: a user-environment / infra misconfiguration that the
+/// client cannot fix; Sentry has no actionable signal beyond what the
+/// socket supervisor's exponential backoff already provides.
fn is_network_unreachable_message(lower: &str) -> bool {
lower.contains("error sending request for url")
|| lower.contains("dns error")
@@ -539,15 +594,3 @@ fn is_filesystem_user_path_invalid_message(lower: &str) -> bool {
fn is_empty_provider_response_message(lower: &str) -> bool {
lower.contains("model returned an empty response")
}
-
-/// Capture an error to Sentry with structured tags.
-///
-/// `domain` and `operation` are required and become tags `domain:<…>` and
-/// `operation:<…>`. `extra` is an optional list of extra tag pairs. The error
-/// itself is rendered via `Display` and emitted as a `tracing::error!` event,
-/// which the Sentry tracing layer turns into a Sentry event under the active
-/// scope.
-///
-/// Use stable, low-cardinality values for tag keys/values so Sentry can group
-/// and aggregate. High-cardinality data (full IDs, payloads) belongs in the
-/// error message body, not in tags.
diff --git a/crates/openhuman-core/src/core/observability_plan_and_session_errors.rs b/crates/openhuman-core/src/core/observability_plan_and_session_errors.rs
index 32d82d07c4..67aa5104c0 100644
--- a/crates/openhuman-core/src/core/observability_plan_and_session_errors.rs
+++ b/crates/openhuman-core/src/core/observability_plan_and_session_errors.rs
@@ -1,3 +1,9 @@
+
+/// Whether `msg` is the hosted backend refusing a feature the account's plan
+/// does not include (#8081): a `[…_PLAN_REQUIRED]` code in the head
+/// TinyMemory gives a hosted failure, `[CODE] memory API {route} …`. Matched
+/// as that delimited code, so a description that merely mentions the code
+/// is not a plan refusal. User state, never an expired session.
pub fn is_plan_required_message(msg: &str) -> bool {
// The code runs from the nearest `[` before the head and is all
// `A-Z0-9_`, as TinyMemory cleans it.
@@ -189,13 +195,3 @@ pub fn is_api_key_unset_message(text: &str) -> bool {
|| lower.contains("no api key is configured")
|| lower.contains("no api key supplied")
}
-
-/// Does this error text describe a **local** LLM provider (loopback host, e.g.
-/// LM Studio / Ollama / llama.cpp on `127.0.0.1:<port>` or `localhost:<port>`)
-/// refusing the connection because its server isn't running?
-///
-/// Single-source wrapper over [`is_loopback_unavailable`] so callers outside
-/// this module (the cron scheduler's retry-halt guard) key off the exact same
-/// matcher the [`expected_error_kind`] classifier uses — the phrasing cannot
-/// drift between the source demotion and the cron suppression. Lowercases the
-/// input to match the classifier's internal contract (TAURI-RUST-12K).
diff --git a/crates/openhuman-core/src/core/observability_provider_local_errors.rs b/crates/openhuman-core/src/core/observability_provider_local_errors.rs
index d07f2e3b75..243a3c8a41 100644
--- a/crates/openhuman-core/src/core/observability_provider_local_errors.rs
+++ b/crates/openhuman-core/src/core/observability_provider_local_errors.rs
@@ -1,3 +1,13 @@
+
+/// Does this error text describe a **local** LLM provider (loopback host, e.g.
+/// LM Studio / Ollama / llama.cpp on `127.0.0.1:<port>` or `localhost:<port>`)
+/// refusing the connection because its server isn't running?
+///
+/// Single-source wrapper over [`is_loopback_unavailable`] so callers outside
+/// this module (the cron scheduler's retry-halt guard) key off the exact same
+/// matcher the [`expected_error_kind`] classifier uses — the phrasing cannot
+/// drift between the source demotion and the cron suppression. Lowercases the
+/// input to match the classifier's internal contract (TAURI-RUST-12K).
pub fn is_local_provider_unreachable_message(text: &str) -> bool {
is_loopback_unavailable(&text.to_ascii_lowercase())
}
@@ -180,58 +190,3 @@ fn is_ollama_user_config_rejection(lower: &str) -> bool {
false
}
-
-/// Detect transport-level connection failures that fire before any HTTP status
-/// is observed — DNS resolution failures, TCP connect refused/reset, TLS
-/// handshake failures, or ISP/firewall blocks. The canonical shape is
-/// reqwest's `"error sending request for url (…)"`, which surfaces from any
-/// HTTP call site (provider chat, embeddings, backend RPC) when the request
-/// can't reach the server at all.
-///
-/// These are user-environment problems — VPN drop, captive portal, ISP-level
-/// block (OPENHUMAN-TAURI-32: user in RU couldn't reach the managed backend),
-/// firewall — that no amount of retry / fallback on our side can resolve.
-/// Sentry has no signal to act on (no status, no trace, no payload), so each
-/// occurrence is pure noise. Classify them as expected so the report site
-/// logs a breadcrumb rather than spawning an error event.
-///
-/// Loopback `127.0.0.1:<port>` `Connection refused` shapes are routed
-/// through [`is_loopback_unavailable`] *before* this matcher so the
-/// boot-window race against the embedded core keeps its own bucket — see
-/// the precedence comment in [`expected_error_kind`].
-///
-/// Three additional substrings cover wire-shape variants observed in
-/// Wave 4 that the original `"dns error"` / status-code matchers miss:
-///
-/// - `"failed to lookup address"` / `"nodename nor servname"` —
-/// `getaddrinfo()` failure renderings on macOS / BSD libc and POSIX
-/// resolvers (`OPENHUMAN-TAURI-44` ~50 events,
-/// `[socket] Connection failed: WebSocket connect: IO error: failed to
-/// lookup address information: nodename nor servname provided, or not
-/// known`).
-/// - `"http error: 200 ok"` — tungstenite's `WsError::Http(200)` render
-/// when a corporate proxy / captive portal intercepts the WebSocket
-/// handshake and returns a plain HTML 200 page (`OPENHUMAN-TAURI-4P`
-/// ~66 events). Tungstenite-only — reqwest renders HTTP 200 as
-/// `"HTTP status server error (200)"`, so this can't collide with the
-/// regular HTTP call path.
-/// - `"unexpected eof during handshake"` — `native-tls`'s render when the
-/// peer (or an intercepting firewall / antivirus / corporate TLS proxy)
-/// closes the TCP connection mid-TLS-handshake, surfacing as
-/// `"TLS error: native-tls error: unexpected EOF during handshake"`
-/// wrapped by `socket::ws_loop::run_connection` into
-/// `"WebSocket connect: …"` (`TAURI-RUST-4ZD`, first seen on
-/// `[email protected]`, Windows). The existing `"tls handshake"` anchor
-/// misses it because the words aren't contiguous (`"tls error"` …
-/// `"during handshake"`). Same user-environment shape as the other
-/// handshake-stage entries — the socket supervisor already retries with
-/// exponential backoff and Sentry has no actionable signal.
-/// - `"http version must be 1.1 or higher"` — tungstenite's
-/// `ProtocolError::WrongHttpVersion` render. Fires when a server (or
-/// intermediary proxy / HTTP/2-only edge) responds to the WebSocket
-/// upgrade with HTTP/2+, which the WS spec forbids — the handshake
-/// requires HTTP/1.1 (`CORE-RUST-DP`, ~2 events / 24h, first seen on
-/// `[email protected]`). Same shape as the existing handshake-stage
-/// entries: a user-environment / infra misconfiguration that the
-/// client cannot fix; Sentry has no actionable signal beyond what the
-/// socket supervisor's exponential backoff already provides.
diff --git a/crates/openhuman-core/src/core/observability_reporting.rs b/crates/openhuman-core/src/core/observability_reporting.rs
index 87ce999b3d..468a1a5851 100644
--- a/crates/openhuman-core/src/core/observability_reporting.rs
+++ b/crates/openhuman-core/src/core/observability_reporting.rs
@@ -1,3 +1,15 @@
+
+/// Capture an error to Sentry with structured tags.
+///
+/// `domain` and `operation` are required and become tags `domain:<…>` and
+/// `operation:<…>`. `extra` is an optional list of extra tag pairs. The error
+/// itself is rendered via `Display` and emitted as a `tracing::error!` event,
+/// which the Sentry tracing layer turns into a Sentry event under the active
+/// scope.
+///
+/// Use stable, low-cardinality values for tag keys/values so Sentry can group
+/// and aggregate. High-cardinality data (full IDs, payloads) belongs in the
+/// error message body, not in tags.
pub fn report_error<E: Display + ?Sized>(
err: &E,
domain: &str,
@@ -686,4 +698,3 @@ pub fn report_warning_message(message: &str, domain: &str, operation: &str, extr
/// for its own reasons doesn't get silently dropped
/// - tag `failure == "non_2xx"` (the marker set by `ops::api_error`)
/// - tag `status` parses to one of [`TRANSIENT_PROVIDER_HTTP_STATUSES`]
-#[cfg(feature = "crash-reporting")]
diff --git a/crates/openhuman-core/src/web_chat/progress_bridge_spawn.rs b/crates/openhuman-core/src/web_chat/progress_bridge_spawn.rs
index dbba255d3a..dcdbafad09 100644
--- a/crates/openhuman-core/src/web_chat/progress_bridge_spawn.rs
+++ b/crates/openhuman-core/src/web_chat/progress_bridge_spawn.rs
@@ -22,7 +22,7 @@ pub(crate) fn spawn_progress_bridge(
let (drained_tx, drained_rx) = tokio::sync::watch::channel(false);
let timing_snapshot: std::sync::Arc<
- std::sync::Mutex<Option<super::turn_timing::TurnTimingSnapshot>>,
+ std::sync::Mutex<Option<crate::web_chat::turn_timing::TurnTimingSnapshot>>,
> = std::sync::Arc::new(std::sync::Mutex::new(None));
let timing_snapshot_for_task = timing_snapshot.clone();
dispatch_ctx.clone().spawn(async move {
@@ -44,8 +44,8 @@ pub(crate) fn spawn_progress_bridge(
// separately via `deliver_response` and is never part of this buffer
// (it belongs to the terminal round, which ends with no tool call).
let mut pending_narration = String::new();
- let mut timing = super::turn_timing::TurnTiming::start();
- let mut turn_cost_throttle = super::turn_timing::TurnCostThrottle::new();
+ let mut timing = crate::web_chat::turn_timing::TurnTiming::start();
+ let mut turn_cost_throttle = crate::web_chat::turn_timing::TurnCostThrottle::new();
let mut events_seen: u64 = 0;
// Per-request monotonic ordering key stamped on every emitted
// web-channel event (see `publish_seq_stamped`). Unique per emission so