Skip to content

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

chore: apply rustfmt and refresh saas ambient baseline

Steven Enamakel8a9db9d82898
diff --git a/crates/openhuman-core/src/agent/orchestration/background_completions_tenant_tests.rs b/crates/openhuman-core/src/agent/orchestration/background_completions_tenant_tests.rs
index 6c1d42fa04..784d22301a 100644
--- a/crates/openhuman-core/src/agent/orchestration/background_completions_tenant_tests.rs
+++ b/crates/openhuman-core/src/agent/orchestration/background_completions_tenant_tests.rs
@@ -29,7 +29,10 @@ async fn record(ctx: &Arc<CoreContext>, ws: &std::path::Path, task: &str) {
}
fn pending(ws: &std::path::Path) -> Vec<String> {
- pending_for(ws, "t1").into_iter().map(|r| r.task_id).collect()
+ pending_for(ws, "t1")
+ .into_iter()
+ .map(|r| r.task_id)
+ .collect()
}
#[tokio::test]
@@ -86,8 +89,14 @@ fn a_saas_cancel_reaches_only_the_callers_workspace() {
use super::running_subagents::{caller_workspace_in, CallerWorkspace};
let ws = TestWorkspace::new();
let alice = profile("u-alice", ws.path());
- assert!(matches!(caller_workspace_in(false, None), CallerWorkspace::All));
- assert!(matches!(caller_workspace_in(true, None), CallerWorkspace::Nothing));
+ assert!(matches!(
+ caller_workspace_in(false, None),
+ CallerWorkspace::All
+ ));
+ assert!(matches!(
+ caller_workspace_in(true, None),
+ CallerWorkspace::Nothing
+ ));
match caller_workspace_in(true, Some(&alice)) {
CallerWorkspace::Only(dir) => assert_eq!(dir, ws.path()),
_ => panic!("a scoped SaaS caller reaches its own workspace"),
diff --git a/crates/openhuman-core/src/core/runtime/tenant.rs b/crates/openhuman-core/src/core/runtime/tenant.rs
index dceda28c16..e43abb3a58 100644
--- a/crates/openhuman-core/src/core/runtime/tenant.rs
+++ b/crates/openhuman-core/src/core/runtime/tenant.rs
@@ -116,7 +116,10 @@ pub fn current_tenant_or_isolated(site: &str) -> Tenant {
/// share. With no profile (the desktop, embedded agents) it is the bare id,
/// as before. A SaaS task with no scope gets a key nothing else shares.
pub fn profile_key(id: &str) -> String {
- tenant_key(&current_tenant_or_isolated("profile_key").profile_only(), id)
+ tenant_key(
+ &current_tenant_or_isolated("profile_key").profile_only(),
+ id,
+ )
}
/// Profile prefix byte of a [`tenant_key`].
diff --git a/crates/openhuman-core/src/core/runtime/tenant_tests.rs b/crates/openhuman-core/src/core/runtime/tenant_tests.rs
index 42ae79c703..6c09088bbc 100644
--- a/crates/openhuman-core/src/core/runtime/tenant_tests.rs
+++ b/crates/openhuman-core/src/core/runtime/tenant_tests.rs
@@ -45,7 +45,11 @@ fn a_derived_context_inherits_the_profile_and_a_profile_gets_fresh_slots() {
// A plain derive (a turn context) keeps the profile and its slots.
let turn = profile.derive_with(overlay());
assert_eq!(turn.profile(), Some("p1"));
- *turn.agent_state().slot::<std::sync::Mutex<u32>>().lock().unwrap() = 7;
+ *turn
+ .agent_state()
+ .slot::<std::sync::Mutex<u32>>()
+ .lock()
+ .unwrap() = 7;
assert_eq!(
*profile
.agent_state()
@@ -84,12 +88,18 @@ fn a_tenant_is_in_use_while_a_turn_context_or_a_handle_lives() {
assert!(!profile.tenant_in_use());
let turn = profile.derive_with(overlay());
- assert!(profile.tenant_in_use(), "a live turn context shares the slots");
+ assert!(
+ profile.tenant_in_use(),
+ "a live turn context shares the slots"
+ );
drop(turn);
assert!(!profile.tenant_in_use());
let handle = Arc::clone(&profile);
- assert!(profile.tenant_in_use(), "a second handle (a request, a task)");
+ assert!(
+ profile.tenant_in_use(),
+ "a second handle (a request, a task)"
+ );
drop(handle);
assert!(!profile.tenant_in_use());
@@ -168,5 +178,8 @@ async fn profile_keys_drop_the_agent() {
assert_eq!(key, tenant_key(&tenant(Some("p1"), None), "t1"));
let agent_only = root.derive_with(overlay().session_agent("a1"));
let key = CoreContext::scope(agent_only, async { profile_key("t1") }).await;
- assert_eq!(key, "t1", "no profile: the bare id, embedded agents included");
+ assert_eq!(
+ key, "t1",
+ "no profile: the bare id, embedded agents included"
+ );
}
diff --git a/crates/openhuman-core/src/platform/cost/global.rs b/crates/openhuman-core/src/platform/cost/global.rs
index 85a25f4531..8d23a15561 100644
--- a/crates/openhuman-core/src/platform/cost/global.rs
+++ b/crates/openhuman-core/src/platform/cost/global.rs
@@ -146,7 +146,10 @@ pub(crate) struct TenantTracker(RwLock<Option<Arc<CostTracker>>>);
/// Give `ctx` (a SaaS profile's context) a cost tracker over the profile's
/// own workspace. Called when the profile opens; a failure leaves it without
/// one (its usage goes unrecorded) rather than borrowing another ledger.
-pub fn seed_tenant_tracker(ctx: &crate::core::runtime::CoreContext, config: &crate::config::Config) {
+pub fn seed_tenant_tracker(
+ ctx: &crate::core::runtime::CoreContext,
+ config: &crate::config::Config,
+) {
match CostTracker::new(config.cost.clone(), &config.workspace_dir) {
Ok(tracker) => {
*ctx.agent_state().slot::<TenantTracker>().0.write() = Some(Arc::new(tracker));
@@ -163,7 +166,9 @@ pub fn seed_tenant_tracker(ctx: &crate::core::runtime::CoreContext, config: &cra
}
/// The tracker `ctx` was seeded with; `None` without a context.
-pub(crate) fn tracker_in(ctx: Option<&crate::core::runtime::CoreContext>) -> Option<Arc<CostTracker>> {
+pub(crate) fn tracker_in(
+ ctx: Option<&crate::core::runtime::CoreContext>,
+) -> Option<Arc<CostTracker>> {
ctx.and_then(|ctx| ctx.agent_state().slot::<TenantTracker>().0.read().clone())
}
diff --git a/crates/openhuman-core/src/user_agents/host_tests.rs b/crates/openhuman-core/src/user_agents/host_tests.rs
index 7aafc04558..1da470faa1 100644
--- a/crates/openhuman-core/src/user_agents/host_tests.rs
+++ b/crates/openhuman-core/src/user_agents/host_tests.rs
@@ -271,7 +271,10 @@ async fn an_open_agent_is_gated_by_its_own_policy_not_the_operators() {
let state = host.open(&id).unwrap();
assert_eq!(state.context().profile(), Some(id.as_str()));
- let own = state.context().agent_policy().expect("the profile carries a policy");
+ let own = state
+ .context()
+ .agent_policy()
+ .expect("the profile carries a policy");
assert!(own.enabled, "the forced autonomy policy is on");
assert!(own.workspace_only);
let effective = CoreContext::scope(Arc::clone(state.context()), async {
diff --git a/crates/openhuman-core/src/web_chat/ops.rs b/crates/openhuman-core/src/web_chat/ops.rs
index 9090afca2c..74df8a8ddb 100644
--- a/crates/openhuman-core/src/web_chat/ops.rs
+++ b/crates/openhuman-core/src/web_chat/ops.rs
@@ -34,11 +34,11 @@ pub(crate) use state::in_flight;
pub use state::parallel_in_flight_entries_for_test;
#[cfg(test)]
pub(crate) use state::scoped_key;
-#[cfg(test)]
-pub(crate) use state::{key_in, unscope_in};
pub(super) use state::thread_sessions;
pub use state::{cancel_should_target, in_flight_entries_for_test, invalidate_thread_sessions};
pub(crate) use state::{event_session_id_for, key_for};
+#[cfg(test)]
+pub(crate) use state::{key_in, unscope_in};
#[cfg(any(test, debug_assertions))]
pub use test_hooks::set_test_forced_run_chat_task_error;
diff --git a/scripts/ci/saas-ambient-baseline.json b/scripts/ci/saas-ambient-baseline.json
index fe8978e3a3..199afc24a4 100644
--- a/scripts/ci/saas-ambient-baseline.json
+++ b/scripts/ci/saas-ambient-baseline.json
@@ -13,6 +13,27 @@
"text": "let config = crate::config::Config::load_or_init().await?;",
"occurrence": 1
},
+ {
+ "rule": "ambient-context",
+ "path": "crates/openhuman-core/src/agent/harness/definition/registry.rs",
+ "line": 158,
+ "text": "crate::core::runtime::CoreContext::current()",
+ "occurrence": 1
+ },
+ {
+ "rule": "ambient-context",
+ "path": "crates/openhuman-core/src/agent/harness/graph.rs",
+ "line": 185,
+ "text": "let outcome = match (turn_origin, crate::core::runtime::CoreContext::current()) {",
+ "occurrence": 1
+ },
+ {
+ "rule": "ambient-context",
+ "path": "crates/openhuman-core/src/agent/hooks.rs",
+ "line": 296,
+ "text": "let core_ctx = crate::core::runtime::context::CoreContext::current();",
+ "occurrence": 1
+ },
{
"rule": "bare-spawn",
"path": "crates/openhuman-core/src/agent/hooks.rs",
@@ -97,6 +118,13 @@
"text": "let config = crate::config::Config::load_or_init()",
"occurrence": 1
},
+ {
+ "rule": "ambient-context",
+ "path": "crates/openhuman-core/src/agent/session_store/mod.rs",
+ "line": 211,
+ "text": "crate::core::runtime::CoreContext::current()",
+ "occurrence": 1
+ },
{
"rule": "bare-spawn",
"path": "crates/openhuman-core/src/agent/subagent_host/ops/graph/dispatch.rs",
@@ -104,6 +132,20 @@
"text": "tokio::spawn(async move {",
"occurrence": 1
},
+ {
+ "rule": "ambient-context",
+ "path": "crates/openhuman-core/src/agent/tinyagents/tools.rs",
+ "line": 210,
+ "text": "let execution = match (origin, crate::core::runtime::CoreContext::current()) {",
+ "occurrence": 1
+ },
+ {
+ "rule": "ambient-context",
+ "path": "crates/openhuman-core/src/agent/turn_origin.rs",
+ "line": 205,
+ "text": "let context = crate::core::runtime::CoreContext::current()",
+ "occurrence": 1
+ },
{
"rule": "bare-spawn",
"path": "crates/openhuman-core/src/agent/turn_origin.rs",
@@ -111,6 +153,13 @@
"text": "tokio::spawn(propagate(fut))",
"occurrence": 1
},
+ {
+ "rule": "ambient-context",
+ "path": "crates/openhuman-core/src/backend/transport/install.rs",
+ "line": 86,
+ "text": "if let Some(transport) = crate::core::runtime::context::CoreContext::current()",
+ "occurrence": 1
+ },
{
"rule": "home-dir",
"path": "crates/openhuman-core/src/channels/host/adapters.rs",
@@ -121,14 +170,14 @@
{
"rule": "bare-spawn",
"path": "crates/openhuman-core/src/channels/runtime/dispatch/processor/turn.rs",
- "line": 114,
+ "line": 131,
"text": "_acknowledgment_task = Some(AbortOnDropHandle::new(tokio::spawn(async move {",
"occurrence": 1
},
{
"rule": "bare-spawn",
"path": "crates/openhuman-core/src/channels/runtime/dispatch/processor/turn.rs",
- "line": 234,
+ "line": 251,
"text": "Some(AbortOnDropHandle::new(tokio::spawn(async move {",
"occurrence": 1
},
@@ -307,6 +356,20 @@
"text": "std::env::set_var(\"RUST_LOG\", \"error\");",
"occurrence": 1
},
+ {
+ "rule": "ambient-context",
+ "path": "crates/openhuman-core/src/core/all.rs",
+ "line": 78,
+ "text": "crate::core::runtime::context::CoreContext::current().map(|c| c.domains())",
+ "occurrence": 1
+ },
+ {
+ "rule": "ambient-context",
+ "path": "crates/openhuman-core/src/core/all.rs",
+ "line": 1206,
+ "text": "let scoped: ControllerFuture = match CoreContext::current() {",
+ "occurrence": 1
+ },
{
"rule": "env-mutation",
"path": "crates/openhuman-core/src/core/logging.rs",
@@ -317,14 +380,14 @@
{
"rule": "home-dir",
"path": "crates/openhuman-core/src/core/runtime/context.rs",
- "line": 207,
+ "line": 210,
"text": "dirs::home_dir()",
"occurrence": 1
},
{
"rule": "ambient-config",
"path": "crates/openhuman-core/src/core/runtime/context.rs",
- "line": 232,
+ "line": 235,
"text": "None => crate::config::Config::load_or_init().await,",
"occurrence": 1
},
@@ -538,6 +601,13 @@
"text": ".map(|d| d.home_dir().join(\".openhuman\"))",
"occurrence": 1
},
+ {
+ "rule": "ambient-context",
+ "path": "crates/openhuman-core/src/inference/provider/factory/access_gates.rs",
+ "line": 212,
+ "text": "crate::core::runtime::context::CoreContext::current()",
+ "occurrence": 1
+ },
{
"rule": "home-dir",
"path": "crates/openhuman-core/src/inference/provider/openhuman_backend_model.rs",
@@ -986,6 +1056,13 @@
"text": "tokio::task::spawn_blocking(do_write);",
"occurrence": 1
},
+ {
+ "rule": "ambient-context",
+ "path": "crates/openhuman-core/src/skills/write_root.rs",
+ "line": 25,
+ "text": "let workspace = crate::core::runtime::CoreContext::current()?",
+ "occurrence": 1
+ },
{
"rule": "bare-spawn",
"path": "crates/openhuman-core/src/threads/ops/edit.rs",
@@ -1014,6 +1091,13 @@
"text": "Config::load_or_init()",
"occurrence": 1
},
+ {
+ "rule": "ambient-context",
+ "path": "crates/openhuman-core/src/threads/ops/support.rs",
+ "line": 49,
+ "text": "let ctx = CoreContext::current();",
+ "occurrence": 1
+ },
{
"rule": "bare-spawn",
"path": "crates/openhuman-core/src/threads/ops/support.rs",
@@ -1049,6 +1133,13 @@
"text": "loaded_config = match crate::config::Config::load_or_init().await {",
"occurrence": 1
},
+ {
+ "rule": "ambient-context",
+ "path": "crates/openhuman-core/src/tools/ops.rs",
+ "line": 926,
+ "text": "let domains = crate::core::runtime::context::CoreContext::current().map(|c| c.domains());",
+ "occurrence": 1
+ },
{
"rule": "ambient-config",
"path": "crates/openhuman-core/src/tools/registry/ops.rs",
@@ -1056,6 +1147,13 @@
"text": "let config = Config::load_or_init().await.map_err(|err| {",
"occurrence": 1
},
+ {
+ "rule": "ambient-context",
+ "path": "crates/openhuman-core/src/tools/toolpacks/groups.rs",
+ "line": 188,
+ "text": "crate::core::runtime::context::CoreContext::current().map(|c| c.tool_groups()),",
+ "occurrence": 1
+ },
{
"rule": "bare-spawn",
"path": "crates/openhuman-core/src/voice/always_on/lock_watcher.rs",
@@ -1213,7 +1311,7 @@
{
"rule": "bare-spawn",
"path": "crates/openhuman-core/src/web_chat/ops/state.rs",
- "line": 111,
+ "line": 113,
"text": "tokio::spawn(async move {",
"occurrence": 1
},