Pass 3 of 3 · Deep dive of PHAROSPass 1 · OverviewPass 2 · How it works
Code Observatory / Source
Read the neighbours
Loads edges in both directions and keeps each resolution. A limit caps the rows read.
PINNED SOURCE Copied from the repository at this commit. Source, not an execution.
PHAROS at 975a38dMIT license
symbol_graphbackend/app/codeintel/symbols.py, lines 39–62Open source
def symbol_graph(db: Session, chunk_id: uuid.UUID, *, limit: int = 50) -> dict[str, list[dict]]: """Resolved callers, callees, containment and imports around one chunk.""" out: dict[str, list[dict]] = {"calls": [], "called_by": [], "contains": [], "contained_by": [], "imports": [], "imported_by": []} edges = db.execute( select(CodeEdge.source_chunk_id, CodeEdge.target_chunk_id, CodeEdge.edge_type, CodeEdge.resolution) .where(or_(CodeEdge.source_chunk_id == chunk_id, CodeEdge.target_chunk_id == chunk_id)) .limit(limit * 6) ).all() other_ids = {t if s == chunk_id else s for s, t, _, _ in edges if t is not None} chunks = { c.id: c for c in db.execute(select(DocumentChunk).where(DocumentChunk.id.in_(other_ids))).scalars() } if other_ids else {} inverse = {"calls": "called_by", "contains": "contained_by", "imports": "imported_by"} for src, dst, etype, resolution in edges: outgoing = src == chunk_id other = chunks.get(dst if outgoing else src) if other is None: continue relation = etype if outgoing else inverse[etype] if len(out[relation]) >= limit: continue out[relation].append(chunk_ref(other) | {"resolution": resolution}) return outWhere this comes from
- Commit
975a38d5d17839c26ee219295a5be6ac66b6d910- File
backend/app/codeintel/symbols.py- Lines
- 39–62
- Git blob
abdbb1001335e092a3fd51dcc000a89cac57e3a4- License
- MIT, © 2024–2026 Pharos Contributors. Notice
Read it on GitHub at this commit
Check it yourself
From a clone of the repository, the first command prints the blob above and the second prints these lines.
git rev-parse 975a38d:backend/app/codeintel/symbols.py
git show 975a38d:backend/app/codeintel/symbols.py | sed -n '39,62p'