TL;DR
As AI code generation explodes, the sheer volume of code is outpacing engineers' ability to maintain it. This paper introduces PROOF (Provable Representation Of Original Functionality), a system that translates complex codebases into structured, natural-language specifications mapped to a global call graph. By verifying these specifications through a "zero-edit" round-trip code reconstruction process, PROOF allows LLMs to safely maintain and update codebases indirectly through the specification layer, bypassing context window limits and eliminating semantic drift.
What Problem Does This Paper Address?
The proliferation of Large Language Models (LLMs) has made writing code easier than ever, but it has triggered a massive spike in software complexity and maintenance debt. As shown in Figure 1, the growth of code volume is vastly outstripping the growth of the engineering workforce, dramatically increasing the maintenance burden per engineer.
While it is tempting to use LLMs to maintain these massive codebases, direct repository-level code management hits two major bottlenecks:
- Context Window Constraints: Repositories are often too large to fit into an LLM's prompt context simultaneously.
- Global Dependencies: Code changes in one file frequently break dependencies across multiple other files, leading to hallucinations and logical inconsistencies.
Existing intermediate representations (IRs) or documentation tools often lack structural constraints or rigorous verification, meaning there is no guarantee that the AI's abstract understanding actually matches what the code executes.
Methods
PROOF addresses these challenges by introducing a verified, structured intermediate specification layer (Spec). The framework operates in three distinct phases: Generation, Verification, and Update.
1. Specification Generation
Instead of analyzing the entire codebase at once, PROOF breaks it down top-down into a five-level hierarchy: Project, Module, Object, Function, and Segment. Crucially, it models functions and objects as strict semantic closures using a standardized six-field template:
- Description: The core execution intent.
- I/O Definition: Parameter types and return value constraints.
- Meta: Language, purity (side effects), and atomicity.
- Deps: External calls and dependencies.
- Data: Read/write states of global or mutable variables.
- Error: Exception boundaries.
A deterministic parsing algorithm links these individual nodes together into a global Spec graph that is topologically isomorphic to the repository's native call graph.
2. Equivalence Verification
To ensure the natural-language Spec accurately captures the code's actual behavior, PROOF performs a zero-edit round-trip verification. It forces the LLM to reconstruct the entire codebase exclusively from the Spec, without access to the original source code. The reconstructed code is then run against the repository's original test suite. PROOF measures Fidelity—the fraction of originally passing tests that the reconstructed code still passes—and iteratively repairs the Spec until it achieves a perfect match.
3. Codebase Update
When a new feature or bug fix is requested, the LLM localizes the change to specific nodes in the Spec graph. The developer reviews and approves the natural-language changes in the Spec layer. Once approved, the LLM automatically propagates these changes back down to the source code. To combat long-term divergence, PROOF includes a drift calibration mechanism ($\Delta_i$) to measure and correct semantic drift over time.
Datasets
The authors evaluated PROOF on three real-world Python repositories from the popular SWE-bench benchmark:
- Flask (24 files, 491 tests)
- Seaborn (54 files, 2,381 tests)
- Pytest (81 files, 4,224 tests)
These repositories represent varying scales and degrees of structural coupling, with Pytest being the largest and most tightly coupled.
Key Insights and Ideas
- Macroscopic Complexity vs. Microscopic Simplicity: While a global repository call graph looks like a dense, tangled hairball (as seen in Flask, Figure 3), individual nodes have highly localized dependencies. Exploiting this localization allows LLMs to reason effectively within tight context limits.
- Verification via Reconstruction: You cannot easily compare natural language to source code directly. By turning verification into a code reconstruction and testing problem ($Code \rightarrow Spec \rightarrow Code$), PROOF creates an objective, automated way to validate natural language abstractions.
- Shifting the Human Review Layer: Instead of reviewing thousands of lines of low-level syntactic diffs, engineers using PROOF only need to review and approve structured natural-language specifications.
Key Results
PROOF was compared against three state-of-the-art baselines: RepoAgent, RPG-Encoder, and EPAM.
- Behavioral Equivalence: PROOF achieved a 100% test pass rate (Pass@3) after three repair rounds on both Flask and Seaborn, and 96.80% on the highly complex Pytest repository, significantly outperforming all baselines (Figure 4).
- Structural Preservation: PROOF achieved the highest Abstract Syntax Tree (AST) similarity to the original codebase across all datasets, peaking at 96.12% similarity on Pytest, proving that the Spec accurately preserves architectural intent.
- Interpretability: In human and LLM-as-a-judge evaluations, PROOF scored significantly higher in Completeness and Consistency due to its rigid six-field closure template.
- Robustness: Even when powered by a weaker model (GPT-5.5 Medium), PROOF's structured framework allowed it to outperform baselines that were using more advanced models like Claude 3.5 Sonnet.
Limitations and Future Work
- Test Suite Dependency: PROOF relies heavily on having a high-quality, pre-existing test suite to verify behavioral equivalence. For codebases with poor test coverage, it would need to be paired with automated LLM test-generation tools.
- Language and Domain Specifics: The system's effectiveness depends on the underlying LLM's understanding of the target programming language. Low-resource or proprietary domain-specific languages (DSLs) would likely require fine-tuning or RAG extensions.
- Static vs. Distributed Architectures: Currently, PROOF maps static call graphs within individual repositories. Extending this approach to distributed architectures (e.g., microservices interacting via RPCs or message queues) remains an open research challenge.
Summary updated