{
  "openapi": "3.1.0",
  "info": {
    "title": "Artificial Mind Engine (AME) Gateway API",
    "version": "1.2.0",
    "description": "Canonical OpenAPI 3.1 contract decoupling the stateful Cognitive OS Kernel (Closed IP)\nfrom hot-swappable stateless LLMs (OpenAI, Anthropic, Gemini, DeepSeek, OpenRouter, local vLLM/Ollama)\nand multi-domain application adapters (Game NPC, Companion Chat, Counseling/Coach, Personal Agent, Custom).\nThe shared contract sandbox uses a separate X-AME-Visitor-Token for Mind ownership. Send a random 32–128 character URL-safe value and retain it per browser. Without it the Mind list is empty; creating a Mind requires it. Other visitors cannot read or delete those Minds. The sealed gateway uses tenant authentication instead.\nJSON request bodies are limited to 1 MiB (1048576 bytes); string input limits are UTF-16 code units.\n"
  },
  "servers": [
    {
      "url": "https://artificialmind.me/ame-api",
      "description": "Production gateway API 1.2.0 (sealed kernel 4.5.1)"
    },
    {
      "url": "https://artificialmind.me/ame-demo",
      "description": "Hosted Keyless Contract Sandbox"
    },
    {
      "url": "http://127.0.0.1:8090",
      "description": "Local AME Sandbox or Self-Hosted Sealed Kernel Gateway"
    }
  ],
  "security": [
    {
      "ApiKeyAuth": []
    },
    {
      "BearerAuth": []
    }
  ],
  "paths": {
    "/": {
      "get": {
        "summary": "Sealed gateway versions and probe paths (sandbox serves an HTML console)",
        "security": [],
        "responses": {
          "200": {
            "description": "Service directory or sandbox console",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ServiceIndex"
                }
              },
              "text/html": {
                "schema": {
                  "type": "string"
                }
              }
            }
          }
        }
      }
    },
    "/v1/health": {
      "get": {
        "summary": "Gateway & sealed kernel health check",
        "security": [],
        "responses": {
          "200": {
            "description": "Service status and engine mode",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HealthResponse"
                }
              }
            }
          }
        }
      }
    },
    "/v1/livez": {
      "get": {
        "summary": "Lightweight liveness probe",
        "security": [],
        "responses": {
          "200": {
            "description": "Gateway process is alive",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Liveness"
                }
              }
            }
          }
        }
      }
    },
    "/v1/readyz": {
      "get": {
        "summary": "Readiness probe verifying storage and kernel readiness",
        "security": [],
        "responses": {
          "200": {
            "description": "Gateway is ready to accept traffic",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Readiness"
                }
              }
            }
          },
          "503": {
            "description": "Storage is not ready",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ReadinessFailure"
                }
              }
            }
          }
        }
      }
    },
    "/v1/usage": {
      "get": {
        "parameters": [
          {
            "$ref": "#/components/parameters/SandboxVisitorToken"
          }
        ],
        "summary": "Retrieve aggregated B2B tenant token, turn, and cache usage summary",
        "responses": {
          "200": {
            "description": "Cumulative tenant counters on the gateway; sandbox totals cover only currently owned Minds.",
            "headers": {
              "X-RateLimit-Limit": {
                "$ref": "#/components/headers/X-RateLimit-Limit"
              },
              "X-RateLimit-Remaining": {
                "$ref": "#/components/headers/X-RateLimit-Remaining"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "oneOf": [
                    {
                      "$ref": "#/components/schemas/SealedUsage"
                    },
                    {
                      "$ref": "#/components/schemas/SandboxUsage"
                    }
                  ]
                }
              }
            }
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          },
          "503": {
            "$ref": "#/components/responses/UnavailableError"
          },
          "401": {
            "$ref": "#/components/responses/UnauthorizedError"
          },
          "429": {
            "$ref": "#/components/responses/RateLimitedError"
          }
        }
      }
    },
    "/v1/minds": {
      "get": {
        "summary": "List persistent Mind instances (D4-redacted summaries)",
        "parameters": [
          {
            "$ref": "#/components/parameters/SandboxVisitorToken"
          },
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 200,
              "default": 50
            }
          },
          {
            "name": "offset",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "minimum": 0,
              "default": 0
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Paginated list of Mind summaries",
            "headers": {
              "X-RateLimit-Limit": {
                "$ref": "#/components/headers/X-RateLimit-Limit"
              },
              "X-RateLimit-Remaining": {
                "$ref": "#/components/headers/X-RateLimit-Remaining"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/MindListResponse"
                }
              }
            }
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          },
          "503": {
            "$ref": "#/components/responses/UnavailableError"
          },
          "401": {
            "$ref": "#/components/responses/UnauthorizedError"
          },
          "429": {
            "$ref": "#/components/responses/RateLimitedError"
          }
        }
      },
      "post": {
        "summary": "Create an isolated persistent Mind instance",
        "parameters": [
          {
            "$ref": "#/components/parameters/SandboxVisitorToken"
          },
          {
            "$ref": "#/components/parameters/IdempotencyKey"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CreateMindRequest"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Created Mind state summary",
            "headers": {
              "X-Idempotent-Replay": {
                "schema": {
                  "const": "true"
                },
                "description": "Present on a replayed response."
              },
              "X-RateLimit-Limit": {
                "$ref": "#/components/headers/X-RateLimit-Limit"
              },
              "X-RateLimit-Remaining": {
                "$ref": "#/components/headers/X-RateLimit-Remaining"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/MindSummary"
                }
              }
            }
          },
          "409": {
            "$ref": "#/components/responses/ConflictError"
          },
          "413": {
            "$ref": "#/components/responses/TooLargeError"
          },
          "400": {
            "$ref": "#/components/responses/BadRequestError"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          },
          "503": {
            "$ref": "#/components/responses/UnavailableError"
          },
          "401": {
            "$ref": "#/components/responses/UnauthorizedError"
          },
          "429": {
            "$ref": "#/components/responses/RateLimitedError"
          }
        }
      }
    },
    "/v1/minds/{mindId}": {
      "get": {
        "summary": "Retrieve Mind metadata & safe telemetry (D4 filtered)",
        "parameters": [
          {
            "$ref": "#/components/parameters/SandboxVisitorToken"
          },
          {
            "$ref": "#/components/parameters/MindId"
          }
        ],
        "responses": {
          "200": {
            "description": "Mind summary",
            "headers": {
              "X-RateLimit-Limit": {
                "$ref": "#/components/headers/X-RateLimit-Limit"
              },
              "X-RateLimit-Remaining": {
                "$ref": "#/components/headers/X-RateLimit-Remaining"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/MindSummary"
                }
              }
            }
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          },
          "503": {
            "$ref": "#/components/responses/UnavailableError"
          },
          "401": {
            "$ref": "#/components/responses/UnauthorizedError"
          },
          "404": {
            "$ref": "#/components/responses/NotFoundError"
          },
          "429": {
            "$ref": "#/components/responses/RateLimitedError"
          }
        }
      },
      "delete": {
        "summary": "Delete a Mind instance and purge its state",
        "parameters": [
          {
            "$ref": "#/components/parameters/SandboxVisitorToken"
          },
          {
            "$ref": "#/components/parameters/MindId"
          }
        ],
        "responses": {
          "200": {
            "description": "Mind deletion confirmation",
            "headers": {
              "X-RateLimit-Limit": {
                "$ref": "#/components/headers/X-RateLimit-Limit"
              },
              "X-RateLimit-Remaining": {
                "$ref": "#/components/headers/X-RateLimit-Remaining"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/DeleteMindResponse"
                }
              }
            }
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          },
          "503": {
            "$ref": "#/components/responses/UnavailableError"
          },
          "401": {
            "$ref": "#/components/responses/UnauthorizedError"
          },
          "404": {
            "$ref": "#/components/responses/NotFoundError"
          },
          "429": {
            "$ref": "#/components/responses/RateLimitedError"
          }
        }
      }
    },
    "/v1/minds/{mindId}/turn": {
      "post": {
        "summary": "Mode A (Proxy BYO-LLM) — prepare cognitive state, invoke chosen LLM, and settle the turn",
        "parameters": [
          {
            "$ref": "#/components/parameters/SandboxVisitorToken"
          },
          {
            "$ref": "#/components/parameters/MindId"
          },
          {
            "$ref": "#/components/parameters/IdempotencyKey"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ProxyTurnRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Grounded reply, domain-shaped structured output, KV cache stats & D4-filtered telemetry",
            "headers": {
              "X-Idempotent-Replay": {
                "schema": {
                  "const": "true"
                },
                "description": "Present on a replayed response."
              },
              "X-RateLimit-Limit": {
                "$ref": "#/components/headers/X-RateLimit-Limit"
              },
              "X-RateLimit-Remaining": {
                "$ref": "#/components/headers/X-RateLimit-Remaining"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TurnResult"
                }
              }
            }
          },
          "409": {
            "$ref": "#/components/responses/ConflictError"
          },
          "413": {
            "$ref": "#/components/responses/TooLargeError"
          },
          "502": {
            "$ref": "#/components/responses/UpstreamError"
          },
          "400": {
            "$ref": "#/components/responses/BadRequestError"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          },
          "503": {
            "$ref": "#/components/responses/UnavailableError"
          },
          "401": {
            "$ref": "#/components/responses/UnauthorizedError"
          },
          "404": {
            "$ref": "#/components/responses/NotFoundError"
          },
          "429": {
            "$ref": "#/components/responses/RateLimitedError"
          }
        }
      }
    },
    "/v1/minds/{mindId}/prepare": {
      "post": {
        "summary": "Mode B Step 1 (Zero-Key) — compute prefix-aligned prompts, providerCacheHints, FEP lock & safety directives without sending LLM keys",
        "parameters": [
          {
            "$ref": "#/components/parameters/SandboxVisitorToken"
          },
          {
            "$ref": "#/components/parameters/MindId"
          },
          {
            "$ref": "#/components/parameters/IdempotencyKey"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/PrepareTurnRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Ephemeral ticket and prefix-stable LLM invocation package",
            "headers": {
              "X-Idempotent-Replay": {
                "schema": {
                  "const": "true"
                },
                "description": "Present on a replayed response."
              },
              "X-RateLimit-Limit": {
                "$ref": "#/components/headers/X-RateLimit-Limit"
              },
              "X-RateLimit-Remaining": {
                "$ref": "#/components/headers/X-RateLimit-Remaining"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PrepareTurnResponse"
                }
              }
            }
          },
          "409": {
            "$ref": "#/components/responses/ConflictError"
          },
          "413": {
            "$ref": "#/components/responses/TooLargeError"
          },
          "400": {
            "$ref": "#/components/responses/BadRequestError"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          },
          "503": {
            "$ref": "#/components/responses/UnavailableError"
          },
          "401": {
            "$ref": "#/components/responses/UnauthorizedError"
          },
          "404": {
            "$ref": "#/components/responses/NotFoundError"
          },
          "429": {
            "$ref": "#/components/responses/RateLimitedError"
          }
        }
      }
    },
    "/v1/minds/{mindId}/settle": {
      "post": {
        "summary": "Mode B Step 2 (Zero-Key) — settle raw LLM reply and optional token usage into somatic markers, memory & structured domain output",
        "parameters": [
          {
            "$ref": "#/components/parameters/SandboxVisitorToken"
          },
          {
            "$ref": "#/components/parameters/MindId"
          },
          {
            "$ref": "#/components/parameters/IdempotencyKey"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/SettleTurnRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Settled turn result with domain payload and telemetry",
            "headers": {
              "X-Idempotent-Replay": {
                "schema": {
                  "const": "true"
                },
                "description": "Present on a replayed response."
              },
              "X-RateLimit-Limit": {
                "$ref": "#/components/headers/X-RateLimit-Limit"
              },
              "X-RateLimit-Remaining": {
                "$ref": "#/components/headers/X-RateLimit-Remaining"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TurnResult"
                }
              }
            }
          },
          "409": {
            "$ref": "#/components/responses/ConflictError"
          },
          "413": {
            "$ref": "#/components/responses/TooLargeError"
          },
          "400": {
            "$ref": "#/components/responses/BadRequestError"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          },
          "503": {
            "$ref": "#/components/responses/UnavailableError"
          },
          "401": {
            "$ref": "#/components/responses/UnauthorizedError"
          },
          "404": {
            "$ref": "#/components/responses/NotFoundError"
          },
          "429": {
            "$ref": "#/components/responses/RateLimitedError"
          }
        }
      }
    },
    "/v1/minds/{mindId}/idle-tick": {
      "post": {
        "summary": "D2 Offline circadian/homeostasis progression during absence gaps",
        "parameters": [
          {
            "$ref": "#/components/parameters/SandboxVisitorToken"
          },
          {
            "$ref": "#/components/parameters/MindId"
          },
          {
            "$ref": "#/components/parameters/IdempotencyKey"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/IdleTickRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Updated homeostasis & proactive state",
            "headers": {
              "X-Idempotent-Replay": {
                "schema": {
                  "const": "true"
                },
                "description": "Present on a replayed response."
              },
              "X-RateLimit-Limit": {
                "$ref": "#/components/headers/X-RateLimit-Limit"
              },
              "X-RateLimit-Remaining": {
                "$ref": "#/components/headers/X-RateLimit-Remaining"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/IdleTickResponse"
                }
              }
            }
          },
          "409": {
            "$ref": "#/components/responses/ConflictError"
          },
          "413": {
            "$ref": "#/components/responses/TooLargeError"
          },
          "400": {
            "$ref": "#/components/responses/BadRequestError"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          },
          "503": {
            "$ref": "#/components/responses/UnavailableError"
          },
          "401": {
            "$ref": "#/components/responses/UnauthorizedError"
          },
          "404": {
            "$ref": "#/components/responses/NotFoundError"
          },
          "429": {
            "$ref": "#/components/responses/RateLimitedError"
          }
        }
      }
    },
    "/v1/minds/{mindId}/memories": {
      "get": {
        "summary": "List stored memories for a Mind (supports tier, connector, category, and revocation filtering)",
        "parameters": [
          {
            "$ref": "#/components/parameters/SandboxVisitorToken"
          },
          {
            "$ref": "#/components/parameters/MindId"
          },
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 200,
              "default": 50
            }
          },
          {
            "name": "offset",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "minimum": 0,
              "default": 0
            }
          },
          {
            "name": "epistemicTier",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "maxLength": 64
            }
          },
          {
            "name": "connectorId",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "maxLength": 256
            }
          },
          {
            "name": "category",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "maxLength": 128
            }
          },
          {
            "name": "includeRevoked",
            "in": "query",
            "required": false,
            "schema": {
              "type": "boolean",
              "default": false
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Filtered list of Mind memory records",
            "headers": {
              "X-RateLimit-Limit": {
                "$ref": "#/components/headers/X-RateLimit-Limit"
              },
              "X-RateLimit-Remaining": {
                "$ref": "#/components/headers/X-RateLimit-Remaining"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/MemoryListResponse"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequestError"
          },
          "401": {
            "$ref": "#/components/responses/UnauthorizedError"
          },
          "404": {
            "$ref": "#/components/responses/NotFoundError"
          },
          "429": {
            "$ref": "#/components/responses/RateLimitedError"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          },
          "503": {
            "$ref": "#/components/responses/UnavailableError"
          }
        }
      },
      "post": {
        "summary": "Ingest an external connector or system memory without advancing conversation turn count",
        "parameters": [
          {
            "$ref": "#/components/parameters/SandboxVisitorToken"
          },
          {
            "$ref": "#/components/parameters/MindId"
          },
          {
            "$ref": "#/components/parameters/IdempotencyKey"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/IngestMemoryRequest"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Ingested memory record (turnIndex 0)",
            "headers": {
              "X-Idempotent-Replay": {
                "schema": {
                  "const": "true"
                },
                "description": "Present on a replayed response."
              },
              "X-RateLimit-Limit": {
                "$ref": "#/components/headers/X-RateLimit-Limit"
              },
              "X-RateLimit-Remaining": {
                "$ref": "#/components/headers/X-RateLimit-Remaining"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/IngestMemoryResponse"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequestError"
          },
          "401": {
            "$ref": "#/components/responses/UnauthorizedError"
          },
          "404": {
            "$ref": "#/components/responses/NotFoundError"
          },
          "409": {
            "$ref": "#/components/responses/ConflictError"
          },
          "413": {
            "$ref": "#/components/responses/TooLargeError"
          },
          "429": {
            "$ref": "#/components/responses/RateLimitedError"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          },
          "503": {
            "$ref": "#/components/responses/UnavailableError"
          }
        }
      }
    },
    "/v1/minds/{mindId}/memories/search": {
      "post": {
        "summary": "Search Mind memories lexically with optional tier, connector, and category filters",
        "parameters": [
          {
            "$ref": "#/components/parameters/SandboxVisitorToken"
          },
          {
            "$ref": "#/components/parameters/MindId"
          },
          {
            "$ref": "#/components/parameters/IdempotencyKey"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/MemorySearchRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Ranked lexical search results (revoked memories excluded by default)",
            "headers": {
              "X-Idempotent-Replay": {
                "schema": {
                  "const": "true"
                },
                "description": "Present on a replayed response."
              },
              "X-RateLimit-Limit": {
                "$ref": "#/components/headers/X-RateLimit-Limit"
              },
              "X-RateLimit-Remaining": {
                "$ref": "#/components/headers/X-RateLimit-Remaining"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/MemorySearchResponse"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequestError"
          },
          "401": {
            "$ref": "#/components/responses/UnauthorizedError"
          },
          "404": {
            "$ref": "#/components/responses/NotFoundError"
          },
          "409": {
            "$ref": "#/components/responses/ConflictError"
          },
          "413": {
            "$ref": "#/components/responses/TooLargeError"
          },
          "429": {
            "$ref": "#/components/responses/RateLimitedError"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          },
          "503": {
            "$ref": "#/components/responses/UnavailableError"
          }
        }
      }
    },
    "/v1/minds/{mindId}/connectors/{connectorId}/revoke": {
      "post": {
        "summary": "Cascade D3 memory erasure when an OAuth/MCP connector is revoked",
        "parameters": [
          {
            "$ref": "#/components/parameters/SandboxVisitorToken"
          },
          {
            "$ref": "#/components/parameters/MindId"
          },
          {
            "$ref": "#/components/parameters/ConnectorId"
          },
          {
            "$ref": "#/components/parameters/IdempotencyKey"
          }
        ],
        "requestBody": {
          "required": false,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ConnectorRevokeRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Scoped connector revocation receipt (D3)",
            "headers": {
              "X-Idempotent-Replay": {
                "schema": {
                  "const": "true"
                },
                "description": "Present on a replayed response."
              },
              "X-RateLimit-Limit": {
                "$ref": "#/components/headers/X-RateLimit-Limit"
              },
              "X-RateLimit-Remaining": {
                "$ref": "#/components/headers/X-RateLimit-Remaining"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ConnectorRevocationReceipt"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequestError"
          },
          "401": {
            "$ref": "#/components/responses/UnauthorizedError"
          },
          "404": {
            "$ref": "#/components/responses/NotFoundError"
          },
          "409": {
            "$ref": "#/components/responses/ConflictError"
          },
          "413": {
            "$ref": "#/components/responses/TooLargeError"
          },
          "429": {
            "$ref": "#/components/responses/RateLimitedError"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          },
          "503": {
            "$ref": "#/components/responses/UnavailableError"
          }
        }
      }
    },
    "/v1/minds/{mindId}/egress-check": {
      "post": {
        "summary": "Verify outbound payload against D4 leakage markers, raw credentials, and revocation epoch",
        "parameters": [
          {
            "$ref": "#/components/parameters/SandboxVisitorToken"
          },
          {
            "$ref": "#/components/parameters/MindId"
          },
          {
            "$ref": "#/components/parameters/IdempotencyKey"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/EgressCheckRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Outbound egress firewall inspection result",
            "headers": {
              "X-Idempotent-Replay": {
                "schema": {
                  "const": "true"
                },
                "description": "Present on a replayed response."
              },
              "X-RateLimit-Limit": {
                "$ref": "#/components/headers/X-RateLimit-Limit"
              },
              "X-RateLimit-Remaining": {
                "$ref": "#/components/headers/X-RateLimit-Remaining"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/EgressCheckResult"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequestError"
          },
          "401": {
            "$ref": "#/components/responses/UnauthorizedError"
          },
          "404": {
            "$ref": "#/components/responses/NotFoundError"
          },
          "409": {
            "$ref": "#/components/responses/ConflictError"
          },
          "413": {
            "$ref": "#/components/responses/TooLargeError"
          },
          "429": {
            "$ref": "#/components/responses/RateLimitedError"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          },
          "503": {
            "$ref": "#/components/responses/UnavailableError"
          }
        }
      }
    },
    "/v1/minds/{mindId}/memories/{memoryId}": {
      "delete": {
        "summary": "Revoke a stored memory and return a scoped deletion receipt",
        "parameters": [
          {
            "$ref": "#/components/parameters/SandboxVisitorToken"
          },
          {
            "$ref": "#/components/parameters/MindId"
          },
          {
            "name": "memoryId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Scoped deletion receipt with the number of remaining references",
            "headers": {
              "X-RateLimit-Limit": {
                "$ref": "#/components/headers/X-RateLimit-Limit"
              },
              "X-RateLimit-Remaining": {
                "$ref": "#/components/headers/X-RateLimit-Remaining"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/RevocationReceipt"
                }
              }
            }
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          },
          "503": {
            "$ref": "#/components/responses/UnavailableError"
          },
          "401": {
            "$ref": "#/components/responses/UnauthorizedError"
          },
          "404": {
            "$ref": "#/components/responses/NotFoundError"
          },
          "429": {
            "$ref": "#/components/responses/RateLimitedError"
          }
        }
      }
    },
    "/v1/minds/{mindId}/telemetry": {
      "get": {
        "summary": "D4-filtered public telemetry (unconscious internal vectors strictly redacted)",
        "parameters": [
          {
            "$ref": "#/components/parameters/SandboxVisitorToken"
          },
          {
            "$ref": "#/components/parameters/MindId"
          }
        ],
        "responses": {
          "200": {
            "description": "Safe public telemetry snapshot",
            "headers": {
              "X-RateLimit-Limit": {
                "$ref": "#/components/headers/X-RateLimit-Limit"
              },
              "X-RateLimit-Remaining": {
                "$ref": "#/components/headers/X-RateLimit-Remaining"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SafeTelemetry"
                }
              }
            }
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          },
          "503": {
            "$ref": "#/components/responses/UnavailableError"
          },
          "401": {
            "$ref": "#/components/responses/UnauthorizedError"
          },
          "404": {
            "$ref": "#/components/responses/NotFoundError"
          },
          "429": {
            "$ref": "#/components/responses/RateLimitedError"
          }
        }
      }
    },
    "/v1/minds/{mindId}/simulate-batch": {
      "post": {
        "summary": "Deterministic simulation independent of Mind state (0 LLM calls; OFF arms use fixed reference rules)",
        "parameters": [
          {
            "$ref": "#/components/parameters/SandboxVisitorToken"
          },
          {
            "$ref": "#/components/parameters/MindId"
          },
          {
            "$ref": "#/components/parameters/IdempotencyKey"
          }
        ],
        "requestBody": {
          "required": false,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/SimulateBatchRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Deterministic convergence trajectory and cross-arm comparison report (D4-filtered)",
            "headers": {
              "X-Idempotent-Replay": {
                "schema": {
                  "const": "true"
                },
                "description": "Present on a replayed response."
              },
              "X-RateLimit-Limit": {
                "$ref": "#/components/headers/X-RateLimit-Limit"
              },
              "X-RateLimit-Remaining": {
                "$ref": "#/components/headers/X-RateLimit-Remaining"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SimulateBatchResponse"
                }
              }
            }
          },
          "409": {
            "$ref": "#/components/responses/ConflictError"
          },
          "413": {
            "$ref": "#/components/responses/TooLargeError"
          },
          "400": {
            "$ref": "#/components/responses/BadRequestError"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          },
          "503": {
            "$ref": "#/components/responses/UnavailableError"
          },
          "401": {
            "$ref": "#/components/responses/UnauthorizedError"
          },
          "404": {
            "$ref": "#/components/responses/NotFoundError"
          },
          "429": {
            "$ref": "#/components/responses/RateLimitedError"
          }
        }
      }
    }
  },
  "components": {
    "securitySchemes": {
      "ApiKeyAuth": {
        "type": "apiKey",
        "in": "header",
        "name": "X-AME-API-Key"
      },
      "BearerAuth": {
        "type": "http",
        "scheme": "bearer",
        "description": "Bearer token accepted in the Authorization header."
      }
    },
    "parameters": {
      "MindId": {
        "name": "mindId",
        "in": "path",
        "required": true,
        "schema": {
          "type": "string"
        }
      },
      "ConnectorId": {
        "name": "connectorId",
        "in": "path",
        "required": true,
        "schema": {
          "type": "string",
          "minLength": 1,
          "maxLength": 256
        }
      },
      "SandboxVisitorToken": {
        "name": "X-AME-Visitor-Token",
        "in": "header",
        "required": false,
        "description": "Sandbox visitor credential; required to create or access owned Minds. Ignore on the sealed gateway.",
        "schema": {
          "type": "string",
          "pattern": "^[A-Za-z0-9_-]{32,128}$"
        }
      },
      "IdempotencyKey": {
        "name": "Idempotency-Key",
        "in": "header",
        "required": false,
        "description": "Reuse only for the same logical request and body. Reuse with a different body returns 409. Replay is not permanent.",
        "schema": {
          "type": "string",
          "maxLength": 255
        }
      }
    },
    "headers": {
      "X-RateLimit-Limit": {
        "description": "Maximum requests allowed in the current rate-limit window",
        "schema": {
          "type": "integer"
        }
      },
      "X-RateLimit-Remaining": {
        "description": "Remaining requests in the current rate-limit window",
        "schema": {
          "type": "integer"
        }
      },
      "Retry-After": {
        "description": "Seconds to wait before retrying after HTTP 429",
        "schema": {
          "type": "integer"
        }
      }
    },
    "responses": {
      "ConflictError": {
        "description": "IDEMPOTENCY_KEY_REUSE or IDEMPOTENCY_INVALIDATED. TICKET_REVISION_STALE on settlement requires fresh preparation.",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/ErrorResponse"
            }
          }
        }
      },
      "TooLargeError": {
        "description": "BAD_REQUEST (body exceeds 1048576 bytes)",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/ErrorResponse"
            }
          }
        }
      },
      "UpstreamError": {
        "description": "UPSTREAM_LLM_ERROR or UPSTREAM_LLM_EMPTY",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/ErrorResponse"
            }
          }
        }
      },
      "UnavailableError": {
        "description": "Gateway authentication is not configured or session capacity is busy.",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/ErrorResponse"
            }
          }
        }
      },
      "InternalError": {
        "description": "Gateway failed; a failed deletion is not a receipt.",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/ErrorResponse"
            }
          }
        }
      },
      "BadRequestError": {
        "description": "Validation or malformed request payload error",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/ErrorResponse"
            }
          }
        }
      },
      "UnauthorizedError": {
        "description": "Missing or invalid API key or bearer token",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/ErrorResponse"
            }
          }
        }
      },
      "NotFoundError": {
        "description": "Mind, memory, or turn ticket not found",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/ErrorResponse"
            }
          }
        }
      },
      "RateLimitedError": {
        "description": "RATE_LIMITED (minute window or batch concurrency), MIND_QUOTA_EXCEEDED, MIND_QUOTA_UNAVAILABLE or PENDING_TICKET_QUOTA_EXCEEDED. Only minute-window throttling supplies Retry-After.",
        "headers": {
          "Retry-After": {
            "$ref": "#/components/headers/Retry-After"
          },
          "X-RateLimit-Limit": {
            "$ref": "#/components/headers/X-RateLimit-Limit"
          },
          "X-RateLimit-Remaining": {
            "$ref": "#/components/headers/X-RateLimit-Remaining"
          }
        },
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/ErrorResponse"
            }
          }
        }
      }
    },
    "schemas": {
      "ServiceIndex": {
        "type": "object",
        "required": [
          "service",
          "version",
          "apiVersion",
          "health",
          "livez",
          "readyz"
        ],
        "properties": {
          "service": {
            "type": "string"
          },
          "version": {
            "type": "string"
          },
          "apiVersion": {
            "type": "string"
          },
          "health": {
            "type": "string"
          },
          "livez": {
            "type": "string"
          },
          "readyz": {
            "type": "string"
          }
        }
      },
      "EventTime": {
        "type": "string",
        "format": "date-time",
        "description": "RFC 3339 with explicit offset or Z; Unix epoch through 366 days after now.",
        "examples": [
          "2026-01-01T12:00:00+09:00"
        ]
      },
      "SamplingHints": {
        "type": "object",
        "properties": {
          "temperature": {
            "type": "number",
            "minimum": 0,
            "maximum": 2
          },
          "maxTokens": {
            "type": "integer",
            "minimum": 16,
            "maximum": 16384
          },
          "topP": {
            "type": "number",
            "minimum": 0,
            "maximum": 1
          },
          "minP": {
            "type": "number",
            "minimum": 0,
            "maximum": 1
          },
          "presencePenalty": {
            "type": "number",
            "minimum": -2,
            "maximum": 2
          },
          "frequencyPenalty": {
            "type": "number",
            "minimum": -2,
            "maximum": 2
          }
        }
      },
      "ErrorResponse": {
        "type": "object",
        "required": [
          "error",
          "code",
          "message"
        ],
        "properties": {
          "error": {
            "type": "string",
            "pattern": "^[a-z0-9_]+$"
          },
          "code": {
            "type": "string",
            "pattern": "^[A-Z0-9_]+$"
          },
          "message": {
            "type": "string"
          },
          "retryAfterSeconds": {
            "type": "integer",
            "minimum": 0,
            "description": "Same seconds as retryAfterSec for per-minute throttling."
          },
          "retryAfterSec": {
            "type": "integer",
            "minimum": 0
          }
        }
      },
      "DomainId": {
        "type": "string",
        "enum": [
          "game_npc",
          "companion_chat",
          "counseling_coach",
          "personal_agent",
          "custom"
        ]
      },
      "HealthResponse": {
        "type": "object",
        "required": [
          "ok",
          "service",
          "version",
          "mode",
          "domains"
        ],
        "properties": {
          "ok": {
            "type": "boolean"
          },
          "service": {
            "type": "string"
          },
          "version": {
            "type": "string"
          },
          "mode": {
            "type": "string",
            "enum": [
              "sealed-kernel",
              "sandbox-contract"
            ]
          },
          "apiVersion": {
            "type": "string"
          },
          "multiTenant": {
            "type": "boolean"
          },
          "storage": {
            "type": "string"
          },
          "storageMode": {
            "type": "string"
          },
          "domains": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/DomainId"
            }
          },
          "notice": {
            "type": "string"
          }
        }
      },
      "Liveness": {
        "allOf": [
          {
            "$ref": "#/components/schemas/HealthProbeResponse"
          },
          {
            "required": [
              "uptimeSec"
            ],
            "properties": {
              "ok": {
                "const": true
              },
              "status": {
                "const": "alive"
              }
            }
          }
        ]
      },
      "Readiness": {
        "allOf": [
          {
            "$ref": "#/components/schemas/HealthProbeResponse"
          },
          {
            "properties": {
              "ok": {
                "const": true
              },
              "status": {
                "const": "ready"
              }
            },
            "required": [
              "storage"
            ],
            "anyOf": [
              {
                "required": [
                  "persistFailures",
                  "readFailures"
                ]
              },
              {
                "properties": {
                  "service": {
                    "const": "ame-sandbox-server"
                  }
                },
                "required": [
                  "storageMode"
                ]
              }
            ]
          }
        ]
      },
      "HealthProbeResponse": {
        "type": "object",
        "required": [
          "ok",
          "status",
          "service",
          "version"
        ],
        "properties": {
          "ok": {
            "type": "boolean"
          },
          "status": {
            "type": "string",
            "enum": [
              "alive",
              "ready",
              "not_ready"
            ]
          },
          "service": {
            "type": "string"
          },
          "version": {
            "type": "string"
          },
          "storageMode": {
            "type": "string"
          },
          "uptimeSec": {
            "type": "integer",
            "minimum": 0
          },
          "storage": {
            "type": "string"
          },
          "persistFailures": {
            "type": "integer",
            "minimum": 0
          },
          "readFailures": {
            "type": "integer",
            "minimum": 0
          },
          "error": {
            "type": "string"
          },
          "code": {
            "type": "string"
          },
          "message": {
            "type": "string"
          }
        }
      },
      "ReadinessFailure": {
        "allOf": [
          {
            "$ref": "#/components/schemas/HealthProbeResponse"
          },
          {
            "type": "object",
            "required": [
              "storage",
              "persistFailures",
              "readFailures",
              "error",
              "code",
              "message"
            ],
            "properties": {
              "ok": {
                "const": false
              },
              "status": {
                "const": "not_ready"
              }
            }
          }
        ]
      },
      "SealedUsage": {
        "allOf": [
          {
            "$ref": "#/components/schemas/UsageSummary"
          },
          {
            "required": [
              "tenantId",
              "totalCalls",
              "prepareCount",
              "settleCount",
              "proxyTurnCount",
              "idleTickCount",
              "revokeCount",
              "promptTokens",
              "completionTokens",
              "cachedTokens",
              "estimatedCacheHitPct"
            ]
          }
        ]
      },
      "SandboxUsage": {
        "allOf": [
          {
            "$ref": "#/components/schemas/UsageSummary"
          },
          {
            "required": [
              "rateLimit"
            ],
            "not": {
              "required": [
                "tenantId"
              ]
            }
          }
        ]
      },
      "UsageSummary": {
        "type": "object",
        "required": [
          "totalMinds",
          "totalTurns",
          "totalPromptTokens",
          "totalCompletionTokens",
          "totalCachedTokens"
        ],
        "properties": {
          "tenantId": {
            "type": "string"
          },
          "totalCalls": {
            "type": "integer",
            "minimum": 0
          },
          "prepareCount": {
            "type": "integer",
            "minimum": 0
          },
          "settleCount": {
            "type": "integer",
            "minimum": 0
          },
          "proxyTurnCount": {
            "type": "integer",
            "minimum": 0
          },
          "idleTickCount": {
            "type": "integer",
            "minimum": 0
          },
          "revokeCount": {
            "type": "integer",
            "minimum": 0
          },
          "promptTokens": {
            "type": "integer",
            "minimum": 0
          },
          "completionTokens": {
            "type": "integer",
            "minimum": 0
          },
          "cachedTokens": {
            "type": "integer",
            "minimum": 0
          },
          "estimatedCacheHitPct": {
            "type": "number"
          },
          "totalMinds": {
            "type": "integer"
          },
          "totalTurns": {
            "type": "integer"
          },
          "totalPromptTokens": {
            "type": "integer"
          },
          "totalCompletionTokens": {
            "type": "integer"
          },
          "totalCachedTokens": {
            "type": "integer"
          },
          "estimatedCacheSavingsPct": {
            "type": "number",
            "description": "Sandbox compatibility alias for the cached-token fraction as a percentage; not cost savings."
          },
          "rateLimit": {
            "type": "object",
            "properties": {
              "limit": {
                "type": "integer"
              },
              "remaining": {
                "type": "integer"
              },
              "windowSeconds": {
                "type": "integer"
              }
            }
          }
        }
      },
      "MindListResponse": {
        "type": "object",
        "required": [
          "minds"
        ],
        "properties": {
          "minds": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ListedMindSummary"
            }
          },
          "total": {
            "type": "integer"
          },
          "limit": {
            "type": "integer"
          },
          "offset": {
            "type": "integer"
          }
        }
      },
      "DeleteMindResponse": {
        "type": "object",
        "required": [
          "deleted",
          "mindId",
          "revocationEpoch",
          "auditReceiptId",
          "residualCount",
          "verificationScope",
          "residualLeakCheck"
        ],
        "properties": {
          "deleted": {
            "type": "boolean"
          },
          "mindId": {
            "type": "string"
          },
          "revocationEpoch": {
            "type": "integer",
            "minimum": 0
          },
          "auditReceiptId": {
            "type": "string"
          },
          "residualCount": {
            "type": "integer",
            "minimum": 0
          },
          "verificationScope": {
            "type": "string",
            "enum": [
              "process-memory",
              "process-memory+postgres"
            ]
          },
          "residualLeakCheck": {
            "type": "string",
            "enum": [
              "0.00%",
              "100.00%"
            ],
            "description": "Legacy pass/fail marker within verificationScope; not a measured percentage."
          }
        }
      },
      "LlmProviderConfig": {
        "type": "object",
        "required": [
          "provider",
          "model"
        ],
        "properties": {
          "provider": {
            "type": "string",
            "enum": [
              "mock",
              "openai",
              "anthropic",
              "gemini",
              "deepseek",
              "openrouter",
              "openai-compat"
            ]
          },
          "model": {
            "type": "string",
            "minLength": 1,
            "maxLength": 256
          },
          "apiKey": {
            "type": "string",
            "maxLength": 8192
          },
          "baseUrl": {
            "type": "string",
            "format": "uri",
            "maxLength": 2048
          },
          "providerOrder": {
            "type": "array",
            "maxItems": 16,
            "items": {
              "type": "string",
              "maxLength": 256
            }
          },
          "allowFallbacks": {
            "type": "boolean"
          },
          "samplingHints": {
            "$ref": "#/components/schemas/SamplingHints"
          },
          "temperature": {
            "type": "number",
            "minimum": 0,
            "maximum": 2
          },
          "maxTokens": {
            "type": "integer",
            "minimum": 16,
            "maximum": 16384
          },
          "promptCacheKey": {
            "type": "string",
            "maxLength": 256
          }
        }
      },
      "CreateMindRequest": {
        "type": "object",
        "required": [
          "domain",
          "persona"
        ],
        "properties": {
          "domain": {
            "$ref": "#/components/schemas/DomainId"
          },
          "persona": {
            "type": "object",
            "required": [
              "name",
              "role"
            ],
            "properties": {
              "name": {
                "type": "string",
                "minLength": 1,
                "maxLength": 256
              },
              "role": {
                "type": "string",
                "minLength": 1,
                "maxLength": 256
              },
              "traits": {
                "type": "object",
                "maxProperties": 32,
                "propertyNames": {
                  "type": "string",
                  "maxLength": 256
                },
                "additionalProperties": {
                  "type": "number"
                }
              },
              "backstory": {
                "type": "string",
                "maxLength": 32000
              },
              "language": {
                "type": "string",
                "maxLength": 256,
                "default": "ko"
              },
              "timezoneOffsetMinutes": {
                "type": "integer",
                "minimum": -720,
                "maximum": 840
              },
              "voiceExamples": {
                "type": "array",
                "maxItems": 32,
                "items": {
                  "type": "string",
                  "maxLength": 2000
                }
              }
            }
          },
          "customSchema": {
            "type": "object",
            "description": "Optional JSON schema metadata when domain is \"custom\"",
            "properties": {
              "name": {
                "type": "string",
                "maxLength": 256
              },
              "fields": {
                "type": "array",
                "maxItems": 32,
                "items": {
                  "type": "string",
                  "maxLength": 256
                }
              }
            }
          },
          "safetyPolicy": {
            "type": "object",
            "properties": {
              "strictAbstention": {
                "type": "boolean",
                "default": true
              },
              "antiSycophancy": {
                "type": "boolean",
                "default": true
              },
              "crisisEscalation": {
                "type": "boolean",
                "default": false
              }
            }
          }
        }
      },
      "MindSummary": {
        "allOf": [
          {
            "$ref": "#/components/schemas/ListedMindSummary"
          },
          {
            "type": "object",
            "required": [
              "telemetry"
            ]
          }
        ]
      },
      "ListedMindSummary": {
        "type": "object",
        "required": [
          "mindId",
          "domain",
          "personaName",
          "turnCount",
          "revocationEpoch"
        ],
        "properties": {
          "mindId": {
            "type": "string"
          },
          "tenantId": {
            "type": "string"
          },
          "domain": {
            "$ref": "#/components/schemas/DomainId"
          },
          "personaName": {
            "type": "string"
          },
          "turnCount": {
            "type": "integer"
          },
          "revocationEpoch": {
            "type": "integer"
          },
          "telemetry": {
            "$ref": "#/components/schemas/SafeTelemetry"
          }
        }
      },
      "TokenUsageInput": {
        "type": "object",
        "properties": {
          "promptTokens": {
            "type": "integer",
            "minimum": 0
          },
          "completionTokens": {
            "type": "integer",
            "minimum": 0
          },
          "cachedTokens": {
            "type": "integer",
            "minimum": 0
          },
          "latencyMs": {
            "type": "number",
            "minimum": 0
          }
        }
      },
      "ProviderCacheHints": {
        "type": "object",
        "required": [
          "promptCacheKey",
          "staticPrefixHash",
          "openai",
          "anthropic",
          "gemini",
          "deepseek",
          "openrouter",
          "vllm"
        ],
        "description": "Provider-specific hints. cachedContentHint is not a provider-issued cache resource.",
        "properties": {
          "promptCacheKey": {
            "type": "string"
          },
          "staticPrefixHash": {
            "type": "string"
          },
          "openai": {
            "type": "object",
            "properties": {
              "prompt_cache_key": {
                "type": "string"
              },
              "prompt_cache_retention": {
                "const": "24h"
              }
            }
          },
          "anthropic": {
            "type": "object",
            "properties": {
              "cache_control": {
                "$ref": "#/components/schemas/CacheControl"
              },
              "systemCacheControl": {
                "$ref": "#/components/schemas/CacheControl"
              },
              "historyBreakpointIndex": {
                "type": [
                  "integer",
                  "null"
                ]
              }
            }
          },
          "gemini": {
            "type": "object",
            "properties": {
              "cachedContentHint": {
                "type": "string"
              },
              "systemInstructionHash": {
                "type": "string"
              }
            }
          },
          "deepseek": {
            "type": "object",
            "properties": {
              "prefixCacheKey": {
                "type": "string"
              }
            }
          },
          "openrouter": {
            "type": "object",
            "properties": {
              "prompt_cache_key": {
                "type": "string"
              },
              "stickyProviderRecommended": {
                "const": true
              }
            }
          },
          "vllm": {
            "type": "object",
            "properties": {
              "prefixCacheKey": {
                "type": "string"
              }
            }
          }
        }
      },
      "CacheControl": {
        "type": "object",
        "required": [
          "type",
          "ttl"
        ],
        "properties": {
          "type": {
            "const": "ephemeral"
          },
          "ttl": {
            "const": "1h"
          }
        }
      },
      "ProxyTurnRequest": {
        "type": "object",
        "required": [
          "userInput",
          "llm"
        ],
        "properties": {
          "userInput": {
            "type": "string",
            "minLength": 1,
            "maxLength": 32000
          },
          "eventTimestampIso": {
            "$ref": "#/components/schemas/EventTime"
          },
          "occurredAt": {
            "$ref": "#/components/schemas/EventTime"
          },
          "speaker": {
            "type": "string",
            "maxLength": 256
          },
          "voiceExamples": {
            "type": "array",
            "maxItems": 32,
            "items": {
              "type": "string",
              "maxLength": 2000
            }
          },
          "surfacingMode": {
            "type": "string",
            "enum": [
              "IMPLICIT_COLOR",
              "CASUAL_ALLUSION",
              "DIRECT_RECALL"
            ]
          },
          "llm": {
            "$ref": "#/components/schemas/LlmProviderConfig"
          },
          "rewardSignal": {
            "type": "number",
            "minimum": -1000,
            "maximum": 1000
          },
          "outcomeTags": {
            "type": "array",
            "maxItems": 32,
            "items": {
              "type": "string",
              "maxLength": 256
            }
          },
          "directEval": {
            "type": "boolean",
            "description": "Optional evaluation mode for single-turn benchmarks."
          },
          "promptCacheKey": {
            "type": "string",
            "maxLength": 256
          },
          "actionCandidate": {
            "$ref": "#/components/schemas/ActionCandidate"
          },
          "connectorContext": {
            "$ref": "#/components/schemas/ConnectorContext"
          },
          "metadata": {
            "type": "object",
            "additionalProperties": true
          }
        }
      },
      "PrepareTurnRequest": {
        "type": "object",
        "required": [
          "userInput"
        ],
        "properties": {
          "userInput": {
            "type": "string",
            "minLength": 1,
            "maxLength": 32000
          },
          "eventTimestampIso": {
            "$ref": "#/components/schemas/EventTime"
          },
          "occurredAt": {
            "$ref": "#/components/schemas/EventTime"
          },
          "speaker": {
            "type": "string",
            "maxLength": 256
          },
          "voiceExamples": {
            "type": "array",
            "maxItems": 32,
            "items": {
              "type": "string",
              "maxLength": 2000
            }
          },
          "surfacingMode": {
            "type": "string",
            "enum": [
              "IMPLICIT_COLOR",
              "CASUAL_ALLUSION",
              "DIRECT_RECALL"
            ]
          },
          "rewardSignal": {
            "type": "number",
            "minimum": -1000,
            "maximum": 1000
          },
          "outcomeTags": {
            "type": "array",
            "maxItems": 32,
            "items": {
              "type": "string",
              "maxLength": 256
            }
          },
          "directEval": {
            "type": "boolean",
            "description": "Optional evaluation mode for single-turn benchmarks."
          },
          "promptCacheKey": {
            "type": "string",
            "maxLength": 256
          },
          "actionCandidate": {
            "$ref": "#/components/schemas/ActionCandidate"
          },
          "connectorContext": {
            "$ref": "#/components/schemas/ConnectorContext"
          },
          "metadata": {
            "type": "object",
            "additionalProperties": true
          }
        }
      },
      "ChatMessage": {
        "type": "object",
        "required": [
          "role",
          "content"
        ],
        "properties": {
          "role": {
            "type": "string",
            "enum": [
              "system",
              "user",
              "assistant"
            ]
          },
          "content": {
            "type": "string"
          }
        }
      },
      "PrepareTurnResponse": {
        "type": "object",
        "required": [
          "turnTicketId",
          "mindId",
          "domain",
          "systemPrompt",
          "messages",
          "kvCacheEpoch",
          "windowStart",
          "compressCutoff",
          "fepThoughtLock",
          "hotAbstention",
          "somaticHint",
          "samplingHints",
          "safetyDirectives",
          "domainOutputContract"
        ],
        "properties": {
          "turnTicketId": {
            "type": "string"
          },
          "mindId": {
            "type": "string"
          },
          "domain": {
            "$ref": "#/components/schemas/DomainId"
          },
          "eventTimestampIso": {
            "$ref": "#/components/schemas/EventTime"
          },
          "occurredAt": {
            "$ref": "#/components/schemas/EventTime"
          },
          "speaker": {
            "type": "string",
            "maxLength": 256
          },
          "voiceExamples": {
            "type": "array",
            "maxItems": 32,
            "items": {
              "type": "string",
              "maxLength": 2000
            }
          },
          "surfacingMode": {
            "type": "string",
            "enum": [
              "IMPLICIT_COLOR",
              "CASUAL_ALLUSION",
              "DIRECT_RECALL"
            ]
          },
          "revocationEpoch": {
            "type": "integer",
            "minimum": 0
          },
          "activeMemoryContext": {
            "type": "string"
          },
          "routingHint": {
            "type": "object",
            "properties": {
              "tier": {
                "type": "string"
              }
            }
          },
          "memoryRefs": {
            "type": "array",
            "items": {
              "type": "object"
            }
          },
          "systemPrompt": {
            "type": "string"
          },
          "messages": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ChatMessage"
            }
          },
          "kvCacheEpoch": {
            "type": "integer"
          },
          "windowStart": {
            "type": "integer"
          },
          "compressCutoff": {
            "type": "integer"
          },
          "promptCacheKey": {
            "type": "string"
          },
          "providerCacheHints": {
            "$ref": "#/components/schemas/ProviderCacheHints"
          },
          "fepThoughtLock": {
            "type": "object",
            "required": [
              "mode",
              "freeEnergy",
              "tau",
              "locked"
            ],
            "properties": {
              "mode": {
                "type": "string",
                "enum": [
                  "automatic_low_fe",
                  "locked_high_fe"
                ]
              },
              "freeEnergy": {
                "type": "number"
              },
              "tau": {
                "type": "number"
              },
              "locked": {
                "type": "boolean"
              }
            }
          },
          "hotAbstention": {
            "type": "object",
            "required": [
              "shouldAbstain",
              "reason"
            ],
            "properties": {
              "shouldAbstain": {
                "type": "boolean"
              },
              "reason": {
                "type": "string"
              }
            }
          },
          "somaticHint": {
            "type": "string"
          },
          "samplingHints": {
            "$ref": "#/components/schemas/SamplingHints"
          },
          "safetyDirectives": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "actionRiskGate": {
            "$ref": "#/components/schemas/ActionRiskGateVerdict"
          },
          "domainOutputContract": {
            "type": "object",
            "additionalProperties": true
          }
        }
      },
      "SettleTurnRequest": {
        "type": "object",
        "required": [
          "turnTicketId",
          "rawReply"
        ],
        "properties": {
          "turnTicketId": {
            "type": "string",
            "minLength": 1,
            "maxLength": 256
          },
          "rawReply": {
            "type": "string",
            "minLength": 1,
            "maxLength": 32000
          },
          "rewardSignal": {
            "type": "number"
          },
          "outcomeTags": {
            "type": "array",
            "maxItems": 32,
            "items": {
              "type": "string",
              "maxLength": 256
            }
          },
          "providerUsed": {
            "type": "string",
            "maxLength": 256
          },
          "modelUsed": {
            "type": "string",
            "maxLength": 256
          },
          "usage": {
            "$ref": "#/components/schemas/TokenUsageInput"
          },
          "eventTimestampIso": {
            "$ref": "#/components/schemas/EventTime"
          },
          "occurredAt": {
            "$ref": "#/components/schemas/EventTime"
          },
          "speaker": {
            "type": "string",
            "maxLength": 256
          },
          "connectorContext": {
            "$ref": "#/components/schemas/ConnectorContext"
          },
          "actionOutcome": {
            "$ref": "#/components/schemas/ActionOutcome"
          }
        }
      },
      "IdleTickRequest": {
        "type": "object",
        "required": [
          "elapsedHours"
        ],
        "properties": {
          "elapsedHours": {
            "type": "number",
            "minimum": 0,
            "maximum": 720
          },
          "reason": {
            "type": "string",
            "maxLength": 256
          },
          "proactiveTriggerInput": {
            "$ref": "#/components/schemas/ProactiveTriggerInput"
          }
        }
      },
      "IdleTickResponse": {
        "type": "object",
        "required": [
          "mindId",
          "elapsedHours",
          "homeostasisBefore",
          "homeostasisAfter",
          "telemetry"
        ],
        "properties": {
          "mindId": {
            "type": "string"
          },
          "elapsedHours": {
            "type": "number"
          },
          "homeostasisBefore": {
            "type": "number"
          },
          "homeostasisAfter": {
            "type": "number"
          },
          "proactiveHint": {
            "type": "string"
          },
          "proactiveVerdict": {
            "$ref": "#/components/schemas/ProactiveVerdict"
          },
          "telemetry": {
            "$ref": "#/components/schemas/SafeTelemetry"
          }
        }
      },
      "SafeTelemetry": {
        "type": "object",
        "description": "Filtered public telemetry; sandbox cache figures are illustrative.",
        "required": [
          "affectiveBand",
          "fepMode",
          "freeEnergy",
          "hotAbstained",
          "kvPrefixEpoch",
          "estimatedPrefixCachePct",
          "activeMemoryCount",
          "revocationEpoch",
          "d4Redacted"
        ],
        "properties": {
          "affectiveBand": {
            "type": "string",
            "enum": [
              "steady",
              "warm",
              "alert",
              "guarded",
              "reflective"
            ]
          },
          "fepMode": {
            "type": "string",
            "enum": [
              "automatic_low_fe",
              "locked_high_fe"
            ]
          },
          "freeEnergy": {
            "type": "number"
          },
          "hotAbstained": {
            "type": "boolean"
          },
          "kvPrefixEpoch": {
            "type": "integer"
          },
          "estimatedPrefixCachePct": {
            "type": "number"
          },
          "cacheEstimateIllustrative": {
            "type": "boolean"
          },
          "llmLatencyMs": {
            "type": "number"
          },
          "activeMemoryCount": {
            "type": "integer"
          },
          "revocationEpoch": {
            "type": "integer"
          },
          "somaticTrend": {
            "type": "string",
            "enum": [
              "neutral",
              "positive_reinforcement",
              "aversive_caution"
            ]
          },
          "tokenUsage": {
            "$ref": "#/components/schemas/TokenUsageInput"
          },
          "d4Redacted": {
            "type": "boolean",
            "enum": [
              true
            ]
          }
        }
      },
      "RevocationReceipt": {
        "type": "object",
        "required": [
          "revoked",
          "mindId",
          "memoryId",
          "revocationEpoch",
          "auditReceiptId",
          "residualCount",
          "verificationScope",
          "residualLeakCheck"
        ],
        "properties": {
          "revoked": {
            "type": "boolean"
          },
          "mindId": {
            "type": "string"
          },
          "memoryId": {
            "type": "string"
          },
          "revocationEpoch": {
            "type": "integer"
          },
          "auditReceiptId": {
            "type": "string"
          },
          "residualCount": {
            "type": "integer",
            "minimum": 0
          },
          "verificationScope": {
            "type": "string",
            "enum": [
              "process-memory",
              "process-memory+postgres"
            ]
          },
          "residualLeakCheck": {
            "type": "string",
            "enum": [
              "0.00%",
              "100.00%"
            ],
            "description": "Legacy pass/fail marker within verificationScope; not a measured percentage."
          }
        }
      },
      "TurnResult": {
        "type": "object",
        "required": [
          "mindId",
          "turnIndex",
          "domain",
          "providerUsed",
          "modelUsed",
          "reply",
          "domainOutput",
          "memoryRefs",
          "kvCache",
          "telemetry"
        ],
        "properties": {
          "mindId": {
            "type": "string"
          },
          "turnIndex": {
            "type": "integer"
          },
          "domain": {
            "$ref": "#/components/schemas/DomainId"
          },
          "providerUsed": {
            "type": "string"
          },
          "modelUsed": {
            "type": "string"
          },
          "bubbles": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "occurredAt": {
            "$ref": "#/components/schemas/EventTime"
          },
          "epistemicTier": {
            "type": "string"
          },
          "simulated": {
            "type": "boolean"
          },
          "requestedProvider": {
            "type": "string"
          },
          "requestedModel": {
            "type": "string"
          },
          "reply": {
            "type": "string"
          },
          "actionRiskGate": {
            "$ref": "#/components/schemas/ActionRiskGateVerdict"
          },
          "domainOutput": {
            "type": "object",
            "additionalProperties": true
          },
          "memoryRefs": {
            "type": "array",
            "items": {
              "type": "object",
              "required": [
                "memoryId",
                "summary",
                "salience"
              ],
              "properties": {
                "memoryId": {
                  "type": "string"
                },
                "summary": {
                  "type": "string"
                },
                "salience": {
                  "type": "number"
                }
              }
            }
          },
          "kvCache": {
            "type": "object",
            "required": [
              "epoch",
              "windowStart",
              "compressCutoff",
              "systemPrefixHash",
              "cachedRatioPct"
            ],
            "properties": {
              "epoch": {
                "type": "integer"
              },
              "windowStart": {
                "type": "integer"
              },
              "compressCutoff": {
                "type": "integer"
              },
              "systemPrefixHash": {
                "type": "string"
              },
              "cachedRatioPct": {
                "type": "number"
              },
              "illustrative": {
                "type": "boolean"
              }
            }
          },
          "telemetry": {
            "$ref": "#/components/schemas/SafeTelemetry"
          }
        }
      },
      "SimulateBatchRequest": {
        "type": "object",
        "properties": {
          "turns": {
            "type": "integer",
            "minimum": 1,
            "maximum": 1000000,
            "default": 100000
          },
          "profileCount": {
            "type": "integer",
            "minimum": 1,
            "maximum": 40,
            "default": 40
          },
          "checkpoints": {
            "type": "integer",
            "minimum": 2,
            "maximum": 20,
            "default": 8
          },
          "seed": {
            "type": "integer",
            "default": 1337
          },
          "compareArms": {
            "type": "boolean",
            "default": true
          },
          "language": {
            "type": "string",
            "enum": [
              "ko",
              "en"
            ],
            "default": "ko"
          }
        }
      },
      "ConvergenceCheckpoint": {
        "type": "object",
        "required": [
          "totalTurns",
          "composite",
          "batchIntegrity",
          "polarityAccuracy",
          "securityCalibration",
          "attentionStability",
          "emotionGranularity",
          "ownershipScore",
          "egoHealth",
          "safetyCompliance"
        ],
        "properties": {
          "totalTurns": {
            "type": "integer"
          },
          "composite": {
            "type": "number"
          },
          "batchIntegrity": {
            "type": "number"
          },
          "polarityAccuracy": {
            "type": "number"
          },
          "securityCalibration": {
            "type": "number"
          },
          "attentionStability": {
            "type": "number"
          },
          "emotionGranularity": {
            "type": "number"
          },
          "ownershipScore": {
            "type": "number"
          },
          "egoHealth": {
            "type": "number"
          },
          "safetyCompliance": {
            "type": "number"
          }
        }
      },
      "BatchArmResult": {
        "type": "object",
        "required": [
          "final",
          "checkpoints",
          "driftDelta"
        ],
        "properties": {
          "final": {
            "$ref": "#/components/schemas/ConvergenceCheckpoint"
          },
          "checkpoints": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ConvergenceCheckpoint"
            }
          },
          "driftDelta": {
            "type": "number"
          }
        }
      },
      "SimulateBatchResponse": {
        "type": "object",
        "required": [
          "mindId",
          "engineMode",
          "requestedTurnsPerArm",
          "executedTurnsPerArm",
          "totalExecutedTurnsAllArms",
          "profileCount",
          "turnsPerProfile",
          "elapsedMs",
          "turnsPerSecond",
          "arms",
          "d4Redacted"
        ],
        "properties": {
          "mindId": {
            "type": "string"
          },
          "engineMode": {
            "type": "string",
            "enum": [
              "sealed-kernel",
              "sandbox-contract"
            ]
          },
          "requestedTurnsPerArm": {
            "type": "integer"
          },
          "executedTurnsPerArm": {
            "type": "integer"
          },
          "totalExecutedTurnsAllArms": {
            "type": "integer"
          },
          "profileCount": {
            "type": "integer"
          },
          "turnsPerProfile": {
            "type": "integer"
          },
          "elapsedMs": {
            "type": "number"
          },
          "turnsPerSecond": {
            "type": "number"
          },
          "language": {
            "type": "string",
            "enum": [
              "ko",
              "en"
            ]
          },
          "note": {
            "type": "string"
          },
          "arms": {
            "type": "object",
            "additionalProperties": {
              "$ref": "#/components/schemas/BatchArmResult"
            }
          },
          "deltaVsBaseline": {
            "type": "object",
            "required": [
              "compositeGainOverMindOff",
              "compositeGainOverAacimOff",
              "safetyGainOverAacimOff",
              "driftBounded"
            ],
            "properties": {
              "compositeGainOverMindOff": {
                "type": "number"
              },
              "compositeGainOverAacimOff": {
                "type": "number"
              },
              "safetyGainOverAacimOff": {
                "type": "number"
              },
              "driftBounded": {
                "type": "boolean"
              }
            }
          },
          "d4Redacted": {
            "type": "boolean",
            "enum": [
              true
            ]
          }
        }
      },
      "ActionCandidate": {
        "type": "object",
        "required": [
          "toolName",
          "riskLevel",
          "reversibility"
        ],
        "properties": {
          "toolName": {
            "type": "string",
            "minLength": 1,
            "maxLength": 256
          },
          "riskLevel": {
            "type": "string",
            "enum": [
              "low",
              "medium",
              "high",
              "irreversible"
            ]
          },
          "reversibility": {
            "type": "string",
            "enum": [
              "reversible",
              "compensatable",
              "irreversible"
            ]
          },
          "targetSummary": {
            "type": "string",
            "maxLength": 2000
          },
          "connectorId": {
            "type": "string",
            "maxLength": 256
          }
        }
      },
      "ConnectorContext": {
        "type": "object",
        "required": [
          "connectorId",
          "scopeLevel"
        ],
        "properties": {
          "connectorId": {
            "type": "string",
            "minLength": 1,
            "maxLength": 256
          },
          "scopeLevel": {
            "type": "string",
            "enum": [
              "read",
              "write",
              "admin"
            ]
          },
          "tokenSurrogateRef": {
            "type": "string",
            "maxLength": 256,
            "description": "Opaque surrogate reference only; raw OAuth/API credentials are rejected."
          },
          "delegatedScope": {
            "type": "string",
            "maxLength": 512
          }
        }
      },
      "ActionRiskGateVerdict": {
        "type": "object",
        "required": [
          "decision",
          "confidence",
          "epiplexityMargin",
          "reasonCode",
          "requiresUserConfirmation"
        ],
        "properties": {
          "decision": {
            "type": "string",
            "enum": [
              "allow",
              "allow_with_audit",
              "require_hitl",
              "abstain_block"
            ]
          },
          "confidence": {
            "type": "number",
            "minimum": 0,
            "maximum": 1
          },
          "epiplexityMargin": {
            "type": "number"
          },
          "reasonCode": {
            "type": "string",
            "maxLength": 128
          },
          "requiresUserConfirmation": {
            "type": "boolean"
          }
        }
      },
      "ActionOutcome": {
        "type": "object",
        "properties": {
          "toolName": {
            "type": "string",
            "maxLength": 256
          },
          "status": {
            "type": "string",
            "enum": [
              "executed",
              "cancelled",
              "hitl_pending",
              "failed",
              "blocked"
            ]
          },
          "summary": {
            "type": "string",
            "maxLength": 2000
          }
        },
        "additionalProperties": true
      },
      "ProactiveTriggerInput": {
        "type": "object",
        "required": [
          "triggerKind",
          "urgencyScore"
        ],
        "properties": {
          "triggerKind": {
            "type": "string",
            "enum": [
              "calendar_due",
              "inbox_urgent",
              "goal_stall",
              "followup_window",
              "heartbeat"
            ]
          },
          "urgencyScore": {
            "type": "number",
            "minimum": 0,
            "maximum": 1
          },
          "userFocusState": {
            "type": "string",
            "enum": [
              "deep_work",
              "idle",
              "sleeping",
              "meeting"
            ]
          }
        }
      },
      "ProactiveVerdict": {
        "type": "object",
        "required": [
          "shouldWakeUp",
          "channel",
          "reason",
          "cooldownSeconds"
        ],
        "properties": {
          "shouldWakeUp": {
            "type": "boolean"
          },
          "channel": {
            "type": "string",
            "enum": [
              "silent",
              "digest",
              "push"
            ]
          },
          "reason": {
            "type": "string",
            "maxLength": 512
          },
          "cooldownSeconds": {
            "type": "integer",
            "minimum": 0
          }
        }
      },
      "ConnectorRevokeRequest": {
        "type": "object",
        "properties": {
          "reason": {
            "type": "string",
            "maxLength": 512
          },
          "cascadeMemories": {
            "type": "boolean",
            "default": true
          }
        }
      },
      "ConnectorRevocationReceipt": {
        "type": "object",
        "required": [
          "mindId",
          "connectorId",
          "revokedAtIso",
          "revocationEpoch",
          "invalidatedMemoriesCount",
          "status"
        ],
        "properties": {
          "mindId": {
            "type": "string"
          },
          "connectorId": {
            "type": "string"
          },
          "revokedAtIso": {
            "type": "string",
            "format": "date-time"
          },
          "revocationEpoch": {
            "type": "integer",
            "minimum": 0
          },
          "invalidatedMemoriesCount": {
            "type": "integer",
            "minimum": 0
          },
          "status": {
            "type": "string",
            "enum": [
              "revoked",
              "already_revoked"
            ]
          },
          "auditReceiptId": {
            "type": "string"
          },
          "residualCount": {
            "type": "integer",
            "minimum": 0
          },
          "verificationScope": {
            "type": "string",
            "enum": [
              "process-memory",
              "process-memory+postgres"
            ]
          },
          "residualLeakCheck": {
            "type": "string",
            "enum": [
              "0.00%",
              "100.00%"
            ]
          }
        }
      },
      "EgressCheckRequest": {
        "type": "object",
        "required": [
          "targetChannel",
          "payloadText"
        ],
        "properties": {
          "targetChannel": {
            "type": "string",
            "minLength": 1,
            "maxLength": 128
          },
          "payloadText": {
            "type": "string",
            "minLength": 1,
            "maxLength": 65536
          },
          "expectedEpoch": {
            "type": "integer",
            "minimum": 0
          }
        }
      },
      "EgressRedactionItem": {
        "type": "object",
        "required": [
          "rule",
          "match",
          "replacement"
        ],
        "properties": {
          "rule": {
            "type": "string"
          },
          "match": {
            "type": "string"
          },
          "replacement": {
            "type": "string"
          }
        }
      },
      "EgressCheckResult": {
        "type": "object",
        "required": [
          "mindId",
          "targetChannel",
          "verdict",
          "redactions",
          "matchedRules",
          "revocationEpoch",
          "checkedAtIso"
        ],
        "properties": {
          "mindId": {
            "type": "string"
          },
          "targetChannel": {
            "type": "string"
          },
          "verdict": {
            "type": "string",
            "enum": [
              "pass",
              "redact",
              "block"
            ]
          },
          "redactions": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/EgressRedactionItem"
            }
          },
          "matchedRules": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "revocationEpoch": {
            "type": "integer",
            "minimum": 0
          },
          "checkedAtIso": {
            "type": "string",
            "format": "date-time"
          },
          "sanitizedPreview": {
            "type": "string"
          }
        }
      },
      "MemoryRecord": {
        "type": "object",
        "required": [
          "memoryId",
          "summary",
          "salience",
          "turnIndex",
          "tags",
          "createdAt"
        ],
        "properties": {
          "memoryId": {
            "type": "string"
          },
          "summary": {
            "type": "string"
          },
          "content": {
            "type": "string"
          },
          "salience": {
            "type": "number"
          },
          "turnIndex": {
            "type": "integer",
            "minimum": 0
          },
          "epistemicTier": {
            "type": "string"
          },
          "connectorId": {
            "type": [
              "string",
              "null"
            ]
          },
          "category": {
            "type": [
              "string",
              "null"
            ]
          },
          "tags": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "revoked": {
            "type": "boolean"
          },
          "createdAt": {
            "type": [
              "integer",
              "string"
            ]
          }
        }
      },
      "MemoryListResponse": {
        "type": "object",
        "required": [
          "mindId",
          "revocationEpoch",
          "memories"
        ],
        "properties": {
          "mindId": {
            "type": "string"
          },
          "revocationEpoch": {
            "type": "integer",
            "minimum": 0
          },
          "memories": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/MemoryRecord"
            }
          },
          "total": {
            "type": "integer",
            "minimum": 0
          },
          "limit": {
            "type": "integer",
            "minimum": 1
          },
          "offset": {
            "type": "integer",
            "minimum": 0
          }
        }
      },
      "IngestMemoryRequest": {
        "type": "object",
        "required": [
          "content"
        ],
        "properties": {
          "content": {
            "type": "string",
            "minLength": 1,
            "maxLength": 32000
          },
          "summary": {
            "type": "string",
            "maxLength": 512
          },
          "epistemicTier": {
            "type": "string",
            "maxLength": 64
          },
          "connectorId": {
            "type": "string",
            "maxLength": 256
          },
          "category": {
            "type": "string",
            "maxLength": 128
          },
          "salience": {
            "type": "number",
            "minimum": 0,
            "maximum": 1
          },
          "tags": {
            "type": "array",
            "maxItems": 32,
            "items": {
              "type": "string",
              "maxLength": 128
            }
          },
          "metadata": {
            "type": "object",
            "additionalProperties": true
          },
          "occurredAt": {
            "$ref": "#/components/schemas/EventTime"
          }
        }
      },
      "IngestMemoryResponse": {
        "allOf": [
          {
            "$ref": "#/components/schemas/MemoryRecord"
          },
          {
            "type": "object",
            "required": [
              "mindId",
              "revocationEpoch"
            ],
            "properties": {
              "mindId": {
                "type": "string"
              },
              "revocationEpoch": {
                "type": "integer",
                "minimum": 0
              }
            }
          }
        ]
      },
      "MemorySearchRequest": {
        "type": "object",
        "required": [
          "query"
        ],
        "properties": {
          "query": {
            "type": "string",
            "minLength": 1,
            "maxLength": 2000
          },
          "limit": {
            "type": "integer",
            "minimum": 1,
            "maximum": 100,
            "default": 10
          },
          "topK": {
            "type": "integer",
            "minimum": 1,
            "maximum": 100
          },
          "epistemicTier": {
            "type": "string",
            "maxLength": 64
          },
          "epistemicTiers": {
            "type": "array",
            "items": {
              "type": "string",
              "maxLength": 64
            }
          },
          "connectorId": {
            "type": "string",
            "maxLength": 256
          },
          "category": {
            "type": "string",
            "maxLength": 128
          },
          "includeRevoked": {
            "type": "boolean",
            "default": false
          }
        }
      },
      "MemorySearchHit": {
        "allOf": [
          {
            "$ref": "#/components/schemas/MemoryRecord"
          },
          {
            "type": "object",
            "required": [
              "score"
            ],
            "properties": {
              "score": {
                "type": "number"
              }
            }
          }
        ]
      },
      "MemorySearchResponse": {
        "type": "object",
        "required": [
          "mindId",
          "query",
          "revocationEpoch",
          "results"
        ],
        "properties": {
          "mindId": {
            "type": "string"
          },
          "query": {
            "type": "string"
          },
          "revocationEpoch": {
            "type": "integer",
            "minimum": 0
          },
          "totalMatches": {
            "type": "integer",
            "minimum": 0
          },
          "results": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/MemorySearchHit"
            }
          }
        }
      }
    }
  }
}
