SYSTEM INTERNALS

KURO 2.0 Master Architecture

Level 2 Autonomous ReAct Agent architecture with AST security boundaries, deterministic verification, and automated self-healing.

# System Layer Diagram

KURO cleanly decouples presentation, intelligence, permission gates, capabilities, and persistence:

ASCII Architecture Map
┌────────────────────────────────────────────────────────────────────────┐
│                        USER / DEVELOPER CLI                            │
└───────────────────────────────────┬────────────────────────────────────┘
                                    │ CLIAdapter / IOHost
                                    ▼
┌────────────────────────────────────────────────────────────────────────┐
│                      CORE AGENT ORCHESTRATION                          │
│                                                                        │
│   • KuroAgent (ReAct State Machine)                                    │
│   • ModelRouter (Gemini › Groq › OpenRouter › OpenAI › Ollama)         │
│   • ContextEngine (Episodic Memory & Token Budget Optimization)        │
└───────────────────────────────────┬────────────────────────────────────┘
                                    │ Safe Action Parser
                                    ▼
┌────────────────────────────────────────────────────────────────────────┐
│                    SECURITY & SANDBOX PERIMETER                        │
│                                                                        │
│   • Permission Gate (SAFE, CONFIRM, DANGEROUS states)                  │
│   • AST Guard (Static inspection: blocks winreg, _ctypes, popen)       │
│   • Windows DPAPI Vault (Zero plaintext credential leaks)              │
│   • Git Stash Safety Net (Automatic snapshot before write operations)  │
└───────────────────────────────────┬────────────────────────────────────┘
                                    │ Whitelisted Invocations
                                    ▼
┌────────────────────────────────────────────────────────────────────────┐
│                     PLUG-AND-PLAY CAPABILITIES                         │
│                                                                        │
│   • Core Tools (FileSystem, Shell, Telemetry, Vision, Browser)         │
│   • Kuro Hub Store (/hub install: tools, plugins, skills, bridges)     │
└───────────────────────────────────┬────────────────────────────────────┘
                                    │ Result Inspection
                                    ▼
┌────────────────────────────────────────────────────────────────────────┐
│                  DETERMINISTIC VERIFICATION & HEALING                  │
│                                                                        │
│   • py_compile AST syntax check & exit code validation                 │
│   • Failure Classifier (10 categories: MISSING_DEPENDENCY, etc.)       │
│   • Automated Repair (auto-pip, mkdir -p, or git-stash rollback)       │
└────────────────────────────────────────────────────────────────────────┘

# Core Module Breakdown

core.agent.KuroAgent

Coordinates the ReAct execution lifecycle: Goal Decomposition → Thought Synthesis → Action Dispatch → Observation Ingestion → Termination Check.

core.model_router.ModelRouter

Routes prompts based on task characteristics (e.g. reasoning vs. low-latency token streaming) and cascades across alternative API providers on HTTP 429 rate limit errors.

core.sandbox.SandboxGuard

Applies Python AST inspection prior to dynamic tool execution. Identifies prohibited AST nodes, unauthorized disk wiping commands (rm -rf, format), and unapproved network calls.

healing.SelfHealingEngine

Autonomous error recovery pipeline. Classifies exceptions into structured diagnostic categories and resolves issues (e.g. installing missing modules or rolling back corrupt diffs) before reporting failure.

# Deterministic Verification & Healing

Passive chat widgets assume an operation succeeded if the language model says so. KURO rejects this assumption:

  • 1. File Presence & Diff Audit: Every created or edited file is immediately validated on disk with stat checks and byte comparison.
  • 2. AST Syntax Compilation: Python source code changes are pre-compiled with py_compile to ensure no broken syntax is committed.
  • 3. Git Safety Rollbacks: If an automated change produces errors, KURO triggers /undo via internal stash checkpoints to restore pristine state.