LOKI LogoLOKIv1.10.0

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:

FlagTypeDefaultDescription
incident.jsonjsonalwaysComplete 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.harharalwaysCaptured 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.webmvideoalwaysFull 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.htmlhtml--reportStandalone 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.pypythonon crash or -c > 1Self-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 (click with repeat/force/delay_ms, fill, press, force_enable_disabled, tamper_hidden, offline, and CDP throttle via Network.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_FAULTS route mocks: If ApiChaosEngine injected HTTP faults during the session, repro_test.py registers page.route(url, ...) handlers that fulfill those URLs with the exact captured status code, body, and header x-loki-repro: deterministic_mock.
  • Browser, device & seed fidelity: Initializes random.seed(seed), launches the same Playwright engine (chromium, firefox, or webkit) in headed mode (headless=False), and applies p.devices[DEVICE_NAME] if a mobile device was emulated.
  • Exit codes used by loki replay and CodeHealer: Exits with code 1 if pageerror, console.error, requestfailed, or dialog events are reproduced (💥 CRASH SUCCESSFULLY REPRODUCED!), code 0 if zero crashes occur (✔ No crashes detected), or code 2 on 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): Spawns CONCURRENCY threads (_lane), each launching its own independent Playwright browser instance, loading TARGET_URL, resolving SELECTOR, and waiting at barrier.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, DELETE with status < 400) and HTTP >= 500 / pageerror crashes across all lanes. Exits with code 1 (💥 RACE CONDITION REPRODUCED) if all_crashes is non-empty OR success_count > 1, and code 0 if at most one lane succeeded cleanly.
Terminal
# Replay the latest incident via LOKI CLI
loki replay
# Replay a specific run_id or open its recorded video
loki replay run_20261022_143000
loki replay run_20261022_143000 --video
# Or execute the standalone Playwright script directly with Python
python .loki/runs/run_20261022_143000/repro_test.py