code-generation functional-correctness compiler-feedback generative-compilation rust llm-decoding partial-program-checking sealor
Abstract
Languages with rich static semantics, such as Rust, provide stronger guarantees for AI-generated code, but their strictness makes generation more difficult. Off-the-shelf compilers can provide useful feedback post-generation, but does not guide intermediate generation steps, such as those during autoregressive LLM decoding. Constrained decoding intervenes earlier by rejecting invalid tokens during sampling, but requires white-box model access and costly reimplementation for semantic constraints.We introduce generative compilation, the first approach to obtaining compiler feedback on partial programs during generation. The core technical device is a sealor: a lightweight, mostly syntax-guided transformation that converts partial programs into complete ones that standard compilers can diagnose. It is designed such that possible-to-complete partial programs are never rejected, while preserving enough code context to catch genuine dead ends early. We construct such a sealor on a core Rust-like calculus and prove that it satisfies these properties, all mechanized in Lean. We extend it to the first partial-program checker for real Rust. We evaluate our method on challenging repository-level Rust coding tasks, across both frontier black-box and open-weight models. We show that generative compilation reduces non-compiling outputs and improves functional correctness, relative to standard post-generation feedback. It does so by detecting a broad range of errors close to their source and early during generation, thereby reducing errors cascades and enabling focused diagnostics. More broadly, generative compilation is a step toward making compilers a first-class citizen of AI-assisted programming active during generation, rather than a separate post-generation check.
한국어 요약
한 줄 요약
Rust 언어에서 생성 중인 코드에 실시간 컴파일러 피드백을 제공하는 새로운 방법, Generative Compilation을 제안한다.
핵심 기여도
- **Sealor**라는 새로운 기법을 제안하여 부분 프로그램을 완전한 형태로 변환하여 컴파일러 피드백을 얻는다.
- Rust 언어 기반의 **Core Rust-like calculus**에서 Sealor의 정당성을 **Lean**을 통해 증명한다.
- 실제 Rust 코드에 적용한 **첫 번째 부분 프로그램 체커**를 구현한다.
- **Black-box 및 Open-weight 모델**에서 평가하여 생성 코드의 **실행 가능성과 기능적 정확도를 향상**시킨다.
핵심 아이디어
기존의 컴파일러 피드백은 생성 후에만 제공되며, 생성 중에 발생하는 오류를 사전에 막지 못한다. Generative Compilation은 생성 중인 부분 프로그램에 대해 실시간으로 컴파일러 피드백을 제공함으로써, 오류를 조기에 탐지하고 오류 확산을 줄인다. Sealor는 문법 중심의 가벼운 변환으로, 부분 프로그램을 완전한 형태로 변환하여 표준 컴파일러가 진단할 수 있도록 한다. 이는 부분 프로그램이 완성 가능한 경우 거부하지 않으면서도, 진짜로 해결 불가능한 경로를 조기에 포착할 수 있도록 설계되었다.
기술적 접근법
- **Sealor**: 부분 프로그램을 완전한 형태로 변환하는 가벼운 문법 기반 변환.
- **Core Rust-like calculus**에서 Sealor의 정당성 증명.
- **Lean**을 사용한 증명 자동화.
- **Rust** 언어에 대한 부분 프로그램 체커 구현.
- **Black-box 및 Open-weight 모델**을 대상으로 평가.
주요 결과
- **Repository-level Rust 코딩 작업**에서 **비컴파일 가능한 출력을 감소**시킴.
- **기능적 정확도**가 향상됨.
- 오류를 **생성 과정 초기에 탐지**하여 오류 확산을 줄임.
- **Sealor 기반 피드백**이 기존의 생성 후 피드백 대비 **더 빠르고 정확한 진단**을 제공함.
의의 및 한계
Generative Compilation은 컴파일러를 생성 과정에 통합함으로써, AI 생성 코드의 신뢰성을 향상시키는 중요한 발전이다. 특히 Rust와 같은 정적 의미가 풍부한 언어에서 유용하며, 실시간 진단을 가능하게 한다. 그러나 Sealor는 문법 중심이므로, 의미적 오류를 완전히 포착하지 못할 수 있다. 또한, 다른 언어로의 확장성은 명시되지 않음.
실용적 활용
Rust 기반의 소프트웨어 개발, AI 생성 코드의 실시간 검증, 코드 생성 모델의 훈련 과정에서 오류 조기 탐지에 활용 가능하다.