Guide

Worked example: Multi-Engine Essentials Mission 1

"Practicing Takeoffs" — 3 engine-failure scenarios (a rejected takeoff before rotation, a gear-down abort at rotation, a full engine-out "Drill" at 500 ft AGL), real grading on each, crash-retry-give-up branching, and success/give-up outcome signaling. Authored entirely in this JSON file — no new Swift was written for the mission itself, only the generic primitives this reference documents. The real file: coach-ios/CoachApp/Resources/multi-engine-essentials.mission1.json. It imports with zero warnings and is covered by Tests/CoachCoreTests/MultiEngineEssentialsMission1Tests.swift.

Walkthrough

1. Welcome, then a composite "ready for takeoff" wait

t_welcome speaks on after_start. t_ready_1 is a 4-way all_of: engine mode is multi (app_state), idle airspeed (ias_at_most), both engines spun up (rpm_at_least_all_engines), and aligned with a runway end (near_runway_end) — no single condition kind could express this on its own.

2. Scenario 1 — rejected takeoff, reusing an existing grader

t_fail_1's action is a plain failure with "grade_against": "abort-take-off-multi" — the control-order checklist grading comes FREE from the existing ProcedureFlowCatalog mechanism, already engine-identity-aware. The mission only adds two NEW continuous checks on top of that free grading: centerline_deviation and stopped_before_runway_end, both windowed between the failure trigger and a "stopped" trigger (ias_at_most again, as a level check — not a held condition, which would be unnecessary risk for a one-sample-of-slop tolerance here).

3. Scenario 2 — same grader, plus a gear check

The failure condition is itself an all_of: crossing Vr+1 (crosses_speed with vspeed_ref) AND already airborne (agl_at_least). Grading adds window_percent_in_tolerance on gear_down_fraction — "the gear never came up" is the EXISTING percentage rule, not a new kind.

4. Scenario 3 — The Drill, and a continuous airspeed curve

Failure fires crossing Vyse above 500 ft AGL, graded against drill-engine-out-multi (the 10-step identify/verify/feather checklist, free again) plus a new airspeed_penalty_curve — 0% at Vmc, 25% at Vmc+5, 100% at blue line.

5. Crash, retry once, give up on the second crash

"Crashed" needs no new primitive — crosses_agl at 0 ft, not before the failure fired. t_crash_3's action increment_counters a counter. t_retry_3_rearm is gated on not (counter_at_least 2) and rearm_triggers the whole scenario-3 chain. Note the retry/give-up beats each split into TWO sibling triggers sharing one literal condition block — a single trigger carries exactly one action, so "speak a line" and "rearm" need separate triggers even though they fire at the same instant.

6. Success or give-up, signaled generically

Reaching pattern altitude (crosses_agl at 1000 ft, climbing) leads to complete_mission with "outcome": "success". The second crash instead leads to the same action with "outcome": "gave_up" — one generic signal, two different author-chosen outcome keys.

Judgment calls made authoring this file, flagged in its own "notes" field: pattern altitude uses AGL rather than a fixed indicated altitude (independent of field elevation, so the mission can launch from any ground_start airport); a short after_trigger(seconds: 3) guard was added to each re-armed "ready for takeoff" wait, purely to stop it from re-satisfying on the SAME tick the previous scenario's stop trigger fires.

The full file

