{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/raku-so/json-schema/raku-so-memory-create-schema.json",
  "title": "MemoryCreate",
  "description": "Create a new memory. Embedding generated server-side.\n\nInvariants:\n    - content is required and must be 1-50,000 characters\n    - tags are normalised to lowercase and stripped of whitespace\n    - metadata JSON must not exceed 10,000 characters\n    - importance must be between 0.0 and 1.0",
  "x-generated": "2026-11-22",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/raku-so-openapi.json#/components/schemas/MemoryCreate",
  "properties": {
    "content": {
      "type": "string",
      "maxLength": 50000,
      "minLength": 1,
      "title": "Content",
      "description": "Memory content text"
    },
    "source": {
      "anyOf": [
        {
          "type": "string",
          "maxLength": 500
        },
        {
          "type": "null"
        }
      ],
      "title": "Source",
      "description": "Where this memory came from"
    },
    "memory_type": {
      "$ref": "#/$defs/MemoryType",
      "default": "fact"
    },
    "importance": {
      "type": "number",
      "maximum": 1.0,
      "minimum": 0.0,
      "title": "Importance",
      "description": "Importance score 0-1",
      "default": 0.5
    },
    "metadata": {
      "anyOf": [
        {
          "additionalProperties": true,
          "type": "object"
        },
        {
          "type": "null"
        }
      ],
      "title": "Metadata",
      "description": "Arbitrary JSON metadata"
    },
    "tags": {
      "items": {
        "type": "string"
      },
      "type": "array",
      "maxItems": 20,
      "title": "Tags",
      "description": "Max 20 tags"
    },
    "confidence_score": {
      "anyOf": [
        {
          "type": "number",
          "maximum": 1.0,
          "minimum": 0.0
        },
        {
          "type": "null"
        }
      ],
      "title": "Confidence Score"
    },
    "source_type": {
      "anyOf": [
        {
          "$ref": "#/$defs/SourceType"
        },
        {
          "type": "null"
        }
      ]
    },
    "evidence_count": {
      "type": "integer",
      "minimum": 0.0,
      "title": "Evidence Count",
      "default": 0
    },
    "contradiction_count": {
      "type": "integer",
      "minimum": 0.0,
      "title": "Contradiction Count",
      "default": 0
    },
    "confidence_decay_rate": {
      "anyOf": [
        {
          "type": "number",
          "maximum": 1.0,
          "minimum": 0.0
        },
        {
          "type": "null"
        }
      ],
      "title": "Confidence Decay Rate"
    },
    "last_validated_at": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "title": "Last Validated At",
      "description": "ISO-8601: last confidence review"
    },
    "valid_from": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "title": "Valid From",
      "description": "ISO-8601: when this fact became true"
    },
    "valid_to": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "title": "Valid To",
      "description": "ISO-8601: when this fact stopped being true"
    }
  },
  "type": "object",
  "required": [
    "content"
  ],
  "$defs": {
    "MemoryType": {
      "type": "string",
      "enum": [
        "fact",
        "event",
        "preference",
        "procedure",
        "insight"
      ],
      "title": "MemoryType",
      "description": "Types of memory that can be stored.\n\nv2.0 taxonomy (migration 005):\n    observation → event, reflection → insight, instruction → procedure.\n    fact and preference unchanged."
    },
    "SourceType": {
      "type": "string",
      "enum": [
        "direct_data",
        "user_stated",
        "system_observed",
        "inference",
        "hearsay",
        "speculation",
        "corrected",
        "external_api",
        "derived"
      ],
      "title": "SourceType",
      "description": "Confidence source classification (v3.3).\n\nClassifies how a memory was obtained, informing confidence scoring.\nOrdering roughly tracks epistemic strength: direct_data and user_stated\nare high-trust; speculation and hearsay are low-trust."
    }
  }
}