{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "urn:http6:proposed-protocol-contracts:v1",
  "title": "Proposed production integration record contracts, not a standardized wire format",
  "$defs": {
    "signature": {
      "type": "object",
      "properties": {
        "algorithm": {
          "type": "string",
          "minLength": 1,
          "pattern": "^[ -~]+$"
        },
        "issuer_key_id": {
          "type": "string",
          "minLength": 1,
          "pattern": "^[ -~]+$"
        },
        "signature": {
          "type": "string",
          "minLength": 1,
          "pattern": "^[ -~]+$"
        }
      },
      "required": [
        "algorithm",
        "issuer_key_id",
        "signature"
      ],
      "additionalProperties": false
    },
    "rootReceipt": {
      "type": "object",
      "properties": {
        "kind": {
          "const": "human-admission-receipt"
        },
        "receipt_id": {
          "type": "string",
          "minLength": 1,
          "pattern": "^[ -~]+$"
        },
        "subject_handle": {
          "type": "string",
          "minLength": 1,
          "pattern": "^[ -~]+$"
        },
        "root_instance": {
          "type": "string",
          "pattern": "^[0-9a-f]{64}$"
        },
        "root_key_fingerprint": {
          "type": "string",
          "pattern": "^[0-9a-f]{64}$"
        },
        "policy_digest": {
          "type": "string",
          "pattern": "^[0-9a-f]{64}$"
        },
        "requirement_profile_digest": {
          "type": "string",
          "pattern": "^[0-9a-f]{64}$"
        },
        "runtime_appraisal_digest": {
          "type": "string",
          "pattern": "^[0-9a-f]{64}$"
        },
        "context_digest": {
          "type": "string",
          "pattern": "^[0-9a-f]{64}$"
        },
        "epoch": {
          "type": "integer",
          "minimum": 0,
          "maximum": 9007199254740991
        },
        "human_auth_time": {
          "type": "string",
          "format": "date-time"
        },
        "not_before": {
          "type": "string",
          "format": "date-time"
        },
        "expires_at": {
          "type": "string",
          "format": "date-time"
        },
        "identity_profile_ref": {
          "type": "string",
          "minLength": 1,
          "pattern": "^[ -~]+$"
        },
        "authentication_profile_ref": {
          "type": "string",
          "minLength": 1,
          "pattern": "^[ -~]+$"
        },
        "signature": {
          "$ref": "#/$defs/signature"
        }
      },
      "required": [
        "kind",
        "receipt_id",
        "subject_handle",
        "root_instance",
        "root_key_fingerprint",
        "policy_digest",
        "requirement_profile_digest",
        "runtime_appraisal_digest",
        "context_digest",
        "epoch",
        "human_auth_time",
        "not_before",
        "expires_at",
        "identity_profile_ref",
        "authentication_profile_ref",
        "signature"
      ],
      "additionalProperties": false
    },
    "runtimeAppraisal": {
      "type": "object",
      "properties": {
        "kind": {
          "const": "runtime-appraisal"
        },
        "appraisal_id": {
          "type": "string",
          "minLength": 1,
          "pattern": "^[ -~]+$"
        },
        "attester_id": {
          "type": "string",
          "minLength": 1,
          "pattern": "^[ -~]+$"
        },
        "instance_key_fingerprint": {
          "type": "string",
          "pattern": "^[0-9a-f]{64}$"
        },
        "measurement": {
          "type": "string",
          "pattern": "^[0-9a-f]{64}$"
        },
        "policy_digest": {
          "type": "string",
          "pattern": "^[0-9a-f]{64}$"
        },
        "challenge_digest": {
          "type": "string",
          "pattern": "^[0-9a-f]{64}$"
        },
        "machine_generation": {
          "type": "string",
          "minLength": 1,
          "pattern": "^[ -~]+$"
        },
        "issued_at": {
          "type": "string",
          "format": "date-time"
        },
        "expires_at": {
          "type": "string",
          "format": "date-time"
        },
        "reference_values_digest": {
          "type": "string",
          "pattern": "^[0-9a-f]{64}$"
        },
        "decision": {
          "enum": [
            "accepted",
            "rejected"
          ]
        },
        "signature": {
          "$ref": "#/$defs/signature"
        }
      },
      "required": [
        "kind",
        "appraisal_id",
        "attester_id",
        "instance_key_fingerprint",
        "measurement",
        "policy_digest",
        "challenge_digest",
        "machine_generation",
        "issued_at",
        "expires_at",
        "reference_values_digest",
        "decision",
        "signature"
      ],
      "additionalProperties": false
    },
    "requirementProfile": {
      "type": "object",
      "properties": {
        "kind": {
          "const": "requirement-profile"
        },
        "scope_id": {
          "type": "string",
          "minLength": 1,
          "pattern": "^[ -~]+$"
        },
        "scope_manifest_digest": {
          "type": "string",
          "pattern": "^[0-9a-f]{64}$"
        },
        "edition_refs": {
          "type": "array",
          "items": {
            "type": "string",
            "minLength": 1,
            "pattern": "^[ -~]+$"
          }
        },
        "source_catalog_digests": {
          "type": "array",
          "items": {
            "type": "string",
            "pattern": "^[0-9a-f]{64}$"
          }
        },
        "selected_ids": {
          "type": "array",
          "minItems": 1,
          "uniqueItems": true,
          "items": {
            "type": "string",
            "minLength": 1,
            "pattern": "^[ -~]+$"
          }
        },
        "resolved_parameters": {
          "type": "object"
        },
        "evidence_policy_digest": {
          "type": "string",
          "pattern": "^[0-9a-f]{64}$"
        },
        "approval_ref": {
          "type": "string",
          "minLength": 1,
          "pattern": "^[ -~]+$"
        },
        "profile_status": {
          "enum": [
            "draft",
            "approved"
          ]
        }
      },
      "required": [
        "kind",
        "scope_id",
        "scope_manifest_digest",
        "edition_refs",
        "source_catalog_digests",
        "selected_ids",
        "resolved_parameters",
        "evidence_policy_digest",
        "approval_ref",
        "profile_status"
      ],
      "additionalProperties": false
    },
    "auditEvent": {
      "type": "object",
      "properties": {
        "kind": {
          "const": "authorization-event"
        },
        "event_id": {
          "type": "string",
          "minLength": 1,
          "pattern": "^[ -~]+$"
        },
        "root_instance": {
          "type": "string",
          "pattern": "^[0-9a-f]{64}$"
        },
        "acting_instance": {
          "type": "string",
          "pattern": "^[0-9a-f]{64}$"
        },
        "epoch": {
          "type": "integer",
          "minimum": 0,
          "maximum": 9007199254740991
        },
        "policy_digest": {
          "type": "string",
          "pattern": "^[0-9a-f]{64}$"
        },
        "operation_digest": {
          "type": "string",
          "pattern": "^[0-9a-f]{64}$"
        },
        "decision": {
          "enum": [
            "permit",
            "deny",
            "hold"
          ]
        },
        "reason_id": {
          "type": "string",
          "minLength": 1,
          "pattern": "^[ -~]+$"
        },
        "event_time": {
          "type": "string",
          "format": "date-time"
        },
        "transaction_id": {
          "type": [
            "string",
            "null"
          ]
        },
        "collector_id": {
          "type": "string",
          "minLength": 1,
          "pattern": "^[ -~]+$"
        },
        "signature": {
          "$ref": "#/$defs/signature"
        }
      },
      "required": [
        "kind",
        "event_id",
        "root_instance",
        "acting_instance",
        "epoch",
        "policy_digest",
        "operation_digest",
        "decision",
        "reason_id",
        "event_time",
        "transaction_id",
        "collector_id",
        "signature"
      ],
      "additionalProperties": false
    },
    "providerEvidence": {
      "type": "object",
      "properties": {
        "kind": {
          "const": "provider-evidence"
        },
        "evidence_id": {
          "type": "string",
          "minLength": 1,
          "pattern": "^[ -~]+$"
        },
        "provider_id": {
          "type": "string",
          "minLength": 1,
          "pattern": "^[ -~]+$"
        },
        "scope_id": {
          "type": "string",
          "minLength": 1,
          "pattern": "^[ -~]+$"
        },
        "subject_id": {
          "type": "string",
          "minLength": 1,
          "pattern": "^[ -~]+$"
        },
        "claim_type": {
          "type": "string",
          "minLength": 1,
          "pattern": "^[ -~]+$"
        },
        "claim_digest": {
          "type": "string",
          "pattern": "^[0-9a-f]{64}$"
        },
        "artifact_digests": {
          "type": "array",
          "items": {
            "type": "string",
            "pattern": "^[0-9a-f]{64}$"
          }
        },
        "issued_at": {
          "type": "string",
          "format": "date-time"
        },
        "expires_at": {
          "type": "string",
          "format": "date-time"
        },
        "revocation_ref": {
          "type": "string",
          "minLength": 1,
          "pattern": "^[ -~]+$"
        },
        "signature": {
          "$ref": "#/$defs/signature"
        }
      },
      "required": [
        "kind",
        "evidence_id",
        "provider_id",
        "scope_id",
        "subject_id",
        "claim_type",
        "claim_digest",
        "artifact_digests",
        "issued_at",
        "expires_at",
        "revocation_ref",
        "signature"
      ],
      "additionalProperties": false
    }
  },
  "oneOf": [
    {
      "$ref": "#/$defs/rootReceipt"
    },
    {
      "$ref": "#/$defs/runtimeAppraisal"
    },
    {
      "$ref": "#/$defs/requirementProfile"
    },
    {
      "$ref": "#/$defs/auditEvent"
    },
    {
      "$ref": "#/$defs/providerEvidence"
    }
  ]
}
