{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://hogarmas.net/content-credentials/audit-report-envelope-schema.json",
  "title": "H/M Content Credentials Audit Report Envelope",
  "type": "object",
  "additionalProperties": false,
  "required": ["schema", "ruleset", "reportId", "report", "integrity"],
  "properties": {
    "schema": {
      "const": "hm.content-credentials-audit-report-envelope.v1"
    },
    "ruleset": {
      "const": "2026-07-28.1"
    },
    "reportId": {
      "type": "string",
      "pattern": "^urn:hm:content-credentials:audit:[a-f0-9]{64}$"
    },
    "report": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "schema",
        "ruleset",
        "generatedAt",
        "case",
        "source",
        "findings",
        "evidenceSequence",
        "custody",
        "sourceReportDigest",
        "sourceReport",
        "privacy",
        "limitations"
      ],
      "properties": {
        "schema": {
          "const": "hm.content-credentials-audit-report.v1"
        },
        "ruleset": {
          "const": "2026-07-28.1"
        },
        "generatedAt": {
          "type": "string",
          "format": "date-time"
        },
        "case": {
          "type": "object",
          "additionalProperties": false,
          "required": ["caseId", "organization", "reviewer", "purpose"],
          "properties": {
            "caseId": { "type": "string", "maxLength": 120 },
            "organization": { "type": "string", "maxLength": 180 },
            "reviewer": { "type": "string", "maxLength": 180 },
            "purpose": { "type": "string", "maxLength": 500 }
          }
        },
        "source": {
          "type": "object",
          "additionalProperties": false,
          "required": ["fileName", "mimeType", "sizeBytes", "sha256"],
          "properties": {
            "fileName": { "type": "string", "maxLength": 180 },
            "mimeType": { "type": "string", "maxLength": 120 },
            "sizeBytes": { "type": "integer", "minimum": 0 },
            "sha256": {
              "type": "string",
              "pattern": "^sha256:[a-f0-9]{64}$"
            }
          }
        },
        "findings": {
          "type": "object"
        },
        "evidenceSequence": {
          "type": "array",
          "maxItems": 100,
          "items": { "type": "object" }
        },
        "custody": {
          "type": "object",
          "additionalProperties": false,
          "required": ["mode", "actorIdentityAuthenticated", "eventCount", "hashChained", "events"],
          "properties": {
            "mode": { "const": "local-operator-declared" },
            "actorIdentityAuthenticated": { "const": false },
            "eventCount": { "type": "integer", "minimum": 1, "maximum": 100 },
            "hashChained": { "const": true },
            "events": {
              "type": "array",
              "minItems": 1,
              "maxItems": 100,
              "items": {
                "type": "object",
                "required": [
                  "sequence",
                  "occurredAt",
                  "type",
                  "actor",
                  "inputDigest",
                  "outputDigest",
                  "previousEventDigest",
                  "eventDigest"
                ]
              }
            }
          }
        },
        "sourceReportDigest": {
          "type": "string",
          "pattern": "^sha256:[a-f0-9]{64}$"
        },
        "sourceReport": {
          "$ref": "https://hogarmas.net/content-credentials/report-schema.json"
        },
        "privacy": {
          "type": "object",
          "additionalProperties": false,
          "required": [
            "processedLocally",
            "sourceFileUploaded",
            "browserStorageUsed",
            "sourceFileIncluded",
            "sourceFileNameIncluded"
          ],
          "properties": {
            "processedLocally": { "const": true },
            "sourceFileUploaded": { "const": false },
            "browserStorageUsed": { "const": false },
            "sourceFileIncluded": { "const": false },
            "sourceFileNameIncluded": { "type": "boolean" }
          }
        },
        "limitations": {
          "type": "object",
          "additionalProperties": false,
          "required": [
            "reportDigitallySigned",
            "operatorIdentityAuthenticated",
            "exporterIdentityAuthenticated",
            "semanticTruthProven",
            "authorshipProven",
            "aiAbsenceProven",
            "legalComplianceCertified"
          ],
          "properties": {
            "reportDigitallySigned": { "const": false },
            "operatorIdentityAuthenticated": { "const": false },
            "exporterIdentityAuthenticated": { "const": false },
            "semanticTruthProven": { "const": false },
            "authorshipProven": { "const": false },
            "aiAbsenceProven": { "const": false },
            "legalComplianceCertified": { "const": false }
          }
        }
      }
    },
    "integrity": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "algorithm",
        "canonicalization",
        "digest",
        "cryptographicallySigned",
        "issuerIdentityVerified"
      ],
      "properties": {
        "algorithm": { "const": "SHA-256" },
        "canonicalization": { "const": "hm.canonical-json.v1" },
        "digest": {
          "type": "string",
          "pattern": "^sha256:[a-f0-9]{64}$"
        },
        "cryptographicallySigned": { "const": false },
        "issuerIdentityVerified": { "const": false }
      }
    }
  }
}
