← Lab /Software

LLM framework generates correct specs for unsafe Rust with 88.9% success

KaPilot can automatically produce specifications for unsafe Rust functions that are equivalent to or stronger than manually written ground-truth specs

Software arXiv 24 Jul 2026 Method Prototype evidence

Published as “KaPilot: LLM-Assisted Generation of Kani Specifications for Unsafe Rust Verification”

Why it matters

KaPilot makes automated verification of unsafe Rust more practical by reducing manual specification effort and improving spec quality, though users must still handle a non-trivial failure and vacuity rate.

Summary

KaPilot generates correct Kani specifications for unsafe Rust code with an 88.9% success rate and 57.4% of them matching or exceeding ground-truth quality, but only about half of the passed specifications are judged "good" and a notable fraction are vacuous or fail verification. It outperforms the prior AutoSpec tool by 14.8% in verifiable specs and 25.9% in equivalent-or-better specs, using a multi-agent pipeline that extracts safety requirements from documentation, prechecks specs with LLMs, and applies vacuity checks. However, verification failures reach up to 31% on functions without ground truth, and the approach relies on manual labeling to distinguish good from bad specs.

What they found 1

  1. KaPilot improves over AutoSpec by 14.8% in verifiable specs and 25.9% in equivalent-or-better specs.

    “Compared with AutoSpec on GoldSet, KaPilot achieves a 14.8% higher success rate in generating verifiable specifications and a 25.9% higher success rate in generating specifications that are semantically equivalent to or better than the ground truth.”

Caveats 6

  • Only 51.85%-62.96% of passed specifications are labeled good, meaning many passed specs are incomplete or vacuous.
  • A good indicates that verification passes and the specification captures all safety requirements. A bad indicates that verification passes, but the specification is incomplete or vacuous.
  • The failure rate (28.57% to 31.43%) is higher than that on GoldSet (7.41% to 20.37%).
  • We exclude 27 functions due to Kani’s (1) no support for await and inline assembly, (2) incompatibility with packed_simd, and (3) inability to express contracts for functions that return mutable references to arguments.
  • Kani currently supports loop-invariant primitives only for while loops.
  • As there is no fully automated approach to distinguish good from bad cases, we manually performed the categorisation for GoldSet, for which ground truth is available.

What’s new here 4

  • Extracts safety requirements from function documentation rather than code, addressing code-centric limitation C1.
  • Introduces a SpecPrecheck agent that uses LLMs to assess coverage and strength of generated specs, improving stability (C2).
  • Implements automated vacuity checks and a shuffle-and-implication strategy to ensure non-trivial, semantically aligned specifications (C3).
  • Provides a multi-agent generate-precheck-verify loop with feedback-driven refinement, which prior LLM-based tools lack.