Skip to content

alazndy/R-AI-OS

Repository files navigation

⚑ R-AI-OS: The AI OS Kernel

R-AI-OS Logo

A Hardened, LLM-Native OS Kernel for Autonomous Agent Swarms

Version Rust License Security

Vision β€’ Security Kernel β€’ Core Modules β€’ VS Code Extension β€’ Quick Start β€’ CLI β€’ Roadmap


πŸ”­ The Vision

R-AI-OS is not just a CLI tool β€” it is a Kernel. While traditional operating systems manage hardware, R-AI-OS manages the AI layer: a decentralized swarm of 90+ autonomous specialists running across Claude Code, Gemini CLI, and any MCP-compatible agent.

It solves the fundamental problem of unsupervised agent execution: agents that run unchecked can leak secrets, corrupt files, and make network calls they shouldn't. R-AI-OS sits between the human and the swarm as a hardened control plane β€” enforcing policies, auditing every action, and managing context economics.

Human β†’ [ R-AI-OS Kernel ] β†’ Agent Swarm (Claude / Gemini / MCP)
              ↓
    [Security Kernel] [Context Manager] [Swarm Mesh] [Hybrid UI]

πŸ›‘οΈ Security Kernel (v2.0.0-alpha)

The Security Kernel is the core of R-AI-OS. It enforces a zero-trust model for all agent tool calls: every action is policy-gated, logged, and auditable. All 4 phases are complete and tested (239/239 tests green).

Architecture

src/security/
β”œβ”€β”€ sandbox.rs       # Filesystem Jail β€” canonicalize + boundary enforcement
β”œβ”€β”€ policy.rs        # Policy Manager β€” TOML-based allow/deny/confirm engine
β”œβ”€β”€ verify_chain.rs  # Audit Chain β€” SHA-256 hash-chained SQLite ledger
└── egress.rs        # Egress Filter β€” domain allowlist/blocklist, fail-closed

Phase 1 β€” Filesystem Jail

Prevents agents from reading or writing outside their designated workspace boundary. Uses path canonicalization to defeat traversal attacks.

# raios-policy.toml
[sandbox]
enabled = true
workspace_root = "/home/user/projects/my-app"

Phase 2 β€” Policy Manager

Every MCP tool call passes through a policy gate before execution. Rules are defined in raios-policy.toml and evaluated in order.

[tools]
default = "allow"

[[tools.rules]]
tool = "bash"
action = "confirm"   # requires human approval

[[tools.rules]]
tool = "write_file"
path_glob = "/etc/**"
action = "deny"

Fail-closed by design: confirm rules in daemon/stdio mode deny by default β€” no interactive prompt means no silent execution.

Phase 3 β€” Audit Chain

Every allow/deny decision is written to a tamper-evident, SHA-256 hash-chained SQLite ledger. Each entry links to the previous entry's hash β€” any tampering is immediately detectable.

raios verify-chain          # verify full chain integrity
raios verify-chain -n 50    # show last 50 entries then verify

Phase 4 β€” Egress Filter

Domain-level allowlist/blocklist for any HTTP/HTTPS calls made via MCP tools. Fail-closed: unrecognized domains are denied unless explicitly allowed.

[egress]
mode = "allowlist"
allowed = ["api.anthropic.com", "api.openai.com", "*.github.com"]

Redaction Engine

Automatically masks sensitive values (API keys, GCP secrets, PII patterns) before they appear in logs or are forwarded to Sentry. Built on regex with 20+ detection patterns.

Sentry Observability

Production-grade error tracking with contextual breadcrumbs and automatic panic capture. Every unhandled crash sends a structured report with session context.


🧠 Core Modules

🎯 Unified Agent Router

Maps natural-language task descriptions to the right specialist using local BM25 + vector hybrid indexing. Bridges Maestro (39 agents) and ECC (48 agents) ecosystems natively.

πŸ“‰ Token Budgeter & Context Manager (Cortex)

  • Sigmap: Up to 97% token reduction via high-density signature mapping (SIGMAP.md)
  • BM25 persistence: Index survives restarts via mtime-based invalidation
  • Vector store: Binary SQLite BLOBs β€” transaction-safe, no JSON drift
  • Session memory: Per-agent memory.md auto-append

πŸ”„ Agent Swarm Mesh

Parallel worktree-based agent execution with coordination primitives:

  • Lock Manager: File and task-level locks with priority levels (User > Agent > Automation)
  • Radar Whispers: Real-time context hints pushed to all connected agents (compile errors, security alerts, architectural violations)
  • Factory Mode: Submit heavy jobs async; completion fires broadcast + optional webhook

πŸ”Œ Tri-Protocol Interface

All three protocols share one event bus:

  • TCP :42069 β€” Daemon IPC (UUID token auth, mandatory handshake)
  • TCP :42070 β€” MCP-over-TCP (agent tool calls, policy-gated)
  • CLI β€” Direct commands (raios <command>)

πŸ“Š Portfolio Intelligence

  • Neural Search: Semantic search across 140+ projects with BM25 + embeddings
  • Health Scanner: Background scan for memory.md compliance, security leaks, git drift
  • GitHub Sync: Live star counts and last-commit timestamps
  • Auto-Discovery: Detects new workspace directories and updates entities.json automatically

πŸ–₯️ VS Code Extension (v0.4.0)

R-AI-OS ships a native VS Code extension that turns the IDE into a Hybrid UI β€” combining the real-time power of the TUI with the rich surface of the IDE.

