Skip to content
RAG Repo

Software Heritage is a non-profit, long-term archive built specifically for software source code. It collects, preserves, and makes publicly available code from across the software world, and crucially it keeps not just the latest snapshot of a project but its full development history, so you can see how a codebase changed commit by commit. Marking a decade of operation, the archive holds over 27 billion unique source files and has been recognised as a digital public good by the Digital Public Goods Alliance.

The underlying model is a giant graph: repositories, directories, files, and revisions, each file carrying an intrinsic identifier (a SWHID) derived from cryptographic hashes, so any artefact can be referenced permanently and verified. You can explore it through the web interface, which acts as a "wayback machine" for source code, or programmatically through the public REST API and the graph and vault services that let you retrieve directories and full histories. For large-scale work, a full graph export is available rather than crawling the API file by file.

For RAG, this is a strong foundation for code-aware retrieval: building a system that answers questions about how something is implemented, tracing a function across versions, or assembling a corpus of real-world code and commit messages to ground a coding assistant. Its breadth and its emphasis on history are hard to match anywhere else.

The big caveat is licensing, and it is not a small one. Software Heritage's own infrastructure is open source, but the code it preserves keeps whatever licence its original authors set, and those vary from one file to the next, from permissive to strongly copyleft to no licence at all. Archiving is not the same as a grant of reuse rights, so you must check the licence on individual files before redistributing or training on them. If you would rather have that filtering done for you, this is the upstream source for The Stack v2, which selects only permissively licensed code and is the more practical starting point for most model training.

source-codearchivepreservationnonprofitsoftware

Related sources