Skip to content

codervisor/lean-verify

Repository files navigation

LeanVerify

The Shield against AI Hallucination 🛡️

An Intent Verification Layer that ensures AI-generated code actually fulfills product specifications — not just tricks unit tests.

License: MIT

Why LeanVerify?

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.

How It Works

Parse Spec → Spin up Sandbox → Inject Code → Monitor Trace → AI Semantic Audit → Quality Report
  1. Spec-Driven Oracle — Reads .spec files (from lean-spec) as the source of truth
  2. Adversarial Testing — Injects unexpected inputs to catch hardcoded "cheats"
  3. Semantic Sandbox — Executes code in isolation and observes real behavior (file changes, network calls, memory state)
  4. Structural Quality Report — Classifies failures as Logic Divergence, Hardcoded Cheat, Missing Implementation, or Environment Error

Quick Start

# 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

CLI Commands

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

Architecture

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)

Core Components

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

Dual-Mode Entry

LeanVerify works as both:

  • Standalone CLI: lean-verify run
  • lean-spec Plugin: lean-spec verify (after running lean-verify plugin-install)

Development

# Prerequisites: Node.js >= 18, pnpm, Rust toolchain

# Install dependencies
pnpm install

# Build all packages
pnpm build

# Run tests
pnpm test

Part of the Codervisor Ecosystem

LeanVerify is a core component of Codervisor, working alongside:

  • lean-spec — Lightweight specification format
  • forge — Project scaffolding and standards

License

MIT

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors