{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://thehiveryiq.com/.well-known/schemas/intent-affirmation-v1.json",
  "title": "Intent Affirmation Receipt, v1",
  "description": "Canonical schema for the Hive intent affirmation receipt, canonical type intent.affirmation.",
  "type": "object",
  "required": [
    "receipt_id",
    "payload_sha256",
    "sig_b64u",
    "key_id",
    "algorithm",
    "ts",
    "signed_body"
  ],
  "additionalProperties": false,
  "properties": {
    "receipt_id": { "type": "string", "pattern": "^r_intent\\.affirmation_[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",
        "intent_affirmation",
        "boundary"
      ],
      "additionalProperties": false,
      "properties": {
        "receipt_type": { "type": "string", "const": "intent.affirmation" },
        "schema": { "type": "string", "const": "r1.0.0" },
        "intent_affirmation": {
          "type": "object",
          "required": [
            "affirmation_id",
            "recorded_at",
            "subject_pseudonym",
            "presented_artifact",
            "affirmed_at",
            "transmitted_artifact",
            "artifact_equality_class",
            "ordering_class",
            "time_reference",
            "observed_drift_ms",
            "drift_class",
            "affirmation_channel_class",
            "evidence_access_class",
            "salt_commitment"
          ],
          "additionalProperties": false,
          "properties": {
            "affirmation_id": { "type": "string", "pattern": "^ia_[0-9a-f]{16,64}$" },
            "recorded_at": { "type": "string", "pattern": "^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}(\\.\\d{1,9})?Z$" },
            "subject_pseudonym": { "type": "string", "pattern": "^[0-9a-f]{64}$" },
            "presented_artifact": {
              "type": "object",
              "required": ["artifact_digest", "presented_at"],
              "additionalProperties": false,
              "properties": {
                "artifact_digest": { "type": "string", "pattern": "^[0-9a-f]{64}$" },
                "presented_at": { "type": "string", "pattern": "^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}(\\.\\d{1,9})?Z$" }
              }
            },
            "affirmed_at": { "type": "string", "pattern": "^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}(\\.\\d{1,9})?Z$" },
            "transmitted_artifact": {
              "type": "object",
              "required": ["artifact_digest", "transmitted_at"],
              "additionalProperties": false,
              "properties": {
                "artifact_digest": { "type": "string", "pattern": "^[0-9a-f]{64}$" },
                "transmitted_at": { "type": "string", "pattern": "^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}(\\.\\d{1,9})?Z$" }
              }
            },
            "artifact_equality_class": { "type": "string", "enum": ["digests_equal", "digests_differ"] },
            "ordering_class": { "type": "string", "enum": ["affirmation_bracketed", "affirmation_outside_bracket"] },
            "time_reference": {
              "type": "object",
              "required": ["reference_id", "reference_digest", "drift_bound_ms"],
              "additionalProperties": false,
              "properties": {
                "reference_id": { "type": "string", "pattern": "^tr_[0-9a-z_]{1,48}$" },
                "reference_digest": { "type": "string", "pattern": "^[0-9a-f]{64}$" },
                "drift_bound_ms": { "type": "integer", "minimum": 1, "maximum": 86400000 }
              }
            },
            "observed_drift_ms": { "type": "integer", "minimum": 0, "maximum": 86400000 },
            "drift_class": { "type": "string", "enum": ["within_declared_bound", "exceeds_declared_bound"] },
            "affirmation_channel_class": { "type": "string", "enum": ["interactive_display", "voice_playback", "messaging_thread", "embedded_webview"] },
            "evidence_access_class": { "type": "string", "enum": ["confidential_independent", "issuer_only", "public_commitment_only"] },
            "salt_commitment": { "type": "string", "pattern": "^[0-9a-f]{64}$" }
          }
        },
        "boundary": {
          "type": "string",
          "minLength": 1,
          "const": "This receipt attests only that the digest of the artifact presented for affirmation equals the digest of the artifact transmitted as the authenticated intent, and that the affirmation instant falls strictly between the presentation instant and the transmission instant, with all three instants placed against a declared external time reference and drift bound. It does not attest that a human was present, that anyone read, understood, or agreed to anything, that the presented summary is a faithful summary of what any person said, that the affirmation was freely given, or that the presented artifact was rendered legibly. The channel and the time reference are recorded as declared and are not verified here."
        }
      }
    }
  }
}
