1.3 KiB
1.3 KiB
DAL Skeleton (pgvector)
Interfaces
IDatabase— connect/tx + memory ops (ensureNamespace, upsertItem/Chunks/Embeddings, searchText/searchVector).PgDal— Qt6/QSql-based implementation with in-memory fallback.
SQL Calls (target)
- ensureNamespace:
INSERT ... ON CONFLICT (name) DO UPDATE RETURNING id - upsertItem:
INSERT ... ON CONFLICT (id) DO UPDATE SET ... RETURNING id - upsertChunks: batch insert w/
RETURNING id - upsertEmbeddings: batch insert; ensure
model, dimset, vector column populated. - searchText: FTS/trigram query filtered by namespace/thread/tags.
- searchVector:
ORDER BY embeddings.vector <-> $1 LIMIT k(with filters).
Next
- Wire
Handlers::upsert_memory/search_memorytoIDatabase. - Harden SQL with RLS/session GUCs & retries.
- Expand hybrid search scoring (RRF weights, secret filters).
Implementation Checklist (2025-10-15)
- Require Qt6::Sql (
QPSQLdriver) at configure time; bail out early when unavailable. - During
PgDal::connect, parse DSNs withQUrl, openQSqlDatabase, and retain in-memory fallback forstub://. - Use
QSqlQuerywithINSERT ... RETURNINGfor namespace/item/chunk/embedding operations. - Derive DSNs from
kompanionrc(KConfig) or CLI wizard, and surface informativestd::runtime_errormessages when QSql operations fail.