vscode-extension/
β”œβ”€β”€ src/extension.ts    # Extension host + TokenBridge proxy
β”œβ”€β”€ src/sidebar/        # Webview Kanban dashboard (Geist Sans + glassmorphism)
└── raios-0.4.0.vsix    # Packaged extension

Features:

  • Activity Bar icon β€” raios-sidebar-view panel always visible
  • Kanban Dashboard β€” Read-only project status, health scores, active tasks
  • TokenBridge Proxy β€” Extension host proxies all daemon requests with Bearer token; the session token never touches the Webview context (XSS-safe)
  • Status Bar β€” Live daemon connection indicator

Install:

code --install-extension vscode-extension/raios-0.4.0.vsix

πŸš€ Quick Start

git clone https://github.com/alazndy/R-AI-OS.git
cd R-AI-OS
cargo install --path . --force

Start the daemon (background process that powers the TUI and MCP server):

aiosd

Launch the TUI:

raios

Bootstrap your AI factory (replicates 90+ agents and 180+ skills):

raios bootstrap

πŸ’» CLI Reference

Core Operations

Command Description
raios health Portfolio health dashboard β€” scans all projects
raios health <project> Single-project health scan
raios search "<query>" Semantic search across portfolio
raios new "ProjectName" Scaffold a new project (follows MASTER rules)
raios task "<description>" Route to best agent or specific one
raios bootstrap Replicate AI factory on a new machine

Git Operations

Command Description
raios git status Git status across portfolio
raios git log Recent commits
raios git diff Staged/unstaged diff
raios git commit Intelligent bulk commit

Security

Command Description
raios verify-chain Verify audit log hash-chain integrity
raios verify-chain -n <N> Show last N entries then verify
raios security OWASP security scan

Build & Dev

Command Description
raios build Build current project
raios test Run test suite
raios deps Dependency audit
raios env Environment variable scan

Agent Swarm

Command Description
raios swarm start Start a parallel agent worktree
raios swarm list List active swarm tasks
raios swarm approve <id> Approve a pending swarm diff

Analysis

Command Description
raios rbj --project <name> Red-Blue-Judge audit cycle

πŸ“ Project Structure

src/
β”œβ”€β”€ bin/
β”‚   β”œβ”€β”€ raios.rs          # CLI entrypoint
β”‚   └── aiosd.rs          # Daemon entrypoint
β”œβ”€β”€ app/
β”‚   └── events/           # Event handling (actions, keyboard, commands)
β”‚       └── keyboard/     # Keyboard module (6 sub-modules)
β”œβ”€β”€ cli/                  # CLI command implementations
β”œβ”€β”€ core/
β”‚   β”œβ”€β”€ build/            # Build logic (10 sub-modules, language-specific)
β”‚   └── deps/             # Dependency management (10 sub-modules)
β”œβ”€β”€ cortex/               # Vector store, BM25 index, session memory
β”œβ”€β”€ daemon/               # aiosd background daemon
β”œβ”€β”€ intelligence/         # Agent routing, instinct engine, RBJ
β”œβ”€β”€ mcp/                  # MCP server β€” policy-gated tool call handler
β”œβ”€β”€ search/               # Neural search (BM25 + vector hybrid)
β”œβ”€β”€ security/             # Security Kernel (sandbox, policy, chain, egress)
β”œβ”€β”€ sentinel/             # Redaction engine, Sentry integration
β”œβ”€β”€ server/               # HTTP/WebSocket server (Axum)
β”œβ”€β”€ swarm/                # Parallel worktree agent management
└── ui/
    └── panels/           # TUI panels (13 modules β€” dashboard, security, etc.)

πŸ—ΊοΈ Roadmap

  • Phase 1–7: Core TUI, workspace mapping, health dashboard, BM25 search
  • Phase 8: Universal Kernel β€” Tri-protocol, Lock Manager, Radar Whispers, Factory Mode
  • Phase 9: Refactor & Modularization β€” all large files split into focused modules
  • Phase 10: Hardened Kernel Alpha β€” Sentry, Redaction Engine, Audit Ledger
  • Phase 10B: Security Kernel (Faz 1–4) β€” Sandbox + Policy + Audit Chain + Egress βœ…
  • Phase IDE: Hybrid UI β€” VS Code Sidebar WebView + TokenBridge Proxy βœ…
  • Phase 11: Tool Pinning & Drift Detection β€” MCP tool manifest hashing, supply chain tamper detection
  • Phase 12: Secret Leasing β€” raios secret grant <tool> <ENV_VAR> with TTL-based auto-revoke
  • Phase 13: Rate Limiting β€” Tool call frequency limiter for AI loop spam protection
  • Phase 14: Quarantine Mode β€” Isolate suspicious agent calls, require human approval
  • Phase 15: Write-Back Bridge β€” Sidebar Kanban β†’ memory.md task state sync

πŸ”— Research References

  • vigils β€” Agent control plane (Filesystem Jail, Egress Filter, Policy Manager, Hash-Chain)
  • ruvos β€” Agentic OS memory architecture reference
  • bash-agent β€” Lightweight agent worker patterns
  • agent-skills β€” Engineering discipline and agent verification
  • needle β€” Ultra-fast local function calling

R-AI-OS is the bridge between human creativity and autonomous execution. πŸ¦ΎπŸ›‘οΈβš”οΈ