Built for the AI era · Humans & Agents

Software AI agents can write, and humans can actually trust.

AI can now generate thousands of lines of glue code in seconds, but reviewing it, sandboxing it, and keeping long-running workflows from breaking in production is a nightmare. StateScript gives teams and agents one small, verifiable language that enforces permissions, survives crashes cleanly, and cuts codebase size in half.

-54.8%
Less code across 208 real OSS ports
7.9 KB
Avg sandboxed .wasm binary
147/208
Ports faster than V8 in native LLVM (1.53× med)
0
Runtime npm dependencies
 deploy-gate.st ✓ VERIFIED · Run live →
// Permissions are explicit. Budgets cannot be escalated.
use fs, sh
policy ci = budget(fuel: 50000, time: 30s), caps(fs: "ro")

var approved = false
view canShip: bool = approved

// Proven BEFORE a single line runs in production:
invariant !(inState(deploying) && !canShip)
eventually inState(live) || inState(aborted) || inState(timedOut)

state review {
  on approve { approved = true } -> deploying
  on reject                      -> aborted
  after 24h                      -> timedOut
}

state deploying {
  entry {
    transact {
      unwind { sh.run("rollback-release") }
      res = try sh.run("deploy-prod")
      if res.ok { -> live } else { -> aborted }
    }
  }
}
PROOF: PASS (all states checked) .WASM: 4.8 KB SANDBOX: fs:ro DURABLE: JSON snapshot
The Skeptic’s Question

“Why on earth do we need another programming language?”

You don’t need another syntax for writing for-loops. You need a way to ship reliable automation when AI agents are writing code, touching real systems, waiting hours for humans, and burning through context windows. Here is what breaks with general-purpose glue code, and what StateScript solves out of the box.

01 · Strict Sandboxing

Agents can’t go rogue, even if they hallucinate

Giving an LLM bash or Python means trusting a prompt not to touch production. In StateScript, every file declares the exact permissions it needs (use fs) and runs under monotonic policy limits inside a WebAssembly sandbox that can tighten budgets, never widen them.

Inspectable .wasm capability manifest checked before the first instruction runs.
02 · Real Durability

Pause for 5 seconds or 5 days, with no replay traps

Long-running workflows crash, deploy mid-flight, or wait 24 hours for a human click. Instead of replaying code from line 1 and exploding on nondeterminism, StateScript pauses into a tiny, inspectable JSON snapshot and resumes right where it stopped, with transact + unwind automatic rollback on failure.

Try clicking “Simulate Crash & Restore” live in the Playground.
03 · Half the Code

Less for humans to review. Fewer tokens for agents to burn.

Verbose boilerplate slows down human code review and fills AI context windows with noise. Compact pipelines (|), pattern matching, and first-class states cut real production libraries by more than half while eliminating entire classes of bugs.

Measured on 208 real OSS ports: 38,032 → 17,206 SLOC (-54.8%), complexity -26.4%.
04 · Tiny & Fast Everywhere

Zero-dependency WASM in browsers, native LLVM speed on servers

One source file compiles directly to a ~7.9 KB sandboxed .wasm module (with zero C toolchain required) or to a standalone ~47.1 KB Full-LTO LLVM native binary that outperforms Node/V8 on the majority of real workloads.

Beats V8 outright on 147 / 208 libraries (median 1.53× faster).
05 · Proofs, Not Just Spot Checks

Catch the one-in-a-million edge case before it ships

Unit tests only check the paths someone remembered to write, while AI-generated code loves hiding bugs in rare retry, timeout, or approval sequences. StateScript automatically checks every reachable state before deployment and exports 1:1 proofs to Lean 4, TLA+, and Z3 so critical rules are proven true, not just hoped true.

Try breaking approved = true in the Playground to watch the checker catch it.
06 · Auditable by Humans

Every file draws its own state diagram and wire spec

Reviewing AI-written code shouldn’t mean reverse-engineering tangled callbacks. Every StateScript module auto-generates clear Mermaid state diagrams, produces RFC-style ASCII packet diagrams from declarative binary frame and grammar rules, and embeds its exact permission manifest into the binary.

See it live on this site’s own HTTP/2 server (website/server.st · Live Stats).
Real-World Before & After

What teams actually replace with StateScript

Pick a real scenario to compare typical production glue code against one verifiable StateScript module.

