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(orchestration): scope background delivery and subagent state per profile
Steven Enamakelde0f67d7178f
diff --git a/crates/openhuman-core/src/agent/orchestration/background_completions.rs b/crates/openhuman-core/src/agent/orchestration/background_completions.rsindex e04a0288d3..96fd77adec 100644--- a/crates/openhuman-core/src/agent/orchestration/background_completions.rs+++ b/crates/openhuman-core/src/agent/orchestration/background_completions.rs@@ -21,12 +21,16 @@//! stays in [`super::background_delivery`]. The wording is//! [`super::completion_notice`].+use crate::core::runtime::DispatchCtx;use std::collections::{HashMap, HashSet, VecDeque};// Keys of `HostState`'s thread and session maps: per profile (see `profile_key`)./// The key of a thread or session id in `HostState`'s maps: per profile of `ctx`'s tenant.-fn key(ctx: &crate::core::runtime::DispatchCtx, id: &str) -> String {+fn key(ctx: &DispatchCtx, id: &str) -> String {use crate::core::runtime::tenant;- tenant::profile_key_in(&tenant::isolated_unless_tenant(ctx.tenant(), "profile_key"), id)+ tenant::profile_key_in(+ &tenant::isolated_unless_tenant(ctx.tenant(), "profile_key"),+ id,+ )}use std::path::{Path, PathBuf};use std::sync::{Arc, Mutex, OnceLock};@@ -196,7 +200,7 @@ pub(crate) fn router_for_workspace(workspace_dir: &Path) -> Arc<CompletionRouter}/// Remember which workspace holds `thread_id`'s completions.-fn note_thread_workspace(ctx: &crate::core::runtime::DispatchCtx, thread_id: &str, workspace_dir: &Path) {+fn note_thread_workspace(ctx: &DispatchCtx, thread_id: &str, workspace_dir: &Path) {state().thread_workspaces.insert(key(ctx, thread_id), workspace_dir.to_path_buf());@@ -204,18 +208,24 @@ fn note_thread_workspace(ctx: &crate::core::runtime::DispatchCtx, thread_id: &st/// The router that holds `thread_id`'s completions, if any child of that thread/// was spawned or recorded in this process.-pub(crate) fn router_for_thread(ctx: &crate::core::runtime::DispatchCtx, thread_id: &str) -> Option<Arc<CompletionRouter>> {- let workspace = state().thread_workspaces.get(&key(ctx, thread_id)).cloned()?;+pub(crate) fn router_for_thread(+ ctx: &DispatchCtx,+ thread_id: &str,+) -> Option<Arc<CompletionRouter>> {+ let workspace = state()+ .thread_workspaces+ .get(&key(ctx, thread_id))+ .cloned()?;Some(router_for_workspace(&workspace))}/// The workspace holding `thread_id`'s completions, if known to this process.-pub(crate) fn workspace_for_thread(ctx: &crate::core::runtime::DispatchCtx, thread_id: &str) -> Option<PathBuf> {+pub(crate) fn workspace_for_thread(ctx: &DispatchCtx, thread_id: &str) -> Option<PathBuf> {state().thread_workspaces.get(&key(ctx, thread_id)).cloned()}/// Remember that `session_id` is a turn on `thread_id`.-pub(crate) fn note_session_thread(ctx: &crate::core::runtime::DispatchCtx, session_id: &str, thread_id: &str) {+pub(crate) fn note_session_thread(ctx: &DispatchCtx, session_id: &str, thread_id: &str) {let session_key = key(ctx, session_id);let mut st = state();if st@@ -234,7 +244,7 @@ pub(crate) fn note_session_thread(ctx: &crate::core::runtime::DispatchCtx, sessi/// The chat thread a session id belongs to: the cached mapping, else the/// `thread_id` a web-channel session id carries in its JSON body.-pub(crate) fn thread_for_session(ctx: &crate::core::runtime::DispatchCtx, session_id: &str) -> Option<String> {+pub(crate) fn thread_for_session(ctx: &DispatchCtx, session_id: &str) -> Option<String> {if let Some(thread) = state().session_threads.get(&key(ctx, session_id)) {return Some(thread.clone());}@@ -251,7 +261,7 @@ pub(crate) fn thread_for_session(ctx: &crate::core::runtime::DispatchCtx, sessio/// Record a finished background sub-agent for idle delivery, keyed by its/// parent chat thread. Idempotent on `task_id`.pub(crate) async fn record_completion(- ctx: &crate::core::runtime::DispatchCtx,+ ctx: &DispatchCtx,workspace_dir: &Path,parent_session: &str,task_id: impl Into<String>,@@ -281,7 +291,7 @@ pub(crate) async fn record_completion(/// The router drops the record when its task was tombstoned (collected inline,/// stopped) or its thread was cancelled (deleted, stopped).pub(crate) async fn record_outcome(- ctx: &crate::core::runtime::DispatchCtx,+ ctx: &DispatchCtx,workspace_dir: &Path,parent_session: &str,task_id: impl Into<String>,@@ -387,7 +397,7 @@ pub(crate) async fn record_outcome(/// relay, so the user learns the delegated task errored instead of the turn/// silently finalizing on "Accepted".pub(crate) async fn record_failure(- ctx: &crate::core::runtime::DispatchCtx,+ ctx: &DispatchCtx,workspace_dir: &Path,parent_session: &str,task_id: impl Into<String>,@@ -415,7 +425,7 @@ pub(crate) async fn record_failure(/// the framed `[SUBAGENT_NEEDS_INPUT]` notice is delivered back into chat for the/// parent agent to relay to (or answer for) the user.pub(crate) async fn record_awaiting_input(- ctx: &crate::core::runtime::DispatchCtx,+ ctx: &DispatchCtx,workspace_dir: &Path,parent_session: &str,task_id: impl Into<String>,@@ -522,7 +532,11 @@ pub(crate) fn mark_collected(workspace_dir: &Path, task_id: &str) -> bool {/// delivered into a thread that no longer exists. Takes the caller's workspace so/// the marker is written even when no child of the thread was seen by this/// process. Returns the number of queued completions removed.-pub(crate) fn discard_for_thread(ctx: &crate::core::runtime::DispatchCtx, workspace_dir: &Path, thread_id: &str) -> usize {+pub(crate) fn discard_for_thread(+ ctx: &DispatchCtx,+ workspace_dir: &Path,+ thread_id: &str,+) -> usize {let seen = {let thread_key = key(ctx, thread_id);let mut st = state();@@ -594,7 +608,7 @@ fn cancel_deleted_parent(entry: &Entry, thread_id: &str) -> usize {/// gate lifts at [`resume_stopped_thread`] (the next accepted user turn), while/// the stopped generation's task ids stay tombstoned/// ([`finish_stop_for_thread`]). Returns the number of queued completions removed.-pub(crate) fn discard_pending_for_thread(ctx: &crate::core::runtime::DispatchCtx, thread_id: &str) -> usize {+pub(crate) fn discard_pending_for_thread(ctx: &DispatchCtx, thread_id: &str) -> usize {state().stopped_threads.insert(key(ctx, thread_id));let Some(router) = router_for_thread(ctx, thread_id) else {return 0;@@ -614,7 +628,7 @@ pub(crate) fn discard_pending_for_thread(ctx: &crate::core::runtime::DispatchCtx/// Complete a Stop after its registered children were aborted: tombstone their/// task ids so a straggler from the stopped generation cannot record once a/// later user turn reopens the thread.-pub(crate) fn finish_stop_for_thread(ctx: &crate::core::runtime::DispatchCtx, thread_id: &str, task_ids: &[String]) {+pub(crate) fn finish_stop_for_thread(ctx: &DispatchCtx, thread_id: &str, task_ids: &[String]) {let Some(router) = router_for_thread(ctx, thread_id) else {return;};@@ -632,7 +646,7 @@ pub(crate) fn finish_stop_for_thread(ctx: &crate::core::runtime::DispatchCtx, th/// Stop is pressed. New task ids remain distinct from the stopped generation./// Only a thread this process stopped or cancelled pays for the durable resume/// marker, so an ordinary chat message writes nothing.-pub(crate) fn resume_stopped_thread(ctx: &crate::core::runtime::DispatchCtx, thread_id: &str) {+pub(crate) fn resume_stopped_thread(ctx: &DispatchCtx, thread_id: &str) {let was_stopped = state().stopped_threads.remove(&key(ctx, thread_id));if !was_stopped {return;@@ -655,7 +669,7 @@ pub(crate) fn resume_stopped_thread(ctx: &crate::core::runtime::DispatchCtx, thr/// restart): a live spawn proves the user re-engaged the thread. Returns whether/// the child must be aborted.pub(crate) fn mark_stopped_task_if_thread_stopped(- ctx: &crate::core::runtime::DispatchCtx,+ ctx: &DispatchCtx,workspace_dir: &Path,thread_id: &str,task_id: &str,@@ -694,7 +708,7 @@ pub(crate) fn mark_stopped_task_if_thread_stopped(/// purge of that workspace; each thread with undelivered results is cancelled/// durably (and remembered as deleted), so stragglers are still dropped. Other/// workspaces are untouched. Returns the number of completions removed.-pub(crate) fn clear_all(ctx: &crate::core::runtime::DispatchCtx, workspace_dir: &Path) -> usize {+pub(crate) fn clear_all(ctx: &DispatchCtx, workspace_dir: &Path) -> usize {let entry = entry_for(workspace_dir);let parents: HashSet<String> = entry.store@@ -716,7 +730,7 @@ pub(crate) fn clear_all(ctx: &crate::core::runtime::DispatchCtx, workspace_dir:/// return the threads that still hold undelivered completions (a previous/// process finished the work but never delivered it). Remembers each thread's/// workspace so the delivery loop can claim them.-pub(crate) fn recover_pending_threads(ctx: &crate::core::runtime::DispatchCtx, workspace_dir: &Path) -> Vec<String> {+pub(crate) fn recover_pending_threads(ctx: &DispatchCtx, workspace_dir: &Path) -> Vec<String> {let entry = entry_for(workspace_dir);if let Err(error) = entry.router.compact(SETTLED_RETENTION) {log::warn!("[background_completions] compact failed error={error}");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.rsindex 0f2b50b3c9..0b880852e7 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@@ -2,6 +2,7 @@//! unique per user, so one user's Stop or delete on `t1` must never gate,//! drop or reach another user's `t1`.+use crate::core::runtime::DispatchCtx;use std::sync::Arc;use super::background_completions::*;@@ -23,7 +24,15 @@ fn profile(name: &str, workspace: &std::path::Path) -> Arc<CoreContext> {async fn record(ctx: &Arc<CoreContext>, ws: &std::path::Path, task: &str) {CoreContext::scope(Arc::clone(ctx),- record_completion(&crate::core::runtime::DispatchCtx::ambient(), ws, "sess-1", task, "researcher", "done", Some("t1".into())),+ record_completion(+ &DispatchCtx::ambient(),+ ws,+ "sess-1",+ task,+ "researcher",+ "done",+ Some("t1".into()),+ ),).await;}@@ -44,7 +53,7 @@ async fn one_profiles_stop_and_delete_never_reach_anothers_thread() {// Alice presses Stop on her `t1`.CoreContext::scope(Arc::clone(&alice), async {- discard_pending_for_thread(&crate::core::runtime::DispatchCtx::ambient(), "t1");+ discard_pending_for_thread(&DispatchCtx::ambient(), "t1");}).await;@@ -57,13 +66,18 @@ async fn one_profiles_stop_and_delete_never_reach_anothers_thread() {// Bob deletes his `t1`; Alice re-engages hers and keeps working.CoreContext::scope(Arc::clone(&bob), async {- discard_for_thread(&crate::core::runtime::DispatchCtx::ambient(), ws_b.path(), "t1");+ discard_for_thread(&DispatchCtx::ambient(), ws_b.path(), "t1");}).await;CoreContext::scope(Arc::clone(&alice), async {- resume_stopped_thread(&crate::core::runtime::DispatchCtx::ambient(), "t1");+ resume_stopped_thread(&DispatchCtx::ambient(), "t1");assert!(- !mark_stopped_task_if_thread_stopped(&crate::core::runtime::DispatchCtx::ambient(), ws_a.path(), "t1", "alice-2"),+ !mark_stopped_task_if_thread_stopped(+ &DispatchCtx::ambient(),+ ws_a.path(),+ "t1",+ "alice-2"+ ),"bob's delete does not abort alice's child");})@@ -78,7 +92,9 @@ async fn one_profiles_stop_and_delete_never_reach_anothers_thread() {// Each profile resolves `t1` to its own workspace.let resolved = |ctx: &Arc<CoreContext>| {- CoreContext::sync_scope(Arc::clone(ctx), || workspace_for_thread(&crate::core::runtime::DispatchCtx::ambient(), "t1"))+ CoreContext::sync_scope(Arc::clone(ctx), || {+ workspace_for_thread(&DispatchCtx::ambient(), "t1")+ })};assert_eq!(resolved(&alice).as_deref(), Some(ws_a.path()));assert_eq!(resolved(&bob).as_deref(), Some(ws_b.path()));diff --git a/crates/openhuman-core/src/agent/orchestration/background_completions_tests.rs b/crates/openhuman-core/src/agent/orchestration/background_completions_tests.rsindex 022b364298..e141528e55 100644--- a/crates/openhuman-core/src/agent/orchestration/background_completions_tests.rs+++ b/crates/openhuman-core/src/agent/orchestration/background_completions_tests.rs@@ -1,4 +1,5 @@use super::*;+use crate::core::runtime::DispatchCtx;use tinyagents_tasks::CompletionStatus;use tokio::sync::MutexGuard;@@ -17,7 +18,7 @@ fn workspace() -> TestWorkspace {fn record(ws: &Path, session: &str, task: &str, summary: &str, thread: Option<&str>) {futures::executor::block_on(record_completion(- &crate::core::runtime::DispatchCtx::ambient(),+ &DispatchCtx::ambient(),ws,session,task,@@ -77,10 +78,7 @@ fn headless_completion_is_dropped() {.claim_pending("", usize::MAX).unwrap().is_empty());- assert!(- recover_pending_threads(&crate::core::runtime::DispatchCtx::ambient(), ws.path())- .is_empty()- );+ assert!(recover_pending_threads(&DispatchCtx::ambient(), ws.path()).is_empty());}#[test]@@ -89,17 +87,17 @@ fn the_session_is_mapped_to_its_thread_for_the_idle_gate() {let ws = workspace();record(ws.path(), "sess-map", "sub-1", "x", Some("thread-map"));assert_eq!(- thread_for_session(&crate::core::runtime::DispatchCtx::ambient(), "sess-map").as_deref(),+ thread_for_session(&DispatchCtx::ambient(), "sess-map").as_deref(),Some("thread-map"));// A web-channel session id carries its thread in the JSON body.let web = r#"{"client_id":"c","thread_id":"thread-json"}"#;assert_eq!(- thread_for_session(&crate::core::runtime::DispatchCtx::ambient(), web).as_deref(),+ thread_for_session(&DispatchCtx::ambient(), web).as_deref(),Some("thread-json"));assert_eq!(- thread_for_session(&crate::core::runtime::DispatchCtx::ambient(), "cron:job-1"),+ thread_for_session(&DispatchCtx::ambient(), "cron:job-1"),None);}@@ -114,11 +112,7 @@ fn discard_for_thread_removes_matching_and_drops_stragglers() {record(w, "sess-d2", "sub-c", "z", Some("thread-DEL"));assert_eq!(- discard_for_thread(- &crate::core::runtime::DispatchCtx::ambient(),- w,- "thread-DEL"- ),+ discard_for_thread(&DispatchCtx::ambient(), w, "thread-DEL"),2);assert!(pending_ids(w, "thread-DEL").is_empty());@@ -132,11 +126,7 @@ fn record_after_discard_is_dropped_by_the_cancelled_parent() {let w = ws.path();// The thread is deleted before this process ever saw a child of it: the// delete still writes the cancelled-parent marker in the caller's workspace.- discard_for_thread(- &crate::core::runtime::DispatchCtx::ambient(),- w,- "thread-race",- );+ discard_for_thread(&DispatchCtx::ambient(), w, "thread-race");// A straggler that records after the sweep (the cooperative-abort race) is// dropped rather than queued.record(w, "sess-race", "sub-late", "stale", Some("thread-race"));@@ -152,22 +142,18 @@ fn a_child_registering_after_its_thread_was_deleted_is_aborted_and_stays_droppedlet ws = workspace();let w = ws.path();assert!(!mark_stopped_task_if_thread_stopped(- &crate::core::runtime::DispatchCtx::ambient(),+ &DispatchCtx::ambient(),w,"thread-del-reg","sub-a"));- discard_for_thread(- &crate::core::runtime::DispatchCtx::ambient(),- w,- "thread-del-reg",- );+ discard_for_thread(&DispatchCtx::ambient(), w, "thread-del-reg");// A child spawned before the delete registers after it: it must be aborted,// and registering must not lift the delete (unlike a stopped thread, a// deleted one never reopens).assert!(mark_stopped_task_if_thread_stopped(- &crate::core::runtime::DispatchCtx::ambient(),+ &DispatchCtx::ambient(),w,"thread-del-reg","sub-b"@@ -185,14 +171,11 @@ fn clear_all_withdraws_every_pending_completion() {record(w, "sess-c1", "sub-1", "a", Some("t1"));record(w, "sess-c2", "sub-2", "b", Some("t2"));- let removed = clear_all(&crate::core::runtime::DispatchCtx::ambient(), w);+ let removed = clear_all(&DispatchCtx::ambient(), w);assert_eq!(removed, 2);assert!(pending_ids(w, "t1").is_empty());assert!(pending_ids(w, "t2").is_empty());- assert_eq!(- clear_all(&crate::core::runtime::DispatchCtx::ambient(), w),- 0- );+ assert_eq!(clear_all(&DispatchCtx::ambient(), w), 0);}#[test]@@ -203,10 +186,7 @@ fn clear_all_is_scoped_to_its_workspace() {record(purged.path(), "sess-p", "sub-1", "a", Some("t-purged"));record(other.path(), "sess-o", "sub-2", "b", Some("t-other"));- assert_eq!(- clear_all(&crate::core::runtime::DispatchCtx::ambient(), purged.path()),- 1- );+ assert_eq!(clear_all(&DispatchCtx::ambient(), purged.path()), 1);assert!(pending_ids(purged.path(), "t-purged").is_empty());assert_eq!(@@ -287,7 +267,7 @@ fn record_failure_queues_a_framed_failure_for_delivery() {let ws = workspace();let w = ws.path();futures::executor::block_on(record_failure(- &crate::core::runtime::DispatchCtx::ambient(),+ &DispatchCtx::ambient(),w,"sess-fail","sub-bad",@@ -308,7 +288,7 @@ fn record_awaiting_input_queues_a_framed_needs_input_for_delivery() {let ws = workspace();let w = ws.path();futures::executor::block_on(record_awaiting_input(- &crate::core::runtime::DispatchCtx::ambient(),+ &DispatchCtx::ambient(),w,"sess-ask","sub-ask",@@ -332,7 +312,7 @@ fn the_outcome_survives_a_claim() {let ws = workspace();let w = ws.path();futures::executor::block_on(record_outcome(- &crate::core::runtime::DispatchCtx::ambient(),+ &DispatchCtx::ambient(),w,"sess-out","sub-1",@@ -372,10 +352,7 @@ fn discard_pending_for_thread_blocks_late_results_until_the_next_turn() {// Stop drops the undelivered result so it can't start a delivery turn...assert_eq!(- discard_pending_for_thread(- &crate::core::runtime::DispatchCtx::ambient(),- "thread-stop-live"- ),+ discard_pending_for_thread(&DispatchCtx::ambient(), "thread-stop-live"),1);assert!(pending_ids(w, "thread-stop-live").is_empty());@@ -395,7 +372,7 @@ fn discard_pending_for_thread_blocks_late_results_until_the_next_turn() {// Completing Stop keeps the thread gate until a new user turn begins, so a// child that registers after the cancellation sweep is still rejected.finish_stop_for_thread(- &crate::core::runtime::DispatchCtx::ambient(),+ &DispatchCtx::ambient(),"thread-stop-live",&["sub-stop-later".into()],);@@ -411,16 +388,13 @@ fn discard_pending_for_thread_blocks_late_results_until_the_next_turn() {// A child that was spawned before Stop but registers after the registry// sweep gets its own tombstone before the thread can be reopened.assert!(mark_stopped_task_if_thread_stopped(- &crate::core::runtime::DispatchCtx::ambient(),+ &DispatchCtx::ambient(),w,"thread-stop-live","sub-stop-registered-late"));- resume_stopped_thread(- &crate::core::runtime::DispatchCtx::ambient(),- "thread-stop-live",- );+ resume_stopped_thread(&DispatchCtx::ambient(), "thread-stop-live");record(w,"sess-stop",@@ -449,10 +423,7 @@ fn a_stop_before_a_restart_is_lifted_by_the_first_new_spawn() {let w = ws.path();record(w, "sess-rs", "sub-1", "x", Some("thread-restart-stop"));assert_eq!(- discard_pending_for_thread(- &crate::core::runtime::DispatchCtx::ambient(),- "thread-restart-stop"- ),+ discard_pending_for_thread(&DispatchCtx::ambient(), "thread-restart-stop"),1);@@ -460,7 +431,7 @@ fn a_stop_before_a_restart_is_lifted_by_the_first_new_spawn() {// marker is not.forget_workspace_for_test(w);assert!(!mark_stopped_task_if_thread_stopped(- &crate::core::runtime::DispatchCtx::ambient(),+ &DispatchCtx::ambient(),w,"thread-restart-stop","sub-new"@@ -506,7 +477,7 @@ fn undelivered_completions_are_found_again_after_a_restart() {drop(router);forget_workspace_for_test(w);- let threads = recover_pending_threads(&crate::core::runtime::DispatchCtx::ambient(), w);+ let threads = recover_pending_threads(&DispatchCtx::ambient(), w);assert_eq!(threads,@@ -517,9 +488,7 @@ fn undelivered_completions_are_found_again_after_a_restart() {pending_for(w, "thread-boot")[0].result.text,"unseen result");- assert!(- router_for_thread(&crate::core::runtime::DispatchCtx::ambient(), "thread-boot").is_some()- );+ assert!(router_for_thread(&DispatchCtx::ambient(), "thread-boot").is_some());}#[test]@@ -529,11 +498,7 @@ fn a_delete_survives_a_restart_and_is_not_lifted_by_a_new_spawn() {let w = ws.path();record(w, "sess-dr", "sub-1", "x", Some("thread-del-restart"));assert_eq!(- discard_for_thread(- &crate::core::runtime::DispatchCtx::ambient(),- w,- "thread-del-restart"- ),+ discard_for_thread(&DispatchCtx::ambient(), w, "thread-del-restart"),1);@@ -542,7 +507,7 @@ fn a_delete_survives_a_restart_and_is_not_lifted_by_a_new_spawn() {// to a stopped thread, and its result must stay dropped.forget_workspace_for_test(w);assert!(mark_stopped_task_if_thread_stopped(- &crate::core::runtime::DispatchCtx::ambient(),+ &DispatchCtx::ambient(),w,"thread-del-restart","sub-late"@@ -589,10 +554,7 @@ fn clear_all_also_withdraws_a_completion_a_delivery_has_leased() {1);- assert_eq!(- clear_all(&crate::core::runtime::DispatchCtx::ambient(), w),- 1- );+ assert_eq!(clear_all(&DispatchCtx::ambient(), w), 1);assert!(pending_ids(w, "thread-leased").is_empty());assert_eq!(@@ -607,26 +569,20 @@ fn the_session_cache_evicts_its_oldest_mapping_only() {let _guard = test_guard();for i in 0..(SESSION_THREADS_CAP + 5) {note_session_thread(- &crate::core::runtime::DispatchCtx::ambient(),+ &DispatchCtx::ambient(),&format!("evict-sess-{i}"),&format!("evict-thread-{i}"),);}assert_eq!(- thread_for_session(- &crate::core::runtime::DispatchCtx::ambient(),- "evict-sess-0"- ),+ thread_for_session(&DispatchCtx::ambient(), "evict-sess-0"),None,"oldest evicted");for survivor in [5, SESSION_THREADS_CAP / 2, SESSION_THREADS_CAP + 4] {assert_eq!(- thread_for_session(- &crate::core::runtime::DispatchCtx::ambient(),- &format!("evict-sess-{survivor}")- )- .as_deref(),+ thread_for_session(&DispatchCtx::ambient(), &format!("evict-sess-{survivor}"))+ .as_deref(),Some(format!("evict-thread-{survivor}").as_str()),"a surviving session still resolves to its own thread");@@ -639,11 +595,7 @@ fn a_delete_marker_outlives_compaction() {let ws = workspace();let w = ws.path();record(w, "sess-cm", "sub-1", "x", Some("thread-compact"));- discard_for_thread(- &crate::core::runtime::DispatchCtx::ambient(),- w,- "thread-compact",- );+ discard_for_thread(&DispatchCtx::ambient(), w, "thread-compact");// Settled records expire; the deletion must not.router_for_workspace(w)@@ -651,7 +603,7 @@ fn a_delete_marker_outlives_compaction() {.unwrap();forget_workspace_for_test(w);assert!(mark_stopped_task_if_thread_stopped(- &crate::core::runtime::DispatchCtx::ambient(),+ &DispatchCtx::ambient(),w,"thread-compact","sub-late"@@ -664,11 +616,7 @@ fn deleting_a_thread_that_never_used_background_work_writes_nothing() {let ws = workspace();let w = ws.path();assert_eq!(- discard_for_thread(- &crate::core::runtime::DispatchCtx::ambient(),- w,- "thread-plain"- ),+ discard_for_thread(&DispatchCtx::ambient(), w, "thread-plain"),0);assert!(@@ -686,11 +634,7 @@ fn a_late_record_for_a_deleted_thread_is_dropped_by_the_durable_marker_alone() {let ws = workspace();let w = ws.path();record(w, "sess-dm", "sub-1", "x", Some("thread-dm"));- discard_for_thread(- &crate::core::runtime::DispatchCtx::ambient(),- w,- "thread-dm",- );+ discard_for_thread(&DispatchCtx::ambient(), w, "thread-dm");// A restart empties the in-memory gates; the marker on disk still decides.forget_workspace_for_test(w);record(w, "sess-dm", "sub-late", "stale", Some("thread-dm"));@@ -703,7 +647,7 @@ async fn release_all_closes_every_router_and_the_log_stays_replayable() {let ws = workspace();let w = ws.path();record_completion(- &crate::core::runtime::DispatchCtx::ambient(),+ &DispatchCtx::ambient(),w,"sess-rel","sub-1",@@ -719,13 +663,13 @@ async fn release_all_closes_every_router_and_the_log_stays_replayable() {"the router (and its log handle) is dropped");assert!(- workspace_for_thread(&crate::core::runtime::DispatchCtx::ambient(), "thread-rel").is_none(),+ workspace_for_thread(&DispatchCtx::ambient(), "thread-rel").is_none(),"process-local maps are cleared");// The next boot finds the undelivered completion from the log alone.assert_eq!(- recover_pending_threads(&crate::core::runtime::DispatchCtx::ambient(), w),+ recover_pending_threads(&DispatchCtx::ambient(), w),["thread-rel"]);}@@ -767,16 +711,13 @@ async fn release_all_keeps_the_stop_and_delete_gates() {let _guard = crate::config::TEST_ENV_LOCK.lock().await;let ws = workspace();let w = ws.path();- discard_pending_for_thread(- &crate::core::runtime::DispatchCtx::ambient(),- "thread-keep-stop",- );+ discard_pending_for_thread(&DispatchCtx::ambient(), "thread-keep-stop");state().deleted_threads.insert("thread-keep-del".into());release_all().await;// A detached child finishing after the release is still refused.record_completion(- &crate::core::runtime::DispatchCtx::ambient(),+ &DispatchCtx::ambient(),w,"s","sub-1",@@ -786,7 +727,7 @@ async fn release_all_keeps_the_stop_and_delete_gates() {).await;record_completion(- &crate::core::runtime::DispatchCtx::ambient(),+ &DispatchCtx::ambient(),w,"s","sub-2",@@ -797,10 +738,7 @@ async fn release_all_keeps_the_stop_and_delete_gates() {.await;assert!(pending_ids(w, "thread-keep-stop").is_empty());assert!(pending_ids(w, "thread-keep-del").is_empty());- resume_stopped_thread(- &crate::core::runtime::DispatchCtx::ambient(),- "thread-keep-stop",- );+ resume_stopped_thread(&DispatchCtx::ambient(), "thread-keep-stop");state().deleted_threads.remove("thread-keep-del");}@@ -838,7 +776,7 @@ async fn a_store_that_keeps_failing_degrades_to_memory_instead_of_losing_the_resinstall_store_for_test(w, Arc::new(FullDisk(InMemoryCompletionStore::new())));record_completion(- &crate::core::runtime::DispatchCtx::ambient(),+ &DispatchCtx::ambient(),w,"sess-fd","sub-1",diff --git a/crates/openhuman-core/src/agent/orchestration/background_delivery.rs b/crates/openhuman-core/src/agent/orchestration/background_delivery.rsindex 8495a7cf24..66912ac495 100644--- a/crates/openhuman-core/src/agent/orchestration/background_delivery.rs+++ b/crates/openhuman-core/src/agent/orchestration/background_delivery.rs@@ -27,6 +27,7 @@//! appends to the thread's transcript. It persists its reply before announcing//! `chat_done`, so a reconnect cannot lose a completed delegated result.+use crate::core::runtime::DispatchCtx;use std::collections::HashSet;use std::future::Future;use std::path::{Path, PathBuf};@@ -198,14 +199,11 @@ pub(super) fn drain_schedule_in(let thread_in = |owner: Option<Arc<CoreContext>>| {let thread_id = match &owner {Some(ctx) => background_completions::thread_for_session(- &crate::core::runtime::DispatchCtx::new(Arc::clone(ctx)),+ &DispatchCtx::new(Arc::clone(ctx)),session,),// No owner: the unscoped (desktop) drain reads the ambient context.- None => background_completions::thread_for_session(- &crate::core::runtime::DispatchCtx::ambient(),- session,- ),+ None => background_completions::thread_for_session(&DispatchCtx::ambient(), session),};if thread_id.is_none() {log::trace!("[background_delivery] session has no delivery thread; not scheduling");@@ -257,7 +255,7 @@ fn schedule_delivery_inner(thread_id: String, delay: Duration, wait_idle: bool,// delayed task must run under the profile that scheduled it.crate::core::runtime::spawn_scoped(async move {// Inside the owner's scope: the context this drain acts for.- let ctx = crate::core::runtime::DispatchCtx::ambient();+ let ctx = DispatchCtx::ambient();let turn_fence = fence.clone();let turn_thread = thread_id.clone();let outcome = run_drain(@@ -295,18 +293,11 @@ fn scheduled_for_test() -> &'static Mutex<Vec<(String, Duration)>> {/// after [`RECOVERY_DELAY`], through the normal idle-gated path, fenced by the/// calling profile's lease when there is one. Returns the number of threads/// scheduled.-pub(crate) fn recover_on_boot(- ctx: &crate::core::runtime::DispatchCtx,- workspace_dir: &Path,-) -> usize {+pub(crate) fn recover_on_boot(ctx: &DispatchCtx, workspace_dir: &Path) -> usize {recover_fenced(ctx, workspace_dir, DrainFence::current())}-fn recover_fenced(- ctx: &crate::core::runtime::DispatchCtx,- workspace_dir: &Path,- fence: DrainFence,-) -> usize {+fn recover_fenced(ctx: &DispatchCtx, workspace_dir: &Path, fence: DrainFence) -> usize {// Scheduling needs a runtime; check before claiming so a later call retries.if tokio::runtime::Handle::try_current().is_err() {log::warn!(@@ -337,11 +328,7 @@ fn recover_fenced(/// host has not published the profile yet, so it cannot be looked up): a drain/// that comes due after this node lost that lease is dropped, and the records/// stay pending for the node that holds it now.-pub(crate) fn recover_on_open(- ctx: &crate::core::runtime::DispatchCtx,- workspace_dir: &Path,- fence: DrainFence,-) -> usize {+pub(crate) fn recover_on_open(ctx: &DispatchCtx, workspace_dir: &Path, fence: DrainFence) -> usize {background_completions::forget_recovery(workspace_dir);let scheduled = recover_fenced(ctx, workspace_dir, fence);if scheduled == 0 {@@ -357,7 +344,7 @@ pub(crate) fn recover_on_open(/// batch stays leased until the caller settles it with `mark_delivered` //// `mark_failed` / `release`.fn claim_ready(- ctx: &crate::core::runtime::DispatchCtx,+ ctx: &DispatchCtx,router: &CompletionRouter,thread_id: &str,) -> Option<Vec<CompletionRecord>> {@@ -376,11 +363,7 @@ fn claim_ready(/// Drain + deliver pending completions for a thread — if idle and not already/// delivering. Batches everything ready at this instant into one system turn.-async fn try_deliver(- busy_ctx: crate::core::runtime::DispatchCtx,- thread_id: String,- fence: DrainFence,-) {+async fn try_deliver(busy_ctx: DispatchCtx, thread_id: String, fence: DrainFence) {if !fence.admits() {log::info!("[background_delivery] profile lease lost; not delivering thread_id={thread_id}"@@ -395,7 +378,7 @@ async fn try_deliver(let router = background_completions::router_for_workspace(&workspace_dir);let turn_workspace = workspace_dir.clone();// A drain is event-driven and carries no context of its own.- let ctx = crate::core::runtime::DispatchCtx::host_default();+ let ctx = DispatchCtx::host_default();let retry_after = try_deliver_with(&busy_ctx,thread_id.clone(),@@ -429,7 +412,7 @@ async fn try_deliver(/// outside this module.#[cfg(test)]pub(super) async fn try_deliver_for_test(- ctx: crate::core::runtime::DispatchCtx,+ ctx: DispatchCtx,thread_id: String,router: Arc<CompletionRouter>,turns: Arc<std::sync::atomic::AtomicU32>,@@ -480,7 +463,7 @@ async fn persist_undelivered(workspace_dir: PathBuf, thread_id: String, notice:/// terminal announcement is observable, and that a record which exhausts its/// attempts is handed to `on_undeliverable` rather than dropped.async fn try_deliver_with<F, Fut, G, GFut>(- ctx: &crate::core::runtime::DispatchCtx,+ ctx: &DispatchCtx,thread_id: String,router: Arc<CompletionRouter>,mut deliver: F,@@ -625,11 +608,7 @@ struct DeliverySlot {impl DeliverySlot {/// `None` when a delivery is already in flight for the thread.- fn claim(- ctx: &crate::core::runtime::DispatchCtx,- thread_id: &str,- router: Arc<CompletionRouter>,- ) -> Option<Self> {+ fn claim(ctx: &DispatchCtx, thread_id: &str, router: Arc<CompletionRouter>) -> Option<Self> {let key = tenant::profile_key_in(&super::busy_guard::caller(ctx), thread_id);let mut d = delivering().lock().expect("delivering poisoned");if !d.insert(key.clone()) {@@ -669,7 +648,7 @@ impl Drop for DeliverySlot {/// later cold-boot resume would prefer — which is how a restart used to drop/// every turn before the delivery notice.async fn run_system_turn_on_thread(- ctx: &crate::core::runtime::DispatchCtx,+ ctx: &DispatchCtx,workspace_dir: PathBuf,thread_id: String,prompt: String,@@ -752,7 +731,7 @@ fn persist_delivery_reply(success: bool,) -> Result<(), String> {crate::threads::store::append_message(- &crate::core::runtime::DispatchCtx::ambient(),+ &DispatchCtx::ambient(),workspace_dir,thread_id,crate::threads::store::ConversationMessage {diff --git a/crates/openhuman-core/src/agent/orchestration/background_delivery_recovery_tests.rs b/crates/openhuman-core/src/agent/orchestration/background_delivery_recovery_tests.rsindex 69ff8ba1ff..7fbecf6d69 100644--- a/crates/openhuman-core/src/agent/orchestration/background_delivery_recovery_tests.rs+++ b/crates/openhuman-core/src/agent/orchestration/background_delivery_recovery_tests.rs@@ -1,4 +1,5 @@use super::*;+use crate::core::runtime::DispatchCtx;#[tokio::test]async fn a_mixed_batch_that_partly_gives_up_still_retries_the_rest() {@@ -9,7 +10,7 @@ async fn a_mixed_batch_that_partly_gives_up_still_retries_the_rest() {let router = router_for_workspace(w);for _ in 0..(DEFAULT_MAX_ATTEMPTS - 1) {try_deliver_with(- &crate::core::runtime::DispatchCtx::ambient(),+ &DispatchCtx::ambient(),"thread-mixed".into(),router.clone(),|_t, _n| async move { Err::<String, String>("checkout failed".to_string()) },@@ -23,7 +24,7 @@ async fn a_mixed_batch_that_partly_gives_up_still_retries_the_rest() {let gave_up = Arc::new(Mutex::new(String::new()));let sink = Arc::clone(&gave_up);let retry = try_deliver_with(- &crate::core::runtime::DispatchCtx::ambient(),+ &DispatchCtx::ambient(),"thread-mixed".into(),router,|_t, _n| async move { Err::<String, String>("checkout failed".to_string()) },diff --git a/crates/openhuman-core/src/agent/orchestration/background_delivery_slots_tests.rs b/crates/openhuman-core/src/agent/orchestration/background_delivery_slots_tests.rsindex 13a1a583a5..30b3454e1d 100644--- a/crates/openhuman-core/src/agent/orchestration/background_delivery_slots_tests.rs+++ b/crates/openhuman-core/src/agent/orchestration/background_delivery_slots_tests.rs@@ -7,6 +7,7 @@ use super::*;use crate::agent::orchestration::background_completions::{pending_for, record_completion, router_for_workspace, TestWorkspace,};+use crate::core::runtime::DispatchCtx;use crate::core::runtime::{ContextOverlay, DomainSet};use crate::tools::toolpacks::ToolGroups;@@ -50,7 +51,7 @@ async fn pair() -> Pair {CoreContext::scope(Arc::clone(ctx),record_completion(- &crate::core::runtime::DispatchCtx::ambient(),+ &DispatchCtx::ambient(),ws.path(),&session,task,@@ -80,24 +81,20 @@ async fn one_profiles_busy_turn_does_not_block_anothers_thread() {let _guard = crate::config::TEST_ENV_LOCK.lock().await;let p = pair().await;let turn = in_scope(&p.alice, || {- TurnBusy::start(&crate::core::runtime::DispatchCtx::ambient(), &p.session)+ TurnBusy::start(&DispatchCtx::ambient(), &p.session)});assert!(in_scope(&p.alice, || is_busy(- &crate::core::runtime::DispatchCtx::ambient(),+ &DispatchCtx::ambient(),&p.thread)));assert!(!in_scope(&p.bob, || is_busy(- &crate::core::runtime::DispatchCtx::ambient(),+ &DispatchCtx::ambient(),&p.thread)));let router_b = router_for_workspace(p.ws_b.path());let batch = in_scope(&p.bob, || {- claim_ready(- &crate::core::runtime::DispatchCtx::ambient(),- &router_b,- &p.thread,- )+ claim_ready(&DispatchCtx::ambient(), &router_b, &p.thread)}).expect("bob's thread is idle while alice's turn runs");assert_eq!(batch[0].task_id, "task-bob");@@ -106,19 +103,19 @@ async fn one_profiles_busy_turn_does_not_block_anothers_thread() {// Bob's Stop clears only Bob's turns; Alice stays busy.assert_eq!(in_scope(&p.bob, || clear_busy_for_thread(- &crate::core::runtime::DispatchCtx::ambient(),+ &DispatchCtx::ambient(),&p.thread)),0);assert!(in_scope(&p.alice, || is_busy(- &crate::core::runtime::DispatchCtx::ambient(),+ &DispatchCtx::ambient(),&p.thread)));drop(turn);assert!(!in_scope(&p.alice, || is_busy(- &crate::core::runtime::DispatchCtx::ambient(),+ &DispatchCtx::ambient(),&p.thread)));}@@ -133,16 +130,12 @@ async fn a_delivery_in_flight_for_one_profile_does_not_take_anothers_slot() {);let held = in_scope(&p.alice, || {- DeliverySlot::claim(- &crate::core::runtime::DispatchCtx::ambient(),- &p.thread,- router_a.clone(),- )+ DeliverySlot::claim(&DispatchCtx::ambient(), &p.thread, router_a.clone())}).expect("alice claims her slot");assert!(in_scope(&p.alice, || DeliverySlot::claim(- &crate::core::runtime::DispatchCtx::ambient(),+ &DispatchCtx::ambient(),&p.thread,router_a.clone()))@@ -150,11 +143,7 @@ async fn a_delivery_in_flight_for_one_profile_does_not_take_anothers_slot() {"one delivery per thread within a profile");let bob_slot = in_scope(&p.bob, || {- DeliverySlot::claim(- &crate::core::runtime::DispatchCtx::ambient(),- &p.thread,- router_b.clone(),- )+ DeliverySlot::claim(&DispatchCtx::ambient(), &p.thread, router_b.clone())});assert!(bob_slot.is_some(),@@ -185,7 +174,7 @@ async fn a_delivery_in_flight_for_one_profile_does_not_take_anothers_slot() {let retry = CoreContext::scope(bob,try_deliver_with(- &crate::core::runtime::DispatchCtx::ambient(),+ &DispatchCtx::ambient(),thread,router_bob,bob_log,@@ -200,7 +189,7 @@ async fn a_delivery_in_flight_for_one_profile_does_not_take_anothers_slot() {let retry = CoreContext::scope(Arc::clone(&p.alice),try_deliver_with(- &crate::core::runtime::DispatchCtx::ambient(),+ &DispatchCtx::ambient(),p.thread.clone(),router_a,alice_deliver,@@ -228,20 +217,16 @@ async fn desktop_keys_are_the_bare_ids() {let thread = unique("t-desk");let session = unique("desk-session");in_scope(&desktop, || {- background_completions::note_session_thread(- &crate::core::runtime::DispatchCtx::ambient(),- &session,- &thread,- )+ background_completions::note_session_thread(&DispatchCtx::ambient(), &session, &thread)});let turn = in_scope(&desktop, || {- TurnBusy::start(&crate::core::runtime::DispatchCtx::ambient(), &session)+ TurnBusy::start(&DispatchCtx::ambient(), &session)});assert_eq!(turn.key, session);assert!(busy().lock().unwrap().contains_key(&session));assert!(in_scope(&desktop, || is_busy(- &crate::core::runtime::DispatchCtx::ambient(),+ &DispatchCtx::ambient(),&thread)));drop(turn);@@ -249,11 +234,7 @@ async fn desktop_keys_are_the_bare_ids() {let router = router_for_workspace(ws.path());let slot = in_scope(&desktop, || {- DeliverySlot::claim(- &crate::core::runtime::DispatchCtx::ambient(),- &thread,- router,- )+ DeliverySlot::claim(&DispatchCtx::ambient(), &thread, router)}).expect("free");assert_eq!(slot.key, thread);@@ -270,22 +251,19 @@ async fn an_older_guard_dropping_keeps_a_replacement_turn_busy() {let session = web_session(&thread);let old = in_scope(&desktop, || {- TurnBusy::start(&crate::core::runtime::DispatchCtx::ambient(), &session)+ TurnBusy::start(&DispatchCtx::ambient(), &session)});let new = in_scope(&desktop, || {- TurnBusy::start(&crate::core::runtime::DispatchCtx::ambient(), &session)+ TurnBusy::start(&DispatchCtx::ambient(), &session)});drop(old);assert!(- in_scope(&desktop, || is_busy(- &crate::core::runtime::DispatchCtx::ambient(),- &thread- )),+ in_scope(&desktop, || is_busy(&DispatchCtx::ambient(), &thread)),"replacement still running");drop(new);assert!(!in_scope(&desktop, || is_busy(- &crate::core::runtime::DispatchCtx::ambient(),+ &DispatchCtx::ambient(),&thread)));}diff --git a/crates/openhuman-core/src/agent/orchestration/background_delivery_tenant_tests.rs b/crates/openhuman-core/src/agent/orchestration/background_delivery_tenant_tests.rsindex 26c37f076e..1965094559 100644--- a/crates/openhuman-core/src/agent/orchestration/background_delivery_tenant_tests.rs+++ b/crates/openhuman-core/src/agent/orchestration/background_delivery_tenant_tests.rs@@ -4,6 +4,7 @@//! profile owns. Driven through `drain_schedule_in(true, ..)` with an injected//! resolver, so the process-wide SaaS mode flag stays untouched.+use crate::core::runtime::DispatchCtx;use std::path::Path;use std::sync::Arc;@@ -45,7 +46,8 @@ fn seen_by(drain: &Drain) -> (Option<String>, String, Vec<String>) {let ctx = drain.owner.clone().expect("a SaaS drain carries its owner");let profile = ctx.profile().map(str::to_owned);let pending = CoreContext::sync_scope(ctx, || {- let ws = workspace_for_thread(&crate::core::runtime::DispatchCtx::ambient(), &drain.thread_id).expect("owner knows its thread");+ let ws = workspace_for_thread(&DispatchCtx::ambient(), &drain.thread_id)+ .expect("owner knows its thread");pending_for(&ws, &drain.thread_id).into_iter().map(|r| r.task_id)@@ -69,7 +71,8 @@ async fn an_off_task_completion_drains_only_its_owners_thread() {for (ctx, ws, task) in [(&alice, &ws_a, &task_a), (&bob, &ws_b, &task_b)] {CoreContext::scope(Arc::clone(ctx),- record_completion(&crate::core::runtime::DispatchCtx::ambient(),+ record_completion(+ &DispatchCtx::ambient(),ws.path(),&session,task.as_str(),diff --git a/crates/openhuman-core/src/agent/orchestration/background_delivery_tests.rs b/crates/openhuman-core/src/agent/orchestration/background_delivery_tests.rsindex a51b8c213d..2227815bd2 100644--- a/crates/openhuman-core/src/agent/orchestration/background_delivery_tests.rs+++ b/crates/openhuman-core/src/agent/orchestration/background_delivery_tests.rs@@ -2,6 +2,7 @@ use super::*;use crate::agent::orchestration::background_completions::{forget_workspace_for_test, pending_for, record_completion, router_for_workspace, TestWorkspace,};+use crate::core::runtime::DispatchCtx;use std::path::Path;use std::sync::atomic::{AtomicU32, Ordering};use tinyagents_tasks::DEFAULT_MAX_ATTEMPTS;@@ -17,7 +18,7 @@ fn workspace() -> TestWorkspace {async fn record(ws: &Path, session: &str, task: &str, summary: &str, thread: &str) {let thread = Some(thread.to_owned());record_completion(- &crate::core::runtime::DispatchCtx::ambient(),+ &DispatchCtx::ambient(),ws,session,task,@@ -56,24 +57,15 @@ async fn claim_takes_the_ready_batch_when_idle() {record(w, "bd-ready", "sub-2", "beta", "thread-ready").await;let router = router_for_workspace(w);- let batch = claim_ready(- &crate::core::runtime::DispatchCtx::ambient(),- &router,- "thread-ready",- )- .expect("claims a batch");+ let batch =+ claim_ready(&DispatchCtx::ambient(), &router, "thread-ready").expect("claims a batch");assert_eq!(batch.len(), 2);let notice = router.formatter().format_batch(&batch);assert!(notice.contains("sub-1") && notice.contains("sub-2"));// The records stay pending (leased) until the turn lands.assert_eq!(pending_ids(w, "thread-ready").len(), 2);assert!(- claim_ready(- &crate::core::runtime::DispatchCtx::ambient(),- &router,- "thread-ready"- )- .is_none(),+ claim_ready(&DispatchCtx::ambient(), &router, "thread-ready").is_none(),"a held lease is not claimed twice");}@@ -87,20 +79,10 @@ async fn claim_skips_a_busy_thread_and_leaves_the_queue_intact() {let router = router_for_workspace(w);mark_busy("bd-busy");- assert!(claim_ready(- &crate::core::runtime::DispatchCtx::ambient(),- &router,- "thread-busy"- )- .is_none());+ assert!(claim_ready(&DispatchCtx::ambient(), &router, "thread-busy").is_none());clear_busy("bd-busy");assert!(- claim_ready(- &crate::core::runtime::DispatchCtx::ambient(),- &router,- "thread-busy"- )- .is_some(),+ claim_ready(&DispatchCtx::ambient(), &router, "thread-busy").is_some(),"a deferral leaves the record claimable");assert_eq!(@@ -115,12 +97,7 @@ async fn claim_is_none_when_nothing_is_pending() {let _g = test_guard().await;let ws = workspace();let router = router_for_workspace(ws.path());- assert!(claim_ready(- &crate::core::runtime::DispatchCtx::ambient(),- &router,- "bd-empty-unique"- )- .is_none());+ assert!(claim_ready(&DispatchCtx::ambient(), &router, "bd-empty-unique").is_none());}#[tokio::test]@@ -134,7 +111,7 @@ async fn a_delivered_batch_is_settled_and_not_redelivered() {let seen = Arc::clone(&turns);try_deliver_with(- &crate::core::runtime::DispatchCtx::ambient(),+ &DispatchCtx::ambient(),"thread-ok".into(),router.clone(),move |thread, notice| {@@ -169,7 +146,7 @@ async fn persistence_failure_releases_batch_without_terminal_announcement() {let announced_for_delivery = Arc::clone(&announced);try_deliver_with(- &crate::core::runtime::DispatchCtx::ambient(),+ &DispatchCtx::ambient(),"thread-persist".into(),router.clone(),move |_thread_id, _notice| {@@ -209,16 +186,10 @@ async fn persistence_failure_releases_batch_without_terminal_announcement() {async fn a_turn_is_busy_until_its_guard_drops() {let sid = r#"{"client_id":"c","thread_id":"bd-turn-thread"}"#.to_string();- let turn = TurnBusy::start(&crate::core::runtime::DispatchCtx::ambient(), &sid);- assert!(is_busy(- &crate::core::runtime::DispatchCtx::ambient(),- "bd-turn-thread"- ));+ let turn = TurnBusy::start(&DispatchCtx::ambient(), &sid);+ assert!(is_busy(&DispatchCtx::ambient(), "bd-turn-thread"));drop(turn);- assert!(!is_busy(- &crate::core::runtime::DispatchCtx::ambient(),- "bd-turn-thread"- ));+ assert!(!is_busy(&DispatchCtx::ambient(), "bd-turn-thread"));// The bus events no longer mark busy: the subscriber runs off-task and// cannot tell which profile a session belongs to.@@ -228,10 +199,7 @@ async fn a_turn_is_busy_until_its_guard_drops() {channel: "test".into(),}).await;- assert!(!is_busy(- &crate::core::runtime::DispatchCtx::ambient(),- "bd-turn-thread"- ));+ assert!(!is_busy(&DispatchCtx::ambient(), "bd-turn-thread"));}/// Drive the real delivery loop with a turn executor that always fails, the@@ -252,7 +220,7 @@ async fn drain_until_empty_or(let turns_for_delivery = Arc::clone(&turns);let sink = Arc::clone(&undelivered);try_deliver_with(- &crate::core::runtime::DispatchCtx::ambient(),+ &DispatchCtx::ambient(),thread.to_string(),router.clone(),move |_thread_id, _notice| {@@ -354,7 +322,7 @@ async fn transient_failure_under_the_ceiling_keeps_the_result() {let router = router_for_workspace(w);try_deliver_with(- &crate::core::runtime::DispatchCtx::ambient(),+ &DispatchCtx::ambient(),"thread-transient".into(),router.clone(),|_t, _n| async move { Err::<String, String>("blip".to_string()) },@@ -389,7 +357,7 @@ async fn busy_deferral_does_not_consume_the_failure_budget() {for _ in 0..(DEFAULT_MAX_ATTEMPTS * 2) {mark_busy("bd-busy-defer");try_deliver_with(- &crate::core::runtime::DispatchCtx::ambient(),+ &DispatchCtx::ambient(),"thread-busy-defer".into(),router.clone(),|_t, _n| async move { unreachable!("must not run a delivery turn while busy") },@@ -463,21 +431,16 @@ async fn a_pending_completion_survives_a_restart_and_is_delivered() {drop(router);forget_workspace_for_test(w);- let threads = background_completions::recover_pending_threads(- &crate::core::runtime::DispatchCtx::ambient(),- w,- );+ let threads = background_completions::recover_pending_threads(&DispatchCtx::ambient(), w);assert_eq!(threads, ["thread-restart"]);- let router = background_completions::router_for_thread(- &crate::core::runtime::DispatchCtx::ambient(),- "thread-restart",- )- .expect("recovered");+ let router =+ background_completions::router_for_thread(&DispatchCtx::ambient(), "thread-restart")+ .expect("recovered");let delivered = Arc::new(Mutex::new(Vec::<String>::new()));let sink = Arc::clone(&delivered);try_deliver_with(- &crate::core::runtime::DispatchCtx::ambient(),+ &DispatchCtx::ambient(),"thread-restart".into(),router,move |thread, notice| {@@ -503,11 +466,7 @@ async fn a_pending_completion_survives_a_restart_and_is_delivered() {);forget_workspace_for_test(w);- assert!(background_completions::recover_pending_threads(- &crate::core::runtime::DispatchCtx::ambient(),- w- )- .is_empty());+ assert!(background_completions::recover_pending_threads(&DispatchCtx::ambient(), w).is_empty());}#[tokio::test]@@ -586,7 +545,7 @@ async fn a_delivered_batch_restores_the_full_failure_budget() {};for _ in 0..(DEFAULT_MAX_ATTEMPTS - 1) {try_deliver_with(- &crate::core::runtime::DispatchCtx::ambient(),+ &DispatchCtx::ambient(),"thread-budget".into(),router.clone(),|_t, _n| async move { Err::<String, String>("blip".to_string()) },@@ -595,7 +554,7 @@ async fn a_delivered_batch_restores_the_full_failure_budget() {.await;}try_deliver_with(- &crate::core::runtime::DispatchCtx::ambient(),+ &DispatchCtx::ambient(),"thread-budget".into(),router.clone(),|_t, _n| async move { Ok::<String, String>("delivered".to_string()) },@@ -630,7 +589,7 @@ async fn a_dropped_delivery_releases_its_slot_and_lease() {let router = router.clone();async move {try_deliver_with(- &crate::core::runtime::DispatchCtx::ambient(),+ &DispatchCtx::ambient(),"thread-drop".into(),router,move |_t, _n| {@@ -651,7 +610,7 @@ async fn a_dropped_delivery_releases_its_slot_and_lease() {let delivered = Arc::new(Mutex::new(false));let flag = Arc::clone(&delivered);try_deliver_with(- &crate::core::runtime::DispatchCtx::ambient(),+ &DispatchCtx::ambient(),"thread-drop".into(),router,move |_t, _n| {@@ -682,7 +641,7 @@ async fn a_failed_turn_under_the_ceiling_asks_for_a_backoff_retry() {let router = router_for_workspace(w);let retry = try_deliver_with(- &crate::core::runtime::DispatchCtx::ambient(),+ &DispatchCtx::ambient(),"thread-retry".into(),router.clone(),|_t, _n| async move { Err::<String, String>("session checkout failed".to_string()) },@@ -692,7 +651,7 @@ async fn a_failed_turn_under_the_ceiling_asks_for_a_backoff_retry() {assert_eq!(retry, Some(retry_backoff(1)));let delivered = try_deliver_with(- &crate::core::runtime::DispatchCtx::ambient(),+ &DispatchCtx::ambient(),"thread-retry".into(),router,|_t, _n| async move { Ok::<String, String>("presented".to_string()) },@@ -724,16 +683,13 @@ async fn boot_recovery_schedules_a_delivery_for_every_thread_with_undelivered_reforget_workspace_for_test(w);scheduled_for_test().lock().expect("scheduled").clear();- assert_eq!(- recover_on_boot(&crate::core::runtime::DispatchCtx::ambient(), w),- 1- );+ assert_eq!(recover_on_boot(&DispatchCtx::ambient(), w), 1);assert!(scheduled_for_test().lock().expect("scheduled").contains(&("thread-boot-sched".to_string(), RECOVERY_DELAY)));assert_eq!(- recover_on_boot(&crate::core::runtime::DispatchCtx::ambient(), w),+ recover_on_boot(&DispatchCtx::ambient(), w),0,"a workspace is scanned once per process");@@ -746,21 +702,14 @@ async fn recover_on_open_rescans_a_workspace_already_recovered() {let w = ws.path();record(w, "bd-open", "sub-1", "left pending", "thread-open-resc").await;forget_workspace_for_test(w);+ assert_eq!(recover_on_boot(&DispatchCtx::ambient(), w), 1);assert_eq!(- recover_on_boot(&crate::core::runtime::DispatchCtx::ambient(), w),- 1- );- assert_eq!(- recover_on_boot(&crate::core::runtime::DispatchCtx::ambient(), w),+ recover_on_boot(&DispatchCtx::ambient(), w),0,"boot recovery claims once");assert_eq!(- recover_on_open(- &crate::core::runtime::DispatchCtx::ambient(),- w,- DrainFence::none()- ),+ recover_on_open(&DispatchCtx::ambient(), w, DrainFence::none()),1,"a re-open scans again");@@ -774,28 +723,16 @@ async fn a_cancelled_turn_does_not_leave_the_thread_busy() {let other = r#"{"client_id":"c","thread_id":"bd-other-thread"}"#;mark_busy(session);mark_busy(other);- assert!(is_busy(- &crate::core::runtime::DispatchCtx::ambient(),- "bd-stale-thread"- ));+ assert!(is_busy(&DispatchCtx::ambient(), "bd-stale-thread"));assert_eq!(- clear_busy_for_thread(- &crate::core::runtime::DispatchCtx::ambient(),- "bd-stale-thread"- ),+ clear_busy_for_thread(&DispatchCtx::ambient(), "bd-stale-thread"),1);- assert!(!is_busy(- &crate::core::runtime::DispatchCtx::ambient(),- "bd-stale-thread"- ));+ assert!(!is_busy(&DispatchCtx::ambient(), "bd-stale-thread"));assert!(- is_busy(- &crate::core::runtime::DispatchCtx::ambient(),- "bd-other-thread"- ),+ is_busy(&DispatchCtx::ambient(), "bd-other-thread"),"other threads are untouched");clear_busy(other);diff --git a/crates/openhuman-core/src/agent/orchestration/busy_guard.rs b/crates/openhuman-core/src/agent/orchestration/busy_guard.rsindex a2fec43d94..877ecf74ad 100644--- a/crates/openhuman-core/src/agent/orchestration/busy_guard.rs+++ b/crates/openhuman-core/src/agent/orchestration/busy_guard.rs@@ -57,7 +57,10 @@ impl TurnBusy {/// not map to its thread: a relayed channel turn runs under the channel/// pipeline's own session id, which [`background_completions`] never/// learns, so marking that session would leave the thread looking idle.- pub(crate) fn start_on_thread(ctx: &crate::core::runtime::DispatchCtx, thread_id: &str) -> Self {+ pub(crate) fn start_on_thread(+ ctx: &crate::core::runtime::DispatchCtx,+ thread_id: &str,+ ) -> Self {Self::start(ctx, &format!("{THREAD_MARK}{thread_id}"))}}@@ -103,12 +106,16 @@ pub(crate) fn is_busy(ctx: &crate::core::runtime::DispatchCtx, thread_id: &str)/// or `AgentError`, and its session would otherwise stay "busy" and defer this/// thread's deliveries until restart. Another profile's turn on a thread with/// the same id is left alone. Returns how many sessions were cleared.-pub(crate) fn clear_busy_for_thread(ctx: &crate::core::runtime::DispatchCtx, thread_id: &str) -> usize {+pub(crate) fn clear_busy_for_thread(+ ctx: &crate::core::runtime::DispatchCtx,+ thread_id: &str,+) -> usize {let me = caller(ctx);let mut busy = busy().lock().expect("background_delivery busy poisoned");let before = busy.len();busy.retain(|key, _| {- session_of(key, &me).is_none_or(|session| thread_of(ctx, session).as_deref() != Some(thread_id))+ session_of(key, &me)+ .is_none_or(|session| thread_of(ctx, session).as_deref() != Some(thread_id))});let cleared = before - busy.len();if cleared > 0 {diff --git a/crates/openhuman-core/src/agent/orchestration/delivery_drain.rs b/crates/openhuman-core/src/agent/orchestration/delivery_drain.rsindex baac589084..70ac1ef4fe 100644--- a/crates/openhuman-core/src/agent/orchestration/delivery_drain.rs+++ b/crates/openhuman-core/src/agent/orchestration/delivery_drain.rs@@ -14,6 +14,7 @@//! Outside SaaS, and for work that serves no hosted profile, a drain has no//! fence and always runs.+use crate::core::runtime::DispatchCtx;use std::future::Future;use std::sync::Arc;use std::time::Duration;@@ -93,7 +94,7 @@ pub(super) enum DrainOutcome {/// `wait_idle` serves a recovered record: it has no owner noted (that table is/// process-local), so the busy turn's completion event would not wake it.pub(super) async fn run_drain<F, Fut>(- ctx: &crate::core::runtime::DispatchCtx,+ ctx: &DispatchCtx,thread_id: &str,delay: Duration,wait_idle: bool,diff --git a/crates/openhuman-core/src/agent/orchestration/delivery_drain_tests.rs b/crates/openhuman-core/src/agent/orchestration/delivery_drain_tests.rsindex 481766e01b..215339fcd7 100644--- a/crates/openhuman-core/src/agent/orchestration/delivery_drain_tests.rs+++ b/crates/openhuman-core/src/agent/orchestration/delivery_drain_tests.rs@@ -3,6 +3,7 @@ use crate::agent::orchestration::background_completions::{pending_for, record_completion, router_for_workspace, TestWorkspace,};use crate::agent::orchestration::busy_guard::TurnBusy;+use crate::core::runtime::DispatchCtx;use crate::storage::fence::{system_now_ms, ScopeMatch};use crate::storage::lease::{DocumentLeases, LeaseStore};use crate::storage::MemoryStorage;@@ -39,7 +40,7 @@ async fn drain(let ran = Arc::new(AtomicBool::new(false));let flag = Arc::clone(&ran);let outcome = run_drain(- &crate::core::runtime::DispatchCtx::ambient(),+ &DispatchCtx::ambient(),thread,delay,wait_idle,@@ -121,10 +122,7 @@ async fn an_expired_grant_fences_the_drain_without_a_latch() {async fn losing_the_lease_while_waiting_for_an_idle_thread_drops_the_drain() {let _g = crate::config::TEST_ENV_LOCK.lock().await;let (_leases, fence) = live_fence();- let turn = TurnBusy::start_on_thread(- &crate::core::runtime::DispatchCtx::ambient(),- "dd-busy-fenced",- );+ let turn = TurnBusy::start_on_thread(&DispatchCtx::ambient(), "dd-busy-fenced");let latch = Arc::clone(&fence);tokio::spawn(async move {tokio::time::sleep(SHORT * 3).await;@@ -140,9 +138,9 @@ async fn losing_the_lease_while_waiting_for_an_idle_thread_drops_the_drain() {async fn a_recovered_drain_waits_for_a_relayed_turn_on_its_thread() {let _g = crate::config::TEST_ENV_LOCK.lock().await;let thread = "dd-relayed-thread";- let turn = TurnBusy::start_on_thread(&crate::core::runtime::DispatchCtx::ambient(), thread);+ let turn = TurnBusy::start_on_thread(&DispatchCtx::ambient(), thread);assert!(- is_busy(&crate::core::runtime::DispatchCtx::ambient(), thread),+ is_busy(&DispatchCtx::ambient(), thread),"a relayed turn marks its thread busy");let release = tokio::spawn(async move {@@ -153,10 +151,7 @@ async fn a_recovered_drain_waits_for_a_relayed_turn_on_its_thread() {release.await.unwrap();assert_eq!(outcome, DrainOutcome::Ran);assert!(ran);- assert!(!is_busy(- &crate::core::runtime::DispatchCtx::ambient(),- thread- ));+ assert!(!is_busy(&DispatchCtx::ambient(), thread));}#[tokio::test]@@ -166,7 +161,7 @@ async fn a_delivery_waits_while_a_relayed_turn_runs_on_its_thread() {let w = ws.path();let thread = "dd-relay-deliver";record_completion(- &crate::core::runtime::DispatchCtx::ambient(),+ &DispatchCtx::ambient(),w,"dd-relay-session","sub-relay",@@ -179,14 +174,14 @@ async fn a_delivery_waits_while_a_relayed_turn_runs_on_its_thread() {let turns = Arc::new(AtomicU32::new(0));let attempt = |turns: Arc<AtomicU32>| {super::super::background_delivery::try_deliver_for_test(- crate::core::runtime::DispatchCtx::ambient(),+ DispatchCtx::ambient(),thread.to_string(),Arc::clone(&router),turns,)};- let relayed = TurnBusy::start_on_thread(&crate::core::runtime::DispatchCtx::ambient(), thread);+ let relayed = TurnBusy::start_on_thread(&DispatchCtx::ambient(), thread);attempt(Arc::clone(&turns)).await;assert_eq!(turns.load(Ordering::SeqCst),diff --git a/crates/openhuman-core/src/agent/orchestration/running_subagents/cancel.rs b/crates/openhuman-core/src/agent/orchestration/running_subagents/cancel.rsindex 9e1c0997ff..7bde29049a 100644--- a/crates/openhuman-core/src/agent/orchestration/running_subagents/cancel.rs+++ b/crates/openhuman-core/src/agent/orchestration/running_subagents/cancel.rs@@ -36,7 +36,10 @@ pub(crate) struct CancelledSubagent {////// User controls check the captured profile in SaaS. The desktop user retains/// authority over every sub-agent in their own core.-pub(crate) fn cancel_by_task(ctx: &crate::core::runtime::DispatchCtx, task_id: &str) -> Option<CancelledSubagent> {+pub(crate) fn cancel_by_task(+ ctx: &crate::core::runtime::DispatchCtx,+ task_id: &str,+) -> Option<CancelledSubagent> {let id = TaskId::new(task_id);let snapshot = registry().snapshot_trusted(&id).ok()?;if !control_admits(ctx, &snapshot.metadata) {@@ -115,7 +118,10 @@ pub(crate) fn cancel_for_thread(ctx: &crate::core::runtime::DispatchCtx, thread_/// recorded: delivering one would start a fresh system turn on the thread,/// which is exactly what Stop is meant to prevent. Returns the cancelled task/// ids.-pub(crate) fn stop_for_thread(ctx: &crate::core::runtime::DispatchCtx, thread_id: &str) -> Vec<String> {+pub(crate) fn stop_for_thread(+ ctx: &crate::core::runtime::DispatchCtx,+ thread_id: &str,+) -> Vec<String> {let own = caller_workspace(ctx);let cancelled = registry().cancel_where(|metadata| {@@ -216,10 +222,7 @@ impl CallerWorkspace {}pub(crate) fn caller_workspace(ctx: &crate::core::runtime::DispatchCtx) -> CallerWorkspace {- caller_workspace_in(- crate::core::runtime::is_saas(),- ctx.resolved().as_deref(),- )+ caller_workspace_in(crate::core::runtime::is_saas(), ctx.resolved().as_deref())}/// [`caller_workspace`] as a function of the mode and the task's own scope.diff --git a/crates/openhuman-core/src/agent/orchestration/running_subagents/registry.rs b/crates/openhuman-core/src/agent/orchestration/running_subagents/registry.rsindex b0142684eb..edbb8e5326 100644--- a/crates/openhuman-core/src/agent/orchestration/running_subagents/registry.rs+++ b/crates/openhuman-core/src/agent/orchestration/running_subagents/registry.rs@@ -56,10 +56,7 @@ pub(crate) struct RunningSubagentMetadata {/// Resolve the caller's profile without falling back to the operator in SaaS.fn caller_profile(ctx: &crate::core::runtime::DispatchCtx) -> Result<Option<String>, WaitError> {- let profile = ctx- .tenant()- .map_err(|_| WaitError::NotOwned)?- .profile;+ let profile = ctx.tenant().map_err(|_| WaitError::NotOwned)?.profile;if crate::core::runtime::is_saas() && profile.is_none() {return Err(WaitError::NotOwned);}@@ -85,7 +82,10 @@ pub(crate) fn admit_spawn(}/// Host ownership adapter over TinyAgents' opaque owner string.-pub(super) fn owner_key(ctx: &crate::core::runtime::DispatchCtx, parent_session: &str) -> Result<String, WaitError> {+pub(super) fn owner_key(+ ctx: &crate::core::runtime::DispatchCtx,+ parent_session: &str,+) -> Result<String, WaitError> {let profile = caller_profile(ctx)?;Ok(crate::core::runtime::tenant::tenant_key(&crate::core::runtime::tenant::Tenant {@@ -98,7 +98,10 @@ pub(super) fn owner_key(ctx: &crate::core::runtime::DispatchCtx, parent_session:/// Public user controls may reach any of their profile's parents; desktop/// controls retain the process user's existing authority over all workers.-pub(super) fn control_admits(ctx: &crate::core::runtime::DispatchCtx, metadata: &RunningSubagentMetadata) -> bool {+pub(super) fn control_admits(+ ctx: &crate::core::runtime::DispatchCtx,+ metadata: &RunningSubagentMetadata,+) -> bool {!crate::core::runtime::is_saas()|| caller_profile(ctx).is_ok_and(|profile| profile == metadata.profile)}diff --git a/crates/openhuman-core/src/agent/orchestration/running_subagents/resolve.rs b/crates/openhuman-core/src/agent/orchestration/running_subagents/resolve.rsindex 11e7e3b0eb..6f9264bd0e 100644--- a/crates/openhuman-core/src/agent/orchestration/running_subagents/resolve.rs+++ b/crates/openhuman-core/src/agent/orchestration/running_subagents/resolve.rs@@ -21,7 +21,11 @@ pub(crate) fn task_id_for_session(subagent_session_id: &str,parent_session: &str,) -> Result<String, WaitError> {- live_task_id(registry(), subagent_session_id, &owner_key(ctx, parent_session)?)+ live_task_id(+ registry(),+ subagent_session_id,+ &owner_key(ctx, parent_session)?,+ )}pub(crate) fn task_id_for_session_in_workspace(diff --git a/crates/openhuman-core/src/agent/orchestration/running_subagents/wait.rs b/crates/openhuman-core/src/agent/orchestration/running_subagents/wait.rsindex 0a309ae431..c1c4a74133 100644--- a/crates/openhuman-core/src/agent/orchestration/running_subagents/wait.rs+++ b/crates/openhuman-core/src/agent/orchestration/running_subagents/wait.rs@@ -19,7 +19,13 @@ pub(crate) async fn wait(parent_session: &str,timeout: Duration,) -> Result<WaitOutcome, WaitError> {- wait_detached(registry(), task_id, &owner_key(ctx, parent_session)?, timeout).await+ wait_detached(+ registry(),+ task_id,+ &owner_key(ctx, parent_session)?,+ timeout,+ )+ .await}pub(crate) async fn wait_in_workspace(diff --git a/crates/openhuman-core/src/agent/orchestration/running_subagents_steering_tests.rs b/crates/openhuman-core/src/agent/orchestration/running_subagents_steering_tests.rsindex d6422013fb..7b8e5cc220 100644--- a/crates/openhuman-core/src/agent/orchestration/running_subagents_steering_tests.rs+++ b/crates/openhuman-core/src/agent/orchestration/running_subagents_steering_tests.rs@@ -6,7 +6,8 @@ async fn steer_pushes_into_the_subagent_queue() {let rq = run_queue();let tx = register_test("task-steer", "session-A", rq.clone());- steer(&crate::core::runtime::DispatchCtx::ambient(),+ steer(+ &crate::core::runtime::DispatchCtx::ambient(),"task-steer","session-A","refocus on memory safety".into(),@@ -19,7 +20,8 @@ async fn steer_pushes_into_the_subagent_queue() {assert_eq!(status.steers, 1, "steer should land in the steer lane");// collect mode goes to the collect lane- steer(&crate::core::runtime::DispatchCtx::ambient(),+ steer(+ &crate::core::runtime::DispatchCtx::ambient(),"task-steer","session-A","extra context".into(),@@ -45,7 +47,8 @@ async fn steer_prefers_registered_tinyagents_handle() {let task_id = TaskId::new("task-registered-steer");shared_steering_registry().register(task_id.clone(), handle.clone());- steer(&crate::core::runtime::DispatchCtx::ambient(),+ steer(+ &crate::core::runtime::DispatchCtx::ambient(),"task-registered-steer","session-A","refocus".into(),@@ -80,7 +83,8 @@ async fn steer_rejects_cross_parent_and_unknown() {let _tx = register_test("task-owned", "session-owner", rq);assert_eq!(- steer(&crate::core::runtime::DispatchCtx::ambient(),+ steer(+ &crate::core::runtime::DispatchCtx::ambient(),"task-owned","session-intruder","x".into(),@@ -90,7 +94,8 @@ async fn steer_rejects_cross_parent_and_unknown() {Err(SteerError::NotOwned));assert_eq!(- steer(&crate::core::runtime::DispatchCtx::ambient(),+ steer(+ &crate::core::runtime::DispatchCtx::ambient(),"task-missing","session-owner","x".into(),@@ -112,7 +117,14 @@ async fn steer_after_terminal_is_rejected() {});assert_eq!(- steer(&crate::core::runtime::DispatchCtx::ambient(), "task-term", "session-A", "x".into(), QueueLane::Steer).await,+ steer(+ &crate::core::runtime::DispatchCtx::ambient(),+ "task-term",+ "session-A",+ "x".into(),+ QueueLane::Steer+ )+ .await,Err(SteerError::AlreadyDone));prune("task-term");@@ -125,7 +137,8 @@ async fn detached_subagent_rejects_followup_lane() {let _tx = register_test("task-no-followup", "session-A", rq.clone());assert_eq!(- steer(&crate::core::runtime::DispatchCtx::ambient(),+ steer(+ &crate::core::runtime::DispatchCtx::ambient(),"task-no-followup","session-A","not a new turn".into(),diff --git a/crates/openhuman-core/src/agent/orchestration/running_subagents_tenant_tests.rs b/crates/openhuman-core/src/agent/orchestration/running_subagents_tenant_tests.rsindex 30e5284fcd..1383e4c11e 100644--- a/crates/openhuman-core/src/agent/orchestration/running_subagents_tenant_tests.rs+++ b/crates/openhuman-core/src/agent/orchestration/running_subagents_tenant_tests.rs@@ -60,7 +60,8 @@ impl Worker {let (tx, rx) = status_channel();let task_handle = tokio::spawn(std::future::pending::<()>());let abort = task_handle.abort_handle();- register(&crate::core::runtime::DispatchCtx::ambient(),+ register(+ &crate::core::runtime::DispatchCtx::ambient(),task.clone(),"researcher".into(),PARENT.into(),@@ -227,7 +228,12 @@ async fn saas_dispatch_exposes_only_the_callers_detached_worker_controls() {}).await;CoreContext::scope(pair.alice.clone(), async {- assert!(resume_ref_for_task(&crate::core::runtime::DispatchCtx::ambient(), &pair.a.task, PARENT).is_ok());+ assert!(resume_ref_for_task(+ &crate::core::runtime::DispatchCtx::ambient(),+ &pair.a.task,+ PARENT+ )+ .is_ok());}).await;for function in ["steer", "cancel"] {@@ -339,7 +345,9 @@ async fn same_parent_rosters_are_profile_isolated() {}let pair = Pair::new();for (ctx, own) in [(&pair.alice, &pair.a), (&pair.bob, &pair.b)] {- let tasks = CoreContext::sync_scope(ctx.clone(), || snapshot_for_parent(&crate::core::runtime::DispatchCtx::ambient(), PARENT));+ let tasks = CoreContext::sync_scope(ctx.clone(), || {+ snapshot_for_parent(&crate::core::runtime::DispatchCtx::ambient(), PARENT)+ });assert_eq!(tasks.iter().map(|t| t.task_id.as_str()).collect::<Vec<_>>(),[own.task.as_str()]@@ -358,19 +366,38 @@ async fn same_parent_resolution_and_wait_refuse_foreign_workers() {let pair = Pair::new();CoreContext::scope(pair.bob.clone(), async {assert!(matches!(- task_id_for_session(&crate::core::runtime::DispatchCtx::ambient(), &pair.a.session, PARENT),+ task_id_for_session(+ &crate::core::runtime::DispatchCtx::ambient(),+ &pair.a.session,+ PARENT+ ),Err(WaitError::NotOwned)));assert!(matches!(- resume_ref_for_task(&crate::core::runtime::DispatchCtx::ambient(), &pair.a.task, PARENT),+ resume_ref_for_task(+ &crate::core::runtime::DispatchCtx::ambient(),+ &pair.a.task,+ PARENT+ ),Err(WaitError::NotOwned)));assert!(matches!(- wait(&crate::core::runtime::DispatchCtx::ambient(), &pair.a.task, PARENT, Duration::ZERO).await,+ wait(+ &crate::core::runtime::DispatchCtx::ambient(),+ &pair.a.task,+ PARENT,+ Duration::ZERO+ )+ .await,Err(WaitError::NotOwned)));assert_eq!(- task_id_for_session(&crate::core::runtime::DispatchCtx::ambient(), &pair.b.session, PARENT).unwrap(),+ task_id_for_session(+ &crate::core::runtime::DispatchCtx::ambient(),+ &pair.b.session,+ PARENT+ )+ .unwrap(),pair.b.task);})@@ -388,13 +415,26 @@ async fn same_parent_agent_steering_refuses_foreign_worker() {let pair = Pair::new();CoreContext::scope(pair.bob.clone(), async {assert_eq!(- steer(&crate::core::runtime::DispatchCtx::ambient(), &pair.a.task, PARENT, "foreign".into(), QueueLane::Steer).await,+ steer(+ &crate::core::runtime::DispatchCtx::ambient(),+ &pair.a.task,+ PARENT,+ "foreign".into(),+ QueueLane::Steer+ )+ .await,Err(SteerError::NotOwned));assert_eq!(pair.a.queue.status().await.steers, 0);- steer(&crate::core::runtime::DispatchCtx::ambient(), &pair.b.task, PARENT, "own".into(), QueueLane::Steer)- .await- .unwrap();+ steer(+ &crate::core::runtime::DispatchCtx::ambient(),+ &pair.b.task,+ PARENT,+ "own".into(),+ QueueLane::Steer,+ )+ .await+ .unwrap();assert_eq!(pair.b.queue.status().await.steers, 1);}).await;@@ -435,7 +475,12 @@ async fn public_cancellation_refuses_another_profiles_task() {field(&control("cancel", &pair.a.task).await, "cancelled"),Some(false));- assert!(resume_ref_for_task(&crate::core::runtime::DispatchCtx::ambient(), &pair.b.task, PARENT).is_ok());+ assert!(resume_ref_for_task(+ &crate::core::runtime::DispatchCtx::ambient(),+ &pair.b.task,+ PARENT+ )+ .is_ok());assert_eq!(field(&control("cancel", &pair.b.task).await, "cancelled"),Some(true)@@ -444,7 +489,12 @@ async fn public_cancellation_refuses_another_profiles_task() {.await;CoreContext::scope(pair.alice.clone(), async {assert!(- resume_ref_for_task(&crate::core::runtime::DispatchCtx::ambient(), &pair.a.task, PARENT).is_ok(),+ resume_ref_for_task(+ &crate::core::runtime::DispatchCtx::ambient(),+ &pair.a.task,+ PARENT+ )+ .is_ok(),"foreign cancel leaves original worker live");})@@ -463,11 +513,22 @@ async fn missing_saas_scope_cannot_observe_or_control_workers() {assert!(CoreContext::scoped().is_none());assert!(snapshot_for_parent(&crate::core::runtime::DispatchCtx::ambient(), PARENT).is_empty());assert!(matches!(- resume_ref_for_task(&crate::core::runtime::DispatchCtx::ambient(), &pair.a.task, PARENT),+ resume_ref_for_task(+ &crate::core::runtime::DispatchCtx::ambient(),+ &pair.a.task,+ PARENT+ ),Err(WaitError::NotOwned)));assert_eq!(- steer(&crate::core::runtime::DispatchCtx::ambient(), &pair.a.task, PARENT, "unscoped".into(), QueueLane::Steer).await,+ steer(+ &crate::core::runtime::DispatchCtx::ambient(),+ &pair.a.task,+ PARENT,+ "unscoped".into(),+ QueueLane::Steer+ )+ .await,Err(SteerError::NotOwned));assert_eq!(@@ -480,13 +541,24 @@ async fn missing_saas_scope_cannot_observe_or_control_workers() {);assert_eq!(pair.a.queue.status().await.steers, 0);CoreContext::sync_scope(pair.alice.clone(), || {- assert!(resume_ref_for_task(&crate::core::runtime::DispatchCtx::ambient(), &pair.a.task, PARENT).is_ok())+ assert!(resume_ref_for_task(+ &crate::core::runtime::DispatchCtx::ambient(),+ &pair.a.task,+ PARENT+ )+ .is_ok())});// A scoped kernel context without an admitted profile is not authority.CoreContext::scope(CoreContext::for_test(DomainSet::full(), None), async {- assert!(snapshot_for_parent(&crate::core::runtime::DispatchCtx::ambient(), PARENT).is_empty());+ assert!(+ snapshot_for_parent(&crate::core::runtime::DispatchCtx::ambient(), PARENT).is_empty()+ );assert!(matches!(- resume_ref_for_task(&crate::core::runtime::DispatchCtx::ambient(), &pair.a.task, PARENT),+ resume_ref_for_task(+ &crate::core::runtime::DispatchCtx::ambient(),+ &pair.a.task,+ PARENT+ ),Err(WaitError::NotOwned)));assert_eq!(@@ -511,7 +583,10 @@ async fn desktop_public_controls_remain_available_without_parent_scope() {}let directory = tempfile::tempdir().unwrap();let worker = Worker::register(directory.path());- assert_eq!(snapshot_for_parent(&crate::core::runtime::DispatchCtx::ambient(), PARENT).len(), 1);+ assert_eq!(+ snapshot_for_parent(&crate::core::runtime::DispatchCtx::ambient(), PARENT).len(),+ 1+ );assert_eq!(field(&control("steer", &worker.task).await, "steered"),Some(true)diff --git a/crates/openhuman-core/src/agent/orchestration/running_subagents_tests.rs b/crates/openhuman-core/src/agent/orchestration/running_subagents_tests.rsindex fff0705b13..433e62287f 100644--- a/crates/openhuman-core/src/agent/orchestration/running_subagents_tests.rs+++ b/crates/openhuman-core/src/agent/orchestration/running_subagents_tests.rs@@ -88,7 +88,8 @@ fn register_test_with_thread(rq: Arc<RunQueue<QueuedTurn>>,) -> watch::Sender<DetachedSubagentStatus> {let (tx, rx) = status_channel();- register(&crate::core::runtime::DispatchCtx::ambient(),+ register(+ &crate::core::runtime::DispatchCtx::ambient(),task_id.into(),"researcher".into(),parent_session.into(),@@ -146,7 +147,11 @@ async fn task_store_records_spawn_complete_and_cancel() {// A second sub-agent that gets cancelled is recorded Cancelled.let _tx2 = register_test("task-ledger-2", "ledger-parent", run_queue());- assert!(cancel_by_task(&crate::core::runtime::DispatchCtx::ambient(), "task-ledger-2").is_some());+ assert!(cancel_by_task(+ &crate::core::runtime::DispatchCtx::ambient(),+ "task-ledger-2"+ )+ .is_some());let cancelled = task_records(None).into_iter().find(|r| r.spec.task_id.as_str() == "task-ledger-2")@@ -161,7 +166,8 @@ async fn task_id_for_session_enforces_parent_ownership() {let _guard = test_guard_async().await;let rq = run_queue();let (tx, rx) = status_channel();- register(&crate::core::runtime::DispatchCtx::ambient(),+ register(+ &crate::core::runtime::DispatchCtx::ambient(),"task-session".into(),"researcher".into(),"session-owner".into(),@@ -176,11 +182,20 @@ async fn task_id_for_session_enforces_parent_ownership() {.expect("fixture registration admitted");assert_eq!(- task_id_for_session(&crate::core::runtime::DispatchCtx::ambient(), "subsess-1", "session-owner").unwrap(),+ task_id_for_session(+ &crate::core::runtime::DispatchCtx::ambient(),+ "subsess-1",+ "session-owner"+ )+ .unwrap(),"task-session");assert!(matches!(- task_id_for_session(&crate::core::runtime::DispatchCtx::ambient(), "subsess-1", "session-other"),+ task_id_for_session(+ &crate::core::runtime::DispatchCtx::ambient(),+ "subsess-1",+ "session-other"+ ),Err(WaitError::NotOwned)));let _ = tx.send(DetachedSubagentStatus::Completed {@@ -194,7 +209,8 @@ async fn task_id_for_session_enforces_parent_ownership() {async fn snapshot_and_block_scope_to_parent_and_reflect_live_status() {let _guard = test_guard_async().await;let (tx_a, rx_a) = status_channel();- register(&crate::core::runtime::DispatchCtx::ambient(),+ register(+ &crate::core::runtime::DispatchCtx::ambient(),"task-fleet-a".into(),"researcher".into(),"fleet-parent".into(),@@ -208,7 +224,8 @@ async fn snapshot_and_block_scope_to_parent_and_reflect_live_status() {).expect("fixture registration admitted");let (tx_b, rx_b) = status_channel();- register(&crate::core::runtime::DispatchCtx::ambient(),+ register(+ &crate::core::runtime::DispatchCtx::ambient(),"task-fleet-b".into(),"code_executor".into(),"fleet-parent".into(),@@ -223,7 +240,8 @@ async fn snapshot_and_block_scope_to_parent_and_reflect_live_status() {.expect("fixture registration admitted");// A worker owned by a different parent must not leak into the snapshot.let (tx_other, rx_other) = status_channel();- register(&crate::core::runtime::DispatchCtx::ambient(),+ register(+ &crate::core::runtime::DispatchCtx::ambient(),"task-fleet-other".into(),"researcher".into(),"other-parent".into(),@@ -243,7 +261,10 @@ async fn snapshot_and_block_scope_to_parent_and_reflect_live_status() {}).unwrap();- let snap = snapshot_for_parent(&crate::core::runtime::DispatchCtx::ambient(), "fleet-parent");+ let snap = snapshot_for_parent(+ &crate::core::runtime::DispatchCtx::ambient(),+ "fleet-parent",+ );assert_eq!(snap.len(), 2, "only this parent's workers: {snap:?}");// Ordered by agent_id then task_id → code_executor before researcher.assert_eq!(snap[0].agent_id, "code_executor");@@ -251,9 +272,13 @@ async fn snapshot_and_block_scope_to_parent_and_reflect_live_status() {assert_eq!(snap[1].agent_id, "researcher");assert_eq!(snap[1].status, "running");- let block =- active_subagents_context_block(&crate::core::runtime::DispatchCtx::ambient(), "fleet-parent", &test_workspace(), &FleetToolSet::all())- .expect("block present");+ let block = active_subagents_context_block(+ &crate::core::runtime::DispatchCtx::ambient(),+ "fleet-parent",+ &test_workspace(),+ &FleetToolSet::all(),+ )+ .expect("block present");assert!(block.contains("[active_subagents]"));assert!(block.contains("use wait_subagent to collect"));assert!(block.contains("You have 2 sub-agent worker(s)"));@@ -262,10 +287,13 @@ async fn snapshot_and_block_scope_to_parent_and_reflect_live_status() {assert!(block.ends_with("[/active_subagents]\n\n"));// A parent with no registered workers gets no block (no perturbation).- assert!(- active_subagents_context_block(&crate::core::runtime::DispatchCtx::ambient(), "nobody-here", &test_workspace(), &FleetToolSet::all())- .is_none()- );+ assert!(active_subagents_context_block(+ &crate::core::runtime::DispatchCtx::ambient(),+ "nobody-here",+ &test_workspace(),+ &FleetToolSet::all()+ )+ .is_none());// The shipped orchestrator has no wait/steer/close tools (#5701): the// guidance must not name them and must say results arrive on their own.@@ -274,8 +302,13 @@ async fn snapshot_and_block_scope_to_parent_and_reflect_live_status() {let registry = AgentDefinitionRegistry::builtins_only();let def = registry.get("orchestrator").expect("built-in orchestrator");let fleet = FleetToolSet::from_scope(&def.tools, &def.disallowed_tools);- let block = active_subagents_context_block(&crate::core::runtime::DispatchCtx::ambient(), "fleet-parent", &test_workspace(), &fleet)- .expect("block present");+ let block = active_subagents_context_block(+ &crate::core::runtime::DispatchCtx::ambient(),+ "fleet-parent",+ &test_workspace(),+ &fleet,+ )+ .expect("block present");for name in ["wait_subagent","steer_subagent",@@ -334,14 +367,19 @@ async fn snapshot_and_block_scope_to_parent_and_reflect_live_status() {).expect("mark idle");- let block =- active_subagents_context_block(&crate::core::runtime::DispatchCtx::ambient(), "cold-parent", durable_ws.path(), &FleetToolSet::all())- .expect("durable-only roster present");+ let block = active_subagents_context_block(+ &crate::core::runtime::DispatchCtx::ambient(),+ "cold-parent",+ durable_ws.path(),+ &FleetToolSet::all(),+ )+ .expect("durable-only roster present");assert!(block.contains(&format!("session={}", session.subagent_session_id)));assert!(block.contains("status=idle"));assert!(block.contains("about: Daily X trending email workflow"));// Other parents' durable sessions must not leak in.- assert!(active_subagents_context_block(&crate::core::runtime::DispatchCtx::ambient(),+ assert!(active_subagents_context_block(+ &crate::core::runtime::DispatchCtx::ambient(),"unrelated-parent",durable_ws.path(),&FleetToolSet::all()@@ -366,7 +404,8 @@ async fn snapshot_and_block_scope_to_parent_and_reflect_live_status() {async fn resume_ref_for_task_includes_resume_fields_and_enforces_ownership() {let _guard = test_guard_async().await;let (tx, rx) = status_channel();- register(&crate::core::runtime::DispatchCtx::ambient(),+ register(+ &crate::core::runtime::DispatchCtx::ambient(),"task-resume".into(),"researcher".into(),"session-owner".into(),@@ -380,7 +419,12 @@ async fn resume_ref_for_task_includes_resume_fields_and_enforces_ownership() {).expect("fixture registration admitted");- let reference = resume_ref_for_task(&crate::core::runtime::DispatchCtx::ambient(), "task-resume", "session-owner").expect("resume reference");+ let reference = resume_ref_for_task(+ &crate::core::runtime::DispatchCtx::ambient(),+ "task-resume",+ "session-owner",+ )+ .expect("resume reference");assert_eq!(reference.task_id, "task-resume");assert_eq!(reference.agent_id, "researcher");assert_eq!(@@ -388,7 +432,11 @@ async fn resume_ref_for_task_includes_resume_fields_and_enforces_ownership() {Some("subsess-resume"));assert!(matches!(- resume_ref_for_task(&crate::core::runtime::DispatchCtx::ambient(), "task-resume", "session-other"),+ resume_ref_for_task(+ &crate::core::runtime::DispatchCtx::ambient(),+ "task-resume",+ "session-other"+ ),Err(WaitError::NotOwned)));@@ -403,7 +451,8 @@ async fn resume_ref_for_task_includes_resume_fields_and_enforces_ownership() {async fn task_id_for_session_prefers_live_task_over_terminal_task() {let _guard = test_guard_async().await;let (old_tx, old_rx) = status_channel();- register(&crate::core::runtime::DispatchCtx::ambient(),+ register(+ &crate::core::runtime::DispatchCtx::ambient(),"task-old".into(),"researcher".into(),"session-owner".into(),@@ -421,7 +470,8 @@ async fn task_id_for_session_prefers_live_task_over_terminal_task() {iterations: 1,});let (_new_tx, new_rx) = status_channel();- register(&crate::core::runtime::DispatchCtx::ambient(),+ register(+ &crate::core::runtime::DispatchCtx::ambient(),"task-new".into(),"researcher".into(),"session-owner".into(),@@ -436,7 +486,12 @@ async fn task_id_for_session_prefers_live_task_over_terminal_task() {.expect("fixture registration admitted");assert_eq!(- task_id_for_session(&crate::core::runtime::DispatchCtx::ambient(), "subsess-live", "session-owner").unwrap(),+ task_id_for_session(+ &crate::core::runtime::DispatchCtx::ambient(),+ "subsess-live",+ "session-owner"+ )+ .unwrap(),"task-new");prune("task-old");@@ -458,9 +513,14 @@ async fn wait_returns_completion_once_published() {drop(tx);});- let outcome = wait(&crate::core::runtime::DispatchCtx::ambient(), "task-wait", "session-A", Duration::from_secs(5))- .await- .expect("wait should resolve");+ let outcome = wait(+ &crate::core::runtime::DispatchCtx::ambient(),+ "task-wait",+ "session-A",+ Duration::from_secs(5),+ )+ .await+ .expect("wait should resolve");match outcome {WaitOutcome::Terminal(DetachedSubagentStatus::Completed { output, iterations }) => {assert_eq!(output, "the answer");@@ -471,7 +531,13 @@ async fn wait_returns_completion_once_published() {// pruned after a terminal waitassert!(matches!(- wait(&crate::core::runtime::DispatchCtx::ambient(), "task-wait", "session-A", Duration::from_millis(10)).await,+ wait(+ &crate::core::runtime::DispatchCtx::ambient(),+ "task-wait",+ "session-A",+ Duration::from_millis(10)+ )+ .await,Err(WaitError::Unknown)));}@@ -482,16 +548,22 @@ async fn wait_times_out_and_leaves_entry_intact() {let rq = run_queue();let _tx = register_test("task-slow", "session-A", rq);- let outcome = wait(&crate::core::runtime::DispatchCtx::ambient(), "task-slow", "session-A", Duration::from_millis(20))- .await- .expect("wait should resolve");+ let outcome = wait(+ &crate::core::runtime::DispatchCtx::ambient(),+ "task-slow",+ "session-A",+ Duration::from_millis(20),+ )+ .await+ .expect("wait should resolve");assert!(matches!(outcome,WaitOutcome::TimedOut(DetachedSubagentStatus::Running)));// still steerable after a timed-out wait- assert!(steer(&crate::core::runtime::DispatchCtx::ambient(),+ assert!(steer(+ &crate::core::runtime::DispatchCtx::ambient(),"task-slow","session-A","still here".into(),@@ -518,26 +590,53 @@ async fn cancel_for_thread_aborts_only_matching_entries() {// The two cancelled entries are gone (steer can't find them).assert_eq!(- steer(&crate::core::runtime::DispatchCtx::ambient(), "task-tA-1", "session-A", "x".into(), QueueLane::Steer).await,+ steer(+ &crate::core::runtime::DispatchCtx::ambient(),+ "task-tA-1",+ "session-A",+ "x".into(),+ QueueLane::Steer+ )+ .await,Err(SteerError::Unknown));assert_eq!(- steer(&crate::core::runtime::DispatchCtx::ambient(), "task-tA-2", "session-A", "x".into(), QueueLane::Steer).await,+ steer(+ &crate::core::runtime::DispatchCtx::ambient(),+ "task-tA-2",+ "session-A",+ "x".into(),+ QueueLane::Steer+ )+ .await,Err(SteerError::Unknown));// Non-matching entries stay live and steerable.- assert!(steer(&crate::core::runtime::DispatchCtx::ambient(), "task-tB", "session-A", "x".into(), QueueLane::Steer)- .await- .is_ok());- assert!(- steer(&crate::core::runtime::DispatchCtx::ambient(), "task-headless", "session-A", "x".into(), QueueLane::Steer)- .await- .is_ok()- );+ assert!(steer(+ &crate::core::runtime::DispatchCtx::ambient(),+ "task-tB",+ "session-A",+ "x".into(),+ QueueLane::Steer+ )+ .await+ .is_ok());+ assert!(steer(+ &crate::core::runtime::DispatchCtx::ambient(),+ "task-headless",+ "session-A",+ "x".into(),+ QueueLane::Steer+ )+ .await+ .is_ok());// Idempotent: a second pass cancels nothing.- assert_eq!(cancel_for_thread(&crate::core::runtime::DispatchCtx::ambient(), "thread-X"), 0);+ assert_eq!(+ cancel_for_thread(&crate::core::runtime::DispatchCtx::ambient(), "thread-X"),+ 0+ );prune("task-tB");prune("task-headless");@@ -551,7 +650,8 @@ async fn cancel_by_task_returns_metadata_and_removes_entry() {let task_id = TaskId::new("task-cbt");shared_steering_registry().register(task_id.clone(), SteeringHandle::allow_all());- let meta = cancel_by_task(&crate::core::runtime::DispatchCtx::ambient(), "task-cbt").expect("known task should cancel");+ let meta = cancel_by_task(&crate::core::runtime::DispatchCtx::ambient(), "task-cbt")+ .expect("known task should cancel");assert_eq!(meta.already_finished, None,"a running task is a real cancel"@@ -566,12 +666,23 @@ async fn cancel_by_task_returns_metadata_and_removes_entry() {// Entry is gone — steer can no longer find it, and a second cancel is a no-op.assert_eq!(- steer(&crate::core::runtime::DispatchCtx::ambient(), "task-cbt", "session-Z", "x".into(), QueueLane::Steer).await,+ steer(+ &crate::core::runtime::DispatchCtx::ambient(),+ "task-cbt",+ "session-Z",+ "x".into(),+ QueueLane::Steer+ )+ .await,Err(SteerError::Unknown));assert!(cancel_by_task(&crate::core::runtime::DispatchCtx::ambient(), "task-cbt").is_none());// Unknown ids are simply None.- assert!(cancel_by_task(&crate::core::runtime::DispatchCtx::ambient(), "never-existed").is_none());+ assert!(cancel_by_task(+ &crate::core::runtime::DispatchCtx::ambient(),+ "never-existed"+ )+ .is_none());}/// A finished run stays registered until the terminal sweep, so a late@@ -608,7 +719,8 @@ async fn cancel_by_task_flags_a_run_that_already_finished() {for (task_id, status, finished) in cases {let tx = register_test(task_id, "session-F", run_queue());tx.send(status).expect("status channel open");- let meta = cancel_by_task(&crate::core::runtime::DispatchCtx::ambient(), task_id).expect("registered task is found");+ let meta = cancel_by_task(&crate::core::runtime::DispatchCtx::ambient(), task_id)+ .expect("registered task is found");assert_eq!(meta.already_finished, finished, "{task_id}");}}@@ -621,7 +733,7 @@ async fn cancel_all_clears_everything() {// Headless (no parent thread) — aborted, but contributes no thread id.let _b = register_test_with_thread("task-all-2", "session-B", None, rq);- let cancelled_threads = cancel_all(&crate::core::runtime::DispatchCtx::ambient(), );+ let cancelled_threads = cancel_all(&crate::core::runtime::DispatchCtx::ambient());assert!(cancelled_threads.contains(&"thread-1".to_string()),"cancel_all should report the parent thread of the cancelled sub-agent"@@ -632,15 +744,29 @@ async fn cancel_all_clears_everything() {);assert_eq!(- steer(&crate::core::runtime::DispatchCtx::ambient(), "task-all-1", "session-A", "x".into(), QueueLane::Steer).await,+ steer(+ &crate::core::runtime::DispatchCtx::ambient(),+ "task-all-1",+ "session-A",+ "x".into(),+ QueueLane::Steer+ )+ .await,Err(SteerError::Unknown));assert_eq!(- steer(&crate::core::runtime::DispatchCtx::ambient(), "task-all-2", "session-B", "x".into(), QueueLane::Steer).await,+ steer(+ &crate::core::runtime::DispatchCtx::ambient(),+ "task-all-2",+ "session-B",+ "x".into(),+ QueueLane::Steer+ )+ .await,Err(SteerError::Unknown));// Registry is empty now.- assert!(cancel_all(&crate::core::runtime::DispatchCtx::ambient(), ).is_empty());+ assert!(cancel_all(&crate::core::runtime::DispatchCtx::ambient(),).is_empty());}#[tokio::test]@@ -651,7 +777,8 @@ async fn stop_for_thread_aborts_the_threads_running_children() {// Stop button used to leave behind.let child = tokio::spawn(std::future::pending::<()>());let (_tx, rx) = status_channel();- register(&crate::core::runtime::DispatchCtx::ambient(),+ register(+ &crate::core::runtime::DispatchCtx::ambient(),"task-stop-1".into(),"researcher".into(),"session-stop".into(),@@ -679,11 +806,19 @@ async fn stop_for_thread_aborts_the_threads_running_children() {"stop must abort the detached child task");assert_eq!(- steer(&crate::core::runtime::DispatchCtx::ambient(), "task-stop-1", "session-stop", "x".into(), QueueLane::Steer).await,+ steer(+ &crate::core::runtime::DispatchCtx::ambient(),+ "task-stop-1",+ "session-stop",+ "x".into(),+ QueueLane::Steer+ )+ .await,Err(SteerError::Unknown));assert!(- steer(&crate::core::runtime::DispatchCtx::ambient(),+ steer(+ &crate::core::runtime::DispatchCtx::ambient(),"task-stop-other","session-stop","x".into(),@@ -693,7 +828,10 @@ async fn stop_for_thread_aborts_the_threads_running_children() {.is_ok(),"a different thread's sub-agent is untouched");- assert!(stop_for_thread(&crate::core::runtime::DispatchCtx::ambient(), "thread-stop").is_empty(), "idempotent");+ assert!(+ stop_for_thread(&crate::core::runtime::DispatchCtx::ambient(), "thread-stop").is_empty(),+ "idempotent"+ );prune("task-stop-other");}diff --git a/crates/openhuman-core/src/agent/orchestration/running_subagents_wire_tests.rs b/crates/openhuman-core/src/agent/orchestration/running_subagents_wire_tests.rsindex fcb1abe144..629a86beb9 100644--- a/crates/openhuman-core/src/agent/orchestration/running_subagents_wire_tests.rs+++ b/crates/openhuman-core/src/agent/orchestration/running_subagents_wire_tests.rs@@ -32,7 +32,8 @@ async fn roster_status_labels_are_literal() {let mut senders = Vec::new();for id in ["wire-run", "wire-done", "wire-await", "wire-fail"] {let (tx, rx) = status_channel();- register(&crate::core::runtime::DispatchCtx::ambient(),+ register(+ &crate::core::runtime::DispatchCtx::ambient(),id.into(),"researcher".into(),"wire-parent".into(),@@ -66,10 +67,11 @@ async fn roster_status_labels_are_literal() {_ => {}}}- let labels: Vec<(String, &str)> = snapshot_for_parent(&crate::core::runtime::DispatchCtx::ambient(), "wire-parent")- .into_iter()- .map(|s| (s.task_id, s.status))- .collect();+ let labels: Vec<(String, &str)> =+ snapshot_for_parent(&crate::core::runtime::DispatchCtx::ambient(), "wire-parent")+ .into_iter()+ .map(|s| (s.task_id, s.status))+ .collect();assert_eq!(labels,vec![@@ -127,7 +129,14 @@ async fn durable_fallback_maps_every_store_status_to_literal_wait_outcome() {"wire-d-running","wire-d-pending",] {- let outcome = wait_in_workspace(&crate::core::runtime::DispatchCtx::ambient(), id, parent, &ws, timeout).await;+ let outcome = wait_in_workspace(+ &crate::core::runtime::DispatchCtx::ambient(),+ id,+ parent,+ &ws,+ timeout,+ )+ .await;seen.push(format!("{id}: {outcome:?}"));}assert_eq!(@@ -143,15 +152,27 @@ async fn durable_fallback_maps_every_store_status_to_literal_wait_outcome() {);// A different parent is refused, an unknown id is unknown.assert_eq!(- wait_in_workspace(&crate::core::runtime::DispatchCtx::ambient(), "wire-d-failed", "someone-else", &ws, timeout)- .await- .unwrap_err(),+ wait_in_workspace(+ &crate::core::runtime::DispatchCtx::ambient(),+ "wire-d-failed",+ "someone-else",+ &ws,+ timeout+ )+ .await+ .unwrap_err(),WaitError::NotOwned);assert_eq!(- wait_in_workspace(&crate::core::runtime::DispatchCtx::ambient(), "wire-d-nope", parent, &ws, timeout)- .await- .unwrap_err(),+ wait_in_workspace(+ &crate::core::runtime::DispatchCtx::ambient(),+ "wire-d-nope",+ parent,+ &ws,+ timeout+ )+ .await+ .unwrap_err(),WaitError::Unknown);}@@ -161,7 +182,8 @@ async fn spawn_ledger_record_has_literal_persisted_shape() {let _guard = super::test_guard_async().await;let ws = tempfile::tempdir().unwrap();let (_tx, rx) = status_channel();- register(&crate::core::runtime::DispatchCtx::ambient(),+ register(+ &crate::core::runtime::DispatchCtx::ambient(),"wire-shape-1".into(),"researcher".into(),"wire-shape-parent".into(),diff --git a/crates/openhuman-core/src/agent/orchestration/subagent_control_tests.rs b/crates/openhuman-core/src/agent/orchestration/subagent_control_tests.rsindex 1f0ed0ec44..f90054d410 100644--- a/crates/openhuman-core/src/agent/orchestration/subagent_control_tests.rs+++ b/crates/openhuman-core/src/agent/orchestration/subagent_control_tests.rs@@ -111,7 +111,8 @@ async fn cancel_of_a_finished_run_reports_its_outcome_and_rewrites_nothing() {),] {let (tx, rx) = status_channel();- register(&crate::core::runtime::DispatchCtx::ambient(),+ register(+ &crate::core::runtime::DispatchCtx::ambient(),task_id.into(),"agent_memory".into(),"session-rpc".into(),diff --git a/crates/openhuman-core/src/agent/orchestration/tools/spawn_async_subagent_tests.rs b/crates/openhuman-core/src/agent/orchestration/tools/spawn_async_subagent_tests.rsindex be22762e35..9170860ce2 100644--- a/crates/openhuman-core/src/agent/orchestration/tools/spawn_async_subagent_tests.rs+++ b/crates/openhuman-core/src/agent/orchestration/tools/spawn_async_subagent_tests.rs@@ -76,7 +76,8 @@ async fn late_registration_refusal_aborts_the_worker_and_settles_its_durable_ses// synthetic error or an accepted worker under another actor.let join = tokio::spawn(std::future::pending::<()>());let (_tx, rx) = running_subagents::status_channel();- let refused = running_subagents::register(&crate::core::runtime::DispatchCtx::ambient(),+ let refused = running_subagents::register(+ &crate::core::runtime::DispatchCtx::ambient(),"late-refusal-task".into(),"task_manager_agent".into(),"late-parent".into(),diff --git a/crates/openhuman-core/src/agent/orchestration/tools/steer_subagent.rs b/crates/openhuman-core/src/agent/orchestration/tools/steer_subagent.rsindex 1a79bbccd0..e75ac9af2b 100644--- a/crates/openhuman-core/src/agent/orchestration/tools/steer_subagent.rs+++ b/crates/openhuman-core/src/agent/orchestration/tools/steer_subagent.rs@@ -132,7 +132,8 @@ impl SteerSubagentTool {}};let parent_session = parent.session_id;- let dispatch = crate::agent::tinyagents::host::run_context::dispatch_ctx_for_tool(tool_context);+ let dispatch =+ crate::agent::tinyagents::host::run_context::dispatch_ctx_for_tool(tool_context);let resolved_task_id = if task_id.is_empty() {match running_subagents::task_id_for_session_in_workspace(diff --git a/crates/openhuman-core/src/agent/orchestration/tools/wait_subagent.rs b/crates/openhuman-core/src/agent/orchestration/tools/wait_subagent.rsindex fd91a81c7d..36fad31d5f 100644--- a/crates/openhuman-core/src/agent/orchestration/tools/wait_subagent.rs+++ b/crates/openhuman-core/src/agent/orchestration/tools/wait_subagent.rs@@ -181,7 +181,8 @@ impl WaitSubagentTool {}};let parent_session = parent.session_id;- let dispatch = crate::agent::tinyagents::host::run_context::dispatch_ctx_for_tool(tool_context);+ let dispatch =+ crate::agent::tinyagents::host::run_context::dispatch_ctx_for_tool(tool_context);let resolved_task_id = if task_id.is_empty() {match running_subagents::task_id_for_session_in_workspace(diff --git a/crates/openhuman-core/src/agent/session_host/runtime/run_loop.rs b/crates/openhuman-core/src/agent/session_host/runtime/run_loop.rsindex 88a6bd75f7..816d87f2c7 100644--- a/crates/openhuman-core/src/agent/session_host/runtime/run_loop.rs+++ b/crates/openhuman-core/src/agent/session_host/runtime/run_loop.rs@@ -91,11 +91,10 @@ impl OpenHumanSessionHost {// Busy state for background-result delivery is marked here, in the// turn's own (profile) scope; the bus subscriber runs off-task.// A guard, so a turn dropped mid-flight does not leave it busy.- let busy =- crate::agent::orchestration::busy_guard::TurnBusy::start(- &self.dispatch_ctx(),- self.event_session_id(),- );+ let busy = crate::agent::orchestration::busy_guard::TurnBusy::start(+ &self.dispatch_ctx(),+ self.event_session_id(),+ );BUS.publish(DomainEvent::AgentTurnStarted {session_id: self.event_session_id().to_string(),channel: self.event_channel().to_string(),diff --git a/crates/openhuman-core/src/agent/session_host/runtime_session.rs b/crates/openhuman-core/src/agent/session_host/runtime_session.rsindex f70bdbb70b..d2cf1e53c7 100644--- a/crates/openhuman-core/src/agent/session_host/runtime_session.rs+++ b/crates/openhuman-core/src/agent/session_host/runtime_session.rs@@ -16,6 +16,7 @@ mod transcript;mod turn;pub(super) use turn::begin_turn_resume;+use crate::core::runtime::DispatchCtx;use std::sync::Arc;use anyhow::Result;@@ -74,7 +75,11 @@ struct OpenHumanTurnPrelude {/// Host prompt/utilisation state, shared by the runtime hooks. It is not/// generic conversation state and the runtime never persists it.context: Arc<std::sync::Mutex<crate::agent::context::ContextManager>>,- tool_policy: Arc<dyn tinyagents_harness::middleware::ToolCallPolicy<crate::agent::tinyagents::host::OpenHumanRunContext>>,+ tool_policy: Arc<+ dyn tinyagents_harness::middleware::ToolCallPolicy<+ crate::agent::tinyagents::host::OpenHumanRunContext,+ >,+ >,tool_dispatcher: Arc<dyn tinytools_agent::dialect::ToolDialect>,workspace_dir: std::path::PathBuf,action_dir: std::path::PathBuf,@@ -278,9 +283,7 @@ impl OpenHumanTurnPrelude {.filter(|spec| !withheld.contains(&spec.name)).filter(|spec| {self.thread_id.is_some()- || !crate::agent::tinyagents::tool_registration::is_thread_goal_tool(- &spec.name,- )+ || !crate::agent::tinyagents::tool_registration::is_thread_goal_tool(&spec.name)}).map(|spec| spec.as_ref().clone()).collect::<Vec<_>>();diff --git a/crates/openhuman-core/src/agent/session_host/runtime_session/transcript.rs b/crates/openhuman-core/src/agent/session_host/runtime_session/transcript.rsindex b0d3e6e8b9..033014569f 100644--- a/crates/openhuman-core/src/agent/session_host/runtime_session/transcript.rs+++ b/crates/openhuman-core/src/agent/session_host/runtime_session/transcript.rs@@ -21,11 +21,10 @@ impl OpenHumanSessionHost {}self.session_history_locator_memo.get_or_init(|| {- let session_agent_id =- crate::agent::session_store::current_agent_key_or(- &self.dispatch_ctx(),- &self.agent_definition_id,- );+ let session_agent_id = crate::agent::session_store::current_agent_key_or(+ &self.dispatch_ctx(),+ &self.agent_definition_id,+ );transcripts_or_files(&self.dispatch_ctx(), &session_agent_id, &self.workspace_dir)}).clone()diff --git a/crates/openhuman-core/src/agent/session_store/mod.rs b/crates/openhuman-core/src/agent/session_store/mod.rsindex 631014916f..b10bf14b50 100644--- a/crates/openhuman-core/src/agent/session_store/mod.rs+++ b/crates/openhuman-core/src/agent/session_store/mod.rs@@ -25,10 +25,10 @@ mod workspace;pub use rebound::{rebind_all, ReboundSessionStores};pub use workspace::{- artifact_blobs_for, attachment_stash_for, current_documents_for, default_turn_states_for, ledger_for,- provider_for_workspace, release_workspace_defaults, require_ledger, status_store_for,- stores_for, stores_or_ephemeral, turn_states_for, with_ledger, with_ledger_async,- WorkspaceSessionStores,+ artifact_blobs_for, attachment_stash_for, current_documents_for, default_turn_states_for,+ ledger_for, provider_for_workspace, release_workspace_defaults, require_ledger,+ status_store_for, stores_for, stores_or_ephemeral, turn_states_for, with_ledger,+ with_ledger_async, WorkspaceSessionStores,};static PROVIDER: LazyLock<RwLock<Option<Arc<dyn SessionStoreProvider>>>> =@@ -151,7 +151,10 @@ pub fn transcripts_or_files(/// directory under an embedded agent's context, else `workspace_dir` — which/// for a SaaS profile's default agent is that profile's own workspace.#[must_use]-pub fn transcript_root(ctx: &crate::core::runtime::DispatchCtx, workspace_dir: &std::path::Path) -> std::path::PathBuf {+pub fn transcript_root(+ ctx: &crate::core::runtime::DispatchCtx,+ workspace_dir: &std::path::Path,+) -> std::path::PathBuf {match current_embedded_agent(ctx) {Some(agent) => agent_transcript_root(workspace_dir, &agent),None => workspace_dir.to_path_buf(),@@ -164,9 +167,7 @@ pub fn transcript_root(ctx: &crate::core::runtime::DispatchCtx, workspace_dir: &/// workspace it was handed is the only one it touches.#[must_use]pub fn current_embedded_agent(ctx: &crate::core::runtime::DispatchCtx) -> Option<String> {- ctx.tenant()- .ok()- .and_then(|tenant| tenant.agent)+ ctx.tenant().ok().and_then(|tenant| tenant.agent)}/// The stores of the tenant the current [`CoreContext`] works for, keyed by@@ -201,7 +202,8 @@ pub fn current(ctx: &crate::core::runtime::DispatchCtx) -> Option<AgentStores> {/// session's own definition id), as before profiles existed.#[must_use]pub fn current_agent_key_or(ctx: &crate::core::runtime::DispatchCtx, fallback: &str) -> String {- let tenant = crate::core::runtime::tenant::isolated_unless_tenant(ctx.tenant(), "session_locator");+ let tenant =+ crate::core::runtime::tenant::isolated_unless_tenant(ctx.tenant(), "session_locator");if tenant.profile.is_some() {return crate::core::runtime::session_key(&tenant);}diff --git a/crates/openhuman-core/src/agent/session_store/workspace_tests.rs b/crates/openhuman-core/src/agent/session_store/workspace_tests.rsindex a3dbc916bc..84e0833f1c 100644--- a/crates/openhuman-core/src/agent/session_store/workspace_tests.rs+++ b/crates/openhuman-core/src/agent/session_store/workspace_tests.rs@@ -118,10 +118,16 @@ fn releasing_defaults_lets_the_next_call_open_afresh() {let ws = scratch();let before = fallback_provider(ws.path());let cached = fallback_provider(ws.path());- assert!(Arc::ptr_eq(&before, &cached), "a repeat call reuses the provider");+ assert!(+ Arc::ptr_eq(&before, &cached),+ "a repeat call reuses the provider"+ );release_workspace_defaults();let after = fallback_provider(ws.path());- assert!(!Arc::ptr_eq(&before, &after), "release drops the cached provider");+ assert!(+ !Arc::ptr_eq(&before, &after),+ "release drops the cached provider"+ );}#[test]diff --git a/crates/openhuman-core/src/agent/subagent_host/ops/graph_tests.rs b/crates/openhuman-core/src/agent/subagent_host/ops/graph_tests.rsindex d9d7569827..2f4f31d8da 100644--- a/crates/openhuman-core/src/agent/subagent_host/ops/graph_tests.rs+++ b/crates/openhuman-core/src/agent/subagent_host/ops/graph_tests.rs@@ -21,7 +21,8 @@ fn subagent_transcript_keeps_cumulative_spend_separate_from_unknown_last_call()source: tinyagents_harness::cost::CostSource::Charged,},};- super::transcript::persist_subagent_transcript(&crate::core::runtime::DispatchCtx::ambient(),+ super::transcript::persist_subagent_transcript(+ &crate::core::runtime::DispatchCtx::ambient(),workspace.path(),"root__usage","worker",@@ -35,7 +36,10 @@ fn subagent_transcript_keeps_cumulative_spend_separate_from_unknown_last_call()"test",2,);- let root = crate::agent::session_store::transcript_root(&crate::core::runtime::DispatchCtx::ambient(), workspace.path());+ let root = crate::agent::session_store::transcript_root(+ &crate::core::runtime::DispatchCtx::ambient(),+ workspace.path(),+ );let path = tinyagents_session::transcript::resolve_keyed_transcript_path(&root, "root__usage").unwrap();let transcript = tinyagents_session::transcript::read_transcript(&path).unwrap();diff --git a/crates/openhuman-core/src/channels/providers/relay/ops.rs b/crates/openhuman-core/src/channels/providers/relay/ops.rsindex 22660f4fd9..a2a2f51c9f 100644--- a/crates/openhuman-core/src/channels/providers/relay/ops.rs+++ b/crates/openhuman-core/src/channels/providers/relay/ops.rs@@ -112,7 +112,10 @@ pub(crate) async fn run_relay_turn(// waits instead of landing mid-turn. The pipeline's session id does not// name the thread, so the guard is taken on the thread itself; this task// runs in the caller's scope, which keys it to the caller's profile.- let busy = crate::agent::orchestration::busy_guard::TurnBusy::start_on_thread(&dispatch_ctx, &thread_id);+ let busy = crate::agent::orchestration::busy_guard::TurnBusy::start_on_thread(+ &dispatch_ctx,+ &thread_id,+ );let channel = Arc::new(RelayChannel::new(params.channel.clone(),params.client_id(),diff --git a/crates/openhuman-core/src/channels/providers/relay/ops_tests.rs b/crates/openhuman-core/src/channels/providers/relay/ops_tests.rsindex 70a3197275..b97c68a7c3 100644--- a/crates/openhuman-core/src/channels/providers/relay/ops_tests.rs+++ b/crates/openhuman-core/src/channels/providers/relay/ops_tests.rs@@ -104,7 +104,8 @@ async fn a_relayed_turn_runs_as_an_external_channel_and_keeps_its_thread() {let _bus = mock_agent_run_turn(move |req: AgentTurnRequest| {let mut seen = stub_seen.lock().unwrap();seen.busy- .push(crate::agent::orchestration::busy_guard::is_busy(&crate::core::runtime::DispatchCtx::ambient(),+ .push(crate::agent::orchestration::busy_guard::is_busy(+ &crate::core::runtime::DispatchCtx::ambient(),&relayed_thread,));seen.histories.push(@@ -155,7 +156,10 @@ async fn a_relayed_turn_runs_as_an_external_channel_and_keeps_its_thread() {"a relayed turn marks its thread busy, so a background result waits");assert!(- !crate::agent::orchestration::busy_guard::is_busy(&crate::core::runtime::DispatchCtx::ambient(), ¶ms("m1", "x").thread_id()),+ !crate::agent::orchestration::busy_guard::is_busy(+ &crate::core::runtime::DispatchCtx::ambient(),+ ¶ms("m1", "x").thread_id()+ ),"the thread is idle once the turn ends");for origin in &seen.origins {diff --git a/crates/openhuman-core/src/core/runtime/bootstrap.rs b/crates/openhuman-core/src/core/runtime/bootstrap.rsindex a86d544968..01b21905a2 100644--- a/crates/openhuman-core/src/core/runtime/bootstrap.rs+++ b/crates/openhuman-core/src/core/runtime/bootstrap.rs@@ -162,8 +162,10 @@ pub(crate) async fn bootstrap_core_runtime(// result never reached its chat thread is still pending in the durable// completion log (`<workspace>/.openhuman/background_completions.jsonl`).// Schedule its delivery turn through the normal idle-gated path.- let redelivering =- crate::agent::orchestration::background_delivery::recover_on_boot(&DispatchCtx::ambient(), &workspace_dir);+ let redelivering = crate::agent::orchestration::background_delivery::recover_on_boot(+ &DispatchCtx::ambient(),+ &workspace_dir,+ );if redelivering > 0 {log::info!("[runtime] scheduled redelivery of undelivered background completions for \diff --git a/crates/openhuman-core/src/cron/completion_owner.rs b/crates/openhuman-core/src/cron/completion_owner.rsindex e835354724..c2db8736ee 100644--- a/crates/openhuman-core/src/cron/completion_owner.rs+++ b/crates/openhuman-core/src/cron/completion_owner.rs@@ -22,11 +22,7 @@ static OWNERS: LazyLock<Mutex<HashMap<String, String>>> = LazyLock::new(Default:/// Notes that `job_id` just completed as the current context's agent, when/// it ran as one. Call just before publishing `CronJobCompleted`.pub fn note(ctx: &crate::core::runtime::DispatchCtx, job_id: &str) {- let Some(agent) = ctx- .tenant()- .ok()- .and_then(|tenant| tenant.agent)- else {+ let Some(agent) = ctx.tenant().ok().and_then(|tenant| tenant.agent) else {return;};let mut owners = OWNERSdiff --git a/crates/openhuman-core/src/cron/limits_tests.rs b/crates/openhuman-core/src/cron/limits_tests.rsindex 1847c63418..472919bb73 100644--- a/crates/openhuman-core/src/cron/limits_tests.rs+++ b/crates/openhuman-core/src/cron/limits_tests.rs@@ -163,12 +163,20 @@ async fn run_now_refuses_a_stored_job_that_breaks_the_limits() {let shell =add_shell_job(&config, None, Schedule::Every { every_ms: 600_000 }, "echo").unwrap();config.cron.agent_jobs_only = true;- assert!(crate::cron::ops::run_job_now(&crate::core::runtime::DispatchCtx::ambient(), &config, &shell.id)- .await- .is_err());- assert!(crate::cron::ops::cron_run(&crate::core::runtime::DispatchCtx::ambient(), &config, &shell.id)- .await- .is_err());+ assert!(crate::cron::ops::run_job_now(+ &crate::core::runtime::DispatchCtx::ambient(),+ &config,+ &shell.id+ )+ .await+ .is_err());+ assert!(crate::cron::ops::cron_run(+ &crate::core::runtime::DispatchCtx::ambient(),+ &config,+ &shell.id+ )+ .await+ .is_err());assert!(crate::cron::list_runs(&config, &shell.id, 10).unwrap().is_empty());diff --git a/crates/openhuman-core/src/cron/ops.rs b/crates/openhuman-core/src/cron/ops.rsindex 6606d19013..bc8a4f63d9 100644--- a/crates/openhuman-core/src/cron/ops.rs+++ b/crates/openhuman-core/src/cron/ops.rs@@ -260,7 +260,11 @@ pub async fn run_job_now(/// Execute `job` once (with its retry budget), deliver its output and persist/// the run and its last-run state. The caller holds the job's run claim.-async fn run_and_record(ctx: &crate::core::runtime::DispatchCtx, config: &Config, job: &CronJob) -> (bool, String) {+async fn run_and_record(+ ctx: &crate::core::runtime::DispatchCtx,+ config: &Config,+ job: &CronJob,+) -> (bool, String) {let run_id = uuid::Uuid::new_v4().to_string();let started_at = chrono::Utc::now();let (success, output) = cron::scheduler::execute_job_now(config, job, &run_id).await;diff --git a/crates/openhuman-core/src/cron/ops_tests.rs b/crates/openhuman-core/src/cron/ops_tests.rsindex 723d4ae7b6..90835638d5 100644--- a/crates/openhuman-core/src/cron/ops_tests.rs+++ b/crates/openhuman-core/src/cron/ops_tests.rs@@ -371,7 +371,9 @@ async fn cron_runs_returns_empty_history_for_new_job() {async fn cron_run_rejects_empty_job_id() {let tmp = TempDir::new().unwrap();let config = test_config(&tmp);- let err = cron_run(&crate::core::runtime::DispatchCtx::ambient(), &config, "").await.unwrap_err();+ let err = cron_run(&crate::core::runtime::DispatchCtx::ambient(), &config, "")+ .await+ .unwrap_err();assert!(err.contains("Missing 'job_id'"));}@@ -379,7 +381,13 @@ async fn cron_run_rejects_empty_job_id() {async fn cron_run_rejects_whitespace_job_id() {let tmp = TempDir::new().unwrap();let config = test_config(&tmp);- let err = cron_run(&crate::core::runtime::DispatchCtx::ambient(), &config, " ").await.unwrap_err();+ let err = cron_run(+ &crate::core::runtime::DispatchCtx::ambient(),+ &config,+ " ",+ )+ .await+ .unwrap_err();assert!(err.contains("Missing 'job_id'"));}@@ -387,7 +395,13 @@ async fn cron_run_rejects_whitespace_job_id() {async fn cron_run_errors_when_cron_disabled() {let tmp = TempDir::new().unwrap();let config = disabled_cron_config(&tmp);- let err = cron_run(&crate::core::runtime::DispatchCtx::ambient(), &config, "some-id").await.unwrap_err();+ let err = cron_run(+ &crate::core::runtime::DispatchCtx::ambient(),+ &config,+ "some-id",+ )+ .await+ .unwrap_err();assert!(err.contains("cron is disabled"));}@@ -397,7 +411,13 @@ async fn cron_run_returns_queued_immediately_for_valid_job() {let config = test_config(&tmp);let job = make_job(&config, "*/5 * * * *", None, "echo hello");- let out = cron_run(&crate::core::runtime::DispatchCtx::ambient(), &config, &job.id).await.unwrap();+ let out = cron_run(+ &crate::core::runtime::DispatchCtx::ambient(),+ &config,+ &job.id,+ )+ .await+ .unwrap();assert_eq!(out.value["job_id"], json!(job.id));assert_eq!(out.value["status"], json!("queued"));assert!(out.logs.iter().any(|l| l.contains("enqueued")));@@ -418,7 +438,13 @@ async fn cron_run_response_conforms_to_its_declared_schema() {let config = test_config(&tmp);let job = make_job(&config, "*/5 * * * *", None, "echo hello");- let out = cron_run(&crate::core::runtime::DispatchCtx::ambient(), &config, &job.id).await.unwrap();+ let out = cron_run(+ &crate::core::runtime::DispatchCtx::ambient(),+ &config,+ &job.id,+ )+ .await+ .unwrap();let result = out.value.as_object().expect("result payload is an object");let schema = cron_schemas("run");@@ -483,7 +509,13 @@ async fn cron_run_rejects_duplicate_concurrent_execution() {// Hold the run claim directly to simulate an in-flight execution without// spawning a real long-running subprocess (deterministic, no timing dependency).let running = try_acquire_run(&job.id).expect("the job is free");- let err = cron_run(&crate::core::runtime::DispatchCtx::ambient(), &config, &job.id).await.unwrap_err();+ let err = cron_run(+ &crate::core::runtime::DispatchCtx::ambient(),+ &config,+ &job.id,+ )+ .await+ .unwrap_err();drop(running);assert!(@@ -527,7 +559,13 @@ async fn run_job_now_runs_and_records_the_handler_result() {std::sync::Arc::new(|_ctx| Box::pin(async { Err("nope".to_string()) })),);let job = single_flight_system_job(&config, "ops-run-now");- let (success, output) = run_job_now(&crate::core::runtime::DispatchCtx::ambient(), &config, &job.id).await.unwrap();+ let (success, output) = run_job_now(+ &crate::core::runtime::DispatchCtx::ambient(),+ &config,+ &job.id,+ )+ .await+ .unwrap();assert!(!success);assert!(output.contains("nope"), "{output}");let runs = cron::list_runs(&config, &job.id, 10).unwrap();@@ -548,9 +586,21 @@ async fn run_job_now_refuses_a_job_that_is_already_running() {let config = test_config(&tmp);let job = single_flight_system_job(&config, "ops-run-now-busy");let _running = try_acquire_run(&job.id).expect("the job is free");- let err = run_job_now(&crate::core::runtime::DispatchCtx::ambient(), &config, &job.id).await.unwrap_err();+ let err = run_job_now(+ &crate::core::runtime::DispatchCtx::ambient(),+ &config,+ &job.id,+ )+ .await+ .unwrap_err();assert!(err.contains("already running"), "{err}");- let err = cron_run(&crate::core::runtime::DispatchCtx::ambient(), &config, &job.id).await.unwrap_err();+ let err = cron_run(+ &crate::core::runtime::DispatchCtx::ambient(),+ &config,+ &job.id,+ )+ .await+ .unwrap_err();assert!(err.contains("already running"), "{err}");}@@ -558,5 +608,11 @@ async fn run_job_now_refuses_a_job_that_is_already_running() {async fn run_job_now_reports_an_unknown_job() {let tmp = TempDir::new().unwrap();let config = test_config(&tmp);- assert!(run_job_now(&crate::core::runtime::DispatchCtx::ambient(), &config, "no-such-job").await.is_err());+ assert!(run_job_now(+ &crate::core::runtime::DispatchCtx::ambient(),+ &config,+ "no-such-job"+ )+ .await+ .is_err());}diff --git a/crates/openhuman-core/src/cron/scheduler/origin_delivery.rs b/crates/openhuman-core/src/cron/scheduler/origin_delivery.rsindex da36a747a0..76b5b71888 100644--- a/crates/openhuman-core/src/cron/scheduler/origin_delivery.rs+++ b/crates/openhuman-core/src/cron/scheduler/origin_delivery.rs@@ -80,8 +80,10 @@ pub(crate) async fn append_to_origin_transcript(tinyagents_session::transcript::AgentTranscriptFiles::new(workspace_dir, &agent).session_exists(&session);}- let locator =- FileTranscriptLocator::new(crate::agent::session_store::transcript_root(ctx, workspace_dir));+ let locator = FileTranscriptLocator::new(crate::agent::session_store::transcript_root(+ ctx,+ workspace_dir,+ ));let options = BackgroundAppend::new(append.idempotency_key,serde_json::json!({@@ -190,7 +192,18 @@ pub(crate) async fn deliver_to_origin(JobOrigin::Web {thread_id,agent_id,- } => deliver_to_web_thread(ctx, config, job, run_id, thread_id, agent_id.as_deref(), text).await,+ } => {+ deliver_to_web_thread(+ ctx,+ config,+ job,+ run_id,+ thread_id,+ agent_id.as_deref(),+ text,+ )+ .await+ }JobOrigin::Channel {channel,reply_target,diff --git a/crates/openhuman-core/src/cron/scheduler/origin_delivery_tests.rs b/crates/openhuman-core/src/cron/scheduler/origin_delivery_tests.rsindex 263fbfbdc1..83d02496e0 100644--- a/crates/openhuman-core/src/cron/scheduler/origin_delivery_tests.rs+++ b/crates/openhuman-core/src/cron/scheduler/origin_delivery_tests.rs@@ -90,9 +90,15 @@ async fn no_reply_is_suppressed_without_writing_anything() {let tmp = tempfile::TempDir::new().unwrap();let cfg = config(&tmp);seed_thread(&cfg, "t-1");- let status = deliver_to_origin(&crate::core::runtime::DispatchCtx::ambient(), &cfg, &job(Some(web("t-1"))), "run-1", " NO_REPLY ")- .await- .unwrap();+ let status = deliver_to_origin(+ &crate::core::runtime::DispatchCtx::ambient(),+ &cfg,+ &job(Some(web("t-1"))),+ "run-1",+ " NO_REPLY ",+ )+ .await+ .unwrap();assert_eq!(status, DeliveryStatus::Suppressed);assert!(conversations::get_messages(&crate::core::runtime::DispatchCtx::ambient(),@@ -111,9 +117,15 @@ async fn web_delivery_stores_one_row_under_the_run_reply_id_and_is_idempotent()let j = job(Some(web("t-1")));for _ in 0..2 {- let status = deliver_to_origin(&crate::core::runtime::DispatchCtx::ambient(), &cfg, &j, "run-1", " Drink water! ")- .await- .unwrap();+ let status = deliver_to_origin(+ &crate::core::runtime::DispatchCtx::ambient(),+ &cfg,+ &j,+ "run-1",+ " Drink water! ",+ )+ .await+ .unwrap();assert_eq!(status, DeliveryStatus::Delivered);}let messages = conversations::get_messages(@@ -130,9 +142,15 @@ async fn web_delivery_stores_one_row_under_the_run_reply_id_and_is_idempotent()assert_eq!(messages[0].content, "Drink water!");assert_eq!(messages[0].sender, "agent");- deliver_to_origin(&crate::core::runtime::DispatchCtx::ambient(), &cfg, &j, "run-2", "Again!")- .await- .unwrap();+ deliver_to_origin(+ &crate::core::runtime::DispatchCtx::ambient(),+ &cfg,+ &j,+ "run-2",+ "Again!",+ )+ .await+ .unwrap();assert_eq!(conversations::get_messages(&crate::core::runtime::DispatchCtx::ambient(),@@ -149,9 +167,15 @@ async fn web_delivery_stores_one_row_under_the_run_reply_id_and_is_idempotent()async fn web_delivery_to_a_missing_thread_fails() {let tmp = tempfile::TempDir::new().unwrap();let cfg = config(&tmp);- let err = deliver_to_origin(&crate::core::runtime::DispatchCtx::ambient(), &cfg, &job(Some(web("gone"))), "run-1", "hi")- .await- .unwrap_err();+ let err = deliver_to_origin(+ &crate::core::runtime::DispatchCtx::ambient(),+ &cfg,+ &job(Some(web("gone"))),+ "run-1",+ "hi",+ )+ .await+ .unwrap_err();assert!(err.to_string().contains("origin thread"));}@@ -159,9 +183,15 @@ async fn web_delivery_to_a_missing_thread_fails() {async fn origin_mode_without_an_origin_is_an_error() {let tmp = tempfile::TempDir::new().unwrap();let cfg = config(&tmp);- assert!(deliver_to_origin(&crate::core::runtime::DispatchCtx::ambient(), &cfg, &job(None), "run-1", "hi")- .await- .is_err());+ assert!(deliver_to_origin(+ &crate::core::runtime::DispatchCtx::ambient(),+ &cfg,+ &job(None),+ "run-1",+ "hi"+ )+ .await+ .is_err());}fn meta() -> TranscriptMeta {@@ -220,12 +250,24 @@ async fn web_delivery_appends_to_the_resumed_agent_transcript() {agent_id: Some("orchestrator".into()),}));j.id = "job-1".into();- deliver_to_origin(&crate::core::runtime::DispatchCtx::ambient(), &cfg, &j, "run-1", "Drink water!")- .await- .unwrap();- deliver_to_origin(&crate::core::runtime::DispatchCtx::ambient(), &cfg, &j, "run-1", "Drink water!")- .await- .unwrap();+ deliver_to_origin(+ &crate::core::runtime::DispatchCtx::ambient(),+ &cfg,+ &j,+ "run-1",+ "Drink water!",+ )+ .await+ .unwrap();+ deliver_to_origin(+ &crate::core::runtime::DispatchCtx::ambient(),+ &cfg,+ &j,+ "run-1",+ "Drink water!",+ )+ .await+ .unwrap();let head = locator.head_generation(&session);let path = resolve_keyed_transcript_path(&cfg.workspace_dir, &session_stem(&head)).unwrap();@@ -249,7 +291,8 @@ async fn transcript_append_waits_for_a_live_turn() {let workspace = cfg.workspace_dir.clone();let task = tokio::spawn(async move {- append_to_origin_transcript(&crate::core::runtime::DispatchCtx::ambient(),+ append_to_origin_transcript(+ &crate::core::runtime::DispatchCtx::ambient(),&workspace,&TranscriptAppend {thread_id: "t-1",diff --git a/crates/openhuman-core/src/cron/scheduler_classifier_and_delivery_tests.rs b/crates/openhuman-core/src/cron/scheduler_classifier_and_delivery_tests.rsindex b90bd15cd7..01941a9146 100644--- a/crates/openhuman-core/src/cron/scheduler_classifier_and_delivery_tests.rs+++ b/crates/openhuman-core/src/cron/scheduler_classifier_and_delivery_tests.rs@@ -13,9 +13,15 @@ async fn deliver_if_configured_skips_empty_mode() {let config = test_config(&tmp).await;let mut job = test_job("echo ok");job.delivery.mode = "".into();- assert!(deliver_if_configured(&crate::core::runtime::DispatchCtx::ambient(), &config, &job, "output", true)- .await- .is_ok());+ assert!(deliver_if_configured(+ &crate::core::runtime::DispatchCtx::ambient(),+ &config,+ &job,+ "output",+ true+ )+ .await+ .is_ok());}#[tokio::test]@@ -29,7 +35,14 @@ async fn deliver_if_configured_announce_missing_channel_errors() {to: Some("target".into()),best_effort: true,};- let result = deliver_if_configured(&crate::core::runtime::DispatchCtx::ambient(), &config, &job, "out", true).await;+ let result = deliver_if_configured(+ &crate::core::runtime::DispatchCtx::ambient(),+ &config,+ &job,+ "out",+ true,+ )+ .await;assert!(result.is_err());}@@ -44,7 +57,14 @@ async fn deliver_if_configured_announce_missing_target_errors() {to: None,best_effort: true,};- let result = deliver_if_configured(&crate::core::runtime::DispatchCtx::ambient(), &config, &job, "out", true).await;+ let result = deliver_if_configured(+ &crate::core::runtime::DispatchCtx::ambient(),+ &config,+ &job,+ "out",+ true,+ )+ .await;assert!(result.is_err());}@@ -59,9 +79,15 @@ async fn deliver_if_configured_proactive_mode_succeeds() {to: None,best_effort: true,};- assert!(deliver_if_configured(&crate::core::runtime::DispatchCtx::ambient(), &config, &job, "hello", true)- .await- .is_ok());+ assert!(deliver_if_configured(+ &crate::core::runtime::DispatchCtx::ambient(),+ &config,+ &job,+ "hello",+ true+ )+ .await+ .is_ok());}// ──────────────────────────────────────────────────────────────────────@@ -610,11 +636,15 @@ async fn deliver_if_configured_failure_skips_chat_but_alerts() {let config = test_config(&tmp).await;let job = proactive_job();// Failed run (non-empty canned error): no chat injection, but still alerts.- assert!(- deliver_if_configured(&crate::core::runtime::DispatchCtx::ambient(), &config, &job, "Something went wrong.", false)- .await- .is_ok()- );+ assert!(deliver_if_configured(+ &crate::core::runtime::DispatchCtx::ambient(),+ &config,+ &job,+ "Something went wrong.",+ false+ )+ .await+ .is_ok());assert_eq!(cron_alerts(&config).await, 1);}@@ -624,9 +654,15 @@ async fn deliver_if_configured_empty_failure_alerts_with_fallback_body() {let config = test_config(&tmp).await;let job = proactive_job();// Empty failed run: still surfaces in /notifications with a fallback body.- assert!(deliver_if_configured(&crate::core::runtime::DispatchCtx::ambient(), &config, &job, "", false)- .await- .is_ok());+ assert!(deliver_if_configured(+ &crate::core::runtime::DispatchCtx::ambient(),+ &config,+ &job,+ "",+ false+ )+ .await+ .is_ok());let items =crate::desktop::notifications::store::list(&config, 10, 0, Some("cron"), None).unwrap();assert_eq!(items.len(), 1);diff --git a/crates/openhuman-core/src/cron/scheduler_frequency_tests.rs b/crates/openhuman-core/src/cron/scheduler_frequency_tests.rsindex 6febabc8d9..6cb3c2c0eb 100644--- a/crates/openhuman-core/src/cron/scheduler_frequency_tests.rs+++ b/crates/openhuman-core/src/cron/scheduler_frequency_tests.rs@@ -10,7 +10,15 @@ async fn deliver_if_configured_empty_success_skips_chat_and_alert() {let config = test_config(&tmp).await;let job = proactive_job();// Successful but empty: nothing delivered anywhere.- assert!(deliver_if_configured(&crate::core::runtime::DispatchCtx::ambient(), &config, &job, "", true).await.is_ok());+ assert!(deliver_if_configured(+ &crate::core::runtime::DispatchCtx::ambient(),+ &config,+ &job,+ "",+ true+ )+ .await+ .is_ok());assert_eq!(cron_alerts(&config).await, 0);}diff --git a/crates/openhuman-core/src/cron/scheduler_halt_and_persist_tests.rs b/crates/openhuman-core/src/cron/scheduler_halt_and_persist_tests.rsindex f550228750..514ec50a0b 100644--- a/crates/openhuman-core/src/cron/scheduler_halt_and_persist_tests.rs+++ b/crates/openhuman-core/src/cron/scheduler_halt_and_persist_tests.rs@@ -542,9 +542,15 @@ async fn deliver_if_configured_skips_non_announce_mode() {let job = test_job("echo ok");// Default delivery mode is not "announce", so nothing is published.- assert!(deliver_if_configured(&crate::core::runtime::DispatchCtx::ambient(), &config, &job, "x", true)- .await- .is_ok());+ assert!(deliver_if_configured(+ &crate::core::runtime::DispatchCtx::ambient(),+ &config,+ &job,+ "x",+ true+ )+ .await+ .is_ok());}#[tokio::test]@@ -601,9 +607,15 @@ async fn deliver_if_configured_publishes_event_for_announce_mode() {assert_eq!(received.load(Ordering::SeqCst), 1);// Also verify the function itself succeeds.- assert!(deliver_if_configured(&crate::core::runtime::DispatchCtx::ambient(), &config, &job, "hello", true)- .await- .is_ok());+ assert!(deliver_if_configured(+ &crate::core::runtime::DispatchCtx::ambient(),+ &config,+ &job,+ "hello",+ true+ )+ .await+ .is_ok());}#[test]diff --git a/crates/openhuman-core/src/desktop/notifications/bus_tests_2_tests.rs b/crates/openhuman-core/src/desktop/notifications/bus_tests_2_tests.rsindex 54ee069c29..e7480e70db 100644--- a/crates/openhuman-core/src/desktop/notifications/bus_tests_2_tests.rs+++ b/crates/openhuman-core/src/desktop/notifications/bus_tests_2_tests.rs@@ -544,7 +544,10 @@ async fn a_noted_cron_completion_names_its_agent() {.session_agent("notif-owner-agent"),);crate::core::runtime::CoreContext::scope(context, async {- crate::cron::completion_owner::note(&crate::core::runtime::DispatchCtx::ambient(), "notif-owner-job");+ crate::cron::completion_owner::note(+ &crate::core::runtime::DispatchCtx::ambient(),+ "notif-owner-job",+ );}).await;let event = DomainEvent::CronJobCompleted {diff --git a/crates/openhuman-core/src/profiles/turn_gate_tests.rs b/crates/openhuman-core/src/profiles/turn_gate_tests.rsindex 66f1b85742..9f5aa28a80 100644--- a/crates/openhuman-core/src/profiles/turn_gate_tests.rs+++ b/crates/openhuman-core/src/profiles/turn_gate_tests.rs@@ -27,5 +27,7 @@ async fn other_profiles_are_not_held_up() {#[tokio::test]async fn work_without_a_profile_is_not_gated() {- assert!(acquire(&crate::core::runtime::DispatchCtx::ambient()).await.is_none());+ assert!(acquire(&crate::core::runtime::DispatchCtx::ambient())+ .await+ .is_none());}diff --git a/crates/openhuman-core/src/threads/ops_conversion_tests.rs b/crates/openhuman-core/src/threads/ops_conversion_tests.rsindex 27102f67d1..5dee23ead2 100644--- a/crates/openhuman-core/src/threads/ops_conversion_tests.rs+++ b/crates/openhuman-core/src/threads/ops_conversion_tests.rs@@ -368,7 +368,8 @@ async fn thread_delete_removes_persisted_turn_state_snapshot() {// Queue a finished background sub-agent result for this thread; deleting the// thread must discard it so it's never delivered into a dead thread.use crate::agent::orchestration::background_completions as bg;- bg::record_completion(&crate::core::runtime::DispatchCtx::ambient(),+ bg::record_completion(+ &crate::core::runtime::DispatchCtx::ambient(),&dir,"sess-del","sub-del-1",@@ -430,7 +431,8 @@ async fn threads_purge_removes_every_turn_state_snapshot() {// Queue background sub-agent results across sessions; a full purge must wipe// them all since no parent thread survives.use crate::agent::orchestration::background_completions as bg;- bg::record_completion(&crate::core::runtime::DispatchCtx::ambient(),+ bg::record_completion(+ &crate::core::runtime::DispatchCtx::ambient(),&dir,"sess-p1","sub-p1",@@ -439,7 +441,8 @@ async fn threads_purge_removes_every_turn_state_snapshot() {Some("thread-a".into()),).await;- bg::record_completion(&crate::core::runtime::DispatchCtx::ambient(),+ bg::record_completion(+ &crate::core::runtime::DispatchCtx::ambient(),&dir,"sess-p2","sub-p2",diff --git a/crates/openhuman-core/src/web_chat/ops/channel_ops.rs b/crates/openhuman-core/src/web_chat/ops/channel_ops.rsindex 4eca5bc1ea..93ae12e1f9 100644--- a/crates/openhuman-core/src/web_chat/ops/channel_ops.rs+++ b/crates/openhuman-core/src/web_chat/ops/channel_ops.rs@@ -161,10 +161,10 @@ async fn cancel_chat_inner(// the gap between abort and the queue sweep.let discarded =crate::agent::orchestration::background_completions::discard_pending_for_thread(- ctx,- thread_id,+ ctx, thread_id,);- let stopped = crate::agent::orchestration::running_subagents::stop_for_thread(ctx, thread_id);+ let stopped =+ crate::agent::orchestration::running_subagents::stop_for_thread(ctx, thread_id);crate::agent::orchestration::background_completions::finish_stop_for_thread(ctx, thread_id, &stopped,);diff --git a/crates/openhuman-core/src/web_chat/web_tests_session_and_concurrency_tests.rs b/crates/openhuman-core/src/web_chat/web_tests_session_and_concurrency_tests.rsindex 2b92993e4c..c9fbb43e64 100644--- a/crates/openhuman-core/src/web_chat/web_tests_session_and_concurrency_tests.rs+++ b/crates/openhuman-core/src/web_chat/web_tests_session_and_concurrency_tests.rs@@ -619,7 +619,8 @@ async fn unscoped_cancel_stops_the_threads_detached_subagents() {let workspace = tempfile::tempdir().expect("workspace");let child = tokio::spawn(std::future::pending::<()>());let (_status_tx, status_rx) = running_subagents::status_channel();- running_subagents::register(&crate::core::runtime::DispatchCtx::ambient(),+ running_subagents::register(+ &crate::core::runtime::DispatchCtx::ambient(),"task-web-stop-1".into(),"researcher".into(),"session-web-stop".into(),diff --git a/crates/openhuman-embed/src/cron.rs b/crates/openhuman-embed/src/cron.rsindex 5ab480534c..02d691e729 100644--- a/crates/openhuman-embed/src/cron.rs+++ b/crates/openhuman-embed/src/cron.rs@@ -463,9 +463,10 @@ impl<'a> Cron<'a> {.find(name)?.ok_or_else(|| CronError::NotFound(name.to_string()))?;log::debug!("[embed][cron] run_now name={name} id={}", job.id);- let (success, output) = openhuman_core::cron::ops::run_job_now(&self.dispatch, self.config, &job.id)- .await- .map_err(CronError::Run)?;+ let (success, output) =+ openhuman_core::cron::ops::run_job_now(&self.dispatch, self.config, &job.id)+ .await+ .map_err(CronError::Run)?;Ok(JobRun { success, output })}