{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://thehiveryiq.com/.well-known/schemas/ppr-wearable-v2.json",
  "title": "PPR Wearable v1",
  "description": "PPR Wearable receipt. It binds a nonce, a subject assignment commitment, a device commitment, firmware, one metric observation, sequence and clock evidence, and optional calibration evidence into a canonical message, then verifies the Ed25519 device signature and derives the listed provenance relations. It verifies signed measurement provenance relations and does not establish subject identity, clinical validity, or fitness for diagnosis.",
  "type": "object",
  "required": [
    "receipt_id",
    "payload_sha256",
    "sig_b64u",
    "key_id",
    "algorithm",
    "ts",
    "signed_body"
  ],
  "additionalProperties": false,
  "properties": {
    "receipt_id": {
      "type": "string",
      "pattern": "^r_ppr\\.wearable_[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",
        "record_id",
        "evidence_digest_sha256",
        "recorded_at",
        "verdict",
        "boundary",
        "subject_assignment_sha256",
        "assignment_trust_classification",
        "device_id_commitment_sha256",
        "device_model",
        "firmware_sha256",
        "device_public_key",
        "observation_nonce",
        "metric_type",
        "unit",
        "observed_at",
        "sequence_no",
        "gateway_received_at",
        "device_signature",
        "observation_sha256",
        "metric_unit_relation",
        "signature_relation",
        "clock_lag_ms",
        "sequence_relation",
        "calibration_relation",
        "assignment_relation",
        "elements",
        "outcome"
      ],
      "additionalProperties": false,
      "properties": {
        "receipt_type": {
          "type": "string",
          "const": "ppr.wearable"
        },
        "schema": {
          "type": "string",
          "const": "r2.0.0"
        },
        "record_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": [
            "subject_identity_proven",
            "clinical_validity_proven",
            "diagnosis_fitness_proven"
          ],
          "additionalProperties": false,
          "properties": {
            "subject_identity_proven": {
              "type": "boolean",
              "const": false
            },
            "clinical_validity_proven": {
              "type": "boolean",
              "const": false
            },
            "diagnosis_fitness_proven": {
              "type": "boolean",
              "const": false
            }
          }
        },
        "boundary": {
          "type": "string",
          "const": "PPR Wearable receipt. It binds a nonce, a subject assignment commitment, a device commitment, firmware, one metric observation, sequence and clock evidence, and optional calibration evidence into a canonical message, then verifies the Ed25519 device signature and derives the listed provenance relations. It verifies signed measurement provenance relations and does not establish subject identity, clinical validity, or fitness for diagnosis."
        },
        "subject_assignment_sha256": {
          "type": "string",
          "pattern": "^[0-9a-f]{64}$",
          "description": "Commitment to the subject assignment record."
        },
        "assignment_trust_classification": {
          "type": "string",
          "enum": [
            "trusted",
            "untrusted",
            "unknown"
          ],
          "description": "Trust classification supplied with the linked evidence. Unknown remains indeterminate."
        },
        "device_id_commitment_sha256": {
          "type": "string",
          "pattern": "^[0-9a-f]{64}$",
          "description": "Commitment to the device identifier."
        },
        "device_model": {
          "type": "string",
          "minLength": 1,
          "maxLength": 256,
          "description": "Declared device model."
        },
        "firmware_sha256": {
          "type": "string",
          "pattern": "^[0-9a-f]{64}$",
          "description": "Commitment to the device firmware."
        },
        "device_public_key": {
          "type": "string",
          "pattern": "^[0-9a-f]{64}$",
          "description": "Lowercase hexadecimal Ed25519 public key for the signed device or platform message."
        },
        "observation_nonce": {
          "type": "string",
          "minLength": 16,
          "maxLength": 256
        },
        "metric_type": {
          "type": "string",
          "minLength": 1,
          "maxLength": 128
        },
        "unit": {
          "type": "string",
          "minLength": 1,
          "maxLength": 64
        },
        "value": {
          "type": [
            "number",
            "string",
            "boolean"
          ],
          "description": "Observed value. Exactly one of value and value_commitment_sha256 must be present."
        },
        "value_commitment_sha256": {
          "type": "string",
          "pattern": "^[0-9a-f]{64}$",
          "description": "Commitment to the observed value."
        },
        "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$",
          "description": "Device observation instant."
        },
        "sequence_no": {
          "type": "integer",
          "minimum": 0
        },
        "prior_sequence_no": {
          "type": "integer",
          "minimum": 0
        },
        "gateway_received_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$",
          "description": "Instant the gateway received the observation."
        },
        "device_signature": {
          "type": "string",
          "pattern": "^[A-Za-z0-9_-]{86}$",
          "description": "Unpadded base64url Ed25519 signature over the canonical message defined by this contract."
        },
        "calibration_ref": {
          "type": "string",
          "minLength": 1,
          "maxLength": 256,
          "description": "Optional calibration record reference."
        },
        "calibration_trust_classification": {
          "type": "string",
          "enum": [
            "trusted",
            "untrusted",
            "unknown"
          ],
          "description": "Trust classification supplied with the linked evidence. Unknown remains indeterminate."
        },
        "observation_sha256": {
          "type": "string",
          "pattern": "^[0-9a-f]{64}$",
          "description": "SHA256 of the canonical wearable observation message."
        },
        "metric_unit_relation": {
          "type": "string",
          "enum": [
            "matched",
            "mismatch",
            "indeterminate"
          ]
        },
        "signature_relation": {
          "type": "string",
          "enum": [
            "valid",
            "invalid"
          ]
        },
        "clock_lag_ms": {
          "type": "integer"
        },
        "sequence_relation": {
          "type": "string",
          "enum": [
            "initial",
            "contiguous",
            "gap",
            "out_of_order",
            "indeterminate"
          ]
        },
        "calibration_relation": {
          "type": "string",
          "enum": [
            "resolved",
            "untrusted",
            "indeterminate",
            "not_applicable"
          ]
        },
        "assignment_relation": {
          "type": "string",
          "enum": [
            "resolved",
            "untrusted",
            "indeterminate"
          ]
        },
        "elements": {
          "type": "array",
          "minItems": 0,
          "maxItems": 5,
          "items": {
            "type": "string",
            "enum": [
              "signature_invalid",
              "sequence_gap",
              "clock_unresolved",
              "calibration_unresolved",
              "assignment_unresolved"
            ]
          }
        },
        "outcome": {
          "type": "string",
          "enum": [
            "measurement_provenance_complete",
            "measurement_provenance_partial",
            "measurement_provenance_inconsistent"
          ]
        }
      }
    }
  }
}
