SpecGuardBench: Can Coding Agents Construct Reliable Validation Harnesses from Natural Language Specifications?
Organizations: The Chinese University of Hong Kong, Shenzhen · Aalto University · Lero, the Research Ireland Centre for Software · University of Limerick ·
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.
Figures & tables
| Agent | Detection | False Alarm | Faithfulness | Edge Cov. | Cost |
|---|---|---|---|---|---|
| Codex / GPT-5.6-sol | 81.8% | 23.0% | 61.9% | 82.0% | $0.74 |
| Claude Code / Claude Opus 5 | 65.3% | 20.6% | 50.2% | 72.4% | $1.79 |
| OpenCode / DeepSeek-V4-Pro | 66.7% | 26.8% | 45.0% | 75.1% | $0.43 |
| OpenCode / GLM-5.3 | 74.2% | 15.1% | 62.9% | 84.3% | $1.48 |
| Gold reference violating reference (%) | ||||
|---|---|---|---|---|
| Agent | Detection | False Alarm | Gold Rejection | Faithfulness |
| Codex / GPT-5.6-sol | 83 78 | 21 37 | 0 4 29 | 65 46 |
| Claude Code / Claude Opus 5 | 66 33 | 19 38 | 0 4 31 | 52 21 |
| OpenCode / DeepSeek-V4-Pro | 70 67 | 23 48 | 15 41 | 52 28 |
| OpenCode / GLM-5.3 | 75 44 | 12 24 | 0 0 12 | 68 39 |
Appendix figures & tables5 assets
Supplementary material from the paper’s appendix.
Appendix
| Type | A check must establish that | Counterpart | (%) | |
|---|---|---|---|---|
| Functional postcondition | the return value satisfies a predicate over the inputs | postconditions ( ensures in JML, ACSL, and Dafny) | 143 | (49.1%) |
| Input validation | for inputs meeting a stated condition, the call raises a specified exception, returns a specified error value, emits a specified message or warning, or emits none of these | specification cases (JML normal_behavior and exceptional_behavior , ACSL behaviors, SPARK Contract_Cases ) | 52 | (17.9%) |
| State postcondition | state that outlives the call, in the receiver, an argument, or the module, ends in a required relation to its state before the call or to the inputs | two-state postconditions ( \old in JML and ACSL, old in Dafny) | 18 | (6.2%) |
| Frame condition | the call leaves specified state unmodified, and a result required to be new shares no state with existing objects | frame clauses ( assignable , assigns , modifies ), \fresh , separation logic | 14 | (4.8%) |
| Interaction protocol | the function calls specified collaborators with specified arguments and multiplicity, or reads a value from a specified source | I/O specifications in separation logic, flow contracts (SPARK Depends ) | 32 | (11.0%) |
| Call order | events within one execution occur in a specified order | temporal logic (LTL), typestate | 2 | (0.7%) |
| Agent | Detection | False Alarm | Faithfulness | Edge Cov. | Cost |
|---|---|---|---|---|---|
| Codex / GPT-5.6-sol | 83.0% | 24.3% | 63.4% | 82.4% | $0.73 |
| Claude Code / Claude Opus 5 | 62.6% | 19.9% | 50.5% | 73.9% | $1.76 |
| OpenCode / DeepSeek-V4-Pro | 64.7% | 25.5% | 45.1% | 73.7% | $0.43 |
| OpenCode / GLM-5.3 | 75.5% | 17.2% | 62.5% | 84.4% | $1.41 |
| Gold reference violating reference (%) | ||||
|---|---|---|---|---|
| Agent | Detection | False Alarm | Gold Rejection | Faithfulness |
| Codex / GPT-5.6-sol | 86.5 78.3 | 24.8 31.7 | 0 1.5 24.1 | 66.2 51.5 |
| Claude Code / Claude Opus 5 | 64.3 40.6 | 19.8 35.8 | 0 5.3 28.7 | 49.6 25.2 |
| OpenCode / DeepSeek-V4-Pro | 75.7 72.2 | 22.2 51.6 | 16.4 43.1 | 57.3 30.6 |
| OpenCode / GLM-5.3 | 80.5 49.2 | 14.2 29.2 | 0 0.0 13.3 | 70.9 42.1 |
| Agent | Detection | False Alarm | Faithfulness | Edge Cov. |
|---|---|---|---|---|
| Codex / GPT-5.6-sol | 81.8 5.9 | 23.0 5.7 | 61.9 8.0 | 82.0 6.4 |
| Claude Code / Claude Opus 5 | 65.3 5.4 | 20.6 4.5 | 50.2 6.3 | 72.4 6.6 |
| OpenCode / DeepSeek-V4-Pro | 66.7 5.8 | 26.8 7.1 | 45.0 6.1 | 75.1 7.7 |
| OpenCode / GLM-5.3 | 74.2 5.8 | 15.1 4.6 | 62.9 6.9 | 84.3 4.7 |
| GPT-5.6-sol GLM-5.3 | 7.6 6.6 | 7.9 4.4 | 1.0 6.8 | 2.3 4.1 |
| DeepSeek-V4-Pro Claude Opus 5 | 1.4 5.4 | 6.2 5.4 | 5.2 5.5 | 2.7 4.2 |
| In the contracts | In the paper |
|---|---|
| certificate | validation harness |
| build_cases() , coverage cases | scenario generator, test scenarios |
| check_case(case) | executable checks |
| case | test scenario |
| target | the callable the scenarios invoke |
| gold implementation, gold patch | gold implementation |
AI Coding Agents
AI coding agents use language models and software tools to plan, edit, test, and maintain code with varying levels of autonomy.
See all 310 papers