LOKI LogoLOKIv1.10.0

Architecture

How the safety gate, chaos sandbox, passive detectors, evidence scrubber, AI brain, and CodeHealer fit together.

Overview

LOKI System Architecture
authorizedDOM / netfindings + HARincident.jsonRCA + patchrepro_test.py → verify or rollback
01cli.py · safety.py
CLI & Safety Gate
safety.pyconfig.yamlloki auth
02sandbox.py · personas.py
Chaos Sandbox & Swarm
4 PersonasApiChaosBarrier(N)
03detectors.py
7 Passive Detectors
JS & 4xx/5xxMobile LayoutUI Freeze
06healer.py · replayer.py
Auto-Healing (Healer)
.loki.bakUnified DiffAuto-Rollback
05brain.py · chat.py
AI Brain (LiteLLM)
rules.mdRCA Diagnosisloki chat
04reporter.py · scrubber.py
Evidence & Repro
incident.jsonnetwork.harrepro_test.py
02Chaos Sandbox & Swarm(sandbox.py · personas.py · api_chaos.py)
Click any node in the diagram to inspect

Launches isolated Playwright browsers (Chromium, Firefox, WebKit & mobile devices), drives the 4 chaos personas, injects in-flight HTTP/Auth faults, and coordinates Barrier(N) race probes.

rage-clickernovice-chaoticnetwork-tormentoradversaryApiChaosEngineBarrier(N)

Core Modules

FlagTypeDefaultDescription
cli.py & safety.pyEntry & Auth GateAlways activeParses Typer CLI commands, resolves .loki/config.yaml and .loki/models.json, and enforces ensure_target_authorized() before any browser session starts.
sandbox.py & personas.pyChaos EnginePlaywrightLaunches isolated Chromium, Firefox, or WebKit contexts (desktop or emulated mobile devices), drives the 4 chaos personas (rage-clicker, novice-chaotic, network-tormentor, adversary), and orchestrates --concurrency race probes.
api_chaos.pyNetwork & Auth Faults30% fault rateIntercepts XHR/fetch traffic in-flight to inject 5xx errors, corrupt JSON, artificial latency, stripped keys, and 401/403/cookie-eviction auth faults.
detectors.py7 Passive DetectorsReal-timeMonitors JS exceptions & unhandled rejections, network 4xx/5xx & failed requests, unexpected dialogs, error pages, broken resources, mobile layout overflow, and UI main-thread freezes.
reporter.py, scrubber.py & reproducer.pyEvidence & Repro.loki/runs/run_*/Redacts secrets from network.har (NetworkScrubber), writes incident.json, replay.webm, and report.html, and generates deterministic Playwright reproduction scripts (repro_test.py).
brain.py & healer.pyAI Brain & CodeHealerLiteLLMEvaluates .loki/rules.md at the end of the session (PASSED / VIOLATED), diagnoses root causes, synthesizes surgical code patches with <file>.loki.bak backups, and verifies fixes via repro_test.py.