feat(retrieval): Phase 2 — idempotent index lifecycle#240
Merged
Conversation
- Add Retriever with createIndex/dropIndex/describeIndex over the kit - createIndex no-ops when FT.INFO shows the index, creates when absent, rethrows non-not-found errors - dropIndex tolerates a missing index, rethrows other errors - describeIndex parses FT.INFO into a typed description via kit parsers - Export Retriever, RetrieverClient, RetrieverOptions, IndexDescription
KIvanow
approved these changes
Jun 15, 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 subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
Phase 2 — Index lifecycle (idempotent)
Adds
Retrieverto@betterdb/retrievalwith the three index-lifecycle methods, built over the Phase 0@betterdb/valkey-search-kitparsers and Phase 1'sbuildFtCreateArgs.Methods
createIndex()— probesFT.INFO; no-ops when the index exists, issuesFT.CREATEwhen absent, and rethrows non-not-foundFT.INFOerrors instead of blindly creating.dropIndex()— issuesFT.DROPINDEX, swallowsisIndexNotFoundError, rethrows other errors.describeIndex()— parsesFT.INFOinto a typedIndexDescription(name,dims,numDocs,indexingState) via the kit'sparseFtInfoStats/parseDimensionFromInfo; propagates the error when the index is missing.Public API
Exports
RetrieverplusRetrieverClient,RetrieverOptions,IndexDescription.Tests
8 unit tests (mocked client), full package suite 42/42 green,
tsc --noEmitclean.Scope / follow-ups
dimscomes from the schema here; embedFn-based dims inference is Phase 3.describeIndexsurfaces the raw error on a missing index (caller checks existence viacreateIndexfirst); a typed not-found variant can come with the query layer if needed.Note
Low Risk
New retrieval-layer API with mocked tests only; no changes to auth, persistence, or existing call paths.
Overview
Introduces
Retrieverin@betterdb/retrievalas the public API for Valkey search index lifecycle, wired to existingbuildFtCreateArgs/indexNameand@betterdb/valkey-search-kitparsers.createIndex()probesFT.INFOfirst: it skipsFT.CREATEwhen the index exists, creates only on index-not-found, and rethrows otherFT.INFOfailures (e.g. LOADING).dropIndex()runsFT.DROPINDEXand ignores missing-index errors.describeIndex()mapsFT.INFOtoIndexDescription(name,dims,numDocs,indexingState) and surfaces errors when the index is absent.The package entrypoint now exports
RetrieverplusRetrieverClient,RetrieverOptions, andIndexDescription. Eight mocked unit tests cover these behaviors.Reviewed by Cursor Bugbot for commit 2789579. Bugbot is set up for automated code reviews on this repo. Configure here.