{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://play.modiqo.ai/feeds/public-plays.schema.json",
  "title": "modiqo public Play feed",
  "description": "A transport-neutral snapshot of public registry Plays. The envelope stays stable as delivery moves from checked-in snapshots to scheduled generation and live pagination.",
  "type": "object",
  "required": ["schema", "schema_version", "feed_id", "generated_at", "source", "delivery", "page", "organizations", "links", "items"],
  "properties": {
    "schema": {"const": "modiqo.public-play-feed.v1"},
    "schema_version": {"const": 1},
    "feed_id": {"const": "public-plays"},
    "generated_at": {"type": "string", "format": "date-time"},
    "source": {
      "type": "object",
      "required": ["kind", "scope", "observed_at", "inventory_play"],
      "properties": {
        "kind": {"const": "rote-registry"},
        "scope": {"const": "public"},
        "observed_at": {"type": "string", "format": "date-time"},
        "inventory_play": {"type": "string", "format": "uri"}
      },
      "additionalProperties": true
    },
    "delivery": {
      "type": "object",
      "required": ["mode", "ordering"],
      "properties": {
        "mode": {"enum": ["snapshot", "scheduled", "live"]},
        "ordering": {"type": "string"}
      },
      "additionalProperties": true
    },
    "page": {
      "type": "object",
      "required": ["count", "next_cursor"],
      "properties": {
        "count": {"type": "integer", "minimum": 0},
        "next_cursor": {"type": ["string", "null"]}
      },
      "additionalProperties": true
    },
    "organizations": {
      "type": "array",
      "items": {
        "type": "object",
        "required": ["slug", "display_name", "verified", "verified_since"],
        "properties": {
          "slug": {"type": "string", "minLength": 1},
          "display_name": {"type": "string", "minLength": 1},
          "verified": {"type": "boolean"},
          "verified_since": {"type": ["string", "null"], "format": "date-time"}
        },
        "additionalProperties": false
      }
    },
    "links": {
      "type": "object",
      "required": ["self", "schema"],
      "properties": {
        "self": {"type": "string", "format": "uri"},
        "schema": {"type": "string", "format": "uri"}
      },
      "additionalProperties": true
    },
    "items": {
      "type": "array",
      "items": {"$ref": "#/$defs/play"}
    }
  },
  "additionalProperties": true,
  "$defs": {
    "play": {
      "type": "object",
      "required": ["id", "reference", "uri", "manifest_uri", "name", "title", "description", "owner", "registry_organization", "tags", "primary_domain", "version", "visibility", "stats", "steps", "parameters", "execution", "effects", "integrity"],
      "properties": {
        "id": {"type": "string", "format": "uri"},
        "reference": {"type": "string"},
        "uri": {"type": "string", "format": "uri"},
        "manifest_uri": {"type": "string", "format": "uri"},
        "name": {"type": "string"},
        "title": {"type": "string"},
        "description": {"type": "string"},
        "owner": {
          "type": "object",
          "required": ["kind", "slug"],
          "properties": {"kind": {"type": "string"}, "slug": {"type": "string"}},
          "additionalProperties": true
        },
        "registry_organization": {"type": "string", "minLength": 1},
        "tags": {
          "type": "array",
          "minItems": 3,
          "maxItems": 6,
          "uniqueItems": true,
          "items": {"type": "string", "pattern": "^[a-z0-9]+(?:-[a-z0-9]+)*$"}
        },
        "primary_domain": {"type": "string", "pattern": "^domain-[a-z0-9]+(?:-[a-z0-9]+)*$"},
        "author": {"type": "string"},
        "version": {"type": "string"},
        "published_at": {"type": ["string", "null"], "format": "date-time"},
        "visibility": {"const": "public"},
        "stats": {
          "type": "object",
          "required": ["downloads", "installs"],
          "properties": {
            "downloads": {"type": "integer", "minimum": 0},
            "installs": {"type": "integer", "minimum": 0}
          },
          "additionalProperties": true
        },
        "steps": {
          "type": "object",
          "required": ["count", "names"],
          "properties": {
            "count": {"type": "integer", "minimum": 0},
            "names": {"type": "array", "items": {"type": "string"}}
          },
          "additionalProperties": true
        },
        "parameters": {"type": "array", "items": {"type": "object"}},
        "execution": {"type": "object"},
        "effects": {"type": "object"},
        "integrity": {"type": "object"}
      },
      "additionalProperties": true
    }
  }
}
