{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://heartcortex.ai/schemas/1.0/arrhythmia.schema.json",
  "title": "Arrhythmia",
  "type": "object",
  "required": [
    "id",
    "code",
    "severity",
    "status",
    "detectedAt"
  ],
  "properties": {
    "id": {
      "$ref": "common.schema.json#/$defs/uuid",
      "x-heart-privacy": "public"
    },
    "code": {
      "description": "Fault code (Part 3, Section 5): a standard area.problem code, a profile code, or a reverse-DNS product code. Required.",
      "type": "string",
      "pattern": "^[a-z0-9]+(\\.[a-z0-9-]+)+$",
      "x-heart-privacy": "public"
    },
    "kind": {
      "description": "Deprecated (Part 3, Section 5.5): the older broad alert type, kept so existing software keeps working. Send it alongside code when an old kind fits. Removed in 2.0.",
      "anyOf": [
        {
          "enum": [
            "error-spike",
            "latency-spike",
            "resource-exhaustion",
            "cost-spike",
            "dependency-failure",
            "model-unavailable",
            "model-drift",
            "security-anomaly",
            "policy-violation",
            "data-integrity",
            "flatline"
          ]
        },
        {
          "type": "string",
          "pattern": "^[a-z0-9]+(\\.[a-z0-9-]+)+$"
        }
      ],
      "x-heart-privacy": "public",
      "deprecated": true
    },
    "severity": {
      "$ref": "common.schema.json#/$defs/severity",
      "x-heart-privacy": "public"
    },
    "status": {
      "enum": [
        "open",
        "acknowledged",
        "tending",
        "escalated",
        "resolved"
      ],
      "x-heart-privacy": "public"
    },
    "detectedAt": {
      "$ref": "common.schema.json#/$defs/timestamp",
      "x-heart-privacy": "public"
    },
    "acknowledgedAt": {
      "description": "When a person first acknowledged the alert (POST /arrhythmias/{id}/acknowledge).",
      "$ref": "common.schema.json#/$defs/timestamp",
      "x-heart-privacy": "public"
    },
    "acknowledgedBy": {
      "description": "Who acknowledged it.",
      "type": "string",
      "x-heart-privacy": "private"
    },
    "silencedUntil": {
      "description": "Repeats of this alert are not notified before this time (POST /arrhythmias/{id}/silence).",
      "$ref": "common.schema.json#/$defs/timestamp",
      "x-heart-privacy": "public"
    },
    "resolvedAt": {
      "$ref": "common.schema.json#/$defs/timestamp",
      "x-heart-privacy": "public"
    },
    "component": {
      "type": "string",
      "x-heart-privacy": "internal"
    },
    "summary": {
      "type": "string",
      "x-heart-privacy": "internal"
    },
    "explanation": {
      "description": "Plain-language account for a human.",
      "type": "string",
      "x-heart-privacy": "internal"
    },
    "cause": {
      "description": "Why it happened (Part 2, A2).",
      "type": "object",
      "x-heart-privacy": "internal",
      "required": [
        "text",
        "confidence"
      ],
      "properties": {
        "code": {
          "type": "string",
          "pattern": "^[a-z0-9]+(\\.[a-z0-9-]+)+$",
          "description": "Fault code of the cause, when one fits. Left out when the cause is not known."
        },
        "component": {
          "type": "string"
        },
        "text": {
          "type": "string"
        },
        "confidence": {
          "$ref": "common.schema.json#/$defs/confidence"
        }
      }
    },
    "evidence": {
      "description": "Sequence numbers of the Rhythm events behind this alert.",
      "type": "array",
      "items": {
        "type": "integer",
        "minimum": 0
      },
      "x-heart-privacy": "internal"
    },
    "actions": {
      "type": "array",
      "items": {
        "$ref": "common.schema.json#/$defs/uuid"
      },
      "x-heart-privacy": "internal"
    },
    "escalation": {
      "type": "object",
      "x-heart-privacy": "internal",
      "required": [
        "at",
        "reason"
      ],
      "properties": {
        "at": {
          "$ref": "common.schema.json#/$defs/timestamp"
        },
        "reason": {
          "type": "string"
        },
        "to": {
          "type": "string",
          "x-heart-privacy": "private"
        }
      }
    },
    "ext": {
      "$ref": "common.schema.json#/$defs/ext",
      "x-heart-privacy": "private"
    }
  }
}
