Back to the room

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

Code Observatory / Source

One hop of the graph

Calls and imports around the top hits. Containment edges are left out.

PINNED SOURCE Copied from the repository at this commit. Source, not an execution.

PHAROS at 975a38dMIT license

Retriever.neighborsbackend/app/codeintel/retrieval.py, lines 567–590Open source
    def neighbors(self, chunk_ids: Iterable[str], limit: int = 10) -> list[tuple[str, str, str]]:        """``(seed_id, neighbor_id, relation)`` for one hop around ``chunk_ids``."""        ids = [uuid.UUID(c) for c in chunk_ids]        if not ids:            return []        rows = self.db.execute(            select(CodeEdge.source_chunk_id, CodeEdge.target_chunk_id, CodeEdge.edge_type)            .where(                and_(                    CodeEdge.edge_type != "contains",                    or_(CodeEdge.source_chunk_id.in_(ids), CodeEdge.target_chunk_id.in_(ids)),                )            )            .limit(limit * 4)        ).all()        seeds = {str(i) for i in ids}        out = []        for s, t, etype in rows:            s, t = str(s), str(t)            if s in seeds and t not in seeds:                out.append((s, t, etype))            elif t in seeds and s not in seeds:                out.append((t, s, {"calls": "called_by", "imports": "imported_by"}.get(etype, etype)))        return out[:limit]

Where this comes from

Commit
975a38d5d17839c26ee219295a5be6ac66b6d910
File
backend/app/codeintel/retrieval.py
Lines
567–590
Git blob
884729a39ae0b3d340ad83f75946677dcddf3791
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/retrieval.py
git show 975a38d:backend/app/codeintel/retrieval.py | sed -n '567,590p'