Skip to content

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

refactor(runtime): extract flows boot reconcile into helper

Steven Enamakelbcf9a6190257
diff --git a/crates/openhuman-core/src/core/runtime/services.rs b/crates/openhuman-core/src/core/runtime/services.rs
index 4b527de25f..44d30facf8 100644
--- a/crates/openhuman-core/src/core/runtime/services.rs
+++ b/crates/openhuman-core/src/core/runtime/services.rs
@@ -236,11 +236,8 @@ pub fn spawn_flows_boot_reconcile(ctx: std::sync::Arc<crate::core::runtime::Core
tokio::spawn(async move {
log::debug!("[flows] boot reconcile: loading config");
let dispatch = crate::core::runtime::DispatchCtx::new(ctx);
- match dispatch.load_config().await {
- Ok(config) => {
- let swept =
- crate::flows::recovery::sweep_orphaned_runs_on_boot(&dispatch, &config)
- .await;
+ match reconcile_flows_on_boot(&dispatch).await {
+ Ok(swept) => {
// Logged unconditionally: a silent success and a task that
// never ran are otherwise indistinguishable in a boot log.
log::debug!("[flows] boot reconcile: completed; reconciled_runs={swept}");
@@ -250,8 +247,8 @@ pub fn spawn_flows_boot_reconcile(ctx: std::sync::Arc<crate::core::runtime::Core
);
}
}
- Err(err) => {
- log::warn!("[core] config load failed, skipping flows boot reconcile: {err}");
+ Err(error) => {
+ log::warn!("[core] config load failed, skipping flows boot reconcile: {error}");
}
}
});
@@ -260,6 +257,13 @@ pub fn spawn_flows_boot_reconcile(ctx: std::sync::Arc<crate::core::runtime::Core
log::debug!("[flows] flows feature disabled at compile time — no boot run reconciliation");
}
+async fn reconcile_flows_on_boot(
+ dispatch: &crate::core::runtime::DispatchCtx,
+) -> Result<usize, String> {
+ let config = dispatch.load_config().await.map_err(|error| error.to_string())?;
+ Ok(crate::flows::recovery::sweep_orphaned_runs_on_boot(dispatch, &config).await)
+}
+
/// Cron scheduler — ticks the schedule module every ~5s and executes due jobs
/// automatically. Gated by `config.cron.enabled`.
///