{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://hogarmas.net/content-credentials/manifest-diff-schema.json",
  "title": "H/M Content Credentials manifest diff",
  "type": "object",
  "additionalProperties": false,
  "required": ["schema", "ruleset", "before", "after", "summary", "changes", "privacy", "limitations"],
  "properties": {
    "schema": { "const": "hm.content-credentials-manifest-diff.v1" },
    "ruleset": { "const": "2026-07-22.1" },
    "before": { "$ref": "#/$defs/side" },
    "after": { "$ref": "#/$defs/side" },
    "summary": {
      "type": "object",
      "additionalProperties": false,
      "required": ["identical", "changedPathCount", "addedValueCount", "removedValueCount"],
      "properties": {
        "identical": { "type": "boolean" },
        "changedPathCount": { "type": "integer", "minimum": 0, "maximum": 13 },
        "addedValueCount": { "type": "integer", "minimum": 0 },
        "removedValueCount": { "type": "integer", "minimum": 0 }
      }
    },
    "changes": {
      "type": "array",
      "maxItems": 13,
      "items": {
        "oneOf": [
          { "$ref": "#/$defs/scalarChange" },
          { "$ref": "#/$defs/setChange" }
        ]
      }
    },
    "privacy": {
      "type": "object",
      "additionalProperties": false,
      "required": ["processedLocally", "sourceFilesUploaded", "browserStorageUsed", "rawManifestIncluded", "certificateSerialIncluded", "exportedFileNamesIncluded"],
      "properties": {
        "processedLocally": { "const": true },
        "sourceFilesUploaded": { "const": false },
        "browserStorageUsed": { "const": false },
        "rawManifestIncluded": { "const": false },
        "certificateSerialIncluded": { "const": false },
        "exportedFileNamesIncluded": { "type": "boolean" }
      }
    },
    "limitations": {
      "type": "object",
      "additionalProperties": false,
      "required": ["changeCauseIdentified", "actorIdentified", "semanticTruthProven", "completeCertificateChainExposed", "legalComplianceCertified"],
      "properties": {
        "changeCauseIdentified": { "const": false },
        "actorIdentified": { "const": false },
        "semanticTruthProven": { "const": false },
        "completeCertificateChainExposed": { "const": false },
        "legalComplianceCertified": { "const": false }
      }
    }
  },
  "$defs": {
    "side": {
      "type": "object",
      "additionalProperties": false,
      "required": ["fileName", "manifestCount", "activeManifest"],
      "properties": {
        "fileName": { "type": "string", "maxLength": 320 },
        "manifestCount": { "type": "integer", "minimum": 0, "maximum": 200 },
        "activeManifest": { "type": "string", "maxLength": 320 }
      }
    },
    "scalarChange": {
      "type": "object",
      "additionalProperties": false,
      "required": ["path", "kind", "before", "after", "changed"],
      "properties": {
        "path": { "type": "string", "maxLength": 120 },
        "kind": { "const": "scalar" },
        "before": { "type": "string", "maxLength": 320 },
        "after": { "type": "string", "maxLength": 320 },
        "changed": { "const": true }
      }
    },
    "setChange": {
      "type": "object",
      "additionalProperties": false,
      "required": ["path", "kind", "before", "after", "added", "removed", "changed"],
      "properties": {
        "path": { "type": "string", "maxLength": 120 },
        "kind": { "const": "set" },
        "before": { "$ref": "#/$defs/stringSet" },
        "after": { "$ref": "#/$defs/stringSet" },
        "added": { "$ref": "#/$defs/stringSet" },
        "removed": { "$ref": "#/$defs/stringSet" },
        "changed": { "const": true }
      }
    },
    "stringSet": {
      "type": "array",
      "maxItems": 200,
      "uniqueItems": true,
      "items": { "type": "string", "maxLength": 320 }
    }
  }
}
