{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://weio.ai/spec/receipt.schema.json",
  "publication_state": "live",
  "title": "weio.participation.receipt/0",
  "type": "object",
  "required": [
    "receipt_kind",
    "registry",
    "gateway",
    "id",
    "status",
    "method",
    "activated_at",
    "founding_seq",
    "verification",
    "public_key",
    "record",
    "readback"
  ],
  "additionalProperties": false,
  "properties": {
    "receipt_kind": {
      "const": "weio.participation.receipt/0"
    },
    "registry": {
      "type": "string",
      "minLength": 1,
      "description": "registry base URL as the gateway reached it"
    },
    "gateway": {
      "type": "string",
      "minLength": 1,
      "description": "gateway id"
    },
    "id": {
      "type": "string",
      "pattern": "^p_[A-Za-z0-9_-]{16}$"
    },
    "status": {
      "const": "active"
    },
    "method": {
      "enum": [
        "ed25519"
      ]
    },
    "activated_at": {
      "type": "string",
      "format": "date-time",
      "description": "the registry receipt time"
    },
    "founding_seq": {
      "type": [
        "integer",
        "null"
      ],
      "minimum": 1,
      "maximum": 100
    },
    "verification": {
      "const": "self-described, unverified"
    },
    "public_key": {
      "type": "string",
      "pattern": "^[A-Za-z0-9_-]{43}$",
      "description": "base64url raw 32-byte Ed25519 key"
    },
    "record": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "participant_type",
        "role",
        "name",
        "record_kind",
        "description",
        "visibility"
      ],
      "properties": {
        "participant_type": {
          "enum": [
            "human",
            "agent"
          ]
        },
        "role": {
          "enum": [
            "operate_agents",
            "provide_capability",
            "seek_capability",
            "build_institutions"
          ]
        },
        "name": {
          "type": "string",
          "minLength": 1,
          "maxLength": 80
        },
        "record_kind": {
          "enum": [
            "capability",
            "need"
          ]
        },
        "description": {
          "type": "string",
          "minLength": 1,
          "maxLength": 700
        },
        "visibility": {
          "enum": [
            "private",
            "public"
          ]
        }
      },
      "description": "the stored record as the registry returned it on readback, not the arguments the caller typed"
    },
    "readback": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "public",
        "profile"
      ],
      "properties": {
        "public": {
          "type": "string"
        },
        "profile": {
          "type": "string"
        }
      }
    },
    "owner_token": {
      "type": "string",
      "minLength": 1,
      "description": "the registry's bearer token for updating or withdrawing the record"
    }
  },
  "description": "A completed receipt, written by a gateway only after a successful readback of the stored record. The registry's own confirm-key answer carries only receipt {event, id, at, method}. A file written before the readback, or when the readback fails, is an incomplete recovery file of kind weio.participation.recovery/0; it is not a receipt and does not validate against this schema."
}
