Skip to content

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

fix(review): typed version-gap; policy publish owned by the module host

Shanue95378505b8c
diff --git a/src/core/cli.rs b/src/core/cli.rs
index 9dba111116..1082a2d998 100644
--- a/src/core/cli.rs
+++ b/src/core/cli.rs
@@ -507,18 +507,11 @@ fn run_call_command(args: &[String]) -> Result<()> {
// fails with "the module host policy was never published"
// without this — the same per-process publish the memory and
// tree-summarizer subcommand families already do.
+ // One line by design: `src/core/` is transport, and the load-
+ // config-install-sink-publish-policy sequence lives with the
+ // module host in the openhuman layer (review finding on #5932).
#[cfg(feature = "modules")]
- {
- // Propagated, not discarded: a method that crosses the module
- // binding would otherwise run against an unpublished policy
- // and fail with the misleading "policy was never published"
- // (review finding) — the config error is the true cause.
- let config = crate::openhuman::config::Config::load_or_init()
- .await
- .map_err(|error| format!("load config for module policy: {error}"))?;
- crate::openhuman::memory::host::install_memory_event_sink();
- crate::openhuman::modules::memory::set_modules_policy(std::sync::Arc::new(config));
- }
+ crate::openhuman::modules::memory::publish_cli_boot_policy().await?;
invoke_method(default_state(), &method, params).await
})
.map_err(anyhow::Error::msg)?;
diff --git a/src/openhuman/memory/ops/sync.rs b/src/openhuman/memory/ops/sync.rs
index bd97c4646d..3b2251f851 100644
--- a/src/openhuman/memory/ops/sync.rs
+++ b/src/openhuman/memory/ops/sync.rs
@@ -387,21 +387,19 @@ pub async fn memory_scheduler_override(
.override_scheduler_gate(seconds)
.await
.map_err(|error| {
- let rendered = error.to_string();
- // Against the released v1.13.6 module the member does not
- // exist yet (it ships in tinymemory#127), and the bus answers
- // with a member-resolution error. An operator running this
- // today should read a version gap, not an internal fault
- // (review finding on #5932).
- if rendered.contains("MemberNotFound")
- || rendered.contains("UnknownMethod")
- || rendered.contains("no such member")
- {
+ // Typed version-gap detection: the provider maps a module
+ // that predates the member (tinybus UnknownMethod) onto
+ // `MemoryError::Unsupported`, so this match is on the type,
+ // not on error prose (review finding on #5932).
+ if matches!(
+ error,
+ crate::openhuman::memory::api::error::MemoryError::Unsupported { .. }
+ ) {
"this build's memory module does not support the scheduler override \
(requires tinymemory >= 1.13.7)"
.to_string()
} else {
- format!("scheduler override: {rendered}")
+ format!("scheduler override: {error}")
}
})?;
Ok(RpcOutcome::new(
diff --git a/src/openhuman/memory/tree/tree_runtime/cli.rs b/src/openhuman/memory/tree/tree_runtime/cli.rs
index da774ab716..e93a501bdf 100644
--- a/src/openhuman/memory/tree/tree_runtime/cli.rs
+++ b/src/openhuman/memory/tree/tree_runtime/cli.rs
@@ -341,22 +341,24 @@ fn build_runtime() -> Result<tokio::runtime::Runtime> {
}
async fn load_config() -> Result<crate::openhuman::config::Config> {
- let mut config = crate::openhuman::config::Config::load_or_init()
- .await
- .unwrap_or_default();
- config.apply_env_overrides();
-
- // Every subcommand reaches the memory driver, and since the round-2
- // migration that is a module binding: without the host policy published
- // the driver binds but its first call fails with "the module host policy
- // was never published". The server publishes it during boot; this CLI is
- // its own process and must do the same (the `memory` subcommand family
- // already does, in memory_cli.rs). Idempotent, so once per load is fine.
- crate::openhuman::memory::host::install_memory_event_sink();
+ // Every subcommand reaches the memory driver over the module binding, and
+ // this CLI is its own process: the shared helper loads config, installs
+ // the event sink and publishes the module host policy exactly as the
+ // server's boot does (one sequence, owned by the module host — #5932).
#[cfg(feature = "modules")]
- crate::openhuman::modules::memory::set_modules_policy(std::sync::Arc::new(config.clone()));
-
- Ok(config)
+ {
+ crate::openhuman::modules::memory::publish_cli_boot_policy()
+ .await
+ .map_err(|error| anyhow::anyhow!(error))
+ }
+ #[cfg(not(feature = "modules"))]
+ {
+ let mut config = crate::openhuman::config::Config::load_or_init()
+ .await
+ .unwrap_or_default();
+ config.apply_env_overrides();
+ Ok(config)
+ }
}
fn init_logging(verbose: bool) {
diff --git a/src/openhuman/modules/memory_part_01.rs b/src/openhuman/modules/memory_part_01.rs
index b37b9f3636..bd00b6c02e 100644
--- a/src/openhuman/modules/memory_part_01.rs
+++ b/src/openhuman/modules/memory_part_01.rs
@@ -204,6 +204,25 @@ static MODULES_POLICY: std::sync::OnceLock<Arc<Config>> = std::sync::OnceLock::n
/// Call once during boot, before any workspace is bound. Later calls are
/// ignored — a driver already resolved against the first value must not have the
/// policy change underneath it.
+/// Load config and publish the module host policy, for a CLI process.
+///
+/// The server does this during boot; every CLI family that crosses the memory
+/// module binding (`memory`, `tree-summarizer`, the raw `call` dispatcher) is
+/// its own process and must do the same before its first driver call, or that
+/// call fails with "the module host policy was never published". One helper so
+/// the sequence lives in the openhuman layer — `src/core/` is transport and
+/// carries a one-line call, not the business of loading config and installing
+/// sinks (review finding on #5932).
+pub async fn publish_cli_boot_policy() -> Result<Config, String> {
+ let mut config = Config::load_or_init()
+ .await
+ .map_err(|error| format!("load config for module policy: {error}"))?;
+ config.apply_env_overrides();
+ crate::openhuman::memory::host::install_memory_event_sink();
+ set_modules_policy(Arc::new(config.clone()));
+ Ok(config)
+}
+
pub fn set_modules_policy(config: Arc<Config>) {
let _ = MODULES_POLICY.set(config);
}
diff --git a/src/openhuman/modules/memory_part_02.rs b/src/openhuman/modules/memory_part_02.rs
index 2c0f33373a..ddd30c554c 100644
--- a/src/openhuman/modules/memory_part_02.rs
+++ b/src/openhuman/modules/memory_part_02.rs
@@ -705,11 +705,21 @@ impl ModuleMemoryProvider {
/// embedding's vocabulary. The module serves it as a plain member
/// (`OverrideSchedulerGate`), and only this host client names it.
pub(crate) async fn override_scheduler_gate(&self, seconds: u64) -> Result<(), MemoryError> {
- module_call!(
- self,
- "override_scheduler_gate",
- methods::OVERRIDE_SCHEDULER_GATE,
- (seconds,)
- )
+ self.proxy("override_scheduler_gate")
+ .await?
+ .call(methods::OVERRIDE_SCHEDULER_GATE, (seconds,))
+ .await
+ .map_err(|error| {
+ // Typed, not text-matched: a module predating the member
+ // answers `tinybus::Error::UnknownMethod`, and mapping that
+ // variant to `Unsupported` here lets the RPC report a version
+ // gap on the type rather than by grepping arbitrary error
+ // strings (review finding on #5932).
+ if matches!(error, tinybus::Error::UnknownMethod { .. }) {
+ MemoryError::unsupported_raw("scheduler_override")
+ } else {
+ from_bus(&error)
+ }
+ })
}
}