{
  "$schema": "http://json-schema.org/draft-07/schema#",
  "$id": "https://aiwg.io/schemas/testing/test-inventory.v1.schema.json",
  "title": "test-inventory v1",
  "type": "object",
  "additionalProperties": false,
  "properties": {
    "apiVersion": {
      "const": "testing.aiwg.io/v1"
    },
    "kind": {
      "const": "TestInventory"
    },
    "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": {
        "root": {
          "type": "string",
          "minLength": 1
        },
        "protocolHash": {
          "type": "string",
          "pattern": "^[a-f0-9]{64}$",
          "minLength": 64,
          "maxLength": 64
        },
        "snapshotHash": {
          "type": "string",
          "pattern": "^[a-f0-9]{64}$",
          "minLength": 64,
          "maxLength": 64
        },
        "complete": {
          "type": "boolean"
        },
        "authority": {
          "const": "source-file-candidates"
        },
        "counts": {
          "type": "object",
          "additionalProperties": false,
          "properties": {
            "sourceFiles": {
              "type": "integer",
              "minimum": 0
            },
            "testFiles": {
              "type": "integer",
              "minimum": 0
            },
            "testCases": {
              "type": "null"
            },
            "configurationFiles": {
              "type": "integer",
              "minimum": 0
            }
          },
          "required": [
            "sourceFiles",
            "testFiles",
            "testCases",
            "configurationFiles"
          ]
        },
        "files": {
          "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"
                  ]
                }
              }
            },
            "required": [
              "path",
              "hash",
              "size",
              "role",
              "isSource"
            ],
            "allOf": [
              {
                "if": {
                  "properties": {
                    "role": {
                      "const": "test"
                    }
                  },
                  "required": [
                    "role"
                  ]
                },
                "then": {
                  "required": [
                    "areas",
                    "lanes",
                    "runnerHint",
                    "signals"
                  ],
                  "properties": {
                    "areas": {},
                    "lanes": {},
                    "runnerHint": {},
                    "signals": {}
                  }
                }
              }
            ]
          }
        },
        "diagnostics": {
          "type": "array",
          "items": {
            "type": "object",
            "additionalProperties": false,
            "properties": {
              "code": {
                "type": "string",
                "minLength": 1
              },
              "path": {
                "type": "string",
                "minLength": 1,
                "pattern": "^(?!/)(?![A-Za-z]:)(?!.*\\\\)(?!.*(?:^|/)\\.\\.(?:/|$))[^\\u0000]+$"
              },
              "lanes": {
                "type": "array",
                "items": {
                  "type": "string",
                  "minLength": 1
                }
              },
              "message": {
                "type": "string",
                "minLength": 1
              }
            },
            "required": [
              "code",
              "message"
            ]
          }
        }
      },
      "required": [
        "root",
        "protocolHash",
        "snapshotHash",
        "complete",
        "authority",
        "counts",
        "files",
        "diagnostics"
      ]
    }
  },
  "required": [
    "apiVersion",
    "kind",
    "metadata",
    "spec"
  ]
}
