{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://hybrid-cortex.com/integrations/platform/identity-authority.schema.json",
  "title": "Reviewed Hybrid ID registered-client Cortex authority v1",
  "description": "Compatible implementation deployed by Hybrid ID with gates closed, not commissioned. Millisecond timestamps, lease at most 5000ms, current app/owner/agent/protection authority and exact request digest. Internal subject projections never enter counterparty responses.",
  "type": "object",
  "additionalProperties": false,
  "required": [
    "schema",
    "audience",
    "client_id",
    "subject",
    "app_subject",
    "caller_kind",
    "agent_id",
    "grant_id",
    "generation",
    "permissions",
    "readiness",
    "synthetic",
    "request_digest",
    "checked_at",
    "expires_at",
    "owner_approval"
  ],
  "properties": {
    "schema": {
      "const": "HYBRID_CORTEX_PLATFORM_AUTHORITY_V1"
    },
    "audience": {
      "const": "https://hybrid-cortex.com"
    },
    "client_id": {
      "type": "string",
      "pattern": "^hid_app_[A-Za-z0-9_-]{1,128}$"
    },
    "subject": {
      "type": "string",
      "pattern": "^[A-Za-z0-9_-]{43}$"
    },
    "app_subject": {
      "type": "string",
      "pattern": "^[A-Za-z0-9_-]{43}$"
    },
    "caller_kind": {
      "enum": [
        "owner",
        "agent"
      ]
    },
    "agent_id": {
      "anyOf": [
        {
          "type": "null"
        },
        {
          "type": "string",
          "pattern": "^[a-f0-9]{32}$"
        }
      ]
    },
    "grant_id": {
      "type": "string",
      "pattern": "^[A-Za-z0-9_-]{16,160}$"
    },
    "generation": {
      "type": "string",
      "pattern": "^[a-f0-9]{64}$"
    },
    "permissions": {
      "type": "array",
      "minItems": 1,
      "uniqueItems": true,
      "items": {
        "enum": [
          "cortex:platform:onboarding",
          "cortex:platform:participation",
          "cortex:platform:query",
          "cortex:platform:introductions",
          "cortex:platform:usage"
        ]
      }
    },
    "readiness": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "identity",
        "protection",
        "vault"
      ],
      "properties": {
        "identity": {
          "type": "boolean"
        },
        "protection": {
          "type": "boolean"
        },
        "vault": {
          "type": "boolean"
        }
      }
    },
    "synthetic": {
      "type": "boolean"
    },
    "request_digest": {
      "type": "string",
      "pattern": "^[a-f0-9]{64}$"
    },
    "checked_at": {
      "type": "integer"
    },
    "expires_at": {
      "type": "integer"
    },
    "owner_approval": {
      "anyOf": [
        {
          "type": "null"
        },
        {
          "type": "object",
          "additionalProperties": false,
          "required": [
            "receipt_id",
            "subject",
            "request_digest",
            "operation",
            "expires_at"
          ],
          "properties": {
            "receipt_id": {
              "type": "string",
              "pattern": "^[A-Za-z0-9_-]{16,160}$"
            },
            "subject": {
              "type": "string",
              "pattern": "^[A-Za-z0-9_-]{43}$"
            },
            "request_digest": {
              "type": "string",
              "pattern": "^[a-f0-9]{64}$"
            },
            "operation": {
              "type": "string"
            },
            "expires_at": {
              "type": "integer",
              "description": "Short-lived exact owner decision, maximum five minutes and bounded by grant/terms expiry."
            }
          }
        }
      ]
    }
  },
  "$defs": {
    "ParticipantCurrent": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "client_id",
        "subject",
        "grant_id",
        "generation",
        "request_digest",
        "checked_at",
        "expires_at",
        "schema",
        "agent_id",
        "representation",
        "active"
      ],
      "properties": {
        "client_id": {
          "type": "string",
          "pattern": "^hid_app_[A-Za-z0-9_-]{1,128}$"
        },
        "subject": {
          "type": "string",
          "pattern": "^[A-Za-z0-9_-]{43}$"
        },
        "grant_id": {
          "type": "string",
          "pattern": "^[A-Za-z0-9_-]{16,160}$"
        },
        "generation": {
          "type": "string",
          "pattern": "^[a-f0-9]{64}$"
        },
        "request_digest": {
          "type": "string",
          "pattern": "^[a-f0-9]{64}$"
        },
        "checked_at": {
          "type": "integer"
        },
        "expires_at": {
          "type": "integer"
        },
        "schema": {
          "const": "HYBRID_CORTEX_PLATFORM_PARTICIPANT_V1"
        },
        "agent_id": {
          "type": "string",
          "pattern": "^[a-f0-9]{32}$"
        },
        "representation": {
          "const": "personal"
        },
        "active": {
          "const": true
        }
      },
      "description": "Current canonical personal-agent ownership/grant/protection status; at most five-second observation, not a renewal or data grant."
    }
  }
}
