{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://tylereno.me/oidf/schemas/event/envelope.json",
  "title": "EventEnvelope",
  "description": "Canonical Keel Event envelope (RFC 0006).",
  "x-keel-schema-version": "1.0.0",
  "type": "object",
  "additionalProperties": false,
  "required": [
    "id",
    "type",
    "spec_version",
    "occurred_at",
    "recorded_at",
    "actor_id",
    "payload"
  ],
  "properties": {
    "id": { "$ref": "../common/identifier.json" },
    "type": {
      "type": "string",
      "enum": [
        "DeploymentCreated",
        "DeploymentRevised",
        "TransitionRequested",
        "EvidenceSubmitted",
        "EvidenceValidated",
        "EvidenceRejected",
        "TransitionRejected",
        "StateAdvanced",
        "InspectionFailed",
        "PermitExpired",
        "TelemetryReceived",
        "MaterialDelivered",
        "ScheduleUpdated",
        "PluginError",
        "SyncBatchCommitted",
        "ConfigurationRevised"
      ]
    },
    "spec_version": {
      "type": "string",
      "const": "1.0.0"
    },
    "occurred_at": { "$ref": "../common/timestamp.json" },
    "recorded_at": { "$ref": "../common/timestamp.json" },
    "actor_id": { "$ref": "../common/identifier.json" },
    "deployment_id": { "$ref": "../common/identifier.json" },
    "asset_id": { "$ref": "../common/identifier.json" },
    "caused_by_event_id": { "$ref": "../common/identifier.json" },
    "correlation_id": { "$ref": "../common/identifier.json" },
    "sequence": {
      "type": "integer",
      "minimum": 1,
      "description": "Per-subject monotonic sequence assigned by Event Engine."
    },
    "payload_hash": {
      "type": "string",
      "minLength": 1,
      "description": "Hash of canonical payload bytes; algorithm via security profile."
    },
    "signature": {
      "type": "string",
      "minLength": 1
    },
    "payload": {
      "type": "object",
      "description": "Typed by `type`; validated by the matching payload schema."
    },
    "extensions": {
      "type": "object",
      "additionalProperties": true
    }
  }
}
