Formerly "Logically Airgapped Inference" (LAGI)—a content-verified egress gate that blocks responses failing formal validation.
Formally verified network sentry for AI inference using eBPF data diodes.
For Apart's hackathon. See comms/whitepaper/main.pdf for motivation and background.
Linux host with:
- Docker Engine with Compose V2
- Rust nightly toolchain with
rust-srccomponent bpf-linkerfor compiling eBPF- Lean 4 via elan
Install Rust toolchain:
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
rustup install nightly
rustup component add rust-src --toolchain nightly
cargo install bpf-linkerInstall Lean 4:
curl -sSf https://raw.githubusercontent.com/leanprover/elan/master/elan-init.sh | shgit clone <repo-url>
cd adversarial-network-tapped-inference-hackathon./enclaves/muenclave/scripts/download-iso.shThis downloads the ~55MB bootable ISO that runs llama2.c inference.
cd sentry
make
cd ..This compiles eBPF filters to sentry/build/:
Rust diodes (reference implementations):
rust_minimal.o- Printable ASCII checkrust_json.o- JSON depth validationrust_hateless.o- Content filtering (blocks "hate")
Lean diodes (specification-derived):
lean_json_start.o- Size < 1400, starts with{lean_json_prefix.o- Starts with{or[lean_printable16.o- First 16 bytes printable ASCIIlean_printable64.o- First 64 bytes printable ASCII
docker compose up -dThis starts:
- muenclave (172.30.0.11:8080) - QEMU VM running muInference
- sentry (host network, privileged) - eBPF filter attachment
- dashboard (localhost:8501) - Streamlit monitoring UI
open http://localhost:8501Or use curl to test directly:
curl -H "Content-Type: application/json" \
http://172.30.0.11:8080/api/generate \
-d '{"prompt": "Once upon a time", "wait_time": 10}'With the hateless diode (default), content containing "hate" is blocked:
# This passes (no "hate" in response)
curl -H "Content-Type: application/json" \
http://172.30.0.11:8080/api/generate \
-d '{"prompt": "Once upon a time", "wait_time": 10}'
# This gets blocked (prompt echoed in response contains "hate")
curl -H "Content-Type: application/json" \
http://172.30.0.11:8080/api/generate \
-d '{"prompt": "I hate bananas", "wait_time": 10}'Watch filter decisions:
docker logs -f lagi-sentry┌─────────────────────────────────────────────────────────────────┐
│ DOCKER HOST │
│ │
│ ┌────────────────────────────────────────────────────────┐ │
│ │ Docker Bridge: 172.30.0.0/24 │ │
│ │ │ │
│ │ ┌──────────────┐ veth ┌──────────────┐ │ │
│ │ │ sentry │◄─────────────────►│ muenclave │ │ │
│ │ │ │ TC FILTER │ 172.30.0.11 │ │ │
│ │ │ - Rust eBPF │ ATTACHED HERE │ │ │ │
│ │ │ - hateless │ │ - QEMU VM │ │ │
│ │ │ diode │ │ - llama2.c │ │ │
│ │ └──────────────┘ └──────────────┘ │ │
│ │ │ │
│ └────────────────────────────────────────────────────────┘ │
│ │
│ ════════════════════════════════════════════════════════════ │
│ HOST KERNEL │
│ eBPF filters run HERE │
└─────────────────────────────────────────────────────────────────┘
| Component | Description |
|---|---|
sentry/ |
eBPF diode implementations (Rust/Aya) + Lean 4 specifications |
enclaves/muenclave/ |
QEMU VM running muInference ISO with VNC+OCR API |
dash/ |
Streamlit dashboard for interactive testing |
tests/ |
End-to-end test suite and configuration |
Rust (reference implementations):
| Diode | Property Checked | Use Case |
|---|---|---|
rust_minimal.o |
Printable ASCII (first 16 bytes) | Baseline sanity |
rust_json.o |
JSON depth ≤ 2 | Structural validation |
rust_hateless.o |
No "hate" in first 512 bytes | Content filtering |
Lean (specification-derived):
| Diode | Property Checked | Use Case |
|---|---|---|
lean_json_start.o |
Size < 1400, starts with { |
JSON object filter |
lean_json_prefix.o |
Starts with { or [ |
JSON value filter |
lean_printable16.o |
First 16 bytes printable | ASCII sanity |
lean_printable64.o |
First 64 bytes printable | Extended ASCII sanity |
# Start everything
docker compose up -d
# Stop everything
docker compose down
# View sentry logs
docker logs -f lagi-sentry
# Rebuild after code changes
cd sentry && make && cd ..
docker compose restart sentry
# Run Lean specification tests
cd sentry/spec && lake build"rust_hateless.o not found" or "lean_*.o not found"
cd sentry && make"muinference.iso not found"
./enclaves/muenclave/scripts/download-iso.shContainer unhealthy
docker compose down
docker compose up -d
docker ps # Check health statusPermission denied (eBPF)
The sentry container requires privileged: true and host network mode. Ensure Docker has appropriate permissions.
The sentry/spec/ directory contains Lean 4 specifications and a compiler that generates eBPF bytecode directly from formally specified predicates. The Lean-compiled diodes (lean_*.o) are built alongside the Rust reference implementations.
See sentry/spec/CLAUDE.md for details on the verification architecture and predicate DSL.