Skip to content

Persistence

Preserve simulation state across restarts with Miravo's snapshot system — instances, lifecycle stages, active faults, adapters, and template assignments.

Miravo persists simulation state to disk so restarts resume where they left off.

State is saved as a JSON snapshot at ~/.miravo/state/{simulationName}.json (or $MIRAVO_HOME/state/). The snapshot captures:

  • All active instances with their IDs, browse paths, and parameters
  • Operating hours and lifecycle stage per instance
  • Active faults per instance
  • Template run assignments
  • Enabled adapters and their configuration

Miravo debounces structural changes and writes a snapshot when:

  • Instances are spawned or removed
  • Templates are loaded or unloaded
  • Adapters are enabled or disabled
  • The simulation stops gracefully

A boot snapshot is written immediately after startup reconciliation, before the first tick.

When a simulation starts with a name that matches an existing snapshot:

  1. The snapshot is validated with Zod schemas
  2. Preloaded boot instances are cleared
  3. Instances are restored with their exact IDs, operating hours, lifecycle stages, and active faults
  4. Template run assignments are restored
  5. Enabled adapters are re-enabled with their persisted configuration
  6. Spawn counters advance past restored numeric IDs to avoid collisions

The snapshot is authoritative — it replaces any boot-time configuration.

Remove persisted state with the reset command:

Reset simulation (remove all instances, keep persistence):

Terminal window
miravo reset

Reset simulation and clear persisted state:

Terminal window
miravo reset --clear-persistence

Or via the admin API:

Terminal window
curl -s http://127.0.0.1:8080/commands \
-H 'content-type: application/json' \
-d '{"type":"resetSimulation","clearPersistence":true}'
ConfigDefaultDescription
MIRAVO_HOME~/.miravoBase directory
$MIRAVO_HOME/state/Snapshot directory

In Docker, mount a volume to preserve state across container restarts:

volumes:
- ./miravo-data:/data/miravo
environment:
MIRAVO_HOME: /data/miravo
  • Current member values (regenerated from generators on each tick)
  • RNG state (seeded RNG is deterministic from the seed, but exact sequence position is not saved)
  • In-flight MQTT messages or OPC UA subscriptions