Back to the room

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

Code Observatory / module

source

codeintel.source

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

Calls (1)
SymbolFileResolved by
_FileCachesource.pysame file
Contains (9)
SymbolFileResolved by
_fetch_httpssource.pysame file
_FileCachesource.pysame file
_loadsource.pysame file
_resolve_onesource.pysame file
_slicesource.pysame file
git_blob_shasource.pysame file
resolve_sourcessource.pysame file
SourceRequestsource.pysame file
SourceResultsource.pysame file
Imports (1)
SymbolFileResolved by
git_sourcegit_source.pythrough an import
Imported by (3)
SymbolFileResolved by
contextcontext.pythrough an import
symbolssymbols.pythrough an import
routerrouter.pythrough an import
codeintel.sourcebackend/app/codeintel/source.py, lines 1–40Open source
"""On-demand source resolution for hybrid storage.Pharos stores pointers (repository, commit, path, line span) instead ofsource code. This module turns a pointer back into code:* **local repositories** — ``git cat-file`` from the registered checkout's  object database (works offline, no network);* **GitHub / GitLab / Bitbucket** — the host's raw-file endpoint at the  pinned commit, over https, from an allowlist of hosts, without following  redirects, with a size cap and a short timeout.Every fetched file is checked against the git blob SHA recorded at indextime (``sha1("blob <len>\\0" + bytes)``). A mismatch is reported as``unavailable:content_mismatch`` instead of returning code that may not bewhat was indexed. Because URLs pin a commit, fetched files are immutable andare cached in-process."""from __future__ import annotationsimport concurrent.futuresimport hashlibimport loggingimport threadingfrom collections import OrderedDictfrom dataclasses import dataclassfrom urllib.parse import urlsplitfrom .git_source import RAW_CONTENT_HOSTS, GitError, local_git_dir, raw_file_url, read_file_at_commitlogger = logging.getLogger(__name__)MAX_FETCH_BYTES = 2_000_000FETCH_TIMEOUT_SECONDS = 5.0FETCH_CONCURRENCY = 8CACHE_FILES = 256@dataclassclass SourceRequest:

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

What the index recorded

Signature
module backend.app.codeintel.source
File
backend/app/codeintel/source.py
Lines
1–173
Parser
python-ast
Git blob
c9f05cf7bf871b09919d64e9fdaf8380ecc3df2c
Call sites
2 named, 1 resolved, 1 left unlinked

Read it on GitHub at this commit