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(cron): keep manual run callback alive until acknowledgement commits
Steven Enamakelcee6863b8f55
diff --git a/crates/openhuman-core/src/cron/bus_host.rs b/crates/openhuman-core/src/cron/bus_host.rsindex ede5f6923d..b432be6d49 100644--- a/crates/openhuman-core/src/cron/bus_host.rs+++ b/crates/openhuman-core/src/cron/bus_host.rs@@ -129,6 +129,13 @@ impl Binding {DispatchCtx::from_weak(self.context.as_ref())}+ /// Pin the bound context for a finite module lifecycle handoff. The host+ /// registration itself keeps only the weak reference, avoiding a cycle+ /// through long-lived scheduler state.+ pub(crate) fn pin_context(&self) -> Option<Arc<CoreContext>> {+ self.context.as_ref().and_then(Weak::upgrade)+ }+/// Runs `fut` under the bound context. A context that has since been/// dropped (its agent is no longer live) runs `fut` as the caller is.pub(crate) async fn within<F: Future>(&self, fut: F) -> F::Output {diff --git a/crates/openhuman-core/src/cron/scheduler/dispatcher.rs b/crates/openhuman-core/src/cron/scheduler/dispatcher.rsindex 23a70fe871..e7c5f9701c 100644--- a/crates/openhuman-core/src/cron/scheduler/dispatcher.rs+++ b/crates/openhuman-core/src/cron/scheduler/dispatcher.rs@@ -65,6 +65,7 @@ pub(crate) async fn run_job_now(reply_rx.await.map_err(|_| anyhow!("cron manual worker owner stopped before reporting admission"))?+ .map_err(anyhow::Error::msg)}async fn own_manual_run(@@ -178,15 +179,19 @@ async fn own_manual_run({Ok(Some(state)) => state,// The released contract defines absence as no retained worker- // in this module generation. It is quiescent, but does not- // prove admission or success.+ // in this module generation. We cannot infer that the+ // service is still in the generation that prepared this+ // handle, so keep the callback and context and reconcile.Ok(None) => {if let Some(reply_tx) = reply_tx.take() {let _ = reply_tx.send(Err("cron manual worker disappeared before a terminal result".to_string(),));}- return Ok(());+ tracing::debug!("[cron:scheduler] manual handle absent without observed terminal state; retaining callback while reconciling");+ tokio::time::sleep(retry_delay).await;+ retry_delay = (retry_delay * 2).min(Duration::from_secs(1));+ continue;}Err(error) => {tracing::debug!(error = %error.wire_message(), "[cron:scheduler] retrying WaitManualRun");@@ -259,7 +264,29 @@ async fn own_manual_run(};match result {Ok(true) => break,- Ok(false) => tracing::debug!("[cron:scheduler] terminal manual handle not yet acknowledged"),+ Ok(false) => {+ tracing::debug!("[cron:scheduler] terminal manual handle not yet acknowledged");+ match module::proxy(&config).await {+ Ok(proxy) => match proxy+ .call::<Option<ManualRunState>>(+ members::WAIT_MANUAL_RUN,+ (WaitManualRun {+ handle: ack.handle.clone(),+ },),+ )+ .await+ {+ // The worker's terminal state was observed before+ // Ack, so absence now means the acknowledgement's+ // effect committed despite an earlier lost response.+ Ok(None) => break,+ Ok(Some(ManualRunState::Terminal { .. })) => {}+ Ok(Some(_)) => tracing::warn!("[cron:scheduler] acknowledged manual worker returned to a nonterminal state"),+ Err(error) => tracing::debug!(error = %error.wire_message(), "[cron:scheduler] reconciling manual acknowledgement"),+ },+ Err(error) => tracing::debug!(%error, "[cron:scheduler] reconciling manual acknowledgement"),+ }+ }Err(error) => tracing::debug!(error = %error.wire_message(), "[cron:scheduler] retrying ambiguous AcknowledgeManualRun"),}tokio::time::sleep(retry_delay).await;@@ -464,6 +491,7 @@ impl Drop for JobDispatcher {return;};let config = self.binding.config();+ let context_pin = self.binding.pin_context();let Ok(runtime) = tokio::runtime::Handle::try_current() else {return;};@@ -472,6 +500,7 @@ impl Drop for JobDispatcher {// is retried while the registration remains owned by this task.runtime.spawn(async move {let Started { handle, host } = started;+ let _context_pin = context_pin;let _host_lifetime = host;let mut retry_delay = Duration::from_millis(100);loop {diff --git a/crates/openhuman-core/src/modules/registry_contract_tests.rs b/crates/openhuman-core/src/modules/registry_contract_tests.rsindex 90f47ade12..7c346da47c 100644--- a/crates/openhuman-core/src/modules/registry_contract_tests.rs+++ b/crates/openhuman-core/src/modules/registry_contract_tests.rs@@ -185,12 +185,21 @@ fn the_flows_record_pins_every_host_of_one_release() {let record = find("tinyflows").unwrap();assert_eq!(record.version, "0.8.25");assert_eq!(record.assets.len(), 11);- for asset in record.assets {- assert!(- asset.archive.starts_with("tinyflows-module-0.8.25-"),- "{}",- asset.archive- );- assert_eq!(asset.sha256.len(), 64, "{}", asset.archive);+ let expected = [+ ("tinyflows-module-0.8.25-macos-26-arm64.tar.gz", "af7e4fd98885704f4745384b32f628128954389595269698bc26fa90be41ea68"),+ ("tinyflows-module-0.8.25-macos-26-x86_64.tar.gz", "d253d9ca4d95b806042b7b5bc4f98acfdb174c0512e3fb7035a46a7e0e07b39d"),+ ("tinyflows-module-0.8.25-macos-15-arm64.tar.gz", "2f6a938f3d12874db93d3b44eca3e7aa44418cd1c6d07a06813d3ff10eddacbe"),+ ("tinyflows-module-0.8.25-macos-15-x86_64.tar.gz", "7dafc35c4754e1198209f0fd182e3ab3e7e1aa2bb6cfdcfad1bae0649049aa7f"),+ ("tinyflows-module-0.8.25-ubuntu-24.04-x86_64.tar.gz", "1a713e76ff38034481a06cfc0dc9cee1c59af80af6338d9d4a4c8901fbab7c8f"),+ ("tinyflows-module-0.8.25-ubuntu-24.04-arm64.tar.gz", "b0f59ee5d2f7726f409a5e3d5cd48eea2f2a2f32fe82a070eb8758ee80ae2646"),+ ("tinyflows-module-0.8.25-ubuntu-22.04-x86_64.tar.gz", "4d8f500c83243894daea71a3051c1d549269cd2079bf114469c41324a7e3733d"),+ ("tinyflows-module-0.8.25-ubuntu-22.04-arm64.tar.gz", "3eadc6e3e71a6176354a695b33897b6eda61ba469f26dc51e27dd3e966cebda0"),+ ("tinyflows-module-0.8.25-windows-2025-x86_64.zip", "9cf9b8bf35b4e7134a57dc5e03d14966c9ff468bfec16fcac8b22285dcbc2e40"),+ ("tinyflows-module-0.8.25-windows-2022-x86_64.zip", "bb5c8d97030aa53a05c3baf60bb1e3a6a8631be6add72a03823052b795fb1286"),+ ("tinyflows-module-0.8.25-windows-11-arm64.zip", "712cf7bc89b3d0a1a02beff3d792990047cd946a23433a3e6f54b35545963ad8"),+ ];+ for (asset, (archive, sha256)) in record.assets.iter().zip(expected) {+ assert_eq!(asset.archive, archive);+ assert_eq!(asset.sha256, sha256, "{}", asset.archive);}}