{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://catalog.lintel.tools/schemas/schemastore/problem-package-generators/latest.json",
  "x-lintel": {
    "source": "https://raw.githubusercontent.com/RagnarGrootKoerkamp/BAPCtools/refs/heads/main/bapctools/resources/support/schemas/generators_yaml_schema.json",
    "sourceSha256": "0ea789aed3e46ab1dac00c995716d6c008a9f9db069413a70f95b38ecbe155a4",
    "fileMatch": [
      "generators.yml",
      "generators.yaml"
    ],
    "parsers": [
      "yaml"
    ]
  },
  "type": "object",
  "properties": {
    "data": {
      "type": "object",
      "required": [
        "sample",
        "secret"
      ],
      "properties": {
        "invalid_answer": {
          "$ref": "#/$defs/test_group"
        },
        "invalid_input": {
          "$ref": "#/$defs/test_group"
        },
        "invalid_output": {
          "$ref": "#/$defs/test_group"
        },
        "sample": {
          "$ref": "#/$defs/test_group"
        },
        "secret": {
          "$ref": "#/$defs/test_group"
        },
        "valid_output": {
          "$ref": "#/$defs/test_group"
        }
      },
      "additionalProperties": false
    },
    "generators": {
      "type": "object",
      "patternProperties": {
        "^[a-zA-Z0-9_][a-zA-Z0-9_.-]{0,254}$": {
          "allOf": [
            {
              "prefixItems": [
                true
              ]
            },
            {
              "type": "array",
              "items": {
                "type": "string",
                "$ref": "#/$defs/path",
                "not": {
                  "pattern": "^/"
                }
              },
              "minLength": 1
            }
          ]
        }
      }
    },
    "version": {
      "type": "string"
    }
  },
  "required": [
    "data"
  ],
  "$defs": {
    "command": {
      "type": "string",
      "not": {
        "pattern": "\\{seed.*\\{seed"
      }
    },
    "config": {
      "type": "object",
      "properties": {
        "random_salt": {
          "type": "string"
        },
        "solution": {
          "type": "string",
          "$ref": "#/$defs/path",
          "pattern": "^/"
        }
      },
      "additionalProperties": false
    },
    "data_dict": {
      "type": "object",
      "additionalProperties": false,
      "patternProperties": {
        "^[a-zA-Z0-9_][a-zA-Z0-9_.-]{0,254}$": {
          "anyOf": [
            {
              "$ref": "#/$defs/test_group"
            },
            {
              "$ref": "#/$defs/test_case"
            }
          ]
        }
      }
    },
    "data_list": {
      "type": "object",
      "additionalProperties": true
    },
    "path": {
      "type": "string",
      "pattern": "^/?([a-zA-Z0-9_][a-zA-Z0-9_.-]{0,254}/)*[a-zA-Z0-9_][a-zA-Z0-9_.-]{0,254}$"
    },
    "test_case": {
      "anyOf": [
        {
          "type": "string",
          "$ref": "#/$defs/command",
          "not": {
            "pattern": "^/"
          }
        },
        {
          "type": "object",
          "properties": {
            "ans": {
              "type": "string"
            },
            "ans.download": {
              "type": [
                "string",
                "object"
              ]
            },
            "ans.statement": {
              "type": [
                "string",
                "object"
              ]
            },
            "copy": {
              "type": "string",
              "$ref": "#/$defs/path",
              "not": {
                "pattern": "^/"
              }
            },
            "count": {
              "type": "array",
              "items": {
                "type": "integer"
              },
              "anyOf": [
                {
                  "type": "integer"
                },
                {
                  "type": "array"
                },
                {
                  "type": "string"
                }
              ]
            },
            "generate": {
              "type": "string",
              "$ref": "#/$defs/command",
              "not": {
                "pattern": "^/"
              }
            },
            "in": {
              "type": "string"
            },
            "in.download": {
              "type": [
                "string",
                "object"
              ]
            },
            "in.statement": {
              "type": [
                "string",
                "object"
              ]
            },
            "interaction": {
              "type": "string",
              "pattern": "^([<>][^\\n]*\\n|---\\n)+$"
            },
            "match": {
              "anyOf": [
                {
                  "type": "string"
                },
                {
                  "type": "array",
                  "items": {
                    "type": "string"
                  }
                },
                {
                  "type": "object",
                  "properties": {
                    "ans": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "array",
                          "items": {
                            "type": "string"
                          }
                        }
                      ]
                    },
                    "in": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "array",
                          "items": {
                            "type": "string"
                          }
                        }
                      ]
                    }
                  }
                }
              ]
            },
            "out": {
              "type": "string"
            },
            "yaml": {
              "$ref": "#/$defs/test_case_configuration"
            }
          },
          "$ref": "#/$defs/config",
          "required": [
            "count"
          ]
        }
      ]
    },
    "test_case_configuration": {
      "type": "object",
      "$ref": "#/$defs/test_case_or_group_configuration",
      "properties": {
        "description": {
          "type": "string"
        },
        "hint": {
          "type": "string"
        }
      },
      "additionalProperties": false
    },
    "test_case_or_group_configuration": {
      "type": "object",
      "properties": {
        "args": {
          "type": "array",
          "items": {
            "type": "string"
          }
        },
        "full_feedback": {
          "type": "boolean"
        },
        "input_validator_args": {
          "anyOf": [
            {
              "type": "array",
              "items": {
                "type": "string"
              }
            },
            {
              "type": "object",
              "additionalProperties": {
                "type": "array",
                "items": {
                  "type": "string"
                }
              }
            }
          ]
        },
        "input_visualizer_args": {
          "type": "array",
          "items": {
            "type": "string"
          }
        },
        "output_validator_args": {
          "type": "array",
          "items": {
            "type": "string"
          }
        },
        "output_visualizer_args": {
          "type": "array",
          "items": {
            "type": "string"
          }
        }
      },
      "additionalProperties": false
    },
    "test_data_group": {
      "type": "string",
      "pattern": "secret/[a-zA-Z0-9_][a-zA-Z0-9_.-]{0,254}$"
    },
    "test_group": {
      "type": "object",
      "$ref": "#/$defs/test_group_config",
      "properties": {
        "data": {
          "anyOf": [
            {
              "$ref": "#/$defs/data_dict"
            },
            {
              "type": "array",
              "items": {
                "$ref": "#/$defs/data_list"
              }
            }
          ]
        },
        "include": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/path"
          }
        }
      },
      "additionalProperties": false
    },
    "test_group_config": {
      "type": "object",
      "$ref": "#/$defs/config",
      "properties": {
        "test_group.yaml": {
          "$ref": "#/$defs/test_group_configuration"
        }
      },
      "additionalProperties": false
    },
    "test_group_configuration": {
      "type": "object",
      "$ref": "#/$defs/test_case_or_group_configuration",
      "properties": {
        "max_score": {
          "anyOf": [
            {
              "allOf": [
                {
                  "type": "number"
                },
                {
                  "type": "integer",
                  "minimum": 0
                }
              ]
            },
            {
              "const": "unbounded"
            }
          ]
        },
        "require_pass": {
          "anyOf": [
            {
              "const": "sample"
            },
            {
              "$ref": "#/$defs/test_data_group"
            },
            {
              "type": "array",
              "items": {
                "anyOf": [
                  {
                    "const": "sample"
                  },
                  {
                    "$ref": "#/$defs/test_data_group"
                  }
                ]
              }
            }
          ]
        },
        "score_aggregation": {
          "enum": [
            "pass-fail",
            "sum",
            "min"
          ]
        },
        "static_validation_score": {
          "anyOf": [
            {
              "allOf": [
                {
                  "type": "number"
                },
                {
                  "type": "integer",
                  "minimum": 0
                }
              ]
            },
            {
              "const": "pass-fail"
            }
          ]
        }
      },
      "additionalProperties": false
    }
  },
  "$ref": "#/$defs/test_group_config",
  "additionalProperties": true
}
