From e8fd08c800223ca3520cbdd8f82e23b686034bae Mon Sep 17 00:00:00 2001 From: Steven Enamakel <31011319+senamakel@users.noreply.github.com> Date: Mon, 6 Apr 2026 19:46:15 -0700 Subject: [PATCH] feat(memory): use timestamp-prefixed document IDs for chronological sorting (#381) Replace random UUID document IDs with `{unix_seconds}_{8char_hex}` format so memory documents sort chronologically by filename and ID. --- src/openhuman/memory/store/unified/documents.rs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/openhuman/memory/store/unified/documents.rs b/src/openhuman/memory/store/unified/documents.rs index 900730201..e9df68a20 100644 --- a/src/openhuman/memory/store/unified/documents.rs +++ b/src/openhuman/memory/store/unified/documents.rs @@ -27,7 +27,11 @@ impl UnifiedMemory { let document_id = input .document_id .or(existing_document_id) - .unwrap_or_else(|| Uuid::new_v4().to_string()); + .unwrap_or_else(|| { + let ts = Self::now_ts() as u64; + let short = &Uuid::new_v4().to_string()[..8]; + format!("{ts}_{short}") + }); let now = Self::now_ts(); let created_at = { let conn = self.conn.lock();