KatalockAi AcademyBack to KatalockAi
Capstone 2, counts toward Phase 17

RAG over a codebase

Build cross-repo semantic code search: AST-aware chunks, hybrid dense plus BM25 retrieval, reranking, a symbol graph and cited answers, with incremental re-indexing on each commit.

about 30 h Earns its own certificate Reviewed against a 7-point rubric
Submit your project Get coached by Professor Katalock

The capstone and what it builds on

  1. 1RAG over Codebase (Cross-Repo Semantic Search)The capstone brief
  2. 2Chunking Strategies for RAGPhase 5: Natural language processing
  3. 3Information Retrieval and SearchPhase 5: Natural language processing
  4. 4Embedding Models - The 2026 Deep DivePhase 5: Natural language processing
  5. 5Embeddings & Vector RepresentationsPhase 11: LLM engineering and RAG
  6. 6RAG (Retrieval-Augmented Generation)Phase 11: LLM engineering and RAG
  7. 7Advanced RAG (Chunking, Reranking, Hybrid Search)Phase 11: LLM engineering and RAG
  8. 8Evaluation & Testing LLM ApplicationsPhase 11: LLM engineering and RAG

What You'll Build

A code question-answering system over several repositories. Files are parsed into function and class chunks, indexed three ways (code embedding, summary embedding, field-weighted BM25), linked by a symbol graph and searched with hybrid retrieval plus a cross-encoder reranker. Answers must cite repo/path:start-end for every claim, and the index updates incrementally when a commit lands.

Requirements

  1. Ingestion walker that parses each file with tree-sitter (or the language's own AST) and emits chunk records {repo, path, start_line, end_line, symbol, kind, body} cut at function and class boundaries, not fixed token windows.
  2. Chunk summarizer: a one-sentence summary per chunk (public contract and side effects) from an LLM, cached by content hash so reruns do not pay again. If budget forces you to summarise only part of the corpus, say which part.
  3. Dense embeddings for chunk bodies and summaries (any open code or text embedding model) stored in a vector store (Qdrant, pgvector, LanceDB or FAISS) with the chunk metadata as payload.
  4. BM25 index with field weights (for example symbol name 4, summary 2, body 1) so both "function named X" and "function that does X" queries work.
  5. Symbol graph of import and call edges (kuzu, SQLite or networkx) used at query time to expand retrieval across repo boundaries.
  6. Query pipeline: dense and BM25 retrieval in parallel, dedupe by (repo, path, symbol), fusion, cross-encoder rerank of the top 50 down to 10, then synthesis with required repo/path:start-end citations.
  7. Citation enforcement: parse the answer, validate each anchor against the index (file exists, line range valid) and drop or re-ask for claims without a valid anchor.
  8. Incremental re-index: given a commit (git hook or reindex <sha> command), re-embed only chunks whose text changed, delete stale chunks and update affected edges. Report wall-clock time and chunks re-embedded vs total for a real commit.
  9. Evaluation set of at least 50 questions you write yourself with gold file:line answers, including cross-repo questions. Report MRR@10, nDCG@10, citation faithfulness and p50/p95 query latency, plus an ablation: dense only, hybrid, hybrid plus rerank.
  10. A CLI or small web UI that shows the answer, clickable or copyable citations and snippet previews.

Constraints

  • Model-agnostic: any OpenAI-compatible endpoint (including the KatalockAi API) or a local model (for example via Ollama, llama.cpp or vLLM) may be used. No named commercial model is required; record which model you used in the README.
  • Hardware: a laptop CPU is enough for a small embedding model and reranker (for example a bge-small class embedder and a MiniLM cross-encoder); a GPU just makes ingestion faster.
  • Substitution: the lesson targets 2M lines across 10 repos, 100 questions and 10k QPS. Here at least 3 public repos (roughly 50k lines or more in total), 50 or more labelled questions and latency measured at modest concurrency on your machine are accepted. Report your corpus size.
  • Choose your own repos; do not reuse the example questions from the lesson.

Stretch Goals

  • Inject generated boilerplate into the corpus, measure retrieval poisoning and add a down-weighting flag.
  • Link a cross-language call (for example Python client to Go service) through the symbol graph.
  • Add a weekly drift check that reruns the eval and alerts on a 5% MRR@10 drop.

How to Submit

  • Public GitHub repo with ingest/, index/, query/, eval/ (questions.jsonl with gold anchors, metrics output) and README.md.
  • README: which repos you indexed and why, how to build the index and ask a question, the ablation table, incremental re-index measurements and limitations.
  • Paste the eval metrics output, two example answers with citations and the incremental re-index log when you submit.

How It's Reviewed

Professor Katalock reads your repository and the evidence you paste, and scores each criterion out of 100. You pass with a weighted total of 70 or more and no criterion below 40. A copied or padded submission is flagged and fails.

CriterionWeightHow it's checked
Retrieval quality25eval/ shows MRR@10 and nDCG@10 on 50 or more labelled questions, including the dense / hybrid / hybrid plus rerank ablation.
Citation faithfulness20Fraction of answer claims with valid file:line anchors is reported; the enforcement code validates anchors and handles missing ones.
Incremental indexing correctness15Re-index only touches changed chunks, removes stale ones and updates edges; the log shows time and counts for a real commit; a test covers it.
Latency and scale10Corpus size, p50 and p95 query latency are reported with how they were measured.
UX and answer formatting10CLI or UI shows answers with clickable or copyable citations and snippet previews.
Code quality and structure10Clear module split between ingest, index, query and eval; runs per README; key functions tested.
README: design decisions and limitations10README justifies chunking, fusion and model choices, discusses failure cases from the learner's own eval and states limits.

Submit

Push your work to a public GitHub repository with a README that explains how to run it, then paste the evidence below. Up to 3 reviews a day, free.

  • Eval metrics output (MRR@10, nDCG@10, citation faithfulness, p50/p95 latency) including the ablation table
  • Two example questions with full cited answers
  • Incremental re-index log for a real commit (chunks changed vs total, wall-clock time)
  • List of the repos indexed and their combined line count
  • Short reflection on the worst-performing question type and why

Reviews are done by AI against the rubric above. They check the evidence in your repository; they are not a substitute for a human code review, and a review can be wrong. If you think it is, improve the README so the evidence is unmistakable and resubmit.