{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://standards.rootblocks.com/schemas/regression/regression-suite.v1.schema.json",
  "title": "RootBlocks Regression Suite v1",
  "type": "object",
  "additionalProperties": false,
  "required": [
    "schemaVersion",
    "suiteId",
    "featureId",
    "workflowId",
    "standard",
    "cases"
  ],
  "properties": {
    "schemaVersion": {
      "const": "rootblocks.regression-suite/v1"
    },
    "suiteId": {
      "type": "string",
      "pattern": "^[a-z0-9][a-z0-9.-]{2,127}$"
    },
    "featureId": {
      "type": "string",
      "pattern": "^[a-z0-9][a-z0-9.-]{2,127}$"
    },
    "workflowId": {
      "type": "string",
      "pattern": "^[a-z0-9][a-z0-9.-]{2,127}$"
    },
    "standard": {
      "$ref": "#/$defs/standardRef"
    },
    "sourceMapRef": {
      "type": "string",
      "pattern": "^builderx/source-maps/.+\\.(json|yaml|yml)$"
    },
    "cases": {
      "type": "array",
      "minItems": 1,
      "items": {
        "$ref": "#/$defs/case"
      }
    }
  },
  "$defs": {
    "standardRef": {
      "type": "object",
      "additionalProperties": false,
      "required": ["bundleId", "version", "hash"],
      "properties": {
        "bundleId": {
          "type": "string",
          "pattern": "^[a-z0-9][a-z0-9.-]{2,127}$"
        },
        "version": {
          "$ref": "#/$defs/semver"
        },
        "hash": {
          "type": "string",
          "pattern": "^[a-f0-9]{64,128}$"
        }
      }
    },
    "semver": {
      "type": "string",
      "pattern": "^(0|[1-9][0-9]*)\\.(0|[1-9][0-9]*)\\.(0|[1-9][0-9]*)(-[A-Za-z0-9.-]+)?(\\+[A-Za-z0-9.-]+)?$"
    },
    "case": {
      "type": "object",
      "additionalProperties": false,
      "required": ["id", "type", "criticality", "inputRef", "expected"],
      "properties": {
        "id": {
          "type": "string",
          "pattern": "^[a-z0-9][a-z0-9.-]{2,127}$"
        },
        "type": {
          "enum": ["workflow-fixture", "contract", "e2e", "manual-gate-sim"]
        },
        "criticality": {
          "enum": ["low", "medium", "high", "critical"]
        },
        "inputRef": {
          "type": "string",
          "pattern": "^builderx/regression/fixtures/.+\\.json$"
        },
        "expected": {
          "type": "object",
          "additionalProperties": false,
          "required": ["finalState"],
          "properties": {
            "finalState": {
              "enum": ["Completed", "Failed", "Blocked", "RequiresManualApproval"]
            },
            "outputRef": {
              "type": "string",
              "pattern": "^builderx/regression/fixtures/.+\\.json$"
            },
            "path": {
              "type": "object",
              "additionalProperties": false,
              "properties": {
                "includes": {
                  "type": "array",
                  "items": {
                    "type": "string",
                    "pattern": "^[a-z0-9][a-z0-9.-]{1,127}$"
                  }
                },
                "excludes": {
                  "type": "array",
                  "items": {
                    "type": "string",
                    "pattern": "^[a-z0-9][a-z0-9.-]{1,127}$"
                  }
                }
              }
            }
          }
        }
      }
    }
  }
}

