{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://aeternumfoundation.org/schema/golden-codex/1.2.0/label.schema.json",
  "title": "Golden Codex: the label",
  "x-status": "Golden Codex 1.2.0.",
  "description": "What a browser, shop, feed or agent can read without a second request. Every field copies a statement from the full record; none makes a new statement.",
  "type": "object",
  "additionalProperties": false,
  "properties": {
    "gc": {
      "const": "1.2/label"
    },
    "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
    },
    "made": {
      "enum": [
        "digitalCapture",
        "computationalCapture",
        "negativeFilm",
        "positiveFilm",
        "print",
        "humanEdits",
        "compositeWithTrainedAlgorithmicMedia",
        "algorithmicallyEnhanced",
        "digitalCreation",
        "dataDrivenMedia",
        "trainedAlgorithmicMedia",
        "algorithmicMedia",
        "screenCapture",
        "virtualRecording",
        "composite",
        "compositeCapture",
        "compositeSynthetic",
        "empty",
        "trainedAlgorithmicData",
        "not_determined"
      ],
      "description": "How the pixels were made: the IPTC Digital Source Type term (or one of the two C2PA terms), or not_determined. The full URI is http://cv.iptc.org/newscodes/digitalsourcetype/<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."
    },
    "credit": {
      "type": "string",
      "minLength": 1,
      "description": "One maker credit as carried by the full record, or 'unknown'.",
      "maxLength": 120
    },
    "status": {
      "type": "string",
      "format": "uri",
      "minLength": 8,
      "description": "One rights status address, as reported in the full record."
    },
    "description": {
      "type": "string",
      "minLength": 1,
      "maxLength": 300
    },
    "alt_text": {
      "type": "string",
      "minLength": 1,
      "maxLength": 250
    },
    "image": {
      "type": "string",
      "minLength": 1,
      "description": "The image's Soulmark for THIS rendition: the fingerprint of this file's image, when the label is made for it.",
      "pattern": "^sha256-[A-Za-z0-9_-]{43}$"
    }
  },
  "required": [
    "gc",
    "record",
    "title",
    "image"
  ],
  "dependentRequired": {
    "ai": [
      "made"
    ]
  },
  "allOf": [
    {
      "if": {
        "properties": {
          "made": {
            "enum": [
              "trainedAlgorithmicMedia",
              "compositeWithTrainedAlgorithmicMedia",
              "algorithmicMedia"
            ]
          }
        },
        "required": [
          "made"
        ]
      },
      "then": {
        "required": [
          "ai"
        ]
      }
    },
    {
      "if": {
        "required": [
          "ai"
        ]
      },
      "then": {
        "required": [
          "made"
        ],
        "properties": {
          "made": {
            "enum": [
              "trainedAlgorithmicMedia",
              "compositeWithTrainedAlgorithmicMedia",
              "algorithmicMedia"
            ]
          }
        }
      }
    }
  ]
}
