# Research notes: focused technical answers

Canonical HTML: https://aogavrilov.com/research-notes/
Document language: en

Evidence-bounded answers for problem-first retrieval. Each note separates a practical procedure, published evidence, and explicit limitations; the notes do not report new experiments.

## Code-space vs token-space masked diffusion: how to compare them

A stage-consistent comparison protocol for code-space and token-space masked diffusion language models when the discrete codec is lossy.

Question: How should code-space and token-space masked diffusion language modeling be compared?

Direct answer: Evaluate source text, codec reconstructions, token-space outputs, and decoded code-space outputs with the same external scorer and preprocessing. Report the codec reconstruction gap separately: code-space generation cannot recover information that the codec already removed.

Canonical note: https://aogavrilov.com/research-notes/code-space-vs-token-space-masked-diffusion/

## Localized code modification with generative models

How to prevent unnecessary whole-function rewriting while preserving enough freedom for a generative model to make the requested code change.

Question: How can a generative model modify code without rewriting the entire function?

Direct answer: Define protected and editable regions before generation, reuse or constrain the protected representation, generate only candidate changes, and reject outputs that alter protected code or fail task-specific checks. Locality and task success must be measured together.

Canonical note: https://aogavrilov.com/research-notes/localized-code-modification-generative-models/

## Constrained code generation for software engineering

A practical distinction between grammar constraints, type constraints, preservation boundaries, and behavior-level acceptance checks for generated code.

Question: What does constrained code generation guarantee in a software-engineering workflow?

Direct answer: Only the property explicitly enforced by the constraint. Grammar-constrained decoding can guarantee membership in a grammar; type-aware methods can target type validity; neither alone proves task correctness, semantic equivalence, behavior preservation, or edit locality.

Canonical note: https://aogavrilov.com/research-notes/constrained-code-generation-software-engineering/

## AI-assisted refactoring: methods and evidence

How to evaluate recent AI-assisted refactoring methods without confusing a plausible generated patch with verified behavior preservation.

Question: Which methods and evidence matter for AI-assisted behavior-preserving refactoring?

Direct answer: Separate transformation proposal from trusted execution and verification. Where possible, let the model identify a refactoring and apply it through a refactoring engine; then require compilation, tests, static checks, and evidence that the intended transformation occurred.

Canonical note: https://aogavrilov.com/research-notes/ai-assisted-refactoring-evidence/

## Predictable code generation needs a preservation contract

Why deterministic sampling is not enough, and how observable protected properties and acceptance checks make code-generation behavior testable.

Question: What makes code generation predictable rather than merely controllable?

Direct answer: Predictability requires an observable contract stated before generation: what may change, what must remain stable, how each property will be measured, and when an output will be rejected. A fixed prompt, seed, mask, grammar, or latent code is only a mechanism.

Canonical note: https://aogavrilov.com/research-notes/predictable-code-generation-preservation-contract/
