{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://raw.githubusercontent.com/grafana/cog/main/schemas/compiler_passes.json",
  "$ref": "#/$defs/YamlCompiler",
  "$defs": {
    "AstArrayType": {
      "properties": {
        "value_type": {
          "$ref": "#/$defs/AstType"
        }
      },
      "additionalProperties": false,
      "type": "object"
    },
    "AstComposableSlotType": {
      "properties": {
        "variant": {
          "type": "string"
        }
      },
      "additionalProperties": false,
      "type": "object"
    },
    "AstDisjunctionType": {
      "properties": {
        "branches": {
          "$ref": "#/$defs/AstTypes"
        },
        "discriminator": {
          "type": "string",
          "description": "If the branches are references to structs, some languages will need\nextra context to be able to distinguish between them. Golang, for\nexample, doesn't support sum types (disjunctions of fixed types).\nTo emulate sum types for these languages, we need a way to\ndiscriminate against every possible type.\n\nTo do that, we need two things:\n\t- a discriminator: the name of a field that is present in all types.\n\t  The value of which identifies the type being used.\n - a mapping: associating a \"discriminator value\" to a type."
        },
        "discriminator_mapping": {
          "additionalProperties": {
            "type": "string"
          },
          "type": "object"
        }
      },
      "additionalProperties": false,
      "type": "object"
    },
    "AstEnumType": {
      "properties": {
        "values": {
          "items": {
            "$ref": "#/$defs/AstEnumValue"
          },
          "type": "array",
          "description": "possible values. Value types might be different"
        }
      },
      "additionalProperties": false,
      "type": "object"
    },
    "AstEnumValue": {
      "properties": {
        "type": {
          "$ref": "#/$defs/AstType"
        },
        "name": {
          "type": "string"
        },
        "value": true
      },
      "additionalProperties": false,
      "type": "object"
    },
    "AstIntersectionType": {
      "properties": {
        "branches": {
          "items": {
            "$ref": "#/$defs/AstType"
          },
          "type": "array"
        }
      },
      "additionalProperties": false,
      "type": "object"
    },
    "AstJenniesHints": {
      "type": "object",
      "description": "meant to be used by jennies, to gain a finer control on the codegen from schemas"
    },
    "AstMapType": {
      "properties": {
        "indextype": {
          "$ref": "#/$defs/AstType"
        },
        "valuetype": {
          "$ref": "#/$defs/AstType"
        }
      },
      "additionalProperties": false,
      "type": "object"
    },
    "AstRefType": {
      "properties": {
        "referred_pkg": {
          "type": "string"
        },
        "referred_type": {
          "type": "string"
        }
      },
      "additionalProperties": false,
      "type": "object"
    },
    "AstScalarType": {
      "properties": {
        "scalar_kind": {
          "type": "string",
          "description": "bool, bytes, string, int, float, ..."
        },
        "value": {
          "description": "if value isn't nil, we're representing a constant scalar"
        },
        "constraints": {
          "items": {
            "$ref": "#/$defs/AstTypeConstraint"
          },
          "type": "array"
        }
      },
      "additionalProperties": false,
      "type": "object"
    },
    "AstStructField": {
      "properties": {
        "name": {
          "type": "string"
        },
        "comments": {
          "items": {
            "type": "string"
          },
          "type": "array"
        },
        "type": {
          "$ref": "#/$defs/AstType"
        },
        "required": {
          "type": "boolean"
        },
        "passestrail": {
          "items": {
            "type": "string"
          },
          "type": "array"
        }
      },
      "additionalProperties": false,
      "type": "object"
    },
    "AstStructType": {
      "properties": {
        "fields": {
          "items": {
            "$ref": "#/$defs/AstStructField"
          },
          "type": "array"
        }
      },
      "additionalProperties": false,
      "type": "object"
    },
    "AstType": {
      "properties": {
        "kind": {
          "type": "string"
        },
        "nullable": {
          "type": "boolean"
        },
        "default": true,
        "disjunction": {
          "$ref": "#/$defs/AstDisjunctionType"
        },
        "array": {
          "$ref": "#/$defs/AstArrayType"
        },
        "enum": {
          "$ref": "#/$defs/AstEnumType"
        },
        "map": {
          "$ref": "#/$defs/AstMapType"
        },
        "struct": {
          "$ref": "#/$defs/AstStructType"
        },
        "ref": {
          "$ref": "#/$defs/AstRefType"
        },
        "scalar": {
          "$ref": "#/$defs/AstScalarType"
        },
        "intersection": {
          "$ref": "#/$defs/AstIntersectionType"
        },
        "composable_slot": {
          "$ref": "#/$defs/AstComposableSlotType"
        },
        "hints": {
          "$ref": "#/$defs/AstJenniesHints"
        },
        "passestrail": {
          "items": {
            "type": "string"
          },
          "type": "array"
        }
      },
      "additionalProperties": false,
      "type": "object",
      "description": "Struct representing every type defined by the IR."
    },
    "AstTypeConstraint": {
      "properties": {
        "op": {
          "type": "string"
        },
        "args": {
          "items": true,
          "type": "array"
        }
      },
      "additionalProperties": false,
      "type": "object"
    },
    "AstTypes": {
      "items": {
        "$ref": "#/$defs/AstType"
      },
      "type": "array"
    },
    "YamlAddFields": {
      "properties": {
        "to": {
          "type": "string",
          "description": "Expected format: [package].[object]"
        },
        "fields": {
          "items": {
            "$ref": "#/$defs/AstStructField"
          },
          "type": "array"
        }
      },
      "additionalProperties": false,
      "type": "object"
    },
    "YamlAddObject": {
      "properties": {
        "object": {
          "type": "string",
          "description": "Expected format: [package].[object]"
        },
        "as": {
          "$ref": "#/$defs/AstType"
        }
      },
      "additionalProperties": false,
      "type": "object"
    },
    "YamlAnonymousStructsToNamed": {
      "properties": {},
      "additionalProperties": false,
      "type": "object"
    },
    "YamlCompiler": {
      "properties": {
        "passes": {
          "items": {
            "$ref": "#/$defs/YamlCompilerPass"
          },
          "type": "array"
        }
      },
      "additionalProperties": false,
      "type": "object"
    },
    "YamlCompilerPass": {
      "properties": {
        "entrypoint_identification": {
          "$ref": "#/$defs/YamlEntrypointIdentification"
        },
        "dataquery_identification": {
          "$ref": "#/$defs/YamlDataqueryIdentification"
        },
        "unspec": {
          "$ref": "#/$defs/YamlUnspec"
        },
        "replace_reference": {
          "$ref": "#/$defs/YamlReplaceReference"
        },
        "fields_set_default": {
          "$ref": "#/$defs/YamlFieldsSetDefault"
        },
        "fields_set_required": {
          "$ref": "#/$defs/YamlFieldsSetRequired"
        },
        "fields_set_not_required": {
          "$ref": "#/$defs/YamlFieldsSetNotRequired"
        },
        "omit": {
          "$ref": "#/$defs/YamlOmit"
        },
        "add_fields": {
          "$ref": "#/$defs/YamlAddFields"
        },
        "name_anonymous_struct": {
          "$ref": "#/$defs/YamlNameAnonymousStruct"
        },
        "add_object": {
          "$ref": "#/$defs/YamlAddObject"
        },
        "rename_object": {
          "$ref": "#/$defs/YamlRenameObject"
        },
        "retype_object": {
          "$ref": "#/$defs/YamlRetypeObject"
        },
        "hint_object": {
          "$ref": "#/$defs/YamlHintObject"
        },
        "retype_field": {
          "$ref": "#/$defs/YamlRetypeField"
        },
        "omit_fields": {
          "$ref": "#/$defs/YamlOmitFields"
        },
        "schema_set_identifier": {
          "$ref": "#/$defs/YamlSchemaSetIdentifier"
        },
        "schema_set_entry_point": {
          "$ref": "#/$defs/YamlSchemaSetEntryPoint"
        },
        "duplicate_object": {
          "$ref": "#/$defs/YamlDuplicateObject"
        },
        "trim_enum_values": {
          "$ref": "#/$defs/YamlTrimEnumValues"
        },
        "constant_to_enum": {
          "$ref": "#/$defs/YamlConstantToEnum"
        },
        "anonymous_structs_to_named": {
          "$ref": "#/$defs/YamlAnonymousStructsToNamed"
        },
        "disjunction_to_type": {
          "$ref": "#/$defs/YamlDisjunctionToType"
        },
        "disjunction_of_anonymous_structs_to_explicit": {
          "$ref": "#/$defs/YamlDisjunctionOfAnonymousStructsToExplicit"
        },
        "disjunction_infer_mapping": {
          "$ref": "#/$defs/YamlDisjunctionInferMapping"
        },
        "disjunction_with_constant_to_default": {
          "$ref": "#/$defs/YamlDisjunctionWithConstantToDefault"
        }
      },
      "additionalProperties": false,
      "type": "object"
    },
    "YamlConstantToEnum": {
      "properties": {
        "objects": {
          "items": {
            "type": "string"
          },
          "type": "array",
          "description": "Expected format: [package].[object]"
        }
      },
      "additionalProperties": false,
      "type": "object"
    },
    "YamlDataqueryIdentification": {
      "properties": {},
      "additionalProperties": false,
      "type": "object"
    },
    "YamlDisjunctionInferMapping": {
      "properties": {},
      "additionalProperties": false,
      "type": "object"
    },
    "YamlDisjunctionOfAnonymousStructsToExplicit": {
      "properties": {},
      "additionalProperties": false,
      "type": "object"
    },
    "YamlDisjunctionToType": {
      "properties": {},
      "additionalProperties": false,
      "type": "object"
    },
    "YamlDisjunctionWithConstantToDefault": {
      "properties": {},
      "additionalProperties": false,
      "type": "object"
    },
    "YamlDuplicateObject": {
      "properties": {
        "object": {
          "type": "string",
          "description": "Expected format: [package].[object]"
        },
        "as": {
          "type": "string"
        },
        "omit_fields": {
          "items": {
            "type": "string"
          },
          "type": "array"
        }
      },
      "additionalProperties": false,
      "type": "object"
    },
    "YamlEntrypointIdentification": {
      "properties": {},
      "additionalProperties": false,
      "type": "object"
    },
    "YamlFieldsSetDefault": {
      "properties": {
        "defaults": {
          "type": "object",
          "description": "Expected format: [package].[object].[field] → value"
        }
      },
      "additionalProperties": false,
      "type": "object"
    },
    "YamlFieldsSetNotRequired": {
      "properties": {
        "fields": {
          "items": {
            "type": "string"
          },
          "type": "array",
          "description": "Expected format: [package].[object].[field]"
        }
      },
      "additionalProperties": false,
      "type": "object"
    },
    "YamlFieldsSetRequired": {
      "properties": {
        "fields": {
          "items": {
            "type": "string"
          },
          "type": "array",
          "description": "Expected format: [package].[object].[field]"
        }
      },
      "additionalProperties": false,
      "type": "object"
    },
    "YamlHintObject": {
      "properties": {
        "object": {
          "type": "string",
          "description": "Expected format: [package].[object]"
        },
        "hints": {
          "$ref": "#/$defs/AstJenniesHints"
        }
      },
      "additionalProperties": false,
      "type": "object"
    },
    "YamlNameAnonymousStruct": {
      "properties": {
        "field": {
          "type": "string",
          "description": "Expected format: [package].[object].[field]"
        },
        "as": {
          "type": "string"
        }
      },
      "additionalProperties": false,
      "type": "object"
    },
    "YamlOmit": {
      "properties": {
        "objects": {
          "items": {
            "type": "string"
          },
          "type": "array",
          "description": "Expected format: [package].[object]"
        }
      },
      "additionalProperties": false,
      "type": "object"
    },
    "YamlOmitFields": {
      "properties": {
        "fields": {
          "items": {
            "type": "string"
          },
          "type": "array",
          "description": "Expected format: [package].[object].[field]"
        }
      },
      "additionalProperties": false,
      "type": "object"
    },
    "YamlRenameObject": {
      "properties": {
        "from": {
          "type": "string",
          "description": "Expected format: [package].[object]"
        },
        "to": {
          "type": "string"
        }
      },
      "additionalProperties": false,
      "type": "object"
    },
    "YamlReplaceReference": {
      "properties": {
        "from": {
          "type": "string",
          "description": "Expected format: [package].[object]"
        },
        "to": {
          "type": "string",
          "description": "Expected format: [package].[object]"
        }
      },
      "additionalProperties": false,
      "type": "object"
    },
    "YamlRetypeField": {
      "properties": {
        "field": {
          "type": "string",
          "description": "Expected format: [package].[object].[field]"
        },
        "as": {
          "$ref": "#/$defs/AstType"
        },
        "comments": {
          "items": {
            "type": "string"
          },
          "type": "array"
        }
      },
      "additionalProperties": false,
      "type": "object"
    },
    "YamlRetypeObject": {
      "properties": {
        "object": {
          "type": "string",
          "description": "Expected format: [package].[object]"
        },
        "as": {
          "$ref": "#/$defs/AstType"
        },
        "comments": {
          "items": {
            "type": "string"
          },
          "type": "array"
        }
      },
      "additionalProperties": false,
      "type": "object"
    },
    "YamlSchemaSetEntryPoint": {
      "properties": {
        "package": {
          "type": "string"
        },
        "entry_point": {
          "type": "string"
        }
      },
      "additionalProperties": false,
      "type": "object"
    },
    "YamlSchemaSetIdentifier": {
      "properties": {
        "package": {
          "type": "string"
        },
        "identifier": {
          "type": "string"
        }
      },
      "additionalProperties": false,
      "type": "object"
    },
    "YamlTrimEnumValues": {
      "properties": {},
      "additionalProperties": false,
      "type": "object"
    },
    "YamlUnspec": {
      "properties": {},
      "additionalProperties": false,
      "type": "object"
    }
  }
}