Skip to content

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

refactor(orchestration): extract delegation checkpointer construction

Steven Enamakelb95ac6c12e87
diff --git a/crates/openhuman-core/src/agent/orchestration/delegation.rs b/crates/openhuman-core/src/agent/orchestration/delegation.rs
index 453415c22a..7c7ff8d31a 100644
--- a/crates/openhuman-core/src/agent/orchestration/delegation.rs
+++ b/crates/openhuman-core/src/agent/orchestration/delegation.rs
@@ -84,23 +84,7 @@ pub(crate) async fn run_subagent_delegation_with_parent_context(
//
// With a storage backend configured (`crate::storage`) the checkpoints
// live there instead, in the acting agent's scope.
- let checkpointer: Arc<dyn Checkpointer<DelegationState>> =
- match crate::storage::current_scoped()
- .map_err(|e| format!("resolve the storage scope for graph checkpoints: {e}"))?
- {
- Some(scoped) => Arc::new(tinyagents_graph::checkpoint::DriverCheckpointer::<
- DelegationState,
- >::with_prefix(
- Arc::clone(scoped.documents()), "delegation_graph"
- )),
- None => {
- let checkpoint_db = config.workspace_dir.join("graph_checkpoints.db");
- Arc::new(
- SqliteCheckpointer::<DelegationState>::open(&checkpoint_db)
- .map_err(|e| format!("open durable graph checkpoint store: {e}"))?,
- )
- }
- };
+ let checkpointer = open_delegation_checkpointer(&config)?;
tracing::info!(
target: LOG_TARGET,
@@ -311,6 +295,31 @@ fn delegation_subagent_options(
}
}
+/// Open the delegation graph's durable checkpointer: the acting agent's scope
+/// on the storage backend when one is installed, else `graph_checkpoints.db`
+/// under the workspace.
+pub fn open_delegation_checkpointer(
+ config: &Config,
+) -> Result<Arc<dyn Checkpointer<DelegationState>>, String> {
+ match crate::storage::current_scoped()
+ .map_err(|e| format!("resolve the storage scope for graph checkpoints: {e}"))?
+ {
+ Some(scoped) => Ok(Arc::new(
+ tinyagents_graph::checkpoint::DriverCheckpointer::<DelegationState>::with_prefix(
+ Arc::clone(scoped.documents()),
+ "delegation_graph",
+ ),
+ )),
+ None => {
+ let checkpoint_db = config.workspace_dir.join("graph_checkpoints.db");
+ Ok(Arc::new(
+ SqliteCheckpointer::<DelegationState>::open(&checkpoint_db)
+ .map_err(|e| format!("open durable graph checkpoint store: {e}"))?,
+ ))
+ }
+ }
+}
+
#[cfg(test)]
#[path = "delegation_tests.rs"]
mod tests;
diff --git a/crates/openhuman-core/src/agent/orchestration/mod.rs b/crates/openhuman-core/src/agent/orchestration/mod.rs
index a86758bc04..7aeb9d42ef 100644
--- a/crates/openhuman-core/src/agent/orchestration/mod.rs
+++ b/crates/openhuman-core/src/agent/orchestration/mod.rs
@@ -22,6 +22,7 @@ pub mod command_center;
pub(crate) mod completion_notice;
pub(crate) mod completion_target;
pub(crate) mod delegation;
+pub use delegation::open_delegation_checkpointer;
pub(crate) mod fleet_tools;
mod ops;
pub(crate) mod parent_context;
diff --git a/crates/openhuman-core/src/flows/tinyflows/state_tests.rs b/crates/openhuman-core/src/flows/tinyflows/state_tests.rs
index a37ea0ea2c..6735bbad88 100644
--- a/crates/openhuman-core/src/flows/tinyflows/state_tests.rs
+++ b/crates/openhuman-core/src/flows/tinyflows/state_tests.rs
@@ -65,10 +65,10 @@ fn without_a_backend_the_flow_state_is_sqlite() {
workspace_dir: dir.path().to_path_buf(),
..Config::default()
};
- if crate::storage::installed().is_none() {
- assert!(matches!(
- FlowState::open(&config, "flow:a"),
- FlowState::Sqlite(_)
- ));
- }
+ // Nothing in this binary installs a backend, so the slot is empty.
+ assert!(crate::storage::installed().is_none());
+ assert!(matches!(
+ FlowState::open(&config, "flow:a"),
+ FlowState::Sqlite(_)
+ ));
}
diff --git a/scripts/ci/check-dep-sim-calibration.sh b/scripts/ci/check-dep-sim-calibration.sh
index 017a9f7d1b..a43acd9c5d 100755
--- a/scripts/ci/check-dep-sim-calibration.sh
+++ b/scripts/ci/check-dep-sim-calibration.sh
@@ -107,8 +107,11 @@ cd "$(dirname "$0")/../.."
# 314 -> 315 on 2026-10-09: secrets on the storage backend add the
# first-party tinystoragedrivers-secrets crate (its crypto deps were already
# in the graph).
-# This matches the current `flows:337:315:2` entry in
+# 315 -> 316 on 2026-10-09: cron and flows on the storage ports add the
+# first-party tinyflows-drivers crate (one package, one name; no new
+# external crate).
+# This matches the current `flows:338:316:2` entry in
# scripts/kernel-floor.limits; its preceding entries are historical.
-EXPECTED_NAMES=315
+EXPECTED_NAMES=316
exec python3 scripts/dep-sim.py --cut-nothing --expect-names "${EXPECTED_NAMES}"
diff --git a/scripts/kernel-floor.limits b/scripts/kernel-floor.limits
index 2e05796738..265c412e25 100644
--- a/scripts/kernel-floor.limits
+++ b/scripts/kernel-floor.limits
@@ -665,4 +665,7 @@
# from the Linux flows graph; native builds remain at 3.
# 337/315/2 2026-10-09 secrets on the storage backend add the first-party
# tinystoragedrivers-secrets crate (one package, one name).
-flows:337:315:2
+# 338/316/2 2026-10-09 cron and flows on the storage ports add the first-party
+# tinyflows-drivers crate (one package, one name; no new
+# external crate, native builds unchanged).
+flows:338:316:2
diff --git a/tests/storage_flows_e2e.rs b/tests/storage_flows_e2e.rs
index b2f0c032e1..eb70cd7a43 100644
--- a/tests/storage_flows_e2e.rs
+++ b/tests/storage_flows_e2e.rs
@@ -75,7 +75,11 @@ async fn a_configured_backend_holds_cron_flows_and_flow_state() {
.await
.unwrap();
- for path in ["cron/jobs.db", "flows/flows.db"] {
+ // The delegation graph's checkpointer lives on the backend too.
+ let delegation_config = config.clone();
+ openhuman_core::agent::orchestration::open_delegation_checkpointer(&delegation_config).unwrap();
+
+ for path in ["cron/jobs.db", "flows/flows.db", "graph_checkpoints.db"] {
assert!(
!workspace.path().join(path).exists(),
"{path} was not written"
@@ -84,9 +88,21 @@ async fn a_configured_backend_holds_cron_flows_and_flow_state() {
// Without a backend the classic databases are back in use.
assert!(openhuman_core::storage::clear());
+ let fallback = config.clone();
+ tokio::task::spawn_blocking(move || {
+ assert!(matches!(
+ FlowState::open(&fallback, "flow:digest"),
+ FlowState::Sqlite(_)
+ ));
+ })
+ .await
+ .unwrap();
+ // The flow written to the backend is not in the classic catalog.
assert!(flows::ops::flows_list(&config)
.await
.unwrap()
.value
.is_empty());
+ openhuman_core::agent::orchestration::open_delegation_checkpointer(&config).unwrap();
+ assert!(workspace.path().join("graph_checkpoints.db").exists());
}
diff --git a/vendor/tinycomputer b/vendor/tinycomputer
index 489421c0ae..2b0ee5c6a0 160000
--- a/vendor/tinycomputer
+++ b/vendor/tinycomputer
@@ -1 +1 @@
-Subproject commit 489421c0aeb76fae1d68dd796ee4229b0a23e82e
+Subproject commit 2b0ee5c6a0ab5f349cdf45c05041832362820f0f
diff --git a/vendor/tinymemory b/vendor/tinymemory
index 439cce2a7c..004763036e 160000
--- a/vendor/tinymemory
+++ b/vendor/tinymemory
@@ -1 +1 @@
-Subproject commit 439cce2a7cfa42916852b24978a17c2567f45a2f
+Subproject commit 004763036e8ac6af36059ef5bcefed537d55a888