{
  "type": "object",
  "required": [
    "header",
    "requestId",
    "ownerId",
    "projectId",
    "query",
    "limit",
    "algorithm",
    "candidates",
    "startedAt",
    "latencyMs"
  ],
  "properties": {
    "header": {
      "type": "object",
      "required": [
        "namespace",
        "major",
        "minor"
      ],
      "properties": {
        "namespace": {
          "type": "string",
          "const": "ai.aletheion.asm"
        },
        "major": {
          "type": "number",
          "const": 1
        },
        "minor": {
          "type": "integer",
          "minimum": 0
        }
      },
      "additionalProperties": false
    },
    "requestId": {
      "type": "string",
      "minLength": 1,
      "maxLength": 200
    },
    "ownerId": {
      "type": "string",
      "minLength": 1,
      "maxLength": 200
    },
    "projectId": {
      "type": "string",
      "minLength": 1,
      "maxLength": 200
    },
    "sessionId": {
      "type": "string",
      "minLength": 1,
      "maxLength": 200
    },
    "query": {
      "type": "string",
      "minLength": 1
    },
    "limit": {
      "type": "integer",
      "minimum": 1,
      "maximum": 200
    },
    "algorithm": {
      "type": "string",
      "minLength": 1,
      "maxLength": 200
    },
    "candidates": {
      "type": "array",
      "items": {
        "type": "object",
        "required": [
          "memoryId",
          "score",
          "selected",
          "reasonCodes"
        ],
        "properties": {
          "memoryId": {
            "type": "string",
            "minLength": 1,
            "maxLength": 200
          },
          "score": {
            "type": "number",
            "minimum": 0,
            "maximum": 1
          },
          "selected": {
            "type": "boolean"
          },
          "reasonCodes": {
            "type": "array",
            "items": {
              "type": "string",
              "minLength": 1,
              "maxLength": 200
            },
            "uniqueItems": true
          }
        },
        "additionalProperties": false
      }
    },
    "startedAt": {
      "type": "string",
      "format": "date-time"
    },
    "latencyMs": {
      "type": "integer",
      "minimum": 0
    }
  },
  "additionalProperties": false,
  "$id": "asm-retrieval-v1"
}
