{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/latitude-so/json-schema/latitude-so-memory-record-detail-schema.json",
  "title": "MemoryRecordDetail",
  "x-generated": "2026-11-10",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/latitude-so-memory-api-openapi.yml#/components/schemas/MemoryRecordDetail",
  "type": "object",
  "properties": {
    "body": {
      "type": [
        "string",
        "null"
      ],
      "description": "The record's current body. `null` when the record is deleted or its body was not captured."
    },
    "tokenCount": {
      "type": "integer",
      "minimum": 0,
      "description": "Tokens in the current body."
    },
    "versions": {
      "type": "array",
      "items": {
        "$ref": "#/$defs/MemoryRecordVersion"
      },
      "description": "The record's mutating version chain, newest first."
    }
  },
  "required": [
    "body",
    "tokenCount",
    "versions"
  ],
  "$defs": {
    "MemoryRecordVersion": {
      "type": "object",
      "properties": {
        "changeKind": {
          "type": "string",
          "enum": [
            "add",
            "update",
            "remove",
            "read",
            "store_create",
            "store_delete"
          ],
          "description": "Kind of memory operation: `add`/`update`/`remove` (mutations), `read` (retrieval), or `store_create`/`store_delete` (store lifecycle)."
        },
        "tokenCount": {
          "type": "integer",
          "minimum": 0,
          "description": "Tokens in the body produced by this version."
        },
        "tokensAdded": {
          "type": "integer",
          "minimum": 0,
          "description": "Tokens added by this version versus its predecessor."
        },
        "tokensRemoved": {
          "type": "integer",
          "minimum": 0,
          "description": "Tokens removed by this version versus its predecessor."
        },
        "spanId": {
          "type": "string",
          "description": "Span that authored this version."
        },
        "traceId": {
          "type": "string",
          "description": "Trace the authoring span belongs to."
        },
        "sessionId": {
          "type": "string",
          "description": "Session the authoring trace belongs to."
        },
        "userId": {
          "type": "string",
          "description": "End-user attributed to the authoring span. Empty when none."
        },
        "endTime": {
          "type": "string",
          "description": "ISO-8601 timestamp of the authoring span's end (the version ordering key)."
        }
      },
      "required": [
        "changeKind",
        "tokenCount",
        "tokensAdded",
        "tokensRemoved",
        "spanId",
        "traceId",
        "sessionId",
        "userId",
        "endTime"
      ]
    }
  }
}