{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "title": "Market Mesh event envelope v1",
  "type": "object",
  "additionalProperties": false,
  "required": [
    "schema",
    "event_id",
    "case_id",
    "order_id",
    "agreement_id",
    "organization_id",
    "service_id",
    "resource_uid",
    "resource_version",
    "event_type",
    "occurred_at",
    "observed_at",
    "source_mode",
    "source_adapter",
    "evidence_status",
    "payload"
  ],
  "properties": {
    "schema": {
      "const": "cotrugli.market-mesh.event.v1"
    },
    "event_id": {
      "type": "string",
      "minLength": 1
    },
    "case_id": {
      "type": "string",
      "minLength": 1
    },
    "order_id": {
      "type": "string",
      "minLength": 1
    },
    "agreement_id": {
      "type": "string",
      "minLength": 1
    },
    "organization_id": {
      "type": "string",
      "minLength": 1
    },
    "service_id": {
      "type": "string",
      "minLength": 1
    },
    "resource_uid": {
      "type": "string",
      "minLength": 1
    },
    "resource_version": {
      "type": "string",
      "minLength": 1
    },
    "event_type": {
      "type": "string",
      "minLength": 1
    },
    "occurred_at": {
      "type": "string",
      "format": "date-time"
    },
    "observed_at": {
      "type": "string",
      "format": "date-time"
    },
    "source_mode": {
      "enum": [
        "synthetic_fixture",
        "lab_observation",
        "partner_source"
      ]
    },
    "source_adapter": {
      "type": "string",
      "minLength": 1
    },
    "evidence_status": {
      "enum": [
        "UNSEALED",
        "PENDING",
        "VERIFIED_LAB",
        "FINAL",
        "REJECTED"
      ]
    },
    "payload": {
      "type": "object"
    }
  }
}
