Repository features
Code search
Zoekt shards built by the API, published through the bucket, served by a stateless node.
Code search uses Zoekt, the trigram index behind Sourcegraph. It is off unless ZOEKT_URL is set.
- Indexing runs in the API after each push, in the background: apps/api/src/services/git/code-search/code-search.service.ts › indexInBackground. A call while a run is in flight queues exactly one rerun, so the latest HEAD always gets indexed. A marker object (
zoekt-state/…) records which HEAD and visibility the shards describe. The indexer binary,zoekt-git-index, is copied into the API's Docker image from the same Zoekt releaseapps/zoektruns; keep the two versions in step, since they share a shard format. - Publishing goes through the bucket. The Zoekt node (apps/zoekt/serve.sh) keeps no state: it syncs
zoekt/from the bucket every ten seconds with rclone and loads only complete*.zoektfiles. - Searching:
GET /api/search/codeacross public repositories, and/api/repositories/:owner/:slug/searchwithin one. The query can reach any shard, so the visibility filter (only repositories the caller can read) is what enforces access, and it runs before results are paged so a hidden file never counts toward a page.
Deleting a repository waits out any index run in flight, then removes its shards and marker.