SafeScript: a Turing-incomplete JS subset lets agent policies replace code review

uriwa · reddit · 2026-09-27

The author argues code review is broken for AI agents: they pull in third-party skills or synthesize code at runtime, and sandboxes only contain the OS — they can't stop prompt injection or poisoned packages from exfiltrating credentials.

His answer is SafeScript, a Turing-incomplete subset of JavaScript with no unbounded loops, no recursion, and a closed instruction set. Every program compiles to a static DAG, and the compiler extracts a full mathematical proof before execution: every external host contacted, every env var read, worst-case memory bounds, and complete data flow from inputs to hosts. You never review code — you review and approve a policy (e.g., GITHUBTOKEN may only reach api.github.com); violations halt before a single line runs.

Since programs provably terminate and lack dangerous primitives (no eval, filesystem, or shell), it runs directly in your process with zero VM overhead, zero cold starts, and sub-millisecond execution. Open-source repo and playground linked in comments.

Original post →

More from coding & agent

coding & agent channel →