Back to the room

Pass 3 of 3 · Deep dive of PHAROSPass 1 · OverviewPass 2 · How it works

Code Observatory / module

describe

codeintel.describe

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 (4)
SymbolFileResolved by
_candidatesdescribe.pysame file
describe_repositorydescribe.pysame file
DescribeStatsdescribe.pysame file
groundeddescribe.pysame file
Imports (3)
SymbolFileResolved by
embeddingsembeddings.pythrough an import
retrievalretrieval.pythrough an import
texttext.pythrough an import
codeintel.describebackend/app/codeintel/describe.py, lines 1–40Open source
"""Contextual descriptions: an LLM says what each function does, for dense retrieval.Behaviour that lives only in a body ("run the persistent pre-run hooks") isinvisible to a summary of signature, docstring and calls. On the owner's Mac,``pharos describe`` asks Codex for a one- or two-sentence description of eachsource function (undocumented ones first), caches it per (git blob SHA,symbol) in ``chunk_descriptions``, and re-embeds the chunk with it. Laterindexing reuses the cache, so a description is only written again when itsfile changes. Production never calls an LLM.Safety: the model sees only code PHAROS read from the checkout, answers onlyfor ids PHAROS issued, and a description that names an identifier the codedoes not contain is dropped (it would teach retrieval something untrue)."""from __future__ import annotationsimport loggingimport refrom collections.abc import Callablefrom dataclasses import dataclass, fieldfrom pathlib import Pathfrom sqlalchemy import selectfrom sqlalchemy.orm import Sessionfrom ..database.models import ChunkDescription, DocumentChunk, Resourcefrom .embeddings import Embedderfrom .retrieval import path_rolefrom .text import with_descriptionlogger = logging.getLogger(__name__)KINDS = ("function", "method", "macro")BATCH = 12MAX_CODE_CHARS = 1500MAX_DESCRIPTION_CHARS = 400INSTRUCTIONS = """You describe source code for a code-search index.For each numbered snippet, write one or two plain sentences (at most 45 words) saying what the code does

Shows the first 40 of 165 lines. The rest is on GitHub at this commit.

What the index recorded

Signature
module backend.app.codeintel.describe
File
backend/app/codeintel/describe.py
Lines
1–165
Parser
python-ast
Git blob
9e70d40ab4a4d664b1b0e8b0ac225e7a134fa3f2
Call sites
2 named, 0 resolved, 2 left unlinked
Outside this subset
4 more edges reach code outside the graph shown here

Read it on GitHub at this commit