Skip to content

Scenario Format

Scenarios are JSON files that describe a time-indexed sequence of sensor states to inject into a connected device. The CLI validates them against the published JSON Schema before running.

Schema URL: https://sensorchaos.com/schema/scenario/1.0

Add "$schema": "https://sensorchaos.com/schema/scenario/1.0" to your file for autocomplete in VS Code and other JSON-aware editors.

FieldTypeRequiredDescription
namestringyesHuman-readable display name
descriptionstringyesOne-sentence description
versionstringyesSchema version — always "1.0"
duration_snumberyesTotal scenario length in seconds
tagsstring[]noSearchable labels (e.g. "spoofing", "logistics")
baselineobjectyesStarting sensor state before the timeline begins
timelinearrayyesOrdered keyframes indexed by at_s
expectobjectnoAssertions evaluated after the run (for CI)

Defines the initial sensor state. The engine emits these values from t=0 until the first timeline entry fires. All fields are optional — omit anything you don’t need for your scenario.

"baseline": {
"location": {
"lat": 51.5074,
"lng": -0.1278,
"accuracy_m": 6,
"satellites": 10,
"altitude_m": 35,
"speed_mps": 0,
"bearing_deg": 0
},
"accelerometer": [0.0, 0.0, 9.81],
"gyroscope": [0.0, 0.0, 0.0],
"magnetometer": [20.0, -5.0, -44.0],
"barometer": [1013.25],
"update_intervals_ms": {
"location": 1000,
"sensors": 50
}
}
FieldTypeDescription
latnumber | nullLatitude in decimal degrees (null = no fix)
lngnumber | nullLongitude in decimal degrees (null = no fix)
accuracy_mnumber | nullHorizontal accuracy in metres
satellitesinteger | nullVisible satellite count
altitude_mnumber | nullAltitude in metres above sea level
speed_mpsnumber | nullGround speed in m/s
bearing_degnumber | nullHeading in degrees (0–360)

baseline.accelerometer / gyroscope / magnetometer

Section titled “baseline.accelerometer / gyroscope / magnetometer”

Three-element array [x, y, z]. Units:

  • Accelerometer — m/s² (gravity component included; at rest: [0.0, 0.0, 9.81])
  • Gyroscope — rad/s
  • Magnetometer — µT

Single-element array [pressure_hPa]. Standard sea-level pressure is 1013.25.

FieldDefaultDescription
location1000GPS update interval in milliseconds
sensors50IMU/barometer update interval in milliseconds
wifi5000Wi-Fi scan interval in milliseconds

An ordered array of keyframes. Each entry has the same sensor fields as baseline, plus:

FieldTypeRequiredDescription
at_snumberyesSeconds from scenario start when this keyframe fires
notestringnoHuman-readable label shown in CLI output and reports

Partial overrides — you only need to include the fields that change. Omitted fields are inherited from the previous keyframe (or baseline).

Linear interpolation — the engine interpolates between consecutive keyframes on each tick (default 1 Hz), so you only need to specify keyframes, not every second.

Signal loss — set lat, lng, accuracy_m (or any sensor field) to null to inject signal absence.

Scenario typeRequired agent?Fields used
GNSS-onlyno (emulator/ADB helper)location only
Multi-sensoryes (--agent)location + accelerometer + gyroscope + magnetometer + barometer

The expect block declares pass/fail assertions that are evaluated automatically after the scenario completes. If any assertion fails, sensorchaos run exits with code 1 — no extra flags needed. This makes it the primary hook for CI pipelines.

"expect": {
"no_crash": true,
"no_signal_loss": false,
"max_position_error_km": 0.5,
"max_injection_errors": 0,
"min_resilience_score": 60
}
FieldTypeDescription
no_crashbooleanFail if any app_crash event was recorded during the run
no_signal_lossbooleanFail if any tick had null GPS (i.e. signal was absent at any point)
max_position_error_kmnumberFail if the maximum haversine distance between injected and reported location exceeds this value (requires agent)
max_injection_errorsintegerFail if the number of agent injection errors exceeds this count
min_resilience_scorenumberFail if the overall resilience score (0–100) is below this threshold

Assertion results are printed after the run:

Assertions (3/3 passed):
✓ no_crash: 0 crashes
✓ max_injection_errors: 0 injection errors
✗ min_resilience_score: 54 (expected ≥ 60)

Validate a scenario file without running it:

Terminal window
sensorchaos validate path/to/my-scenario.json

Exits 0 on success, 1 with detailed error messages on failure. sensorchaos run also validates automatically before starting.