---
title: AI code verification
url: https://ftrlg.com/en/wiki/ai-code-verification/
lang: en
published: 2026-11-01
version: 1
summary: How AI-generated code is checked through testing, static analysis, independent review, sandboxed execution, and formal verification.
cite_as: "future.log, «AI code verification», https://ftrlg.com/en/wiki/ai-code-verification/"
license: CC BY 4.0 https://creativecommons.org/licenses/by/4.0/
---

# AI code verification

**AI code verification** is the set of methods used to determine whether a program written by a language model meets its task, works, and is safe. It includes testing, static analysis, independent review, sandboxed execution, and formal verification. No single method proves a program's quality on its own.

As generation accelerates, verification becomes the bottleneck. A model can quickly produce plausible code and equally plausible tests, but both artifacts may repeat the same misunderstanding. Research is therefore shifting from judging a model's answer to obtaining **independent evidence**: execution, property checks, and feedback from deterministic tools.

## History

- **February 14, 2024** Meta describes industrial use of TestGen-LLM: the system extends human-written tests and discards generated cases that fail to build, pass unreliably, or do not increase coverage.[^1] <!-- ¶ c4t7n2xqp -->
- **July 9, 2025** Shanghai AI Laboratory researchers show that small test suites inflate code benchmark results, while automatically generated verifiers often contain errors themselves.[^2] <!-- ¶ c8v3k6rmz -->
- **November 24, 2025** Dolcetti and Iotti review two directions: using language models to verify code and verifying their generated code with traditional and hybrid methods.[^3] <!-- ¶ c2m9q5wxz -->
- **March 5, 2026** A C-code experiment shows that models poorly detect their own errors but repair them substantially better after receiving test and static-analysis feedback.[^4] <!-- ¶ c7r4p8dnz -->
- **June 26, 2026** AxDafny combines an agentic generate-and-repair loop with the Dafny formal verifier: successful verification covers executable code, invariants, and proofs.[^5] <!-- ¶ c3w7y6tkz -->
- **June 26, 2026** Jin and Chen publish research on systematic overcorrection: models classify correct code as non-compliant, especially when asked for explanations and fixes.[^6] <!-- ¶ c9n4x2mvz -->
- **July 22, 2026** Cross-Model LLM Code Review shows that a second reviewer is not useful merely by being different: one model pairing improves results, while reversing the same models worsens them.[^7] <!-- ¶ c5k8r3qpz -->
- **September 30, 2026** An analysis of ten terminal agents finds that they nearly always attempt verification but detect only 61.43% of incorrect solutions and repair less than half of detected errors.[^8] <!-- ¶ c6d2m9vxz -->
- **October 21, 2026** VeeReview evaluates whether changes and verification evidence correspond in 1,454 matched pull-request pairs. It fails its own calibration criterion, showing that judging verification from a request's appearance is also unreliable.[^9] <!-- ¶ c4q7t5bnz -->

## How it works

AI code verification consists of several independent layers.

**Execution.** Compilation, unit tests, and integration tests check behavior in specific scenarios. They can prove that an error exists, but not that none exists: untested inputs remain outside the result. <!-- ¶ c7v2n4qrz -->

**Properties.** Property-based testing states a condition that must hold for a class of inputs: output is sorted, a sum never decreases, or repeating an operation changes nothing. A generator then searches for counterexamples. This is stronger than individual examples but depends on choosing the right property and data-generation strategy. <!-- ¶ c3m8x5kpz -->

**Static analysis.** Tools inspect code without running it: types, memory access, resource leaks, vulnerabilities, and architectural violations. They produce both false positives and false negatives. <!-- ¶ c9q4r7vnz -->

**Model review.** Another language model examines the task and changes. This scales the search for possible problems, but the reviewer's verdict itself needs verification: it may miss an error or break a working solution.[^6][^7] <!-- ¶ c5w2k8mpz -->

**Formal verification.** Dafny, Lean, Rocq, and other systems check a mathematical proof that code conforms to a specification. Their guarantee covers stated properties, not every desired behavior. Performance, usability, and alignment with user intent may remain outside the proof.[^5] <!-- ¶ c2n7q4xrz -->

**Isolation.** A sandbox limits the consequences of executing untrusted code: filesystem, network, credentials, time, and resources. It protects the environment but says nothing about program correctness. <!-- ¶ c8p5m3vkz -->

