Complete architecture documentation for the Codex AI-Native OS project.
- CPU: x86_64/ARM64, 16+ cores
- GPU: NVIDIA (CUDA 12), AMD (ROCm), Intel (oneAPI)
- Memory: DDR4/DDR5, 64GB+, NUMA-aware
- Storage: NVMe SSD, PCIe 4.0
AI Scheduler (ai_scheduler.ko):
- GPU-aware process scheduling
- Priority boost for AI tasks
- Real-time latency optimization
/proc/ai_schedulerinterface
AI Memory (ai_mem.ko):
- 256MB pinned memory pool
- 4KB block allocation
- Zero-copy GPU transfers
/proc/ai_memorystatistics
AI GPU (ai_gpu.ko):
- Direct GPU DMA control
- PCI device management
- Kernel-space GPU launches
/proc/ai_gpumonitoring
AI Driver (ai_driver.sys):
- WDM/KMDF filter driver
- Thread priority boost
- Non-paged memory pool
- ETW performance tracing
- GPU utilization monitoring
- Inference latency histogram
- Real-time performance metrics
- BCC/bpftrace integration
Codex Core (codex-rs/core/):
- AI assistant engine
- Sub-agent orchestration
- Deep research capabilities
- MCP server integration
CLI (codex-rs/cli/):
- Command-line interface
- TUI (Terminal UI) with GPU stats
- Configuration management
- Session handling
- Plan mode support
- CUDA acceleration
Tauri GUI (codex-rs/tauri-gui/):
- React + Three.js frontend
- VR/AR integration (Quest 2/3/Pro, Vision Pro)
- 4D Git visualization
- Real-time GPU monitoring
- Hand tracking support (Quest 3/Pro)
Type-safe Rust APIs:
ai-scheduler-rs: Scheduler logicgpu-bindings: GPU operationscodex-ai-kernel-integration: /proc parsercodex-win-api: Windows driver API
Backend (Rust + axum):
- REST API (13 endpoints)
- WebSocket real-time updates
- Git history analysis
- Collaboration features
Frontend (React + Three.js):
- 3D/4D visualization
- GPU-accelerated rendering (120fps)
- Timeline slider
- Search/Filter/Bookmarks
- VR/AR mode (WebXR)
- Hand tracking (Quest 3/Pro)
- Passthrough AR (Quest 3)
- Eye tracking (Quest Pro)
Desktop (Electron):
- System tray integration
- Auto-updater
- Native notifications
- Cross-platform (Windows/Mac/Linux)
Application
↓ (syscall or library call)
User Space API
↓ (/proc write or ioctl)
Kernel Module
↓ (GPU scheduling decision)
AI Scheduler
↓ (pinned memory allocation)
AI Memory
↓ (DMA transfer)
AI GPU
↓ (PCIe)
GPU Hardware
↓ (computation)
Result
↓ (DMA back)
Application
Git Repository
↓ (git2 crate)
Backend Analyzer
↓ (REST API)
Frontend React
↓ (Three.js)
GPU Rendering
↓ (Canvas)
User Display
.git/ Directory Change
↓ (notify crate)
File Watcher
↓ (WebSocket)
Frontend
↓ (React state update)
3D Scene Update
- Zero-copy Transfers: Pinned memory eliminates CPU↔GPU copies
- GPU-aware Scheduling: Scheduler knows GPU availability
- Direct DMA: Kernel bypasses user-space for GPU access
- NUMA Awareness: Memory allocated close to GPU
- InstancedMesh: 99.9% reduction in draw calls
- LOD System: Detail based on camera distance
- Web Workers: Background computation
- Data Streaming: Pagination and SSE
- Capability checks:
CAP_SYS_ADMINrequired - Input validation: All user inputs validated
- Memory safety: Bounds checking, NULL checks
- SELinux/AppArmor: Security module integration
- Type safety: Rust prevents memory errors
- No unsafe: Minimal unsafe code, all documented
- Sandboxing: Electron app sandboxed
- HTTPS: All network communication encrypted
// User space reads kernel stats via /proc
let stats = KernelModuleStats::read()?;
println!("GPU Utilization: {}%", stats.scheduler.unwrap().gpu_utilization_percent);// Frontend fetches data via REST API
const commits = await axios.get('/api/commits');
// Real-time updates via WebSocket
const ws = new WebSocket('ws://localhost:3030/api/realtime');
ws.onmessage = (event) => {
const update = JSON.parse(event.data);
// Update 3D scene
};// Electron app monitors kernel
window.electronAPI.onOpenRepo((path) => {
// Start monitoring repository
// Kernel modules optimize in background
});- Multi-GPU: Support for multiple GPUs
- NUMA: Optimal memory placement
- Thread pool: Parallel processing
- Distributed: Future Redis/PostgreSQL support
- Load balancing: Multiple backend instances
- Caching: Result caching for repeated queries
- Meta Quest 2: WebXR, 90Hz, Controller-based, Virtual Desktop
- Meta Quest 3: WebXR, 120Hz, Hand tracking, Color passthrough, Depth API
- Meta Quest Pro: WebXR, 90Hz, Eye tracking, Face tracking, Hand tracking
- Apple Vision Pro: visionOS, RealityKit, Spatial Computing, Hand/Eye tracking
- SteamVR: PCVR support, Virtual Desktop, High refresh rate
- Hand Tracking: Quest 3/Pro native hand tracking API
- Passthrough AR: Quest 3 color passthrough with depth sensing
- Eye Tracking: Quest Pro eye tracking for foveated rendering
- Face Tracking: Quest Pro face tracking for avatars
- Spatial Anchors: AR position anchoring for persistent overlays
- Rust CI (
rust-ci.yml): Multi-platform builds, Clippy lint, Format check, Test execution - Release CI (
release.yml): Binary generation, npm packaging, GitHub Releases - Security CI: cargo-audit, CVE scanning, Dependency checks
- Docs CI: README validation, Documentation checks, Link verification
- Windows (x64, ARM64)
- macOS (x64, ARM64)
- Linux (x64, ARM64, musl)
Planned enhancements:
- Distributed Kernel: Multi-node GPU scheduling
- Cloud Integration: Kubernetes GPU operator
- Mobile: React Native visualizer
- WebAssembly: Client-side computation
- gRPC: High-performance RPC
- GPU LLM Inference: TensorRT/vLLM integration (v2.2.0)
Maintained by: zapabob
License: Apache 2.0 (user-space), GPL v2 (kernel modules)
Version: 2.1.0