Skip to lesson
Exit
AI-Editor Systems & Design1 / 2

1 min lesson

Indexing a large repo and keeping it fresh

Explain the order in "Indexing a large repo and keeping it fresh", then say how you would verify the result.

Step 1 of 2

Indexing a large repo and keeping it fresh

A repo with hundreds of thousands of files can't be re-embedded on every keystroke. The interview wants to hear that you index incrementally and treat freshness as a first-class problem.

  1. 1Initial build. Walk the tree, chunk by syntactic unit (function, class, block) rather than fixed lines so a chunk is a meaningful retrieval target. Embed and store, keyed by a content hash.
  2. 2Incremental update. On save or file-watch event, re-chunk only the changed files. The content hash skips re-embedding chunks whose text didn't move.
  3. 3Edit-time freshness. Between index updates, the live buffer is the source of truth - read recent edits from the editor, not the stale index, so the model sees what the user just typed.
  4. 4Eviction. Drop vectors for deleted files and prune by access recency so the index doesn't grow without bound.