## Data

| study | what it measured | result |
|---|---|---|
| Meta, TestGen-LLM, 2024[^1] | extending existing Kotlin tests in Instagram and Facebook; filtering by build, reliable passing, and increased coverage | in the Instagram evaluation, **75%** of tests built, **57%** passed reliably, and **25%** increased coverage; 11.5% of classes improved during events, with 73% of recommendations accepted <!-- ¶ c8p3m6qrz --> |
| SAGA / TCGBench, 2025[^2] | tests' ability to detect errors and the quality of automatic verifiers | half of test suites failed to detect known errors; **84%** of verifiers were flawed; human-LLM SAGA reached 90.62% detection but only 32.58% verifier accuracy <!-- ¶ c2x9n7vkz --> |
| Dolcetti et al., 2026[^4] | 100 C tasks, four open models; ground-truth tests and Infer | **46–65%** of solutions were correct; on average, 59% of incorrect programs were repaired with test feedback and 89% of vulnerabilities with analysis feedback; models' vulnerability-detection F1 was below 30% <!-- ¶ c6r3w8pmz --> |
| Jin and Chen, 2026[^6] | five models, HumanEval, MBPP, and QuixBugs; requirement-conformance review | GPT-4o's rejection of correct code rose from 26.2% to **73.2%** on HumanEval and **87.9%** on MBPP with richer instructions; less strict answers accepted buggy code <!-- ¶ c4v7k2xnz --> |
| PBT-Bench, 2026[^10] | 100 tasks, 365 seeded bugs in 40 Python libraries; property-violation discovery | models found **42.1–83.4%** of bugs with Hypothesis guidance and 31.4–76.7% without; different models missed different bugs <!-- ¶ c9t5m3rqz --> |
| AxDafny, 2026[^5] | proof restoration and code generation with proofs; up to 20 attempts | **92.7%** on DafnyBench; 56.4% on new LCB-Pro-Dafny versus 11.6% direct generation; only 28% of hard tasks. Many verified solutions exceeded time limits <!-- ¶ c3n8p6wxz --> |
| Cross-Model Review, 2026[^7] | 116 LiveCodeBench tasks, six writer-reviewer combinations without execution | Claude's review of Codex drafts raised passing from 71.6% to **89.7%**; the reverse pairing reduced it from 91.4% to **82.8%** <!-- ¶ c7m4q9rkz --> |
| TerminalBench 2.1, 2026[^8] | ten agents; objective correctness of first complete solutions and subsequent self-verification | **61.43%** of incorrect solutions detected; **49.36%** of detected errors repaired <!-- ¶ c5w2n8xpz --> |
| VeeReview, 2026[^9] | 1,454 matched agent and human pull requests; correspondence between changes and verification | agreement with human labels was **4–60%** against an 80% target; authors present group differences only as observations from an imperfect instrument <!-- ¶ c2k7r5mqz --> |

> **[EDITORIAL CONCLUSION]** The most consistent finding is the value of external, verifiable feedback. Models repair code much better using reports from tests, analyzers, or verifiers than they detect errors independently. But every layer has a blind spot: tests are incomplete, reviewers overcorrect, static analyzers make mistakes, and formal proofs omit unstated properties. Development therefore points toward combined methods and verification of the checks themselves, not control by a single stronger model. <!-- ¶ c8q4n6vxz -->

## Criticism

Successful execution does not equal correctness. SAGA shows that limited test suites can inflate model estimates; many formally verified AxDafny programs exceeded time and memory limits because specifications covered functionality but not performance.[^2][^5] <!-- ¶ c3p8m5rnz -->

An independent model is not a neutral judge either. Only one direction helped in Cross-Model Review; the other reviewer degraded working solutions. The study covers 116 self-contained algorithmic tasks, not large repositories, so it cannot serve as a universal model ranking.[^7] <!-- ¶ c7v2k9qpz -->

Requiring explanations can worsen review. Jin and Chen found increased rejection of correct code when models were asked to explain problems and propose fixes. A correct verdict also did not guarantee a correct explanation of the error's cause.[^6] <!-- ¶ c4n7x3mwz -->

