{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://meshcognition.org/spec/mmp/schema/room-join.schema.json",
  "title": "MMP v2.0 room-join frame (\u00a75.8.1)",
  "description": "Sealed control frame presenting an owner-signed room-join grant after the handshake. Checked against this schema before the signature is verified; the grant is verified under §18.3.2 against the owner key pinned for the room (never one selected by grantedBy) and must bind the session's proven nodeId and identity key.",
  "type": "object",
  "required": ["type", "grant"],
  "additionalProperties": false,
  "properties": {
    "type": { "const": "room-join" },
    "grant": { "$ref": "#/$defs/grant" }
  },
  "$defs": {
    "grant": {
      "type": "object",
      "required": ["type", "room", "grantee", "granteeKey", "grantedBy", "grantedAt", "expiresAt", "sigAlg", "sig"],
      "additionalProperties": false,
      "properties": {
        "type": { "const": "room-join" },
        "room": { "type": "string", "pattern": "^[a-z0-9._-]{1,64}$" },
        "grantee": { "type": "string", "pattern": "^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$" },
        "granteeKey": { "type": "string", "pattern": "^[A-Za-z0-9_-]{43}$" },
        "grantedBy": { "type": "string", "pattern": "^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$" },
        "grantedAt": { "type": "integer", "minimum": 0, "maximum": 9007199254740991 },
        "expiresAt": { "type": "integer", "minimum": 0, "maximum": 9007199254740991, "description": "At most 2^53 − 1, so every parser reads the integer the owner signed." },
        "sigAlg": { "const": "ed25519" },
        "sig": { "type": "string", "pattern": "^[A-Za-z0-9_-]{86}$" }
      }
    }
  }
}
