# Crustify: Repository-Level Generation of Safe Rust Bindings with LLM Agents and Coverage-Guided Testing

DevFeed: [Crustify: Repository-Level Generation of Safe Rust Bindings with LLM Agents and Coverage-Guided Testing](<https://devfeed.tech/articles/crustify-repository-level-generation-of-safe-rust-bindings-with-llm-agents-and-coverage-guided-testing-125930.md>)

Original publisher: [Read original article](<https://arxiv.org/abs/2611.10394>)

Author: Marius Momeu, Marius Arvinte, Cory Cornelius, Koushik Sen

Published: 2026-11-10T05:00:00Z

Content type: article

Language: en

Sources: [arXiv: Artificial Intelligence](<https://devfeed.tech/sources/arxiv-artificial-intelligence.md>), [arXiv: Cryptography and Security](<https://devfeed.tech/sources/arxiv-cryptography-and-security.md>), [arXiv: Software Engineering](<https://devfeed.tech/sources/arxiv-software-engineering.md>)

Topics: [AI-assisted coding](<https://devfeed.tech/topics/ai-assisted-coding.md>), [code analysis](<https://devfeed.tech/topics/code-analysis.md>), [test](<https://devfeed.tech/topics/test.md>), [Instrumentation](<https://devfeed.tech/topics/instrumentation.md>)

Tags: [agentic](<https://devfeed.tech/tags/agentic.md>), [agents](<https://devfeed.tech/tags/agents.md>), [analyzer](<https://devfeed.tech/tags/analyzer.md>), [apis](<https://devfeed.tech/tags/apis.md>), [c](<https://devfeed.tech/tags/c.md>), [coverage](<https://devfeed.tech/tags/coverage.md>), [cs-ai](<https://devfeed.tech/tags/cs-ai.md>), [cs-cr](<https://devfeed.tech/tags/cs-cr.md>), [cs-pl](<https://devfeed.tech/tags/cs-pl.md>), [cs-se](<https://devfeed.tech/tags/cs-se.md>), [defects](<https://devfeed.tech/tags/defects.md>), [dependencies](<https://devfeed.tech/tags/dependencies.md>), [error](<https://devfeed.tech/tags/error.md>), [ffmpeg](<https://devfeed.tech/tags/ffmpeg.md>), [fixed](<https://devfeed.tech/tags/fixed.md>), [functions](<https://devfeed.tech/tags/functions.md>), [generation](<https://devfeed.tech/tags/generation.md>), [independent](<https://devfeed.tech/tags/independent.md>), [lifecycle](<https://devfeed.tech/tags/lifecycle.md>), [llm-agents](<https://devfeed.tech/tags/llm-agents.md>), [repository](<https://devfeed.tech/tags/repository.md>), [rust](<https://devfeed.tech/tags/rust.md>), [testing](<https://devfeed.tech/tags/testing.md>), [with](<https://devfeed.tech/tags/with.md>)

## AI overview

Crustify uses LLM agents to generate safe Rust bindings for repository-level C libraries. It organizes types and symbols into dependency-ordered batches, derives pointer ownership and lifecycle contracts, and checks bindings with coverage-guided equivalence and undefined-behavior tests under sanitizers and Miri, followed by review. Its supporting tools are ffibox, which avoids creating references to C-aliasable memory; Wavefront, which detects dependencies including those hidden by casts and type-erased pointers; and ffimap, which maps binding unsafe code. With one developer in the loop, it produced bindings for 41.9% of libgit2's and 42.8% of ffmpeg's public APIs in about 51.9 and 58.9 hours. Test coverage of the Rust code was about 99% for both; reviewers fixed 8 and 13 defects causing UB reachable from Rust. The evaluation covers two libraries, and substantial portions of their public APIs remained unbound.

## Source excerpt

arXiv:2611.10394v1 Announce Type: cross Abstract: Wrapping C code in a safe Rust interface lets Rust applications use it without writing unsafe code, until the code itself is migrated to Rust. Such bindings are tedious and error-prone to write, however: their internals use unsafe code that the Rust compiler does not check, so a single mistake can introduce undefined behavior (UB), and they have so far been written mostly by hand. We present Crustify, an agentic co-translator that generates safe Rust bindings for repository-level C libraries. Crustify schedules a target's types and symbols into dependency-ordered waves of independent batches that agents bind concurrently. Its agents derive the ownership and lifecycle contract of every pointer and type they wrap, check each binding with coverage-guided equivalence and UB tests under sanitizers and Miri, and review every wave. They build on three tools that we contribute: (a) ffibox, Rust primitives for C/Rust interop that mirror Box, Arc, and Vec for C objects without ever forming a reference to memory that C may alias; (b) Wavefront, a neuro-symbolic static analyzer that orders a target's items by their dependencies, including those that casts and type-erased pointers hide; and (c) ffimap, a rustc-based analysis that maps the unsafe surface of bindings. On libgit2 and ffmpeg, with one developer in the loop, Crustify generated safe bindings for 41.9% and 42.8% of their public APIs in about 51.9 and 58.9 hours. On the interface consumers are expected to use, only 1.6% and 0.4% of the bindings' public functions are unsafe, and only 0.1% and 0.6% have a raw pointer in their signature. Their tests cover 98.92% and 99.07% of the Rust code and 45.95% and 67.20% of libgit2 and of ffmpeg's libavutil, and the reviewers fixed 8 and 13 defects that caused UB reachable from Rust. To our knowledge, this is the first work to automate the generation of safe Rust bindings for C libraries.