{
  "$schema": "http://json-schema.org/draft-07/schema#",
  "$id": "https://aiwg.io/schemas/testing/test-sample.v1.schema.json",
  "title": "test-sample v1",
  "type": "object",
  "additionalProperties": false,
  "properties": {
    "apiVersion": {
      "const": "testing.aiwg.io/v1"
    },
    "kind": {
      "const": "TestSample"
    },
    "metadata": {
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "name": {
          "type": "string",
          "minLength": 1
        },
        "createdAt": {
          "type": "string",
          "pattern": "^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}(?:\\.\\d+)?Z$"
        },
        "toolVersion": {
          "type": "string",
          "minLength": 1
        }
      },
      "required": [
        "name",
        "createdAt",
        "toolVersion"
      ]
    },
    "spec": {
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "seed": {
          "type": "string",
          "minLength": 1
        },
        "size": {
          "type": "integer",
          "minimum": 1,
          "maximum": 10000
        },
        "unit": {
          "enum": [
            "test-file",
            "registered-case"
          ]
        },
        "populationHash": {
          "type": "string",
          "pattern": "^[a-f0-9]{64}$",
          "minLength": 64,
          "maxLength": 64
        },
        "method": {
          "const": "sha256(seed NUL id), ascending, without replacement per area"
        },
        "areas": {
          "type": "array",
          "items": {
            "type": "object",
            "additionalProperties": false,
            "properties": {
              "area": {
                "type": "string",
                "minLength": 1
              },
              "population": {
                "type": "integer",
                "minimum": 1
              },
              "sampled": {
                "type": "integer",
                "minimum": 1
              },
              "census": {
                "type": "boolean"
              },
              "records": {
                "type": "array",
                "items": {
                  "type": "object",
                  "additionalProperties": false,
                  "properties": {
                    "path": {
                      "type": "string",
                      "minLength": 1,
                      "pattern": "^(?!/)(?![A-Za-z]:)(?!.*\\\\)(?!.*(?:^|/)\\.\\.(?:/|$))[^\\u0000]+$"
                    },
                    "hash": {
                      "type": "string",
                      "pattern": "^[a-f0-9]{64}$",
                      "minLength": 64,
                      "maxLength": 64
                    },
                    "size": {
                      "type": "integer",
                      "minimum": 0
                    },
                    "role": {
                      "enum": [
                        "test",
                        "source",
                        "configuration"
                      ]
                    },
                    "isSource": {
                      "type": "boolean"
                    },
                    "areas": {
                      "type": "array",
                      "items": {
                        "type": "string",
                        "minLength": 1
                      },
                      "uniqueItems": true
                    },
                    "lanes": {
                      "type": "array",
                      "items": {
                        "type": "string",
                        "minLength": 1
                      },
                      "uniqueItems": true
                    },
                    "runnerHint": {
                      "type": "string",
                      "minLength": 1
                    },
                    "signals": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "additionalProperties": false,
                        "properties": {
                          "code": {
                            "type": "string",
                            "minLength": 1
                          },
                          "message": {
                            "type": "string",
                            "minLength": 1
                          },
                          "authority": {
                            "const": "lexical-candidate"
                          },
                          "verdict": {
                            "const": "unreviewed"
                          },
                          "line": {
                            "type": "integer",
                            "minimum": 1
                          },
                          "column": {
                            "type": "integer",
                            "minimum": 1
                          },
                          "excerpt": {
                            "type": "string",
                            "maxLength": 240
                          }
                        },
                        "required": [
                          "code",
                          "message",
                          "authority",
                          "verdict"
                        ]
                      }
                    },
                    "id": {
                      "type": "string",
                      "minLength": 1
                    },
                    "area": {
                      "type": "string",
                      "minLength": 1
                    },
                    "file": {
                      "anyOf": [
                        {
                          "type": "string",
                          "minLength": 1,
                          "pattern": "^(?!/)(?![A-Za-z]:)(?!.*\\\\)(?!.*(?:^|/)\\.\\.(?:/|$))[^\\u0000]+$"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "name": {
                      "type": "string",
                      "minLength": 1
                    },
                    "laneId": {
                      "type": "string",
                      "minLength": 1
                    },
                    "status": {
                      "enum": [
                        "passed",
                        "failed",
                        "skipped",
                        "unknown"
                      ]
                    },
                    "rank": {
                      "type": "string",
                      "pattern": "^[a-f0-9]{64}$",
                      "minLength": 64,
                      "maxLength": 64
                    },
                    "durationMs": {
                      "type": "number",
                      "minimum": 0
                    }
                  },
                  "required": [
                    "id",
                    "area",
                    "rank"
                  ]
                },
                "minItems": 1
              }
            },
            "required": [
              "area",
              "population",
              "sampled",
              "census",
              "records"
            ]
          },
          "minItems": 1
        }
      },
      "required": [
        "seed",
        "size",
        "unit",
        "populationHash",
        "method",
        "areas"
      ]
    }
  },
  "required": [
    "apiVersion",
    "kind",
    "metadata",
    "spec"
  ]
}
