{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://opengdd.org/schema/core/v0.9/tuning.schema.json",
  "title": "OpenGDD v0.9 tuning",
  "type": "object",
  "required": ["values"],
  "additionalProperties": false,
  "$comment": "Cross-field rules stay validator-level: a key appears in values or open, never both; every ranges key MUST exist in values or open; each minimum MUST NOT exceed its maximum; each authored value or guess MUST lie inside its own range; and every rule MUST parse and be checked over the package-decided numbers and available guesses.",
  "properties": {
    "values": {
      "type": "object",
      "propertyNames": { "$ref": "#/$defs/tuningKey" },
      "additionalProperties": { "type": "number" },
      "description": "Required flat map of dotted keys to finite JSON numbers."
    },
    "open": {
      "type": "object",
      "propertyNames": { "$ref": "#/$defs/tuningKey" },
      "additionalProperties": { "type": ["number", "null"] },
      "description": "Optional flat map of open numbers to a finite numeric guess, or null for no guess."
    },
    "ranges": {
      "type": "object",
      "propertyNames": { "$ref": "#/$defs/tuningKey" },
      "additionalProperties": {
        "type": "array",
        "minItems": 2,
        "maxItems": 2,
        "items": { "type": "number" }
      },
      "description": "Optional inclusive [minimum, maximum] bounds for a values or open key."
    },
    "rules": {
      "type": "object",
      "propertyNames": { "pattern": "^[a-z0-9]+(-[a-z0-9]+)*$" },
      "additionalProperties": { "type": "string", "minLength": 1 },
      "description": "Optional named one-line rules over tuning numbers and top-level numeric record fields."
    }
  },
  "$defs": {
    "tuningKey": {
      "type": "string",
      "pattern": "^(?![0-9]+(?:\\.[0-9]+)+$)[A-Za-z0-9_](?:[A-Za-z0-9_-]*[A-Za-z0-9_])?(?:\\.[A-Za-z0-9_](?:[A-Za-z0-9_-]*[A-Za-z0-9_])?)+$",
      "$comment": "Reserved first and extension segments are validator-level because the reserved list is versioned.",
      "description": "A flat dotted key with at least two segments; at least one segment contains a character other than a digit."
    }
  }
}
