arXiv:2609.06383cs.SESep 2026

Manuscript Offprint

arXiv:2609.06383

From Reading Code to Reading Spec: A Verified Layer for LLM-Driven Codebase Maintenance

Xinhao Zhang, Jingjie Lu, Kunpeng Liu, Fei Xie

Abstract

The rapid growth of LLM-generated code increases software complexity and the maintenance burden on engineers. While LLMs offer a potential automated alternative, this structural complexity hinders their ability to manage codebases directly. We introduce the Provable Representation Of Original Functionality (PROOF), which manages codebases indirectly via structured specifications. To enable full-lifecycle codebase management strictly through these specifications, PROOF abstracts codebase topology into a hierarchical natural-language representation. To establish absolute trust, the system proves semantic equivalence by reconstructing source code exclusively from this specification. This verified foundation drives maintenance requests, executing code modifications while synchronously updating itself to prevent semantic drift. Experiments on real-world repositories confirm the effectiveness of these specifications.

1 Introduction

Software systems are experiencing continuous growth in scale and structural complexity, a trend accelerated by the proliferation of Large Language Models (LLMs) (Hatton et al., 2017; Ouyang et al., 2025). Consequently, code generation rates outpace the cognitive capacities of engineering teams. As Figure 1 illustrates, this widening disparity elevates the maintenance burden per engineer, resulting in mounting technical debt as machine-generated code is integrated without adequate human review or long-term maintenance.

A potential approach to mitigating this maintenance burden is to utilize LLMs not only as generators but also as automated maintainers (Liu et al., 2024b). However, applying LLMs to repository-level code management is impeded by two bot-

Figure

Figure 1: Trends in total code volume versus the software engineering workforce, and the corresponding average maintenance burden per engineer (20162026).

tlenecks: context window constraints, which preclude processing repositories simultaneously (Liu et al., 2024a), and global dependencies that span multiple files (Jimenez et al., 2024). Together, these limitations induce context degradation, leading to code hallucination and logical inconsistencies.

To bypass these direct-processing limitations, a viable strategy is to manage repositories indirectly through an intermediate representation (IR) (Lattner and Adve, 2004; Iyer et al., 2016), allowing models to reason over structural abstractions rather than raw, unbounded source code (Hejderup et al., 2018). To ensure reliability, this IR should satisfy three properties: (1) granularity adaptation, partitioning the repository into localized chunks that fit within context limits; (2) topology preservation, retaining the global dependency structures; and (3) verifiability, ensuring the representation is provably equivalent to the original code behavior rather than an unverified generative approximation.

To realize this paradigm, we apply the standard software specification (Spec) as a structured intermediate representation. At the micro-level, it encapsulates objects and functions as minimal closure units, utilizing modular natural language to

  • Corresponding author.

capture essential semantics. At the macro-level, these units are structurally linked via the repository's native call graph. This dual-level architecture adapts to LLM context limits while preserving global topology, establishing an explicit, human-readable abstraction layer that facilitates code comprehension and editing without requiring developers to navigate the underlying syntax directly.

Furthermore, the effectiveness of this representation depends entirely on its rigorous verifiability. To prove that a Spec objectively reflects the source code rather than LLM hallucinations, we introduce a strict round-trip equivalence verification framework. By extracting a Spec from the original code and reconstructing the code relying exclusively on this Spec without source reference, we can objectively validate that the representation captures all critical functionality without omission, rendering it trustworthy for downstream operations.

We decompose the realization of this representation into three lifecycle questions. Generation: how can this structured Spec be completely and systematically constructed for large-scale repositories? Verification: how can its precise consistency with the original codebase be objectively validated to prevent generative hallucinations? Update: how can a verified Spec drive code modifications, and how can bi-directional synchronization be maintained across sustained maintenance cycles to prevent semantic drift?

To systematically address these questions, we developed a closed-loop system, the Provable Representation Of Original Functionality (PROOF), which enables developers to manage code strictly by managing Spec.

Contributions. Our main contributions include:

  • A systematic methodology for Spec generation: a hierarchical natural-language representation mirroring the repository's structural organization, driven by an algorithm that enables LLMs to process the codebase comprehensively.

  • A rigorous validation framework for the generated Spec: evaluating internal quality and semantic consistency with the source code, establishing it as an objectively verifiable equivalent rather than an unverified generative assumption.

  • A methodology for Spec-driven codebase updates: PROOF modifies and validates code while synchronously updating the Spec, enabling developers to manage code exclusively through Spec without semantic drift.

References (14)