{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://thehiveryiq.com/.well-known/schemas/alert-disposition-v1.json",
  "title": "Alert Disposition Receipt, v1",
  "description": "Canonical schema for the Hive alert disposition receipt, canonical type alert.disposition. The instrument binds one raised alert to a response window committed before the alert was raised, and records what was decided about it, by whom (as a salted commitment), and when. If nothing was decided before the window closed, the receipt records that instead. The elapsed time and the outcome are recomputed by the verifier, so the caller cannot choose the conclusion.",
  "type": "object",
  "required": [
    "receipt_id",
    "payload_sha256",
    "sig_b64u",
    "key_id",
    "algorithm",
    "ts",
    "signed_body"
  ],
  "additionalProperties": false,
  "properties": {
    "receipt_id": {
      "type": "string",
      "pattern": "^r_alert[.]disposition_[0-9]{10,}_[0-9a-f]{12}$"
    },
    "payload_sha256": {
      "type": "string",
      "pattern": "^[0-9a-f]{64}$"
    },
    "sig_b64u": {
      "type": "string",
      "pattern": "^[A-Za-z0-9_-]{86}$"
    },
    "key_id": {
      "type": "string",
      "pattern": "^did:(hive|web|key):[A-Za-z0-9._:%-]+$"
    },
    "algorithm": {
      "type": "string",
      "const": "Ed25519"
    },
    "ts": {
      "type": "integer",
      "minimum": 1000000000
    },
    "signed_body": {
      "type": "object",
      "required": [
        "receipt_type",
        "schema",
        "alert_id",
        "alert_digest_sha256",
        "alert_source_commitment",
        "response_policy_sha256",
        "policy_committed_at",
        "response_window_seconds",
        "raised_at",
        "observed_until",
        "disposition",
        "elapsed_seconds",
        "outcome",
        "boundary"
      ],
      "additionalProperties": false,
      "properties": {
        "receipt_type": {
          "type": "string",
          "const": "alert.disposition"
        },
        "schema": {
          "type": "string",
          "const": "r1.0.0"
        },
        "alert_id": {
          "type": "string",
          "minLength": 1,
          "maxLength": 128,
          "pattern": "^[A-Za-z0-9._:-]+$"
        },
        "alert_digest_sha256": {
          "type": "string",
          "pattern": "^[0-9a-f]{64}$",
          "description": "Digest of the alert artifact the caller holds. The content of the alert is not disclosed."
        },
        "alert_source_commitment": {
          "type": "string",
          "pattern": "^[0-9a-f]{64}$",
          "description": "Salted commitment to the monitor or detector that raised the alert."
        },
        "response_policy_sha256": {
          "type": "string",
          "pattern": "^[0-9a-f]{64}$",
          "description": "Digest of the response policy that set the window."
        },
        "policy_committed_at": {
          "type": "string",
          "pattern": "^[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}:[0-9]{2}:[0-9]{2}Z$"
        },
        "response_window_seconds": {
          "type": "integer",
          "minimum": 1,
          "maximum": 2592000
        },
        "raised_at": {
          "type": "string",
          "pattern": "^[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}:[0-9]{2}:[0-9]{2}Z$"
        },
        "observed_until": {
          "type": "string",
          "pattern": "^[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}:[0-9]{2}:[0-9]{2}Z$",
          "description": "The last instant the issuer looked for a disposition before signing."
        },
        "disposition": {
          "type": [
            "object",
            "null"
          ],
          "required": [
            "disposition_class",
            "disposed_at",
            "decision_maker_commitment",
            "rationale_digest_sha256"
          ],
          "additionalProperties": false,
          "properties": {
            "disposition_class": {
              "type": "string",
              "enum": [
                "halted",
                "escalated",
                "continued_with_recorded_decision"
              ]
            },
            "disposed_at": {
              "type": "string",
              "pattern": "^[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}:[0-9]{2}:[0-9]{2}Z$"
            },
            "decision_maker_commitment": {
              "type": "string",
              "pattern": "^[0-9a-f]{64}$"
            },
            "rationale_digest_sha256": {
              "type": "string",
              "pattern": "^[0-9a-f]{64}$"
            }
          },
          "description": "The supplied disposition, or null when none was supplied."
        },
        "elapsed_seconds": {
          "type": [
            "integer",
            "null"
          ],
          "minimum": 0,
          "description": "Derived. Seconds from raised_at to disposed_at, or null when no disposition was recorded."
        },
        "outcome": {
          "type": "string",
          "enum": [
            "disposed_in_window",
            "disposed_after_window",
            "no_disposition_in_window"
          ],
          "description": "Derived from raised_at, the window, the disposition and observed_until."
        },
        "boundary": {
          "type": "string",
          "const": "This receipt records that one alert, identified by its digest, was raised at the stated time under a response window committed before it was raised, and records the disposition supplied for it, or that none was supplied before the window closed. The decision maker is represented only by a commitment. It does not establish that the alert was correct, that the disposition was right, or why it was made, and it does not assign responsibility or decide whether any rule or duty was met."
        }
      }
    }
  }
}
