GreyOS Documentation

Understanding the Recursive Symbolic Execution OS

GreyOS Overview

GreyOS is a fully symbolic operating system where all applications, interfaces, files, time, and sound are expressed and executed via recursive symbolic structures.

The core principle of GreyOS is universal absorption—the ability to transform any existing code, interface, or data into the Grey format, creating a unified platform for all computing.

Key Features

  • Recursive Symbolic Execution - Execute symbolic expressions recursively, allowing for unprecedented flexibility and power in computation
  • Universal Absorption - Convert external formats to Grey format, enabling interoperability with existing software
  • WebAssembly Integration - Seamlessly run and wrap WASM modules, leveraging the growing ecosystem of WASM applications
  • Security by Design - Built-in sandboxing via GreyShield, ensuring that applications run in isolation with controlled access to system resources

System Architecture

GreyOS consists of several core components that work together to provide a complete operating environment:

┌─────────────────────────────────────────────────┐
│                  Applications                    │
├─────────────────────────────────────────────────┤
│                Grey Shell & UI                   │
├───────────────┬───────────────┬─────────────────┤
│    GreyVM     │   GreyShield  │      GreyFS     │
│  (Execution)  │  (Security)   │   (Storage)     │
├───────────────┴───────────────┴─────────────────┤
│                  Grey Compiler                   │
├─────────────────────────────────────────────────┤
│             Host System (WASM/Native)           │
└─────────────────────────────────────────────────┘
                        

Each component has a specific role:

  • GreyVM: The virtual machine responsible for symbolic execution of Grey code
  • GreyFS: A symbolic file system that represents all data as Grey structures
  • GreyShield: The security layer that enforces permissions and sandboxing
  • Grey Compiler: Handles conversion between external formats and Grey code
  • Grey Shell & UI: Provides user interface and command-line interaction
  • Applications: Grey programs that run on top of the OS infrastructure

Grey Language

Grey is a symbolic language designed specifically for recursive symbolic execution. Its syntax resembles a blend of functional and procedural programming paradigms.

Basic Syntax

// Function definition
fn hello(name) {
  return "Hello, " + name + "!"
}

// Main entry point
fn main() {
  render(Scene {
    title: "Grey Application",
    body: [
      Text("Welcome to Grey!"),
      Button("Say Hello", fn() {
        print(hello("World"))
      })
    ]
  })
}

Key Concepts

  • Symbolic References: All entities in Grey are symbolic and can be manipulated as data
  • Recursive Execution: Functions can generate code that is executed recursively
  • Declarative UI: User interfaces are described as symbolic structures

GreyVM

The Grey Virtual Machine (GreyVM) is responsible for executing Grey code through recursive symbolic evaluation. Unlike traditional VMs that execute bytecode, GreyVM works with symbolic structures directly.

Execution Model

GreyVM uses a recursive evaluation strategy:

  1. Parse Grey code into symbolic expressions
  2. Evaluate expressions by recursively expanding symbols
  3. Apply transformations based on pattern matching
  4. Execute the resulting operations

Core VM Functions

  • eval(expr): Evaluates a symbolic expression
  • bind(symbol, value): Binds a value to a symbol in the current scope
  • expand(expr): Expands all symbols in an expression
  • absorb(code, format): Converts external code to Grey symbols

GreyFS

GreyFS is the symbolic file system that stores all data in GreyOS. Unlike traditional file systems that store raw bytes, GreyFS stores symbolic representations of data.

Key Features

  • Symbolic Storage: Files are stored as symbolic expressions
  • Content Addressing: Files can be addressed by content or by path
  • Versioning: Built-in versioning for all files
  • Transformations: Files can be transformed on-the-fly

Basic Operations

// Read a file
let content = read("/apps/hello.grey")

// Write to a file
write("/user/notes/note1.grey", "This is a note")

// List directory contents
let files = ls("/apps")

// Search for files
let results = find("*.grey")

GreyShield

GreyShield is the security component of GreyOS that enforces permissions and sandboxing for applications.

Permission Model

GreyShield uses a fine-grained permission model:

  • File Access: Read, write, execute permissions for specific paths
  • Network Access: Control over which network resources an app can access
  • UI Permissions: Control over which UI elements an app can create/modify
  • Process Control: Limitations on process creation and management

Sandboxing

Each application runs in its own sandbox with:

  • Isolated memory space
  • Resource limitations (CPU, memory, storage)
  • Controlled access to system resources

Universal Absorption

Universal Absorption is the process of converting external code and data formats into Grey symbolic format.

Supported Formats

  • JavaScript: Convert JS to Grey for seamless execution
  • HTML/CSS: Transform web interfaces to Grey UI
  • JSON/XML: Convert data formats to Grey structures
  • Binary Formats: Wrap binary data in Grey abstractions

Absorption Process

  1. Parse external format into intermediate representation
  2. Map concepts to Grey equivalents
  3. Generate Grey code
  4. Optimize the result
// Absorb JavaScript code
let grey_code = absorb("function hello() { return 'Hello, World!'; }", "js")

// Absorb HTML
let grey_ui = absorb("

Title

Content

", "html")

WebAssembly Integration

GreyOS provides native support for WebAssembly (WASM) modules, allowing them to be executed directly or wrapped as Grey applications.

WASM Execution

WASM modules can be executed in two ways:

  • Direct Execution: Run WASM modules directly with minimal overhead
  • Grey Wrapping: Wrap WASM modules in Grey code for deeper integration

Integration API

// Load a WASM module
let module = load_wasm("/apps/calculator.wasm")

// Create a wrapped Grey application
let app = wrap_wasm(module, {
  exports: ["add", "subtract", "multiply", "divide"],
  ui: {
    title: "Calculator",
    elements: [
      // UI definition for the WASM calculator
    ]
  }
})

API Reference

GreyOS provides a comprehensive set of APIs for developers:

Core APIs

  • GreyVM API: Functions for symbolic execution and manipulation
  • GreyFS API: File system operations
  • GreyShield API: Security and permission management
  • Grey UI API: User interface components and rendering

Example: UI API

// Create a simple UI
render(Scene {
  title: "Example App",
  body: [
    Text("Hello, World!"),
    Button("Click Me", fn() {
      print("Button clicked!")
    }),
    TextInput("name", "Enter your name"),
    Button("Submit", fn() {
      print("Hello, " + get("name") + "!")
    })
  ]
})

Tutorials

Explore tutorials to learn how to develop for GreyOS: