{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://ludi-agent-kit/routing.schema.json",
  "title": "ludi-agent-kit routing config",
  "type": "object",
  "required": ["version", "backends", "capabilities"],
  "additionalProperties": false,
  "properties": {
    "$schema": { "type": "string" },
    "version": { "const": 1 },
    "description": { "type": "string" },
    "backends": {
      "type": "object",
      "minProperties": 1,
      "propertyNames": { "pattern": "^[a-z][a-z0-9-]*$" },
      "additionalProperties": {
        "type": "object",
        "additionalProperties": false,
        "properties": {
          "description": { "type": "string" },
          "tier": { "enum": ["free", "low", "mid", "high"] },
          "capability_class": { "enum": ["basic", "standard", "strong", "expert"] },
          "cost_class": { "enum": ["free", "included", "low", "paid", "high"] },
          "availability_class": { "enum": ["available", "temporarily_unavailable", "quota_exhausted", "disabled", "unknown"] },
          "roles": { "type": "array", "items": { "type": "string" } },
          "artifact_types": { "type": "array", "items": { "type": "string" } },
          "vision": { "type": "boolean" }
        }
      }
    },
    "capabilities": {
      "type": "object",
      "minProperties": 1,
      "propertyNames": { "pattern": "^[a-z][a-z0-9-]*$" },
      "additionalProperties": {
        "type": "object",
        "required": ["primary"],
        "additionalProperties": false,
        "properties": {
          "description": { "type": "string" },
          "primary": { "type": "string", "description": "Backend name defined in backends." },
          "fallback": {
            "type": "array",
            "items": { "type": "string" },
            "uniqueItems": true
          },
          "requires": {
            "type": "object",
            "additionalProperties": false,
            "properties": { "vision": { "type": "boolean" } }
          }
        }
      }
    },
    "escalation": {
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "description": { "type": "string" },
        "ladders": {
          "type": "object",
          "additionalProperties": {
            "type": "array",
            "items": { "type": "string" },
            "minItems": 1
          }
        }
      }
    }
  }
}
