MCPcopy Index your code
hub / github.com/bneb/lattice

github.com/bneb/lattice @v1.2.0

Chat with this repo
repository ↗ · DeepWiki ↗ · release v1.2.0 ↗ · + Follow
6,050 symbols 19,131 edges 530 files 1,164 documented · 19% updated 1d agov1.2.0 · 2026-07-07★ 127
What it actually does AI analysis from the code graph — generated when you open this
loading…
README

Salt

A systems language with Z3-powered compile-time verification. Write requires/ensures contracts — the compiler proves them with Z3. Provable checks have zero runtime cost; the rest become runtime assertions as a safe fallback. Arena memory, MLIR codegen. No GC, no borrow checker, no lifetime annotations.

CI Version License

package main

use std.core.result.Result

fn binary_search(arr: &[i64; 5], target: i64) -> Result<i64>
{
    let mut lo: i64 = 0;
    let mut hi: i64 = 4;
    while lo <= hi {
        let mid = (lo + hi) / 2;
        if arr[mid] == target { return Result::Ok(mid); }
        if arr[mid] < target { lo = mid + 1; }
        else { hi = mid - 1; }
    }
    return Result::Err(Status::from_code(5)); // NOT_FOUND
}

pub fn main() -> i32 {
    let data: [i64; 5] = [1, 3, 5, 7, 9];
    match binary_search(&data, 5) {
        Result::Ok(idx) => { return idx as i32; }
        Result::Err(_) => { return -1; }
    }
}

Z3 proves array bounds at compile time and elides the check. With loop induction variables, Z3 elides bounds checks for the entire loop body. The Result::Err path returns NOT_FOUND instead of a sentinel value.


Getting started

git clone https://github.com/bneb/lattice.git
cd lattice
make setup              # Install dependencies (once)
make build              # Build the compiler (~2 min)
make test               # All compiler unit tests pass (1323+)
make lettuce-verify     # Z3 contract verification tests pass
make bench              # LETTUCE vs Redis comparison

Prerequisites: Rust 1.75+, Z3 4.12+ (brew install z3), LLVM 21+ (brew install llvm@21), QEMU (brew install qemu).

Your first Salt program:

// hello.salt
package main

fn main() -> i32 {
    println("Hello, Salt!");
    return 0;
}
salt-front hello.salt --lib --disable-alias-scopes -o /tmp/hello && /tmp/hello

Full tutorial → — build a verified key-value store in 15 minutes.


Architecture

Salt Source (.salt)
    │
    ▼
Parser → Type Checker → Z3 Verifier → MLIR Emitter    [salt-front/]
    │
    ▼
mlir-opt → mlir-translate → LLVM IR → clang -O3       [LLVM backend]
    │
    ▼
KeuOS Kernel: boot.S → kmain → Drivers → Ring 3        [kernel/]
    │
    ▼
User Programs: LETTUCE, Basalt, FACET, NetD            [user/]

Full architecture reference →

What's here

salt-front/ Compiler (Rust → MLIR → LLVM → native)
salt-front/std/ Standard library (arenas, collections, networking, I/O)
kernel/ KeuOS microkernel — SMP, SPSC IPC, TCP stack, Ring 3 daemons
user/ User-space programs (echo_server, fetch, NetD, FACET)
docs/ Documentation — tutorials, blog, specs, deep-dives
tools/salt-lsp/ LSP server (VS Code extension)

Built with Salt

Project What it is Lines
KeuOS Microkernel — 16-core SMP, SPSC IPC, Ring 3 daemons
LETTUCE Redis-compatible server — leads Redis at every concurrency level ~1500
Basalt Llama 2 inference engine ~600
FACET GPU-accelerated 2D compositor with Metal shaders

Verification

Salt embeds Z3 as a compiler pass. Functions carry requires and ensures clauses. The compiler translates them to Z3 formulas and checks them during normal compilation.

UNSAT — the condition always holds. The check is elided. Zero instructions.

SAT — Z3 found a counterexample. You get the specific values before your program runs.

TIMEOUT — Z3 cannot decide within 100ms. A runtime assertion is emitted. Your program still compiles and runs.

Verification is progressive: add the contracts you can prove today. The rest become runtime checks you can address later.

After compilation, Salt reports proof coverage:

Z3: 10/24 checks proven (41%), 14 deferred to runtime

Salt also provides automatic optimizations: the @ operator on Tensor types emits cache-tiled matrix multiplication with L1-sized blocks. On M4 Pro at 2048×2048 f64, Salt's tiled matmul runs in 1.06s vs. hand-tuned C at 1.12s (5.6% faster). Benchmarks →

Performance

LETTUCE, a 314-line Salt server implementing 9 Redis commands, was benchmarked against Redis 7 on the same machine using redis-benchmark. 13-point concurrency sweep, 50,000 requests per test.

Clients LETTUCE Redis 7
1 5,219 req/s 1,437 req/s
10 21,758 5,178
50 14,144 12,710
100 22,381 17,876

LETTUCE leads at every concurrency level. The structural advantage is the arena allocator — zero malloc per request vs. Redis's zmalloc/zfree contention under load. Full benchmark data →

Further reading

License

MIT

Extension points exported contracts — how you extend this code

Core symbols most depended-on inside this repo

Shape

Function 4,254
Method 1,350
Class 366
Enum 68
Interface 12

Languages

Rust78%
C13%
C++6%
Python3%
TypeScript1%

Modules by API surface

user/facet/gpu/stb_image.h218 symbols
salt-front/src/codegen/context.rs118 symbols
salt-front/src/hir/typeck.rs116 symbols
salt-front/src/codegen/context/accessors.rs115 symbols
tests/bridges/ipc_bridge.c112 symbols
salt-front/src/z3_stub.rs101 symbols
salt-front/src/lib.rs83 symbols
salt-front/src/types.rs76 symbols
salt-front/src/hir/lower.rs75 symbols
salt-front/runtime.c74 symbols
salt-front/src/hir/async_lower.rs72 symbols
salt-front/runtime_win.c71 symbols

For agents

$ claude mcp add lattice \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact

Ask about this repo answers extend the page