Real RAG - wire pgvector retrieve + on-write index hooks + model decision¶
| Stage | Built |
|---|---|
| Status | Shipped |
| Design status | In review |
| Estimate | 2w (M) |
| Confidence | Low |
| Linear | PIN-315 ↗ PIN-316 ↗ |
| Linear status | Done |
| Cycle | C15 |
| Design | Design ↗ |
| Linear epic | Cara AI & Automation |
| Module | Cara ↗ |
Priority: High
Scope¶
Lands the pgvector retrieval infrastructure: a cara_embeddings table (ivfflat index) plus indexer functions — Reindex to upsert an entity's embedding on write, Retrieve to run a role-filtered, permission-aware cosine-similarity query — replacing today's keyword-match lookup. Pairs with an encrypted OpenAI API key setting so the indexer can call the embeddings API. Walls/folders/memory integration and the action gate are out of scope for this pass. (Source: PIN-315, PIN-316.)
Acceptance criteria¶
vectorPostgres extension enabled;cara_embeddingstable (entity type, entity ID, content, embedding, updated at) with an ivfflat indexReindexupserts an entity's embedding;Retrieveruns a role-filtered cosine-similarity query with permission filtering applied- Nightly reindex cron job registered (no-op stub until on-write hooks land)
- Encrypted
OpenAIAPIKeysetting, masked in API responses, editable from a new Admin Settings card - Embedding client calls OpenAI's embeddings endpoint using the stored key
- Smoke tests prove the indexer (insert + similarity query) and the embedding call both work end-to-end
Conor's comments¶
Ivan S - did you get feedback on best model setup?
Notes¶
Embedding infra built, not wired; 2wk covers basic vector retrieval only - NOT walls/folders/memory/action gate; replaces keyword match
Open question for Conor¶
Finalize the AI model (self-host vs API) + embeddings