# Formally Verified Rust Core & Verification Matrix

> How Vapor applies TLA+, Lean 4, Kani, seeded DST, and proptest strictly where each tool delivers the highest bug-catching ROI — keeping local cargo test under 5 seconds.

- Site: VAPOR.TOWN (https://vapor.town)
- Canonical: https://vapor.town/docs/verification
- Markdown: https://vapor.town/docs/verification.md
- Section: Verification

## Eight-Crate Rust Workspace

vapor-proto, vapor-core, and vapor-vt are strictly zero-I/O with minimal dependencies so incremental checks finish in under one second.

```vapor-diagram vapor.town — Formally Verified Auth & Verification Layers
vaportown-auth
```

## Verification Matrix by Crate

Zero verification theater: heavy formal checks run in parallel GitHub Actions Linux CI jobs, while high-velocity UI crates rely on headless Ratatui snapshots and proptest fuzzing instead of CBMC.

| Crate / Dir | Required Verification | What It Proves |
| --- | --- | --- |
| vapor-core | Newtypes + proptest + vapor-sim DST + TLA+ + Lean 4 | InPlaceRotation & PoolLease safety, ranking total order, 5h demotion, lease conservation |
| vapor-vt | proptest (arbitrary byte-chunk invariance) + Kani | Bounded memory, index safety, and panic-freedom on untrusted terminal bytes |
| vapor-providers | Unit fixtures + proptest + real-PTY E2E | Robust parsing of agy, Codex rollout, and Claude transcripts |
| vapor-tui | ratatui::TestBackend snapshots + proptest + DST chaos | Resize/key-sequence crash freedom, Kitty APC chunking, OSC 8 safety |
| vapord & vapor | Loopback HTTP/WS + Unix socket + portable-pty E2E | PoolLedger::verify_invariants() and end-to-end PTY swap behavior |

## Running the Verification Suite

Contributors need only stable Rust for the sub-5s inner loop. Formal TLA+, Lean 4, and Kani checks can be invoked on demand or in CI.

```sh
# Verify Workspace & Formal Specs
cargo fmt --all -- --check
cargo clippy --workspace --all-targets -- -D warnings
cargo test --workspace
# Formal specs & proofs:
bash specs/check.sh
cd proofs && lake build
cargo kani -p vapor-vt
```

> **Note:** Every bug fix in vapor-core, vapor-vt, vapor-providers, vapor-tui, or vapord must add a failing regression test — or a pinned vapor-sim DST seed — before applying the fix.
