{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://standards.rootblocks.com/schemas/golden/golden-fixture-manifest.v1.schema.json",
  "title": "RootBlocks Golden Fixture Manifest v1",
  "type": "object",
  "additionalProperties": false,
  "required": ["schemaVersion", "fixtureSetId", "version", "driftPolicy", "coverageRules", "fixtures"],
  "properties": {
    "schemaVersion": {
      "const": "rootblocks.golden-fixture-manifest/v1"
    },
    "fixtureSetId": {
      "type": "string",
      "pattern": "^[a-z0-9][a-z0-9.-]{2,127}$"
    },
    "version": {
      "$ref": "#/$defs/semver"
    },
    "driftPolicy": {
      "type": "object",
      "additionalProperties": false,
      "required": ["expectedResultChangesRequire", "fixturePathChangesRequire"],
      "properties": {
        "expectedResultChangesRequire": {
          "enum": ["compatibility-review"]
        },
        "fixturePathChangesRequire": {
          "enum": ["standard-review"]
        }
      }
    },
    "coverageRules": {
      "type": "array",
      "minItems": 1,
      "items": {
        "$ref": "#/$defs/coverageRule"
      }
    },
    "fixtures": {
      "type": "array",
      "items": {
        "$ref": "#/$defs/fixture"
      }
    }
  },
  "$defs": {
    "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.-]+)?$"
    },
    "path": {
      "type": "string",
      "minLength": 1,
      "pattern": "^[A-Za-z0-9_./@-]+$"
    },
    "expectation": {
      "enum": ["valid", "invalid", "warning", "compatibility-allow", "compatibility-warn", "compatibility-block"]
    },
    "coverageRule": {
      "type": "object",
      "additionalProperties": false,
      "required": ["domain", "minimumValid", "minimumInvalid"],
      "properties": {
        "domain": {
          "type": "string",
          "pattern": "^[a-z0-9][a-z0-9.-]{1,127}$"
        },
        "minimumValid": {
          "type": "integer",
          "minimum": 0
        },
        "minimumInvalid": {
          "type": "integer",
          "minimum": 0
        },
        "minimumWarn": {
          "type": "integer",
          "minimum": 0
        },
        "minimumBlock": {
          "type": "integer",
          "minimum": 0
        }
      }
    },
    "fixture": {
      "type": "object",
      "additionalProperties": false,
      "required": ["id", "kind", "domain", "expected", "reason"],
      "properties": {
        "id": {
          "type": "string",
          "pattern": "^[a-z0-9][a-z0-9.-]{2,127}$"
        },
        "kind": {
          "enum": ["schema-example", "compatibility-check"]
        },
        "domain": {
          "type": "string",
          "pattern": "^[a-z0-9][a-z0-9.-]{1,127}$"
        },
        "schemaPath": {
          "$ref": "#/$defs/path"
        },
        "fixturePath": {
          "$ref": "#/$defs/path"
        },
        "bundlePath": {
          "$ref": "#/$defs/path"
        },
        "consumerProfilePath": {
          "$ref": "#/$defs/path"
        },
        "globalBundlePath": {
          "$ref": "#/$defs/path"
        },
        "expected": {
          "$ref": "#/$defs/expectation"
        },
        "reason": {
          "type": "string",
          "minLength": 1
        }
      },
      "allOf": [
        {
          "if": {
            "properties": {
              "kind": {
                "const": "schema-example"
              }
            },
            "required": ["kind"]
          },
          "then": {
            "required": ["schemaPath", "fixturePath"]
          }
        },
        {
          "if": {
            "properties": {
              "kind": {
                "const": "compatibility-check"
              }
            },
            "required": ["kind"]
          },
          "then": {
            "required": ["bundlePath", "consumerProfilePath"]
          }
        }
      ]
    }
  }
}
