- 新增 src/memory/store/sqlite_store.rs(SqliteStore + 9 个内联测试)
- 基于 rusqlite 0.32(bundled),使用 Arc<Mutex<Connection>> + spawn_blocking
- WAL 模式 + synchronous=NORMAL + busy_timeout=5s + PRAGMA user_version
schema 版本管理
- created_at 归一化为 UTC 的 RFC 3339 TEXT,字典序等价时间序
- 错误精细映射:SqliteFailure/InvalidQuery → InvalidInput;
FromSqlConversionFailure → Serialization;其他 → Storage
- 9 个测试覆盖 CRUD、upsert、prefix/since/offset+limit 过滤、
10 写者 × 10 次并发、持久化 round-trip、trait-box 互换兼容性
依赖:
- rusqlite = { version = "0.32", features = ["bundled"] }
- time 增补 features: parsing, formatting, macros
- dev-dependencies: tempfile = "3"
测试:199 → 200 pass(191 原有 + 9 新增)
23 lines
771 B
Rust
23 lines
771 B
Rust
//! 记忆系统 —— 对话消息管理、知识页面存储与关键词检索。
|
|
|
|
pub mod conversation;
|
|
pub mod error;
|
|
pub mod knowledge;
|
|
pub mod retriever;
|
|
pub mod store;
|
|
pub mod types;
|
|
|
|
// 高频类型(大多数下游需要)
|
|
pub use conversation::{ConversationMemory, ConversationMemoryConfig};
|
|
pub use error::MemoryError;
|
|
pub use knowledge::KnowledgeStore;
|
|
pub use retriever::MemoryRetriever;
|
|
pub use store::{InMemoryStore, MemoryStore, SqliteStore};
|
|
|
|
// 低频类型(配置/高级使用)
|
|
pub use conversation::MemoryStrategy;
|
|
pub use knowledge::{KNOWLEDGE_PREFIX, PageIndexEntry};
|
|
pub use retriever::{RetrievalResult, RetrieverConfig, ScoredItem};
|
|
pub use store::{EvictionConfig, EvictionPolicy};
|
|
pub use types::{KnowledgePage, MemoryFilter, MemoryItem};
|