Pass 3 of 3 · Deep dive of PHAROSPass 1 · OverviewPass 2 · How it works
Code Observatory / class
Retriever
codeintel.retrieval.Retriever
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 |
|---|---|---|
| assemble_context | context.py | through an import |
| search_code | router.py | through an import |
| build_mcp_server | native_server.py | through an import |
| Symbol | File | Resolved by |
|---|---|---|
| __init__ | retrieval.py | same file |
| _dense | retrieval.py | same file |
| _dense_unavailable_reason | retrieval.py | same file |
| _expand_graph | retrieval.py | same file |
| _filter_clauses | retrieval.py | same file |
| _finalize | retrieval.py | same file |
| _fuse | retrieval.py | same file |
| _hydrate | retrieval.py | same file |
| _keyword | retrieval.py | same file |
| _keyword_python | retrieval.py | same file |
| _symbol_boost | retrieval.py | same file |
| neighbors | retrieval.py | same file |
| search | retrieval.py | same file |
| Symbol | File | Resolved by |
|---|---|---|
| retrieval | retrieval.py | same file |
codeintel.retrieval.Retrieverbackend/app/codeintel/retrieval.py, lines 196–255Open source
class Retriever: def __init__(self, db: Session, embedder: Embedder | None) -> None: self.db = db self.embedder = embedder self.is_pg = db.get_bind().dialect.name == "postgresql" # ── public ───────────────────────────────────────────────────────── def search(self, query: str, *, mode: str = "auto", k: int = 10, filters: Filters | None = None, hints: list[str] | None = None) -> SearchOutcome: """``hints``: identifiers or keywords the caller guesses (an agent's ``parse_url``, ``redirect``). They feed keyword retrieval and the exact name boost; the question alone is embedded. With hints, ``auto`` is hybrid.""" if mode not in MODES: raise ValueError(f"mode must be one of {MODES}") filters = filters or Filters() warnings: list[str] = [] timings: dict[str, float] = {} candidates: dict[str, int] = {} hints = [h.strip() for h in (hints or []) if h and h.strip()][:20] terms = list(dict.fromkeys(query_terms(query) + query_terms(" ".join(hints)))) named = " ".join([query, *hints]) effective = mode dense_reason = self._dense_unavailable_reason(filters) if mode == "auto": if dense_reason is None: effective = "hybrid" if hints else "dense" else: effective = "keyword" warnings.append(f"dense retrieval unavailable ({dense_reason}); used keyword retrieval only") elif mode in ("dense", "hybrid", "graph") and dense_reason is not None: raise ModeUnavailable(mode, dense_reason) keyword: list[tuple[str, float]] = [] dense: list[tuple[str, float]] = [] if effective in ("keyword", "hybrid", "graph"): t = time.perf_counter() keyword = self._keyword(terms, filters, CANDIDATES if effective != "keyword" else max(k * 3, CANDIDATES)) timings["keyword"] = (time.perf_counter() - t) * 1000 candidates["keyword"] = len(keyword) if not terms: warnings.append("query has no searchable terms for keyword retrieval") if effective in ("dense", "hybrid", "graph"): t = time.perf_counter() try: qvec = self.embedder.embed_query(query) # type: ignore[union-attr] except EmbeddingUnavailable as exc: if mode == "auto": warnings.append(f"query embedding failed ({exc}); used keyword retrieval only") effective = "keyword" qvec = None else: raise ModeUnavailable(mode, str(exc)) from exc timings["embed_query"] = (time.perf_counter() - t) * 1000 if qvec is not None: t = time.perf_counter() dense = self._dense(qvec, filters, CANDIDATES) timings["dense"] = (time.perf_counter() - t) * 1000 candidates["dense"] = len(dense)Shows the first 60 of 395 lines. The rest is on GitHub at this commit.
What the index recorded
- Signature
class Retriever:- File
backend/app/codeintel/retrieval.py- Lines
- 196–590
- Parser
- python-ast
- Git blob
884729a39ae0b3d340ad83f75946677dcddf3791- Outside this subset
- 16 more edges reach code outside the graph shown here
