Single-binary Rust gateway (vitna-runtime-rs)
vitna-runtime-rs is the Apache-2.0 single-binary Rust data plane for vitna-runtime and vitna-route (source in runtime-rs/). It executes the same signed policies, deterministic scoring, prompt-cache stickiness, security boundaries, and text-free ledger contract as the Node.js runtime while scaling across cores with bounded-window feature inspection on large prompts.
When to run the Rust data plane
- You want a single static binary with no Node.js runtime dependency in a container, sidecar, or edge VM.
- Your traffic carries large prompts (50 KB to 200 KB+ coding contexts, tool histories, or logs) at concurrent request rates where Node's single-threaded event loop adds noticeable proxy latency.
- You want wire-compatible offline verification for both
vitna-routing-policy-v1(lane-based policies) andvitna-auto-route-policy-v1(vitna-routepolicies) from one binary.
Building from source
cargo build --manifest-path runtime-rs/Cargo.toml --releaseThe release binary lands at runtime-rs/target/release/vitna-runtime-rs (vitna-runtime-rs.exe on Windows, ~8.26 MiB stripped).
Offline policy verification
vitna-runtime-rs verify checks the canonical body SHA-256 digest, checks that the document's embedded publicKey appears in VITNA_PUBLIC_KEY (comma-separated base64 SPKI DER keys for zero-downtime key rotation), and verifies the Ed25519 signature over the exact statement bytes produced by platform/engine/policy.mjs.
# Auto-route policy (vitna-auto-route-policy-v1)
VITNA_PUBLIC_KEY="$(cat route-key.pub)" \
vitna-runtime-rs verify --policy auto-route-policy.json \
--org acme --decision 42 --require-mode route --json
# Lane policy (vitna-routing-policy-v1)
VITNA_PUBLIC_KEY="$(cat policy-key.pub)" \
vitna-runtime-rs verify --policy lane-policy.json --org acme --jsonExit codes match vitna-route: 0 on verified pass, 2 on CLI or missing configuration errors, and 3 on cryptographic, digest, tamper, or constraint failures.
Serving traffic
# Auto-route mode under a verified signed policy
VITNA_ROUTE_POLICY=./auto-route-policy.json \
VITNA_PUBLIC_KEY="$(cat route-key.pub)" \
VITNA_LEDGER=/var/lib/vitna/ledger.jsonl \
OPENROUTER_API_KEY=... \
OPENAI_API_KEY=... \
ANTHROPIC_API_KEY=... \
vitna-runtime-rs serve
# Instant rollback to shadow mode without modifying or re-signing the policy
VITNA_ROUTE_POLICY=./auto-route-policy.json \
VITNA_PUBLIC_KEY="$(cat route-key.pub)" \
vitna-runtime-rs serve --shadow
# Lane-policy mode (vitna/<alias>)
VITNA_POLICY=./lane-policy.json \
VITNA_PUBLIC_KEY="$(cat policy-key.pub)" \
VITNA_LEDGER=/var/lib/vitna/ledger.jsonl \
vitna-runtime-rs serveSupported HTTP endpoints:
GET /healthz: unauthenticated liveness check ({ "ok": true, "version": "..." }).GET /healthandGET /status: minimal liveness body when locked and unauthenticated; full policy, mode, allowlist, conversation, and ledger status when authenticated or on unlocked loopback.GET /v1/models: listsauto,vitna/auto, and provider-allowed configured models (orvitna/<alias>lanes in lane-policy mode).POST /v1/chat/completions: OpenAI dialect, SSE streaming and non-streaming, auto-routing, multi-turn cache stickiness, failover, and named-model passthrough.POST /v1/messages: Anthropic Messages API dialect, SSE streaming and non-streaming passthrough with ledger attribution.POST /v1/route/explain: pure decision introspection with no upstream calls and no ledger writes.
Explaining decisions locally
vitna-runtime-rs explain --policy auto-route-policy.json \
--public-key "$(cat route-key.pub)" --json request.jsonSecurity and ledger invariants
vitna-runtime-rs enforces the same invariants as vitna-runtime and vitna-route:
- Refuses to boot unsigned
mode: "route"configurations fail-closed. - Refuses to bind any non-loopback address (
0.0.0.0, LAN IPs, hostnames) unlessVITNA_INBOUND_KEYorVITNA_ROUTE_API_KEYSis configured. - Performs constant-time authentication over SHA-256 digests for
Authorization: Bearer <key>andx-api-key. - Rejects browser-forged non-loopback
Hostheaders,Originheaders onPOST /v1/*, and non-application/jsonPOST /v1/*requests with403whenever no inbound key is set. - Enforces
VITNA_ALLOW_PROVIDERSacross auto-routing, shadow serving, passthrough routes,/v1/messages,/v1/models, and lane resolution. - Appends text-free JSONL rows to
VITNA_LEDGERcontaining numeric feature counts, decision reasons, policy digest, latency, and provider-reported token counts, compatible withvitna-runtime-profile(unitProfiles). Prompt and completion text are never written to disk. - Makes zero network calls to
vitna.ai.
Measured loopback performance
Head-to-head comparison via node runtime-rs/bench/compare.mjs against a local loopback mock upstream (both gateways serving the same signed route policy and appending one JSONL ledger row per request on an open file descriptor; Windows x86_64, rustc 1.98.1, Node v24.19.0):
| Scenario | vitna-runtime-rs (--release) | Node vitna-route | Throughput speedup |
|---|---|---|---|
1 KB (c=16) | 1,761.6 req/s (p50 8.14 ms, p99 25.51 ms) | 720.5 req/s (p50 19.44 ms, p99 51.49 ms) | 2.45x |
200 KB (c=1) | 245.1 req/s (p50 4.01 ms, p99 4.80 ms) | 58.5 req/s (p50 15.67 ms, p99 30.29 ms) | 4.19x |
200 KB (c=4) | 939.8 req/s (p50 3.82 ms, p99 10.44 ms) | 70.5 req/s (p50 54.13 ms, p99 89.43 ms) | 13.33x |
See runtime-rs/README.md for full details and reproduction commands.
