Skip to content

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

test(subagent_sessions): cover late importer rechecking the marker under the claim

Steven Enamakele637aa224731
diff --git a/crates/openhuman-core/src/agent/orchestration/subagent_sessions/store_documents_tests.rs b/crates/openhuman-core/src/agent/orchestration/subagent_sessions/store_documents_tests.rs
index f6b5ab215a..885846ceb4 100644
--- a/crates/openhuman-core/src/agent/orchestration/subagent_sessions/store_documents_tests.rs
+++ b/crates/openhuman-core/src/agent/orchestration/subagent_sessions/store_documents_tests.rs
@@ -187,3 +187,21 @@ fn workspaces_sharing_a_backend_each_import_their_own_legacy_file() {
docs.import_legacy(two, &[session("from-two")]).unwrap();
assert_eq!(docs.load().unwrap().len(), 2);
}
+
+#[test]
+fn a_late_importer_rechecks_the_marker_under_the_claim() {
+ let docs = docs_in(&MemoryStorage::new(), "local");
+ let source = std::path::Path::new("/legacy/subagent_sessions.json");
+ docs.import_legacy(source, &[session("first")]).unwrap();
+ assert!(docs.legacy_imported(source).unwrap());
+ // A process that passed the marker check before the first finished
+ // reaches the claim afterwards: it must not copy its list again.
+ docs.import_legacy(source, &[session("second")]).unwrap();
+ let ids: Vec<_> = docs
+ .load()
+ .unwrap()
+ .into_iter()
+ .map(|s| s.subagent_session_id)
+ .collect();
+ assert_eq!(ids, ["first"]);
+}