cs.SEJul 14, 2025

SpecProbe: Probing Intent-Implementation Misalignments with Generated Executable Postconditions

Authors: Gehao Zhang, Zhenting Wang, Juan Zhai

Organizations: University of Massachusetts Amherst, USA · Rutgers University New Jersey, USA

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 ∼\sim1.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.

Figures & tables

Explore similar work

CardsList
  1. Fidelity Probes for Specification--Code Alignment

    May 17, 2026Ferhat Erata, Hao Zhou, Luke HuanRequirements Engineering

  2. CodeSpecBench: Benchmarking LLMs for Executable Behavioral Specification Generation

    Apr 14, 2026Zaoyu Chen, Jianbo Dai, Boyu Zhu +6LLM EvaluationSoftware Engineering Benchmarks

  3. SpecPylot: Python Specification Generation using Large Language Models

    Apr 17, 2026Ragib Shahariar Ayon, Shibbir AhmedCounterexample-Guided RefinementFormal Verification