{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://bitcoinuniverseio.github.io/atomicals-and-arc-20/contracts/versions/version-manifest.schema.json",
  "title": "Version and provenance manifest",
  "description": "Source sets the documentation can describe. A set exists only when every source in it has verified, pinned material. Fabricated historical snapshots are forbidden.",
  "type": "object",
  "required": ["manifestVersion", "sets"],
  "additionalProperties": false,
  "properties": {
    "manifestVersion": { "const": "1.0.0" },
    "sets": { "type": "array", "minItems": 1, "items": { "$ref": "#/$defs/sourceSet" } }
  },
  "$defs": {
    "date": { "type": "string", "pattern": "^\\d{4}-\\d{2}-\\d{2}$" },
    "pinnedSource": {
      "type": "object",
      "required": ["sourceId", "revision"],
      "additionalProperties": false,
      "properties": {
        "sourceId": { "type": "string" },
        "revision": { "type": ["string", "null"] },
        "note": { "type": "string" }
      }
    },
    "sourceSet": {
      "type": "object",
      "required": [
        "id",
        "label",
        "status",
        "verifiedAt",
        "networks",
        "sources",
        "apiContractVersions"
      ],
      "additionalProperties": false,
      "properties": {
        "id": { "type": "string", "pattern": "^[a-z0-9]+(?:[-][a-z0-9]+)*$" },
        "label": { "type": "string", "minLength": 3 },
        "status": { "enum": ["current", "archived"] },
        "verifiedAt": { "$ref": "#/$defs/date" },
        "networks": {
          "type": "array",
          "minItems": 1,
          "items": { "enum": ["mainnet", "testnet", "signet", "regtest", "none"] }
        },
        "sources": {
          "type": "object",
          "required": ["protocol", "cli", "aipRegistry", "universeRuntime", "avmInterpreter", "docsBuild"],
          "additionalProperties": false,
          "properties": {
            "protocol": { "$ref": "#/$defs/pinnedSource" },
            "cli": { "$ref": "#/$defs/pinnedSource" },
            "aipRegistry": { "$ref": "#/$defs/pinnedSource" },
            "universeRuntime": {
              "type": "array",
              "items": { "$ref": "#/$defs/pinnedSource" },
              "minItems": 1
            },
            "avmInterpreter": { "$ref": "#/$defs/pinnedSource" },
            "docsBuild": {
              "type": "object",
              "required": ["docsVersion"],
              "additionalProperties": false,
              "properties": {
                "docsVersion": { "type": "string" },
                "note": { "type": "string" }
              }
            }
          }
        },
        "apiContractVersions": {
          "type": "array",
          "minItems": 1,
          "items": {
            "type": "object",
            "required": ["document", "version"],
            "additionalProperties": false,
            "properties": {
              "document": { "enum": ["arc20", "atomicals-nfts-realms", "marketplace-v1"] },
              "version": { "type": "string" }
            }
          }
        },
        "drift": {
          "type": "object",
          "additionalProperties": false,
          "properties": {
            "findings": { "type": "integer", "minimum": 0 },
            "checkedAt": { "$ref": "#/$defs/date" }
          }
        }
      }
    }
  }
}
