Skip to content

Nox Runtime Documentation

Nox is a purpose-built sandbox runtime designed to execute untrusted code safely and efficiently. It combines the security guarantees of a capability-based, zero-trust architecture with the performance of a register-based virtual machine. Written in Kotlin and targeting JVM 25+, Nox can be distributed as a JVM library (JAR), a standalone native binary (via GraalVM Native Image), or a shared library (C ABI) for embedding in any language.

Unlike traditional sandboxes that rely on OS-level isolation (containers, VMs), Nox allows for permission to be granted on a per-call basis, with no implicit permissions. This provides a more secure and flexible environment for executing untrusted code. Compared to other sandbox runtimes, Nox is easily extensible with a powerful three-tier plugin system and can be easily adapted into any existing application.

DocumentDescription
Architecture OverviewThe Host-Sandbox model and system topology
Security ModelZero-trust, capability-based security philosophy
Compilation PipelineFrom source code to bytecode execution
DocumentDescription
Memory ModelDual-bank registers, sliding window frames, and memory lifecycle
Instruction SetThe 64-bit instruction layout and opcode reference
Super-InstructionsIntent-based opcodes: HMOD, HACC, SCONCAT
Error HandlingTable-driven zero-cost exception handling
Resource GuardsWatchdogs, instruction limits, and memory caps
DocumentDescription
Language OverviewIntroduction to NSL syntax and semantics
Type SystemPrimitives, structs, arrays, and the json type
Functions & Control FlowFunctions, UFCS, default params, varargs, and streaming
Standard LibraryNamespaced libraries and built-in type methods
DocumentDescription
Plugin Development GuideThree-tier plugin model: built-in, native (C ABI), and Nox imports
FFI InternalsMethodHandle linking (JVM) and C ABI bridging (native)
DocumentDescription
Compiler OverviewFour-phase pipeline, design decisions, file map
AST DesignKotlin sealed class hierarchy with 47 node types for expressions, statements, and declarations
Semantic AnalysisThree-pass type resolution, UFCS chain, null checks, control flow validation
Code GenerationRegister allocation, bytecode emission, constant pools, exception tables
Bytecode DisassemblyThe .noxc pretty-printed format for debugging and test assertions
DocumentDescription
nox RunnerCLI runner with interactive permission/resource prompts, plugins
noxc CompilerCLI compiler for .noxc disassembly generation

See Testing Strategy for info on unit tests, integration tests, E2E golden tests, coverage targets.

DocumentDescription
Program File FormatThe .nox file structure and metadata headers
GlossaryTerminology and definitions
@tool:name "hello_world"
@tool:description "A simple greeting program."
main(string name = "World") {
return `Hello, ${name}!`;
}

Save as hello_world.nox and run:

Terminal window
$ nox run hello_world.nox --name "Alice"
Hello, Alice!
  1. Zero Trust: All code is assumed potentially malicious. No implicit permissions.
  2. Do the Heavy Thinking Once: The compiler handles all analysis; the VM is a fast executor.
  3. Opcode Compression: One complex instruction beats ten simple ones.
  4. Sandbox Everything: No reflection, no direct host access, no escape hatches.
  5. Extensibility Without Compromise: Plugins get the same performance as built-ins.

Safe execution for code you didn't write, whether it came from a developer, a plugin, or an AI.