Add text PK, WAL concurrency tests, and fix bench-smoke config

Infrastructure improvements:
- Fix benchmarks-ann Makefile: type=baseline -> type=vec0-flat (baseline
  was never a valid INDEX_REGISTRY key)
- Add DiskANN + text primary key test: insert, KNN, delete, KNN
- Add rescore + text primary key test: insert, KNN, delete, KNN
- Add WAL concurrency test: reader sees snapshot isolation while
  writer has an open transaction, KNN works on reader's snapshot

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
Alex Garcia 2026-03-31 17:43:49 -07:00
parent d684178a12
commit f2c9fb8f08
4 changed files with 138 additions and 4 deletions

View file

@ -595,3 +595,40 @@ def test_corrupt_zeroblob_validity(db):
).fetchall()
except sqlite3.OperationalError:
pass # Error is acceptable — crash is not
def test_rescore_text_pk_insert_knn_delete(db):
"""Rescore with text primary key: insert, KNN, delete, KNN again."""
db.execute(
"CREATE VIRTUAL TABLE t USING vec0("
" id text primary key,"
" embedding float[128] indexed by rescore(quantizer=bit)"
")"
)
import random
random.seed(99)
vecs = {}
for name in ["alpha", "beta", "gamma", "delta", "epsilon"]:
v = [random.gauss(0, 1) for _ in range(128)]
vecs[name] = v
db.execute("INSERT INTO t(id, embedding) VALUES (?, ?)", [name, float_vec(v)])
# KNN should return text IDs
rows = db.execute(
"SELECT id, distance FROM t WHERE embedding MATCH ? ORDER BY distance LIMIT 3",
[float_vec(vecs["alpha"])],
).fetchall()
assert len(rows) >= 1
ids = [r["id"] for r in rows]
assert "alpha" in ids
# Delete and verify
db.execute("DELETE FROM t WHERE id = 'alpha'")
rows = db.execute(
"SELECT id FROM t WHERE embedding MATCH ? ORDER BY distance LIMIT 3",
[float_vec(vecs["alpha"])],
).fetchall()
ids = [r["id"] for r in rows]
assert "alpha" not in ids
assert len(rows) >= 1 # other results still returned