{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/raku-so/json-schema/raku-so-memory-write-response-schema.json",
  "title": "MemoryWriteResponse",
  "description": "POST /memories response — the created memory plus pipeline status + timing.\n\nSubclasses MemoryResponse so the memory fields stay at the top level (the\nexisting POST client contract is preserved) and adds the two pipeline fields.",
  "x-generated": "2026-11-22",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/raku-so-openapi.json#/components/schemas/MemoryWriteResponse",
  "properties": {
    "id": {
      "type": "string",
      "title": "Id"
    },
    "content": {
      "type": "string",
      "title": "Content"
    },
    "source": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "title": "Source"
    },
    "memory_type": {
      "type": "string",
      "title": "Memory Type"
    },
    "importance": {
      "type": "number",
      "title": "Importance"
    },
    "created_at": {
      "type": "string",
      "title": "Created At"
    },
    "updated_at": {
      "type": "string",
      "title": "Updated At"
    },
    "last_accessed": {
      "type": "string",
      "title": "Last Accessed"
    },
    "access_count": {
      "type": "integer",
      "title": "Access Count"
    },
    "tags": {
      "items": {
        "type": "string"
      },
      "type": "array",
      "title": "Tags",
      "default": []
    },
    "confidence_score": {
      "anyOf": [
        {
          "type": "number"
        },
        {
          "type": "null"
        }
      ],
      "title": "Confidence Score"
    },
    "source_type": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "title": "Source Type"
    },
    "evidence_count": {
      "type": "integer",
      "title": "Evidence Count",
      "default": 0
    },
    "contradiction_count": {
      "type": "integer",
      "title": "Contradiction Count",
      "default": 0
    },
    "confidence_decay_rate": {
      "anyOf": [
        {
          "type": "number"
        },
        {
          "type": "null"
        }
      ],
      "title": "Confidence Decay Rate"
    },
    "last_validated_at": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "title": "Last Validated At"
    },
    "valid_from": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "title": "Valid From"
    },
    "valid_to": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "title": "Valid To"
    },
    "tx_from": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "title": "Tx From"
    },
    "tx_to": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "title": "Tx To"
    },
    "superseded_by": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "title": "Superseded By"
    },
    "is_current": {
      "type": "boolean",
      "title": "Is Current",
      "default": true
    },
    "pipeline_status": {
      "$ref": "#/$defs/PipelineStatus"
    },
    "pipeline": {
      "$ref": "#/$defs/PipelineTiming"
    }
  },
  "type": "object",
  "required": [
    "id",
    "content",
    "memory_type",
    "importance",
    "created_at",
    "updated_at",
    "last_accessed",
    "access_count",
    "pipeline_status",
    "pipeline"
  ],
  "$defs": {
    "PipelineStatus": {
      "properties": {
        "embedding": {
          "$ref": "#/$defs/StepStatus"
        },
        "importance": {
          "$ref": "#/$defs/StepStatus"
        },
        "entities": {
          "$ref": "#/$defs/StepStatus"
        },
        "consolidation": {
          "$ref": "#/$defs/StepStatus"
        },
        "conflicts": {
          "$ref": "#/$defs/StepStatus"
        }
      },
      "type": "object",
      "required": [
        "embedding",
        "importance",
        "entities",
        "consolidation",
        "conflicts"
      ],
      "title": "PipelineStatus",
      "description": "Outcome of each write-pipeline step (RKU-65 §7.4)."
    },
    "PipelineTiming": {
      "properties": {
        "admission_ms": {
          "type": "integer",
          "title": "Admission Ms"
        },
        "embedding_ms": {
          "anyOf": [
            {
              "type": "integer"
            },
            {
              "type": "null"
            }
          ],
          "title": "Embedding Ms"
        },
        "importance_ms": {
          "anyOf": [
            {
              "type": "integer"
            },
            {
              "type": "null"
            }
          ],
          "title": "Importance Ms"
        },
        "entities_ms": {
          "anyOf": [
            {
              "type": "integer"
            },
            {
              "type": "null"
            }
          ],
          "title": "Entities Ms"
        },
        "consolidation_ms": {
          "anyOf": [
            {
              "type": "integer"
            },
            {
              "type": "null"
            }
          ],
          "title": "Consolidation Ms"
        },
        "conflicts_ms": {
          "anyOf": [
            {
              "type": "integer"
            },
            {
              "type": "null"
            }
          ],
          "title": "Conflicts Ms"
        },
        "store_ms": {
          "type": "integer",
          "title": "Store Ms"
        },
        "total_ms": {
          "type": "integer",
          "title": "Total Ms"
        }
      },
      "type": "object",
      "required": [
        "admission_ms",
        "embedding_ms",
        "importance_ms",
        "entities_ms",
        "consolidation_ms",
        "conflicts_ms",
        "store_ms",
        "total_ms"
      ],
      "title": "PipelineTiming",
      "description": "Per-step wall-clock timing in ms. `None` means the step did not run."
    },
    "StepStatus": {
      "type": "string",
      "enum": [
        "ok",
        "deferred",
        "skipped_rss",
        "skipped_due_to_degradation",
        "unavailable"
      ],
      "title": "StepStatus",
      "description": "Per-step outcome in the write pipeline (RKU-65 §7.4)."
    }
  }
}