{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://thehiveryiq.com/.well-known/schemas/usap-diurnal-v2.json",
  "title": "Diurnal Bond v1",
  "description": "Checks a timestamp and applied threshold against a declared schedule. It does not prove that the policy was enforced throughout a system.",
  "type": "object",
  "required": [
    "receipt_id",
    "payload_sha256",
    "sig_b64u",
    "key_id",
    "algorithm",
    "ts",
    "signed_body"
  ],
  "additionalProperties": false,
  "properties": {
    "receipt_id": {
      "type": "string",
      "pattern": "^r_usap\\.diurnal_[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",
        "regime_id",
        "evidence_digest_sha256",
        "recorded_at",
        "verdict",
        "boundary",
        "schedule_timezone",
        "effective_from",
        "effective_until",
        "regime_windows",
        "event_id",
        "event_observed_at",
        "applied_threshold",
        "active_window",
        "required_threshold",
        "threshold_relation",
        "elements",
        "outcome"
      ],
      "additionalProperties": false,
      "properties": {
        "receipt_type": {
          "type": "string",
          "const": "usap.diurnal"
        },
        "schema": {
          "type": "string",
          "const": "r2.0.0"
        },
        "regime_id": {
          "type": "string",
          "minLength": 1,
          "maxLength": 256,
          "pattern": "^[A-Za-z0-9._:-]{1,256}$"
        },
        "evidence_digest_sha256": {
          "type": "string",
          "pattern": "^[0-9a-f]{64}$",
          "description": "SHA-256 of the caller-held evidence bundle this receipt attests was recorded. The service never receives or inspects the underlying evidence, only its digest."
        },
        "recorded_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$"
        },
        "verdict": {
          "type": "object",
          "description": "Service-computed honesty boundary fields. Never caller overridable; recomputed and checked at verify time.",
          "required": [
            "outcome"
          ],
          "additionalProperties": false,
          "properties": {
            "outcome": {
              "type": "string",
              "enum": [
                "conforms_to_declared_regime",
                "does_not_conform_to_declared_regime",
                "indeterminate"
              ]
            }
          }
        },
        "boundary": {
          "type": "string",
          "const": "Checks a timestamp and applied threshold against a declared schedule. It does not prove that the policy was enforced throughout a system."
        },
        "schedule_timezone": {
          "type": "string",
          "minLength": 1,
          "maxLength": 64,
          "pattern": "^[A-Za-z_]+(/[A-Za-z_]+)*$"
        },
        "effective_from": {
          "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$"
        },
        "effective_until": {
          "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$"
        },
        "regime_windows": {
          "type": "array",
          "items": {
            "type": "object",
            "required": [
              "local_start",
              "local_end",
              "required_threshold"
            ],
            "additionalProperties": false,
            "properties": {
              "local_start": {
                "type": "string",
                "pattern": "^([01][0-9]|2[0-3]):[0-5][0-9]$"
              },
              "local_end": {
                "type": "string",
                "pattern": "^([01][0-9]|2[0-3]):[0-5][0-9]$"
              },
              "required_threshold": {
                "type": "integer",
                "minimum": 0,
                "maximum": 1000000000
              }
            }
          },
          "minItems": 1,
          "maxItems": 48
        },
        "event_id": {
          "type": "string",
          "minLength": 1,
          "maxLength": 256
        },
        "event_observed_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$"
        },
        "applied_threshold": {
          "type": "integer",
          "minimum": 0,
          "maximum": 1000000000
        },
        "active_window": {
          "type": "integer",
          "minimum": -1,
          "maximum": 47
        },
        "required_threshold": {
          "type": [
            "integer",
            "null"
          ],
          "minimum": 0,
          "maximum": 1000000000
        },
        "threshold_relation": {
          "type": "string",
          "enum": [
            "meets_regime",
            "below_regime",
            "indeterminate"
          ]
        },
        "elements": {
          "type": "array",
          "items": {
            "type": "string",
            "enum": [
              "outside_active_window",
              "threshold_below_regime",
              "schedule_indeterminate"
            ]
          },
          "minItems": 0,
          "maxItems": 3
        },
        "outcome": {
          "type": "string",
          "enum": [
            "conforms_to_declared_regime",
            "does_not_conform_to_declared_regime",
            "indeterminate"
          ]
        }
      }
    }
  }
}
