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(memory): name the stale module binding instead of a bare NotFound\n\nA folder memory source added after login syncs forever with `NotFound` even\nthough the host's config.toml has it. Only a restart clears it.\n\nThe memory module is handed `config_path` once, when it loads, and\n`ensure_loaded` is a no-op once the module is Ready — `Claim::Done(Ready)`\nreturns without looking at the `config` it was passed. `rebind_workspace` swaps\nthe host's binding under a lock and tells the module nothing. So a process that\nboots signed out loads the module against the pre-login profile, and after login\nthe host writes `[[memory_sources]]` into the real profile's config.toml while\nthe module keeps reading the old one. Every id the host registers is unknown to\nit. Staging never saw this because it always boots with a stored session, so the\nworkspace resolves before the module loads.\n\nThe binding is not repaired here, and that is deliberate. `modules/host.rs`\nstates that tinybus never unloads a library and that there is no shutdown path\nbecause there is nothing a shutdown could reclaim. Re-resolving would initialise\na second module instance over a library whose first instance is still mapped and\nstill holding its SQLite handles, with no way to tear it down — worse than the\nbug. The two workable shapes, a reconfigure entry point or per-call path\nresolution, both need a new tinymemory-module release and a registry pin bump,\nso neither can ship from this repo.\n\nWhat the host can do is stop the failure being anonymous, at both points where\nit can see it.\n\n`describe_source_sync_failure` uses a fact the host already has: `sync_rpc`\nreads its own registry three lines above, for the enabled gate. When the host\nhas the source and the driver answers NotFound, the two registries disagree, and\nthe message now says so and names the restart. A NotFound for an id the host\ndoes not have either is a genuinely missing source and passes through unchanged\n— diagnosing that as drift would send the reader down the wrong path — as does\nevery non-NotFound failure.\n\n`rebind_workspace` now warns when it rebinds while the module is already Ready,\nwhich is the moment the binding goes stale, rather than leaving a NotFound on a\nsync minutes later as the only evidence.\n\nRevert-checked: with the diagnosis reduced to a pass-through, the drift test\nfails on its own assertion, quoting the bare driver string it is meant to\nreplace (23 passed, 1 failed). Restored: 24 passed. Wider: memory::sources 47,\nruntime::context 18, modules:: 147.\n
M3gA-Mind535a130d79d9
diff --git a/src/core/runtime/context.rs b/src/core/runtime/context.rsindex a0602b4382..fe2e50c3f0 100644--- a/src/core/runtime/context.rs+++ b/src/core/runtime/context.rs@@ -99,6 +99,42 @@ struct WorkspaceBinding {memory_subsystem: crate::openhuman::config::schema::MemorySubsystemConfig,}+/// Say so when the workspace is rebound after the memory module has already+/// loaded.+///+/// The module is handed its `config_path` once, when it loads, and tinybus+/// never unloads a library — there is no shutdown path and nothing a shutdown+/// could reclaim (`modules/host.rs`). So a rebind after the module is `Ready`+/// leaves it reading the *previous* profile's source registry for the rest of+/// the process: the host writes `[[memory_sources]]` into the new profile's+/// `config.toml`, and every id it registers is unknown to the driver.+///+/// This is the boot-signed-out-then-log-in case. It cannot be repaired in+/// process, so this does not try. It makes the moment the binding went stale+/// visible in the log, beside the rebind that caused it, instead of leaving a+/// bare `NotFound` on a sync minutes later as the only evidence.+///+/// Best-effort and never fatal: a build without the modules feature, or a+/// process whose memory module never loaded, has nothing stale to report.+#[cfg(feature = "modules")]+fn warn_if_memory_module_outlived_its_profile(workspace_dir: &std::path::Path) {+ use crate::openhuman::modules::types::ModuleState;+ if crate::openhuman::modules::state_of(crate::openhuman::modules::memory::MODULE_ID)+ == ModuleState::Ready+ {+ log::warn!(+ "[core-context] workspace rebound to {} while the memory module is already loaded. \+ The module keeps the source registry it was given when it loaded and cannot be \+ rebound in this process, so memory sources registered under this profile will not \+ be visible to it until the app is restarted.",+ workspace_dir.display()+ );+ }+}++#[cfg(not(feature = "modules"))]+fn warn_if_memory_module_outlived_its_profile(_workspace_dir: &std::path::Path) {}+impl CoreContext {/// Run the core initialization sequence and return the context plus whether/// an operator-supplied RPC bearer exists (for the public-bind safety check@@ -482,6 +518,7 @@ impl CoreContext {workspace_dir: Some(workspace_dir.to_path_buf()),memory_subsystem,};+ warn_if_memory_module_outlived_its_profile(workspace_dir);Ok(())}diff --git a/src/openhuman/memory/sources/rpc_part_01.rs b/src/openhuman/memory/sources/rpc_part_01.rsindex 783df76326..574c252f20 100644--- a/src/openhuman/memory/sources/rpc_part_01.rs+++ b/src/openhuman/memory/sources/rpc_part_01.rs@@ -549,6 +549,41 @@ pub(crate) fn sync_dispatch(entry: &MemorySourceEntry) -> Result<SyncDispatch, S})}+/// Turn a source-sync failure into something a reader can act on.+///+/// A `NotFound` from the driver is ambiguous: either nobody ever registered the+/// id, or the driver is reading a different registry than the host is writing.+/// The second happens because the memory module is loaded once per process and+/// tinybus never unloads a library (`modules/ops.rs`), so the `config_path` it+/// is handed at load is the one it keeps for the life of the process. Boot+/// signed out, log in, and the host starts writing `[[memory_sources]]` into+/// the new profile's `config.toml` while the module still reads the pre-login+/// one — every id the host registers is then unknown to it, permanently.+///+/// The host can tell the two apart, because at this point it holds both halves+/// of the contradiction: `host_has_source` is its own registry's answer for the+/// same id. When the host has it and the driver does not, the registries+/// disagree, and the only in-process remedy is a restart — the same remedy+/// `ops` already states for a module that failed to load.+///+/// Every other failure is returned exactly as the driver stated it; inventing a+/// diagnosis for those would send the reader down the wrong path.+fn describe_source_sync_failure(+ source_id: &str,+ host_has_source: bool,+ error: &crate::openhuman::memory::api::error::MemoryError,+) -> String {+ match error {+ crate::openhuman::memory::api::error::MemoryError::NotFound(_) if host_has_source => format!(+ "the memory module cannot see source '{source_id}', but this profile has it \+ registered. The module is bound to a different profile's source registry — it \+ reads the config it was given when it first loaded, and that binding cannot be \+ changed while the app is running. Restart the app to rebind it."+ ),+ other => other.to_string(),+ }+}+pub async fn sync_rpc(req: SyncRequest) -> Result<RpcOutcome<SyncResponse>, String> {tracing::info!(source_id = %req.source_id, "[memory_sources] sync_rpc: entry");@@ -565,7 +600,11 @@ pub async fn sync_rpc(req: SyncRequest) -> Result<RpcOutcome<SyncResponse>, Stri// that refuse a disabled entry, and this RPC is the third caller, the one// behind the user's Sync button. Same words as `sync_source` so the UI// reads one message (#5820).- if let Some(entry) = super::registry::get_source_in(&config, &req.source_id)? {+ // Kept past the `if let` because the failure path below needs the host's own+ // answer for this id: a driver `NotFound` means something different when the+ // host has the source than when it does not.+ let host_entry = super::registry::get_source_in(&config, &req.source_id)?;+ if let Some(entry) = &host_entry {if !entry.enabled {return Err(format!("source '{}' is disabled", entry.id));}@@ -575,7 +614,7 @@ pub async fn sync_rpc(req: SyncRequest) -> Result<RpcOutcome<SyncResponse>, Striif let SyncDispatch::Connector {connection_id,max_items,- } = sync_dispatch(&entry)?+ } = sync_dispatch(entry)?{crate::openhuman::integrations::composio::ops::composio_sync_budgeted(&config,@@ -606,7 +645,9 @@ pub async fn sync_rpc(req: SyncRequest) -> Result<RpcOutcome<SyncResponse>, Stri})?;sync.run_source_sync(&req.source_id).await- .map_err(|error| error.to_string())?;+ .map_err(|error| {+ describe_source_sync_failure(&req.source_id, host_entry.is_some(), &error)+ })?;Ok(RpcOutcome::new(SyncResponse {diff --git a/src/openhuman/memory/sources/rpc_tests.rs b/src/openhuman/memory/sources/rpc_tests.rsindex cf8fffcf6e..e8bc5f0367 100644--- a/src/openhuman/memory/sources/rpc_tests.rs+++ b/src/openhuman/memory/sources/rpc_tests.rs@@ -9,6 +9,7 @@use super::*;use crate::core::subsystem::DriverClass;+use crate::openhuman::memory::api::error::MemoryError;// Needed to call the family accessors on the *concrete* null provider// below; the handlers above reach them through `dyn MemoryProvider`, where// the trait is in scope by construction.@@ -311,3 +312,63 @@ async fn add_generates_an_id_and_caps_a_request_that_left_its_limits_unset() {"the request's url");}++// ── Profile-drift diagnosis on sync (#5820 follow-up) ────────────────────────+//+// The memory module is loaded once per process and tinybus never unloads a+// library, so the `config_path` it is handed at load is the one it keeps. When+// the host rebinds its workspace mid-process — boot signed out, then log in —+// the host starts writing `[[memory_sources]]` into the new profile's+// config.toml while the module is still reading the old one. Every id the host+// registers is then unknown to the driver, and the user sees a bare+// `NotFound` that reads like a missing source rather than a stale binding.+//+// The host holds both halves of that contradiction at the point of failure: its+// own registry has the id, and the driver says it does not. Saying so is the+// difference between a ten-minute diagnosis and half a day.++#[test]+fn a_not_found_for_a_source_the_host_has_registered_reports_the_stale_binding() {+ let message = describe_source_sync_failure(+ "src_8cc5c81a3a7b482b8f832a84faaa6c4e",+ true,+ &MemoryError::NotFound(+ "no memory source registered as src_8cc5c81a3a7b482b8f832a84faaa6c4e".to_string(),+ ),+ );+ assert!(+ message.contains("different profile") || message.contains("restart"),+ "a NotFound for an id the host DID register must name the stale binding and the \+ remedy, not repeat the driver's 'no memory source registered' — got: {message}"+ );+ assert!(+ message.contains("src_8cc5c81a3a7b482b8f832a84faaa6c4e"),+ "the message must still name the source id: {message}"+ );+}++#[test]+fn a_not_found_for_an_id_the_host_never_registered_is_passed_through() {+ let message = describe_source_sync_failure(+ "src_never_existed",+ false,+ &MemoryError::NotFound("no memory source registered as src_never_existed".to_string()),+ );+ assert!(+ !message.contains("different profile"),+ "an id the host does not have either is a genuinely missing source, not drift — \+ diagnosing it as a stale binding would send the reader down the wrong path: {message}"+ );+}++#[test]+fn a_non_not_found_failure_is_passed_through_unchanged() {+ let inner = MemoryError::Backend("sqlite is locked".to_string());+ let message = describe_source_sync_failure("src_1", true, &inner);+ assert_eq!(+ message,+ inner.to_string(),+ "only NotFound is ambiguous between 'missing' and 'stale binding'; every other \+ failure must reach the caller as the driver stated it"+ );+}