{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://hogarmas.net/content-credentials/trust-diagnostics-schema.json",
  "title": "H/M Content Credentials Trust Diagnostics",
  "type": "object",
  "additionalProperties": false,
  "required": [
    "schema",
    "ruleset",
    "state",
    "algorithm",
    "signerCertificate",
    "timestamp",
    "credentialPath",
    "decisions",
    "validation",
    "availability",
    "boundaries"
  ],
  "properties": {
    "schema": {
      "const": "hm.content-credentials-trust-diagnostics.v1"
    },
    "ruleset": {
      "const": "2026-07-28.2"
    },
    "state": {
      "enum": [
        "trusted",
        "untrusted",
        "unknown",
        "not-applicable"
      ]
    },
    "algorithm": {
      "type": "string",
      "maxLength": 80
    },
    "signerCertificate": {
      "$ref": "#/$defs/certificateSummary"
    },
    "timestamp": {
      "type": "object",
      "additionalProperties": false,
      "required": ["observed", "value", "state", "certificate"],
      "properties": {
        "observed": {
          "type": "boolean"
        },
        "value": {
          "type": "string",
          "maxLength": 80
        },
        "state": {
          "enum": [
            "trusted",
            "validated",
            "untrusted",
            "not-observed"
          ]
        },
        "certificate": {
          "$ref": "#/$defs/certificateSummary"
        }
      }
    },
    "credentialPath": {
      "type": "array",
      "minItems": 3,
      "maxItems": 3,
      "items": {
        "type": "object",
        "additionalProperties": false,
        "required": ["position", "label", "evidence", "state"],
        "properties": {
          "position": {
            "enum": ["signer", "issuer", "trust-anchor"]
          },
          "label": {
            "type": "string",
            "maxLength": 500
          },
          "evidence": {
            "enum": [
              "leaf-certificate-summary",
              "issuer-name-from-leaf-certificate",
              "trust-anchor-object-not-exposed",
              "not-exposed"
            ]
          },
          "state": {
            "enum": [
              "observed",
              "not-observed",
              "trusted",
              "untrusted",
              "unknown",
              "not-applicable"
            ]
          }
        }
      }
    },
    "decisions": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "claimSignature",
        "signingCredential",
        "certificateValidityAtSignature",
        "timestamp",
        "revocation"
      ],
      "properties": {
        "claimSignature": {
          "enum": ["valid", "invalid", "unknown"]
        },
        "signingCredential": {
          "enum": ["trusted", "untrusted", "invalid", "unknown"]
        },
        "certificateValidityAtSignature": {
          "enum": ["inside-validity", "outside-validity", "unknown"]
        },
        "timestamp": {
          "enum": [
            "trusted",
            "validated",
            "untrusted",
            "not-observed"
          ]
        },
        "revocation": {
          "enum": ["revoked", "not-revoked", "not-observed"]
        }
      }
    },
    "validation": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "evaluatedAt",
        "signingCredentialCodes",
        "claimSignatureCodes",
        "timestampCodes"
      ],
      "properties": {
        "evaluatedAt": {
          "type": "string",
          "maxLength": 80
        },
        "signingCredentialCodes": {
          "$ref": "#/$defs/codeArray"
        },
        "claimSignatureCodes": {
          "$ref": "#/$defs/codeArray"
        },
        "timestampCodes": {
          "$ref": "#/$defs/codeArray"
        }
      }
    },
    "availability": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "signerLeafSummaryExposed",
        "timestampLeafSummaryExposed",
        "completeCertificateChainExposed",
        "intermediateCertificateObjectsExposed",
        "rootTrustAnchorObjectExposed",
        "rawCertificateBytesExposed",
        "certificateSerialObserved",
        "certificateSerialIncluded"
      ],
      "properties": {
        "signerLeafSummaryExposed": {
          "type": "boolean"
        },
        "timestampLeafSummaryExposed": {
          "type": "boolean"
        },
        "completeCertificateChainExposed": {
          "const": false
        },
        "intermediateCertificateObjectsExposed": {
          "const": false
        },
        "rootTrustAnchorObjectExposed": {
          "const": false
        },
        "rawCertificateBytesExposed": {
          "const": false
        },
        "certificateSerialObserved": {
          "type": "boolean"
        },
        "certificateSerialIncluded": {
          "const": false
        }
      }
    },
    "boundaries": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "remoteTrustListUsed",
        "humanOrOrganizationIdentityVerified",
        "conformanceCertified",
        "semanticTruthProven",
        "authorshipProven",
        "completePathCanBeReconstructed"
      ],
      "properties": {
        "remoteTrustListUsed": {
          "const": false
        },
        "humanOrOrganizationIdentityVerified": {
          "const": false
        },
        "conformanceCertified": {
          "const": false
        },
        "semanticTruthProven": {
          "const": false
        },
        "authorshipProven": {
          "const": false
        },
        "completePathCanBeReconstructed": {
          "const": false
        }
      }
    }
  },
  "$defs": {
    "distinguishedName": {
      "type": "object",
      "additionalProperties": false,
      "required": ["CN", "O", "OU", "L", "ST", "C"],
      "properties": {
        "CN": {
          "type": "string",
          "maxLength": 180
        },
        "O": {
          "type": "string",
          "maxLength": 180
        },
        "OU": {
          "type": "string",
          "maxLength": 180
        },
        "L": {
          "type": "string",
          "maxLength": 180
        },
        "ST": {
          "type": "string",
          "maxLength": 180
        },
        "C": {
          "type": "string",
          "maxLength": 180
        }
      }
    },
    "certificateSummary": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "observed",
        "subject",
        "issuer",
        "validity",
        "serialNumberIncluded"
      ],
      "properties": {
        "observed": {
          "type": "boolean"
        },
        "subject": {
          "$ref": "#/$defs/distinguishedName"
        },
        "issuer": {
          "$ref": "#/$defs/distinguishedName"
        },
        "validity": {
          "type": "object",
          "additionalProperties": false,
          "required": ["notBefore", "notAfter"],
          "properties": {
            "notBefore": {
              "type": "string",
              "maxLength": 80
            },
            "notAfter": {
              "type": "string",
              "maxLength": 80
            }
          }
        },
        "serialNumberIncluded": {
          "const": false
        }
      }
    },
    "codeArray": {
      "type": "array",
      "maxItems": 120,
      "uniqueItems": true,
      "items": {
        "type": "string",
        "maxLength": 180
      }
    }
  }
}
