Documentation-Guided Agentic Codebase Migration from C to Rust

Minh Le-Anh, Anh Nguyen Hoang, Bach Le, Nghi D. Q. Bui · 2026

Read Documentation-Guided Agentic Codebase Migration from C to Rust by Minh Le-Anh, Anh Nguyen Hoang, Bach Le, Nghi D. Q. Bui (2026) in the Tower of Babel, a free online library of public-domain works preserved in clean, searchable text. No sign-up. The full text is served as a plain-text file at a predictable URL, where text is present: https://antarctic-labs.com/tower-of-babel/arxiv-2605-14634.txt.

Introduction

Le-Anh, Nguyen Hoang, Le and Bui present RustPrint, a documentation-guided agentic framework that migrates whole C repositories to Rust. It first turns the source repo into architecture-aware documentation capturing modules, data flow, APIs and design rationale, then coding agents plan crates, implement modules, check compilability and cut unsafe code. Output documentation is compared with source documentation as a repair signal, and translated tests are run. All eight tested repos are claimed to compile.

Catalog record

CREATORMinh Le-Anh, Anh Nguyen Hoang, Bach Le, Nghi D. Q. Bui
YEAR2026
COLLECTIONPAPERS
FORMATTXT
FILE SIZE99760
LICENSEhttp://creativecommons.org/licenses/by/4.0/
RIGHTSCC BY
SOURCEarXiv

Source: https://arxiv.org/abs/2605.14634

Browse the full library · About the Tower of Babel

Full text

The opening of the work, from the library's hosted text:

