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): add commit_thread_deletion to finalize deletion fences
Steven Enamakel52a2f7a32445
diff --git a/crates/openhuman-core/src/agent/orchestration/completion_owners.rs b/crates/openhuman-core/src/agent/orchestration/completion_owners.rsindex 1b1925385c..4ace19e4ca 100644--- a/crates/openhuman-core/src/agent/orchestration/completion_owners.rs+++ b/crates/openhuman-core/src/agent/orchestration/completion_owners.rs@@ -162,6 +162,24 @@ pub(crate) fn begin_thread_deletion(Ok(())}+/// Mark that the durable deleted-parent marker was written successfully.+pub(crate) fn commit_thread_deletion(+ ctx: &crate::core::runtime::DispatchCtx,+ workspace_dir: &std::path::Path,+ thread_id: &str,+) -> Result<(), String> {+ let profile = ctx+ .tenant()+ .map_err(|error| format!("cannot resolve profile for thread deletion: {error}"))?+ .profile;+ owners().deleting_threads.insert(driver_thread_scope(+ profile,+ workspace_dir.to_path_buf(),+ thread_id.to_owned(),+ ));+ Ok(())+}+/// Release a temporary deletion fence when the conversation delete itself failed.pub(crate) fn release_thread_deletion(ctx: &crate::core::runtime::DispatchCtx,diff --git a/crates/openhuman-core/src/agent/orchestration/completion_owners_tests.rs b/crates/openhuman-core/src/agent/orchestration/completion_owners_tests.rsindex f89c2d88e3..e0c2596c41 100644--- a/crates/openhuman-core/src/agent/orchestration/completion_owners_tests.rs+++ b/crates/openhuman-core/src/agent/orchestration/completion_owners_tests.rs@@ -74,3 +74,59 @@ fn deleting_thread_refuses_late_owner_registration_but_keeps_prior_owner() {);assert!(!st.driver_tasks.contains_key("late"));}++#[test]+fn failed_overlapping_delete_release_keeps_thread_owner_fenced() {+ let ctx = crate::core::runtime::DispatchCtx::ambient();+ let workspace = tempfile::tempdir().expect("workspace");+ let thread = "overlapping-delete-release";+ begin_thread_deletion(&ctx, workspace.path(), thread).expect("first delete begins");+ begin_thread_deletion(&ctx, workspace.path(), thread).expect("overlapping delete begins");++ release_thread_deletion(&ctx, workspace.path(), thread);+ let late_owner = note_driver_task(+ &ctx,+ "overlapping-delete-late-task",+ workspace.path().to_path_buf(),+ tinytools::WorkspaceDescriptor::new(workspace.path()),+ "overlapping-delete-parent".into(),+ Some(thread.into()),+ );+ release_thread_deletion(&ctx, workspace.path(), thread);+ if late_owner.is_ok() {+ finish_driver_task(&ctx, "overlapping-delete-late-task");+ }++ assert!(+ late_owner.is_err(),+ "one failed attempt must not clear another's fence"+ );+}++#[test]+fn retry_release_cannot_remove_committed_thread_deletion_fence() {+ let ctx = crate::core::runtime::DispatchCtx::ambient();+ let workspace = tempfile::tempdir().expect("workspace");+ let thread = "committed-delete-retry";+ begin_thread_deletion(&ctx, workspace.path(), thread).expect("delete begins");+ commit_thread_deletion(&ctx, workspace.path(), thread).expect("durable close commits");+ begin_thread_deletion(&ctx, workspace.path(), thread).expect("delete retry begins");++ release_thread_deletion(&ctx, workspace.path(), thread);+ let late_owner = note_driver_task(+ &ctx,+ "committed-delete-late-task",+ workspace.path().to_path_buf(),+ tinytools::WorkspaceDescriptor::new(workspace.path()),+ "committed-delete-parent".into(),+ Some(thread.into()),+ );+ if late_owner.is_ok() {+ finish_driver_task(&ctx, "committed-delete-late-task");+ }++ assert!(+ late_owner.is_err(),+ "a retry release cannot reopen a deleted parent"+ );+}