Skip to content

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

feat(storage): track updated times not restored during scope move

Steven Enamakel6d93f11186c6
diff --git a/crates/openhuman-core/src/storage/scope_move.rs b/crates/openhuman-core/src/storage/scope_move.rs
index 8a10b7a8fd..5209a92190 100644
--- a/crates/openhuman-core/src/storage/scope_move.rs
+++ b/crates/openhuman-core/src/storage/scope_move.rs
@@ -143,6 +143,9 @@ pub struct MoveReport {
pub entries: u64,
/// Blobs copied.
pub blobs: u64,
+ /// Source documents whose `updated_ms` is kept only in the immutable
+ /// inventory because the target `WriteOptions` cannot restore it.
+ pub updated_times_not_restored: u64,
}
/// Copies the rows in a source inventory to their mapped v2 scopes.
@@ -191,6 +194,9 @@ pub async fn copy_inventory(
let target = backend.for_scope(&target_scope)?;
let docs = target.documents();
for row in inventory.documents.iter().filter(|row| row.scope == source) {
+ if row.meta.updated_ms != 0 {
+ report.updated_times_not_restored += 1;
+ }
docs.ensure_collection(&CollectionSpec::new(&row.collection))
.await?;
let mut options = WriteOptions::new();
diff --git a/crates/openhuman-core/src/storage/scope_move_tests.rs b/crates/openhuman-core/src/storage/scope_move_tests.rs
index e80ac7d01f..d159807d91 100644
--- a/crates/openhuman-core/src/storage/scope_move_tests.rs
+++ b/crates/openhuman-core/src/storage/scope_move_tests.rs
@@ -101,6 +101,7 @@ async fn a_v1_scope_moves_its_documents_streams_and_blobs() {
assert!(report.documents >= 1);
assert_eq!(report.entries, 2);
assert_eq!(report.blobs, 1);
+ assert_eq!(report.updated_times_not_restored, 1);
let new = backend
.for_scope(&scope_for_profile("alice").agent("asha").unwrap())