{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://groups.qft.org/data/operator-enumeration.schema.json",
  "title": "Groups for Physics operator enumeration v1",
  "description": "A bounded four-dimensional Lorentzian scalar/Weyl field inventory and derivative-free enumeration request. Semantic validation additionally checks unique identifiers, field references, charge completeness, minDimension <= maxDimension, and SU(3) p+q <= 2. Every field must descend to the chosen gauge quotient before counting.",
  "type": "object",
  "additionalProperties": false,
  "required": ["schema", "name", "spacetime", "gauge", "fields", "enumeration"],
  "properties": {
    "schema": {"const": "groups.qft.org/operator-enumeration/1"},
    "name": {"type": "string", "minLength": 1, "maxLength": 100},
    "spacetime": {
      "type": "object", "additionalProperties": false,
      "required": ["dimension", "signature"],
      "properties": {"dimension": {"const": 4}, "signature": {"const": "Lorentzian"}}
    },
    "gauge": {
      "type": "object", "additionalProperties": false,
      "required": ["kind", "quotientOrder", "u1Normalization"],
      "properties": {
        "kind": {"const": "su3-su2-u1"},
        "quotientOrder": {"enum": [1, 2, 3, 6]},
        "u1Normalization": {"const": "integer-charge-period-2pi"}
      }
    },
    "fields": {"type": "array", "maxItems": 16, "items": {"$ref": "#/$defs/field"}},
    "enumeration": {
      "type": "object", "additionalProperties": false,
      "required": ["minDimension", "maxDimension", "includeIdentity", "symmetries"],
      "properties": {
        "minDimension": {"type": "integer", "minimum": 1, "maximum": 6},
        "maxDimension": {"type": "integer", "minimum": 1, "maximum": 6},
        "includeIdentity": {"type": "boolean", "description": "When true, also consider the dimension-zero identity, independently of the positive dimension interval. All selected charge targets still apply."},
        "symmetries": {"type": "array", "maxItems": 3, "items": {"$ref": "#/$defs/selection"}}
      }
    }
  },
  "$defs": {
    "identifier": {"type": "string", "pattern": "^[A-Za-z][A-Za-z0-9_]{0,23}$", "not": {"enum": ["constructor", "prototype"]}},
    "charge": {"type": "integer", "minimum": -24, "maximum": 24},
    "field": {
      "type": "object", "additionalProperties": false,
      "required": ["id", "name", "kind", "su3", "su2", "charge", "flavors"],
      "properties": {
        "id": {"$ref": "#/$defs/identifier"},
        "name": {"type": "string", "minLength": 1, "maxLength": 48},
        "kind": {"enum": ["scalar", "left-weyl", "right-weyl"]},
        "su3": {"type": "array", "minItems": 2, "maxItems": 2, "items": {"type": "integer", "minimum": 0, "maximum": 2}},
        "su2": {"type": "integer", "minimum": 0, "maximum": 2},
        "charge": {"$ref": "#/$defs/charge"},
        "flavors": {"type": "integer", "minimum": 1, "maximum": 3}
      }
    },
    "selection": {
      "type": "object", "additionalProperties": false,
      "required": ["id", "name", "kind", "modulus", "charges", "target"],
      "properties": {
        "id": {"$ref": "#/$defs/identifier"},
        "name": {"type": "string", "minLength": 1, "maxLength": 48},
        "kind": {"enum": ["u1", "zn"]},
        "modulus": {"type": "integer", "minimum": 0, "maximum": 12},
        "charges": {"type": "object", "description": "Exactly one charge for each field identifier; charges are uniform across that field's flavor components.", "propertyNames": {"$ref": "#/$defs/identifier"}, "additionalProperties": {"$ref": "#/$defs/charge"}},
        "target": {"$ref": "#/$defs/charge"}
      },
      "allOf": [
        {"if": {"properties": {"kind": {"const": "u1"}}}, "then": {"properties": {"modulus": {"const": 0}}}},
        {"if": {"properties": {"kind": {"const": "zn"}}}, "then": {"properties": {"modulus": {"minimum": 2, "maximum": 12}}}}
      ]
    }
  }
}
