AutolangDocs
System Architecture

System Architecture

This document explains how Autolang executes AI-generated code. It does not focus on language syntax or APIs, but on runtime responsibilities, execution boundaries, and system ownership.

System Overview

The LLM is responsible only for producing source code. From that point onward, execution becomes entirely deterministic and is controlled by the compiler, VM, and host application.

User │ ▼ Prompt │ ▼ LLM Model │ ▼ Autolang Compiler │ ▼ Autolang VM │ Native Bindings │ ▼ Host Application │ Business Systems

Runtime Ownership Matrix

Clear boundaries separate non-deterministic code generation from deterministic execution, capability dispatch, and authority ownership:

ComponentSystem Ownership
LLMSource code generation
CompilerStatic validation & bytecode compilation
VMExecution, stack interpreter & resource budgeting
BindingsCapability dispatch & parameter marshaling
Host ApplicationAuthority, credentials & budget configuration
Business SystemsPersistent enterprise data & side effects

Execution Pipeline

Every execution flows sequentially through distinct system boundaries:

01

LLM Code Generation

InputPrompt + Capability signatures
OutputAutolang Source Script

Generates orchestration text. The LLM's task finishes completely once the source code is produced.

02

Compiler Validation

InputAutolang Source Script
OutputValidated Bytecode Chunk

Performs lexing, parsing, import symbol resolution, static type checking, and bytecode emission. Rejects invalid code before execution starts.

03

VM Execution

InputBytecode Chunk + Resource Budgets
OutputCapability Call / Evaluation Output

Executes instructions via stack interpreter. Enforces opcode budgets, tracks VM heap allocations, and traps runtime exceptions.

04

Host Capability Dispatch

InputVM Stack Arguments
OutputBusiness Data Result

Native bindings unwrap parameters and delegate invocation to host application functions under host authority.

Compiler vs. VM Responsibilities

The compiler and VM maintain strict division of labor between static analysis and dynamic execution:

Compiler (Static Analysis)VM (Dynamic Execution)
Parse source text into ASTExecute bytecode instructions
Static type check & null safetyEvaluate stack opcodes
Build binary bytecode chunkTrack instruction opcode budget
Validate @import library declarationsInvoke native capability bindings
Reject invalid code pre-runProduce execution output buffer

Host Application Responsibilities

Autolang is not a standalone server — the host application (Node.js or C++) acts as the embedding server and central authority. Host responsibilities include:

Capability Registration

Registers explicit capabilities via registerBuiltInLibrary().

Authority & Credentials

Holds all database sockets, API keys, and environment secrets safely outside the VM.

Business Logic Execution

Executes core enterprise logic (CRM, ERP, Mail) when native bindings are invoked.

Resource Governance Config

Configures opcode limit caps (e.g. 100,000 opcodes) and file/HTTP security rules.

Capability Boundary

Authority lives in code you write and control. Autolang scripts never hold authority directly — credentials stay inside the host, bindings own capability access, and scripts only invoke capabilities granted to them.

Host Application (Owns credentials, DB sockets, API keys) │ ▼ Bindings (Expose capability methods) │ ▼ Capabilities (Declared interfaces) │ ▼ Autolang VM Sandbox (Stack interpreter, resource limits) │ ▼ AI Script (Untrusted orchestration logic)

Host Session Lifecycle

The lifecycle of a compiler and VM session inside an embedding application follows a clean, deterministic pattern:

Create Compiler Instance (ACompiler.create()) │ ▼ Register Native Libraries & Capabilities │ ▼ Compile Script (Static validation & bytecode build) │ ▼ Execute VM (Stack evaluation under opcode budget) │ ▼ Reset VM State (Clear output & stack pointers) │ ▼ Compile Next Script ──or──▶ Dispose Compiler