{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://hogarmas.net/content-credentials/metadata/report-schema.json",
  "title": "H/M Photo Metadata Privacy Report",
  "type": "object",
  "additionalProperties": false,
  "required": ["schema", "version", "generatedAt", "analyzer", "source", "observation", "parserWarningCount", "cleanCopy", "privacy", "limitations"],
  "properties": {
    "schema": { "const": "https://hogarmas.net/content-credentials/metadata/report-schema.json" },
    "version": { "const": "1.1.0" },
    "generatedAt": { "type": "string", "format": "date-time" },
    "analyzer": {
      "type": "object",
      "additionalProperties": false,
      "required": ["name", "parser", "parserVersion", "execution"],
      "properties": {
        "name": { "const": "H/M Photo Privacy & Provenance Scanner" },
        "parser": { "const": "exifr" },
        "parserVersion": { "const": "7.1.3" },
        "execution": { "const": "browser-local" }
      }
    },
    "source": {
      "type": "object",
      "additionalProperties": false,
      "required": ["mediaType", "sizeBytes", "sha256", "dimensions", "fileNameIncluded"],
      "properties": {
        "mediaType": { "type": "string", "maxLength": 120 },
        "sizeBytes": { "type": ["integer", "null"], "minimum": 0 },
        "sha256": { "type": ["string", "null"], "pattern": "^[a-f0-9]{64}$" },
        "dimensions": {
          "type": ["object", "null"],
          "additionalProperties": false,
          "required": ["width", "height", "pixels"],
          "properties": {
            "width": { "type": "integer", "minimum": 1 },
            "height": { "type": "integer", "minimum": 1 },
            "pixels": { "type": "integer", "minimum": 1 }
          }
        },
        "fileNameIncluded": { "const": false }
      }
    },
    "observation": { "$ref": "#/$defs/summary" },
    "parserWarningCount": { "type": "integer", "minimum": 0 },
    "cleanCopy": {
      "oneOf": [
        { "type": "null" },
        {
          "type": "object",
          "additionalProperties": false,
          "required": ["outputMediaType", "outputSizeBytes", "outputSha256", "comparison", "method", "removedContainerSegments", "reencoded", "encodedImageDataUntouched", "losslessGuaranteed"],
          "properties": {
            "outputMediaType": { "type": ["string", "null"], "maxLength": 120 },
            "outputSizeBytes": { "type": ["integer", "null"], "minimum": 0 },
            "outputSha256": { "type": ["string", "null"], "pattern": "^[a-f0-9]{64}$" },
            "comparison": {
              "type": "object",
              "required": ["before", "after", "removedTagCount", "removedSensitiveTagCount", "categoryDelta", "allObservedSensitiveFieldsRemoved"],
              "properties": {
                "before": { "$ref": "#/$defs/summary" },
                "after": { "$ref": "#/$defs/summary" },
                "removedTagCount": { "type": "integer", "minimum": 0 },
                "removedSensitiveTagCount": { "type": "integer", "minimum": 0 },
                "categoryDelta": { "$ref": "#/$defs/categories" },
                "allObservedSensitiveFieldsRemoved": { "type": "boolean" }
              }
            },
            "method": { "enum": ["jpeg-lossless-segment-strip", "canvas-reencode"] },
            "removedContainerSegments": { "type": ["integer", "null"], "minimum": 0 },
            "reencoded": { "type": "boolean" },
            "encodedImageDataUntouched": { "type": "boolean" },
            "losslessGuaranteed": { "const": false }
          }
        }
      ]
    },
    "privacy": {
      "type": "object",
      "additionalProperties": false,
      "required": ["sourceFileUploaded", "browserStorageUsed", "rawMetadataValuesIncluded", "coordinatesIncluded", "deviceIdentifiersIncluded", "fileNameIncluded"],
      "properties": {
        "sourceFileUploaded": { "const": false },
        "browserStorageUsed": { "const": false },
        "rawMetadataValuesIncluded": { "const": false },
        "coordinatesIncluded": { "const": false },
        "deviceIdentifiersIncluded": { "const": false },
        "fileNameIncluded": { "const": false }
      }
    },
    "limitations": {
      "type": "object",
      "additionalProperties": false,
      "required": ["provesMetadataWasNeverPresent", "provesMediaAuthenticity", "detectsAiGeneration", "validatesC2paSignatures", "guaranteesAllVendorMetadataParsed", "cleanCopyPreservesPixelsExactly"],
      "properties": {
        "provesMetadataWasNeverPresent": { "const": false },
        "provesMediaAuthenticity": { "const": false },
        "detectsAiGeneration": { "const": false },
        "validatesC2paSignatures": { "const": false },
        "guaranteesAllVendorMetadataParsed": { "const": false },
        "cleanCopyPreservesPixelsExactly": { "const": false }
      }
    }
  },
  "$defs": {
    "categories": {
      "type": "object",
      "additionalProperties": false,
      "required": ["location", "device", "time", "creator", "software", "notes", "embeddedPreview", "technical"],
      "properties": {
        "location": { "type": "integer" },
        "device": { "type": "integer" },
        "time": { "type": "integer" },
        "creator": { "type": "integer" },
        "software": { "type": "integer" },
        "notes": { "type": "integer" },
        "embeddedPreview": { "type": "integer" },
        "technical": { "type": "integer" }
      }
    },
    "summary": {
      "type": "object",
      "additionalProperties": false,
      "required": ["state", "tagCount", "sensitiveTagCount", "categories", "categoryCount"],
      "properties": {
        "state": { "enum": ["sensitive-fields-observed", "no-sensitive-fields-observed"] },
        "tagCount": { "type": "integer", "minimum": 0 },
        "sensitiveTagCount": { "type": "integer", "minimum": 0 },
        "categories": { "$ref": "#/$defs/categories" },
        "categoryCount": { "type": "integer", "minimum": 0, "maximum": 8 }
      }
    }
  }
}
