{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "urn:intertween:experimental:integrity:0.1:relational-trace-event",
  "title": "RelationalTraceEvent",
  "description": "Experimental 0.1 structure only. No assertion of signature, authority, privacy or federation conformance. See README.md.",
  "type": "object",
  "additionalProperties": false,
  "required": [
    "id",
    "event_type",
    "subject_refs",
    "actor",
    "mandate",
    "purpose",
    "timestamp",
    "sequence",
    "previous_event",
    "input_refs",
    "output_refs",
    "policy_decision",
    "validation_status",
    "originating_node",
    "trace_scope",
    "event_hash",
    "signature"
  ],
  "properties": {
    "id": {
      "type": "string",
      "format": "uri",
      "minLength": 1
    },
    "event_type": {
      "enum": [
        "observation",
        "correction",
        "contestation",
        "supersession",
        "withdrawal",
        "reuse",
        "decision",
        "outcome"
      ]
    },
    "subject_refs": {
      "type": "array",
      "minItems": 1,
      "items": {
        "type": "string",
        "format": "uri",
        "minLength": 1
      }
    },
    "actor": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "disclosure"
      ],
      "properties": {
        "disclosure": {
          "enum": [
            "identified",
            "masked",
            "anonymous",
            "unknown"
          ]
        },
        "reference": {
          "type": "string",
          "format": "uri",
          "minLength": 1
        }
      }
    },
    "mandate": {
      "anyOf": [
        {
          "type": "string",
          "format": "uri",
          "minLength": 1
        },
        {
          "type": "null"
        }
      ]
    },
    "purpose": {
      "type": "string",
      "minLength": 1
    },
    "timestamp": {
      "type": "string",
      "format": "date-time"
    },
    "sequence": {
      "type": "integer",
      "minimum": 1
    },
    "previous_event": {
      "anyOf": [
        {
          "type": "string",
          "pattern": "^[a-f0-9]{64}$"
        },
        {
          "type": "null"
        }
      ]
    },
    "input_refs": {
      "type": "array",
      "items": {
        "type": "string",
        "format": "uri",
        "minLength": 1
      }
    },
    "output_refs": {
      "type": "array",
      "items": {
        "type": "string",
        "format": "uri",
        "minLength": 1
      }
    },
    "policy_decision": {
      "type": "string",
      "format": "uri",
      "minLength": 1
    },
    "validation_status": {
      "enum": [
        "unreviewed",
        "machine_checked",
        "human_reviewed",
        "contested"
      ]
    },
    "originating_node": {
      "type": "string",
      "format": "uri",
      "minLength": 1
    },
    "trace_scope": {
      "type": "string",
      "format": "uri",
      "minLength": 1
    },
    "event_hash": {
      "type": "string",
      "pattern": "^[a-f0-9]{64}$"
    },
    "signature": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "algorithm",
        "key_id",
        "value"
      ],
      "properties": {
        "algorithm": {
          "const": "ECDSA-P256-SHA256"
        },
        "key_id": {
          "type": "string",
          "minLength": 1
        },
        "value": {
          "type": "string",
          "pattern": "^[A-Za-z0-9+/]+={0,2}$"
        }
      }
    }
  }
}
