You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
PGVectorStore broken against real Postgres (dimension, register_vector, commit, opclass, JSONB) — hidden by MagicMock #830
PGVectorStore (src/synapsekit/retrieval/pgvector.py) has never run against a real Postgres — its only test uses MagicMock, which hid multiple breakages. Found while converting to real testcontainers tests (epic #829).
Bugs (all hidden by the mock)
self._embeddings.dimension doesn't exist — no real embeddings backend exposes .dimension (base SynapsekitEmbeddings has none; HashingEmbeddings has .dimensions). Raises AttributeError on first connect.
No register_vector — pgvector.psycopg is imported but register_vector_async(conn) is never called, so Python vectors aren't adapted to the vector type on insert/query.
No commit / not autocommit — AsyncConnection.connect(...) defaults to a transaction that is never committed, so inserts would roll back and never be visible.
Wrong index operator classes — uses cosine_ops / l2_ops / inner_product_ops; pgvector's real opclasses are vector_cosine_ops / vector_l2_ops / vector_ip_ops. CREATE INDEX fails.
JSONB handling — inserts json.dumps(...) text into a jsonb column without a cast, and on read calls json.loads() on what psycopg already returns as a dict.
Derive dim from the first embedding vector; create table/index on first add() (no .dimension dependency). search() before any add() returns []; detect a pre-existing table for reconnect/persistence.
connect(..., autocommit=True) + register_vector_async(conn) after CREATE EXTENSION.
Correct opclass names.
Use psycopg Jsonb(...) for metadata; tolerate dict-or-str on read.
Test
Real pgvector/pgvector:pg16 testcontainer: round-trip add/search with true nearest-neighbor ranking, metadata filter, top_k, persistence across reconnect, dimension/empty/negative cases. Replaces the MagicMock test. Runs in the CI integration job.
Activity
fix(retrieval): make PGVectorStore work against real Postgres (Synaps…