{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://bendyline.com/gezk/0.5/schemas/catalog-manifest.schema.json",
  "type": "object",
  "properties": {
    "kind": {
      "type": "string",
      "const": "gezk-catalog"
    },
    "formatVersion": {
      "type": "string",
      "const": "0.5"
    },
    "indexSchemaVersion": {
      "type": "number",
      "const": 2
    },
    "id": {
      "type": "string",
      "pattern": "^[a-z0-9]([a-z0-9-]{0,62}[a-z0-9])?$"
    },
    "version": {
      "type": "string",
      "minLength": 1,
      "maxLength": 128,
      "pattern": "^[A-Za-z0-9](?:[A-Za-z0-9._+-]{0,126}[A-Za-z0-9])?$"
    },
    "name": {
      "type": "string",
      "minLength": 1
    },
    "description": {
      "type": "string"
    },
    "language": {
      "type": "string",
      "minLength": 2
    },
    "publisher": {
      "type": "object",
      "properties": {
        "id": {
          "type": "string",
          "pattern": "^[a-z0-9]([a-z0-9-]{0,62}[a-z0-9])?$"
        },
        "name": {
          "type": "string",
          "minLength": 1
        },
        "url": {
          "type": "string"
        }
      },
      "required": [
        "id",
        "name"
      ]
    },
    "createdAt": {
      "type": "string"
    },
    "sourceSnapshot": {
      "type": "object",
      "properties": {
        "name": {
          "type": "string"
        },
        "date": {
          "type": "string"
        },
        "taxonomyVersion": {
          "type": "string"
        }
      },
      "required": [
        "name",
        "date"
      ]
    },
    "license": {
      "type": "object",
      "properties": {
        "name": {
          "type": "string",
          "minLength": 1
        },
        "spdx": {
          "type": "string"
        },
        "noticePath": {
          "type": "string",
          "minLength": 1
        },
        "attributionRequired": {
          "type": "boolean"
        }
      },
      "required": [
        "name",
        "noticePath",
        "attributionRequired"
      ]
    },
    "embedding": {
      "type": "object",
      "properties": {
        "id": {
          "type": "string",
          "minLength": 1
        },
        "model": {
          "type": "object",
          "properties": {
            "repo": {
              "type": "string",
              "minLength": 1
            },
            "revision": {
              "type": "string",
              "minLength": 1
            },
            "onnxFile": {
              "type": "string",
              "minLength": 1
            },
            "onnxDigest": {
              "type": "string",
              "pattern": "^sha256:[0-9a-f]{64}$"
            }
          },
          "required": [
            "repo",
            "revision"
          ]
        },
        "tokenizer": {
          "type": "object",
          "properties": {
            "kind": {
              "type": "string",
              "minLength": 1
            },
            "file": {
              "type": "string",
              "minLength": 1
            },
            "digest": {
              "type": "string",
              "pattern": "^sha256:[0-9a-f]{64}$"
            }
          },
          "required": [
            "kind"
          ]
        },
        "pooling": {
          "type": "string",
          "enum": [
            "mean",
            "cls",
            "last"
          ]
        },
        "normalized": {
          "type": "boolean"
        },
        "dimensions": {
          "type": "integer",
          "exclusiveMinimum": 0,
          "maximum": 9007199254740991
        },
        "maxTokens": {
          "type": "integer",
          "exclusiveMinimum": 0,
          "maximum": 9007199254740991
        },
        "queryInstruction": {
          "type": "string"
        },
        "passageInstruction": {
          "type": "string"
        },
        "vectorEncoding": {
          "type": "string",
          "enum": [
            "bit+int8"
          ]
        },
        "distance": {
          "type": "object",
          "properties": {
            "stage1": {
              "type": "string",
              "const": "hamming"
            },
            "stage2": {
              "type": "string",
              "const": "cosine"
            }
          },
          "required": [
            "stage1",
            "stage2"
          ]
        },
        "quantization": {
          "type": "object",
          "properties": {
            "int8": {
              "type": "object",
              "properties": {
                "method": {
                  "type": "string",
                  "const": "symmetric-linear"
                },
                "scale": {
                  "type": "number",
                  "const": 127
                }
              },
              "required": [
                "method",
                "scale"
              ]
            },
            "binary": {
              "type": "object",
              "properties": {
                "method": {
                  "type": "string",
                  "const": "sign"
                },
                "threshold": {
                  "type": "number",
                  "const": 0
                },
                "packing": {
                  "type": "string",
                  "const": "lsb-first"
                }
              },
              "required": [
                "method",
                "threshold",
                "packing"
              ]
            }
          },
          "required": [
            "int8",
            "binary"
          ]
        }
      },
      "required": [
        "id",
        "model",
        "tokenizer",
        "pooling",
        "normalized",
        "dimensions",
        "maxTokens",
        "queryInstruction",
        "passageInstruction",
        "vectorEncoding",
        "distance",
        "quantization"
      ]
    },
    "chunking": {
      "type": "object",
      "properties": {
        "id": {
          "type": "string",
          "minLength": 1
        },
        "unit": {
          "type": "string",
          "enum": [
            "tokens",
            "chars"
          ]
        },
        "tokenizer": {
          "type": "string",
          "enum": [
            "profile",
            "none"
          ]
        },
        "target": {
          "type": "integer",
          "exclusiveMinimum": 0,
          "maximum": 9007199254740991
        },
        "overlap": {
          "type": "integer",
          "minimum": 0,
          "maximum": 9007199254740991
        },
        "contextHeader": {
          "type": "object",
          "properties": {
            "max": {
              "type": "integer",
              "minimum": 0,
              "maximum": 9007199254740991
            }
          },
          "required": [
            "max"
          ]
        }
      },
      "required": [
        "id",
        "unit",
        "tokenizer",
        "target",
        "overlap",
        "contextHeader"
      ]
    },
    "topics": {
      "minItems": 1,
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "pattern": "^[a-z0-9]([a-z0-9-]{0,62}[a-z0-9])?$"
          },
          "name": {
            "type": "string",
            "minLength": 1
          }
        },
        "required": [
          "id",
          "name"
        ]
      }
    },
    "router": {
      "type": "object",
      "properties": {
        "shardTargetChunks": {
          "type": "integer",
          "exclusiveMinimum": 0,
          "maximum": 9007199254740991
        },
        "shards": {
          "type": "array",
          "items": {
            "type": "object",
            "properties": {
              "id": {
                "type": "integer",
                "minimum": 0,
                "maximum": 9007199254740991
              },
              "path": {
                "type": "string",
                "minLength": 1
              },
              "chunks": {
                "type": "integer",
                "minimum": 0,
                "maximum": 9007199254740991
              },
              "documents": {
                "type": "integer",
                "minimum": 0,
                "maximum": 9007199254740991
              },
              "centroids": {
                "type": "integer",
                "minimum": 0,
                "maximum": 9007199254740991
              },
              "sha256": {
                "type": "string",
                "pattern": "^[0-9a-f]{64}$"
              }
            },
            "required": [
              "id",
              "path",
              "chunks",
              "documents",
              "centroids",
              "sha256"
            ]
          }
        },
        "totalCentroids": {
          "type": "integer",
          "minimum": 0,
          "maximum": 9007199254740991
        }
      },
      "required": [
        "shardTargetChunks",
        "shards",
        "totalCentroids"
      ]
    },
    "counts": {
      "type": "object",
      "properties": {
        "documents": {
          "type": "integer",
          "minimum": 0,
          "maximum": 9007199254740991
        },
        "chunks": {
          "type": "integer",
          "minimum": 0,
          "maximum": 9007199254740991
        },
        "shards": {
          "type": "integer",
          "exclusiveMinimum": 0,
          "maximum": 9007199254740991
        }
      },
      "required": [
        "documents",
        "chunks",
        "shards"
      ]
    },
    "files": {
      "minItems": 1,
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "path": {
            "type": "string",
            "minLength": 1
          },
          "sizeBytes": {
            "type": "integer",
            "minimum": 0,
            "maximum": 9007199254740991
          },
          "sha256": {
            "type": "string",
            "pattern": "^[0-9a-f]{64}$"
          }
        },
        "required": [
          "path",
          "sizeBytes",
          "sha256"
        ]
      }
    },
    "requires": {
      "type": "object",
      "properties": {
        "formatVersion": {
          "type": "string",
          "const": "0.5"
        },
        "features": {
          "type": "array",
          "items": {
            "type": "string"
          }
        }
      },
      "required": [
        "formatVersion"
      ]
    },
    "smokeQueries": {
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "query": {
            "type": "string",
            "minLength": 1
          },
          "expectedDocumentIds": {
            "minItems": 1,
            "type": "array",
            "items": {
              "type": "string",
              "minLength": 1,
              "maxLength": 256
            }
          }
        },
        "required": [
          "query",
          "expectedDocumentIds"
        ]
      }
    },
    "toolchain": {
      "type": "object",
      "properties": {
        "name": {
          "type": "string",
          "minLength": 1
        },
        "version": {
          "type": "string",
          "minLength": 1
        },
        "node": {
          "type": "string"
        },
        "sqlite": {
          "type": "string"
        },
        "platform": {
          "type": "string"
        },
        "modelDigest": {
          "type": "string"
        },
        "tokenizerDigest": {
          "type": "string"
        }
      },
      "required": [
        "name",
        "version"
      ]
    },
    "signature": {
      "type": "object",
      "properties": {
        "algorithm": {
          "type": "string",
          "const": "ed25519"
        },
        "keyId": {
          "type": "string",
          "minLength": 1
        },
        "canonicalization": {
          "type": "string",
          "const": "rfc8785"
        },
        "value": {
          "type": "string",
          "minLength": 1
        }
      },
      "required": [
        "algorithm",
        "keyId",
        "canonicalization",
        "value"
      ]
    }
  },
  "required": [
    "kind",
    "formatVersion",
    "indexSchemaVersion",
    "id",
    "version",
    "name",
    "language",
    "publisher",
    "createdAt",
    "license",
    "embedding",
    "chunking",
    "topics",
    "router",
    "counts",
    "files",
    "requires"
  ]
}
