{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://opengdd.org/schema/core/v0.8/manifest.schema.json",
  "title": "OpenGDD v0.7 manifest",
  "type": "object",
  "required": ["opengdd", "id", "version", "title", "designer", "target"],
  "additionalProperties": false,
  "properties": {
    "opengdd": { "const": "0.8" },
    "id": {
      "type": "string",
      "pattern": "^[a-z0-9]+(-[a-z0-9]+)*$",
      "description": "Package id, kebab-case. Catalogues may impose uniqueness within their own declared domain."
    },
    "version": { "$ref": "#/$defs/specVersion" },
    "title": { "type": "string", "minLength": 1 },
    "designer": {
      "type": "object",
      "required": ["name"],
      "additionalProperties": false,
      "properties": {
        "name": { "type": "string", "minLength": 1 },
        "handle": { "type": "string", "description": "Registry handle" },
        "contact": { "type": "string" }
      }
    },
    "target": {
      "type": "object",
      "required": ["platform", "genre"],
      "additionalProperties": false,
      "properties": {
        "platform": { "enum": ["web-2d", "web-3d"] },
        "genre": { "type": "string", "minLength": 1 },
        "session_minutes": { "type": "number", "minimum": 0 },
        "audience": { "type": "string" }
      }
    },
    "commerce": {
      "type": "object",
      "required": ["license", "split"],
      "additionalProperties": false,
      "properties": {
        "license": { "enum": ["opengdd-share-v0"] },
        "split": {
          "type": "object",
          "required": ["designer", "builder"],
          "additionalProperties": false,
          "properties": {
            "designer": { "type": "number", "minimum": 0, "maximum": 100 },
            "builder": { "type": "number", "minimum": 0, "maximum": 100 }
          },
          "description": "Percentages; validator must additionally check they sum to 100"
        },
        "derived_from": {
          "type": "object",
          "required": ["id", "version"],
          "additionalProperties": false,
          "properties": {
            "id": {
              "type": "string",
              "pattern": "^[a-z0-9]+(-[a-z0-9]+)*$"
            },
            "version": { "$ref": "#/$defs/specVersion" }
          }
        }
      },
      "description": "Optional commerce metadata. Publication or commerce profiles may impose additional requirements outside core package conformance."
    }
  },
  "$defs": {
    "specVersion": {
      "type": "string",
      "pattern": "^(0|[1-9]\\d*)\\.(0|[1-9]\\d*)\\.(0|[1-9]\\d*)$",
      "description": "Design-spec version: numeric MAJOR.MINOR.PATCH with no leading zero except 0 and no prerelease or build suffix"
    }
  }
}
