{
  "$schema": "http://json-schema.org/draft-07/schema#",
  "$id": "https://aiwg.io/schemas/testing/conformance-protocol.v1.schema.json",
  "title": "Test Conformance Protocol v1",
  "type": "object",
  "additionalProperties": false,
  "properties": {
    "apiVersion": {
      "const": "testing.aiwg.io/v1"
    },
    "kind": {
      "const": "TestConformanceProtocol"
    },
    "metadata": {
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "name": {
          "type": "string",
          "minLength": 1
        },
        "description": {
          "type": "string"
        }
      },
      "required": [
        "name"
      ]
    },
    "spec": {
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "platform": {
          "type": "string",
          "minLength": 1
        },
        "system": {
          "type": "string",
          "minLength": 1
        },
        "source": {
          "type": "object",
          "additionalProperties": false,
          "properties": {
            "include": {
              "type": "array",
              "items": {
                "type": "string",
                "minLength": 1
              },
              "uniqueItems": true,
              "minItems": 1
            },
            "exclude": {
              "type": "array",
              "items": {
                "type": "string",
                "minLength": 1
              },
              "uniqueItems": true
            }
          },
          "required": [
            "include",
            "exclude"
          ]
        },
        "tests": {
          "type": "object",
          "additionalProperties": false,
          "properties": {
            "include": {
              "type": "array",
              "items": {
                "type": "string",
                "minLength": 1
              },
              "uniqueItems": true,
              "minItems": 1
            },
            "exclude": {
              "type": "array",
              "items": {
                "type": "string",
                "minLength": 1
              },
              "uniqueItems": true
            }
          },
          "required": [
            "include",
            "exclude"
          ]
        },
        "areas": {
          "type": "array",
          "minItems": 1,
          "items": {
            "type": "object",
            "additionalProperties": false,
            "properties": {
              "id": {
                "type": "string",
                "pattern": "^[a-z][a-z0-9-]*$"
              },
              "include": {
                "type": "array",
                "items": {
                  "type": "string",
                  "minLength": 1
                },
                "uniqueItems": true,
                "minItems": 1
              }
            },
            "required": [
              "id",
              "include"
            ]
          }
        },
        "lanes": {
          "type": "array",
          "minItems": 1,
          "items": {
            "type": "object",
            "additionalProperties": false,
            "properties": {
              "id": {
                "type": "string",
                "pattern": "^[a-z][a-z0-9-]*$"
              },
              "runner": {
                "type": "string",
                "minLength": 1
              },
              "include": {
                "type": "array",
                "items": {
                  "type": "string",
                  "minLength": 1
                },
                "uniqueItems": true,
                "minItems": 1
              },
              "exclude": {
                "type": "array",
                "items": {
                  "type": "string",
                  "minLength": 1
                },
                "uniqueItems": true
              },
              "command": {
                "type": "object",
                "additionalProperties": false,
                "properties": {
                  "argv": {
                    "type": "array",
                    "minItems": 1,
                    "items": {
                      "type": "string",
                      "minLength": 1
                    }
                  },
                  "timeoutMs": {
                    "type": "integer",
                    "minimum": 1,
                    "maximum": 3600000
                  },
                  "env": {
                    "type": "object",
                    "additionalProperties": {
                      "type": "string"
                    }
                  }
                },
                "required": [
                  "argv",
                  "timeoutMs"
                ]
              },
              "result": {
                "type": "object",
                "additionalProperties": false,
                "properties": {
                  "format": {
                    "enum": [
                      "canonical",
                      "vitest",
                      "jest",
                      "node-tap",
                      "pytest-json",
                      "go-json",
                      "cargo-json",
                      "junit",
                      "trx"
                    ]
                  },
                  "path": {
                    "type": "string",
                    "minLength": 1
                  }
                },
                "required": [
                  "format"
                ]
              },
              "discovery": {
                "type": "object",
                "additionalProperties": false,
                "properties": {
                  "command": {
                    "type": "object",
                    "additionalProperties": false,
                    "properties": {
                      "argv": {
                        "type": "array",
                        "minItems": 1,
                        "items": {
                          "type": "string",
                          "minLength": 1
                        }
                      },
                      "timeoutMs": {
                        "type": "integer",
                        "minimum": 1,
                        "maximum": 3600000
                      },
                      "env": {
                        "type": "object",
                        "additionalProperties": {
                          "type": "string"
                        }
                      }
                    },
                    "required": [
                      "argv",
                      "timeoutMs"
                    ]
                  },
                  "result": {
                    "type": "object",
                    "additionalProperties": false,
                    "properties": {
                      "format": {
                        "enum": [
                          "canonical",
                          "vitest",
                          "jest",
                          "node-tap",
                          "pytest-json",
                          "go-json",
                          "cargo-json",
                          "junit",
                          "trx"
                        ]
                      },
                      "path": {
                        "type": "string",
                        "minLength": 1
                      }
                    },
                    "required": [
                      "format"
                    ]
                  }
                },
                "required": [
                  "command",
                  "result"
                ]
              },
              "required": {
                "type": "boolean"
              },
              "versionCommand": {
                "type": "array",
                "minItems": 1,
                "items": {
                  "type": "string",
                  "minLength": 1
                }
              },
              "negativeControls": {
                "type": "array",
                "items": {
                  "type": "object",
                  "additionalProperties": false,
                  "properties": {
                    "id": {
                      "type": "string",
                      "minLength": 1
                    },
                    "description": {
                      "type": "string",
                      "minLength": 1
                    },
                    "command": {
                      "type": "object",
                      "additionalProperties": false,
                      "properties": {
                        "argv": {
                          "type": "array",
                          "minItems": 1,
                          "items": {
                            "type": "string",
                            "minLength": 1
                          }
                        },
                        "timeoutMs": {
                          "type": "integer",
                          "minimum": 1,
                          "maximum": 3600000
                        },
                        "env": {
                          "type": "object",
                          "additionalProperties": {
                            "type": "string"
                          }
                        }
                      },
                      "required": [
                        "argv",
                        "timeoutMs"
                      ]
                    },
                    "result": {
                      "type": "object",
                      "additionalProperties": false,
                      "properties": {
                        "format": {
                          "enum": [
                            "canonical",
                            "vitest",
                            "jest",
                            "node-tap",
                            "pytest-json",
                            "go-json",
                            "cargo-json",
                            "junit",
                            "trx"
                          ]
                        },
                        "path": {
                          "type": "string",
                          "minLength": 1
                        }
                      },
                      "required": [
                        "format"
                      ]
                    },
                    "testIds": {
                      "type": "array",
                      "items": {
                        "type": "string",
                        "minLength": 1
                      },
                      "uniqueItems": true,
                      "minItems": 1
                    },
                    "changePlan": {
                      "type": "string",
                      "minLength": 1
                    }
                  },
                  "required": [
                    "id",
                    "description",
                    "command",
                    "result",
                    "testIds",
                    "changePlan"
                  ]
                }
              },
              "coverage": {
                "type": "object",
                "additionalProperties": false,
                "properties": {
                  "format": {
                    "enum": [
                      "istanbul",
                      "canonical"
                    ]
                  },
                  "path": {
                    "type": "string",
                    "minLength": 1
                  },
                  "provider": {
                    "type": "string",
                    "minLength": 1
                  },
                  "version": {
                    "type": "string",
                    "minLength": 1
                  }
                },
                "required": [
                  "format",
                  "path",
                  "provider",
                  "version"
                ]
              }
            },
            "required": [
              "id",
              "runner",
              "include",
              "exclude",
              "command",
              "result",
              "required"
            ]
          }
        },
        "policy": {
          "type": "object",
          "additionalProperties": false,
          "properties": {
            "requireDiscovery": {
              "type": "boolean"
            },
            "requireReview": {
              "type": "boolean"
            },
            "requireNegativeControls": {
              "type": "boolean"
            },
            "allowSkipped": {
              "type": "boolean"
            },
            "coverageThresholds": {
              "type": "object",
              "additionalProperties": false,
              "properties": {
                "lines": {
                  "type": "number",
                  "minimum": 0,
                  "maximum": 100
                },
                "statements": {
                  "type": "number",
                  "minimum": 0,
                  "maximum": 100
                },
                "functions": {
                  "type": "number",
                  "minimum": 0,
                  "maximum": 100
                },
                "branches": {
                  "type": "number",
                  "minimum": 0,
                  "maximum": 100
                }
              },
              "required": []
            },
            "maxFiles": {
              "type": "integer",
              "minimum": 1,
              "maximum": 1000000
            },
            "maxFileBytes": {
              "type": "integer",
              "minimum": 1,
              "maximum": 100000000
            },
            "maxOutputBytes": {
              "type": "integer",
              "minimum": 1024,
              "maximum": 100000000
            }
          },
          "required": [
            "requireDiscovery",
            "requireReview",
            "requireNegativeControls",
            "allowSkipped",
            "coverageThresholds",
            "maxFiles",
            "maxFileBytes",
            "maxOutputBytes"
          ]
        },
        "research": {
          "type": "object",
          "additionalProperties": false,
          "properties": {
            "paths": {
              "type": "array",
              "items": {
                "type": "string",
                "minLength": 1
              },
              "uniqueItems": true
            },
            "allowWeb": {
              "type": "boolean"
            }
          },
          "required": [
            "paths",
            "allowWeb"
          ]
        },
        "configFiles": {
          "type": "array",
          "items": {
            "type": "string",
            "minLength": 1
          },
          "uniqueItems": true
        },
        "obligations": {
          "type": "array",
          "items": {
            "type": "object",
            "additionalProperties": false,
            "properties": {
              "id": {
                "type": "string",
                "pattern": "^[a-z][a-z0-9-]*$"
              },
              "description": {
                "type": "string",
                "minLength": 12
              },
              "level": {
                "type": "string",
                "minLength": 1
              },
              "sut": {
                "type": "string",
                "minLength": 1
              },
              "boundary": {
                "type": "string",
                "minLength": 1
              },
              "lanes": {
                "type": "array",
                "items": {
                  "type": "string",
                  "minLength": 1
                },
                "minItems": 1,
                "uniqueItems": true
              },
              "testIds": {
                "type": "array",
                "items": {
                  "type": "string",
                  "minLength": 1
                },
                "minItems": 1,
                "uniqueItems": true
              },
              "assertions": {
                "type": "array",
                "items": {
                  "type": "string",
                  "minLength": 1
                },
                "minItems": 1,
                "uniqueItems": true
              },
              "owner": {
                "type": "string",
                "minLength": 1
              },
              "prerequisites": {
                "type": "array",
                "items": {
                  "type": "string",
                  "minLength": 1
                },
                "uniqueItems": true
              }
            },
            "required": [
              "id",
              "description",
              "level",
              "sut",
              "boundary",
              "lanes",
              "testIds",
              "assertions",
              "owner",
              "prerequisites"
            ]
          },
          "minItems": 1
        }
      },
      "required": [
        "platform",
        "system",
        "source",
        "tests",
        "areas",
        "lanes",
        "policy",
        "research"
      ]
    }
  },
  "required": [
    "apiVersion",
    "kind",
    "metadata",
    "spec"
  ]
}
