{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "sks.local-model-config.v2",
  "type": "object",
  "required": ["schema", "enabled", "status", "provider", "endpoint", "model", "policy", "capability", "blockers"],
  "properties": {
    "schema": { "const": "sks.local-model-config.v2" },
    "generated_at": { "type": "string" },
    "updated_at": { "type": "string" },
    "enabled": { "type": "boolean" },
    "status": {
      "enum": ["disabled", "enabled_unverified", "verified", "degraded", "blocked"]
    },
    "provider": { "enum": ["ollama", "mlx-lm", "openai-compatible"] },
    "endpoint": { "type": "string" },
    "base_url": { "type": "string" },
    "model": { "type": "string", "minLength": 1 },
    "keep_alive": { "type": "string" },
    "timeout_ms": { "type": "number", "minimum": 1 },
    "temperature": { "type": "number" },
    "think": { "type": "boolean" },
    "policy": {
      "type": "object",
      "required": ["role", "allowed_task_classes", "forbidden_task_classes", "requires_gpt_final"],
      "properties": {
        "role": { "const": "worker_only" },
        "allowed_task_classes": { "type": "array", "items": { "type": "string" } },
        "forbidden_task_classes": { "type": "array", "items": { "type": "string" } },
        "requires_gpt_final": { "type": "boolean" }
      },
      "additionalProperties": false
    },
    "capability": {
      "type": "object",
      "required": ["api_reachable", "model_installed", "supports_streaming", "supports_json_schema", "supports_tools", "supports_images", "context_window", "max_parallel_requests"],
      "properties": {
        "api_reachable": { "type": "boolean" },
        "model_installed": { "type": "boolean" },
        "supports_streaming": { "type": "boolean" },
        "supports_json_schema": { "type": "boolean" },
        "supports_tools": { "type": "boolean" },
        "supports_images": { "type": "boolean" },
        "context_window": { "type": "number", "minimum": 1 },
        "max_parallel_requests": { "type": "number", "minimum": 1 }
      },
      "additionalProperties": false
    },
    "last_smoke": {
      "anyOf": [
        { "type": "null" },
        {
          "type": "object",
          "required": ["ok"],
          "properties": {
            "ok": { "type": "boolean" },
            "skipped": { "type": "boolean" },
            "ran_at": { "type": "string" },
            "prompt_hash": { "type": "string" },
            "latency_ms": { "type": "number" },
            "tokens_per_second": { "type": "number" },
            "schema_valid": { "type": "boolean" },
            "result_path": { "type": "string" },
            "status": { "enum": ["enabled_unverified", "verified", "degraded", "blocked"] },
            "reason": { "type": "string" },
            "blockers": { "type": "array", "items": { "type": "string" } }
          },
          "additionalProperties": false
        }
      ]
    },
    "blockers": { "type": "array", "items": { "type": "string" } }
  },
  "additionalProperties": false
}
