← All posts

Trusted TS v0.25.0: Running TypeScript Nobody Has Read at 4.78 KiB per Actor

Inside Engine Contract v20 and Box Contract v24: preemptible Z3-verified TypeScript actors, PikeVM ReDoS immunity, Caps.kv/Caps.crypto, WHATWG SSE, and Linux Landlock/seccomp sandboxes.

Modern server-side TypeScript applications routinely execute two categories of code nobody on your team has read line by line: deeply nested npm dependency trees and AI-authored handler logic. In conventional Node, Deno, or Bun runtimes, a compromised helper or catastrophic regular expression shares ambient access to your process heap, event loop, environment variables, local filesystem, and outbound sockets.

Trusted TS (v0.25.0) splits execution across an explicit, Rust-enforced capability boundary in a 4-crate workspace (tts-kernel → tts-engine → tts-prove → tts) — documented at trusted-ts.robertguss.com.

1. tts (Engine Contract v20): Tiny, Preemptible, Verifiable Actors

Rather than embedding V8 per tenant or trusting arbitrary JS prototypes, tts compiles a strict, prototype-free TypeScript subset into a 41-opcode bytecode VM (held under a strict 45-opcode verification ceiling) with zero runtime syscalls or I/O:

  • Memory density & spin immunity (v0.23.0): 1,000 live stateful actors on a single OS thread consume 8,444 KiB total VmRSS (4.78 KiB / actor marginal overhead over 3,664 KiB baseline). Running under --fuel=2000, an honest actor executing beside concurrent infinite spin and allocation-churn loops maintains 0.049 ms p50 (0.159 ms p99) latency.
  • Linear-time RegExp immunity: Regex literals compile to bounded <= 256-state Thompson NFAs inside a fuel-metered PikeVM (O(|pattern| * |input|)). On EVIL_RE = /^(a+)+$/ with "a".repeat(28) + "!", tts run finishes in 0.157 ms compared to 11,911.430 ms in Node V8 (75,945× faster).
  • Nominal taint & transactional invariants: Branded Secret values (__label) enforce non-interference before public replies leave the actor (tts prove verifies init_invariant, handle_no_panic, inductive_invariant, and allowLabels flow rules in Z3), while failing invariant(state) checks roll back state cleanly at runtime.
  • Typed Caps.kv & Caps.crypto (Engine Contract v20): Actors interact with persistent KV stores and HMAC-SHA256 verification solely through typed capability continuations (from: "kv", from: "crypto"), preserving the 41-opcode VM ceiling.

2. tts-box (Box Contract v24): Durable Host & Linux Sandboxes

tts-box wraps strict tts gatekeeper actors around durable HTTPS/mTLS/MCP endpoints and unmodified npm packages:

  • Linux Landlock v6 + seccomp-BPF + cgroup v2 boxes: Enforces a default 7-day npm cooldown (tts-box add), OSV advisory checks (tts-box audit), --ignore-scripts installs bound by SHA-256 .stamp manifests, read/TCP isolation (net: false or allowlisted), and systemd memory/task quotas.
  • Framework templates & checked watch-reload (v0.25.0): tts-box init <dir> --template=hono|express scaffolds 6 verified policy, manifest, adapter, and route files (policy.ts, policy.test.ts, manifest.json, box/adapter.mjs, box/app/{routes,server}.ts, README.md). During development, tts-box dev runs tts check before every live swap (683.1 ms p50 actor reload / 402.1 ms p50 Linux box app/*.ts fast-sync without re-running npm ci).
  • WHATWG HTTP SSE Streaming & Durable WAL: v0.25.0 ships declarative actor SSE (0.849 ms first-byte p50, 54,167 events/s) and sandboxed box streamBox SSE (0.969 ms first-byte p50, 55,750 events/s), backed by synchronous=FULL SQLite wal_kv, dual-secret prevEnv HMAC rotation, and 28 Prometheus /metrics families.

3. Continuous Verification Scorecard (v0.25.0)

Every release enforces hard formal and empirical gates:

  • External Conformance (trusted-ts-checks): 48 / 48 PASS
  • Workspace Line Coverage: 91.83% (gate >= 90%)
  • Core Architecture Budget (cargo atlas): 49,002 / 50,500 token-lines (0 violations)
  • Kernel & Protocol Proofs: 143 Verus verified, Lean 4 (0 sorryAx), 18 / 18 Kani harnesses, and 6 / 6 @tsmodel specs

Explore the full Verified Escrow CLI Walkthrough (captured directly against v0.23.0 verified_escrow.ts using tts check --json, tts sim --seeds=1..100, and interactive tts run NDJSON turns), read the Benchmarks & Scorecard, inspect Release v0.25.0, or sponsor ongoing work.