Parent epic: #2385
Scope Change
Originally scoped as generics migration. After adversarial critique review, the generics migration is deferred to backlog (P4) because:
sqlx::migrate! is monomorphic — requires #[cfg] per backend
- Trait bounds explosion (5 HRTB bounds in
FullDriver already)
- The
#[cfg] type alias approach is pragmatically correct for pre-v1.0
This issue is repurposed for concrete code quality and performance fixes.
Changes
Pool Configuration (P2)
- SQLite pool: Add
min_connections(2) and acquire_timeout(5s) to pool.rs:78-82
- Postgres pool: Fix
connect_postgres to use max_connections correctly — currently pool_size field is silently ignored (pool.rs:99)
- Rename/consolidate
DbConfig fields: pool_size → remove, use max_connections only
sql! Macro (P2)
- Replace
Box::leak() with LazyLock per call site in postgres variant (lib.rs:102-111):
macro_rules! sql {
($query:expr) => {{
static REWRITTEN: std::sync::LazyLock<String> =
std::sync::LazyLock::new(|| $crate::rewrite_placeholders($query));
REWRITTEN.as_str()
}};
}
- Fix the misleading doc comment that claims LazyLock is already used
Error Consolidation (P2)
- Merge
MemoryError::Sqlx(sqlx::Error) and MemoryError::Db(DbError) into single MemoryError::Db
- Remove backward-compat aliases:
SqliteStore (store/mod.rs:32), SqliteVectorStore (db_vector_store.rs:24)
Edge Upsert Optimization (P2)
- Replace SELECT+UPDATE/INSERT in
insert_edge_typed (graph/store/mod.rs:413-437) with single INSERT ... ON CONFLICT DO UPDATE ... RETURNING id
- Halves DB round-trips per graph extraction pass
Error Handling (P2)
- Fix
get_vectors (embedding_store.rs:372) — .unwrap_or_default() silently swallows all DB errors. Propagate errors properly.
Acceptance Criteria
- SQLite pool has
min_connections + acquire_timeout
- Postgres pool respects
max_connections config
sql! macro on postgres allocates once per call site (add a test)
- No
MemoryError::Sqlx variant
- No
SqliteStore / SqliteVectorStore aliases
insert_edge_typed uses single upsert query
get_vectors propagates errors
- All tests pass
Parent epic: #2385
Scope Change
Originally scoped as generics migration. After adversarial critique review, the generics migration is deferred to backlog (P4) because:
sqlx::migrate!is monomorphic — requires#[cfg]per backendFullDriveralready)#[cfg]type alias approach is pragmatically correct for pre-v1.0This issue is repurposed for concrete code quality and performance fixes.
Changes
Pool Configuration (P2)
min_connections(2)andacquire_timeout(5s)topool.rs:78-82connect_postgresto usemax_connectionscorrectly — currentlypool_sizefield is silently ignored (pool.rs:99)DbConfigfields:pool_size→ remove, usemax_connectionsonlysql! Macro (P2)
Box::leak()withLazyLockper call site in postgres variant (lib.rs:102-111):Error Consolidation (P2)
MemoryError::Sqlx(sqlx::Error)andMemoryError::Db(DbError)into singleMemoryError::DbSqliteStore(store/mod.rs:32),SqliteVectorStore(db_vector_store.rs:24)Edge Upsert Optimization (P2)
insert_edge_typed(graph/store/mod.rs:413-437) with singleINSERT ... ON CONFLICT DO UPDATE ... RETURNING idError Handling (P2)
get_vectors(embedding_store.rs:372) —.unwrap_or_default()silently swallows all DB errors. Propagate errors properly.Acceptance Criteria
min_connections+acquire_timeoutmax_connectionsconfigsql!macro on postgres allocates once per call site (add a test)MemoryError::SqlxvariantSqliteStore/SqliteVectorStorealiasesinsert_edge_typeduses single upsert queryget_vectorspropagates errors