{
  "$schema": "http://json-schema.org/draft-07/schema#",
  "$id": "gno://schemas/metadata-summary",
  "title": "Typed metadata summary",
  "description": "Typed metadata keys indexed documents carry: observed types, document counts and the most common values. Returned by `gno metadata --json`, MCP gno_list_metadata, GET /api/metadata and SDK listMetadata.",
  "type": "object",
  "additionalProperties": false,
  "required": ["collection", "documents", "documentsWithMetadata", "keys"],
  "properties": {
    "collection": { "oneOf": [{ "type": "string" }, { "type": "null" }] },
    "documents": { "type": "integer", "minimum": 0 },
    "documentsWithMetadata": { "type": "integer", "minimum": 0 },
    "keys": {
      "type": "array",
      "items": {
        "type": "object",
        "additionalProperties": false,
        "required": ["key", "types", "documents", "values", "valuesTruncated"],
        "properties": {
          "key": { "type": "string", "minLength": 1 },
          "types": {
            "type": "array",
            "minItems": 1,
            "items": {
              "enum": [
                "string",
                "number",
                "boolean",
                "string[]",
                "number[]",
                "boolean[]"
              ]
            }
          },
          "documents": { "type": "integer", "minimum": 1 },
          "values": {
            "type": "array",
            "maxItems": 100,
            "items": {
              "type": "object",
              "additionalProperties": false,
              "required": ["value", "documents"],
              "properties": {
                "value": {
                  "oneOf": [
                    { "type": "string" },
                    { "type": "number" },
                    { "type": "boolean" }
                  ]
                },
                "documents": { "type": "integer", "minimum": 1 }
              }
            }
          },
          "valuesTruncated": { "type": "boolean" }
        }
      }
    }
  }
}
