An incremental, bottom-up migration of libgit2 from C to Rust.
So far, 41.9% of libgit2's public C API is available as safe Rust bindings: a safe,
idiomatic Rust interface, implemented for now by libgit2's C through unsafe Rust, with
the raw bindings in the libgit2-sys crate.
- Bind (in progress): put a safe Rust API in front of all of libgit2's public C API.
- Migrate: module by module, from the bottom of the dependency order up, port the C
behind the bindings to safe Rust and swap it in for the
unsafeimplementation, without breaking the API's consumers. - Ship hybrids: every step ships as an interoperable build that mixes C and Rust, the modules migrated so far in Rust and the rest still in C.
The bindings were generated by Crustify, a specification-driven AI co-translator developed at UC Berkeley, and reviewed by its own independent, adversarial agents; the paper details the campaign.
- Models: mainly Claude Opus 5.5. GPT-6.1 Sol wrapped the
configmodule and GPT-6 Astra most of the firstindexwave; Claude Fable 5.1 ran the early reviews. - wavefront: CodeQL-based analysis of the C that plans the work in dependency order.
- ffibox: ownership and borrowed-handle types the bindings hold C memory through.
- ffimap: maps the
unsafecode and raw pointers left on the public API. - bindgen for the raw bindings; ASan/UBSan, TSan, Miri and BorrowSanitizer to check for undefined behavior.
- glibc-bindings, openssl-bindings, pcre2-bindings and zlib-bindings for the libraries libgit2 links: each is built per sanitizer variant and wraps what libgit2's API uses as the campaign reaches it.
| Public API wrapped | 480 of 1,146 items (41.9%): 69 of 165 types, 411 of 981 symbols |
| Tests | 2,064: 787 unit, 489 equivalence with the C, 688 UB on the safe API, 100 UB on the unsafe API |
| Line coverage | 98.9% of the Rust, 46.0% of the C |
unsafe public functions |
42 of 2,663 (1.6%) on the consumer-facing interface; 102 (3.8%) with ffibox's trait methods and raw constructors |
| Raw pointers | in 2 consumer-facing public functions' signatures (0.1%); none in public fields |
| UB defects the reviewers fixed | 8 |
| Rust | 17,571 lines of code |
| Wall-clock time, cost | 51.9 hours, $2,308 for every agent |
The campaign's plan, review reports and dashboard are under crustify/.
GPL-2.0-only with the GCC linking exception, as libgit2.