{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://static-agent-marketplace.org/schemas/draft/case.schema.json",
  "title": "Static Agent Marketplace conformance case",
  "description": "The case.json of one conformance case directory, next to its input/ and expected/ folders; see section 16.2 of the specification.",
  "type": "object",
  "required": ["$schema", "id", "description", "spec", "level", "expect", "parameters"],
  "properties": {
    "$schema": {"const": "https://static-agent-marketplace.org/schemas/draft/case.schema.json"},
    "id": {
      "description": "<area>/<case>, equal to the case directory path under conformance/<version>/.",
      "type": "string",
      "pattern": "^[a-z0-9-]+/[a-z0-9-]+$"
    },
    "description": {"type": "string", "minLength": 1, "maxLength": 500},
    "spec": {
      "description": "Numbers of the specification sections the case exercises.",
      "type": "array",
      "minItems": 1,
      "uniqueItems": true,
      "items": {"type": "string", "pattern": "^([0-9]+(\\.[0-9]+)*|[A-Z](\\.[0-9]+)*)$"}
    },
    "level": {
      "description": "required cases must pass for a conformance claim; optional cases cover OPTIONAL behaviour.",
      "enum": ["required", "optional"]
    },
    "expect": {"enum": ["accept", "reject"]},
    "rules": {
      "description": "For reject cases, the rule identifiers of section 4.4 that the input violates.",
      "type": "array",
      "minItems": 1,
      "items": {"type": "string", "pattern": "^[a-z0-9]+(-[a-z0-9]+)*$"}
    },
    "parameters": {
      "description": "Generator parameters (section 4.3).",
      "type": "object",
      "required": ["source", "siteUrl", "base", "pages", "hostPackages"],
      "properties": {
        "source": {"enum": ["skills", "marketplace"]},
        "siteUrl": {"type": "string", "pattern": "^https://[a-z0-9.-]+(:[0-9]+)?$"},
        "base": {"type": "string", "pattern": "^/([A-Za-z0-9._-]+/)+$"},
        "pages": {"type": "string", "pattern": "^/([A-Za-z0-9._-]+/)*$"},
        "marketplace": {
          "type": "object",
          "required": ["name", "owner"],
          "properties": {
            "name": {"type": "string"},
            "owner": {"type": "object", "required": ["name"]},
            "description": {"type": "string"}
          },
          "additionalProperties": false
        },
        "version": {"type": "string"},
        "license": {"type": "string"},
        "lock": {
          "description": "Path of the lock in input/, relative to it (sections 11.2 and 16.2). Absent: the input has no lock.",
          "type": "string",
          "pattern": "^[A-Za-z0-9._-]+(/[A-Za-z0-9._-]+)*\\.json$"
        },
        "hostPackages": {
          "type": "array",
          "uniqueItems": true,
          "items": {"enum": ["codex", "antigravity", "gemini", "bundle"]}
        }
      },
      "additionalProperties": false
    }
  },
  "allOf": [
    {
      "if": {"properties": {"expect": {"const": "reject"}}},
      "then": {"required": ["rules"]},
      "else": {"not": {"required": ["rules"]}}
    },
    {
      "if": {"properties": {"parameters": {"properties": {"source": {"const": "skills"}}}}},
      "then": {"properties": {"parameters": {"required": ["marketplace", "version"]}}}
    }
  ],
  "additionalProperties": false
}
