Search papers, labs, and topics across Lattice.
This paper introduces a specification-based Code2Text2Code reengineering framework to address the limitations of direct Code2Code transformations in LLM-mediated software evolution. The framework transforms source code into a neutral textual specification capturing program behavior and intent, then generates target code from this specification, incorporating iterative verification and retrieval-augmented grounding. Experiments on a multilingual dataset demonstrate the approach's effectiveness in controlled, specification-based reengineering, as opposed to simple code transformation.
LLMs can evolve code more reliably by translating it into a neutral, behavior-rich specification first, rather than directly transforming code.
Direct Code2Code transformation remains challenging to control because it can preserve surface-level syntax while introducing semantic drift, hidden behavioral changes, loss of traceability, non-idiomatic target implementations, or incomplete reconstruction of domain logic. This paper proposes a specification-based Code2Text2Code reengineering framework for LLM-mediated software evolution. The central idea is to transform source code into a neutral textual specification that captures program behavior, identifiers, computational flow, conditions, side effects, data dependencies, and domain-specific intent without directly transferring the source language syntax. The proposed framework combines factual context extraction, Code2Text generation, iterative verification between source code and text specification, Text2Code generation, target code verification, retrieval-augmented grounding, and semantic-aware chunking, and transformation loss estimation. The knowledge representation layer integrates metadata derived from AST, graph-based dependency structures, neutral natural language specifications, technical documentation, business documentation, and architecture-level representations. The conducted experiments include a Code2Text2Code dataset built from multiple programming languages and SQL dialects, comparison of intermediate representations, retrieval evaluation, documentation transformation evaluation, and prompt tuning using DSPy. A graph formalization using structural preservation, reverse compatibility, interface stability, and total graph similarity is implemented to estimate transformation losses. The results support the interpretation of the Code2Text2Code approach not as a simple code transformation, but as a controlled specification-based reengineering process for LLM-mediated software evolution.