{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://hogarmas.net/content-credentials/report-schema.json",
  "title": "H/M Content Credentials inspection report",
  "description": "Sanitized browser-local C2PA evidence report. The report separates manifest presence, integrity, signer trust and declared AI provenance; it is not a truth or compliance verdict.",
  "type": "object",
  "additionalProperties": false,
  "required": ["schema", "ruleset", "verifier", "asset", "provenance", "integrity", "signer", "aiOrigin", "history", "validation", "article50Evidence", "privacy", "limitations"],
  "properties": {
    "schema": { "const": "hm.content-credentials-report.v1" },
    "ruleset": { "type": "string", "pattern": "^[0-9]{4}-[0-9]{2}-[0-9]{2}\\.[0-9]+$" },
    "verifier": { "$ref": "#/$defs/verifier" },
    "asset": {
      "type": "object",
      "additionalProperties": false,
      "required": ["mimeType", "sizeBytes", "sha256"],
      "properties": {
        "mimeType": { "type": "string", "maxLength": 100 },
        "sizeBytes": { "type": "integer", "minimum": 0, "maximum": 1073741824 },
        "sha256": { "type": "string", "pattern": "^$|^sha256:[a-f0-9]{64}$" }
      }
    },
    "provenance": {
      "type": "object",
      "additionalProperties": false,
      "required": ["state", "manifestPresent", "manifestCount", "activeManifest", "claimGenerator", "title"],
      "properties": {
        "state": { "enum": ["present", "absent"] },
        "manifestPresent": { "type": "boolean" },
        "manifestCount": { "type": "integer", "minimum": 0, "maximum": 80 },
        "activeManifest": { "$ref": "#/$defs/text" },
        "claimGenerator": { "$ref": "#/$defs/text" },
        "title": { "$ref": "#/$defs/text" }
      }
    },
    "integrity": {
      "type": "object",
      "additionalProperties": false,
      "required": ["state", "sdkValidationState", "signaturePresent", "successCount", "informationalCount", "failureCount"],
      "properties": {
        "state": { "enum": ["valid", "invalid", "unknown", "not-applicable"] },
        "sdkValidationState": { "enum": ["", "Invalid", "Valid", "Trusted"] },
        "signaturePresent": { "type": "boolean" },
        "successCount": { "type": "integer", "minimum": 0, "maximum": 80 },
        "informationalCount": { "type": "integer", "minimum": 0, "maximum": 80 },
        "failureCount": { "type": "integer", "minimum": 0, "maximum": 80 }
      }
    },
    "signer": {
      "type": "object",
      "additionalProperties": false,
      "required": ["state", "algorithm", "issuer", "commonName", "signedAt"],
      "properties": {
        "state": { "enum": ["trusted", "untrusted", "unknown", "not-applicable"] },
        "algorithm": { "type": "string", "maxLength": 32 },
        "issuer": { "$ref": "#/$defs/text" },
        "commonName": { "$ref": "#/$defs/text" },
        "signedAt": { "type": "string", "maxLength": 64 }
      }
    },
    "aiOrigin": {
      "type": "object",
      "additionalProperties": false,
      "required": ["state", "aiDisclosurePresent", "digitalSourceTypes", "aiRelatedSourceTypes", "modelTypes", "disclosure"],
      "properties": {
        "state": { "enum": ["declared", "source-type-observed", "not-observed"] },
        "aiDisclosurePresent": { "type": "boolean" },
        "digitalSourceTypes": { "$ref": "#/$defs/textArray" },
        "aiRelatedSourceTypes": { "$ref": "#/$defs/textArray" },
        "modelTypes": { "$ref": "#/$defs/textArray" },
        "disclosure": { "type": ["object", "array", "string", "number", "boolean", "null"] }
      }
    },
    "history": {
      "type": "object",
      "additionalProperties": false,
      "required": ["actionCount", "ingredientCount", "actions", "ingredients"],
      "properties": {
        "actionCount": { "type": "integer", "minimum": 0, "maximum": 80 },
        "ingredientCount": { "type": "integer", "minimum": 0, "maximum": 80 },
        "actions": {
          "type": "array",
          "maxItems": 80,
          "items": {
            "type": "object",
            "additionalProperties": false,
            "required": ["action", "digitalSourceType", "softwareAgent", "changed"],
            "properties": {
              "action": { "type": "string", "maxLength": 180 },
              "digitalSourceType": { "$ref": "#/$defs/text" },
              "softwareAgent": { "$ref": "#/$defs/text" },
              "changed": { "type": "boolean" }
            }
          }
        },
        "ingredients": {
          "type": "array",
          "maxItems": 80,
          "items": {
            "type": "object",
            "additionalProperties": false,
            "required": ["title", "format", "relationship", "activeManifest", "dataTypes", "validationCodes"],
            "properties": {
              "title": { "$ref": "#/$defs/text" },
              "format": { "type": "string", "maxLength": 100 },
              "relationship": { "type": "string", "maxLength": 32 },
              "activeManifest": { "$ref": "#/$defs/text" },
              "dataTypes": { "$ref": "#/$defs/textArray" },
              "validationCodes": { "$ref": "#/$defs/textArray" }
            }
          }
        }
      }
    },
    "validation": {
      "type": "object",
      "additionalProperties": false,
      "required": ["success", "informational", "failure", "legacy"],
      "properties": {
        "success": { "$ref": "#/$defs/statusArray" },
        "informational": { "$ref": "#/$defs/statusArray" },
        "failure": { "$ref": "#/$defs/statusArray" },
        "legacy": { "$ref": "#/$defs/statusArray" }
      }
    },
    "article50Evidence": {
      "type": "array",
      "minItems": 6,
      "maxItems": 6,
      "items": {
        "type": "object",
        "additionalProperties": false,
        "required": ["id", "state"],
        "properties": {
          "id": { "enum": ["evidence.manifest", "evidence.binding", "evidence.signer", "evidence.aiDisclosure", "evidence.visibleDisclosure", "evidence.compliance"] },
          "state": { "enum": ["observed", "not-observed", "failed", "unknown", "not-trusted", "partial", "outside-scope", "not-determined"] }
        }
      }
    },
    "privacy": {
      "type": "object",
      "additionalProperties": false,
      "required": ["sourceFileUploaded", "browserStorageUsed", "remoteTrustListUsed", "rawFileDataIncludedInMetrics", "localExportIncludesFileHash"],
      "properties": {
        "sourceFileUploaded": { "const": false },
        "browserStorageUsed": { "const": false },
        "remoteTrustListUsed": { "const": false },
        "rawFileDataIncludedInMetrics": { "const": false },
        "localExportIncludesFileHash": { "const": true }
      }
    },
    "limitations": {
      "type": "object",
      "additionalProperties": false,
      "required": ["semanticTruthProven", "aiAbsenceProven", "trustedIdentityGuaranteed", "legalAdviceProvided", "complianceCertified"],
      "properties": {
        "semanticTruthProven": { "const": false },
        "aiAbsenceProven": { "const": false },
        "trustedIdentityGuaranteed": { "const": false },
        "legalAdviceProvided": { "const": false },
        "complianceCertified": { "const": false }
      }
    }
  },
  "$defs": {
    "text": { "type": "string", "maxLength": 320 },
    "textArray": { "type": "array", "maxItems": 80, "uniqueItems": true, "items": { "type": "string", "maxLength": 320 } },
    "verifier": {
      "type": "object",
      "additionalProperties": false,
      "required": ["name", "sdk", "sdkVersion", "c2paTarget"],
      "properties": {
        "name": { "const": "H/M Content Credentials Inspector" },
        "sdk": { "const": "@contentauth/c2pa-web" },
        "sdkVersion": { "enum": ["0.8.1", "0.13.1"] },
        "c2paTarget": { "const": "2.4" }
      }
    },
    "statusArray": { "type": "array", "maxItems": 80, "items": { "$ref": "#/$defs/status" } },
    "status": {
      "type": "object",
      "additionalProperties": false,
      "required": ["code", "explanation", "url", "success"],
      "properties": {
        "code": { "type": "string", "minLength": 1, "maxLength": 160 },
        "explanation": { "type": "string", "maxLength": 500 },
        "url": { "type": "string", "maxLength": 500 },
        "success": { "type": ["boolean", "null"] }
      }
    }
  }
}

