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 symbolsLoading
| Symbol | File | Resolved by |
|---|---|---|
| _Budget | context.py | same file |
| _cite | context.py | same file |
| _render | context.py | same file |
| _render_memory | context.py | same file |
| assemble_context | context.py | same file |
| ContextRequest | context.py | same file |
| hit_to_dict | context.py | same file |
| RepositoryNotFound | context.py | same file |
| resolve_repositories | context.py | same file |
| select_rules | context.py | same file |
| source_requests | context.py | same file |
| Symbol | File | Resolved by |
|---|---|---|
| embeddings | embeddings.py | through an import |
| git_source | git_source.py | through an import |
| retrieval | retrieval.py | through an import |
| source | source.py | through an import |
| Symbol | File | Resolved by |
|---|---|---|
| router | router.py | through an import |
| native_server | native_server.py | through 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
