SpecProbe:用生成的可执行后置条件探测代码意图与实现的不一致
SpecProbe: Probing Intent-Implementation Misalignments with Generated Executable Postconditions
AI 导读
研究者提出 SpecProbe,一种从自然语言文档生成可执行后置条件(behavioral probes)的代码库感知流水线,用于检测文档意图与实现行为的错位。
正文 · 原文
Abstract:Ensuring that code faithfully reflects its documented intent is a fundamental challenge in software engineering, but the informal natural language specifications in real repositories cannot be automatically compiled into executable checks and run against implementations. We introduce behavioral probes: executable postconditions generated from natural language documentation, injected into programs, and checked during test execution to reveal where documented intent and implementation behavior align or diverge. We present SpecProbe, a repository-aware pipeline that generates behavioral probes and classifies each as non-executable, matched, or mismatched. A structured four-field schema (import, pre-ghost, post-ghost, condition) makes generated postconditions injectable and compilable in real repositories; reasoning supervised fine-tuning on $\sim$1.5K automatically curated examples enables a compact 7B model to generate probes without continued API access. On Defects4J, SpecProbe's 7B model achieves GPT-4o-comparable semantic consistency (Sem@1) at 141$\times$ lower inference cost. The pipeline reveals 80 of 726 historical bugs, and for 95% of them the original failing-test stack trace omits the method checked by the probe. On Python icontract generation, SpecProbe surpasses GPT-5-mini and GPT-o3, demonstrating transfer to a different language and contract format. These results show that behavioral probes complement failing-test stack traces with diagnostic evidence grounded in the selected method's documented intent.
| Subjects: | Software Engineering (cs.SE); Artificial Intelligence (cs.AI) |
| Cite as: | arXiv:2507.10182 [cs.SE] |
| (or arXiv:2507.10182v2 [cs.SE] for this version) | |
| https://doi.org/10.48550/arXiv.2507.10182 arXiv-issued DOI via DataCite |
Submission history
From: Gehao Zhang [view email]
[v1]
Mon, 14 Jul 2025 11:44:04 UTC (1,074 KB)
[v2]
Thu, 26 Nov 2026 21:58:58 UTC (577 KB)
来源:arXiv cs.AI · arxiv.org