{
  "otc": "0.2.0",
  "id": "okham.core.type.event",
  "version": "0.1.0",
  "name": "Event",
  "description": "Records a fact reported by a source at a specific time, with an identified payload type. The consumer validates data against that payload type.",
  "status": "draft",
  "fields": [
    {
      "name": "id",
      "type": "string",
      "required": true,
      "description": "Event identifier (unique, namespaced)."
    },
    {
      "name": "name",
      "type": "string",
      "required": true,
      "description": "Human-readable event name (past tense)."
    },
    {
      "name": "version",
      "type": "string",
      "required": true,
      "description": "Event schema version."
    },
    {
      "name": "status",
      "type": "string",
      "required": true,
      "description": "Lifecycle status."
    },
    {
      "name": "source",
      "type": "object",
      "required": true,
      "description": "source for this event."
    },
    {
      "name": "timestamp",
      "type": "string",
      "required": true,
      "description": "Event occurrence time (ISO 8601, UTC)."
    },
    {
      "name": "causality",
      "type": "object",
      "required": false,
      "description": "causality for this event."
    },
    {
      "name": "classification",
      "type": "object",
      "required": false,
      "description": "classification for this event."
    },
    {
      "name": "payload",
      "type": "object",
      "required": true,
      "description": "payload for this event."
    },
    {
      "name": "metadata",
      "type": "object",
      "required": false,
      "description": "metadata for this event."
    },
    {
      "name": "typeRef",
      "type": "string",
      "required": true,
      "description": "Core type for this instance."
    },
    {
      "name": "typeVersion",
      "type": "string",
      "required": true,
      "description": "Exact version of the Core type."
    }
  ],
  "metadata": {
    "normative": {
      "typeRef": "okham.standards.type.normative.profile",
      "standard": "BCP14",
      "requirements": []
    },
    "replacesFormat": "OEC"
  },
  "schema": {
    "$schema": "https://json-schema.org/draft/2020-12/schema",
    "title": "Event",
    "description": "Records a fact reported by a source at a specific time, with an identified payload type. The consumer validates data against that payload type.",
    "type": "object",
    "required": [
      "typeRef",
      "typeVersion",
      "id",
      "name",
      "version",
      "status",
      "source",
      "timestamp",
      "payload"
    ],
    "properties": {
      "id": {
        "type": "string",
        "pattern": "^[a-z][a-z0-9._-]*[a-z0-9]$",
        "description": "Event identifier (unique, namespaced)."
      },
      "name": {
        "type": "string",
        "minLength": 2,
        "maxLength": 100,
        "description": "Human-readable event name (past tense)."
      },
      "version": {
        "type": "string",
        "pattern": "^\\d+\\.\\d+\\.\\d+$",
        "description": "Event schema version."
      },
      "status": {
        "type": "string",
        "enum": [
          "draft",
          "stable",
          "deprecated",
          "removed"
        ],
        "description": "Lifecycle status."
      },
      "source": {
        "type": "object",
        "required": [
          "capability"
        ],
        "properties": {
          "capability": {
            "type": "string",
            "description": "Identity of the emitting capability."
          },
          "instance": {
            "type": "string",
            "description": "Instance ID of the emitting capability."
          },
          "version": {
            "type": "string",
            "description": "Version of the emitting capability (semver)."
          }
        },
        "additionalProperties": true
      },
      "timestamp": {
        "type": "string",
        "format": "date-time",
        "description": "Event occurrence time (ISO 8601, UTC)."
      },
      "causality": {
        "type": "object",
        "properties": {
          "correlation_id": {
            "type": "string"
          },
          "causation_id": {
            "type": "string"
          },
          "trace_id": {
            "type": "string"
          },
          "span_id": {
            "type": "string"
          }
        },
        "additionalProperties": true
      },
      "classification": {
        "type": "object",
        "properties": {
          "domain": {
            "type": "string"
          },
          "lifecycle": {
            "type": "string"
          },
          "severity": {
            "type": "string",
            "enum": [
              "debug",
              "info",
              "warn",
              "error",
              "critical"
            ]
          },
          "scope": {
            "type": "string",
            "enum": [
              "public",
              "internal",
              "private"
            ]
          },
          "category": {
            "type": "string"
          }
        },
        "additionalProperties": true
      },
      "payload": {
        "type": "object",
        "required": [
          "type",
          "data"
        ],
        "properties": {
          "type": {
            "type": "string",
            "description": "OTC type URL or reference (versioned)."
          },
          "data": {
            "type": "object",
            "description": "Event data (must conform to type).",
            "additionalProperties": true
          }
        },
        "additionalProperties": true
      },
      "metadata": {
        "type": "object",
        "additionalProperties": true
      },
      "typeRef": {
        "type": "string",
        "const": "okham.core.type.event",
        "description": "Core type for this instance."
      },
      "typeVersion": {
        "type": "string",
        "const": "0.1.0",
        "description": "Exact version of the Core type."
      }
    },
    "additionalProperties": true,
    "not": {
      "required": [
        "event"
      ]
    }
  }
}
