mirror of
https://github.com/samvallad33/vestige.git
synced 2026-06-20 21:18:08 +02:00
fix(storage): finish PR 61 rebase cleanup
This commit is contained in:
parent
093bb2d4b5
commit
b34203bcc5
3 changed files with 16 additions and 20 deletions
|
|
@ -24,8 +24,7 @@ pub type EmbedderResult<T> = std::result::Result<T, EmbedderError>;
|
|||
/// Boxed Send future returning an `EmbedderResult<T>`, bound to the lifetime
|
||||
/// of the borrows captured by the call. Used as the return type of every
|
||||
/// async method on the dyn-compatible `Embedder` trait below.
|
||||
pub type BoxedEmbedderFuture<'a, T> =
|
||||
Pin<Box<dyn Future<Output = EmbedderResult<T>> + Send + 'a>>;
|
||||
pub type BoxedEmbedderFuture<'a, T> = Pin<Box<dyn Future<Output = EmbedderResult<T>> + Send + 'a>>;
|
||||
|
||||
/// Pluggable embedder. The storage layer NEVER calls fastembed directly;
|
||||
/// callers compute vectors via this trait and pass them into `MemoryStore`.
|
||||
|
|
@ -78,10 +77,7 @@ pub trait LocalEmbedder: Sync + 'static {
|
|||
/// implementation automatically.
|
||||
pub trait Embedder: Send + Sync + 'static {
|
||||
fn embed<'a>(&'a self, text: &'a str) -> BoxedEmbedderFuture<'a, Vec<f32>>;
|
||||
fn embed_batch<'a>(
|
||||
&'a self,
|
||||
texts: &'a [&'a str],
|
||||
) -> BoxedEmbedderFuture<'a, Vec<Vec<f32>>>;
|
||||
fn embed_batch<'a>(&'a self, texts: &'a [&'a str]) -> BoxedEmbedderFuture<'a, Vec<Vec<f32>>>;
|
||||
fn model_name(&self) -> &str;
|
||||
fn dimension(&self) -> usize;
|
||||
fn model_hash(&self) -> String;
|
||||
|
|
@ -95,10 +91,7 @@ where
|
|||
fn embed<'a>(&'a self, text: &'a str) -> BoxedEmbedderFuture<'a, Vec<f32>> {
|
||||
Box::pin(<T as EmbedderSend>::embed(self, text))
|
||||
}
|
||||
fn embed_batch<'a>(
|
||||
&'a self,
|
||||
texts: &'a [&'a str],
|
||||
) -> BoxedEmbedderFuture<'a, Vec<Vec<f32>>> {
|
||||
fn embed_batch<'a>(&'a self, texts: &'a [&'a str]) -> BoxedEmbedderFuture<'a, Vec<Vec<f32>>> {
|
||||
Box::pin(<T as EmbedderSend>::embed_batch(self, texts))
|
||||
}
|
||||
fn model_name(&self) -> &str {
|
||||
|
|
|
|||
|
|
@ -267,8 +267,7 @@ pub trait LocalMemoryStore: Sync + 'static {
|
|||
/// of the borrows captured by the call (typically `&self` plus any reference
|
||||
/// arguments). Used as the return type of every method on the dyn-compatible
|
||||
/// `MemoryStore` trait below.
|
||||
pub type BoxedStoreFuture<'a, T> =
|
||||
Pin<Box<dyn Future<Output = MemoryStoreResult<T>> + Send + 'a>>;
|
||||
pub type BoxedStoreFuture<'a, T> = Pin<Box<dyn Future<Output = MemoryStoreResult<T>> + Send + 'a>>;
|
||||
|
||||
/// Dyn-compatible storage trait.
|
||||
///
|
||||
|
|
@ -387,7 +386,9 @@ where
|
|||
embedding: &'a [f32],
|
||||
limit: usize,
|
||||
) -> BoxedStoreFuture<'a, Vec<SearchResult>> {
|
||||
Box::pin(<T as MemoryStoreSend>::vector_search(self, embedding, limit))
|
||||
Box::pin(<T as MemoryStoreSend>::vector_search(
|
||||
self, embedding, limit,
|
||||
))
|
||||
}
|
||||
|
||||
fn get_scheduling<'a>(
|
||||
|
|
@ -404,7 +405,9 @@ where
|
|||
before: DateTime<Utc>,
|
||||
limit: usize,
|
||||
) -> BoxedStoreFuture<'a, Vec<(MemoryRecord, SchedulingState)>> {
|
||||
Box::pin(<T as MemoryStoreSend>::get_due_memories(self, before, limit))
|
||||
Box::pin(<T as MemoryStoreSend>::get_due_memories(
|
||||
self, before, limit,
|
||||
))
|
||||
}
|
||||
|
||||
fn add_edge<'a>(&'a self, edge: &'a MemoryEdge) -> BoxedStoreFuture<'a, ()> {
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ use uuid::Uuid;
|
|||
use vestige_core::storage::{MemoryRecord, MemoryStore, SqliteMemoryStore};
|
||||
|
||||
#[tokio::test]
|
||||
async fn fresh_db_has_v12_schema() {
|
||||
async fn fresh_db_has_v16_schema() {
|
||||
let dir = tempdir().unwrap();
|
||||
let db = dir.path().join("fresh.db");
|
||||
let _store = SqliteMemoryStore::new(Some(db.clone())).expect("create");
|
||||
|
|
@ -50,13 +50,13 @@ async fn v11_db_upgrades_cleanly() {
|
|||
next_review, scheduled_days, has_embedding) \
|
||||
VALUES (?1, ?2, 'fact', datetime('now'), datetime('now'), datetime('now'), \
|
||||
1.0, 0.3, 0, 0, 'new', 1.0, 1.0, 1.0, datetime('now'), 1, 0)",
|
||||
rusqlite::params![format!("pre-v12-{i}"), format!("content {i}"),],
|
||||
rusqlite::params![format!("pre-v16-{i}"), format!("content {i}"),],
|
||||
)
|
||||
.expect("insert pre-v12 row");
|
||||
.expect("insert pre-v16 row");
|
||||
}
|
||||
}
|
||||
// Upgrade by opening through SqliteMemoryStore (triggers full migration)
|
||||
let _store = SqliteMemoryStore::new(Some(db.clone())).expect("open with v12");
|
||||
let _store = SqliteMemoryStore::new(Some(db.clone())).expect("open with v16");
|
||||
// Check all 5 rows have empty domains/domain_scores
|
||||
let conn = rusqlite::Connection::open(&db).expect("open raw");
|
||||
let count: i64 = conn
|
||||
|
|
@ -68,7 +68,7 @@ async fn v11_db_upgrades_cleanly() {
|
|||
.expect("count");
|
||||
assert_eq!(
|
||||
count, 5,
|
||||
"all pre-v12 rows must have empty domains/domain_scores"
|
||||
"all pre-v16 rows must have empty domains/domain_scores"
|
||||
);
|
||||
}
|
||||
|
||||
|
|
@ -157,5 +157,5 @@ async fn domains_table_exists() {
|
|||
|row| row.get(0),
|
||||
)
|
||||
.expect("query");
|
||||
assert_eq!(count, 1, "domains table must exist after V12 migration");
|
||||
assert_eq!(count, 1, "domains table must exist after V16 migration");
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue