{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://aeternumfoundation.org/schema/golden-codex/1.2.0/pointer.schema.json",
  "title": "Golden Codex: the pointer",
  "x-status": "Golden Codex 1.2.0.",
  "description": "For thumbnails, previews and anything small or re-encoded. It says that a record exists and identifies that record. It claims nothing else about the work, except the AI disclosure when one applies.",
  "type": "object",
  "additionalProperties": false,
  "properties": {
    "gc": {
      "const": "1.2/pointer"
    },
    "record": {
      "type": "string",
      "minLength": 1,
      "description": "The record's Soulmark: the fingerprint of its canonical bytes. This value is the pointer. A record that does not hash to it is refused.",
      "pattern": "^sha256-[A-Za-z0-9_-]{43}$"
    },
    "title": {
      "type": "string",
      "minLength": 1,
      "maxLength": 120
    },
    "at": {
      "type": "string",
      "format": "uri",
      "minLength": 8,
      "description": "Optional hint where the full record can be fetched. Any address; no one ledger is required."
    },
    "made": {
      "enum": [
        "trainedAlgorithmicMedia",
        "compositeWithTrainedAlgorithmicMedia",
        "algorithmicMedia"
      ],
      "description": "Carried only for an AI-made work: the IPTC Digital Source Type term."
    },
    "ai": {
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "by": {
          "type": "string",
          "minLength": 1,
          "description": "Provider."
        },
        "sys": {
          "type": "string",
          "minLength": 1,
          "description": "System and version."
        },
        "at": {
          "type": "string",
          "pattern": "^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}(\\.\\d+)?Z$"
        },
        "id": {
          "type": "string",
          "minLength": 1,
          "description": "Content identifier."
        }
      },
      "required": [
        "by",
        "sys"
      ],
      "description": "AI disclosure carried in the file at every tier: provider, system and version, time, identifier."
    },
    "image": {
      "type": "string",
      "minLength": 1,
      "description": "Optional: the Soulmark of THIS file's image, when the pointer is made for it.",
      "pattern": "^sha256-[A-Za-z0-9_-]{43}$"
    }
  },
  "required": [
    "gc",
    "record",
    "title"
  ],
  "dependentRequired": {
    "ai": [
      "made"
    ]
  },
  "allOf": [
    {
      "if": {
        "properties": {
          "made": {
            "enum": [
              "trainedAlgorithmicMedia",
              "compositeWithTrainedAlgorithmicMedia",
              "algorithmicMedia"
            ]
          }
        },
        "required": [
          "made"
        ]
      },
      "then": {
        "required": [
          "ai"
        ]
      }
    }
  ]
}
