Skip to content

Latest commit

 

History

History
85 lines (59 loc) · 3.96 KB

File metadata and controls

85 lines (59 loc) · 3.96 KB

Architecture

This document summarizes how the Interactive Reversible Debugger (IRD) is structured and how execution and reversal work at a high level.

High-level diagram

flowchart TB
  subgraph ui [React UI]
    Index[Index page]
    Panels[ControlPanel StateViewer Graphs Quantum]
    Index --> Panels
  end

  subgraph exec [Execution]
    Backend[ExecutionBackend]
    Engine[executionEngine executeCode]
    SafeExpr[safeExpression]
    Backend --> Engine
    Engine --> SafeExpr
  end

  subgraph data [Persistence optional]
    Supa[Supabase client]
    DebugSvc[debuggerService]
    Supa --> DebugSvc
  end

  Index --> Backend
  Index --> DebugSvc
Loading

Frontend application

Execution pipeline

  1. ExecutionBackend (src/lib/executionBackend.ts)
    Abstraction over “run this source and emit states.” The default implementation delegates to executeCode.

  2. executeCode (src/lib/executionEngine.ts)
    Line-oriented simulation: walks source lines, maintains a simple call stack model, emits ExecutionState snapshots (variables, line, object graph, memory estimate).

    Options include:

    • targetLine — stop after a bounded forward run (used for stepping).
    • signalAbortSignal to cancel long runs (e.g. when leaving the page or stopping playback).
    • stepDelayMs — delay between steps (wired to the UI “execution speed” slider).
  3. Numeric expressions
    Assignment right-hand sides that look like pure arithmetic are evaluated with evaluateSafeNumericExpression. There is no general JavaScript interpreter in the browser build.

  4. Reversal in the UI
    “Step back” navigates within the already recorded ExecutionState[] array. True instruction-level reverse execution is not implemented; see Reversible execution model.

Object graph and visualization

Sandboxed numeric evaluation (optional path)

Reversible execution model

Helpers in src/lib/reversibleExecutionModel.ts describe an immutable snapshot timeline. The product’s current user-visible reversal is snapshot replay (index into history), aligned with “event sourcing lite”: forward execution appends states; backward moves the cursor without re-running the engine backward.

A future milestone would add explicit inverse operations or bytecode with guaranteed semantic reverse (memory vs fidelity tradeoff).

Configuration

Related reading

  • SUPABASE.md — database tables and RLS expectations.