Coach Mission & Grading JSON
Author a flyable, graded mission without touching Swift
This is the real, implemented wire format Coach uses to load a mission script, its grading, and its
objectives checklist from a JSON file — downloadable to the app with no update, by a human or an AI model.
Every kind documented here is read directly off the current importer
(ScriptImport.swift/ScriptImport+Grading.swift/ScriptImport+Objectives.swift
in coach-ios) — if this page and the importer ever disagree, the importer is correct and this
page has a bug. See Maintaining this spec for how to keep
them in sync.
Start here if you're new: read "Anatomy of a mission file" below, then open the worked example — a complete, real, zero-warnings-on-import mission (Multi-Engine Essentials' "Practicing Takeoffs") annotated against every page in this reference.
Anatomy of a mission file
One mission is one JSON file matching ScriptImport.File. triggers is required;
grading and objectives are both optional and independent of each other — a file
with triggers only is a flyable, ungraded mission.
{
"schema_version": 1,
"airport": "KVCB",
"generated_by": "free text, optional — who/what authored this",
"notes": "free text, optional",
"triggers": [ /* required — array of Trigger, see conditions.html / actions.html */ ],
"grading": { "rules": [ /* optional — array of Rule, see grading.html */ ] },
"objectives": [ /* optional — array of Objective, see grading.html#objectives */ ]
}
One trigger
{
"id": "t_fail_1",
"name": "Scenario 1 -- rejected takeoff",
"condition": { "kind": "crosses_speed", "knots": 40, "accelerating": true },
"action": { "kind": "failure", "failure_type": "full", "engine_selection": "random", "probability": 1.0 },
"reminder": { "interval_seconds": 20, "first_text": "...", "repeating_text": "..." },
"audio_clip_id": "optional-explicit-pre-recorded-clip-id"
}
| field | required | meaning |
|---|---|---|
| id | required | a short, author-chosen string, unique in this file. Resolved to a real UUID at import time — referenced by after_trigger_id, not_before_trigger_id, rearm_trigger_ids, and grading's own trigger_id fields. |
| name | optional, default "" | the trigger's display name in the app's cue card / debrief UI. Also what objectives[].for_trigger matches against (by name, not id). |
| condition | required | one Condition object. |
| action | required | one Action object. |
| reminder | optional | a repeating spoken nag while this trigger is still waiting — interval_seconds, first_text, repeating_text, all required together. Never recorded as a fired trigger, never touches grading. |
| audio_clip_id | optional | an explicit pre-recorded clip id this trigger's spoken line should play, bypassing the per-lesson recorded-voice catalog lookup entirely. |
A dropped trigger silently breaks everything chained after it. The importer fails soft
— an unresolvable condition/action (unknown kind, missing required field, a vspeed_ref not
set on the pilot's aircraft profile, a reference to an id that doesn't exist) drops that one trigger with
a warning rather than crashing the whole file. But anything else that chains off that trigger's id via
after_trigger_id/not_before_trigger_id/rearm_trigger_ids will never
fire either. Always check import warnings, not just that the file parsed.
IDs, names & references
Three different reference styles exist in this format, deliberately — know which one each field uses:
- Trigger
idreferences (after_trigger_id,not_before_trigger_id,after_trigger_ids,rearm_trigger_ids, grading'strigger_id/start_trigger_id/end_trigger_id/payload_trigger_id/read_trigger_id, awindow_start/window_endboundary's owntrigger_id) all resolve against the sameid→UUID map built once from this file's owntriggersarray — a hand-authored Swift script has none of these in JSON form (it resolves grading by triggernameinstead, seeGoOldSchoolGrading.swift-style graders), but a JSON-authored script always uses realids for this. - Objective
for_triggermatches a trigger'sname(string equality), not itsid— the one exception. See Objectives. - Order in the
triggersarray matters for forward references: a trigger referenced byafter_trigger_id/not_before_trigger_id/etc. must appear earlier in the array than the trigger that references it (the id map is built once up front, but a reference to a trigger not yet declared is still a mistake worth avoiding by convention — every real worked example in this app follows chronological order).
Vspeed-relative thresholds
Any condition field expecting a literal speed in knots can instead be given relative to the pilot's own aircraft profile, resolved at import time:
{ "kind": "crosses_speed", "vspeed_ref": "vr", "vspeed_offset_kts": 1, "accelerating": true }
vspeed_ref is a key into AircraftProfile.value(for:) — vr,
vmc, vyse, vs0, vs1, vsse, vxse,
vle, vlo, vlr, vfe, vne, va,
vref. vspeed_offset_kts (default 0) adds to the resolved value before
comparing — "Vr + 1 kt," "Vmc exactly." A referenced V-speed the pilot's current profile has left unset is a
hard import warning and the whole trigger is dropped — never a silent fallback to 0.