arXiv:2608.03588cs.PLcs.AI2026-08

为代码生成流程提供可组合的鲁棒性验证框架,确保等效提示生成相同结果。

GenOS: Compositional Certificates for Semantic Robustness in AI Code Generation

  • 用马尔可夫核建模每层流程,定义观察者相关的等价关系
  • 等效提示下,下游验证通过概率和代码类别分布完全一致
  • 适用于调试、验证和替换生成器或提示的场景,尤其适合高可靠性系统

AI代码生成代理是随机工作流:提示被解析,代码样本生成,验证器产生观测,协调器决定提交或修复。微小的提示或规范变化可能改变程序行为分布,即使文本语义相似。现有系统仅评估正确性,缺乏对提示、合约、生成器或程序在完整流程中安全替换的可组合判据。本文提出GenOS,一种针对此类替换问题的概率化操作语义。每一层建模为马尔可夫核,每接口携带观察者相对的等价关系。证明等价兼容核可下降至商类,且商化与分布扩展及顺序组合可交换。因此,等效提示诱导所有下游等价闭事件(包括验证通过提交)的概率相等。还建立了流程双模拟、有声验证下的受控提交安全性、总变差非扩张性,以及可加的鲁棒性界,将近似误差归因于各管道层。一个可执行的插入排序审计实例化理论,使用自然语言改写、形式合约、六个程序、两个观察器,在121个输入上全量执行。等效提示产生相同的代码类别和提交分布;分配5%概率给原地合约的提示被突变观察器识别,但下游距离仍在预测范围内。在20,000次随机有限核试验中,无精确或近似定律被违反。GenOS是模型参数化的:兼容性是可测量属性,而非对语言模型行为的假设。

原文摘要 · Abstract (English)

AI coding agents are stochastic workflows: prompts are interpreted, artifacts are sampled, validators produce observations, and orchestrators commit or repair. Small prompt or specification changes can therefore alter program-behavior distributions even when the texts appear synonymous. Existing systems evaluate correctness, but lack a compositional criterion for safely replacing a prompt, contract, generator, or program inside a complete agentic workflow. We introduce GenOS, a probabilistic operational semantics for this replacement problem. Each layer is modeled as a Markov kernel, and each interface carries an observer-relative equivalence. We prove that equivalence-compatible kernels descend to quotient classes and that quotienting commutes with distributional extension and sequential composition. Hence, equivalent prompts induce equal probabilities for all downstream equivalence-closed events, including verified commit. We also establish workflow bisimulation, guarded-commit safety under sound validation, total-variation non-expansiveness, and an additive robustness bound that attributes approximation error to individual pipeline layers. An executable insertion-sort audit instantiates the theory with natural-language paraphrases, a formal contract, six programs, two observers, and exhaustive execution on 121 inputs. Equivalent prompts yield identical code-class and commit distributions; a prompt assigning 5% probability to an in-place contract is distinguished by a mutation observer, while downstream distances remain within the predicted bound. Across 20,000 randomized finite-kernel trials, no exact or approximate law is violated. GenOS is model-parametric: compatibility is a measurable property to test, not an assumption about language-model behavior.

代码生成鲁棒性形式验证概率语义

Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。