{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/nopaque-co-uk/json-schema/nopaque-co-uk-create-digital-test-run-request-schema.json",
  "title": "CreateDigitalTestRunRequest",
  "x-generated": "2026-11-29",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/nopaque-co-uk-openapi.json#/components/schemas/CreateDigitalTestRunRequest",
  "type": "object",
  "required": [
    "sector",
    "mission"
  ],
  "properties": {
    "connectorId": {
      "type": "string",
      "description": "The connector to run against. Preferred over inline `target`/`targetRef`.\nResolved into the concrete target at launch time, so editing the\nconnector updates every run/config that points at it.\n"
    },
    "targetRef": {
      "type": "string",
      "description": "TRANSITIONAL — inline target identity for report aggregation, the\nchat analogue of phoneNumber. Superseded by `connectorId`; still\naccepted until every caller has migrated. Required together with\n`target` when `connectorId` is absent.\n"
    },
    "target": {
      "allOf": [
        {
          "$ref": "#/$defs/DigitalTarget"
        }
      ],
      "description": "TRANSITIONAL — inline target. Superseded by `connectorId`; still\naccepted until every caller has migrated. Required together with\n`targetRef` when `connectorId` is absent.\n"
    },
    "sector": {
      "type": "string"
    },
    "mission": {
      "type": "string"
    },
    "kind": {
      "type": "string",
      "enum": [
        "freeform",
        "compliance",
        "standard"
      ],
      "default": "freeform",
      "description": "`freeform` — did the customer get what they came for (LLM-judged, needs `acceptance`).\n`compliance` — did the bot behave (LLM-judged against catalogue conditions, needs `catalogueTestId`).\n`standard` — did it say the right thing (step assertions, no model in the loop, needs `steps`).\n"
    },
    "acceptance": {
      "type": "string",
      "description": "Required for `kind: freeform`."
    },
    "catalogueTestId": {
      "type": "string",
      "pattern": "^M-\\d{3}$",
      "description": "Required for `kind: compliance`."
    },
    "passConditions": {
      "type": "array",
      "maxItems": 50,
      "items": {
        "type": "string"
      },
      "description": "ALL must hold for a pass. Judge-side only — never sent to the bot under test."
    },
    "failConditions": {
      "type": "array",
      "maxItems": 50,
      "items": {
        "type": "string"
      },
      "description": "ANY one triggers a fail. Judge-side only."
    },
    "setup": {
      "type": "string"
    },
    "additionalContext": {
      "type": "string",
      "maxLength": 800
    },
    "profileId": {
      "type": "string",
      "description": "Reference to a saved profile (see `/profiles`) to draw test data from —\nthe same mechanism voice tests use. Resolved at RUN time, so editing the\nprofile updates every test that points at it rather than leaving stale\ncopies behind. Takes precedence over an inline `profile`.\n\nA profile that resolves to no usable items is rejected with 400 rather\nthan run with no data — a test that silently sent nothing would fail\nagainst a perfectly good bot and read as a product defect.\n"
    },
    "profile": {
      "$ref": "#/$defs/DigitalProfile"
    },
    "profileSnapshot": {
      "type": "object",
      "additionalProperties": true,
      "description": "Flat label→value dict for the judged kinds."
    },
    "probes": {
      "type": "array",
      "maxItems": 100,
      "items": {
        "type": "string"
      },
      "description": "Probe utterances for the judged kinds. `standard` uses `steps` instead."
    },
    "steps": {
      "type": "array",
      "maxItems": 200,
      "items": {
        "$ref": "#/$defs/ChatStep"
      },
      "description": "`standard` only. A judged kind carrying steps is rejected."
    },
    "samples": {
      "type": "integer",
      "minimum": 1,
      "maximum": 10,
      "description": "How many times to run before returning a verdict. Defaults to 3 for the judged\nkinds and 1 for `standard`.\n\nSampling is a JUDGE problem, not a channel one: an LLM verdict on a test with\n3+ conditions is unstable at roughly p³, so a majority needs at least 3 votes.\nA `standard` step test asserts exact strings with no model in the loop, is\nstable at one run, and may only be 1 — repeating it would triple the bill for\nbyte-identical transcripts.\n"
    },
    "maxTurns": {
      "type": "integer",
      "minimum": 1,
      "maximum": 60,
      "default": 12
    }
  },
  "$defs": {
    "ChatStep": {
      "type": "object",
      "description": "One step of a `kind: standard` test, discriminated on `type`.\n\nModelled as a discriminated union rather than one permissive object so a\ngenerated client cannot build a step that the API will reject - an `expect`\nwith no `expected`, for instance.\n",
      "oneOf": [
        {
          "$ref": "#/$defs/SendChatStep"
        },
        {
          "$ref": "#/$defs/ExpectChatStep"
        },
        {
          "$ref": "#/$defs/WaitChatStep"
        },
        {
          "$ref": "#/$defs/EndChatStep"
        }
      ]
    },
    "ChatStepBase": {
      "type": "object",
      "properties": {
        "id": {
          "type": "string"
        },
        "name": {
          "type": "string"
        }
      }
    },
    "ConnectChatTarget": {
      "type": "object",
      "description": "Amazon Connect chat via StartChatContact plus the participant websocket.",
      "required": [
        "transport",
        "instanceId",
        "contactFlowId"
      ],
      "properties": {
        "transport": {
          "type": "string",
          "enum": [
            "connect-chat"
          ]
        },
        "instanceId": {
          "type": "string"
        },
        "contactFlowId": {
          "type": "string"
        },
        "region": {
          "type": "string",
          "default": "us-east-1"
        },
        "attributes": {
          "type": "object",
          "additionalProperties": {
            "type": "string"
          },
          "description": "Contact attributes set at StartChatContact."
        },
        "assumeRoleArn": {
          "type": "string",
          "description": "Optional cross-account role. Absent means ambient credentials."
        }
      }
    },
    "DigitalProfile": {
      "type": "object",
      "description": "Test data a `standard` run's steps draw on. The voice profile shape minus `voiceItems`.",
      "properties": {
        "dataItems": {
          "type": "object",
          "additionalProperties": {
            "type": "object",
            "properties": {
              "label": {
                "type": "string"
              },
              "value": {
                "type": "string"
              }
            }
          }
        }
      }
    },
    "DigitalTarget": {
      "type": "object",
      "description": "What `phoneNumber` becomes on a text channel. Discriminated on `transport`.\n`targetRef` (on the run, not here) is the stable human-readable identity a\nreport aggregates on.\n",
      "oneOf": [
        {
          "$ref": "#/$defs/ConnectChatTarget"
        },
        {
          "$ref": "#/$defs/HttpJsonTarget"
        },
        {
          "$ref": "#/$defs/WebWidgetTarget"
        },
        {
          "$ref": "#/$defs/LexV2Target"
        },
        {
          "$ref": "#/$defs/DirectLineTarget"
        }
      ]
    },
    "DirectLineTarget": {
      "type": "object",
      "description": "Microsoft Bot Framework Direct Line 3.0: Copilot Studio agents and Azure Bot\nService bots. Holds a token endpoint URL, never a Direct Line secret.\n",
      "required": [
        "transport",
        "tokenEndpoint"
      ],
      "properties": {
        "transport": {
          "type": "string",
          "enum": [
            "direct-line"
          ]
        },
        "tokenEndpoint": {
          "type": "string",
          "minLength": 1,
          "description": "An https endpoint that returns a Direct Line token. Copilot Studio serves one;\nfor Azure Bot Service it is an endpoint the customer hosts that exchanges their\nsecret for a token.\n"
        },
        "directLineDomain": {
          "type": "string",
          "description": "The Direct Line host, for example `https://europe.directline.botframework.com`.\nWhen absent it is discovered (Copilot Studio) or the global host is used.\n"
        },
        "locale": {
          "type": "string",
          "minLength": 1,
          "default": "en-US"
        },
        "skipStartEvent": {
          "type": "boolean",
          "default": false,
          "description": "A `startConversation` event is sent when the conversation opens, which is what\nmakes a Copilot Studio agent greet. Set true for a bot that greets on its own.\n"
        }
      }
    },
    "EndChatStep": {
      "allOf": [
        {
          "$ref": "#/$defs/ChatStepBase"
        },
        {
          "type": "object",
          "description": "Close the conversation explicitly. Optional - the runner closes the transport anyway.",
          "required": [
            "type"
          ],
          "properties": {
            "type": {
              "type": "string",
              "enum": [
                "end"
              ]
            }
          }
        }
      ]
    },
    "ExpectChatStep": {
      "allOf": [
        {
          "$ref": "#/$defs/ChatStepBase"
        },
        {
          "type": "object",
          "description": "Assert the bot's next message.\n\n`exact` is the default because chat delivers the bytes the bot sent. Voice\nhas to fuzzy-match at a threshold because ASR is lossy; defaulting to one\nhere would silently pass near-misses. Matching trims and collapses\nwhitespace but is case-SENSITIVE - a bot that changed case changed its\noutput.\n",
          "required": [
            "type",
            "expected"
          ],
          "properties": {
            "type": {
              "type": "string",
              "enum": [
                "expect"
              ]
            },
            "expected": {
              "type": "string",
              "minLength": 1
            },
            "matcher": {
              "type": "string",
              "enum": [
                "exact",
                "contains",
                "regex",
                "similarity"
              ],
              "default": "exact"
            },
            "threshold": {
              "type": "integer",
              "minimum": 0,
              "maximum": 100,
              "default": 100,
              "description": "Only consulted by `similarity`, but reported on every result row so a failure shows the bar it was judged against."
            },
            "timeoutSecs": {
              "type": "number",
              "exclusiveMinimum": 0,
              "maximum": 120,
              "default": 20
            }
          }
        }
      ]
    },
    "HttpJsonTarget": {
      "type": "object",
      "description": "Generic REST chat endpoint, including OpenAI-compatible shapes.",
      "required": [
        "transport",
        "endpoint"
      ],
      "properties": {
        "transport": {
          "type": "string",
          "enum": [
            "http-json"
          ]
        },
        "endpoint": {
          "type": "string"
        },
        "openaiCompatible": {
          "type": "boolean"
        },
        "authRef": {
          "type": "string"
        }
      }
    },
    "LexV2Target": {
      "type": "object",
      "description": "Amazon Lex V2 via RecognizeText. Plain request and response, no websocket.",
      "required": [
        "transport",
        "botId",
        "botAliasId"
      ],
      "properties": {
        "transport": {
          "type": "string",
          "enum": [
            "lex-v2"
          ]
        },
        "botId": {
          "type": "string",
          "minLength": 1
        },
        "botAliasId": {
          "type": "string",
          "minLength": 1
        },
        "localeId": {
          "type": "string",
          "minLength": 1,
          "default": "en_US"
        },
        "region": {
          "type": "string",
          "default": "us-east-1"
        },
        "assumeRoleArn": {
          "type": "string",
          "description": "Optional cross-account role. Absent means ambient credentials."
        }
      }
    },
    "SendChatStep": {
      "allOf": [
        {
          "$ref": "#/$defs/ChatStepBase"
        },
        {
          "type": "object",
          "description": "Send a customer message. Supply EXACTLY ONE of `text` or `profileItemId` -\nboth, or neither, is a 400.\n\n`profileItemId` is a key into `profile.dataItems`, mirroring how a voice\nDTMF step resolves one. There is no template syntax: an unresolvable\nreference fails loudly rather than sending the literal `{{accountNumber}}`\nto the bot.\n",
          "required": [
            "type"
          ],
          "properties": {
            "type": {
              "type": "string",
              "enum": [
                "send"
              ]
            },
            "text": {
              "type": "string"
            },
            "profileItemId": {
              "type": "string"
            }
          }
        }
      ]
    },
    "WaitChatStep": {
      "allOf": [
        {
          "$ref": "#/$defs/ChatStepBase"
        },
        {
          "type": "object",
          "description": "Pause. For targets that rate-limit, or to let an async handoff settle.",
          "required": [
            "type"
          ],
          "properties": {
            "type": {
              "type": "string",
              "enum": [
                "wait"
              ]
            },
            "seconds": {
              "type": "number",
              "exclusiveMinimum": 0,
              "maximum": 60,
              "default": 1
            }
          }
        }
      ]
    },
    "WebWidgetTarget": {
      "type": "object",
      "description": "Browser-automated embedded chat widget, for targets with no API at all.",
      "required": [
        "transport",
        "url"
      ],
      "properties": {
        "transport": {
          "type": "string",
          "enum": [
            "web-widget"
          ]
        },
        "url": {
          "type": "string"
        },
        "selectorProfile": {
          "type": "string"
        }
      }
    }
  }
}