{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "type": "object",
  "properties": {
    "runs": {
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid",
            "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
          },
          "build": {
            "type": "string",
            "format": "uuid",
            "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
          },
          "startedAt": {
            "type": "number"
          },
          "scheduledAt": {
            "type": "number"
          },
          "manual": {
            "type": "boolean"
          },
          "status": {
            "type": "string",
            "enum": ["queued", "running", "succeeded", "failed", "uncertain"]
          },
          "duration": {
            "anyOf": [
              {
                "type": "number"
              },
              {
                "type": "null"
              }
            ]
          },
          "error": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ]
          },
          "result": {
            "anyOf": [
              {
                "type": "object",
                "properties": {
                  "outcome": {
                    "type": "string",
                    "enum": ["succeeded", "partial", "failed"]
                  },
                  "summary": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 500
                  },
                  "metrics": {
                    "type": "object",
                    "propertyNames": {
                      "type": "string",
                      "pattern": "^[A-Za-z][\\w.-]{0,63}$"
                    },
                    "additionalProperties": {
                      "type": "number"
                    }
                  },
                  "diagnostics": {
                    "maxItems": 50,
                    "type": "array",
                    "items": {
                      "type": "object",
                      "properties": {
                        "level": {
                          "type": "string",
                          "enum": ["error", "warning", "info"]
                        },
                        "message": {
                          "type": "string",
                          "minLength": 1,
                          "maxLength": 500
                        },
                        "subject": {
                          "type": "string",
                          "minLength": 1,
                          "maxLength": 200
                        },
                        "code": {
                          "type": "string",
                          "minLength": 1,
                          "maxLength": 100
                        }
                      },
                      "required": ["level", "message"]
                    }
                  }
                },
                "required": ["outcome"]
              },
              {
                "type": "null"
              }
            ]
          }
        },
        "required": [
          "id",
          "build",
          "startedAt",
          "scheduledAt",
          "manual",
          "status",
          "duration",
          "error"
        ]
      }
    },
    "environment": {
      "description": "The environment the command used: test unless --environment live was given.",
      "type": "string",
      "enum": ["test", "live"]
    }
  },
  "required": ["runs"]
}
