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
refactor(goals): isolate goal store for lost-scope callers
Steven Enamakel5e36e754f374
diff --git a/crates/openhuman-core/src/agent/goals/mod.rs b/crates/openhuman-core/src/agent/goals/mod.rsindex 9b3403b66f..9d7b44180c 100644--- a/crates/openhuman-core/src/agent/goals/mod.rs+++ b/crates/openhuman-core/src/agent/goals/mod.rs@@ -34,12 +34,7 @@ pub fn goal_store(Ok(tenant) => tenant,Err(no_tenant) => {log::warn!("[thread_goals] {no_tenant}; using throwaway in-memory store");- return Arc::new(GoalStore::with_observer(- tinyagents_session::port::InMemorySessionStores::new()- .for_agent("ephemeral")- .kv,- Arc::new(OpenHumanGoalObserver),- ));+ return isolated_goal_store();}};let stores = crate::core::runtime::slot_for::<ScopedGoalStores>(context);@@ -62,6 +57,16 @@ pub fn goal_store(store}+/// A lost-scope caller gets isolated state, without permission to publish+/// goal changes into the host's thread or web-channel event streams.+fn isolated_goal_store() -> Arc<GoalStore> {+ Arc::new(GoalStore::new(+ tinyagents_session::port::InMemorySessionStores::new()+ .for_agent("ephemeral")+ .kv,+ ))+}+struct OpenHumanGoalObserver;impl GoalObserver for OpenHumanGoalObserver {diff --git a/crates/openhuman-core/src/agent/goals/mod_tests.rs b/crates/openhuman-core/src/agent/goals/mod_tests.rsindex ea438c4756..aa5f3c7717 100644--- a/crates/openhuman-core/src/agent/goals/mod_tests.rs+++ b/crates/openhuman-core/src/agent/goals/mod_tests.rs@@ -152,3 +152,32 @@ async fn goal_store_uses_the_explicit_dispatch_context_provider() {}).await;}++#[tokio::test]+async fn isolated_goal_store_does_not_publish_thread_updates() {+ crate::core::bus::init().await.expect("bus init");+ let mut events = crate::core::bus::BUS+ .get()+ .expect("bus initialized")+ .receiver();+ let thread_id = format!("unscoped-goal-{}", uuid::Uuid::new_v4());++ isolated_goal_store()+ .set(&thread_id, "must stay private", None)+ .await+ .expect("write isolated goal");++ loop {+ match events.try_recv() {+ Ok(crate::core::events::DomainEvent::ThreadGoalUpdated {+ thread_id: event_thread,+ ..+ }) if event_thread == thread_id => {+ panic!("isolated goal mutation must not publish a thread update")+ }+ Ok(_) | Err(tinybus::TryRecvError::Lagged(_)) => continue,+ Err(tinybus::TryRecvError::Empty) => break,+ Err(tinybus::TryRecvError::Closed) => panic!("event bus closed"),+ }+ }+}