{
  "schema_version": 1,
  "airport": "KVCB",
  "generated_by": "multi-engine-essentials-phase3",
  "notes": "MultiEngine Mission 1 -- Practicing Takeoffs. See coach-ios/CoachApp/Resources/multi-engine-essentials.mission1.json for the full, current notes field.",
  "triggers": [
    { "id": "t_welcome", "name": "Welcome",
      "condition": { "kind": "after_start", "seconds": 1 },
      "action": { "kind": "message", "speak": true,
        "text": "Welcome aboard. Today we're going to practice rejected takeoffs and engine failures in a multi-engine airplane. Let's get into position and get started." } },

    { "id": "t_ready_1", "name": "Ready for takeoff",
      "condition": { "kind": "all_of", "conditions": [
        { "kind": "app_state", "state_key": "engine_mode_multi" },
        { "kind": "ias_at_most", "knots": 5 },
        { "kind": "rpm_at_least_all_engines", "rpm_at_least": 500 },
        { "kind": "near_runway_end", "within_ft": 500, "aligned_tolerance_deg": 20 }
      ] },
      "action": { "kind": "message", "speak": true, "text": "You're ready for takeoff." } },

    { "id": "t_brief_1a", "name": "Scenario 1 briefing",
      "condition": { "kind": "after_trigger", "after_trigger_id": "t_ready_1", "seconds": 1 },
      "action": { "kind": "message", "speak": true,
        "text": "Heads up -- I'm going to give you an engine failure before you rotate. If it happens, this is a rejected takeoff: throttle or throttles to idle, use the rudder for directional control, and brake to a stop on the runway." } },

    { "id": "t_brief_1b", "name": "Scenario 1 PTT ask",
      "condition": { "kind": "after_trigger", "after_trigger_id": "t_brief_1a", "seconds": 8 },
      "action": { "kind": "message", "speak": true, "text": "Key your mic when you're ready for me to arm the failure." } },

    { "id": "t_ptt_1", "name": "PTT confirm -- scenario 1",
      "condition": { "kind": "ptt_pressed" },
      "action": { "kind": "message", "speak": true, "text": "Copy. Standing by." } },

    { "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,
        "grade_against": "abort-take-off-multi" } },

    { "id": "t_stopped_1", "name": "Stopped -- scenario 1",
      "condition": { "kind": "all_of", "conditions": [
        { "kind": "ias_at_most", "knots": 2 },
        { "kind": "after_trigger", "after_trigger_id": "t_fail_1", "seconds": 0 }
      ] },
      "action": { "kind": "noop" } },

    { "id": "t_debrief_1", "name": "Debrief -- scenario 1",
      "condition": { "kind": "after_trigger", "after_trigger_id": "t_stopped_1", "seconds": 2 },
      "action": { "kind": "message", "speak": true, "text": "Nicely handled. Taxi back and let's go again." } },

    { "id": "t_ready_2", "name": "Ready for takeoff -- scenario 2",
      "condition": { "kind": "all_of", "conditions": [
        { "kind": "ias_at_most", "knots": 5 },
        { "kind": "rpm_at_least_all_engines", "rpm_at_least": 500 },
        { "kind": "near_runway_end", "within_ft": 500, "aligned_tolerance_deg": 20 },
        { "kind": "after_trigger", "after_trigger_id": "t_debrief_1", "seconds": 3 }
      ] },
      "action": { "kind": "message", "speak": true, "text": "You're ready for takeoff again." } },

    { "id": "t_s2_brief", "name": "Scenario 2 briefing",
      "condition": { "kind": "after_trigger", "after_trigger_id": "t_ready_2", "seconds": 1 },
      "action": { "kind": "message", "speak": true,
        "text": "This time the failure comes right at rotation, and I want you to leave the gear right where it is -- don't raise it. Pull the throttles to idle and expect to brake hard. I hope you picked a runway long enough for your accelerate-stop distance." } },

    { "id": "t_fail_2", "name": "Scenario 2 -- gear-down abort at rotation",
      "condition": { "kind": "all_of", "conditions": [
        { "kind": "crosses_speed", "vspeed_ref": "vr", "vspeed_offset_kts": 1, "accelerating": true },
        { "kind": "agl_at_least", "feet": 5 }
      ] },
      "action": { "kind": "failure", "failure_type": "full", "engine_selection": "random", "probability": 1.0,
        "grade_against": "abort-take-off-multi" } },

    { "id": "t_stopped_2", "name": "Stopped -- scenario 2",
      "condition": { "kind": "all_of", "conditions": [
        { "kind": "ias_at_most", "knots": 2 },
        { "kind": "after_trigger", "after_trigger_id": "t_fail_2", "seconds": 0 }
      ] },
      "action": { "kind": "noop" } },

    { "id": "t_debrief_2", "name": "Debrief -- scenario 2",
      "condition": { "kind": "after_trigger", "after_trigger_id": "t_stopped_2", "seconds": 2 },
      "action": { "kind": "message", "speak": true, "text": "Nicely handled again. Taxi back and let's go one more time." } },

    { "id": "t_ready_3", "name": "Ready for takeoff -- scenario 3",
      "condition": { "kind": "all_of", "conditions": [
        { "kind": "ias_at_most", "knots": 5 },
        { "kind": "rpm_at_least_all_engines", "rpm_at_least": 500 },
        { "kind": "near_runway_end", "within_ft": 500, "aligned_tolerance_deg": 20 },
        { "kind": "after_trigger", "after_trigger_id": "t_debrief_2", "seconds": 3 }
      ] },
      "action": { "kind": "message", "speak": true, "text": "You're ready for takeoff for the last scenario." } },

    { "id": "t_s3_brief", "name": "Scenario 3 briefing -- The Drill",
      "condition": { "kind": "after_trigger", "after_trigger_id": "t_ready_3", "seconds": 1 },
      "action": { "kind": "message", "speak": true,
        "text": "This last one happens after you're already climbing, about five hundred feet above the ground. Stay on blue line the whole way up, and follow the drill exactly, in order: mixtures forward, props forward, throttles forward, flaps up, gear up. Then identify -- dead foot, dead engine. Verify by pulling that engine's throttle to idle -- if anything changes on the other engine, you pulled the wrong one, so stop and reassess before you touch anything else. Feather the dead engine, and keep climbing at blue line up to pattern altitude." } },

    { "id": "t_s3_ptt_ask", "name": "Scenario 3 PTT ask",
      "condition": { "kind": "after_trigger", "after_trigger_id": "t_s3_brief", "seconds": 16 },
      "action": { "kind": "message", "speak": true, "text": "Key your mic when you're ready for this one." } },

    { "id": "t_ptt_3", "name": "PTT confirm -- scenario 3",
      "condition": { "kind": "ptt_pressed" },
      "action": { "kind": "message", "speak": true, "text": "Copy. Standing by." } },

    { "id": "t_fail_3", "name": "Scenario 3 -- The Drill",
      "condition": { "kind": "all_of", "conditions": [
        { "kind": "crosses_speed", "vspeed_ref": "vyse", "accelerating": true },
        { "kind": "agl_at_least", "feet": 500 }
      ] },
      "action": { "kind": "failure", "failure_type": "full", "engine_selection": "random", "probability": 1.0,
        "grade_against": "drill-engine-out-multi" } },

    { "id": "t_tpa_reached", "name": "Reached pattern altitude",
      "condition": { "kind": "crosses_agl", "feet": 1000, "climbing": true, "not_before_trigger_id": "t_fail_3" },
      "action": { "kind": "message", "speak": true,
        "text": "That's your first engine failure in a multi-engine airplane. There's a lot going on there, especially the asymmetric yaw -- nice work." } },

    { "id": "t_mission_complete_success", "name": "Mission complete",
      "condition": { "kind": "after_trigger", "after_trigger_id": "t_tpa_reached", "seconds": 0 },
      "action": { "kind": "complete_mission", "outcome": "success" } },

    { "id": "t_crash_3", "name": "Crash -- scenario 3",
      "condition": { "kind": "crosses_agl", "feet": 0, "climbing": false, "not_before_trigger_id": "t_fail_3" },
      "action": { "kind": "increment_counter", "counter_id": "s3_crash_count" } },

    { "id": "t_retry_3_msg", "name": "Retry -- scenario 3",
      "condition": { "kind": "all_of", "conditions": [
        { "kind": "after_trigger", "after_trigger_id": "t_crash_3", "seconds": 1 },
        { "kind": "not", "condition": { "kind": "counter_at_least", "counter_id": "s3_crash_count", "count": 2 } }
      ] },
      "action": { "kind": "message", "speak": true, "text": "Let's reset to the beginning of the runway and try that scenario again." } },

    { "id": "t_retry_3_rearm", "name": "Retry rearm -- scenario 3",
      "condition": { "kind": "all_of", "conditions": [
        { "kind": "after_trigger", "after_trigger_id": "t_crash_3", "seconds": 1 },
        { "kind": "not", "condition": { "kind": "counter_at_least", "counter_id": "s3_crash_count", "count": 2 } }
      ] },
      "action": { "kind": "rearm_triggers", "rearm_trigger_ids": [
        "t_ready_3", "t_s3_brief", "t_s3_ptt_ask", "t_ptt_3", "t_fail_3", "t_tpa_reached", "t_crash_3"
      ] } },

    { "id": "t_give_up_3_msg", "name": "Give up -- scenario 3",
      "condition": { "kind": "counter_at_least", "counter_id": "s3_crash_count", "count": 2 },
      "action": { "kind": "message", "speak": true, "text": "Let's take a break there -- we'll come back to this." } },

    { "id": "t_give_up_3_complete", "name": "Give up complete -- scenario 3",
      "condition": { "kind": "counter_at_least", "counter_id": "s3_crash_count", "count": 2 },
      "action": { "kind": "complete_mission", "outcome": "gave_up" } }
  ],
  "grading": {
    "rules": [
      { "id": "r_centerline_1", "label": "Scenario 1 -- centerline tracking during the rejected takeoff",
        "kind": "centerline_deviation", "runway_width_ft": 75,
        "window_start": { "kind": "trigger", "trigger_id": "t_fail_1" },
        "window_end": { "kind": "trigger", "trigger_id": "t_stopped_1" } },

      { "id": "r_stopped_1", "label": "Scenario 1 -- stopped before the runway end",
        "kind": "stopped_before_runway_end", "runway_length_ft": 5000,
        "window_start": { "kind": "trigger", "trigger_id": "t_fail_1" },
        "window_end": { "kind": "trigger", "trigger_id": "t_stopped_1" } },

      { "id": "r_centerline_2", "label": "Scenario 2 -- centerline tracking during the rejected takeoff",
        "kind": "centerline_deviation", "runway_width_ft": 75,
        "window_start": { "kind": "trigger", "trigger_id": "t_fail_2" },
        "window_end": { "kind": "trigger", "trigger_id": "t_stopped_2" } },

      { "id": "r_stopped_2", "label": "Scenario 2 -- stopped before the runway end",
        "kind": "stopped_before_runway_end", "runway_length_ft": 5000,
        "window_start": { "kind": "trigger", "trigger_id": "t_fail_2" },
        "window_end": { "kind": "trigger", "trigger_id": "t_stopped_2" } },

      { "id": "r_gear_2", "label": "Scenario 2 -- gear stayed down",
        "kind": "window_percent_in_tolerance", "field": "gear_down_fraction", "target": 1.0, "tolerance": 0,
        "comparison": "at_or_above",
        "window_start": { "kind": "trigger", "trigger_id": "t_fail_2" },
        "window_end": { "kind": "trigger", "trigger_id": "t_stopped_2" } },

      { "id": "r_airspeed_curve_3", "label": "Scenario 3 -- airspeed vs. blue line",
        "kind": "airspeed_penalty_curve",
        "anchors": [
          { "vspeed_ref": "vmc", "offset_kts": 0, "percent": 0 },
          { "vspeed_ref": "vmc", "offset_kts": 5, "percent": 25 },
          { "vspeed_ref": "vyse", "offset_kts": 0, "percent": 100 }
        ],
        "window_start": { "kind": "trigger", "trigger_id": "t_fail_3" },
        "window_end": { "kind": "trigger", "trigger_id": "t_tpa_reached" } }
    ]
  },
  "objectives": [
    { "text": "Taxi into position and confirm ready for takeoff.", "for_trigger": "Ready for takeoff" },
    { "text": "Key your mic to confirm you're ready for the first scenario.", "for_trigger": "PTT confirm -- scenario 1" },
    { "text": "Handle the rejected takeoff: throttle(s) idle, land straight ahead, brake to a stop.", "for_trigger": "Scenario 1 -- rejected takeoff" },
    { "text": "Handle the gear-down abort at rotation -- leave the gear alone.", "for_trigger": "Scenario 2 -- gear-down abort at rotation" },
    { "text": "Key your mic to confirm you're ready for The Drill.", "for_trigger": "PTT confirm -- scenario 3" },
    { "text": "Fly The Drill: identify, verify, feather, and climb at blue line to pattern altitude.", "for_trigger": "Scenario 3 -- The Drill" },
    { "text": "Reach pattern altitude.", "for_trigger": "Reached pattern altitude" },
    { "text": "Mission complete.", "for_trigger": "Mission complete" }
  ]
}