Skip to content

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

test(subagent_host): add lifecycle checkpoint test module

Steven Enamakelf6c184640623
diff --git a/crates/openhuman-core/src/agent/subagent_host/lifecycle_checkpoint.rs b/crates/openhuman-core/src/agent/subagent_host/lifecycle_checkpoint.rs
index ac9d068be3..91b0a843be 100644
--- a/crates/openhuman-core/src/agent/subagent_host/lifecycle_checkpoint.rs
+++ b/crates/openhuman-core/src/agent/subagent_host/lifecycle_checkpoint.rs
@@ -13,3 +13,7 @@ pub(super) fn absolute_checkpoint_dir(path: PathBuf) -> PathBuf {
}
})
}
+
+#[cfg(test)]
+#[path = "lifecycle_checkpoint_tests.rs"]
+mod tests;
diff --git a/crates/openhuman-core/src/agent/subagent_host/lifecycle_checkpoint_tests.rs b/crates/openhuman-core/src/agent/subagent_host/lifecycle_checkpoint_tests.rs
new file mode 100644
index 0000000000..416acf1a89
--- /dev/null
+++ b/crates/openhuman-core/src/agent/subagent_host/lifecycle_checkpoint_tests.rs
@@ -0,0 +1,31 @@
+use super::*;
+
+/// The in-flight map is keyed by this path, so it must name a directory the
+/// same way before and after the lifecycle store creates it. Reached through a
+/// symlinked parent (macOS `/var` -> `/private/var`), a path that resolved
+/// literally while absent and canonically once present split one task into two
+/// leaders.
+#[cfg(unix)]
+#[test]
+fn checkpoint_dir_key_is_stable_across_directory_creation() {
+ let scratch = tempfile::tempdir().expect("scratch");
+ let real = scratch.path().join("real");
+ std::fs::create_dir_all(&real).expect("real parent");
+ let link = scratch.path().join("link");
+ std::os::unix::fs::symlink(&real, &link).expect("symlinked parent");
+
+ let requested = link.join(".openhuman/subagent_checkpoints");
+ let before = absolute_checkpoint_dir(requested.clone());
+ std::fs::create_dir_all(&requested).expect("create checkpoint dir");
+ let after = absolute_checkpoint_dir(requested);
+
+ assert_eq!(before, after, "key must not change when the directory appears");
+ assert_eq!(after, std::fs::canonicalize(&after).expect("exists"));
+}
+
+#[test]
+fn relative_checkpoint_dir_is_made_absolute() {
+ let resolved = absolute_checkpoint_dir(PathBuf::from("does/not/exist/yet"));
+ assert!(resolved.is_absolute());
+ assert!(resolved.ends_with("does/not/exist/yet"));
+}