{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://sidecat.dev/spec/system/0.1/author.schema.json",
  "title": "Sidecat System 0.1 candidate author profile",
  "description": "Unpublished trial schema. Parser rules for duplicate members, UTF-8 and number lexical form are additional to JSON Schema.",
  "oneOf": [
    {
      "$ref": "#/$defs/descriptor"
    },
    {
      "$ref": "#/$defs/call"
    },
    {
      "$ref": "#/$defs/outcome"
    },
    {
      "$ref": "#/$defs/event"
    },
    {
      "$ref": "#/$defs/subscribe"
    },
    {
      "$ref": "#/$defs/challenge"
    },
    {
      "$ref": "#/$defs/authenticate"
    },
    {
      "$ref": "#/$defs/ready"
    },
    {
      "$ref": "#/$defs/authError"
    },
    {
      "$ref": "#/$defs/activation"
    },
    {
      "$ref": "#/$defs/selection"
    }
  ],
  "$defs": {
    "iri": {
      "type": "string",
      "minLength": 3,
      "maxLength": 2048,
      "pattern": "^[A-Za-z][A-Za-z0-9+.-]*:.+"
    },
    "name": {
      "type": "string",
      "minLength": 1,
      "maxLength": 128,
      "pattern": "^[a-z][a-z0-9]*(?:[.-][a-z0-9]+)*$"
    },
    "token": {
      "type": "string",
      "minLength": 1,
      "maxLength": 4096
    },
    "path": {
      "type": "string",
      "minLength": 1,
      "maxLength": 512,
      "pattern": "^(?!/)(?!.*(?:^|/)\\.\\.(?:/|$))[A-Za-z0-9_./-]+$"
    },
    "decimalText": {
      "type": "string",
      "pattern": "^(?:0|-?[1-9][0-9]*)$"
    },
    "safeInteger": {
      "type": "integer",
      "minimum": -9007199254740991,
      "maximum": 9007199254740991
    },
    "integerValue": {
      "type": "object",
      "required": [
        "$sidecat",
        "decimal"
      ],
      "properties": {
        "$sidecat": {
          "const": "integer"
        },
        "decimal": {
          "$ref": "#/$defs/decimalText"
        }
      },
      "additionalProperties": false
    },
    "decimalValue": {
      "type": "object",
      "required": [
        "$sidecat",
        "coefficient",
        "scale"
      ],
      "properties": {
        "$sidecat": {
          "const": "decimal"
        },
        "coefficient": {
          "$ref": "#/$defs/decimalText"
        },
        "scale": {
          "$ref": "#/$defs/safeInteger"
        }
      },
      "additionalProperties": false
    },
    "float64Value": {
      "type": "object",
      "required": [
        "$sidecat",
        "bits"
      ],
      "properties": {
        "$sidecat": {
          "const": "float64"
        },
        "bits": {
          "type": "string",
          "pattern": "^[0-9a-f]{16}$"
        }
      },
      "additionalProperties": false
    },
    "objectRef": {
      "type": "object",
      "required": [
        "$sidecat",
        "owner",
        "type",
        "key"
      ],
      "properties": {
        "$sidecat": {
          "const": "object-ref"
        },
        "owner": {
          "$ref": "#/$defs/ownerID"
        },
        "type": {
          "$ref": "#/$defs/iri"
        },
        "key": {
          "$ref": "#/$defs/token"
        }
      },
      "additionalProperties": false
    },
    "revisionRef": {
      "type": "object",
      "required": [
        "$sidecat",
        "object",
        "revision"
      ],
      "properties": {
        "$sidecat": {
          "const": "revision-ref"
        },
        "object": {
          "$ref": "#/$defs/objectRef"
        },
        "revision": {
          "$ref": "#/$defs/token"
        }
      },
      "additionalProperties": false
    },
    "blobRef": {
      "type": "object",
      "required": [
        "$sidecat",
        "algorithm",
        "digest"
      ],
      "properties": {
        "$sidecat": {
          "const": "blob-ref"
        },
        "algorithm": {
          "const": "sha-256"
        },
        "owner": {
          "$ref": "#/$defs/ownerID"
        },
        "digest": {
          "type": "string",
          "pattern": "^[0-9a-f]{64}$"
        }
      },
      "additionalProperties": false
    },
    "foreignRef": {
      "type": "object",
      "required": [
        "$sidecat",
        "protocol",
        "authority",
        "identifier"
      ],
      "properties": {
        "$sidecat": {
          "const": "foreign-ref"
        },
        "protocol": {
          "$ref": "#/$defs/iri"
        },
        "authority": {
          "type": "string",
          "minLength": 1,
          "maxLength": 4096
        },
        "identifier": {
          "$ref": "#/$defs/token"
        },
        "revision": {
          "$ref": "#/$defs/token"
        }
      },
      "additionalProperties": false
    },
    "opaqueValue": {
      "type": "object",
      "required": [
        "$sidecat",
        "type",
        "codec",
        "data"
      ],
      "properties": {
        "$sidecat": {
          "const": "opaque"
        },
        "type": {
          "$ref": "#/$defs/iri"
        },
        "codec": {
          "$ref": "#/$defs/iri"
        },
        "data": {
          "type": "string",
          "contentEncoding": "base64",
          "maxLength": 1398104,
          "pattern": "^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$"
        }
      },
      "additionalProperties": false
    },
    "portableValue": {
      "oneOf": [
        {
          "type": "null"
        },
        {
          "type": "boolean"
        },
        {
          "type": "string"
        },
        {
          "$ref": "#/$defs/safeInteger"
        },
        {
          "type": "array",
          "items": {
            "$ref": "#/$defs/portableValue"
          }
        },
        {
          "type": "object",
          "not": {
            "required": [
              "$sidecat"
            ]
          },
          "additionalProperties": {
            "$ref": "#/$defs/portableValue"
          }
        },
        {
          "$ref": "#/$defs/integerValue"
        },
        {
          "$ref": "#/$defs/decimalValue"
        },
        {
          "$ref": "#/$defs/float64Value"
        },
        {
          "$ref": "#/$defs/objectRef"
        },
        {
          "$ref": "#/$defs/revisionRef"
        },
        {
          "$ref": "#/$defs/blobRef"
        },
        {
          "$ref": "#/$defs/foreignRef"
        },
        {
          "$ref": "#/$defs/opaqueValue"
        }
      ]
    },
    "authority": {
      "oneOf": [
        {
          "const": "public"
        },
        {
          "type": "object",
          "required": [
            "action",
            "resourceField"
          ],
          "properties": {
            "action": {
              "$ref": "#/$defs/iri"
            },
            "resourceField": {
              "type": "string",
              "pattern": "^/"
            }
          },
          "additionalProperties": false
        }
      ]
    },
    "operation": {
      "type": "object",
      "required": [
        "name",
        "inputSchema",
        "outputSchema",
        "effect",
        "retry",
        "authority",
        "resourceClass",
        "failures",
        "atomicScope",
        "concurrency",
        "authorizationAt",
        "supportedGuarantees"
      ],
      "properties": {
        "name": {
          "$ref": "#/$defs/name"
        },
        "inputSchema": {
          "$ref": "#/$defs/path"
        },
        "outputSchema": {
          "$ref": "#/$defs/path"
        },
        "effect": {
          "enum": [
            "pure",
            "read",
            "local-mutation",
            "external-effect",
            "continuation"
          ]
        },
        "retry": {
          "enum": [
            "safe",
            "deduplicated",
            "unsafe"
          ]
        },
        "retryKeyScope": {
          "const": "owner+enrollment+interface+operation"
        },
        "retryStatusOperation": {
          "$ref": "#/$defs/name"
        },
        "authority": {
          "$ref": "#/$defs/authority"
        },
        "resourceClass": {
          "enum": [
            "pure",
            "storage-read",
            "storage-write",
            "cpu",
            "network",
            "model",
            "external"
          ]
        },
        "failures": {
          "type": "array",
          "uniqueItems": true,
          "items": {
            "$ref": "#/$defs/name"
          }
        },
        "atomicScope": {
          "enum": [
            "none",
            "object",
            "owner",
            "external-target"
          ]
        },
        "concurrency": {
          "enum": [
            "none",
            "compare-at-commit",
            "append",
            "owner-serialized",
            "effect-intent"
          ]
        },
        "expectedVersionField": {
          "type": "string",
          "pattern": "^/"
        },
        "authorizationAt": {
          "enum": [
            "none",
            "read",
            "admission",
            "commit",
            "effect"
          ]
        },
        "supportedGuarantees": {
          "type": "array",
          "uniqueItems": true,
          "items": {
            "$ref": "#/$defs/iri"
          }
        },
        "retryHorizonSeconds": {
          "type": "integer",
          "minimum": 1,
          "maximum": 9007199254740991
        }
      },
      "allOf": [
        {
          "if": {
            "properties": {
              "retry": {
                "const": "deduplicated"
              }
            }
          },
          "then": {
            "required": [
              "retryKeyScope",
              "retryStatusOperation",
              "retryHorizonSeconds"
            ]
          }
        },
        {
          "if": {
            "properties": {
              "concurrency": {
                "const": "compare-at-commit"
              }
            },
            "required": [
              "concurrency"
            ]
          },
          "then": {
            "required": [
              "expectedVersionField"
            ]
          }
        }
      ],
      "additionalProperties": false
    },
    "objectDeclaration": {
      "type": "object",
      "required": [
        "type",
        "protocols"
      ],
      "properties": {
        "type": {
          "$ref": "#/$defs/iri"
        },
        "protocols": {
          "type": "array",
          "uniqueItems": true,
          "items": {
            "enum": [
              "read-current",
              "conditional-replace",
              "append",
              "query",
              "history",
              "facets",
              "subscribe"
            ]
          }
        }
      },
      "additionalProperties": false
    },
    "eventDeclaration": {
      "type": "object",
      "required": [
        "name",
        "schema",
        "version",
        "delivery",
        "orderScope"
      ],
      "properties": {
        "name": {
          "$ref": "#/$defs/name"
        },
        "schema": {
          "$ref": "#/$defs/path"
        },
        "version": {
          "type": "integer",
          "minimum": 1
        },
        "delivery": {
          "enum": [
            "signal",
            "invalidation",
            "retained"
          ]
        },
        "orderScope": {
          "type": "string",
          "minLength": 1
        },
        "minimumRetentionSeconds": {
          "type": "integer",
          "minimum": 1
        },
        "gap": {
          "enum": [
            "explicit",
            "not-applicable"
          ]
        }
      },
      "allOf": [
        {
          "if": {
            "properties": {
              "delivery": {
                "const": "retained"
              }
            }
          },
          "then": {
            "required": [
              "minimumRetentionSeconds",
              "gap"
            ]
          }
        }
      ],
      "additionalProperties": false
    },
    "interface": {
      "type": "object",
      "required": [
        "id",
        "major",
        "objects",
        "operations",
        "events",
        "minor",
        "profiles"
      ],
      "properties": {
        "id": {
          "$ref": "#/$defs/iri"
        },
        "major": {
          "type": "integer",
          "minimum": 1
        },
        "objects": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/objectDeclaration"
          }
        },
        "operations": {
          "type": "array",
          "minItems": 1,
          "items": {
            "$ref": "#/$defs/operation"
          }
        },
        "events": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/eventDeclaration"
          }
        },
        "minor": {
          "type": "integer",
          "minimum": 0
        },
        "profiles": {
          "type": "array",
          "uniqueItems": true,
          "items": {
            "$ref": "#/$defs/iri"
          }
        }
      },
      "additionalProperties": false
    },
    "requirement": {
      "type": "object",
      "required": [
        "interface",
        "major",
        "minimumMinor",
        "requiredProfiles"
      ],
      "properties": {
        "interface": {
          "$ref": "#/$defs/iri"
        },
        "major": {
          "type": "integer",
          "minimum": 1
        },
        "minimumMinor": {
          "type": "integer",
          "minimum": 0
        },
        "requiredProfiles": {
          "type": "array",
          "uniqueItems": true,
          "items": {
            "$ref": "#/$defs/iri"
          }
        }
      },
      "additionalProperties": false
    },
    "descriptor": {
      "type": "object",
      "required": [
        "systemProfile",
        "appID",
        "appVersion",
        "purpose",
        "helpPath",
        "interfaces",
        "requires"
      ],
      "properties": {
        "systemProfile": {
          "const": "sidecat.system/0.1"
        },
        "appID": {
          "$ref": "#/$defs/iri"
        },
        "appVersion": {
          "type": "string",
          "pattern": "^[0-9]+\\.[0-9]+\\.[0-9]+$"
        },
        "purpose": {
          "type": "string",
          "minLength": 1,
          "maxLength": 1000
        },
        "helpPath": {
          "$ref": "#/$defs/path"
        },
        "interfaces": {
          "type": "array",
          "minItems": 1,
          "items": {
            "$ref": "#/$defs/interface"
          }
        },
        "requires": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/requirement"
          }
        }
      },
      "additionalProperties": false
    },
    "target": {
      "type": "object",
      "required": [
        "app",
        "interface",
        "operation"
      ],
      "properties": {
        "app": {
          "$ref": "#/$defs/iri"
        },
        "interface": {
          "$ref": "#/$defs/iri"
        },
        "operation": {
          "$ref": "#/$defs/name"
        },
        "owner": {
          "$ref": "#/$defs/ownerID"
        },
        "minimumMinor": {
          "type": "integer",
          "minimum": 0
        }
      },
      "additionalProperties": false
    },
    "call": {
      "type": "object",
      "required": [
        "profile",
        "kind",
        "callID",
        "target",
        "input"
      ],
      "properties": {
        "profile": {
          "const": "sidecat.system/0.1"
        },
        "kind": {
          "const": "call"
        },
        "callID": {
          "type": "string",
          "minLength": 1,
          "maxLength": 128
        },
        "target": {
          "$ref": "#/$defs/target"
        },
        "input": {
          "$ref": "#/$defs/portableValue"
        },
        "deadlineMs": {
          "type": "integer",
          "minimum": 1,
          "maximum": 9007199254740991
        },
        "retryKey": {
          "$ref": "#/$defs/token"
        },
        "requestedGuarantees": {
          "type": "array",
          "uniqueItems": true,
          "items": {
            "$ref": "#/$defs/iri"
          }
        }
      },
      "additionalProperties": false
    },
    "error": {
      "type": "object",
      "required": [
        "code",
        "message"
      ],
      "properties": {
        "code": {
          "$ref": "#/$defs/name"
        },
        "message": {
          "type": "string",
          "minLength": 1,
          "maxLength": 2000
        },
        "nextAction": {
          "type": "string",
          "maxLength": 2000
        }
      },
      "additionalProperties": false
    },
    "outcome": {
      "type": "object",
      "required": [
        "profile",
        "kind",
        "callID",
        "disposition"
      ],
      "properties": {
        "profile": {
          "const": "sidecat.system/0.1"
        },
        "kind": {
          "const": "outcome"
        },
        "callID": {
          "type": "string",
          "minLength": 1,
          "maxLength": 128
        },
        "disposition": {
          "enum": [
            "completed",
            "refused",
            "accepted",
            "unknown"
          ]
        },
        "value": {
          "$ref": "#/$defs/portableValue"
        },
        "error": {
          "$ref": "#/$defs/error"
        },
        "continuation": {
          "$ref": "#/$defs/objectRef"
        },
        "reconciliation": {
          "$ref": "#/$defs/objectRef"
        },
        "effectiveGuarantees": {
          "type": "array",
          "uniqueItems": true,
          "items": {
            "$ref": "#/$defs/iri"
          }
        },
        "selectionID": {
          "$ref": "#/$defs/token"
        }
      },
      "allOf": [
        {
          "if": {
            "properties": {
              "disposition": {
                "const": "completed"
              }
            }
          },
          "then": {
            "required": [
              "value"
            ],
            "not": {
              "anyOf": [
                {
                  "required": [
                    "error"
                  ]
                },
                {
                  "required": [
                    "continuation"
                  ]
                },
                {
                  "required": [
                    "reconciliation"
                  ]
                }
              ]
            }
          }
        },
        {
          "if": {
            "properties": {
              "disposition": {
                "const": "refused"
              }
            }
          },
          "then": {
            "required": [
              "error"
            ],
            "not": {
              "anyOf": [
                {
                  "required": [
                    "value"
                  ]
                },
                {
                  "required": [
                    "continuation"
                  ]
                },
                {
                  "required": [
                    "reconciliation"
                  ]
                }
              ]
            }
          }
        },
        {
          "if": {
            "properties": {
              "disposition": {
                "const": "accepted"
              }
            }
          },
          "then": {
            "required": [
              "continuation"
            ],
            "not": {
              "anyOf": [
                {
                  "required": [
                    "value"
                  ]
                },
                {
                  "required": [
                    "error"
                  ]
                },
                {
                  "required": [
                    "reconciliation"
                  ]
                }
              ]
            }
          }
        },
        {
          "if": {
            "properties": {
              "disposition": {
                "const": "unknown"
              }
            }
          },
          "then": {
            "required": [
              "reconciliation"
            ],
            "not": {
              "anyOf": [
                {
                  "required": [
                    "value"
                  ]
                },
                {
                  "required": [
                    "error"
                  ]
                },
                {
                  "required": [
                    "continuation"
                  ]
                }
              ]
            }
          }
        }
      ],
      "additionalProperties": false
    },
    "event": {
      "type": "object",
      "required": [
        "profile",
        "kind",
        "source",
        "event",
        "delivery",
        "payload"
      ],
      "properties": {
        "profile": {
          "const": "sidecat.system/0.1"
        },
        "kind": {
          "const": "event"
        },
        "source": {
          "$ref": "#/$defs/source"
        },
        "event": {
          "$ref": "#/$defs/name"
        },
        "delivery": {
          "enum": [
            "signal",
            "invalidation",
            "retained"
          ]
        },
        "eventID": {
          "$ref": "#/$defs/token"
        },
        "ownerOrder": {
          "$ref": "#/$defs/token"
        },
        "eventVersion": {
          "type": "integer",
          "minimum": 1
        },
        "schemaDigest": {
          "$ref": "#/$defs/sha256Hex"
        },
        "watermark": {
          "$ref": "#/$defs/token"
        },
        "causeID": {
          "$ref": "#/$defs/token"
        },
        "payload": {
          "$ref": "#/$defs/portableValue"
        }
      },
      "allOf": [
        {
          "if": {
            "properties": {
              "delivery": {
                "const": "retained"
              }
            }
          },
          "then": {
            "required": [
              "eventID",
              "ownerOrder",
              "eventVersion",
              "schemaDigest"
            ]
          }
        },
        {
          "if": {
            "properties": {
              "delivery": {
                "const": "invalidation"
              }
            },
            "required": [
              "delivery"
            ]
          },
          "then": {
            "required": [
              "watermark"
            ]
          }
        },
        {
          "if": {
            "properties": {
              "delivery": {
                "enum": [
                  "retained",
                  "invalidation"
                ]
              }
            },
            "required": [
              "delivery"
            ]
          },
          "then": {
            "properties": {
              "source": {
                "required": [
                  "owner"
                ]
              }
            }
          }
        }
      ],
      "additionalProperties": false
    },
    "subscribe": {
      "type": "object",
      "required": [
        "profile",
        "kind",
        "source",
        "delivery",
        "maxItems",
        "maxBytes",
        "maxInFlight"
      ],
      "properties": {
        "profile": {
          "const": "sidecat.system/0.1"
        },
        "kind": {
          "const": "subscribe"
        },
        "source": {
          "$ref": "#/$defs/source"
        },
        "delivery": {
          "enum": [
            "signal",
            "invalidation",
            "retained"
          ]
        },
        "filter": {
          "type": "object"
        },
        "cursor": {
          "$ref": "#/$defs/token"
        },
        "maxItems": {
          "type": "integer",
          "minimum": 1
        },
        "maxBytes": {
          "type": "integer",
          "minimum": 1
        },
        "maxInFlight": {
          "type": "integer",
          "minimum": 1
        }
      },
      "additionalProperties": false,
      "allOf": [
        {
          "if": {
            "properties": {
              "delivery": {
                "enum": [
                  "retained",
                  "invalidation"
                ]
              }
            },
            "required": [
              "delivery"
            ]
          },
          "then": {
            "properties": {
              "source": {
                "required": [
                  "owner"
                ]
              }
            }
          }
        },
        {
          "if": {
            "properties": {
              "delivery": {
                "const": "signal"
              }
            },
            "required": [
              "delivery"
            ]
          },
          "then": {
            "not": {
              "required": [
                "cursor"
              ]
            }
          }
        }
      ]
    },
    "ownerID": {
      "type": "string",
      "pattern": "^urn:sidecat:owner:[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$"
    },
    "b64urlNonce": {
      "type": "string",
      "pattern": "^[A-Za-z0-9_-]{43}$"
    },
    "b64urlSignature": {
      "type": "string",
      "pattern": "^[A-Za-z0-9_-]{86}$"
    },
    "sha256Hex": {
      "type": "string",
      "pattern": "^[0-9a-f]{64}$"
    },
    "source": {
      "type": "object",
      "required": [
        "app",
        "interface"
      ],
      "properties": {
        "app": {
          "$ref": "#/$defs/iri"
        },
        "interface": {
          "$ref": "#/$defs/iri"
        },
        "owner": {
          "$ref": "#/$defs/ownerID"
        }
      },
      "additionalProperties": false
    },
    "challenge": {
      "type": "object",
      "required": [
        "profile",
        "kind",
        "serverNonce",
        "supportedProfiles",
        "authProfile",
        "maxFrameBytes",
        "expiresAfterMs"
      ],
      "properties": {
        "profile": {
          "const": "sidecat.system/0.1"
        },
        "kind": {
          "const": "challenge"
        },
        "serverNonce": {
          "$ref": "#/$defs/b64urlNonce"
        },
        "supportedProfiles": {
          "type": "array",
          "minItems": 1,
          "uniqueItems": true,
          "items": {
            "const": "sidecat.system/0.1"
          }
        },
        "authProfile": {
          "const": "sidecat.local-ed25519/1"
        },
        "maxFrameBytes": {
          "type": "integer",
          "minimum": 1,
          "maximum": 4294967295
        },
        "expiresAfterMs": {
          "type": "integer",
          "minimum": 1,
          "maximum": 9007199254740991
        }
      },
      "additionalProperties": false
    },
    "authenticate": {
      "type": "object",
      "required": [
        "profile",
        "kind",
        "selectedProfile",
        "authProfile",
        "enrollmentID",
        "credentialID",
        "clientNonce",
        "signature"
      ],
      "properties": {
        "profile": {
          "const": "sidecat.system/0.1"
        },
        "kind": {
          "const": "authenticate"
        },
        "selectedProfile": {
          "const": "sidecat.system/0.1"
        },
        "authProfile": {
          "const": "sidecat.local-ed25519/1"
        },
        "enrollmentID": {
          "$ref": "#/$defs/token"
        },
        "credentialID": {
          "$ref": "#/$defs/token"
        },
        "clientNonce": {
          "$ref": "#/$defs/b64urlNonce"
        },
        "signature": {
          "$ref": "#/$defs/b64urlSignature"
        }
      },
      "additionalProperties": false
    },
    "ready": {
      "type": "object",
      "required": [
        "profile",
        "kind",
        "connectionID",
        "actorID",
        "enrollmentID",
        "authEpoch",
        "maxFrameBytes",
        "connectionValidForSeconds"
      ],
      "properties": {
        "profile": {
          "const": "sidecat.system/0.1"
        },
        "kind": {
          "const": "ready"
        },
        "connectionID": {
          "$ref": "#/$defs/token"
        },
        "actorID": {
          "$ref": "#/$defs/token"
        },
        "enrollmentID": {
          "$ref": "#/$defs/token"
        },
        "authEpoch": {
          "type": "integer",
          "minimum": 0
        },
        "maxFrameBytes": {
          "type": "integer",
          "minimum": 1,
          "maximum": 4294967295
        },
        "connectionValidForSeconds": {
          "type": "integer",
          "minimum": 1,
          "maximum": 86400
        }
      },
      "additionalProperties": false
    },
    "authError": {
      "type": "object",
      "required": [
        "profile",
        "kind",
        "code",
        "message"
      ],
      "properties": {
        "profile": {
          "const": "sidecat.system/0.1"
        },
        "kind": {
          "const": "auth-error"
        },
        "code": {
          "enum": [
            "unsupported-profile",
            "unauthenticated",
            "expired",
            "busy"
          ]
        },
        "message": {
          "type": "string",
          "minLength": 1,
          "maxLength": 2000
        }
      },
      "additionalProperties": false
    },
    "interfaceVersion": {
      "type": "object",
      "required": [
        "id",
        "major",
        "minor"
      ],
      "properties": {
        "id": {
          "$ref": "#/$defs/iri"
        },
        "major": {
          "type": "integer",
          "minimum": 1
        },
        "minor": {
          "type": "integer",
          "minimum": 0
        }
      },
      "additionalProperties": false
    },
    "activation": {
      "type": "object",
      "required": [
        "profile",
        "kind",
        "appID",
        "appVersion",
        "packageDigest",
        "descriptorDigest",
        "handlerBuildDigest",
        "owner",
        "instanceID",
        "interfaces"
      ],
      "properties": {
        "profile": {
          "const": "sidecat.system/0.1"
        },
        "kind": {
          "const": "activation"
        },
        "appID": {
          "$ref": "#/$defs/iri"
        },
        "appVersion": {
          "type": "string",
          "pattern": "^[0-9]+\\.[0-9]+\\.[0-9]+$"
        },
        "packageDigest": {
          "$ref": "#/$defs/blobRef"
        },
        "descriptorDigest": {
          "$ref": "#/$defs/blobRef"
        },
        "handlerBuildDigest": {
          "$ref": "#/$defs/blobRef"
        },
        "owner": {
          "$ref": "#/$defs/ownerID"
        },
        "instanceID": {
          "$ref": "#/$defs/token"
        },
        "interfaces": {
          "type": "array",
          "minItems": 1,
          "items": {
            "$ref": "#/$defs/interfaceVersion"
          }
        }
      },
      "additionalProperties": false
    },
    "selection": {
      "type": "object",
      "required": [
        "profile",
        "kind",
        "callID",
        "selectionID",
        "owner",
        "candidateFingerprint",
        "effectiveGuarantees",
        "decisionRequired"
      ],
      "properties": {
        "profile": {
          "const": "sidecat.system/0.1"
        },
        "kind": {
          "const": "selection"
        },
        "callID": {
          "$ref": "#/$defs/token"
        },
        "selectionID": {
          "$ref": "#/$defs/token"
        },
        "owner": {
          "$ref": "#/$defs/ownerID"
        },
        "candidateFingerprint": {
          "$ref": "#/$defs/sha256Hex"
        },
        "effectiveGuarantees": {
          "type": "array",
          "uniqueItems": true,
          "items": {
            "$ref": "#/$defs/iri"
          }
        },
        "decisionRequired": {
          "type": "boolean"
        },
        "expectedVersion": {
          "$ref": "#/$defs/token"
        }
      },
      "additionalProperties": false
    }
  }
}
