Run Artifacts & Reproduction
Inside .loki/runs/run_*/: incident.json, network.har, replay.webm, report.html, and the two standalone repro_test.py reproduction scripts.
Run directory structure (`.loki/runs/run_*/`)
Every loki run session creates a timestamped evidence directory .loki/runs/run_YYYYMMDD_HHMMSS/ via IncidentReporter.save_session() containing the following artifacts:
| Flag | Type | Default | Description |
|---|---|---|---|
| incident.json | json | always | Complete structured telemetry: run_id, timestamp, target_url, persona, browser, seed, device, orientation, duration_seconds, crashes, console_errors, http_errors, failed_requests, unhandled_rejections, navigation_errors, resource_failures, unexpected_dialogs, layout_issues, actions_taken, replay_trace, api_faults, concurrency, concurrency_lanes, rules_evaluations, video_file, and har_file. |
| network.har | har | always | Captured HTTP traffic archive passed through NetworkScrubber.scrub_har_file() to redact auth headers, cookies, JWTs, API keys, and sensitive query/body parameters before being saved (the raw temporary HAR is deleted). |
| replay.webm | video | always | Full browser session video recorded by Playwright (1280x720 or the emulated mobile viewport). Open it directly with loki replay --video or watch it inside report.html. |
| report.html | html | --report | Standalone visual HTML dashboard generated by HTMLReporter.generate() with embedded video player, KPI cards, AI business rules scorecard, mobile layout anomalies, and step-by-step action log. |
| repro_test.py | python | on crash or -c > 1 | Self-contained Playwright script synthesized when report.has_crashes is true or report.concurrency > 1. Run it via loki replay [run_id] or python .loki/runs/<run_id>/repro_test.py. |
1. Deterministic Trace Reproduction (`repro_test.py.tmpl`)
For single-session chaos runs (concurrency == 1) that trigger at least one failure, IncidentReporter renders repro_test.py.tmpl with the exact session parameters:
- Embedded
REPLAY_TRACE: Replays every concrete step recorded by the chaos personas (clickwithrepeat/force/delay_ms,fill,press,force_enable_disabled,tamper_hidden,offline, and CDPthrottleviaNetwork.emulateNetworkConditions). If a run did not capture a structured trace, it falls back to a burst of 5 clicks on every visible button. - Deterministic
API_FAULTSroute mocks: IfApiChaosEngineinjected HTTP faults during the session,repro_test.pyregisterspage.route(url, ...)handlers that fulfill those URLs with the exact captured status code, body, and headerx-loki-repro: deterministic_mock. - Browser, device & seed fidelity: Initializes
random.seed(seed), launches the same Playwright engine (chromium,firefox, orwebkit) in headed mode (headless=False), and appliesp.devices[DEVICE_NAME]if a mobile device was emulated. - Exit codes used by
loki replayandCodeHealer: Exits with code1ifpageerror,console.error,requestfailed, ordialogevents are reproduced (💥 CRASH SUCCESSFULLY REPRODUCED!), code0if zero crashes occur (✔ No crashes detected), or code2on script execution error.
2. Concurrency Race Reproduction (`concurrent_repro_test.py.tmpl`)
When loki run executes with --concurrency N (N > 1), IncidentReporter always generates repro_test.py from concurrent_repro_test.py.tmpl (even if no JS exception was thrown, since a race condition often manifests as multiple 200 OK responses rather than a crash):
- Multi-thread
threading.Barrier(CONCURRENCY): SpawnsCONCURRENCYthreads (_lane), each launching its own independent Playwright browser instance, loadingTARGET_URL, resolvingSELECTOR, and waiting atbarrier.wait(timeout=15). - Synchronized click burst: Once all lanes reach the barrier, every browser fires
page.click(selector, timeout=2000, force=True, no_wait_after=True)at the exact same instant. - Idempotency & crash verdict: Counts state-mutating responses (
POST,PUT,PATCH,DELETEwith status< 400) and HTTP>= 500/pageerrorcrashes across all lanes. Exits with code1(💥 RACE CONDITION REPRODUCED) ifall_crashesis non-empty ORsuccess_count > 1, and code0if at most one lane succeeded cleanly.
Terminal
# Replay the latest incident via LOKI CLIloki replay# Replay a specific run_id or open its recorded videoloki replay run_20261022_143000loki replay run_20261022_143000 --video# Or execute the standalone Playwright script directly with Pythonpython .loki/runs/run_20261022_143000/repro_test.py
