Back to the room

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

Code Observatory / module

context

codeintel.context

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 (11)
SymbolFileResolved by
_Budgetcontext.pysame file
_citecontext.pysame file
_rendercontext.pysame file
_render_memorycontext.pysame file
assemble_contextcontext.pysame file
ContextRequestcontext.pysame file
hit_to_dictcontext.pysame file
RepositoryNotFoundcontext.pysame file
resolve_repositoriescontext.pysame file
select_rulescontext.pysame file
source_requestscontext.pysame file
Imports (4)
SymbolFileResolved by
embeddingsembeddings.pythrough an import
git_sourcegit_source.pythrough an import
retrievalretrieval.pythrough an import
sourcesource.pythrough an import
Imported by (2)
SymbolFileResolved by
routerrouter.pythrough an import
native_servernative_server.pythrough an import
codeintel.contextbackend/app/codeintel/context.py, lines 1–40Open source
"""Context assembly for coding assistants.``assemble_context`` answers "what code should the assistant look at forthis question?" with:* ranked chunks, each with a source pointer (repository, commit, path,  lines), the retrieval evidence, and — unless disabled — the code itself,  verified against the indexed blob SHA;* graph neighbours of the top hits (callers / callees / imports) as compact  summaries;* the repository's learned memory (``app.learning``): its brief, the active  conventions and facts scoped to the retrieved files, and matching  playbooks — rendered first, so it leads the answer;* ACTIVE coding rules learned for the repository (pattern-learning loop);* ``context_text``: the same material rendered as Markdown with  ``path:start-end`` citations, cut to a character budget.The response is plain JSON-serialisable data; the REST endpoint, the MCPtool and the CLI all return it unchanged."""from __future__ import annotationsimport timeimport uuidfrom dataclasses import dataclassfrom sqlalchemy import selectfrom sqlalchemy.orm import Sessionfrom ..database.models import CodingProfile, DocumentChunk, ProposedRule, Repository, Resourcefrom ..learning.recall import memory_for_contextfrom .embeddings import Embedderfrom .git_source import web_file_urlfrom .retrieval import Filters, Hit, Retriever, repositories_matchingfrom .source import SourceRequest, resolve_sourcesMODULE_CODE_LINES = 40MEMORY_CHARS = 4000  # the memory block's share of the budget (at most a third of it)

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

What the index recorded

Signature
module backend.app.codeintel.context
File
backend/app/codeintel/context.py
Lines
1–360
Parser
python-ast
Git blob
0c4a7dd4639651a5c13142d168630e344439f22a
Outside this subset
9 more edges reach code outside the graph shown here

Read it on GitHub at this commit