openapi: 3.0.3
info:
  title: Intent-Driven Mid Platform Dependency API
  version: 0.3.0
  x-contract-level: L1
paths:
  /deps/metadata/query:
    post:
      operationId: queryMetadata
      summary: 查询元数据与知识内容
      x-requirements:
        - AC-IDMP-10
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/MetadataQueryRequest'
      responses:
        '200':
          description: 查询成功
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/MetadataQueryResponse'

  /deps/memory/recall:
    post:
      operationId: recallMemory
      summary: 召回用户记忆
      x-requirements:
        - AC-IDMP-13
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/RecallRequest'
      responses:
        '200':
          description: 召回成功
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/RecallResponse'

  /deps/memory/update:
    post:
      operationId: updateMemory
      summary: 更新用户记忆
      x-requirements:
        - AC-IDMP-14
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/UpdateRequest'
      responses:
        '202':
          description: 已接受异步更新

components:
  schemas:
    MetadataQueryRequest:
      type: object
      required:
        - intent
        - target_kbs
        - metadata_filter
        - query
      properties:
        intent:
          type: string
        target_kbs:
          type: array
          items:
            type: string
        metadata_filter:
          type: object
          additionalProperties: true
        query:
          type: string

    MetadataQueryResponse:
      type: object
      required:
        - items
      properties:
        items:
          type: array
          items:
            $ref: '#/components/schemas/MetadataItem'

    MetadataItem:
      type: object
      required:
        - id
        - score
        - content
      properties:
        id:
          type: string
        score:
          type: number
        content:
          type: string
        metadata:
          type: object
          additionalProperties: true

    RecallRequest:
      type: object
      required:
        - user_id
        - session_id
      properties:
        user_id:
          type: string
        session_id:
          type: string

    RecallResponse:
      type: object
      properties:
        profile:
          type: object
          description: 基础属性记忆（年级、地区、渠道等）
          additionalProperties: true
        facts:
          type: array
          description: 事实型记忆（已购课程、学习结论等）
          items:
            type: string
        preferences:
          type: object
          description: 偏好记忆（语气偏好、关注科目等）
          additionalProperties: true
        last_summary:
          type: string
          description: 最近一次会话摘要

    UpdateRequest:
      type: object
      required:
        - user_id
        - session_id
        - messages
      properties:
        user_id:
          type: string
        session_id:
          type: string
        messages:
          type: array
          items:
            type: object
            additionalProperties: true
        summary:
          type: string
          description: 本轮会话摘要（可选，由中台异步生成后回写）
