{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://thehiveryiq.com/.well-known/schemas/agent-coalition-v1.json",
  "title": "Agent Coalition Attestation Receipt, v1",
  "description": "Canonical schema for the Hive agent coalition attestation receipt, canonical type agent.coalition. The receipt records which member agents joined a coalition, what each contributed to a single coordinated decision, and how the decision rule combined those contributions. It does not prove any member acted in good faith, does not prove the coalition was authorized, and does not prove the coordinated action succeeded.",
  "type": "object",
  "required": [
    "receipt_id",
    "payload_sha256",
    "sig_b64u",
    "key_id",
    "algorithm",
    "ts",
    "signed_body"
  ],
  "additionalProperties": false,
  "properties": {
    "receipt_id": { "type": "string", "pattern": "^r_agent\\.coalition_[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",
        "coalition_id",
        "formed_at",
        "decided_at",
        "decision_commitment",
        "decision_rule",
        "members",
        "member_count",
        "members_digest",
        "weight_sum",
        "attribution_class",
        "self_asserted_member_count",
        "verdict",
        "salt_commitment",
        "boundary"
      ],
      "additionalProperties": false,
      "properties": {
        "receipt_type": { "type": "string", "const": "agent.coalition" },
        "schema": { "type": "string", "const": "r1.0.0" },
        "coalition_id": { "type": "string", "pattern": "^ac_[0-9a-f]{16,64}$" },
        "formed_at": {
          "type": "string",
          "description": "The instant the coalition was formed.",
          "pattern": "^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}(\\.\\d{1,9})?Z$"
        },
        "decided_at": {
          "type": "string",
          "description": "The instant the single coordinated decision was taken.",
          "pattern": "^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}(\\.\\d{1,9})?Z$"
        },
        "decision_commitment": {
          "type": "string",
          "description": "Salted HMAC over the canonical decision descriptor. The decision text itself is never carried.",
          "pattern": "^[0-9a-f]{64}$"
        },
        "decision_rule": {
          "type": "string",
          "description": "How the coalition combined member contributions into one decision, as declared by the issuer and checked against the member set.",
          "enum": ["unanimous", "leader_directed", "weighted_quorum", "first_responder", "unspecified"]
        },
        "members": {
          "type": "array",
          "description": "The member agents. Two members is the smallest thing that can be a coalition, and a joint action with no per member contribution binding collapses into nobody being responsible.",
          "minItems": 2,
          "maxItems": 64,
          "items": {
            "type": "object",
            "required": [
              "member_commitment",
              "role",
              "contribution_commitment",
              "contribution_weight",
              "joined_at",
              "authority_class"
            ],
            "additionalProperties": false,
            "properties": {
              "member_commitment": { "type": "string", "pattern": "^[0-9a-f]{64}$" },
              "role": {
                "type": "string",
                "enum": ["leader", "follower", "observer", "safety_monitor"]
              },
              "contribution_commitment": { "type": "string", "pattern": "^[0-9a-f]{64}$" },
              "contribution_weight": { "type": "number", "minimum": 0, "maximum": 1 },
              "joined_at": {
                "type": "string",
                "pattern": "^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}(\\.\\d{1,9})?Z$"
              },
              "authority_class": {
                "type": "string",
                "description": "Where the member's authority to act came from, as declared. Reported, never graded.",
                "enum": ["operator_delegated", "self_asserted", "unknown"]
              }
            }
          }
        },
        "member_count": {
          "type": "integer",
          "description": "Recomputed by the service from the length of members.",
          "minimum": 2,
          "maximum": 64
        },
        "members_digest": {
          "type": "string",
          "description": "RFC 6962 Merkle root over the per member leaves, in the order members are carried, so a member set cannot be edited after signing.",
          "pattern": "^[0-9a-f]{64}$"
        },
        "weight_sum": {
          "type": "number",
          "description": "Recomputed by the service as the sum of every contribution_weight, rounded to six decimal places.",
          "minimum": 0,
          "maximum": 64
        },
        "attribution_class": {
          "type": "string",
          "description": "Recomputed by the service from the roles, the weights, and the authority classes of the non observer members.",
          "enum": [
            "per_member_attributable",
            "leader_attributable",
            "collectively_attributable_only",
            "not_attributable"
          ]
        },
        "self_asserted_member_count": {
          "type": "integer",
          "description": "Recomputed by the service as the number of members whose authority_class is self_asserted.",
          "minimum": 0,
          "maximum": 64
        },
        "verdict": {
          "type": "string",
          "description": "Recomputed by the service from the attribution class. There is no verdict that asserts the coordinated action was correct.",
          "enum": [
            "coalition_decision_attributed",
            "coalition_decision_partially_attributed",
            "attribution_not_established"
          ]
        },
        "salt_commitment": { "type": "string", "pattern": "^[0-9a-f]{64}$" },
        "boundary": {
          "type": "string",
          "minLength": 1,
          "const": "This receipt records which member agents joined a coalition, what each contributed to a single coordinated decision, and how the decision rule combined those contributions. It does not prove any member acted in good faith, does not prove the coalition was authorized, and does not prove the coordinated action succeeded."
        }
      }
    }
  }
}
