# Inspectable Control for Structure-Preserving Software Regeneration

> Controllable partial code regeneration using hierarchical discrete latent representations.

Canonical HTML: https://aogavrilov.com/publications/inspectable-control/
DOI: https://doi.org/10.1145/3803437.3807386
PDF: https://aogavrilov.com/publications/inspectable-control/paper.pdf
Full-text HTML: https://aogavrilov.com/publications/inspectable-control/full-text/
Full-text Markdown: https://aogavrilov.com/publications/inspectable-control/full-text/index.md
Full-text section and source-block index: https://aogavrilov.com/publications/inspectable-control/full-text/sections.json
W3C Web Annotation block collection: https://aogavrilov.com/publications/inspectable-control/full-text/annotations.jsonld
Full-text NISO JATS 1.4 XML: https://aogavrilov.com/publications/inspectable-control/full-text/article.jats.xml
Thematic research guide: https://aogavrilov.com/research/discrete-latent-generation/

This is a plain Markdown reader representation of the canonical HTML publication guide.
Use the DOI and original English metadata below for citation.

## Bibliographic record

- Authors: Alexey Gavrilov; Alan-Barsag Gazzaev; Mikhail Mozikov; Ilya Makarov; Sergey Muravyov
- Published: 2026-07-05
- Venue: Proceedings of the 34th ACM International Conference on the Foundations of Software Engineering
- Publication format: Companion poster
- Pages: 1406-1407
- Publisher: ACM
- Controlled subject: ACM CCS 2012 — Automatic programming [10011007.10011074.10011092.10011782]
- Controlled subject: ACM CCS 2012 — Software maintenance tools [10011007.10011006.10011073]

## Paper in 30 seconds

### Problem

AI-assisted code modification often needs one bounded change while selected program structure remains fixed. Regenerating the entire program can disturb unrelated regions, and token-level constraints do not expose a coarse control surface.

### Approach

The study encodes 64-token Python functions with a hierarchical VQ-VAE, locks selected coarse discrete codes, and uses masked discrete generation for localized code regeneration in the remaining latent positions.

### Main result

Locking four top-level codes raises parse rate from 0.453 to 0.591 while unlocked positions still change at rate 0.936 and conditional samples remain 0.998 unique.

### Why it matters

The results show a measurable stability–freedom trade-off for controllable code editing and partial program regeneration. They provide early evidence for an inspectable latent control layer, not proof of semantic equivalence or functional correctness.

## Abstract

Software-engineering workflows such as constrained repair, staged refinement, and structure-preserving modification require control over what changes and what remains fixed. Token-level generation is a weak control surface for these operations because it constrains local surface text rather than the coarse structural invariants that software engineering often aims to preserve. We study hierarchical discrete latents as an inspectable intermediate representation for software artifacts: a hierarchical VQ-VAE compresses a 64-token Python function into coarse and fine discrete codes, and masked discrete generation regenerates only selected positions under partial constraints. On 2,000 preprocessed Python functions, locking four top-level codes improves parse rate from 0.453 to 0.591 while preserving substantial change in unlocked positions (edit freedom, 0.936) and near-maximal sample uniqueness (diversity, 0.998). Under fixed coarse context, lower-level refinement is weaker but remains monotonic, supporting a coarse-to-fine reading of the hierarchy. Overall, these results provide early evidence for a practical control layer that supports bounded, structure-preserving software-artifact regeneration above the token level.

## Key results

| Setting | Parse rate | Skeleton | Signature | Unlocked change |
| --- | --- | --- | --- | --- |
| Input (truncated) | 0.994 | 0.994 | 0.994 | — |
| Codec reconstruction | 0.857 | 0.848 | 0.493 | 0 |
| Unconditional generation | 0.453 | 0.08 | 0 | 0.995 |
| Conditional, prefix k=4 | 0.591 | 0.295 | 0.061 | 0.936 |
| Conditional, signature span | 0.6 | 0.302 | 0.063 | not reported |

Coarse latent locking improves syntactic stability without collapsing change in the editable region; the result demonstrates structural control, not guaranteed functional equivalence.

- Dataset: 2,000 preprocessed Python functions from a CodeParrot Clean subset
- Sample size: 2,000 preprocessed Python functions; conditional sample uniqueness is 0.998.
- Conditions: 64-token functions, argmax decoding, 16 top-level codes and 32 lower-level codes; full locking exactly recovers the codec reconstruction.
- Uncertainty: The two-page study reports point estimates without confidence intervals or multi-seed statistical analysis.
- External result-summary mirror: https://huggingface.co/datasets/aogavrilov/inspectable-control-results
- External result-summary collection: https://huggingface.co/collections/aogavrilov/publication-result-summaries-6a6b733b3116a87befb37ec2

## Questions this paper helps answer

### How can AI edit code without rewriting everything?

The paper studies partial code regeneration above the token level. A hierarchical VQ-VAE maps a short Python function to coarse and fine discrete codes; selected coarse positions are locked, and masked discrete generation changes only the remaining latent positions before decoding. This provides an explicit preservation boundary instead of regenerating the whole function.

### What methods preserve program structure during code generation?

This work tests hierarchical discrete latent control. Coarse latent positions can be fixed while unlocked positions are regenerated, after which parse rate and structural proxies are measured. The evidence concerns probabilistic structural stability on short Python functions; it does not establish exact AST preservation, semantic equivalence, or functional correctness.

