{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "vaultfire.pilot-rollout-plan.v1.schema.json",
  "type": "object",
  "additionalProperties": false,
  "required": ["$schema", "schemaVersion", "status", "scopeSha256", "scopeRegistrySha256", "stages"],
  "properties": {
    "$schema": {"const": "../schemas/pilot-rollout-plan.schema.json"},
    "schemaVersion": {"const": "1.0.0"},
    "status": {"enum": ["blocked", "candidate-bound-approved"]},
    "scopeSha256": {"type": ["string", "null"], "pattern": "^[0-9a-f]{64}$"},
    "scopeRegistrySha256": {"type": ["string", "null"], "pattern": "^[0-9a-f]{64}$"},
    "stages": {
      "type": "array",
      "uniqueItems": true,
      "items": {
        "type": "object",
        "additionalProperties": false,
        "required": ["stageId", "sequence", "routeId", "module", "actionClass", "requiredDeploymentContract", "preconditionsEvidenceId", "rollbackEvidenceId", "status"],
        "properties": {
          "stageId": {"type": "string", "pattern": "^stage:[0-9a-f]{64}$"},
          "sequence": {"type": "integer", "minimum": 1},
          "routeId": {"type": "string", "pattern": "^base\\.[a-z0-9]+(?:-[a-z0-9]+)*\\.read-only-query$"},
          "module": {"type": "string", "pattern": "^[A-Za-z][A-Za-z0-9]{2,63}$"},
          "actionClass": {"const": "read-only-query"},
          "requiredDeploymentContract": {"type": "string", "pattern": "^[A-Za-z][A-Za-z0-9]{2,63}$"},
          "preconditionsEvidenceId": {"const": "MODULE-ROLLOUT"},
          "rollbackEvidenceId": {"const": "PAUSE-SAFE-EXITS"},
          "status": {"const": "approved-not-executed"}
        }
      }
    }
  }
}
