Skip to content

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

feat(modules): expose pre-core calls with sanitized failure reports

Steven Enamakel8b2e0ad87650
diff --git a/crates/openhuman-core/Cargo.toml b/crates/openhuman-core/Cargo.toml
index e45e2eda7b..bf00fa4849 100644
--- a/crates/openhuman-core/Cargo.toml
+++ b/crates/openhuman-core/Cargo.toml
@@ -320,7 +320,9 @@ tinychannels = { version = "0.1", features = ["relay-websocket"], optional = tru
# never loads a module. The kernel-floor ratchet catches exactly that, and did.
tinybus = { path = "../../vendor/tinybus/crates/tinybus", default-features = false, features = ["macros", "uds"] }
tinysearch-bus = { path = "../../vendor/tinysearch/crates/tinysearch-bus" }
-tinycomputer-bus = { path = "../../vendor/tinycomputer/crates/tinycomputer-bus", optional = true }
+# Registry vocabulary is available even when the loader is disabled, so the
+# pre-core client can identify and report an unavailable module safely.
+tinycomputer-bus = { path = "../../vendor/tinycomputer/crates/tinycomputer-bus" }
# Desktop accessibility middleware, linked as a plain library (not through the
# tinycomputer module): the voice pipeline needs focus lookup, paste validation,
# permission checks and the Globe key synchronously and in-process. Deps are
@@ -816,7 +818,7 @@ tinymemes = ["dep:tinymemes"]
# A loaded module is trusted in-process code with this process's privileges, and
# tinybus never unloads one. See `crates/openhuman-core/src/modules/` before adding an entry
# to the registry.
-modules = ["tinybus/modules", "dep:tinycomputer-bus"]
+modules = ["tinybus/modules"]
# Voice + audio_toolkit domains: STT/TTS providers, the standalone dictation
# server, always-on listening, and podcast audio generation/email delivery.
# Default-ON — the desktop app always ships with voice. Slim / headless builds
diff --git a/crates/openhuman-core/src/core/observability_availability.rs b/crates/openhuman-core/src/core/observability_availability.rs
index 7f24b710ab..3e27c8f611 100644
--- a/crates/openhuman-core/src/core/observability_availability.rs
+++ b/crates/openhuman-core/src/core/observability_availability.rs
@@ -44,7 +44,10 @@ pub fn is_backend_unavailable_message(msg: &str) -> bool {
/// events (TAURI-RUST-117K / -118J / -117Y / -113J / -113T / -113D / -113N /
/// -113Q / -113X).
///
-/// Anchors, all produced by module loading and nothing else:
+/// Anchors, produced by module loading or the shared module client:
+///
+/// - `MODULE_CALL_REPORTED:` — the shared client already emitted a sanitized
+/// report; product callers must not report its returned error again;
///
/// - [`crate::tools::status::MODULE_FAULT_MARKER`] — every terminal load
/// failure from `modules::ops` and tinybus' `load_first_admitted` carries it;
@@ -57,8 +60,11 @@ pub fn is_backend_unavailable_message(msg: &str) -> bool {
/// policy and workflows use it for failures that must keep paging.
pub fn is_module_unavailable_message(msg: &str) -> bool {
let lower = msg.to_ascii_lowercase();
- msg.contains(crate::tools::status::MODULE_FAULT_MARKER)
+ msg.contains("MODULE_CALL_REPORTED:")
+ || msg.contains(crate::tools::status::MODULE_FAULT_MARKER)
|| (lower.contains("module '") && lower.contains("could not be loaded"))
+ || (lower.contains("module '")
+ && lower.contains("is unavailable: modules are disabled in configuration"))
|| lower.contains("the memory module failed to load")
}
diff --git a/crates/openhuman-core/src/lib.rs b/crates/openhuman-core/src/lib.rs
index 8a5b9c76fc..2a05fc7fd5 100644
--- a/crates/openhuman-core/src/lib.rs
+++ b/crates/openhuman-core/src/lib.rs
@@ -71,7 +71,6 @@ pub mod mcp;
#[cfg(feature = "media")]
pub mod media;
pub mod memory;
-#[cfg(feature = "modules")]
pub mod modules;
pub mod platform;
pub mod profiles;
diff --git a/crates/openhuman-core/src/modules/client.rs b/crates/openhuman-core/src/modules/client.rs
new file mode 100644
index 0000000000..7ecedae27b
--- /dev/null
+++ b/crates/openhuman-core/src/modules/client.rs
@@ -0,0 +1,186 @@
+//! Shared module access for hosts, including before a core runtime is started.
+
+use serde::{de::DeserializeOwned, Serialize};
+
+use crate::config::Config;
+
+use super::{failure, registry};
+
+/// A sanitized terminal module outcome. Arguments and remote error text are absent.
+#[derive(Clone, Copy, Debug, Eq, PartialEq)]
+pub enum ModuleCallError {
+ Unavailable,
+ IncompatibleContract,
+ TransportFailed,
+ ModuleFault,
+}
+
+impl std::fmt::Display for ModuleCallError {
+ fn fmt(&self, formatter: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
+ let reason = match self {
+ Self::Unavailable => "unavailable",
+ Self::IncompatibleContract => "incompatible contract",
+ Self::TransportFailed => "transport failed",
+ Self::ModuleFault => "execution failed",
+ };
+ // Later product reporting recognises this as already reported module
+ // unavailability, rather than producing another terminal Sentry event.
+ write!(formatter, "MODULE_CALL_REPORTED: module {reason}")
+ }
+}
+
+impl std::error::Error for ModuleCallError {}
+
+/// Explicit configuration over the existing process-wide lazy module loader.
+///
+/// Constructing a client starts nothing. It needs neither a signed-in session
+/// nor a core runtime. Set the bundled releases directory through the module
+/// facade before the first call when artifacts ship with the host.
+#[derive(Clone)]
+pub struct ModuleClient {
+ config: Config,
+}
+
+impl ModuleClient {
+ #[must_use]
+ pub fn new(config: Config) -> Self {
+ Self { config }
+ }
+
+ /// Execute a contract member, retaining its existing argument tuple arity.
+ ///
+ /// No implementation fallback is provided. The caller owns approvals,
+ /// cancellation, deadlines and lifecycle cleanup members.
+ pub async fn call<R: DeserializeOwned>(
+ &self,
+ module: &str,
+ member: &str,
+ args: impl Serialize,
+ ) -> Result<R, ModuleCallError> {
+ self.invoke(module, member, args, false).await
+ }
+
+ /// Execute a confidential member after TinyBus recipient attestation.
+ ///
+ /// Use this for credentials and other sensitive module inputs. A failure to
+ /// attest the pinned artifact fails the call; ordinary delivery is never retried.
+ pub async fn call_confidential<R: DeserializeOwned>(
+ &self,
+ module: &str,
+ member: &str,
+ args: impl Serialize,
+ ) -> Result<R, ModuleCallError> {
+ self.invoke(module, member, args, true).await
+ }
+
+ async fn invoke<R: DeserializeOwned>(
+ &self,
+ module: &str,
+ member: &str,
+ args: impl Serialize,
+ confidential: bool,
+ ) -> Result<R, ModuleCallError> {
+ let record = registry::find(module).ok_or(ModuleCallError::Unavailable)?;
+ if !self.config.modules.enabled {
+ failure::report(record, failure::Reason::Disabled);
+ return Err(ModuleCallError::Unavailable);
+ }
+ #[cfg(not(feature = "modules"))]
+ {
+ let _ = (member, args, confidential);
+ failure::report(record, failure::Reason::LoaderDisabled);
+ Err(ModuleCallError::Unavailable)
+ }
+ #[cfg(feature = "modules")]
+ {
+ super::ops::ensure_loaded(&self.config, module)
+ .await
+ .map_err(|_| ModuleCallError::Unavailable)?;
+ let runtime = super::host::runtime().await.map_err(|_| {
+ failure::report(record, failure::Reason::TransportFailed);
+ ModuleCallError::TransportFailed
+ })?;
+ let proxy = runtime
+ .proxy(record.bus_name, record.object_path)
+ .map_err(|_| {
+ failure::report(record, failure::Reason::IncompatibleContract);
+ ModuleCallError::IncompatibleContract
+ })?;
+ invoke_proxy(record, &proxy, member, args, confidential).await
+ }
+ }
+}
+
+#[cfg(feature = "modules")]
+async fn invoke_proxy<R: DeserializeOwned>(
+ record: &'static super::types::ModuleRecord,
+ proxy: &tinybus::Proxy,
+ member: &str,
+ args: impl Serialize,
+ confidential: bool,
+) -> Result<R, ModuleCallError> {
+ let result = if confidential {
+ proxy.call_confidential(member, args).await
+ } else {
+ proxy.call(member, args).await
+ };
+ result.map_err(|error| {
+ let (outcome, reason) = classify(&error);
+ failure::report(record, reason);
+ outcome
+ })
+}
+
+#[cfg(feature = "modules")]
+fn classify(error: &tinybus::Error) -> (ModuleCallError, failure::Reason) {
+ use tinybus::Error;
+ match error {
+ Error::IncompatibleVersion { .. }
+ | Error::UnknownMethod { .. }
+ | Error::UnknownInterface { .. }
+ | Error::UnknownObject { .. }
+ | Error::BadArguments { .. } => (
+ ModuleCallError::IncompatibleContract,
+ failure::Reason::IncompatibleContract,
+ ),
+ Error::MethodFailed { name, .. }
+ if matches!(
+ name.as_str(),
+ Error::UNKNOWN_METHOD
+ | "ai.tinyhumans.tinybus.Error.IncompatibleVersion"
+ | "ai.tinyhumans.tinybus.Error.UnknownInterface"
+ | "ai.tinyhumans.tinybus.Error.UnknownObject"
+ | "ai.tinyhumans.tinybus.Error.BadArguments"
+ ) =>
+ {
+ (
+ ModuleCallError::IncompatibleContract,
+ failure::Reason::IncompatibleContract,
+ )
+ }
+ Error::Json(_) => (
+ ModuleCallError::IncompatibleContract,
+ failure::Reason::IncompatibleContract,
+ ),
+ Error::MethodFailed { name, .. }
+ if matches!(
+ name.as_str(),
+ Error::NOT_ATTESTED | Error::CONFIDENTIALITY_REQUIRED
+ ) =>
+ {
+ (
+ ModuleCallError::TransportFailed,
+ failure::Reason::TransportFailed,
+ )
+ }
+ Error::MethodFailed { .. } => (ModuleCallError::ModuleFault, failure::Reason::ModuleFault),
+ _ => (
+ ModuleCallError::TransportFailed,
+ failure::Reason::TransportFailed,
+ ),
+ }
+}
+
+#[cfg(test)]
+#[path = "client_tests.rs"]
+mod tests;
diff --git a/crates/openhuman-core/src/modules/client_tests.rs b/crates/openhuman-core/src/modules/client_tests.rs
new file mode 100644
index 0000000000..2134fb0401
--- /dev/null
+++ b/crates/openhuman-core/src/modules/client_tests.rs
@@ -0,0 +1,153 @@
+use super::*;
+
+#[tokio::test]
+async fn a_disabled_client_is_unavailable_before_core_startup() {
+ let mut config = Config::default();
+ config.modules.enabled = false;
+ let result = ModuleClient::new(config)
+ .call::<serde_json::Value>("tinyhosts", "Providers", ())
+ .await;
+ assert_eq!(result, Err(ModuleCallError::Unavailable));
+}
+
+#[tokio::test]
+async fn unknown_modules_are_not_loaded_or_reported_using_untrusted_ids() {
+ let client = ModuleClient::new(Config::default());
+ let result = client
+ .call::<serde_json::Value>("private-user-path-and-token", "Anything", ())
+ .await;
+ assert_eq!(result, Err(ModuleCallError::Unavailable));
+ assert!(!result
+ .unwrap_err()
+ .to_string()
+ .contains("private-user-path-and-token"));
+}
+
+#[cfg(not(feature = "modules"))]
+#[tokio::test]
+async fn a_client_without_the_loader_never_falls_back_to_an_implementation() {
+ let result = ModuleClient::new(Config::default())
+ .call::<serde_json::Value>("tinyhosts", "Providers", ())
+ .await;
+ assert_eq!(result, Err(ModuleCallError::Unavailable));
+}
+
+#[cfg(feature = "modules")]
+#[test]
+fn remote_fault_text_is_not_part_of_the_public_error() {
+ let error = tinybus::Error::MethodFailed {
+ name: "private-provider".to_string(),
+ message: "secret-token /home/private-user document content".to_string(),
+ };
+ assert_eq!(classify(&error).0, ModuleCallError::ModuleFault);
+ assert_eq!(
+ classify(&error).0.to_string(),
+ "MODULE_CALL_REPORTED: module execution failed"
+ );
+}
+
+#[test]
+fn subsequent_product_reports_are_demoted() {
+ for error in [
+ ModuleCallError::Unavailable,
+ ModuleCallError::IncompatibleContract,
+ ModuleCallError::TransportFailed,
+ ModuleCallError::ModuleFault,
+ ] {
+ assert!(crate::core::observability::is_module_unavailable_message(
+ &error.to_string()
+ ));
+ }
+}
+
+#[tokio::test]
+async fn confidential_calls_do_not_fall_back_when_disabled() {
+ let mut config = Config::default();
+ config.modules.enabled = false;
+ let result = ModuleClient::new(config)
+ .call_confidential::<serde_json::Value>("tinywallet", "SignTransaction", ("secret-value",))
+ .await;
+ assert_eq!(result, Err(ModuleCallError::Unavailable));
+}
+
+#[cfg(feature = "modules")]
+#[test]
+fn wire_unknown_method_is_an_incompatible_contract() {
+ let error = tinybus::Error::MethodFailed {
+ name: tinybus::Error::UNKNOWN_METHOD.to_string(),
+ message: "private-response-content".to_string(),
+ };
+ assert_eq!(classify(&error).0, ModuleCallError::IncompatibleContract);
+ assert_eq!(
+ classify(&tinybus::Error::ConnectionClosed).0,
+ ModuleCallError::TransportFailed
+ );
+}
+
+#[cfg(feature = "modules")]
+#[derive(Clone)]
+struct BusFixture(std::sync::Arc<std::sync::atomic::AtomicUsize>);
+
+#[cfg(feature = "modules")]
+#[tinybus::interface(name = "test.ModuleClient")]
+impl BusFixture {
+ async fn sum(&self, left: u32, right: u32) -> tinybus::Result<u32> {
+ self.0.fetch_add(1, std::sync::atomic::Ordering::SeqCst);
+ Ok(left + right)
+ }
+
+ async fn fault(&self) -> tinybus::Result<()> {
+ Err(tinybus::Error::MethodFailed {
+ name: "test.ProviderFault".to_string(),
+ message: "secret-value /home/private-user/payload".to_string(),
+ })
+ }
+}
+
+#[cfg(feature = "modules")]
+#[tokio::test]
+async fn bus_calls_preserve_tuple_arity_and_never_downgrade_confidentiality() {
+ use tinybus::{broker::Broker, transport::memory::MemoryBus, Connection, ObjectPath};
+ let bus = MemoryBus::new();
+ Broker::new().spawn(bus.clone());
+ let service = Connection::connect(bus.connect().await.unwrap())
+ .await
+ .unwrap();
+ let caller = Connection::connect(bus.connect().await.unwrap())
+ .await
+ .unwrap();
+ let calls = std::sync::Arc::new(std::sync::atomic::AtomicUsize::new(0));
+ service
+ .serve_at(
+ ObjectPath::new("/test/ModuleClient").unwrap(),
+ BusFixture(calls.clone()),
+ )
+ .await
+ .unwrap();
+ service.request_name("test.ModuleClient").await.unwrap();
+ let proxy = caller
+ .proxy(
+ "test.ModuleClient",
+ "/test/ModuleClient",
+ "test.ModuleClient",
+ )
+ .unwrap();
+ let record = registry::find("tinysearch").unwrap();
+ assert_eq!(
+ invoke_proxy::<u32>(record, &proxy, "Sum", (20_u32, 22_u32), false).await,
+ Ok(42)
+ );
+ assert_eq!(
+ invoke_proxy::<u32>(record, &proxy, "Sum", (20_u32, 22_u32), true).await,
+ Err(ModuleCallError::TransportFailed)
+ );
+ assert_eq!(calls.load(std::sync::atomic::Ordering::SeqCst), 1);
+ assert_eq!(
+ invoke_proxy::<()>(record, &proxy, "Fault", (), false).await,
+ Err(ModuleCallError::ModuleFault)
+ );
+ assert_eq!(
+ invoke_proxy::<()>(record, &proxy, "MissingMember", (), false).await,
+ Err(ModuleCallError::IncompatibleContract)
+ );
+}
diff --git a/crates/openhuman-core/src/modules/failure.rs b/crates/openhuman-core/src/modules/failure.rs
new file mode 100644
index 0000000000..81a5894649
--- /dev/null
+++ b/crates/openhuman-core/src/modules/failure.rs
@@ -0,0 +1,81 @@
+//! Sanitized terminal module reports, deduplicated for the process lifetime.
+
+use std::collections::HashSet;
+use std::sync::{Mutex, OnceLock};
+
+use super::types::ModuleRecord;
+
+/// Closed reason vocabulary: never accept a module error, path or payload here.
+#[derive(Clone, Copy, Debug, Eq, Hash, PartialEq)]
+pub(super) enum Reason {
+ Disabled,
+ LoaderDisabled,
+ ResolutionFailed,
+ IncompatibleContract,
+ TransportFailed,
+ ModuleFault,
+}
+
+impl Reason {
+ fn code(self) -> &'static str {
+ match self {
+ Self::Disabled => "disabled",
+ Self::LoaderDisabled => "loader_disabled",
+ Self::ResolutionFailed => "resolution_failed",
+ Self::IncompatibleContract => "incompatible_contract",
+ Self::TransportFailed => "transport_failed",
+ Self::ModuleFault => "module_fault",
+ }
+ }
+
+ fn stage(self) -> &'static str {
+ match self {
+ Self::Disabled | Self::LoaderDisabled => "availability",
+ Self::ResolutionFailed => "resolve",
+ Self::IncompatibleContract => "contract",
+ Self::TransportFailed => "transport",
+ Self::ModuleFault => "execution",
+ }
+ }
+}
+
+/// Report a terminal outcome once. Registry records supply all identifying tags.
+///
+/// There are finitely many registry records and reasons, so the process cache
+/// is bounded. Concurrent callers cannot duplicate the same terminal report.
+pub(super) fn report(record: &'static ModuleRecord, reason: Reason) {
+ static REPORTED: OnceLock<Mutex<HashSet<(&'static str, Reason)>>> = OnceLock::new();
+ let first = REPORTED
+ .get_or_init(|| Mutex::new(HashSet::new()))
+ .lock()
+ .unwrap_or_else(std::sync::PoisonError::into_inner)
+ .insert((record.id, reason));
+ if !first {
+ return;
+ }
+ let platform = format!("{}-{}", std::env::consts::OS, std::env::consts::ARCH);
+ let capture = || {
+ crate::core::observability::report_error(
+ "loadable module operation failed",
+ "modules",
+ reason.stage(),
+ &[
+ ("module", record.id),
+ ("version", record.version),
+ ("stage", reason.stage()),
+ ("platform", &platform),
+ ("reason_code", reason.code()),
+ ],
+ )
+ };
+ // A host may have put request payloads or user paths on its current scope.
+ // These terminal events carry only the closed metadata above.
+ #[cfg(feature = "crash-reporting")]
+ sentry::with_scope(|scope| scope.clear(), capture);
+ #[cfg(not(feature = "crash-reporting"))]
+ capture();
+}
+
+#[cfg(test)]
+#[path = "failure_tests.rs"]
+mod tests;
diff --git a/crates/openhuman-core/src/modules/failure_tests.rs b/crates/openhuman-core/src/modules/failure_tests.rs
new file mode 100644
index 0000000000..81eefc7610
--- /dev/null
+++ b/crates/openhuman-core/src/modules/failure_tests.rs
@@ -0,0 +1,67 @@
+use super::*;
+
+#[cfg(feature = "crash-reporting")]
+#[test]
+fn terminal_reports_are_sanitized_and_deduplicated() {
+ let record = crate::modules::registry::find("tinybox").unwrap();
+ let events = sentry::test::with_captured_events(|| {
+ sentry::with_scope(
+ |scope| {
+ scope.set_tag("unsafe_path", "/home/private-user/document.txt");
+ scope.set_extra(
+ "unsafe_payload",
+ "private-test-token and user content".into(),
+ );
+ },
+ || {
+ report(record, Reason::ModuleFault);
+ report(record, Reason::ModuleFault);
+ },
+ );
+ });
+ assert_eq!(events.len(), 1, "{events:?}");
+ let event = &events[0];
+ let captured = format!("{event:?}");
+ assert!(!captured.contains("private-test-token"));
+ assert!(!captured.contains("/home/private-user"));
+ assert!(!event.tags.contains_key("unsafe_path"));
+ assert!(event.extra.is_empty());
+ assert_eq!(
+ event.message.as_deref(),
+ Some("loadable module operation failed")
+ );
+ for (key, value) in [
+ ("module", record.id),
+ ("version", record.version),
+ ("stage", "execution"),
+ ("reason_code", "module_fault"),
+ ] {
+ assert_eq!(event.tags.get(key).map(String::as_str), Some(value));
+ }
+ assert_eq!(
+ event.tags.get("platform"),
+ Some(&format!(
+ "{}-{}",
+ std::env::consts::OS,
+ std::env::consts::ARCH
+ ))
+ );
+}
+
+#[test]
+fn reason_codes_and_stages_are_closed_vocabulary() {
+ for reason in [
+ Reason::Disabled,
+ Reason::LoaderDisabled,
+ Reason::ResolutionFailed,
+ Reason::IncompatibleContract,
+ Reason::TransportFailed,
+ Reason::ModuleFault,
+ ] {
+ assert!(reason
+ .code()
+ .chars()
+ .all(|c| c.is_ascii_lowercase() || c == '_'));
+ assert!(reason.stage().chars().all(|c| c.is_ascii_lowercase()));
+ }
+}
diff --git a/crates/openhuman-core/src/modules/mod.rs b/crates/openhuman-core/src/modules/mod.rs
index 62b4d6369f..e0ec67de53 100644
--- a/crates/openhuman-core/src/modules/mod.rs
+++ b/crates/openhuman-core/src/modules/mod.rs
@@ -40,30 +40,52 @@
//! - [`schemas`] — the `modules` RPC surface.
//! - [`boot`] — what happens at startup.
+#[cfg(feature = "modules")]
pub mod boot;
+#[cfg(feature = "modules")]
pub mod browser;
+#[cfg(feature = "modules")]
pub(crate) mod browser_sites;
+#[cfg(feature = "modules")]
pub mod browser_task;
+#[cfg(feature = "modules")]
mod browser_task_report;
+pub mod client;
+#[cfg(feature = "modules")]
pub mod computer;
+#[cfg(feature = "modules")]
pub mod computer_config;
+#[cfg(feature = "modules")]
pub mod connectors;
+#[cfg(feature = "modules")]
pub mod desktop;
#[cfg(feature = "documents")]
+#[cfg(feature = "modules")]
pub mod documents;
+mod failure;
+#[cfg(feature = "modules")]
pub mod host;
+#[cfg(feature = "modules")]
pub mod ops;
pub mod registry;
+#[cfg(feature = "modules")]
pub mod runtime;
+#[cfg(feature = "modules")]
pub mod schemas;
+#[cfg(feature = "modules")]
pub mod search;
+#[cfg(feature = "modules")]
mod tokenjuice_host;
pub mod types;
#[cfg(feature = "voice")]
+#[cfg(feature = "modules")]
pub mod voice;
#[cfg(feature = "web3")]
+#[cfg(feature = "modules")]
pub mod wallet;
+#[cfg(feature = "modules")]
pub use ops::{ensure_loaded, ensure_loaded_within, state_of, LoadError};
+#[cfg(feature = "modules")]
pub use schemas::{all_controller_schemas, all_registered_controllers};
pub use types::{LoadPolicy, ModuleRecord, ModuleState, ModuleStatus, PlatformAsset};
diff --git a/crates/openhuman-core/src/modules/ops.rs b/crates/openhuman-core/src/modules/ops.rs
index 04b68c9c08..960dfec423 100644
--- a/crates/openhuman-core/src/modules/ops.rs
+++ b/crates/openhuman-core/src/modules/ops.rs
@@ -150,6 +150,9 @@ pub async fn ensure_loaded_within(
within: Option<Duration>,
) -> Result<(), LoadError> {
if !config.modules.enabled {
+ if let Some(record) = registry::find(id) {
+ super::failure::report(record, super::failure::Reason::Disabled);
+ }
return Err(LoadError::Failed(format!(
"module '{id}' is unavailable: modules are disabled in configuration"
)));
@@ -236,7 +239,12 @@ async fn start_resolution(
///
/// [`report_error`]: crate::core::observability::report_error
pub(super) fn report_resolution_failure(id: &str, reason: &str) {
- crate::core::observability::report_error(reason, "modules", "resolve", &[("module", id)]);
+ // Loader errors can include download URLs or user paths. Keep their detail
+ // in the operation's returned error, never in the terminal Sentry report.
+ let _ = reason;
+ if let Some(record) = registry::find(id) {
+ super::failure::report(record, super::failure::Reason::ResolutionFailed);
+ }
}
/// Do the actual work of getting `record` serving.
diff --git a/crates/openhuman-core/src/modules/ops_tests.rs b/crates/openhuman-core/src/modules/ops_tests.rs
index 6422578f66..4ad2f9c283 100644
--- a/crates/openhuman-core/src/modules/ops_tests.rs
+++ b/crates/openhuman-core/src/modules/ops_tests.rs
@@ -349,10 +349,28 @@ fn a_failed_resolution_is_reported_once_with_the_module_id() {
// report is the one Sentry event per broken install. Every later caller's
// re-report is demoted as `ModuleUnavailable`; this one must not be.
let events = sentry::test::with_captured_events(|| {
- ops::report_resolution_failure("tinyconnectors", REFUSED_LOAD);
+ ops::report_resolution_failure(
+ "tinyconnectors",
+ "private-test-token /home/private-user/document.txt",
+ );
});
assert_eq!(events.len(), 1, "{events:?}");
+ assert_eq!(
+ events[0].message.as_deref(),
+ Some("loadable module operation failed")
+ );
+ let captured = format!("{:?}", events[0]);
+ assert!(!captured.contains("private-test-token"));
+ assert!(!captured.contains("/home/private-user"));
let tags = &events[0].tags;
+ assert_eq!(
+ tags.get("reason_code").map(String::as_str),
+ Some("resolution_failed")
+ );
+ assert_eq!(
+ tags.get("version").map(String::as_str),
+ Some(registry::find("tinyconnectors").unwrap().version)
+ );
assert_eq!(tags.get("domain").map(String::as_str), Some("modules"));
assert_eq!(tags.get("operation").map(String::as_str), Some("resolve"));
assert_eq!(
@@ -440,3 +458,13 @@ fn a_marked_bus_startup_failure_is_classified_as_module_unavailable() {
// Idempotent: an already-marked error is not annotated twice.
assert_eq!(ops::mark_terminal(marked.clone()), marked);
}
+
+#[tokio::test]
+async fn disabled_modules_are_reported_then_demoted_at_product_boundaries() {
+ let mut config = Config::default();
+ config.modules.enabled = false;
+ let reason = ops::ensure_loaded(&config, "tinyjuice").await.unwrap_err();
+ assert!(crate::core::observability::is_module_unavailable_message(
+ &reason
+ ));
+}
diff --git a/crates/openhuman-core/src/modules/registry.rs b/crates/openhuman-core/src/modules/registry.rs
index 9725429757..880607901c 100644
--- a/crates/openhuman-core/src/modules/registry.rs
+++ b/crates/openhuman-core/src/modules/registry.rs
@@ -30,7 +30,7 @@
//! count — see `registry/records_*.rs`. This file only wires them into
//! [`ALL`] and answers [`find`].
-#[cfg(test)]
+#[cfg(all(test, feature = "modules"))]
#[path = "registry_tests.rs"]
mod tests;
diff --git a/crates/openhuman-embed/src/lib.rs b/crates/openhuman-embed/src/lib.rs
index 0ff7d09900..f8f58c16bc 100644
--- a/crates/openhuman-embed/src/lib.rs
+++ b/crates/openhuman-embed/src/lib.rs
@@ -111,7 +111,6 @@ mod error;
mod harness;
pub mod identity;
pub mod memory;
-#[cfg(feature = "modules")]
pub mod modules;
pub mod process;
#[cfg(feature = "channels")]
diff --git a/crates/openhuman-embed/src/modules.rs b/crates/openhuman-embed/src/modules.rs
index e1d9279740..89443dcdea 100644
--- a/crates/openhuman-embed/src/modules.rs
+++ b/crates/openhuman-embed/src/modules.rs
@@ -3,10 +3,19 @@
/// Point module installs at artifacts bundled with the host (an app's
/// resources directory) instead of downloading them. Set once, before boot;
/// `Err` returns the path when one was already set.
+#[cfg(feature = "modules")]
pub use openhuman_core::modules::ops::set_bundled_releases_dir;
/// The browser-control module.
+#[cfg(feature = "modules")]
pub mod browser {
/// Its registry id, for a host that checks whether it is installed.
pub use openhuman_core::modules::browser::MODULE_ID;
}
+
+/// Pre-core calls through the process-wide loader, with explicit runtime configuration.
+pub use openhuman_core::modules::client::{ModuleCallError, ModuleClient};
+
+#[cfg(all(test, not(feature = "modules"), not(feature = "default")))]
+#[path = "modules_tests.rs"]
+mod tests;
diff --git a/crates/openhuman-embed/src/modules_tests.rs b/crates/openhuman-embed/src/modules_tests.rs
new file mode 100644
index 0000000000..5748762c98
--- /dev/null
+++ b/crates/openhuman-embed/src/modules_tests.rs
@@ -0,0 +1,12 @@
+use super::*;
+
+#[tokio::test]
+async fn pre_core_client_without_a_loader_returns_unavailable() {
+ let mut config = crate::config::RuntimeConfig::default();
+ config.modules.enabled = true;
+ config.modules.allow_download = false;
+ let result = ModuleClient::new(config)
+ .call::<serde_json::Value>("tinyhosts", "Providers", ())
+ .await;
+ assert_eq!(result, Err(ModuleCallError::Unavailable));
+}
diff --git a/crates/openhuman-rpc/src/lib.rs b/crates/openhuman-rpc/src/lib.rs
index 10864ea2d9..f6c95b285c 100644
--- a/crates/openhuman-rpc/src/lib.rs
+++ b/crates/openhuman-rpc/src/lib.rs
@@ -51,7 +51,6 @@ pub mod tinyhumans {
/// config/artifact/chat-surface/modules facades, plus the few process-level
/// facts. A curated list, not the crate; embed's `__host` is not on it.
pub mod embed {
- #[cfg(feature = "modules")]
pub use openhuman_tinyhumans::embed::modules;
pub use openhuman_tinyhumans::embed::{
artifacts, chat_surface, config, process, schema_for_rpc_method, CoreRuntime,
diff --git a/crates/openhuman-tinyhumans/src/lib.rs b/crates/openhuman-tinyhumans/src/lib.rs
index d92464f959..bf3169d19f 100644
--- a/crates/openhuman-tinyhumans/src/lib.rs
+++ b/crates/openhuman-tinyhumans/src/lib.rs
@@ -60,7 +60,6 @@ pub mod embed {
schema_for_rpc_method, PickListenPortError, HTTP_SERVER_COMPILED_IN, VOICE_COMPILED_IN,
};
// The curated facades (each is an explicit list inside embed).
- #[cfg(feature = "modules")]
pub use openhuman_embed::modules;
pub use openhuman_embed::{
artifacts, chat_surface, config, identity, memory, process, seams, session_store,