feat(db): add PostgreSQL + pgvector storage adapter for semantic search - #182
Merged
Merged
Conversation
|
@yoshita-madamala is attempting to deploy a commit to the Kavindu's projects Team on Vercel. A member of the Team first needs to authorize it. |
Implements internal/db/pgvector.go — a production-grade storage adapter
that indexes code ASTs, diffs, and repository memory embeddings in
PostgreSQL 16 with the pgvector extension.
Key additions:
- PGVectorStore: opens a Postgres connection and auto-migrates schema
- embeddings table with vector(1536) column backed by an HNSW index
(vector_cosine_ops) for sub-millisecond approximate nearest-neighbour
queries
- Upsert: idempotent insert-or-update of an embedding row
- Search: top-k cosine similarity search, optionally scoped to a
content kind ("ast", "diff", "memory")
- DeleteBySnapshot: bulk removal for GC / snapshot pruning
- Close: releases the connection pool
Adds dependencies: github.com/pgvector/pgvector-go, github.com/lib/pq
Closes kavix#145
yoshiiita
force-pushed
the
feat/pgvector-storage-adapter
branch
from
August 25, 2026 06:45
b8cea8d to
84b3271
Compare
kavix
self-requested a review
August 26, 2026 12:27
kavix
approved these changes
Aug 26, 2026
kavix
approved these changes
Aug 26, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Closes #145
Implements
internal/db/pgvector.go— a production-grade PostgreSQL 16 +pgvectorstorage adapter for indexing code ASTs, diffs, and repository memory embeddings with sub-millisecond semantic search.What's in this PR
PGVectorStore— opens a Postgres connection and auto-migrates the schema on startupembeddingstable — stores content with avector(1536)column backed by an HNSW index (vector_cosine_ops) for approximate nearest-neighbour queries at sub-millisecond latencyUpsert— idempotent insert-or-update of an embedding (keyed by content-derived ID)Search— top-k cosine similarity query, optionally scoped to a content kind ("ast","diff","memory")DeleteBySnapshot— bulk removal for GC / snapshot pruninggithub.com/pgvector/pgvector-go,github.com/lib/pqSchema
Test plan
pgvectorenabledNewPGVectorStore(dsn)— verify extension + table + index are createdUpsertseveral embeddings with differentkindvaluesSearchwithkind=""— confirm all kinds are returned in distance orderSearchwithkind="ast"— confirm only AST rows are returnedDeleteBySnapshot— confirm rows are removedgo build ./...passes