feat(gitree): add vector search for concepts#1463
Merged
Merged
Conversation
Embed Concept name + description (BGE-small, 384-dim) so concepts are discoverable via semantic search, mirroring the existing clue search. - saveConcept computes/stores embeddings on every write (create + update) - searchConcepts() on Storage: brute-force cosine over :Concept nodes (GraphStorage) and in-memory cosine (FileSystemStore) - POST /gitree/search-concepts route + search-concepts CLI command, returning flat ConceptSummary results with a merged score - backfillConceptEmbeddings() runs on initialize() to embed pre-existing concepts (cheap no-op scan once all are embedded)
…ponse
Use { concepts, total } instead of { results, count }.
Return ranked results without a hard cutoff by default. Guard the FileSystemStore path to exclude concepts without embeddings so 0.0 is safe.
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
Adds semantic (vector) search for Concepts. Previously only Clues had embeddings; concepts were only retrievable by ID or plain text matching. This mirrors the existing clue search infrastructure.
What & why
name + description(concise, high signal) rather thandocumentation, which can be arbitrarily long and would be silently truncated at the model's 512-token limit / diluted by mean-pooling.:Data_Bank:Concept, so no new schema/index work is needed to store embeddings.Changes
types.ts— addembedding?: number[]toConcept.store/utils.ts—conceptEmbeddingText()/computeConceptEmbedding()helpers (embedname + "\n\n" + descriptionviavectorizeQuery).saveConcept(GraphStorage + FileSystemStore) — computes/stores the embedding on every write, so both create and description-update paths stay current. Falls back to any existing embedding on failure.searchConcepts()— added to theStorageabstract and both impls:gds.similarity.cosineover:Conceptnodes (concept counts are small, so a full scan is fast and gives exact scores — same pattern assearchClues).POST /gitree/search-conceptsroute +search-conceptsCLI command. Results are flatConceptSummaryobjects with a mergedscore.backfillConceptEmbeddings()runs at the end ofinitialize()(alongside the existingbackfillPRFileEdges), embedding any pre-existing concepts missing an embedding. Becomes a cheap no-op scan once all concepts are embedded — no manual script required.API
Returns:
{ "query": "authentication", "repo": "all", "count": 1, "results": [ { "id": "owner/repo/auth-system", "name": "Authentication System", "description": "...", "prCount": 2, "commitCount": 0, "lastUpdated": "...", "hasDocumentation": true, "score": 0.82 } ] }Testing
tsc --noEmitpasses.Notes
vectorizeBatchif a much larger legacy corpus is expected.