Pass 3 of 3 · Deep dive of PHAROSPass 1 · OverviewPass 2 · How it works
Code Observatory / module
retrieval
codeintel.retrieval
PINNED SOURCE Source and edges from the index at this commit. An execution appears only where one was recorded.
PHAROS at 975a38dMIT license
Around this symbol
Search all symbolsLoading
| Symbol | File | Resolved by |
|---|---|---|
| _cosine | retrieval.py | same file |
| _supports_iterative_scan | retrieval.py | same file |
| compound_name | retrieval.py | same file |
| Evidence | retrieval.py | same file |
| Filters | retrieval.py | same file |
| Hit | retrieval.py | same file |
| is_test_path | retrieval.py | same file |
| ModeUnavailable | retrieval.py | same file |
| path_role | retrieval.py | same file |
| repositories_matching | retrieval.py | same file |
| Retriever | retrieval.py | same file |
| SearchOutcome | retrieval.py | same file |
| symbol_like_terms | retrieval.py | same file |
| wanted_roles | retrieval.py | same file |
| Symbol | File | Resolved by |
|---|---|---|
| embeddings | embeddings.py | through an import |
| text | text.py | through an import |
| Symbol | File | Resolved by |
|---|---|---|
| context | context.py | through an import |
| describe | describe.py | through an import |
| router | router.py | through an import |
| native_server | native_server.py | through an import |
codeintel.retrievalbackend/app/codeintel/retrieval.py, lines 1–40Open source
"""Chunk-level code retrieval.Modes-----``keyword`` PostgreSQL full-text search over ``search_text`` (identifier-split tokens of path, symbol, signature, docstring, referenced names), ranked with ``ts_rank_cd``.``dense`` pgvector cosine distance between the query embedding and chunk embeddings **of the same embedding model** (HNSW index).``hybrid`` Reciprocal Rank Fusion (k=60) of keyword and dense, plus an exact symbol-name boost.``graph`` ``hybrid`` plus the resolved callers / callees of the top hits that retrieval missed, ranked just below the hit that pulled them in (no score bonus for chunks already retrieved).``auto`` ``dense`` when dense retrieval is available, or ``hybrid`` when the caller passes ``hints`` (identifiers it guesses), so their keyword evidence is fused in. Fusing the question's own words costs more than it adds with a code-aware embedder, and granite-embedding-english-r2 already ranks named symbols first (benchmarks: docs/benchmarks/). Without dense retrieval it is ``keyword``, and the response says so (``mode_used`` and a warning). Explicitly requested modes never silently degrade: they raise :class:`ModeUnavailable` instead.Tests, docs and examples are down-ranked after fusion (``NOISE_PATH_FACTOR``)unless the query asks for them: they repeat the words of the code theyexercise or describe and crowd out the implementation.SQLite (unit tests) uses a Python BM25 and Python cosine over the samecolumns, so behaviour can be tested without PostgreSQL. Retrieval quality andlatency numbers are only ever reported for PostgreSQL."""from __future__ import annotationsimport mathimport reimport timeimport uuidfrom collections import CounterShows the first 40 of 642 lines. The rest is on GitHub at this commit.
What the index recorded
- Signature
module backend.app.codeintel.retrieval- File
backend/app/codeintel/retrieval.py- Lines
- 1–642
- Parser
- python-ast
- Git blob
884729a39ae0b3d340ad83f75946677dcddf3791- Call sites
- 1 named, 0 resolved, 1 left unlinked
- Outside this subset
- 12 more edges reach code outside the graph shown here
