arXiv(opens in a new tab)cs.CLOct 2026Cited by 2 papers on PaperVantage

Manuscript Offprint

arXiv:2610.16870

SpecGuardBench: Can Coding Agents Construct Reliable Validation Harnesses from Natural Language Specifications?

Zhiqing Zhong, Mingyu Chen, Aoyang Fang, Yuzhong Zhang, Haoye Tian, Lionel Briand, Boxi Yu, Pinjia He

Open access. PaperVantage converted this article to text, so layout and figures may differ from the original.

ABSTRACT

As coding agents become more capable, tests remain the primary evidence for judging whether their code is correct. Yet passing available tests does not establish that an implementation satisfies its natural language specification. Reliable validation requires checks that faithfully capture the specification and scenarios that thoroughly exercise the code, but current benchmarks provide limited insight into whether agents can construct such evidence themselves. We introduce SPECGUARDBENCH, a benchmark of 291 tasks from 13 real-world repositories, covering 8 types of verification logic such as functional postconditions and interaction protocols. Given a natural language specification, repository context, and a reference implementation, an agent constructs a validation harness comprising executable checks and test scenarios. The checks should reject implementations that violate the specification while accepting those that satisfy it, and the scenarios should thoroughly exercise the code. Across four proprietary and open-weight coding agents, none constructs a harness scored as faithful on the benchmark's implementations for more than 63% of the tasks. The bottleneck lies less in exploring test scenarios than in constructing checks that faithfully reflect the specification. Specifically, the agents show a clear tendency to write checks that mirror the reference implementation rather than the specification, and therefore reject implementations that the specification permits.

1 INTRODUCTION

As coding agents take on increasingly complex changes and long-horizon tasks across software repositories, natural language specifications from humans or agents guide what they should accomplish and provide a basis for judging their outputs. Reliable validation of whether the code aligns with specifications is therefore essential and challenging for benchmark evaluation, interactive coding workflows, and reinforcement learning with verifiable rewards (RLVR). Across these scenarios, finite executable test suites remain a primary mechanism for validation and supervision (Jimenez et al., 2024; Ma et al., 2025b). Yet passing a test suite does not establish conformance to the underlying specifications: an incorrect implementation may satisfy the tested examples while violating specifications in untested situations (Liu et al., 2023; Ahmed et al., 2026). Moreover, scaling test suites is challenging, as test inputs are typically coupled with expected outcomes. A finite test suite is thus bound to be incomplete, making it an unreliable validation paradigm.

Reliable validation requires checks that faithfully capture the stated specifications and the exploration of test scenarios that thoroughly exercise the relevant code (Barr et al., 2015). Faithful

∗^{*}Pinjia He is the corresponding author.

Figure

Figure 1: Overview of SPECGUARDBENCH task. Given a natural language specification, the repository, and a reference implementation, an agent constructs a validation harness of test scenarios and executable checks; the harness is judged on whether it accepts implementations that satisfy the specification, rejects those that violate it, and how thoroughly the scenarios exercise the relevant code.

checks should identify specification violations without rejecting behavior that the specifications permit, while thorough exploration of test scenarios should apply these checks to executions spanning a broad range of paths and program states. Although exhaustive testing is generally infeasible, exploration budget can be scaled to application-specific reliability requirements, with additional compute helping reduce the risk of undetected faults (Böhme & Falk, 2020). Expressing specifications as reusable executable checks decoupled from test scenarios lets the same checks assess newly generated test scenarios and real-world executions, supporting continued validation beyond the initial test suite and after deployment.

Existing benchmarks increasingly assess models' ability to construct evidence for code validation, but only partially address whether the resulting evidence supports scalable, faithful validation against natural language specifications. Previous test-generation evaluations typically ask whether LLMs can generate tests that improve fault detection (Jain et al., 2025; Jing et al., 2026), reproduce bugs (Mündler et al., 2024; Ahmed et al., 2024), or exercise more program structure (Wang et al., 2025). However, these evaluations overlook the risk that generated tests overfit the reference implementation rather than faithfully capture the stated specifications. Verification-oriented benchmarks (Ye et al., 2025; Thakur et al., 2026) move beyond this paradigm by asking agents to construct machine-checkable specifications that characterize intended program behavior. Machine-checkable specifications are typically decoupled from specific inputs and exercised by a formal verifier. However, they often evaluate these specifications within predefined formal languages and verification interfaces, providing limited evidence about agents' ability to validate code against diverse natural language specifications in real-world repositories. Such scenarios may involve complex dependencies and various types of verification logic (e.g., functional postconditions and interaction protocols).

To bridge this gap, we introduce SPECGUARDBENCH, which evaluates whether LLM agents can construct evidence that supports thorough, faithful validation against natural language specifications in real-world repositories. SPECGUARDBENCH consists of 291 validation problems, covering eight types of verification logic. As shown in Figure 1, given a natural language specification, repository context, and a reference implementation, an agent constructs a validation harness comprising comprehensive test scenarios and executable checks. The test scenarios supply concrete arguments that drive the code under validation through a broad range of program states. The executable checks perform invocations of the code under validation with whatever arguments they receive and assert the properties that the natural language specification requires of the resulting behavior, so the same checks apply across executions, even after deployment. Together, the checks and the scenarios should thoroughly exercise specification-relevant code and expose violations without rejecting implementations that satisfy the specification.

Using SPECGUARDBENCH, we evaluate four coding agents spanning proprietary and open-weight models, and none constructs a validation harness scored as faithful on the benchmark's implementations for more than 63% of the tasks. The primary bottleneck is the faithfulness of the checks, not the thoroughness of the scenarios. The agents detect the violations on most tasks, but their checks also assert requirements the specification does not impose, and the resulting false alarms leave every agent's faithfulness 11 to 22 percentage points below its detection rate. Even when given scenarios that expose the violation, the checks of three of the four agents still accept most of the violations.

they missed, and the scenarios account for at most 33 to 42% of each agent's failures. Moreover, the coding agents ground their checks in the reference implementation rather than in the specification: when shown a violating reference, every agent loses 19 to 31 points of faithfulness, because its validation harness then accepts the violation or rejects the gold implementation. These results reveal a gap in coding agents' ability to validate code against a natural language specification. Closing this gap depends above all on checks that assert no more and no less than the specification requires, which none of the agents we evaluate reliably produces.

In summary, we make the following contributions:

• We introduce SPECGUARDBENCH, a benchmark that evaluates whether LLM agents can construct reliable evidence to validate code in real-world repositories against natural language specifications.

• We release a scalable data construction pipeline that converts code with relevant documentation into additional evaluation tasks.

• We evaluate four proprietary and open-weight LLMs and analyze the remaining challenges in depth.

References (55)