# 软件遗产

**软件遗产**（Software Heritage）是法国国家数字科学技术研究所（Inria）与联合国教科文组织（UNESCO）合作，于2016年发起的一项非营利计划，旨在建立一个通用、长期的档案库，收录所有公开可获取的软件源代码及其完整的开发历史。<sup>[1](https://scienceouverte.univ-lille.fr/en/news/news-detail/happy-birthday-software-heritage)</sup><sup> • </sup><sup>[2](https://pmc.ncbi.nlm.nih.gov/articles/PMC7340894/)</sup> 据称其档案库是现存最大的公共源代码集合；截至2025年12月，它保存了来自超过4.21亿个项目的270多亿个唯一源文件。<sup>[3](https://www.softwareheritage.org/software-heritage-faq/)</sup><sup> • </sup><sup>[4](https://www.softwareheritage.org/wp-content/uploads/2026/01/activity_report_2025.pdf)</sup> 该项目由两位研究者领导：一位是借调至Inria的计算机科学教授罗伯托·迪·科斯莫（Roberto Di Cosmo），另一位是斯特凡诺·扎基罗利（Stefano Zacchiroli）。<sup>[1](https://scienceouverte.univ-lille.fr/en/news/news-detail/happy-birthday-software-heritage)</sup><sup> • </sup><sup>[5](https://www.lemonde.fr/economie/article/2025/01/05/software-heritage-et-scikit-learn-ou-la-bibliotheque-d-alexandrie-du-code-source_6482998_3234.html)</sup>

| 关键事实 | 详情 |
|---|---|
| 成立 | 2016年成立于Inria，获联合国教科文组织支持；由罗伯托·迪·科斯莫和斯特凡诺·扎基罗利领导<sup>[1](https://scienceouverte.univ-lille.fr/en/news/news-detail/happy-birthday-software-heritage)</sup> |
| 与联合国教科文组织的伙伴关系 | 2017年4月3日在联合国教科文组织总部签署协议；档案库于2018年6月7日向公众开放<sup>[6](https://www.unesco.org/en/articles/agreement-software-preservation-signed-unesco)</sup><sup> • </sup><sup>[7](https://www.unesco.org/en/articles/softwareheritageorg-unesco-and-inria-open-archive-digital-age)</sup> |
| 档案规模 | 截至2025年12月，收录来自超过4.21亿个项目和50亿次提交的270多亿个唯一源文件；每秒摄取85个文件和1.3个完整项目<sup>[4](https://www.softwareheritage.org/wp-content/uploads/2026/01/activity_report_2025.pdf)</sup> |
| 数据结构 | 所有制品存储于单一的梅克尔有向无环图中，内置去重机制，独立于版本控制系统或包格式<sup>[8](https://docs.softwareheritage.org/devel/swh-model/data-model.html)</sup><sup> • </sup><sup>[2](https://pmc.ncbi.nlm.nih.gov/articles/PMC7340894/)</sup> |
| 标识符 | SWHID（SoftWare Hash Identifier，软件哈希标识符），一种由代码内容推导出的内在标识符，于2025年4月23日成为国际标准ISO/IEC 18670<sup>[9](https://www.softwareheritage.org/software-hash-identifier-swhid/)</sup> |
| 保存 | 由独立镜像站点组成的网络维护档案库的完整副本；第一个镜像于2023年12月在意大利博洛尼亚上线，由意大利国家新技术、能源和可持续经济发展局（ENEA）托管<sup>[2](https://pmc.ncbi.nlm.nih.gov/articles/PMC7340894/)</sup><sup> • </sup><sup>[4](https://www.softwareheritage.org/wp-content/uploads/2026/01/activity_report_2025.pdf)</sup> |
| 已知局限 | 截至2025年初，归档积压为1至2年；不归档大于100 MB的对象<sup>[10](https://docs.softwareheritage.org/user/using_data/index.html)</sup> |

## 历史

该计划于2016年在法国国家数字科学技术研究所（Inria）发起，获联合国教科文组织支持，旨在应对源代码相对于其所支撑软件的普遍存在而言所具有的脆弱性。<sup>[1](https://scienceouverte.univ-lille.fr/en/news/news-detail/happy-birthday-software-heritage)</sup> 2017年4月3日，联合国教科文组织与Inria在联合国教科文组织总部签署协议，致力于保存软件中包含的技术与科学知识，法国总统弗朗索瓦·奥朗德（François Hollande）、联合国教科文组织总干事伊琳娜·博科娃（Irina Bokova）和Inria首席执行官安托万·珀蒂（Antoine Petit）出席了签字仪式。<sup>[6](https://www.unesco.org/en/articles/agreement-software-preservation-signed-unesco)</sup>

**公开启动。** 档案库于2018年6月7日在联合国教科文组织总部向公众开放。当时它收录了来自超过8300万个软件项目的40多亿个唯一源代码文件，包括其历次迭代版本。<sup>[7](https://www.unesco.org/en/articles/softwareheritageorg-unesco-and-inria-open-archive-digital-age)</sup> 启动仪式上重点展示的例子包括[阿波罗11号](https://www.edgepedia.org/zh/apollo-11)导航系统的源代码、NCSA Mosaic浏览器、电子游戏《[雷神之锤III竞技场](https://www.edgepedia.org/zh/quake-iii-arena)》（Quake III Arena）以及Angular.js网页框架。<sup>[7](https://www.unesco.org/en/articles/softwareheritageorg-unesco-and-inria-open-archive-digital-age)</sup>

增长迅速而持续。2020年，档案库收录了来自超过1亿个软件来源的70多亿个唯一源文件，<sup>[2](https://pmc.ncbi.nlm.nih.gov/articles/PMC7340894/)</sup> 截至2023年7月，收录了来自超过2.5亿个项目的160多亿个文件，<sup>[11](https://arxiv.org/abs/2310.10295)</sup> 到2025年1月，收录了来自3.4亿个项目的约220亿个文件，<sup>[5](https://www.lemonde.fr/economie/article/2025/01/05/software-heritage-et-scikit-learn-ou-la-bibliotheque-d-alexandrie-du-code-source_6482998_3234.html)</sup> 截至2025年12月，收录了来自4.21亿个项目的270多亿个文件。<sup>[4](https://www.softwareheritage.org/wp-content/uploads/2026/01/activity_report_2025.pdf)</sup> 迪·科斯莫在2025年1月表示，其体量大约每两年翻一番。<sup>[5](https://www.lemonde.fr/economie/article/2025/01/05/software-heritage-et-scikit-learn-ou-la-bibliotheque-d-alexandrie-du-code-source_6482998_3234.html)</sup>

## 档案库的运作方式

软件遗产从GitHub和GitLab等代码托管平台、Debian、Ubuntu和Fedora等Linux发行版，以及PyPI、npm和CPAN等包仓库收集代码。一个大规模自动化爬虫定期列出软件来源、安排更新计划，并将制品连同其完整开发历史载入档案库。<sup>[2](https://pmc.ncbi.nlm.nih.gov/articles/PMC7340894/)</sup><sup> • </sup><sup>[12](https://www.softwareheritage.org/wp-content/uploads/2020/01/ipres-2017-swh.pdf)</sup> 由于收集是自动化的，档案库也会摄取托管非代码内容或二进制代码的仓库。<sup>[10](https://docs.softwareheritage.org/user/using_data/index.html)</sup>

**单一的梅克尔图。** 所有收集到的源代码都被转换为一种通用数据结构——一个巨大的梅克尔有向无环图，这是一种结合了树与哈希函数的密码学构造。<sup>[13](https://www.softwareheritage.org/software-heritage-features/)</sup> 每个节点的标识符是其规范内容及其所指向节点的密码学哈希值，因此任何改动都会产生不同的标识符。<sup>[8](https://docs.softwareheritage.org/devel/swh-model/data-model.html)</sup> 由于源代码制品存在大量重复——通过代码托管的分散分布、复制粘贴复用以及修订版本之间的小提交——去重是内置的：只有当不存在标识符匹配的节点时才会添加制品，因此相同的文件、提交、目录和快照只产生一次存储成本。<sup>[8](https://docs.softwareheritage.org/devel/swh-model/data-model.html)</sup> 一个附带效果是，所有归档代码的完整开发历史作为一个统一整体可供使用，使得跨项目的代码复用等结构变得易于观察。<sup>[8](https://docs.softwareheritage.org/devel/swh-model/data-model.html)</sup>

档案库在2025年突破了2拍字节大关；团队与比萨大学和米兰大学合作，部署了压缩协议，将78 TB的原始数据缩减为3 TB的研究数据集，用于大规模代码分析。<sup>[4](https://www.softwareheritage.org/wp-content/uploads/2026/01/activity_report_2025.pdf)</sup>

## SWHID标识符

档案库中的每个制品都带有一个SWHID（SoftWare Hash Identifier，软件哈希标识符），这是一个直接从代码内容推导出的唯一永久标识符。<sup>[3](https://www.softwareheritage.org/software-heritage-faq/)</sup> 由于该标识符是内在的，可以在本地计算和验证，独立于软件遗产，使用通过PyPI以swh.model分发的开源swh-identify工具即可。<sup>[2](https://pmc.ncbi.nlm.nih.gov/articles/PMC7340894/)</sup>

SWHID在多个粒度级别上标识软件：文件内容、目录、提交、发布和快照，限定符可以指定制品在档案库中的位置或标识特定的代码片段。<sup>[3](https://www.softwareheritage.org/software-heritage-faq/)</sup> 例如，标识符swh:1:cnt:94a9ed024d3859793618152ea559a168bbcbb5e2指向包含GPL3许可证全文的文件内容。<sup>[3](https://www.softwareheritage.org/software-heritage-faq/)</sup> 每个展示源代码的档案页面上的“永久链接”标签页提供所查看内容的SWHID及相应的URL。<sup>[3](https://www.softwareheritage.org/software-heritage-faq/)</sup>

**标准化。** 该标识符模式最初为档案库开发，从“软件遗产标识符”更名为“软件哈希标识符”，并于2025年4月23日作为国际标准ISO/IEC 18670发布。<sup>[9](https://www.softwareheritage.org/software-hash-identifier-swhid/)</sup><sup> • </sup><sup>[14](https://www.softwareheritage.org/2026/04/23/one-year-swhid-iso-iec-18670-standard/)</sup> 该标准由Rust、Python和Go的参考实现以及一个旨在防止跨平台分歧的公共测试套件提供支持。<sup>[14](https://www.softwareheritage.org/2026/04/23/one-year-swhid-iso-iec-18670-standard/)</sup>

## 在研究与开放科学中的用途

软件遗产解决了研究软件的两个关切：归档和引用。研究界鼓励将源代码归档到长期公共档案库中以支持可复现性，2011年引入的制品评估流程和ACM的制品审查与徽章计划等机制对研究软件进行评估。<sup>[2](https://pmc.ncbi.nlm.nih.gov/articles/PMC7340894/)</sup> 由于研究软件往往是建立在学术界之外开发的众多依赖之上的薄层，仅靠机构档案库无法覆盖所有与可复现性相关的软件；软件遗产主动归档公开可获取的软件，即使作者未采取任何归档措施。<sup>[2](https://pmc.ncbi.nlm.nih.gov/articles/PMC7340894/)</sup>

档案库还支持实证软件研究。其梅克尔图将公共代码的开发历史物化为单一结构，已被用于研究仓库分叉、开源贡献者、漏洞传播、软件来源追踪和源代码索引。<sup>[11](https://arxiv.org/abs/2310.10295)</sup> 一项对该档案库早期语料的研究发现，原创的、此前从未出现过的源代码文件和提交的增长率在40多年的时间里呈指数增长，不同提交之间相同文件的倍增出现了组合爆炸。<sup>[15](https://arxiv.org/abs/1906.08076)</sup>

**被引代码的覆盖情况。** 2024年，研究人员检查了取自学术出版物的Git托管平台URI，报告称93.98%在活跃网络上仍可公开访问，软件遗产保存了其中68.39%的副本，网络档案库保存了81.43%。<sup>[16](https://arxiv.org/abs/2401.04887)</sup> 同一研究方向发现，通用网络档案库保存的GitHub源代码树很少，平均不到源文件的5%，这将软件遗产的内容级方法与页面级网络归档区分开来。<sup>[17](https://arxiv.org/abs/2505.15042)</sup>

档案库还为人工智能研究提供了数据：2024年2月，首个基于软件遗产数据构建的代码大语言模型Starcoder2使用[The Stack](https://www.edgepedia.org/zh/the-stack) v2数据集发布。<sup>[4](https://www.softwareheritage.org/wp-content/uploads/2026/01/activity_report_2025.pdf)</sup> 2023年10月，该项目发布了关于在软件遗产上进行负责任人工智能训练的原则，而CodeCommons计划于2024年和2025年启动，为负责任的人工智能构建开放、透明、基于代码的资源。<sup>[4](https://www.softwareheritage.org/wp-content/uploads/2026/01/activity_report_2025.pdf)</sup>

## 保存与局限

长期保存依托几个支柱：Inria的机构支持、来自从IT公司到公共机构等多元赞助者的资金，以及一个由独立国际镜像站点组成的网络，每个镜像都维护档案库的完整副本。<sup>[2](https://pmc.ncbi.nlm.nih.gov/articles/PMC7340894/)</sup> 第一个独立镜像于2023年12月在意大利博洛尼亚上线，由ENEA托管；GRNet运营的镜像于2025年在希腊启动，在德国UNIDue的部署正在筹备中。<sup>[4](https://www.softwareheritage.org/wp-content/uploads/2026/01/activity_report_2025.pdf)</sup>

档案库记录了已知局限。由于资源限制，它存在较长的归档积压：截至2025年初，大多数最近创建的仓库或已知仓库的近期更新缺失，滞后1至2年，不过有计划将其缩短至数天或数周。<sup>[10](https://docs.softwareheritage.org/user/using_data/index.html)</sup> 在软件遗产开始归档某个代码托管平台之前从该平台删除的源代码会缺失，这可能使较冷门的平台托管的代码代表性不足。<sup>[10](https://docs.softwareheritage.org/user/using_data/index.html)</sup> Chromium和Linux等超大型仓库给加载器带来挑战，大于100 MB的对象不被归档，作者和提交者的姓名与电子邮件在数据中被假名化。<sup>[10](https://docs.softwareheritage.org/user/using_data/index.html)</sup>

迈向2026年，一个由来自Eclipse基金会、亚马逊、Anaconda和其他组织的专家组成的新顾问委员会正在指导该计划转型为完全独立的全球多方利益相关者组织。<sup>[4](https://www.softwareheritage.org/wp-content/uploads/2026/01/activity_report_2025.pdf)</sup>

## References

1. [Happy birthday, Software Heritage! University of Lille Open Science](https://scienceouverte.univ-lille.fr/en/news/news-detail/happy-birthday-software-heritage)
2. [Roberto Di Cosmo (2020). Archiving and Referencing Source Code with Software Heritage. ICMS 2020, LNCS 12097, pp. 362–373.](https://pmc.ncbi.nlm.nih.gov/articles/PMC7340894/)
3. [Software Heritage FAQ](https://www.softwareheritage.org/software-heritage-faq/)
4. [software heritage](https://www.softwareheritage.org/wp-content/uploads/2026/01/activity_report_2025.pdf)
5. [Software Heritage et Scikit-learn, ou la « bibliothèque d'Alexandrie » du code source, Le Monde, 5 January 2025](https://www.lemonde.fr/economie/article/2025/01/05/software-heritage-et-scikit-learn-ou-la-bibliotheque-d-alexandrie-du-code-source_6482998_3234.html)
6. [Agreement on software preservation signed at UNESCO, 3 April 2017](https://www.unesco.org/en/articles/agreement-software-preservation-signed-unesco)
7. [Softwareheritage.org, UNESCO and Inria open the Archive of the Digital Age, 6 June 2018](https://www.unesco.org/en/articles/softwareheritageorg-unesco-and-inria-open-archive-digital-age)
8. [Data model, Software Heritage documentation](https://docs.softwareheritage.org/devel/swh-model/data-model.html)
9. [SoftWare Hash IDentifier (SWHID), Software Heritage](https://www.softwareheritage.org/software-hash-identifier-swhid/)
10. [Using Software Heritage data, Software Heritage documentation](https://docs.softwareheritage.org/user/using_data/index.html)
11. [Roberto Di Cosmo and Stefano Zacchiroli (2023). The Software Heritage Open Science Ecosystem. arXiv:2310.10295.](https://arxiv.org/abs/2310.10295)
12. [Roberto Di Cosmo and Stefano Zacchiroli (2017). Software Heritage: Why and How to Preserve Software Source Code. iPRES 2017.](https://www.softwareheritage.org/wp-content/uploads/2020/01/ipres-2017-swh.pdf)
13. [Software Heritage features](https://www.softwareheritage.org/software-heritage-features/)
14. [One Year of SWHID as the ISO/IEC 18670 International Standard, Software Heritage, 23 April 2026](https://www.softwareheritage.org/2026/04/23/one-year-swhid-iso-iec-18670-standard/)
15. [Guillaume Rousseau, Roberto Di Cosmo, Stefano Zacchiroli (2019). Growth and Duplication of Public Source Code over Time: Provenance Tracking at Scale. arXiv:1906.08076.](https://arxiv.org/abs/1906.08076)
16. [Emily Escamilla and colleagues (2024). Cited But Not Archived: Analyzing the Status of Code References in Scholarly Articles. arXiv:2401.04887.](https://arxiv.org/abs/2401.04887)
17. [David Calano, Michael Nelson, Michele Weigle (2025). GitHub Repository Complexity Leads to Diminished Web Archive Availability. WebSci '25.](https://arxiv.org/abs/2505.15042)

---
*Initially written Oct 15, 2026*

Topic: 技术与人造世界 › 计算技术与数字系统 › 软件与编程 › Free and open-source software

Copyright 2026 Edgepedia

License: Edgepedia Community License 1.0, https://www.edgepedia.org/edgepedia/license

Source: https://www.edgepedia.org/zh/software-heritage

English original: https://www.edgepedia.org/software-heritage
