{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://cyberdeliaskunkworks.com/data/schemas/archive-object.schema.json",
  "title": "Cyberdelia Archive Object",
  "type": "object",
  "required": ["id", "title", "class", "custody_status", "cyberdelia_path", "provenance"],
  "properties": {
    "id": {"type": "string", "minLength": 1},
    "title": {"type": "string", "minLength": 1},
    "class": {"enum": ["record", "software", "dataset", "observation", "media", "manual", "paper", "research-package", "derivative", "other"]},
    "custody_status": {"enum": ["source-indexed", "mirror-queued", "acquiring", "mirrored", "verified", "mirror-restricted", "source-lost", "superseded"]},
    "cyberdelia_path": {"type": "string", "pattern": "^/"},
    "public_url": {"type": ["string", "null"]},
    "sha256": {"type": ["string", "null"], "pattern": "^[A-Fa-f0-9]{64}$"},
    "size_bytes": {"type": ["integer", "null"], "minimum": 0},
    "mime_type": {"type": ["string", "null"]},
    "retrieved_at": {"type": ["string", "null"], "format": "date-time"},
    "license": {
      "type": "object",
      "properties": {
        "name": {"type": ["string", "null"]},
        "redistribution": {"enum": ["allowed", "restricted", "unknown", "not-applicable"]},
        "notes": {"type": ["string", "null"]}
      },
      "required": ["redistribution"]
    },
    "provenance": {
      "type": "object",
      "required": ["source_url"],
      "properties": {
        "source_url": {"type": ["string", "null"]},
        "authority": {"type": ["string", "null"]},
        "upstream_filename": {"type": ["string", "null"]},
        "upstream_identifier": {"type": ["string", "null"]},
        "upstream_version": {"type": ["string", "null"]},
        "notes": {"type": ["string", "null"]}
      }
    },
    "derivation": {
      "type": ["object", "null"],
      "properties": {
        "is_derivative": {"type": "boolean"},
        "parent_ids": {"type": "array", "items": {"type": "string"}},
        "transformations": {"type": "array", "items": {"type": "string"}}
      }
    },
    "integrity": {
      "type": "object",
      "properties": {
        "verified_at": {"type": ["string", "null"], "format": "date-time"},
        "verification_method": {"type": ["string", "null"]},
        "expected_sha256": {"type": ["string", "null"]}
      }
    }
  },
  "additionalProperties": true
}
