Skip to content

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

refactor(threads): move conversation storage onto the storage backend

Steven Enamakeld66e12de9f48
diff --git a/crates/openhuman-core/src/threads/store/legacy_import_tests.rs b/crates/openhuman-core/src/threads/store/legacy_import_tests.rs
new file mode 100644
index 0000000000..4563e55b7b
--- /dev/null
+++ b/crates/openhuman-core/src/threads/store/legacy_import_tests.rs
@@ -0,0 +1 @@
+use super::*;
diff --git a/crates/openhuman-core/src/threads/store/mod.rs b/crates/openhuman-core/src/threads/store/mod.rs
index 1f11bf9cc0..a122b604c2 100644
--- a/crates/openhuman-core/src/threads/store/mod.rs
+++ b/crates/openhuman-core/src/threads/store/mod.rs
@@ -1,45 +1,56 @@
-//! Workspace-backed chat thread/message storage (`threads::store`).
+//! Backend-backed chat thread/message storage (`threads::store`).
//!
-//! Conversations are JSONL files under `<workspace>/memory/conversations/`:
-//! thread metadata as an append-only upsert/delete log in `threads.jsonl`, and
-//! each thread's messages in a dedicated file under
-//! `threads/<hex(thread_id)>.jsonl`. This is **transcript persistence** — the
-//! raw records plus a trigram/CJK-bigram index for cross-thread substring
-//! search over them. It is not memory: memory v2 (`crate::memory`) only
-//! *ingests* committed turns through its own bus subscriber.
+//! Conversations live in the process's storage backend
+//! ([`crate::storage`]), through TinyAgents' `DriverConversationStore`: thread
+//! metadata as one document per thread and each thread's messages as an
+//! append stream. This is **transcript persistence**: the raw records plus
+//! cross-thread substring search over them. It is not memory: memory v2
+//! (`crate::memory`) only *ingests* committed turns through its own bus
+//! subscriber.
//!
-//! The store itself (on-disk format, locking, warm index cache, CRUD and
-//! search) is `tinyagents_session::threads`, re-exported below so callers
-//! name `crate::threads::store::{...}`. The two message types keep their
-//! historical host spelling (`ConversationMessage`, `ConversationMessagePatch`)
-//! as aliases of `ThreadMessage` / `ThreadMessagePatch`; type names never
-//! reach the disk. What stays here is host wiring:
+//! TinyAgents removed its path-bound JSONL store, so the host keeps only:
//!
+//! - [`backend`] - the workspace-keyed synchronous facade
+//! (`ConversationStore::new(workspace_dir)` and the free functions) the ~50
+//! callers already use, resolving the backend and the conversation scope.
+//! - `legacy_import` - the one-time, read-only import of the retired
+//! `<workspace>/memory/conversations` JSONL tree. A marker document records
+//! completion; the files are never modified.
//! - [`blocking`] - `spawn_blocking` wrappers. Every store entry point is
-//! synchronous and can take `parking_lot` locks across fsync'd file IO, so an
-//! `async fn` that calls one directly parks a tokio **worker** thread for the
-//! whole wait. Request paths must use these (#5156).
+//! synchronous and blocks on the storage bridge, so an `async fn` that calls
+//! one directly parks a tokio **worker** thread. Request paths must use these
+//! (#5156).
//! - `bus` - the `core::bus` subscriber that mirrors inbound and processed
//! channel turns into the store, so Slack/Telegram/... persist alongside the
//! UI's own threads.
//!
-//! The on-disk format is unchanged: the root is still
-//! `<workspace>/memory/conversations`.
+//! The two message types keep their historical host spelling
+//! (`ConversationMessage`, `ConversationMessagePatch`) as aliases of
+//! `ThreadMessage` / `ThreadMessagePatch`.
+pub mod backend;
pub mod blocking;
mod bus;
-use tinyagents_session::threads as store;
+mod legacy_import;
+#[cfg(test)]
+#[path = "legacy_import_tests.rs"]
+mod legacy_import_tests;
+
+use backend as store;
+use tinyagents_session::threads as types;
// Only the hosted-channel relay (`channels`) claims turns.
#[cfg(feature = "channels")]
pub(crate) use bus::claim_channel_turn;
pub use bus::register_conversation_persistence_subscriber;
pub use store::{
- append_message, delete_messages_from, delete_thread, ensure_thread, get_messages,
- is_deterministic_message_id, list_threads, purge_threads, reply_run_id, run_reply_message_id,
- update_message, update_thread_labels, update_thread_title, update_thread_working_dir,
- ConversationPurgeStats, ConversationStore, ConversationThread, CreateConversationThread,
- CrossThreadHit, ThreadMessage as ConversationMessage,
+ append_message, delete_messages_from, delete_thread, ensure_thread, get_messages, list_threads,
+ purge_threads, update_message, update_thread_labels, update_thread_title,
+ update_thread_working_dir, ConversationPurgeStats, ConversationStore,
+};
+pub use types::{
+ is_deterministic_message_id, reply_run_id, run_reply_message_id, ConversationThread,
+ CreateConversationThread, CrossThreadHit, ThreadMessage as ConversationMessage,
ThreadMessagePatch as ConversationMessagePatch,
};