feat: add IRC-style message protocol JSON schemas (draft 2020-12)

Add JSON Schema definitions for all message types:
- Base message envelope (message.schema.json)
- C2S: PRIVMSG, NOTICE, JOIN, PART, QUIT, NICK, MODE, TOPIC, KICK, PING, PUBKEY
- S2C: named commands + numeric reply codes (001, 002, 322, 353, 366, 372, 375, 376, 401, 403, 433)
- S2S: RELAY, LINK, UNLINK, SYNC, PING, PONG
- Schema index (schema/README.md)

All messages use IRC command names and numeric codes from RFC 1459/2812.
Bodies are always objects or arrays (never raw strings) to support
deterministic canonicalization (RFC 8785 JCS) and message signing.
This commit is contained in:
clawbot
2026-02-10 10:26:32 -08:00
parent 4645be5f20
commit 909da3cc99
72 changed files with 1166 additions and 770 deletions

View File

@@ -1,41 +0,0 @@
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"$id": "https://git.eeqj.de/sneak/chat/schema/s2s/link.json",
"title": "S2S Link",
"description": "Server link establishment request/response.",
"type": "object",
"properties": {
"id": {
"type": "string",
"format": "uuid"
},
"type": {
"const": "link"
},
"ts": {
"type": "string",
"format": "date-time"
},
"origin": {
"type": "string",
"description": "Requesting server name."
},
"version": {
"type": "string",
"description": "Protocol version of the requesting server."
},
"auth": {
"type": "string",
"description": "HMAC signature over the link request using the shared federation key."
},
"capabilities": {
"type": "array",
"items": {
"type": "string"
},
"description": "List of supported protocol capabilities.",
"examples": [["relay", "sync", "presence"]]
}
},
"required": ["id", "type", "ts", "origin", "auth"]
}

View File

@@ -0,0 +1,20 @@
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"$id": "https://git.eeqj.de/sneak/chat/schema/s2s/link.schema.json",
"title": "LINK (S2S)",
"description": "Establish server link",
"$ref": "../message.schema.json",
"properties": {
"command": {
"const": "LINK"
},
"body": {
"type": "object",
"description": "Link parameters"
}
},
"required": [
"command",
"body"
]
}

View File

@@ -1,29 +0,0 @@
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"$id": "https://git.eeqj.de/sneak/chat/schema/s2s/ping.json",
"title": "S2S Ping",
"description": "Inter-server keepalive.",
"type": "object",
"properties": {
"id": {
"type": "string",
"format": "uuid"
},
"type": {
"const": "ping"
},
"ts": {
"type": "string",
"format": "date-time"
},
"origin": {
"type": "string",
"description": "Pinging server."
},
"token": {
"type": "string",
"description": "Opaque token to be echoed in pong."
}
},
"required": ["id", "type", "ts", "origin"]
}

View File

@@ -0,0 +1,22 @@
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"$id": "https://git.eeqj.de/sneak/chat/schema/s2s/ping.schema.json",
"title": "PING (S2S)",
"description": "Server-to-server keepalive",
"$ref": "../message.schema.json",
"properties": {
"command": {
"const": "PING"
},
"body": {
"type": "array",
"items": {
"type": "string"
},
"description": "Ping token"
}
},
"required": [
"command"
]
}

View File

@@ -1,29 +0,0 @@
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"$id": "https://git.eeqj.de/sneak/chat/schema/s2s/pong.json",
"title": "S2S Pong",
"description": "Inter-server keepalive response.",
"type": "object",
"properties": {
"id": {
"type": "string",
"format": "uuid"
},
"type": {
"const": "pong"
},
"ts": {
"type": "string",
"format": "date-time"
},
"origin": {
"type": "string",
"description": "Responding server."
},
"token": {
"type": "string",
"description": "Echoed token from the ping."
}
},
"required": ["id", "type", "ts", "origin"]
}

View File

@@ -0,0 +1,22 @@
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"$id": "https://git.eeqj.de/sneak/chat/schema/s2s/pong.schema.json",
"title": "PONG (S2S)",
"description": "Server-to-server keepalive response",
"$ref": "../message.schema.json",
"properties": {
"command": {
"const": "PONG"
},
"body": {
"type": "array",
"items": {
"type": "string"
},
"description": "Pong token"
}
},
"required": [
"command"
]
}

