What is it about?
AI systems that generate code can change more of a program than a developer intended. We explore a way to give such systems more precise and inspectable control. Instead of controlling individual words or code tokens, our method represents a Python function using two layers of discrete codes. The upper layer captures coarse program structure, while the lower layer represents implementation details. Selected structural codes can be locked, and the model regenerates only the remaining editable parts. We tested this approach on short Python functions and measured whether the regenerated code remained syntactically valid, preserved its structure, and still changed in the regions where editing was allowed.
Featured Image
Photo by Christopher Gower on Unsplash
Why is it important?
Software repair and refactoring are usually constrained tasks: developers want to change a specific part of a program while preserving its broader structure. Conventional token-level generation provides limited control over what remains fixed and where changes propagate. In our experiments, locking a small number of coarse latent codes increased the proportion of syntactically valid outputs from 45.3% to 59.1%. At the same time, 93.6% of editable positions still changed, and the generated variants remained highly diverse. These results suggest a path toward more predictable and inspectable AI-assisted software modification. The current study focuses on structural control; functional correctness and practical repair or refactoring performance remain subjects for future work.
Perspectives
I was interested in a practical question: can an AI system expose clear control points between “keep this” and “change that”? For me, the most important result is not only the increase in syntactically valid code, but the visible trade-off between structural stability and freedom to edit. By choosing how many coarse latent positions to lock, we can gradually move from free regeneration toward almost exact reconstruction. I see this work as an early step toward code-generation tools that let developers inspect and control the scope of a change instead of simply accepting or rejecting a complete rewrite.
Alexey Gavrilov
ITMO University
Read the Original
This page is a summary of: Inspectable Control for Structure-Preserving Software Regeneration, July 2026, ACM (Association for Computing Machinery),
DOI: 10.1145/3803437.3807386.
You can read the full text:
Contributors
The following have contributed to this page







