Skip to content

Trusted TS

A TypeScript engine for running code nobody has read — preemptible, formally verified TypeScript actors (`tts`) paired with Linux Landlock/seccomp/cgroup v2 capability boxes and a durable HTTPS/mTLS/MCP host (`tts-box`).
4.78 KiB
Marginal VmRSS per live actor (8.44 KiB total at 1,000 actors)
0.049 ms
Median turn latency beside hostile spin & alloc loops
143 · 18/18
Verus verified · Kani harnesses · Lean 4 (0 sorryAx)
91.98%
Workspace line coverage · 42/42 conformance

Modern TypeScript applications increasingly combine AI-authored logic with deep npm dependency trees exposed to supply-chain attacks. Conventional JavaScript runtimes grant every dependency ambient access to memory, CPU, disk, environment variables, and sockets.

trusted-ts splits execution across a strict capability boundary in a 4-crate Rust workspace (tts-kernel → tts-engine → tts-prove → tts):

1. tts — Strict Engine & Z3 Verifier

Compiles a deterministic, prototype-free TypeScript subset to a 41-opcode bytecode VM with zero runtime I/O, buddy-allocated memory regions, instruction-fuel preemption, transactional invariant(state) rollback, and incremental Z3 proofs with SARIF 2.1.0 & SHA-256 certificates.

Explore tts architecture →

2. tts-box — Durable Host & Capability Boxes

Cross-platform (Linux + macOS) strict actor host serving TLS 1.2/1.3 & mTLS HTTP/1.1, Streamable HTTP MCP 2025-03-26, SQLite WAL durability with replay, and Prometheus /metrics—plus Linux Landlock v6, 64-bit seccomp-BPF, and cgroup v2 boxes for unmodified npm packages.

Explore tts-box host →

Example: Verified Stateful Actor (corpus/verified_escrow.ts)

Section titled “Example: Verified Stateful Actor (corpus/verified_escrow.ts)”

tts prove verifies init_invariant, handle_no_panic, inductive_invariant, Floyd-Hoare /** @invariant ... */ loops, and __label taint non-interference before a single request runs:

type SecretBrand = { readonly __label?: "secret" };
type Secret = string & SecretBrand;
type State = {
available: number;
locked: number;
settled: number;
totalDeposited: number;
txCount: number;
};
export function invariant(state: State): boolean {
return (
state.available >= 0 &&
state.locked >= 0 &&
state.settled >= 0 &&
state.txCount >= 0 &&
state.totalDeposited <= 1000000000 &&
state.txCount <= 1000000000 &&
state.available + state.locked + state.settled === state.totalDeposited
);
}

Because tts compiles every RegExp literal to a bounded <= 256-state Thompson NFA executed in a fuel-metered PikeVM (O(|pattern| * |input|)), exponential backtracking (EVIL_RE = /^(a+)+$/ on "a".repeat(N) + "!") never stalls your event loop:

Evil Regex ReDoS Check (/^(a+)+$/ on 'a'.repeat(28) + '!')

End-to-end execution latency (ms)

Lower is better
tts run (Thompson NFA / PikeVM)0.157 ms · O(N) · 75,945x faster
Node V8 (backtracking engine)11,911.430 ms · Exceeds > 13 hours at N = 40