Documentation-Guided Agentic Codebase Migration from C to Rust Minh Le-Anh, Anh Nguyen Hoang, Bach Le, Nghi D. Q. Bui Abstract Migrating legacy C repositories to Rust promises stronger memory safety, but existing translators often work at the level of files or functions and miss architectural intent. We present RustPrint, a documentation-guided agentic framework for repository-level C-to-Rust migration. RustPrint first converts the source repository into architecture-aware documentation and treats it as a migration blueprint capturing module structure, data flow, APIs, and design rationale. Coding agents then use this blueprint to plan crates, implement modules, check compilability, reduce unsafe code, and iteratively refine the translated repository. RustPrint next compares documentation from the Rust output against the source documentation and uses mismatches as repair signals. It also translates and runs source test suites so runtime failures can guide targeted fixes. Experiments on eight real-world C repositories ranging from 11K to 84K LoC show that RustPrint compiles every target under both an open-weight (Kimi-K2-Instruct) and a closed-weight (GPT-5.4) backbone, while prior LLM-based translators (Self-Repair, EvoC2Rust) fail repository-wide. With the open-weight Kimi-K2-Instruct backbone, RustPrint exceeds an agentic Claude Code baseline on feature preservation ( 93.26% vs. 52.52% ) and on cross-evaluation test pass rate ( 95.17% vs. 79.85% ). These results suggest that documentation-guided coordination is a useful direction for scalable codebase migration. 1 Introduction The C programming language remains the foundation of systems software, including kernels, embedded firmware, networking stacks, and safety-critical infrastructure Peta 2022 . This legacy carries a persistent cost: memory safety vulnerabilities rooted in C’s pointer model continue to drive critical exploits Szekeres et al. 2013 ; van Oorschot 2023 ; Seidel and Beier 2024 . Rust offers memory safety and data-race freedom without giving up low-level control Jung et al. 2021 ; Panter and Eisty 2024 , and has gained adoption in systems settings such as Linux, Android, and embedded software Seidel and Beier 2024 ; Li et al. 2024a ; Mayrhofer et al. 2021 . The central obstacle is scale. Rewriting mature C repositories by hand is expensive, and controlled studies show that even experienced developers find C-to-Rust migration cognitively demanding Li et al. 2024b . Recent progress in LLMs for coding has made repository-scale software engineering more plausible. Multi-agent coding systems can now plan, edit, test, and iteratively repair code across long-horizon tasks Hong et al. 2024 ; Qian et al. 2024 ; Nguyen et al. 2024 ; Islam et al. 2024 . This trend suggests that C-to-Rust migration should be treated not as isolated translation, but as a coding-agent task over an existing repository. However, current migration systems still operate mostly at the level of functions or files, or coordinate translation through dependency graphs, build order, and generated skeletons. These strategies help with compilation, but they do not explicitly transfer the architecture, intent, and behavioral contracts that shape the repository as a whole. Real-world migration is fundamentally a codebase-understanding problem. A repository contains shared data structures, module boundaries, naming conventions, build assumptions, cross-file invariants, and design rationale that cannot be recovered from isolated functions alone. Human developers first build a mental model of the system before rewriting it in another language. This observation motivates a different migration interface: use documentation as a whole-codebase intermediate representation that captures the source repository before agents generate and revise the target implementation. In this paper, we present RustPrint , a framework for repository-level C-to-Rust migration that introduces a documentation-driven paradigm for idiomatic code translation. Rather than translating code unit by unit along dependency edges, RustPrint first generates comprehensive, structured documentation of the source C codebase through a dedicated DocGen module inspired by the hierarchical codebase-documentation ideas of CodeWiki Hoang et al. 2025 . We adapt this stage for migration by first clustering the repository at the file level, then lifting these groups into higher-level component abstractions, and finally customizing prompts so the generated documentation emphasizes abstract feature that are valuable for Rust generation, rather than merely describing the original C implementation. The resulting documentation acts as a repository-level migration blueprint, capturing module interactions, system organization, data-flow conventions, and architectural rationale, thereby guiding the generation of idiomatic Rust that preserves the structure and design philosophy of the original system instead of its syntactic surface. To ensure semantic completeness, we introduce a documentation-guided iterative refinement mechanism that compares the documentation of the generated Rust codebase against that of the original C codebase, systematically identifying gaps in coverage and structural alignment. Finally, we incorporate execution-aware code revision through test-driven feedback, where dynamic test execution surfaces behavioral inconsistencies that static analysis and documentation comparison alone cannot detect. Our contributions are as follows: • We propose a documentation-driven migration paradigm that leverages automatically generated codebase documentation as an intermediate representation for repository-level C-to-Rust translation. By encoding whole-codebase understanding into structured documentation before translation, this approach enables the generation of idiomatic Rust that preserves architectural intent rather than merely replicating syntactic structure. • We introduce a documentation-guided iterative refinement mechanism that assesses and improves the generated Rust code by comparing its documentation against that of the original C codebase, promoting semantic completeness and structural alignment across the entire repository. • We incorporate execution-aware code revision with test-driven feedback, enabling the system to iteratively correct behavioral inconsistencies through dynamic test execution and achieve functional correctness beyond what static translation can guarantee. • We evaluate RustPrint on eight large-scale, real-world C repositories ranging from 11K to 84K LoC, addressing a key limitation of prior work that has primarily focused on small benchmarks and isolated functions. RustPrint compiles every target under both Kimi-K2-Instruct and GPT-5.4, while baseline LLM translators (Self-Repair, EvoC2Rust) fail to compile any repository at this scale. With the open-weight Kimi-K2-Instruct, RustPrint exceeds an agentic Claude Code baseline on feature preservation ( 93.26% vs. 52.52% ) and on cross-evaluation test pass rate ( 95.17% vs. 79.85% ); with GPT-5.4 these figures rise to 97.76% and 98.70% , alongside 99.41% API-level and 98.47% file-level safe rates. 2 Related Work 2.1 Rule-Based C-to-Rust Migration Early C-to-Rust systems relied on transpilation and static analysis. C2Rust directly translates syntax but largely preserves C structure and heavy unsafe usage Emre et al. 2021 ; Ling et al. 2022a . Laertes reduces some of this unsafety through borrow-checker-guided pointer rewriting, though only a limited fraction of pointers can be converted and a few failures can keep large alias classes unsafe Emre et al. 2021 ; Emre et al. 2023 . Other tools target specific idiom gaps such as pthread locks, FILE* I/O, output parameters, and unions Hong and Ryu 2023 ; Hong and Ryu 2025 ; Hong and Ryu 2024a ; Hong and Ryu 2024b . Scylla achieves safe Rust for a restricted C subset Fromherz and Protzenko 2024 . These methods provide useful static foundations, but they do not recover repository-level intent or produce consistently idiomatic Rust. 2.2 LLM-Based Code Translation Large language models enable more flexible translation and repair. Some methods rely on intermediate specifications or summaries, including SpecTra and related work on natural-language or formal specification guidance Nitin and Ray 2024 ; Tai et al. 2025 ; Saha et al. 2024 . Others use additional validation signals: VERT uses WebAssembly for candidate checking Yang et al. 2024 , Syzygy translates tests

Read the complete text