Skip to content

Add a revision-safe persistent embedding cache - #6

Merged
dajiaohuang merged 1 commit into
mainfrom
perf/persistent-embedding-cache
Aug 27, 2026
Merged

Add a revision-safe persistent embedding cache#6
dajiaohuang merged 1 commit into
mainfrom
perf/persistent-embedding-cache

Conversation

@dajiaohuang

Copy link
Copy Markdown
Contributor

Summary

  • add an optional process-safe SQLite embedding cache behind each domain prefix
  • cap it by entry count and logical bytes, validate float32 payloads, and fail open on lock/corruption
  • pin built-in BGE profiles and require custom models to use immutable 40-character commit SHAs
  • scope SQL rows, memory keys, Chroma collections, and vector outbox jobs by model revision
  • prevent pending vector jobs from being delivered or completed under another revision
  • coordinate first-use initialization across local embedder instances and restrict new POSIX cache paths
  • document privacy, tenant-isolation, capacity, and operational settings

Safety properties

  • raw source text is not stored in SQLite (only model/text digests and vectors)
  • low-entropy digest and embedding sensitivity are explicitly documented
  • cache failures never block model inference
  • cache use is opt-in and should stay outside source checkouts/public backups

Validation

  • uv run --extra dev pytest (308 passed, 14 skipped)
  • uv run --extra dev pytest tests/test_embeddings.py tests/test_vector_jobs.py -q
  • uv run --extra dev ruff check .
  • git diff --check
  • verified the three built-in revisions against their official Hugging Face repository HEADs

Configuration

Set _EMBEDDING_CACHE_DIR; optional limits are _EMBEDDING_CACHE_MAX_ENTRIES, _MAX_BYTES, _BUSY_TIMEOUT_MS, and _EPOCH.

@dajiaohuang
dajiaohuang merged commit 4cc3aef into main Aug 27, 2026
2 checks passed
@dajiaohuang
dajiaohuang deleted the perf/persistent-embedding-cache branch August 27, 2026 11:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant