feat(db): IVFFlat index on episodes.embedding [STORY-014]#13
Merged
Conversation
Adds the cosine-distance IVFFlat index that EPIC-014 (RAG / agent memory) will need to build nearest-neighbour queries on top of. Declared in the Drizzle schema (so drizzle-kit owns it) and migrated as 0001_clammy_sir_ram. Cosine ops because OpenAI text-embedding-3-* and Voyage voyage-3 return L2-normalised vectors. lists=100 is a sensible cold-start default — the index is mostly useless on an empty table; REINDEX after the first batch of episodes lands. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
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
0001_clammy_sir_ram.sql.vector_cosine_ops) because OpenAItext-embedding-3-*and Voyagevoyage-3return L2-normalised vectors.lists=100is a sensible cold-start default — the index is mostly useless on an empty table; REINDEX after the first batch of episodes lands.method: "ivfflat".Test plan
pnpm typecheck— clean.pnpm lint— clean.pnpm test— 20 schema tests pass (was 19; added the IVFFlat index assertion).pnpm format:check— clean.pnpm --filter @learnpro/db db:generateproduces a 1-lineCREATE INDEX IF NOT EXISTS ... USING ivfflat ...migration.🤖 Generated with Claude Code