{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://raw.githubusercontent.com/shruggietech/insonic/v1.3.0/schemas/v1.3.0/base-model-manifest.schema.json",
  "title": "insonic downloaded base model manifest",
  "description": "Exact downloaded model identity, upstream revision, declared capabilities/license and ordered file digests. Registration does not claim local availability. Acquisition verifies every declared file before an available installation is committed. Credentials remain opaque references and never appear in URLs.",
  "type": "object",
  "properties": {
    "kind": {
      "const": "base-model-manifest",
      "description": "Downloaded-model document discriminator, separate from speaker-trained models."
    },
    "schema_version": {
      "const": "1.3.0",
      "description": "Insonic contract release version."
    },
    "name": {
      "type": "string",
      "minLength": 1,
      "maxLength": 256,
      "description": "Exact upstream model family/name."
    },
    "model_version": {
      "type": "string",
      "minLength": 1,
      "maxLength": 256,
      "description": "Exact selected upstream model version, rather than an unpinned latest alias."
    },
    "upstream_revision": {
      "type": "string",
      "minLength": 1,
      "maxLength": 512,
      "description": "Immutable upstream revision associated with this manifest."
    },
    "capabilities": {
      "type": "array",
      "minItems": 1,
      "maxItems": 32,
      "description": "Declared adapter capabilities for later selection; registration does not run inference.",
      "items": {
        "type": "string",
        "minLength": 1,
        "maxLength": 128,
        "description": "Declared capability name."
      }
    },
    "license": {
      "type": "string",
      "minLength": 1,
      "description": "Upstream license declaration retained with the selected model."
    },
    "files": {
      "type": "array",
      "minItems": 1,
      "maxItems": 64,
      "description": "Ordered required file roles and independently verified byte identities. The application rejects duplicate roles.",
      "items": {
        "type": "object",
        "additionalProperties": false,
        "properties": {
          "role": {
            "type": "string",
            "minLength": 1,
            "maxLength": 128,
            "description": "Unique role of this required model file."
          },
          "sha256": {
            "$ref": "common.schema.json#/$defs/sha256",
            "description": "Expected lowercase SHA-256 of complete downloaded bytes."
          },
          "size": {
            "type": "integer",
            "minimum": 0,
            "description": "Expected complete byte length, preserving known zero."
          },
          "url": {
            "type": "string",
            "format": "uri",
            "description": "Stable HTTPS source without user information, authentication query values or fragments. Explicit local_http permits HTTP only for a loopback model service; redirects must satisfy the same route rules."
          },
          "credential_id": {
            "$ref": "common.schema.json#/$defs/uuid",
            "description": "Optional workspace-scoped credential reference resolved privately by the selected adapter."
          },
          "local_http": {
            "type": "boolean",
            "default": false,
            "description": "Explicit selection of unencrypted HTTP for localhost or a loopback IP only."
          }
        },
        "required": [
          "role",
          "sha256",
          "size",
          "url"
        ]
      }
    },
    "compatibility": {
      "$ref": "common.schema.json#/$defs/modelCompatibility",
      "description": "Optional adapter/runtime/audio compatibility retained in the immutable manifest digest."
    }
  },
  "required": [
    "kind",
    "schema_version",
    "name",
    "model_version",
    "upstream_revision",
    "capabilities",
    "license",
    "files"
  ],
  "additionalProperties": false,
  "examples": [
    {
      "kind": "base-model-manifest",
      "schema_version": "1.3.0",
      "name": "example-recognizer",
      "model_version": "1.0.0",
      "upstream_revision": "immutable-revision-1",
      "capabilities": [
        "recognition"
      ],
      "license": "Apache-2.0",
      "files": [
        {
          "role": "weights",
          "sha256": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
          "size": 1048576,
          "url": "https://models.example.org/recognizer/1.0.0/weights.bin"
        }
      ]
    }
  ]
}
