{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://docs.shimpz.com/specs/driver/v1/manifest.schema.json",
  "title": "Shimpz Driver Manifest v1",
  "description": "Language-neutral discovery contract for one Space-scoped Shimpz Driver.",
  "type": "object",
  "additionalProperties": false,
  "required": [
    "schema_version",
    "id",
    "title",
    "version",
    "summary",
    "interface",
    "scope",
    "credential_policy",
    "data_plane",
    "port",
    "health_path",
    "metadata_path",
    "capabilities"
  ],
  "properties": {
    "schema_version": {
      "const": 1
    },
    "id": {
      "type": "string",
      "pattern": "^[a-z][a-z0-9]*(?:-[a-z0-9]+)*$",
      "maxLength": 80
    },
    "title": {
      "type": "string",
      "pattern": "^\\S(?:.*\\S)?$",
      "maxLength": 80
    },
    "version": {
      "type": "string",
      "pattern": "^(?:0|[1-9][0-9]*)\\.(?:0|[1-9][0-9]*)\\.(?:0|[1-9][0-9]*)$",
      "maxLength": 80
    },
    "summary": {
      "type": "string",
      "pattern": "^\\S(?:.*\\S)?$",
      "maxLength": 160
    },
    "interface": {
      "type": "string",
      "pattern": "^shimpz\\.[a-z][a-z0-9-]*/v[1-9][0-9]*$",
      "maxLength": 80
    },
    "scope": {
      "const": "space"
    },
    "credential_policy": {
      "enum": ["none", "managed", "managed-or-byok"]
    },
    "credential_schema_path": {
      "type": "string",
      "pattern": "^/[a-z0-9][a-z0-9-]*(?:/[a-z0-9][a-z0-9-]*)*$",
      "maxLength": 80
    },
    "data_plane": {
      "enum": ["direct", "brokered"]
    },
    "port": {
      "type": "integer",
      "minimum": 1,
      "maximum": 65535
    },
    "health_path": {
      "type": "string",
      "pattern": "^/[a-z0-9][a-z0-9/-]*$",
      "maxLength": 80
    },
    "metadata_path": {
      "type": "string",
      "pattern": "^/[a-z0-9][a-z0-9/-]*$",
      "maxLength": 80
    },
    "capabilities": {
      "type": "object",
      "additionalProperties": false,
      "required": ["operations"],
      "properties": {
        "operations": {
          "type": "array",
          "minItems": 1,
          "uniqueItems": true,
          "items": {
            "type": "string",
            "pattern": "^[a-z][a-z0-9]*(?:\\.[a-z][a-z0-9]*)+$"
          }
        }
      }
    }
  },
  "allOf": [
    {
      "if": {
        "properties": {
          "credential_policy": {
            "const": "managed-or-byok"
          }
        },
        "required": ["credential_policy"]
      },
      "then": {
        "required": ["credential_schema_path"]
      },
      "else": {
        "not": {
          "required": ["credential_schema_path"]
        }
      }
    }
  ]
}