Typical Agent Tool Loop (Python / TS + 5 MCP calls)~18,000 tokens burned
# 1. Agent calls list_files() -> dumps 400 paths into context
# 2. Agent calls read_file() 12 times -> 60 KB raw code in context
# 3. Runs unsandboxed shell with full env vars & write access
# 4. No hard fuel/time cap; runaway loop burns $$$
files = glob.glob("src/**/*.ts", recursive=True)
results = []
for f in files:
    txt = open(f).read() # hope prompt didn't ask for /etc/passwd!
    lines = txt.count("\n")
    if lines > 100:
        results.append({"path": f, "lines": lines, "bytes": len(txt)})
results.sort(key=lambda r: -r["lines"])
print(json.dumps(results[:5]))
StateScript (1 sandboxed .wasm call)~180 tokens · fs:ro enforced
use fs

policy audit = budget(fuel: 50000, calls: 200, time: 5s),
               caps(fs: "ro")

return under audit {
  fs.glob("src/**/*.ts")
    | map(fs.read(.))
    | where(.lines > 100)
    | select("path", "lines", "bytes")
    | sort(-.lines)
    | take(5)
}
Bulk file text never enters LLM context Run in Playground →
Why it matters: The host enforces caps(fs: "ro") and fuel: 50000 at the WASM boundary, so even a prompt-injected agent literally cannot write files, leak secrets, or infinite-loop.
Typical Async Workflow + Manual CompensationHalf-applied state on crash
// Forget one finally/catch branch and inventory stays locked forever
let reserved = false;
try {
  await reserveInventory(orderId);
  reserved = true;
  await chargeCard(orderId);
  await sendReceipt(orderId);
} catch (err) {
  if (reserved) {
    try { await releaseInventory(orderId); } catch {}
  }
  throw err;
}
StateScript (transact + unwind)Atomic state + LIFO undo
transact {
  reserved += amount
  unwind { releaseInventory(orderId) }

  charge = try chargeCard(orderId)
  if !charge.ok { return err(charge.error) }
  charged += amount
}
Durable vars auto-rollback + unwind runs only on failure Run in Playground →
Why it matters: unwind executes only when a scope fails or rolls back, keeping cleanup right next to the action it undoes, while transact snapshots and restores durable variables automatically.
Upstream Open-Source JS/TS LibrariesHeavy boilerplate + edge-case bugs
NodeRedis/node-redis-parser : 370 SLOC (bare CR smuggling bug)
websockets/ws frame parser  : 522 SLOC (JS Buffer state sprawl)
nats-io/nats.js protocol    : 704 SLOC (167 cyclomatic complexity)
motdotla/dotenv parser      : 302 SLOC (prototype & escape quirks)
sindresorhus/quick-lru      : 258 SLOC (2x hidden memory overhead)
StateScript Ports (Verified + Faster in Native LLVM)-55% SLOC · 147/208 beat V8
redis-parser.st  :  97 SLOC (-74%) ·  7.5 KB .wasm · strict CRLF
ws-frame.st      : 107 SLOC (-80%) · 12.8 KB .wasm · RFC 6455 guard
nats-protocol.st : 127 SLOC (-82%) ·  7.0 KB .wasm · 31 CC (-81%)
dotenv.st        :  90 SLOC (-70%) ·  5.4 KB .wasm · 2.74× vs V8
quick-lru.st     :  98 SLOC (-62%) ·  6.6 KB .wasm · exact cap inv
Real tested ports, not toy Fibonacci benchmarks Explore all 208 ports →
Why it matters: Every claim on this page is backed by 208 permissively licensed open-source libraries ported, parity-tested, and benchmarked against their upstream V8 implementations.
Real Evidence, Not Micro-Benchmarks

208 Real Open-Source Libraries Ported & Measured

Live data exported directly from corpus/benchmarks.sqlite.

Explore Full 208-Library Table →
Library Category SLOC Compression .wasm Size Native Bin LLVM vs V8
Loading live corpus metrics…
Get Started in 30 Seconds

Zero dependencies. One CLI. Compiles to WASM or Native.

Requires Node 22+ (zero npm runtime packages). Add Clang/LLVM only if you want standalone native binaries.

git clone https://github.com/visionik/statescript && cd statescript && node src/cli.ts verify examples/11-verified-deploy.st
Try in Browser Playground → Read Introduction AI Agent Primer (SKILL.md)