{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/looot/json-schema/looot-session-context-schema.json",
  "title": "SessionContext",
  "x-generated": "2026-11-10",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/looot-session-context-api-openapi.yml#/components/schemas/SessionContext",
  "type": "object",
  "additionalProperties": false,
  "required": [
    "mode",
    "authenticationClass",
    "organizationId",
    "scopes",
    "deploymentMode",
    "role"
  ],
  "properties": {
    "mode": {
      "const": "local_alpha"
    },
    "authenticationClass": {
      "enum": [
        "local_static_token",
        "machine_session"
      ]
    },
    "organizationId": {
      "oneOf": [
        {
          "type": "string",
          "pattern": "^[a-z][a-z0-9_-]{2,127}$"
        },
        {
          "type": "string",
          "pattern": "^[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$"
        }
      ]
    },
    "scopes": {
      "type": "array",
      "maxItems": 100,
      "uniqueItems": true,
      "items": {
        "type": "string",
        "minLength": 1,
        "maxLength": 128,
        "pattern": "^(?:\\*|[a-z][a-z0-9-]{0,62}(?::(?:\\*|[a-z][a-z0-9-]{0,62}))?)$"
      }
    },
    "deploymentMode": {
      "description": "Operator-facing deployment mode: fixture_demo/authenticated_sandbox in local_alpha, approved_production in production, degraded whenever live readiness fails regardless of mode.",
      "enum": [
        "fixture_demo",
        "authenticated_sandbox",
        "approved_production",
        "degraded"
      ]
    },
    "role": {
      "description": "The resolved principal's organization role; null for a resolver that never set one.",
      "enum": [
        "owner",
        "admin",
        "member",
        "viewer",
        null
      ]
    },
    "expiresAt": {
      "description": "Present only for ?include=expiresAt: the presenting token's own expiry (ISO 8601 UTC), or null when it has none.",
      "type": [
        "string",
        "null"
      ],
      "format": "date-time"
    },
    "organizationName": {
      "description": "Present only for ?include=organizationName: the organization's display name, or null when the gateway could not read one.",
      "type": [
        "string",
        "null"
      ],
      "minLength": 1,
      "maxLength": 120
    }
  }
}