Skip to main content

Airtight

Automated verification gate for AI-generated code.

Airtight sits between any AI code generator and production. It ensures the generated code is correct through deterministic checks and cross-consistency validation — inspired by Stanford's Clover paradigm for closed-loop verifiable code generation.

The core guarantee: Airtight never approves incorrect code. It may reject correct code it can't verify (false negatives), but it will never let broken code through (zero false positives).

from airtight import verify, Spec

result = verify(
    code='def sort_desc(items): return sorted(items, reverse=True)',
    intent='Sort items in descending order',
    spec=Spec(
        requires='len(items) >= 0',
        ensures='all(result[i] >= result[i+1] for i in range(len(result)-1))',
        invariant='sorted(result, reverse=True) == result',
        test_inputs=[
            {'items': [3, 1, 2]},
            {'items': []},
        ],
    ),
)

print(result.verdict)       # "full_pass"
print(result.gates_passed)  # ["gate1_deterministic"]

Why Airtight?

AI code generators (Copilot, Claude, GPT) produce code that looks correct but often contains subtle bugs — wrong sort direction, missing edge cases, violated invariants. Testing catches some of these. Airtight catches them systematically.

Approach Catches syntax errors Catches logic bugs Catches spec violations Guarantees soundness
Run and eyeball it ✓ Sometimes No No
Unit tests ✓ If you wrote the test If you wrote the test No
Airtight ✓ ✓ (property-based) ✓ (formal spec) Yes

Installation

pip install airtight-ai

With optional SMT solver support (Z3):

pip install airtight-ai[smt]

Architecture

Airtight is a four-gate verification pipeline. Each gate is independently sound — if any gate rejects the code, the code is definitively non-conformant with respect to that check.

AI Generator → Gate 1 (Deterministic) → Gate 2 (Cross-consistency) → Gate 3 (N-candidate) → Gate 4 (Behavioral) → Verified
                  ↓ reject                 ↓ reject                    ↓ reject               ↓ reject

Gate 1 — Deterministic checks (v0.1, current)

  • Syntax parsing (AST)
  • Property-based testing via Hypothesis
  • Spec pre/postcondition and invariant checking
  • No LLM involvement — mathematically sound

Gate 2 — Cross-consistency (planned v0.2)

  • Six-way Clover consistency checks between intent, spec, and code
  • Reconstruction testing: can spec regenerate equivalent code?
  • Uses a different LLM than the generator to break shared blind spots

Gate 3 — N-candidate filter (planned v0.3)

  • Generate N independent candidates
  • Run Gates 1+2 on each, take first to pass
  • Budget-bounded with convergence detection

Gate 4 — Behavioral equivalence (planned v0.4)

  • Concolic testing and fuzzing
  • I/O comparison against spec expectations

Termination guarantee

Airtight always terminates in bounded time. The Budget object controls:

from airtight import Budget

budget = Budget(
    max_candidates=10,     # Max independent generations (k-factor)
    retries_per_gate=3,    # Max feedback retries per gate
    plateau_window=3,      # Stop if score plateaus for 3 candidates
    same_error_limit=3,    # Stop if same error class recurs 3 times
)

Worst case: 10 × (3 + 6×3) = 210 LLM calls, then STOP. Convergence detection typically exits after 2-4 candidates.

Verdicts

Verdict Meaning Action
full_pass All gates cleared Ship it
partial_pass Gate 1 passed, Gate 2+ failed Requires human review
hard_reject Gate 1 failed Do not ship

Theoretical foundation

Airtight is grounded in two bodies of work:

  1. Clover (Sun et al., Stanford 2024) — Closed-loop verifiable code generation via six-way consistency checking between code, formal annotations, and docstrings. Achieved 87% acceptance of correct code with zero false positives.

  2. Automated reasoning (resolution, SMT solvers, term rewriting) — Provides the deterministic verification backbone. SMT constraints are decidable and sound. Property-based testing via Hypothesis provides probabilistic coverage with formal guarantees.

Contributing

Contributions welcome! See CONTRIBUTING.md for guidelines.

Key areas where help is needed:

  • Gate 2 implementation — Clover-style cross-consistency checks
  • Language support — Currently Python only; JavaScript/TypeScript next
  • Spec DSL — A more ergonomic way to write specifications
  • Benchmarks — Datasets of correct/incorrect AI-generated code

License

Apache 2.0

Metadata

Release files for airtight-ai 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for airtight-ai 0.1.0
File Size Uploaded
airtight_ai-0.1.0.tar.gz 10.1 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for airtight-ai 0.1.0
File Interpreter ABI Platform
airtight_ai-0.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 21.2 kB

Release files / airtight_ai-0.1.0.tar.gz

Download URL airtight_ai-0.1.0.tar.gz
Size 10.1 kB
Tags Source
SHA-256 checksum
How to use checksums
052a4f5750bf77c74c2490e355a10fba915f6be4f22bd771c9a6570079b2e476
BLAKE2b-256 checksum
How to use checksums
d0a5e58537f6b886b01c0746258fd2804e8195cb9a2c5ed4b3d5a41f54df4320
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.5

Release files / airtight_ai-0.1.0-py3-none-any.whl

Download URL airtight_ai-0.1.0-py3-none-any.whl
Size 11.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
b119e644ffe728170aa4342ad3845e9e7fcda1b9ca0d99adca9b679b9889fa34
BLAKE2b-256 checksum
How to use checksums
4f1e9a7b4bfbd19dc8941712537a875b9370046a9c1dc86f0bde7b0a7b1d2b24
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.5

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page