{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/nopaque-co-uk/json-schema/nopaque-co-uk-mission-test-run-schema.json",
  "title": "MissionTestRun",
  "description": "AI-judged \"mission test\" run row. A mission test asks an LLM agent to call the IVR\nwith a freeform mission (e.g. \"find the FX rate\") and judges PASS/FAIL on acceptance\ncriteria. Stored in the same `TestRunsTable` as scripted runs but discriminated by\n`testType: 'mission'`. Cancelled by direct Telnyx hangup.\n",
  "x-generated": "2026-11-29",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/nopaque-co-uk-openapi.json#/components/schemas/MissionTestRun",
  "type": "object",
  "required": [
    "id",
    "workspaceId",
    "testType",
    "status",
    "startedAt"
  ],
  "properties": {
    "id": {
      "type": "string",
      "format": "uuid"
    },
    "workspaceId": {
      "type": "string",
      "format": "uuid"
    },
    "testType": {
      "type": "string",
      "enum": [
        "mission"
      ]
    },
    "status": {
      "type": "string",
      "enum": [
        "pending",
        "running",
        "completed",
        "failed",
        "cancelled"
      ]
    },
    "outcome": {
      "type": [
        "string",
        "null"
      ],
      "enum": [
        "PASS",
        "FAIL",
        "ERROR",
        "INCONCLUSIVE",
        "pending"
      ],
      "description": "Run outcome. PASS/FAIL/ERROR/INCONCLUSIVE are terminal verdicts; 'pending' is a lifecycle state for pre-completion rows. Nullable for historical rows pre-backfill."
    },
    "startedAt": {
      "type": "string",
      "format": "date-time"
    },
    "completedAt": {
      "type": "string",
      "format": "date-time"
    },
    "sector": {
      "type": "string"
    },
    "mission": {
      "type": "string"
    },
    "acceptance": {
      "type": "string"
    },
    "profile": {
      "type": "string",
      "description": "Profile ID used for the in-call AI assistant's Identity block."
    },
    "backgroundNoise": {
      "allOf": [
        {
          "$ref": "#/$defs/BackgroundNoise"
        }
      ],
      "description": "The background noise the run was dispatched with. Absent means none.\n"
    },
    "voiceId": {
      "type": "string",
      "description": "The voice this run actually spoke with — the config's choice, or the\ndefault resolved at dispatch. Recorded so a recording can be traced to\na voice from our own data. Optional: rows created before this field\nexisted have no value and can never be backfilled, because it was only\never written to a container log line. Absent means \"not recorded\", not\n\"no voice\".\n"
    },
    "language": {
      "allOf": [
        {
          "$ref": "#/$defs/CallLanguage"
        }
      ],
      "description": "The call language the run was dispatched with. Absent means English\n(every run before the field existed, and every run that did not set it).\n"
    },
    "advancedParams": {
      "allOf": [
        {
          "$ref": "#/$defs/MissionAdvancedParams"
        }
      ],
      "description": "The turn-taking settings the run was dispatched with. Absent when\nnone were set (server defaults applied) and on runs before\n2026-11-05.\n"
    },
    "carrier": {
      "type": "object",
      "description": "Bring-your-own-carrier (invite-only): the carrier route this run was dialled through,\nrecorded when the run was dispatched. It still names that route after the config's\n`carrierRouteId` is changed or removed. Absent when the run was dialled normally. See\n`GET /testing/carrier-integrations` for the route's name and settings.\n",
      "required": [
        "integrationId",
        "routeId"
      ],
      "properties": {
        "integrationId": {
          "type": "string"
        },
        "routeId": {
          "type": "string"
        }
      }
    },
    "passed": {
      "type": "boolean",
      "description": "AI judgement verdict for freeform mission runs (compliance runs use `verdict` instead)."
    },
    "passReasoning": {
      "type": "string"
    },
    "passEvidence": {
      "type": "string",
      "description": "Freeform-mission evidence quote (singular). Compliance runs use `compliancePassEvidence` instead."
    },
    "transcript": {
      "type": "string"
    },
    "callControlId": {
      "type": "string",
      "description": "Telnyx call-control ID (set once the call connects; required for mid-call cancel)."
    },
    "callPlacedAt": {
      "type": "string",
      "format": "date-time",
      "description": "The moment the dial returned a call_control_id (before the answered event) —\ndistinct from `startedAt`, which is the api-side enqueue moment. The gap between\nthe two is the window in which a cancel can still prevent the call from ever\nbeing placed. Absent on rows cancelled before dial and on every pre-existing row.\n"
    },
    "phoneNumber": {
      "type": "string"
    },
    "configId": {
      "type": "string",
      "format": "uuid",
      "description": "Set when launched FROM a saved `MissionTestConfig` (Phase 60.1)."
    },
    "tags": {
      "type": "array",
      "items": {
        "type": "string"
      },
      "description": "The tags the originating `MissionTestConfig` carried when this run was\ndispatched, kept as they were so retagging the config later does not\nchange which tag filters the run matches. An empty array means the config\nhad no tags. Absent on runs launched without a saved config and on runs\ndispatched before 17 November 2026.\n"
    },
    "errorMessage": {
      "type": "string"
    }
  },
  "$defs": {
    "BackgroundNoise": {
      "type": "string",
      "enum": [
        "cafe",
        "street",
        "home",
        "wind"
      ],
      "description": "Caller background noise: café chatter, city street traffic, home (children and a\nbaby crying) or wind buffeting. The level is fixed per sound.\n"
    },
    "CallLanguage": {
      "type": "string",
      "enum": [
        "en",
        "multi",
        "es",
        "fr",
        "de",
        "it",
        "pt",
        "nl",
        "hi",
        "ru",
        "ja"
      ],
      "description": "The language a mission test call is held in. These are the languages\nTelnyx `deepgram/flux` accepts on the AI Assistant: one language, or\n`multi` (Flux-multi), which code-switches across the other ten. Absent\nmeans English. Mirrors `api/packages/schemas/entities/callLanguage.ts`\n(Zod). Distinct from the transcription languages standard tests and\nmapping use (`en-GB` etc.).\n"
    },
    "MissionAdvancedParams": {
      "type": "object",
      "description": "Optional advanced turn-detection overrides for a single mission test.\nMirrors `api/packages/schemas/entities/missionAdvancedParams.ts` (Zod).\nAll-or-nothing: every field is required when this object is present —\nthis is what makes it safe for the values to be sent to Telnyx as a\nsingle per-call block regardless of whether Telnyx merges into or\nreplaces the stored assistant's turn-detection settings. Omit the\nobject entirely to keep the server's env-var defaults.\n",
      "required": [
        "eagerEotThreshold",
        "eotThreshold",
        "eotTimeoutMs"
      ],
      "additionalProperties": false,
      "properties": {
        "eagerEotThreshold": {
          "type": "number",
          "minimum": 0.3,
          "maximum": 0.9,
          "description": "Lets the assistant start preparing a reply before it is sure the\nother side has finished (0.3-0.9). It does not make the assistant\nwait longer; `eotThreshold` does. Equal to `eotThreshold` switches\nearly preparation off.\n"
        },
        "eotThreshold": {
          "type": "number",
          "minimum": 0.5,
          "maximum": 0.9,
          "description": "The main control: how confident the assistant must be that the\nother side has finished speaking before it replies (0.5-0.9). 0.9\nwaits longest and interrupts least; 0.5 replies at almost any pause.\n"
        },
        "eotTimeoutMs": {
          "type": "integer",
          "minimum": 1000,
          "maximum": 10000,
          "description": "The longest the assistant sits through silence, in milliseconds,\nbefore replying anyway. A ceiling, not a minimum wait: raising it\ndoes not stop interruptions.\n"
        }
      }
    }
  }
}