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.
How It Works
Section titled “How It Works”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
Automatic Save
Section titled “Automatic Save”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.
Restore on Startup
Section titled “Restore on Startup”When a simulation starts with a name that matches an existing snapshot:
- The snapshot is validated with Zod schemas
- Preloaded boot instances are cleared
- Instances are restored with their exact IDs, operating hours, lifecycle stages, and active faults
- Template run assignments are restored
- Enabled adapters are re-enabled with their persisted configuration
- Spawn counters advance past restored numeric IDs to avoid collisions
The snapshot is authoritative — it replaces any boot-time configuration.
Clearing State
Section titled “Clearing State”Remove persisted state with the reset command:
Reset simulation (remove all instances, keep persistence):
miravo resetReset simulation and clear persisted state:
miravo reset --clear-persistenceOr via the admin API:
curl -s http://127.0.0.1:8080/commands \ -H 'content-type: application/json' \ -d '{"type":"resetSimulation","clearPersistence":true}'Persistence Location
Section titled “Persistence Location”| Config | Default | Description |
|---|---|---|
MIRAVO_HOME | ~/.miravo | Base directory |
| — | $MIRAVO_HOME/state/ | Snapshot directory |
In Docker, mount a volume to preserve state across container restarts:
volumes: - ./miravo-data:/data/miravoenvironment: MIRAVO_HOME: /data/miravoWhat Is Not Persisted
Section titled “What Is Not Persisted”- 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