Skip to content

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

test: assert legacy files are left byte-identical after import

Steven Enamakel090834ae5a9c
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 72ad6b5f1e..99f7752b4e 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
@@ -143,21 +143,30 @@ fn a_stale_snapshot_does_not_revert_a_newer_session() {
}
#[test]
-fn a_legacy_session_file_is_imported_once_and_retired() {
+fn a_legacy_session_file_is_imported_once_and_left_byte_identical() {
let dir = tempfile::tempdir().unwrap();
let legacy = dir.path().join(".openhuman");
std::fs::create_dir_all(&legacy).unwrap();
- std::fs::write(
- legacy.join("subagent_sessions.json"),
- serde_json::to_string(&vec![session("legacy-1")]).unwrap(),
- )
- .unwrap();
+ let original = serde_json::to_string(&vec![session("legacy-1")]).unwrap();
+ std::fs::write(legacy.join("subagent_sessions.json"), &original).unwrap();
let store = SubagentSessionStore::new(dir.path().to_path_buf());
let loaded = store.load().unwrap();
assert_eq!(loaded.len(), 1);
assert_eq!(loaded[0].subagent_session_id, "legacy-1");
- assert!(!legacy.join("subagent_sessions.json").exists());
- assert!(legacy.join("subagent_sessions.json.migrated").exists());
+ // The legacy file is read only: same name, same bytes, no `.migrated`.
+ assert_eq!(
+ std::fs::read_to_string(legacy.join("subagent_sessions.json")).unwrap(),
+ original
+ );
+ assert!(!legacy.join("subagent_sessions.json.migrated").exists());
assert_eq!(store.load().unwrap().len(), 1);
+ // The marker, not the file, stops a second import: a session saved after
+ // the first import and then removed from the store is not resurrected.
+ store.save(&[]).unwrap();
+ assert_eq!(store.load().unwrap().len(), 1);
+ assert_eq!(
+ std::fs::read_to_string(legacy.join("subagent_sessions.json")).unwrap(),
+ original
+ );
}
diff --git a/crates/openhuman-core/src/integrations/composio/file_store_tests.rs b/crates/openhuman-core/src/integrations/composio/file_store_tests.rs
index 3e521bf373..b72e50dda8 100644
--- a/crates/openhuman-core/src/integrations/composio/file_store_tests.rs
+++ b/crates/openhuman-core/src/integrations/composio/file_store_tests.rs
@@ -46,7 +46,7 @@ async fn update_applies_and_persists_a_change() {
}
#[tokio::test]
-async fn a_legacy_state_file_is_imported_once_and_retired() {
+async fn a_legacy_state_file_is_imported_once_and_left_byte_identical() {
let dir = tempfile::tempdir().unwrap();
let config = config_in(&dir);
let legacy_dir = dir.path().join("integrations");
@@ -55,8 +55,12 @@ async fn a_legacy_state_file_is_imported_once_and_retired() {
let loaded: BTreeMap<String, u32> = load(&config, USER_SCOPES_FILE).await.unwrap();
assert_eq!(loaded["gmail"], 7);
- assert!(!legacy_dir.join(USER_SCOPES_FILE).exists());
- assert!(legacy_dir
+ // The legacy file is read only: same name, same bytes, no `.migrated`.
+ assert_eq!(
+ std::fs::read(legacy_dir.join(USER_SCOPES_FILE)).unwrap(),
+ br#"{"gmail":7}"#
+ );
+ assert!(!legacy_dir
.join(format!("{USER_SCOPES_FILE}.migrated"))
.exists());
@@ -73,4 +77,8 @@ async fn a_legacy_state_file_is_imported_once_and_retired() {
.unwrap();
let again: BTreeMap<String, u32> = load(&config, USER_SCOPES_FILE).await.unwrap();
assert_eq!(again["gmail"], 9);
+ assert_eq!(
+ std::fs::read(legacy_dir.join(USER_SCOPES_FILE)).unwrap(),
+ br#"{"gmail":7}"#
+ );
}