{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://basicmi.github.io/AI-Chip/schemas/workloads.schema.json",
  "title": "AI Chip Workload and Execution Path Database",
  "type": "object",
  "additionalProperties": false,
  "required": [
    "schema_version",
    "database_version",
    "last_reviewed",
    "scope",
    "status_definitions",
    "workloads",
    "paths"
  ],
  "properties": {
    "schema_version": {
      "type": "string",
      "const": "1.0"
    },
    "database_version": {
      "type": "string",
      "minLength": 1
    },
    "last_reviewed": {
      "type": "string",
      "format": "date"
    },
    "scope": {
      "type": "string",
      "minLength": 1
    },
    "status_definitions": {
      "type": "object",
      "minProperties": 1,
      "additionalProperties": {
        "type": "string",
        "minLength": 1
      }
    },
    "workloads": {
      "type": "array",
      "minItems": 1,
      "items": {
        "$ref": "#/$defs/workload"
      }
    },
    "paths": {
      "type": "array",
      "items": {
        "$ref": "#/$defs/path"
      }
    }
  },
  "$defs": {
    "id": {
      "type": "string",
      "pattern": "^[a-z0-9]+(?:-[a-z0-9]+)*$"
    },
    "workload": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "id",
        "name",
        "category",
        "phase",
        "description",
        "representative_models",
        "key_dimensions",
        "metrics_to_report"
      ],
      "properties": {
        "id": {
          "$ref": "#/$defs/id"
        },
        "name": {
          "type": "string",
          "minLength": 1
        },
        "category": {
          "type": "string",
          "enum": [
            "llm_inference",
            "llm_training",
            "model_porting",
            "multimodal_inference",
            "retrieval",
            "generative_inference",
            "edge_inference"
          ]
        },
        "phase": {
          "type": "string",
          "minLength": 1
        },
        "description": {
          "type": "string",
          "minLength": 1
        },
        "representative_models": {
          "type": "array",
          "items": {
            "type": "string",
            "minLength": 1
          },
          "minItems": 1
        },
        "key_dimensions": {
          "type": "array",
          "items": {
            "type": "string",
            "minLength": 1
          },
          "minItems": 1
        },
        "metrics_to_report": {
          "type": "array",
          "items": {
            "type": "string",
            "minLength": 1
          },
          "minItems": 1
        }
      }
    },
    "configuration": {
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "model": {
          "type": "string"
        },
        "device_scope": {
          "type": "string"
        },
        "precision": {
          "type": "string"
        },
        "device_count": {
          "type": "integer",
          "minimum": 1
        },
        "input_tokens": {
          "type": "integer",
          "minimum": 0
        },
        "output_tokens": {
          "type": "integer",
          "minimum": 0
        },
        "batch_size": {
          "type": "integer",
          "minimum": 1
        },
        "concurrency": {
          "type": "integer",
          "minimum": 1
        },
        "notes": {
          "type": "string"
        }
      }
    },
    "metric": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "name",
        "value",
        "unit",
        "measurement_method",
        "source_url",
        "checked_at",
        "evidence_type"
      ],
      "properties": {
        "name": {
          "type": "string",
          "minLength": 1
        },
        "value": {
          "type": "number"
        },
        "unit": {
          "type": "string",
          "minLength": 1
        },
        "measurement_method": {
          "type": "string",
          "minLength": 1
        },
        "source_url": {
          "type": "string",
          "format": "uri"
        },
        "checked_at": {
          "type": "string",
          "format": "date"
        },
        "evidence_type": {
          "type": "string",
          "enum": [
            "independent",
            "vendor",
            "project",
            "community"
          ]
        }
      }
    },
    "path": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "id",
        "platform_id",
        "workload_id",
        "integration_ids",
        "status",
        "scope",
        "limitations",
        "configuration",
        "metrics",
        "last_checked"
      ],
      "properties": {
        "id": {
          "$ref": "#/$defs/id"
        },
        "platform_id": {
          "$ref": "#/$defs/id"
        },
        "workload_id": {
          "$ref": "#/$defs/id"
        },
        "integration_ids": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/id"
          },
          "minItems": 1,
          "uniqueItems": true
        },
        "status": {
          "type": "string",
          "enum": [
            "integration_only",
            "vendor_reported",
            "workload_tested",
            "benchmark_reported",
            "independently_benchmarked"
          ]
        },
        "scope": {
          "type": "string",
          "minLength": 1
        },
        "limitations": {
          "type": "string",
          "minLength": 1
        },
        "configuration": {
          "$ref": "#/$defs/configuration"
        },
        "metrics": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/metric"
          }
        },
        "last_checked": {
          "type": "string",
          "format": "date"
        }
      }
    }
  }
}
