{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"$id": "https://github.com/ThinkersJournal/commy-wire/schema/control.schema.json",
"title": "Commy control message (draft 1)",
"oneOf": [
{
"properties": {
"type": {
"const": "Authenticate"
},
"data": {
"type": "object",
"required": [
"request_id",
"protocol_version",
"tenant_id",
"method"
],
"properties": {
"request_id": {
"type": "string"
},
"protocol_version": {
"type": "integer",
"minimum": 0,
"maximum": 4294967295
},
"tenant_id": {
"type": "string",
"pattern": "^[A-Za-z0-9_-]{1,64}$"
},
"client_version": {
"type": "string"
},
"client_id": {
"type": "string",
"pattern": "^[A-Za-z0-9_.@:-]{1,128}$",
"description": "A hint for development servers only; a production server takes the identity from the credential."
},
"dev_scopes": {
"type": "array",
"items": {
"type": "string"
},
"description": "Development servers only: exactly these scopes ([] for none) instead of administrator."
},
"method": {
"enum": [
"api_key",
"jwt",
"basic",
"custom"
]
},
"key": {
"type": "string"
},
"token": {
"type": "string"
},
"username": {
"type": "string"
},
"password": {
"type": "string"
},
"data": {}
},
"oneOf": [
{
"properties": {
"method": {
"const": "api_key"
}
},
"required": [
"key"
]
},
{
"properties": {
"method": {
"const": "jwt"
}
},
"required": [
"token"
]
},
{
"properties": {
"method": {
"const": "basic"
}
},
"required": [
"username",
"password"
]
},
{
"properties": {
"method": {
"const": "custom"
}
},
"required": [
"data"
]
}
]
}
}
},
{
"properties": {
"type": {
"const": "FlushAck"
},
"data": {
"type": "object",
"required": [
"request_id",
"file_id",
"seq"
],
"properties": {
"request_id": {
"type": "string"
},
"file_id": {
"type": "integer",
"minimum": 0,
"maximum": 4294967295
},
"seq": {
"type": "integer",
"minimum": 0
}
},
"additionalProperties": false
}
}
},
{
"properties": {
"type": {
"const": "Resync"
},
"data": {
"type": "object",
"required": [
"request_id",
"file_id"
],
"properties": {
"request_id": {
"type": "string"
},
"file_id": {
"type": "integer",
"minimum": 0,
"maximum": 4294967295
}
},
"additionalProperties": false
}
}
},
{
"properties": {
"type": {
"const": "ResyncDone"
},
"data": {
"type": "object",
"required": [
"request_id",
"file_id",
"seq",
"size"
],
"properties": {
"request_id": {
"type": "string"
},
"file_id": {
"type": "integer",
"minimum": 0,
"maximum": 4294967295
},
"seq": {
"type": "integer",
"minimum": 0
},
"size": {
"type": "integer",
"minimum": 0
}
},
"additionalProperties": false
}
}
},
{
"properties": {
"type": {
"const": "GetServiceFilePath"
},
"data": {
"type": "object",
"required": [
"request_id",
"service_id"
],
"properties": {
"request_id": {
"type": "string"
},
"service_id": {
"type": "string"
}
},
"additionalProperties": false
}
}
},
{
"properties": {
"type": {
"const": "ServiceFilePath"
},
"data": {
"type": "object",
"required": [
"request_id",
"service_id",
"file_id"
],
"properties": {
"request_id": {
"type": "string"
},
"service_id": {
"type": "string"
},
"file_id": {
"type": "integer",
"minimum": 0,
"maximum": 4294967295
},
"path": {
"type": "string"
},
"nonce_path": {
"type": "string"
}
},
"dependentRequired": {
"path": [
"nonce_path"
],
"nonce_path": [
"path"
]
},
"additionalProperties": false
}
}
},
{
"properties": {
"type": {
"const": "ConfirmLocal"
},
"data": {
"type": "object",
"required": [
"request_id",
"file_id",
"nonce"
],
"properties": {
"request_id": {
"type": "string"
},
"file_id": {
"type": "integer",
"minimum": 0,
"maximum": 4294967295
},
"nonce": {
"type": "string"
}
},
"additionalProperties": false
}
}
},
{
"properties": {
"type": {
"const": "ConfirmLocalAck"
},
"data": {
"type": "object",
"required": [
"request_id",
"file_id"
],
"properties": {
"request_id": {
"type": "string"
},
"file_id": {
"type": "integer",
"minimum": 0,
"maximum": 4294967295
}
},
"additionalProperties": false
}
}
},
{
"properties": {
"type": {
"const": "RotateRequest"
},
"data": {
"type": "object",
"required": [
"request_id",
"service_id",
"reason"
],
"properties": {
"request_id": {
"type": "string"
},
"service_id": {
"type": "string"
},
"reason": {
"enum": [
"RESIZE",
"REVOCATION"
]
},
"new_size": {
"type": "integer",
"minimum": 1
},
"revoke_client_id": {
"type": "string"
}
},
"additionalProperties": false
}
}
},
{
"properties": {
"type": {
"const": "RotationAccepted"
},
"data": {
"type": "object",
"required": [
"request_id",
"rotation_id"
],
"properties": {
"request_id": {
"type": "string"
},
"rotation_id": {
"type": "string"
}
},
"additionalProperties": false
}
}
},
{
"properties": {
"type": {
"const": "RotationPending"
},
"data": {
"type": "object",
"required": [
"rotation_id",
"service_id",
"file_id",
"deadline_ms",
"fill_ms"
],
"properties": {
"rotation_id": {
"type": "string"
},
"service_id": {
"type": "string"
},
"file_id": {
"type": "integer",
"minimum": 0,
"maximum": 4294967295
},
"deadline_ms": {
"type": "integer",
"minimum": 0
},
"fill_ms": {
"type": "integer",
"minimum": 0
}
},
"additionalProperties": false
}
}
},
{
"properties": {
"type": {
"const": "RotationDrained"
},
"data": {
"type": "object",
"required": [
"request_id",
"rotation_id",
"file_id",
"seq"
],
"properties": {
"request_id": {
"type": "string"
},
"rotation_id": {
"type": "string"
},
"file_id": {
"type": "integer",
"minimum": 0,
"maximum": 4294967295
},
"seq": {
"type": "integer",
"minimum": 0
}
},
"additionalProperties": false
}
}
},
{
"properties": {
"type": {
"const": "RotationCommit"
},
"data": {
"type": "object",
"required": [
"rotation_id",
"service_id",
"reason",
"old_file_id",
"new_file_id",
"generation",
"size"
],
"properties": {
"rotation_id": {
"type": "string"
},
"service_id": {
"type": "string"
},
"reason": {
"enum": [
"RESIZE",
"REVOCATION"
]
},
"old_file_id": {
"type": "integer",
"minimum": 0,
"maximum": 4294967295
},
"new_file_id": {
"type": "integer",
"minimum": 0,
"maximum": 4294967295
},
"generation": {
"type": "integer",
"minimum": 0
},
"size": {
"type": "integer",
"minimum": 0
}
},
"additionalProperties": false
}
}
},
{
"properties": {
"type": {
"const": "Loss"
},
"data": {
"type": "object",
"required": [
"service_id",
"file_id",
"kind"
],
"properties": {
"service_id": {
"type": "string"
},
"file_id": {
"type": "integer",
"minimum": 0,
"maximum": 4294967295
},
"kind": {
"type": "string",
"description": "Known: ROTATION_STRAGGLER, RESYNC_OVERWROTE, REVOKED. A receiver treats any other value as a loss of the whole file.",
"examples": [
"ROTATION_STRAGGLER",
"RESYNC_OVERWROTE",
"REVOKED"
]
},
"ranges": {
"type": "array",
"items": {
"type": "object",
"required": [
"offset",
"len"
],
"properties": {
"offset": {
"type": "integer",
"minimum": 0
},
"len": {
"type": "integer",
"minimum": 0
}
},
"additionalProperties": false
}
}
},
"additionalProperties": false
}
}
},
{
"properties": {
"type": {
"const": "RangesChanged"
},
"data": {
"type": "object",
"required": [
"request_id",
"file_id",
"ranges"
],
"properties": {
"request_id": {
"type": "string"
},
"file_id": {
"type": "integer",
"minimum": 0,
"maximum": 4294967295
},
"ranges": {
"type": "array",
"items": {
"type": "object",
"required": [
"offset",
"len"
],
"properties": {
"offset": {
"type": "integer",
"minimum": 0
},
"len": {
"type": "integer",
"minimum": 0
}
},
"additionalProperties": false
},
"minItems": 1,
"maxItems": 1024,
"description": "Sorted by offset, non-empty, non-overlapping; JSON Schema cannot express the ordering, so receivers also run validate_ranges."
}
},
"additionalProperties": false
}
}
},
{
"properties": {
"type": {
"const": "RangesUpdated"
},
"data": {
"type": "object",
"required": [
"file_id",
"seq",
"ranges"
],
"properties": {
"file_id": {
"type": "integer",
"minimum": 0,
"maximum": 4294967295
},
"seq": {
"type": "integer",
"minimum": 0
},
"ranges": {
"type": "array",
"items": {
"type": "object",
"required": [
"offset",
"len"
],
"properties": {
"offset": {
"type": "integer",
"minimum": 0
},
"len": {
"type": "integer",
"minimum": 0
}
},
"additionalProperties": false
},
"minItems": 1,
"maxItems": 1024,
"description": "Sorted by offset, non-empty, non-overlapping; JSON Schema cannot express the ordering, so receivers also run validate_ranges."
}
},
"additionalProperties": false
}
}
},
{
"properties": {
"type": {
"const": "FlushEnd"
},
"data": {
"type": "object",
"required": [
"request_id",
"file_id"
],
"properties": {
"request_id": {
"type": "string"
},
"file_id": {
"type": "integer",
"minimum": 0,
"maximum": 4294967295
}
},
"additionalProperties": false
}
}
},
{
"properties": {
"type": {
"const": "RotationPrepared"
},
"data": {
"type": "object",
"required": [
"rotation_id",
"service_id",
"old_file_id",
"new_file_id",
"size"
],
"properties": {
"rotation_id": {
"type": "string"
},
"service_id": {
"type": "string"
},
"old_file_id": {
"type": "integer",
"minimum": 0,
"maximum": 4294967295
},
"new_file_id": {
"type": "integer",
"minimum": 0,
"maximum": 4294967295
},
"size": {
"type": "integer",
"minimum": 1
},
"path": {
"type": "string"
}
},
"additionalProperties": false
}
}
},
{
"properties": {
"type": {
"const": "RotationFilled"
},
"data": {
"type": "object",
"required": [
"request_id",
"rotation_id"
],
"properties": {
"request_id": {
"type": "string"
},
"rotation_id": {
"type": "string"
}
},
"additionalProperties": false
}
}
},
{
"properties": {
"type": {
"const": "RotationAbort"
},
"data": {
"type": "object",
"required": [
"request_id",
"rotation_id"
],
"properties": {
"request_id": {
"type": "string"
},
"rotation_id": {
"type": "string"
}
},
"additionalProperties": false
}
}
},
{
"properties": {
"type": {
"const": "RotationAborted"
},
"data": {
"type": "object",
"required": [
"rotation_id",
"service_id",
"file_id",
"reason"
],
"properties": {
"rotation_id": {
"type": "string"
},
"service_id": {
"type": "string"
},
"file_id": {
"type": "integer",
"minimum": 0,
"maximum": 4294967295
},
"reason": {
"type": "string",
"description": "Known: REQUESTER_ABORT, FILL_TIMEOUT, SERVER_ERROR. Treat any other value as an abandoned rotation.",
"examples": [
"REQUESTER_ABORT",
"FILL_TIMEOUT",
"SERVER_ERROR"
]
}
},
"additionalProperties": false
}
}
},
{
"properties": {
"type": {
"const": "Grant"
},
"data": {
"type": "object",
"required": [
"request_id",
"client_id",
"permissions"
],
"properties": {
"request_id": {
"type": "string"
},
"client_id": {
"type": "string"
},
"service_id": {
"type": "string"
},
"permissions": {
"type": "array",
"items": {
"type": "string"
},
"minItems": 1
}
},
"additionalProperties": false
}
}
},
{
"properties": {
"type": {
"const": "Revoke"
},
"data": {
"type": "object",
"required": [
"request_id",
"client_id"
],
"properties": {
"request_id": {
"type": "string"
},
"client_id": {
"type": "string"
},
"service_id": {
"type": "string"
},
"permissions": {
"type": "array",
"items": {
"type": "string"
}
}
},
"additionalProperties": false
}
}
},
{
"properties": {
"type": {
"const": "GrantAck"
},
"data": {
"type": "object",
"required": [
"request_id"
],
"properties": {
"request_id": {
"type": "string"
}
},
"additionalProperties": false
}
}
},
{
"properties": {
"type": {
"const": "ListGrants"
},
"data": {
"type": "object",
"required": [
"request_id"
],
"properties": {
"request_id": {
"type": "string"
},
"client_id": {
"type": "string"
},
"service_id": {
"type": "string"
}
},
"additionalProperties": false
}
}
},
{
"properties": {
"type": {
"const": "Grants"
},
"data": {
"type": "object",
"required": [
"request_id",
"entries"
],
"properties": {
"request_id": {
"type": "string"
},
"entries": {
"type": "array",
"items": {
"type": "object",
"required": [
"client_id",
"permissions"
],
"properties": {
"client_id": {
"type": "string"
},
"service_id": {
"type": "string"
},
"permissions": {
"type": "array",
"items": {
"type": "string"
}
}
},
"additionalProperties": false
}
}
},
"additionalProperties": false
}
}
},
{
"properties": {
"type": {
"const": "SetLocalMapping"
},
"data": {
"type": "object",
"required": [
"request_id",
"service_id",
"enabled"
],
"properties": {
"request_id": {
"type": "string"
},
"service_id": {
"type": "string"
},
"enabled": {
"type": "boolean"
}
},
"additionalProperties": false
}
}
},
{
"properties": {
"type": {
"const": "LocalMappingAck"
},
"data": {
"type": "object",
"required": [
"request_id",
"service_id",
"enabled"
],
"properties": {
"request_id": {
"type": "string"
},
"service_id": {
"type": "string"
},
"enabled": {
"type": "boolean"
}
},
"additionalProperties": false
}
}
},
{
"properties": {
"type": {
"const": "AuthenticationResult"
},
"data": {
"type": "object",
"required": [
"request_id",
"success",
"message",
"server_version"
],
"properties": {
"request_id": {
"type": "string"
},
"success": {
"type": "boolean"
},
"message": {
"type": "string"
},
"server_version": {
"type": "string"
},
"client_id": {
"type": "string"
},
"permissions": {
"type": "array",
"items": {
"type": "string"
}
},
"expires_in_seconds": {
"type": "integer",
"minimum": 0
}
},
"additionalProperties": false
}
}
},
{
"$ref": "error.schema.json"
}
],
"required": [
"type",
"data"
]
}