{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://schemas.driftframe.org/site-reading-governance/v2.0/scenario.schema.json",
  "title": "Specification-by-Example Scenario",
  "type": "object",
  "additionalProperties": false,
  "required": [
    "scenario_id",
    "title",
    "rule_ids",
    "kind",
    "given",
    "when",
    "then",
    "material_effect",
    "recovery",
    "metadata"
  ],
  "properties": {
    "scenario_id": {
      "$ref": "common.schema.json#/$defs/identifier"
    },
    "title": {
      "type": "string",
      "minLength": 5,
      "maxLength": 180
    },
    "rule_ids": {
      "type": "array",
      "minItems": 1,
      "uniqueItems": true,
      "items": {
        "$ref": "common.schema.json#/$defs/identifier"
      }
    },
    "kind": {
      "type": "string",
      "enum": [
        "ordinary_success",
        "boundary",
        "failure_twin",
        "recovery",
        "falsifier"
      ]
    },
    "given": {
      "type": "array",
      "minItems": 1,
      "maxItems": 5,
      "items": {
        "type": "string",
        "minLength": 5,
        "maxLength": 500
      }
    },
    "when": {
      "type": "array",
      "minItems": 1,
      "maxItems": 3,
      "items": {
        "type": "string",
        "minLength": 5,
        "maxLength": 500
      }
    },
    "then": {
      "type": "array",
      "minItems": 1,
      "maxItems": 5,
      "items": {
        "type": "string",
        "minLength": 5,
        "maxLength": 500
      }
    },
    "material_effect": {
      "type": "string",
      "minLength": 10,
      "maxLength": 800
    },
    "recovery": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "owner_role",
        "replacement_behavior",
        "verification"
      ],
      "properties": {
        "owner_role": {
          "type": "string",
          "minLength": 2,
          "maxLength": 120
        },
        "replacement_behavior": {
          "type": "string",
          "minLength": 10,
          "maxLength": 600
        },
        "verification": {
          "type": "string",
          "minLength": 10,
          "maxLength": 600
        }
      }
    },
    "boundaries": {
      "type": "array",
      "uniqueItems": true,
      "items": {
        "$ref": "common.schema.json#/$defs/boundary"
      }
    },
    "metadata": {
      "$ref": "common.schema.json#/$defs/recordMetadata"
    }
  }
}
