{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://hogarmas.net/content-credentials/comparison-schema.json",
  "title": "H/M Content Credentials comparison",
  "type": "object",
  "additionalProperties": false,
  "required": ["schema", "ruleset", "before", "after", "byteIdentity", "observations", "differences", "privacy", "limitations"],
  "properties": {
    "schema": { "const": "hm.content-credentials-comparison.v1" },
    "ruleset": { "const": "2026-07-22.2" },
    "before": { "$ref": "#/$defs/fileSummary" },
    "after": { "$ref": "#/$defs/fileSummary" },
    "byteIdentity": { "enum": ["identical", "different", "unknown"] },
    "observations": {
      "type": "array",
      "maxItems": 20,
      "items": {
        "type": "object",
        "additionalProperties": false,
        "required": ["id", "kind", "before", "after", "changed"],
        "properties": {
          "id": { "enum": ["manifest-presence", "manifest-count", "integrity", "signer-trust", "ai-origin", "claim-generator", "signer-name", "actions", "ingredients", "validation-failures"] },
          "kind": { "enum": ["state", "number", "text"] },
          "before": { "type": ["string", "integer"] },
          "after": { "type": ["string", "integer"] },
          "changed": { "type": "boolean" }
        }
      }
    },
    "differences": {
      "type": "object",
      "additionalProperties": false,
      "required": ["changedObservationCount", "digitalSourceTypes", "validationCodes", "actionTypes"],
      "properties": {
        "changedObservationCount": { "type": "integer", "minimum": 0 },
        "digitalSourceTypes": { "$ref": "#/$defs/setDifference" },
        "validationCodes": { "$ref": "#/$defs/setDifference" },
        "actionTypes": { "$ref": "#/$defs/setDifference" }
      }
    },
    "privacy": {
      "type": "object",
      "additionalProperties": false,
      "required": ["processedLocally", "sourceFilesUploaded", "browserStorageUsed", "exportedFileNamesIncluded", "exportedHashesIncluded"],
      "properties": {
        "processedLocally": { "const": true },
        "sourceFilesUploaded": { "const": false },
        "browserStorageUsed": { "const": false },
        "exportedFileNamesIncluded": { "type": "boolean" },
        "exportedHashesIncluded": { "const": true }
      }
    },
    "limitations": {
      "type": "object",
      "additionalProperties": false,
      "required": ["changeExplained", "semanticTruthProven", "authorshipProven", "aiAbsenceProven", "legalComplianceCertified"],
      "properties": {
        "changeExplained": { "const": false },
        "semanticTruthProven": { "const": false },
        "authorshipProven": { "const": false },
        "aiAbsenceProven": { "const": false },
        "legalComplianceCertified": { "const": false }
      }
    }
  },
  "$defs": {
    "fileSummary": {
      "type": "object",
      "additionalProperties": false,
      "required": ["fileName", "mimeType", "sizeBytes", "sha256", "manifestPresent", "manifestCount", "integrity", "signerTrust", "aiOrigin", "actionCount", "ingredientCount", "validationFailureCount"],
      "properties": {
        "fileName": { "type": "string", "maxLength": 320 },
        "mimeType": { "type": "string", "maxLength": 120 },
        "sizeBytes": { "type": "integer", "minimum": 0 },
        "sha256": { "type": "string", "maxLength": 320 },
        "manifestPresent": { "type": "boolean" },
        "manifestCount": { "type": "integer", "minimum": 0 },
        "integrity": { "type": "string", "maxLength": 40 },
        "signerTrust": { "type": "string", "maxLength": 40 },
        "aiOrigin": { "type": "string", "maxLength": 40 },
        "actionCount": { "type": "integer", "minimum": 0 },
        "ingredientCount": { "type": "integer", "minimum": 0 },
        "validationFailureCount": { "type": "integer", "minimum": 0 }
      }
    },
    "setDifference": {
      "type": "object",
      "additionalProperties": false,
      "required": ["before", "after", "added", "removed"],
      "properties": {
        "before": { "$ref": "#/$defs/stringList" },
        "after": { "$ref": "#/$defs/stringList" },
        "added": { "$ref": "#/$defs/stringList" },
        "removed": { "$ref": "#/$defs/stringList" }
      }
    },
    "stringList": { "type": "array", "maxItems": 80, "items": { "type": "string", "maxLength": 320 }, "uniqueItems": true }
  }
}
