The Shield against AI Hallucination 🛡️
An Intent Verification Layer that ensures AI-generated code actually fulfills product specifications — not just tricks unit tests.
AI coding agents can produce code that appears correct but actually:
- Hallucinates — Claims "task complete" but leaves logic unfinished
- Cheats — Hardcodes return values to pass static test cases
- Diverges — Implements something different from the specification
LeanVerify catches these issues by verifying intent, not just test results.
Parse Spec → Spin up Sandbox → Inject Code → Monitor Trace → AI Semantic Audit → Quality Report
- Spec-Driven Oracle — Reads
.specfiles (from lean-spec) as the source of truth - Adversarial Testing — Injects unexpected inputs to catch hardcoded "cheats"
- Semantic Sandbox — Executes code in isolation and observes real behavior (file changes, network calls, memory state)
- Structural Quality Report — Classifies failures as Logic Divergence, Hardcoded Cheat, Missing Implementation, or Environment Error
# Install
npm install -g @lean-verify/cli
# Initialize in your project
lean-verify init
# Verify your code against specs
lean-verify run
# Check system requirements
lean-verify doctor
# Install as a lean-spec plugin
lean-verify plugin-install| Command | Description |
|---|---|
lean-verify run [specs...] |
Run verification against spec files |
lean-verify init |
Initialize LeanVerify in the current project |
lean-verify doctor |
Check system requirements and configuration |
lean-verify plugin-install |
Install as a lean-spec verify plugin |
packages/
cli/ # TypeScript CLI — entry point and commands
core/ # Core verification engine — Oracle, Sandbox, Verify loop
rust/
crates/
lean-verify-sandbox/ # High-performance sandbox runtime (Rust)
| Component | Responsibility |
|---|---|
lean-verify run |
Main execution engine — coordinates sandbox and Oracle |
| Oracle | "Critic Agent" that reads code to ensure the path taken is correct |
| Adversarial Injection | Changes input variables at runtime to catch hardcoded cases |
| Semantic Sandbox | Reports file changes, network calls, and memory state — not just exit codes |
LeanVerify works as both:
- Standalone CLI:
lean-verify run - lean-spec Plugin:
lean-spec verify(after runninglean-verify plugin-install)
# Prerequisites: Node.js >= 18, pnpm, Rust toolchain
# Install dependencies
pnpm install
# Build all packages
pnpm build
# Run tests
pnpm testLeanVerify is a core component of Codervisor, working alongside:
MIT