Skip to content

Overview ​

Ouro is a self-hosted Luau 0.748 lexer, lossless parser, bytecode compiler, and sandboxed register VM written in pure --!strict Luau. It runs in Roblox and standalone Luau without loadstring, FFI, or native plugins.

luau
--!strict
local Ouro = require("./ouro")

local ok, result = Ouro.run("local x = ...; return x * 2 + 2", {
	preset = "strict",
}, 20)
assert(ok and result == 42)

Pipeline Architecture ​

text
Luau Source ──▶ Ouro.parse ──▶ ParseResult (Flat Arena)
                                      │
                                      ▼
                               Ouro.compile ──▶ Binary Bytecode (v3–v14) / ProtoModule
                                                       │
                                                       ▼
                               Ouro.Bytecode.verify ──▶ Ouro.run / Ouro.sandbox / Ouro.load

Each stage can be used independently. Precompiled bytecode never loads the parser or compiler, and parsing or compiling never loads the VM.

Which API Should I Use? ​

Use CaseEntrypointDefault Safety / Speed
Run untrusted text onceOuro.runSafe by default ("balanced" preset), returns (ok, ...)
Run multiple scripts under one policyOuro.sandboxSafe by default, reusable :run / :load / :fork / :reset
Load trusted or custom-guarded chunksOuro.loadIsolated env, fast @native loop unless budgets/hooks set
Run precompiled binary or IROuro.VM.loadBytecode / loadProtoSkips parser and compiler completely
Compile source or AST to bytecodeOuro.compile / Ouro.compileResultO0–O2 compiler matching Luau 0.748
Parse, lint, or rewrite sourceOuro.parse / parseExpression / parseTypeFlat numeric arena, :text(), :formatDiagnostics(), :reconstruct()
Verify, decode, or disassemble bytecodeOuro.BytecodeUniform (okOrValue?, err?) contract across v3–v14

See Choosing an Entrypoint for side-by-side trade-offs against Roblox loadstring, Fiu, and LuauCeption.

Core Principles ​

1. Pure & Portable Luau ​

Every stage from lexing through VM execution runs in standard --!strict Luau on both Roblox and standalone Luau hosts. Differential conformance suites verify parser, compiler, bytecode, and VM parity against pinned upstream C++ 0.748. Type inference, incremental reparsing, and native machine code generation stay outside this package.

2. Safe High-Level Defaults, Uncoupled Low-Level Primitives ​

Ouro.run and Ouro.sandbox apply explicit named presets ("strict", "balanced", "trusted" in Ouro.PRESETS) so untrusted execution has budgets, allocation limits, and directive clamping without boilerplate. Low-level Ouro.load, VM.loadBytecode, and VM.loadProto stay uncoupled and run on the unguarded @native dispatch loop unless you explicitly configure limits or hooks.

3. Flat Arenas & Lossless Reconstruction ​

The parser writes syntax nodes into flat numeric Structure-of-Arrays buffers (kinds, starts, finishes) using zero-based half-open byte offsets, so traversing large scripts does not build nested node tables. Opting into lossless = true records a compact lexical tape for exact reconstruct() output, and ParseResult includes :text(nodeId), :formatDiagnostic(diag), and :formatDiagnostics() for tooling.

4. Lazy Submodule Loading ​

Requiring the root module loads types and a thin lazy loader facade. Heavy submodules (Ast, Profiles, Tokens, Kinds, Compiler, Bytecode, VM, and PRESETS) load on first property access and cache on the package table, keeping cold require fast when you only use part of the pipeline.

NOTE

When cloning Ouro's ModuleScript in Roblox Studio, keep the cloned instance parented until every needed submodule has been accessed. Ouro.VM loads its internal helpers on first access, so destroying a cloned package after requiring Ouro.VM stays safe for precompiled bytecode.

Where to Go Next ​

Begin with Getting Started to install Ouro and run your first sandboxed script, or open the Cookbook for task-focused Roblox and tooling recipes. For deep stage-by-stage references, read Parsing & AST, Compiling & Bytecode, Sandboxed VM, and Security & Sandbox, or compare runtime performance in Benchmarks.