Skip to content

Real RAG - wire pgvector retrieve + on-write index hooks + model decision

StageBuilt
StatusShipped
Design statusIn review
Estimate2w (M)
ConfidenceLow
LinearPIN-315 ↗ PIN-316 ↗
Linear statusDone
CycleC15
DesignDesign ↗
Linear epicCara AI & Automation
ModuleCara ↗

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

  • vector Postgres extension enabled; cara_embeddings table (entity type, entity ID, content, embedding, updated at) with an ivfflat index
  • Reindex upserts an entity's embedding; Retrieve runs a role-filtered cosine-similarity query with permission filtering applied
  • Nightly reindex cron job registered (no-op stub until on-write hooks land)
  • Encrypted OpenAIAPIKey setting, 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