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
feat(orchestration): fence driver task admission during thread deletion
Steven Enamakel855641cd4f22
diff --git a/crates/openhuman-core/src/agent/orchestration/completion_owners.rs b/crates/openhuman-core/src/agent/orchestration/completion_owners.rsindex e9d71370c7..44814ad949 100644--- a/crates/openhuman-core/src/agent/orchestration/completion_owners.rs+++ b/crates/openhuman-core/src/agent/orchestration/completion_owners.rs@@ -44,6 +44,14 @@ struct Owners {terminal_driver_tasks: HashMap<String, DriverTaskOwner>,terminal_driver_task_order: VecDeque<String>,driver_cancel_reasons: HashMap<String, String>,+ deleting_threads: std::collections::HashSet<DriverThreadScope>,+}++#[derive(Clone, Debug, Hash, PartialEq, Eq)]+struct DriverThreadScope {+ profile: Option<String>,+ workspace_dir: PathBuf,+ thread_id: String,}#[derive(Clone)]@@ -114,6 +122,18 @@ fn remember_active_driver_task(Ok(())}+fn driver_thread_scope(+ profile: Option<String>,+ workspace_dir: PathBuf,+ thread_id: String,+) -> DriverThreadScope {+ DriverThreadScope {+ profile,+ workspace_dir,+ thread_id,+ }+}+/// Move a settled task out of the non-evictable live-owner set while retaining/// its scope for the bounded late cancel-by-task compatibility path.pub(crate) fn finish_driver_task(ctx: &crate::core::runtime::DispatchCtx, task_id: &str) {diff --git a/crates/openhuman-core/src/agent/orchestration/completion_owners_tests.rs b/crates/openhuman-core/src/agent/orchestration/completion_owners_tests.rsindex 05874714ab..b1532e95a8 100644--- a/crates/openhuman-core/src/agent/orchestration/completion_owners_tests.rs+++ b/crates/openhuman-core/src/agent/orchestration/completion_owners_tests.rs@@ -42,3 +42,37 @@ fn active_owner_capacity_refuses_new_tasks_without_evicting_live_scope() {assert!(st.driver_tasks.contains_key("task-0"));assert!(!st.driver_tasks.contains_key("new-task"));}++#[test]+fn deleting_thread_refuses_late_owner_registration_but_keeps_prior_owner() {+ let mut st = Owners::default();+ let existing = owner("existing");+ let existing_key = "existing".to_owned();+ remember_active_driver_task(+ &mut st,+ existing_key.clone(),+ existing.clone(),+ ACTIVE_DRIVER_TASKS_CAP,+ )+ .expect("register live child before deletion starts");+ st.deleting_threads.insert(driver_thread_scope(+ existing.profile.clone(),+ existing.workspace_dir.clone(),+ existing.parent_thread_id.clone().expect("thread owner"),+ ));++ let late = owner("late");+ let result = remember_active_driver_task(+ &mut st,+ "late".into(),+ late,+ ACTIVE_DRIVER_TASKS_CAP,+ );++ assert!(result.is_err(), "a child cannot enter after deletion fences admission");+ assert!(+ st.driver_tasks.contains_key(&existing_key),+ "deletion still sees owners admitted before its fence"+ );+ assert!(!st.driver_tasks.contains_key("late"));+}