Back to the room

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 symbols

Loading

Contains (14)
SymbolFileResolved by
_cosineretrieval.pysame file
_supports_iterative_scanretrieval.pysame file
compound_nameretrieval.pysame file
Evidenceretrieval.pysame file
Filtersretrieval.pysame file
Hitretrieval.pysame file
is_test_pathretrieval.pysame file
ModeUnavailableretrieval.pysame file
path_roleretrieval.pysame file
repositories_matchingretrieval.pysame file
Retrieverretrieval.pysame file
SearchOutcomeretrieval.pysame file
symbol_like_termsretrieval.pysame file
wanted_rolesretrieval.pysame file
Imports (2)
SymbolFileResolved by
embeddingsembeddings.pythrough an import
texttext.pythrough an import
Imported by (4)
SymbolFileResolved by
contextcontext.pythrough an import
describedescribe.pythrough an import
routerrouter.pythrough an import
native_servernative_server.pythrough 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 Counter

Shows 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

Read it on GitHub at this commit