{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/codai-ro/json-schema/codai-ro-session-schema.json",
  "title": "Session",
  "description": "A shared session as returned by create/patch and embedded in list/detail.",
  "x-generated": "2026-11-10",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/codai-ro-sessions-api-openapi.yml#/components/schemas/Session",
  "type": "object",
  "required": [
    "id",
    "session_key",
    "owner_user_id",
    "title",
    "created_at",
    "last_event_at",
    "last_seq",
    "executor_device_id",
    "lease_expires_at",
    "e2e",
    "archived",
    "stub"
  ],
  "properties": {
    "id": {
      "type": "string",
      "format": "uuid",
      "description": "Server-assigned id."
    },
    "session_key": {
      "type": "string",
      "description": "Client-chosen stable key, unique per owner."
    },
    "owner_user_id": {
      "type": "string",
      "format": "uuid"
    },
    "title": {
      "type": [
        "string",
        "null"
      ],
      "maxLength": 500
    },
    "created_at": {
      "type": "string",
      "format": "date-time"
    },
    "last_event_at": {
      "type": "string",
      "format": "date-time",
      "description": "Bumped on every stored event."
    },
    "last_seq": {
      "type": "integer",
      "minimum": 0,
      "description": "Highest event `seq`; 0 for an empty session."
    },
    "executor_device_id": {
      "type": [
        "string",
        "null"
      ],
      "format": "uuid",
      "description": "Mirror of the lease holder; may be stale until the next lease write."
    },
    "lease_expires_at": {
      "type": [
        "string",
        "null"
      ],
      "format": "date-time"
    },
    "e2e": {
      "type": "boolean",
      "description": "Payloads are end-to-end encrypted client-side."
    },
    "archived": {
      "type": "boolean"
    },
    "stub": {
      "type": "boolean",
      "description": "Title-only mirror without events yet; cleared by the first appended event batch."
    }
  }
}