Even automated assessment of the verification process remains unreliable. VeeReview missed its accuracy target against human labels; one rule that did not use a model judge proved more useful as a reminder of the need for mechanically checkable signals.[^9] <!-- ¶ c6r8q2vkz -->

## Development

The first direction is **independent test creation**. Code and test authors are separated to reduce repetition of the same mistake. Tests are then evaluated by their ability to detect deliberately seeded defects, not merely by passing. <!-- ¶ c7p4m2xnz -->

The second is **verifying proposed fixes**. Instead of accepting a review verdict, the system compares original and revised versions on the same tests. This measures fixed and broken solutions rather than the number of comments. <!-- ¶ c2w8q5rkz -->

The third is **moving difficult work into specifications**. Property-based testing and formal methods require program properties to be stated in advance. The Coins study of formal-specification generation shows that automating this remains difficult: proving a wrong or overly weak condition creates false confidence.[^11] <!-- ¶ c9m4p7xrz -->

The fourth is **reporting the limits of evidence**. Results must distinguish whether code builds, passes tests, contains no detected vulnerabilities, and is proven against specific properties. VeeReview and TerminalBench show that merely having a “verified” stage is uninformative.[^8][^9] <!-- ¶ c5t3n8qmz -->

## See also

[Vibe coding](https://ftrlg.com/en/wiki/vibe-coding/) · [Agentic engineering](https://ftrlg.com/en/wiki/agentic-engineering/) · [Autonomous AI agents](https://ftrlg.com/en/wiki/autonomous-ai-agents/) · [AI safety](https://ftrlg.com/en/wiki/ai-safety/)

## References

[^1]: N. Alshahwan et al. Automated Unit Test Improvement using Large Language Models at Meta — arXiv / FSE, February 14, 2024. [arxiv.org](https://arxiv.org/abs/2402.09171)
[^2]: Z. Ma et al. Rethinking Verification for LLM Code Generation: From Generation to Testing — arXiv, July 9, 2025; NeurIPS 2025. [arxiv.org](https://arxiv.org/html/2507.06920v1)
[^3]: G. Dolcetti, E. Iotti. A dual perspective review on large language models and code verification — Frontiers in Computer Science, November 24, 2025. [frontiersin.org](https://www.frontiersin.org/journals/computer-science/articles/10.3389/fcomp.2025.1655469/full)
[^4]: G. Dolcetti et al. Helping LLMs improve code generation using feedback from testing and static analysis — Automated Software Engineering, March 5, 2026. [link.springer.com](https://link.springer.com/article/10.1007/s44163-026-01009-5)
[^5]: A. Letson, B. Requena Pozo, L. Sarra. AxDafny: Agentic Verified Code Generation in Dafny — arXiv, June 26, 2026. [arxiv.org](https://arxiv.org/html/2606.32007)
[^6]: H. Jin, H. Chen. Are LLMs reliable code reviewers? Systematic overcorrection in requirement conformance judgement — Automated Software Engineering, June 26, 2026. [link.springer.com](https://link.springer.com/article/10.1007/s10515-026-00638-5)
[^7]: S. Xiang, Y. Zhang, Y. Zhang, H. Xu. Cross-Model LLM Code Review: Should you use Claude to review Codex or vice versa? — arXiv, July 22, 2026. [arxiv.org](https://arxiv.org/html/2607.21656)
[^8]: Y. Luo et al. Can Terminal Agents Trust Their Own Verification? Diagnosing and Improving Self-Verification — arXiv, September 30, 2026. [arxiv.org](https://arxiv.org/html/2609.38812v1)
[^9]: J. J. Wu, G. Dautovic. VeeReview: Measuring Build–Verify Pairs in Agent-Authored Pull Requests from a V-Model Perspective — arXiv, October 21, 2026. [arxiv.org](https://arxiv.org/html/2610.29143)
[^10]: L. Jing, X. Wang, L. Zhang, S. S. Du. PBT-Bench: Benchmarking AI Agents on Property-Based Testing — arXiv, May 20, 2026. [arxiv.org](https://arxiv.org/html/2605.15229v2)
[^11]: F. Yang et al. How Powerful Are LLMs in Generating Formal Program Specifications? — arXiv, August 13, 2026. [arxiv.org](https://arxiv.org/html/2608.13077v1)

— future.log, «AI code verification», https://ftrlg.com/en/wiki/ai-code-verification/ · CC BY 4.0
