{
  "title": "hub.incident.1",
  "description": "Defines a version 1 incident message payload",
  "type": "object",
  "properties": {
    "message": {
      "type": "object",
      "properties": {
        "version": {
          "type": "integer",
          "exclusiveMinimum": 0,
          "description": "Payload version. Required: the Platform API rejects payloads without a version."
        },
        "id": {
          "type": "string",
          "format": "uuid"
        },
        "relatedIds": {
          "type": "array",
          "items": {
            "type": "string",
            "format": "uuid"
          },
          "uniqueItems": true,
          "description": "IDs of messages this message relates to (e.g. when linking to an existing incident or reporting back)"
        },
        "applicationId": {
          "type": "string"
        },
        "dateTime": {
          "type": "string",
          "format": "date-time"
        }
      },
      "required": [
        "version",
        "id",
        "applicationId",
        "dateTime"
      ]
    },
    "incident": {
      "type": "object",
      "properties": {
        "id": {
          "type": "string",
          "description": "Incident id; must always be present (e.g. client-generated UUID when opening, or the existing incident id when linking or reporting back)"
        },
        "type": {
          "type": "string",
          "enum": [
            "KRI breach",
            "invalid report"
          ],
          "description": "Incident classification. The list of allowed values is configurable per deployment; the suggested baseline values are: KRI breach, invalid report. Extending the list requires a schema version bump."
        },
        "entity": {
          "type": "object",
          "minProperties": 1,
          "additionalProperties": {
            "type": "string"
          },
          "description": "Open key-value map identifying the supervised entity this incident relates to (one entity per incident; all referenceData items refer to this entity). Keys are strings (e.g. id, reference, name, a national identifier field, or a master data attribute name); each value is a string. At least one property is required."
        },
        "importance": {
          "type": "string",
          "enum": [
            "high",
            "medium",
            "low"
          ],
          "description": "Optional business importance of the incident. The list of allowed values is configurable per deployment; the suggested baseline values are: high, medium, low. Extending the list requires a schema version bump."
        },
        "urgency": {
          "type": "string",
          "enum": [
            "high",
            "medium",
            "low"
          ],
          "description": "Optional time-criticality of the incident. The list of allowed values is configurable per deployment; the suggested baseline values are: high, medium, low. Extending the list requires a schema version bump."
        },
        "summary": {
          "type": "string",
          "description": "Incident focus or, when closed, outcome summary"
        },
        "referenceData": {
          "type": "array",
          "minItems": 1,
          "description": "Array of self-describing reference items for the incident. At least one item is required. Each item carries optional identifiers, an optional observed value, and an optional reference time. The supervised entity context is shared across all items via incident.entity. For non-analytics incidents (e.g. a missing or invalid report), model the affected report as a referenceData item and attach files at incident level.",
          "items": {
            "type": "object",
            "properties": {
              "id": {
                "type": "string",
                "description": "Stable identifier for this item within the incident (e.g. analytics measure id or UUID). Use id or name (or both)."
              },
              "name": {
                "type": "string",
                "description": "Item name or label (e.g. KPI/KRI code, or a report identifier). Use id or name (or both)."
              },
              "context": {
                "type": "array",
                "items": {
                  "type": "string"
                },
                "uniqueItems": true,
                "description": "Optional contextual tags describing where this item lives or what kind of object it refers to (e.g. originating module, data collection, type of referenced object such as 'reporting obligation' or 'submission'). Free-form strings; the set of conventional tags is configurable per deployment."
              },
              "referenceTime": {
                "type": "string",
                "format": "date-time",
                "description": "Optional reference timestamp (ISO 8601, UTC) for the period or as-of moment that applies to this item"
              },
              "value": {
                "type": "string",
                "description": "Optional observed value at the time of the incident (e.g. a KPI/KRI measurement or, for non-analytics incidents, a coded report status such as missing, invalid, resubmitted). Omit when no single observed value applies."
              },
              "breachedCondition": {
                "type": "string",
                "description": "Optional description of the breached condition or limit the value is assessed against (e.g. regulatory minimum, target band, or 'report missing')"
              }
            },
            "anyOf": [
              {
                "required": [
                  "id"
                ]
              },
              {
                "required": [
                  "name"
                ]
              }
            ]
          }
        },
        "files": {
          "type": "array",
          "description": "Optional files linked to this incident (e.g. evidence, reports covering the affected entity or referenceData items); omit or empty if none",
          "items": {
            "type": "object",
            "properties": {
              "type": {
                "type": "string",
                "description": "File kind relative to the incident (free-form string, kept consistent with hub.submission.1.files.type; common values: data, data-schema, data-mapping, evidence, report, other)"
              },
              "uri": {
                "type": "string",
                "description": "URI to the file (platform storage s3/gs, https, or file scheme)"
              }
            },
            "required": [
              "type",
              "uri"
            ]
          }
        }
      },
      "required": [
        "id",
        "type",
        "summary",
        "entity",
        "referenceData"
      ]
    }
  },
  "required": [
    "message",
    "incident"
  ]
}
