{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://platformforge.dev/schemas/lab.schema.json",
  "title": "PlatformForge Lab",
  "type": "object",
  "additionalProperties": false,
  "required": ["version", "id", "title", "summary", "difficulty", "estimatedMinutes", "image", "tasks", "limits"],
  "properties": {
    "version": { "const": 1 },
    "id": { "type": "string", "pattern": "^[a-z0-9]+(?:-[a-z0-9]+)*$" },
    "title": { "type": "string", "minLength": 3 },
    "summary": { "type": "string", "minLength": 10 },
    "difficulty": { "enum": ["beginner", "intermediate", "advanced", "capstone"] },
    "estimatedMinutes": { "type": "integer", "minimum": 5, "maximum": 240 },
    "prerequisites": { "type": "array", "items": { "type": "string" }, "uniqueItems": true },
    "image": { "type": "string", "minLength": 3 },
    "shell": { "type": "string" },
    "runtime": {
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "type": { "enum": ["container", "k3d"] },
        "addons": {
          "type": "array",
          "items": { "enum": ["kyverno", "gateway", "gateway-controller", "etcd-snapshot", "registry", "otel", "multi-cluster"] },
          "uniqueItems": true
        },
        "hostBuild": {
          "type": "object",
          "additionalProperties": false,
          "required": ["dockerfile", "context", "image"],
          "properties": {
            "dockerfile": { "type": "string", "minLength": 1 },
            "context": { "type": "string", "minLength": 1 },
            "image": { "type": "string", "minLength": 1 }
          }
        }
      }
    },
    "setup": { "type": "array", "items": { "type": "string" } },
    "tasks": {
      "type": "array",
      "minItems": 1,
      "items": {
        "type": "object",
        "additionalProperties": false,
        "required": ["id", "title", "description", "checks"],
        "properties": {
          "id": { "type": "string" },
          "title": { "type": "string" },
          "description": { "type": "string" },
          "hints": { "type": "array", "items": { "type": "string" } },
          "checks": {
            "type": "array",
            "minItems": 1,
            "items": {
              "type": "object",
              "additionalProperties": false,
              "required": ["type", "name"],
              "properties": {
                "type": { "enum": ["command", "file", "process", "port", "http", "docker", "kubernetes"] },
                "name": { "type": "string" },
                "command": { "type": "string" },
                "path": { "type": "string" },
                "value": { "type": "string" },
                "port": { "type": "integer", "minimum": 1, "maximum": 65535 }
              }
            }
          }
        }
      }
    },
    "limits": {
      "type": "object",
      "additionalProperties": false,
      "required": ["cpus", "memory", "pids", "timeout", "network"],
      "properties": {
        "cpus": { "type": "string" },
        "memory": { "type": "string" },
        "pids": { "type": "integer", "minimum": 16 },
        "timeout": { "type": "integer", "minimum": 60 },
        "network": { "type": "boolean" },
        "privileged": { "const": false }
      }
    },
    "attribution": { "type": "string" }
  }
}