View File

@@ -1,49 +0,0 @@
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"$id": "https://git.eeqj.de/sneak/chat/schema/s2s/relay.json",
"title": "S2S Relay",
"description": "A message relayed from a remote server in the federation.",
"type": "object",
"properties": {
"id": {
"type": "string",
"format": "uuid",
"description": "Message UUID, globally unique across the federation."
},
"type": {
"const": "relay"
},
"ts": {
"type": "string",
"format": "date-time"
},
"origin": {
"type": "string",
"description": "Originating server name."
},
"message": {
"type": "object",
"description": "The original S2C message being relayed. Preserves the original type, from, channel, content, etc.",
"properties": {
"type": {
"type": "string"
},
"from": {
"type": "string"
},
"channel": {
"type": "string"
},
"content": {
"type": "string"
},
"ts": {
"type": "string",
"format": "date-time"
}
},
"required": ["type", "from"]
}
},
"required": ["id", "type", "ts", "origin", "message"]
}

View File

@@ -0,0 +1,20 @@
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"$id": "https://git.eeqj.de/sneak/chat/schema/s2s/relay.schema.json",
"title": "RELAY (S2S)",
"description": "Relay message to linked server",
"$ref": "../message.schema.json",
"properties": {
"command": {
"const": "RELAY"
},
"body": {
"type": "object",
"description": "Wrapped message"
}
},
"required": [
"command",
"body"
]
}

View File

@@ -1,69 +0,0 @@
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"$id": "https://git.eeqj.de/sneak/chat/schema/s2s/sync.json",
"title": "S2S Sync",
"description": "State synchronization between federated servers. Sent after link establishment to share channel and user state.",
"type": "object",
"properties": {
"id": {
"type": "string",
"format": "uuid"
},
"type": {
"const": "sync"
},
"ts": {
"type": "string",
"format": "date-time"
},
"origin": {
"type": "string",
"description": "Server sending the sync."
},
"channels": {
"type": "array",
"description": "Channels on the origin server.",
"items": {
"type": "object",
"properties": {
"name": {
"type": "string",
"pattern": "^#[a-zA-Z0-9_-]+$"
},
"topic": {
"type": "string"
},
"modes": {
"type": "string"
},
"members": {
"type": "array",
"items": {
"type": "string"
},
"description": "List of nicks in the channel."
}
},
"required": ["name"]
}
},
"users": {
"type": "array",
"description": "Users on the origin server.",
"items": {
"type": "object",
"properties": {
"nick": {
"type": "string"
},
"server": {
"type": "string",
"description": "Home server for this user."
}
},
"required": ["nick"]
}
}
},
"required": ["id", "type", "ts", "origin"]
}

View File

@@ -0,0 +1,20 @@
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"$id": "https://git.eeqj.de/sneak/chat/schema/s2s/sync.schema.json",
"title": "SYNC (S2S)",
"description": "Synchronize state between servers",
"$ref": "../message.schema.json",
"properties": {
"command": {
"const": "SYNC"
},
"body": {
"type": "object",
"description": "State data"
}
},
"required": [
"command",
"body"
]
}

View File

@@ -1,30 +0,0 @@
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"$id": "https://git.eeqj.de/sneak/chat/schema/s2s/unlink.json",
"title": "S2S Unlink",
"description": "Server link teardown notification.",
"type": "object",
"properties": {
"id": {
"type": "string",
"format": "uuid"
},
"type": {
"const": "unlink"
},
"ts": {
"type": "string",
"format": "date-time"
},
"origin": {
"type": "string",
"description": "Server initiating the unlink."
},
"reason": {
"type": "string",
"description": "Optional reason for the unlink.",
"examples": ["shutdown", "configuration change", "timeout"]
}
},
"required": ["id", "type", "ts", "origin"]
}

View File

@@ -0,0 +1,22 @@
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"$id": "https://git.eeqj.de/sneak/chat/schema/s2s/unlink.schema.json",
"title": "UNLINK (S2S)",
"description": "Tear down server link",
"$ref": "../message.schema.json",
"properties": {
"command": {
"const": "UNLINK"
},
"body": {
"type": "array",
"items": {
"type": "string"
},
"description": "Unlink reason"
}
},
"required": [
"command"
]
}