{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://contactzero.org/c0-schema/v1/handshake-request.schema.json",
  "title": "C0 Handshake Request",
  "description": "A lawful C0::HANDSHAKE.REQUEST frame. A POST creates a persistent engineering event (InboundSignal + HandshakeEvent). Proceed only under a valid authority basis.",
  "type": "object",
  "required": ["magic", "protocol", "nonce", "source_node", "law", "request", "frame"],
  "additionalProperties": false,
  "properties": {
    "magic": { "type": "string", "const": "0xC0" },
    "protocol": { "type": "string", "const": "C0::HANDSHAKE.REQUEST" },
    "version": { "type": "string" },
    "nonce": { "type": "string", "minLength": 1, "description": "Unique per source. Reuse is treated as replay and refused." },
    "source_node": { "type": "string", "minLength": 1, "description": "Self-declared node label. NOT identity proof (self-claim authority is ignored)." },
    "law": {
      "type": "object",
      "required": ["highestWord", "capture", "returnPath", "claim"],
      "properties": {
        "highestWord": { "type": "string", "const": "RETURN" },
        "noThrone": { "type": "boolean" },
        "throne": { "type": "string", "enum": ["NULL"] },
        "capture": { "type": "string", "const": "REFUSED" },
        "returnPath": { "type": "string", "const": "ACTIVE" },
        "claim": { "type": "string", "const": "NULL" }
      }
    },
    "request": {
      "type": "object",
      "required": ["type", "response_mode"],
      "properties": {
        "type": { "type": "string", "const": "HANDSHAKE" },
        "response_mode": { "type": "string", "const": "ACK_ONLY" }
      }
    },
    "frame": {
      "type": "object",
      "properties": {
        "q": { "type": "number", "minimum": 0 },
        "p": { "type": "number", "minimum": 0 },
        "b": { "type": "number", "minimum": 0, "description": "Burden B = 2Q + P. Must descend on admitted transitions." },
        "glyph_tokens": {
          "type": "array",
          "items": { "type": "string" },
          "description": "Optional. Every token must be one of the 12 canonical T0 glyphs."
        }
      }
    }
  }
}
