20 lines
827 B
Markdown
20 lines
827 B
Markdown
# DAL Skeleton (pgvector)
|
|
|
|
## Interfaces
|
|
- `IDatabase` — connect/tx + memory ops (ensureNamespace, upsertItem/Chunks/Embeddings, searchText/searchVector).
|
|
- `PgDal` — stub implementation for now (no libpq linked).
|
|
|
|
## 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, dim` set, 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_memory` to `IDatabase`.
|
|
- Add libpq (or pqxx) and parameterized statements.
|
|
- Add RLS/session GUCs & retries.
|
|
|