{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://thehiveryiq.com/.well-known/schemas/sigr-bond-v1.json",
  "title": "SiGR Bond v1, signed SLA bond and measurement receipt",
  "description": "Canonical schema for the Hive SiGR Bond receipt, canonical type sigr.bond. Binds a declared SLA bond (latency ceiling, uptime floor, penalty rate) and an observed measurement against it into one Ed25519 signature over a recomputable payload_sha256 and a service computed breach determination. The receipt attests that breached and penalty_micro_usd recompute exactly from the bond terms and the observed measurement. It does not attest that the observed measurement was collected honestly, that the bond terms are commercially reasonable, or that any penalty is legally owed.",
  "type": "object",
  "required": [
    "receipt_id",
    "payload_sha256",
    "sig_b64u",
    "key_id",
    "algorithm",
    "ts",
    "signed_body"
  ],
  "additionalProperties": false,
  "properties": {
    "receipt_id": {
      "type": "string",
      "pattern": "^r_sigr\\.bond_[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",
        "bond_id",
        "tenant_id",
        "customer_ref",
        "terms",
        "measurement",
        "breached",
        "penalty_micro_usd",
        "measured_at",
        "boundary"
      ],
      "additionalProperties": false,
      "properties": {
        "receipt_type": { "type": "string", "const": "sigr.bond" },
        "schema": { "type": "string", "const": "r1.0.0" },
        "bond_id": { "type": "string", "minLength": 1, "maxLength": 256 },
        "tenant_id": { "type": "string", "minLength": 1, "maxLength": 256 },
        "customer_ref": { "type": "string", "minLength": 1, "maxLength": 256 },
        "terms": {
          "type": "object",
          "required": ["latency_ceiling_ms", "uptime_floor_ppm", "penalty_rate_micro_usd_per_breach"],
          "additionalProperties": false,
          "properties": {
            "latency_ceiling_ms": { "type": "integer", "minimum": 0, "maximum": 3600000 },
            "uptime_floor_ppm": {
              "type": "integer",
              "minimum": 0,
              "maximum": 1000000,
              "description": "Parts per million, so 999000 means a 99.9 percent uptime floor."
            },
            "penalty_rate_micro_usd_per_breach": { "type": "integer", "minimum": 0, "maximum": 1000000000000 }
          }
        },
        "measurement": {
          "type": "object",
          "required": ["observed_latency_ms", "observed_uptime_ppm"],
          "additionalProperties": false,
          "properties": {
            "observed_latency_ms": { "type": "integer", "minimum": 0, "maximum": 3600000 },
            "observed_uptime_ppm": { "type": "integer", "minimum": 0, "maximum": 1000000 }
          }
        },
        "breached": {
          "type": "boolean",
          "description": "Recomputed by the verifier: true if observed_latency_ms exceeds terms.latency_ceiling_ms or observed_uptime_ppm falls below terms.uptime_floor_ppm. Never accepted as a caller supplied verdict."
        },
        "penalty_micro_usd": {
          "type": "integer",
          "minimum": 0,
          "maximum": 1000000000000,
          "description": "Recomputed by the verifier: terms.penalty_rate_micro_usd_per_breach when breached is true, otherwise 0. Bounded to the same 1e12 ceiling as terms.penalty_rate_micro_usd_per_breach, since penalty_micro_usd is never anything other than that rate or zero."
        },
        "measured_at": {
          "type": "string",
          "pattern": "^[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}:[0-9]{2}:[0-9]{2}([.][0-9]{1,9})?Z$"
        },
        "boundary": {
          "type": "string",
          "const": "This receipt attests that breached and penalty_micro_usd recompute exactly from the recorded bond terms and the recorded measurement. It does not attest that the measurement was collected honestly, that the bond terms are commercially reasonable, or that any penalty is legally owed."
        }
      }
    }
  }
}
