Pass 3 of 3 · Deep dive of PHAROSPass 1 · OverviewPass 2 · How it works
Code Observatory / Source
Down-rank tests and docs
Tests, docs and examples are multiplied by 0.7 after fusion, unless the query asks for them.
PINNED SOURCE Copied from the repository at this commit. Source, not an execution.
PHAROS at 975a38dMIT license
Retriever._finalizebackend/app/codeintel/retrieval.py, lines 511–531Open source
def _finalize(self, hits: dict[str, Hit], k: int, wanted: set[str] = frozenset()) -> list[Hit]: if not hits: return [] # Down-rank tests, docs and examples (they repeat the words of the # code they exercise or describe and crowd out implementations); # applied after fusion so they still surface when they are the only # match, and not at all for roles the query asks for. paths = dict( self.db.execute( select(DocumentChunk.id, DocumentChunk.chunk_metadata["path"].as_string()).where( DocumentChunk.id.in_([uuid.UUID(c) for c in hits]) ) ).all() ) for cid, h in hits.items(): role = path_role(paths.get(uuid.UUID(cid)) or "") if role != "source" and role not in wanted: h.score *= NOISE_PATH_FACTOR h.evidence.boosts.append(f"{role}_path_penalty") ranked = sorted(hits.values(), key=lambda h: (-h.score, h.chunk_id)) return ranked[:k]Where this comes from
- Commit
975a38d5d17839c26ee219295a5be6ac66b6d910- File
backend/app/codeintel/retrieval.py- Lines
- 511–531
- 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 '511,531p'