{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/contextdb-ai/json-schema/contextdb-ai-evolve-request-schema.json",
  "title": "EvolveRequest",
  "description": "ADD requires content+source and rejects target_memory_id. UPDATE\nrequires content+source plus target_memory_id or entity+attribute.\nDELETE accepts no content/write attributes and requires a target or\nslot. NOOP accepts no content/write attributes and requires a reason.\n",
  "x-generated": "2026-11-04",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/contextdb-ai-openapi.yaml#/components/schemas/EvolveRequest",
  "type": "object",
  "required": [
    "user_id",
    "operation"
  ],
  "properties": {
    "user_id": {
      "$ref": "#/$defs/UserId"
    },
    "operation": {
      "$ref": "#/$defs/EvolutionOperation"
    },
    "content": {
      "type": "string",
      "minLength": 1,
      "maxLength": 4000
    },
    "source": {
      "$ref": "#/$defs/EpistemicSource"
    },
    "confidence": {
      "type": "number",
      "minimum": 0,
      "maximum": 1
    },
    "action_relevant": {
      "type": "boolean"
    },
    "entity": {
      "type": "string",
      "minLength": 1,
      "maxLength": 200
    },
    "attribute": {
      "type": "string",
      "minLength": 1,
      "maxLength": 200
    },
    "target_memory_id": {
      "type": "string",
      "minLength": 1,
      "maxLength": 256
    },
    "metadata": {
      "type": "object",
      "maxProperties": 50,
      "propertyNames": {
        "pattern": "^[A-Za-z0-9._:\\-]{1,128}$"
      },
      "additionalProperties": true
    },
    "noop_reason": {
      "type": "string",
      "minLength": 1,
      "maxLength": 256
    }
  },
  "additionalProperties": false,
  "$defs": {
    "EpistemicSource": {
      "type": "string",
      "enum": [
        "user_stated",
        "agent_inferred",
        "third_party"
      ],
      "description": "Who vouches for the claim. Required on writes."
    },
    "EvolutionOperation": {
      "type": "string",
      "enum": [
        "add",
        "update",
        "delete",
        "noop"
      ]
    },
    "UserId": {
      "type": "string",
      "pattern": "^[A-Za-z0-9._:@+\\-]{1,128}$",
      "description": "End-user memory partition key. Not an identity assertion."
    }
  }
}