### Can hierarchical discrete latents provide localized control over code?

In the reported 2,000-function experiment, locking four top-level codes increased parse rate from 0.453 to 0.591. At the same time, 0.936 of unlocked positions changed and conditional samples were 0.998 unique. These results are early evidence that coarse latent constraints can preserve some structure without eliminating local edit freedom or sample diversity.

### How can code generation balance structural stability and diversity?

The paper evaluates stability and freedom together rather than optimizing only validity. Coarse-code locking raises syntactic validity while unlocked-position change remains high and conditional samples remain almost entirely unique. The result demonstrates a measurable stability-freedom trade-off under the tested configuration, not a universal optimum.

### How does this work relate to LLM-assisted code editing?

The tested model is a hierarchical VQ-VAE with masked discrete generation, not a large language model. The control problem is nevertheless relevant to LLM-assisted editing because unnecessary changes outside a requested region are a practical concern. The paper contributes a complementary latent-space mechanism and evaluation framing, not an LLM editing benchmark.

## Limitations

- The study is limited to short Python functions truncated to 64 tokens.
- Evaluation uses argmax decoding and syntactic or structural proxies rather than tests of functional equivalence.
- Exact signature preservation remains weak.
- Lower-level control is weaker than top-level control.
- Latent positions are not yet aligned to semantic regions such as AST spans, signatures, or control-flow structure.
- The results do not establish correctness for practical repair, refactoring, or repository-level changes.

## Availability

- Public implementation: no implementation is linked in the maintained publication record.
- Public data: no underlying experimental dataset is linked in the maintained publication record.

## References cited by the paper

These entries correspond to the numbered References section in the paper PDF.

- [1] Ali Razavi, Aaron van den Oord, Oriol Vinyals. 2019.
  "Generating Diverse High-Fidelity Images with VQ-VAE-2." Advances in Neural Information Processing Systems.
  https://arxiv.org/abs/1906.00446
  arXiv: https://arxiv.org/abs/1906.00446
- [2] Jacob Austin, Daniel D. Johnson, Jonathan Ho, Daniel Tarlow, Rianne van den Berg. 2021.
  "Structured Denoising Diffusion Models in Discrete State-Spaces." Advances in Neural Information Processing Systems.
  https://arxiv.org/abs/2107.03006
  arXiv: https://arxiv.org/abs/2107.03006
- [3] Subham Sekhar Sahoo, Marianne Arriola, Yair Schiff, Aaron Gokaslan, Edgar Marroquin, Justin T Chiu, Alexander Rush, Volodymyr Kuleshov. 2024.
  "Simple and Effective Masked Diffusion Language Models." Advances in Neural Information Processing Systems.
  https://arxiv.org/abs/2406.07524
  arXiv: https://arxiv.org/abs/2406.07524
- [4] Shraddha Barke, Michael B. James, Nadia Polikarpova. 2023.
  "Grounded Copilot: How Programmers Interact with Code-Generating Models." Proceedings of the ACM on Programming Languages.
  https://doi.org/10.1145/3586030
  DOI: https://doi.org/10.1145/3586030
  arXiv: https://arxiv.org/abs/2206.15000
- [5] Fengji Zhang, Bei Chen, Yue Zhang, Jacky Keung, Jin Liu, Daoguang Zan, Yi Mao, Jian-Guang Lou, Weizhu Chen. 2023.
  "RepoCoder: Repository-Level Code Completion Through Iterative Retrieval and Generation." Proceedings of the 2023 Conference on Empirical Methods in Natural Language Processing.
  https://doi.org/10.18653/v1/2023.emnlp-main.151
  DOI: https://doi.org/10.18653/v1/2023.emnlp-main.151
  arXiv: https://arxiv.org/abs/2303.12570

## Citation and machine-readable resources

- Canonical HTML: https://aogavrilov.com/publications/inspectable-control/
- DOI record: https://doi.org/10.1145/3803437.3807386
- PDF: https://aogavrilov.com/publications/inspectable-control/paper.pdf
- Full-text HTML: https://aogavrilov.com/publications/inspectable-control/full-text/
- Full-text Markdown: https://aogavrilov.com/publications/inspectable-control/full-text/index.md
- W3C Web Annotation block collection: https://aogavrilov.com/publications/inspectable-control/full-text/annotations.jsonld
- Full-text NISO JATS 1.4 XML: https://aogavrilov.com/publications/inspectable-control/full-text/article.jats.xml
- BibTeX: https://aogavrilov.com/publications/inspectable-control/citation.bib
- APA formatted citation: https://aogavrilov.com/publications/inspectable-control/citation-apa.txt
- IEEE formatted citation: https://aogavrilov.com/publications/inspectable-control/citation-ieee.txt
- RIS: https://aogavrilov.com/publications/inspectable-control/citation.ris
- CSL-JSON: https://aogavrilov.com/publications/inspectable-control/citation.json
- OAI Dublin Core XML: https://aogavrilov.com/publications/inspectable-control/oai-dc.xml
- MODS XML: https://aogavrilov.com/publications/inspectable-control/mods.xml
- NISO JATS 1.4 XML metadata: https://aogavrilov.com/publications/inspectable-control/metadata.jats.xml
- RDF Turtle: https://aogavrilov.com/publications/inspectable-control/metadata.ttl
- RO-Crate: https://aogavrilov.com/publications/inspectable-control/ro-crate-metadata.json
