openapi: 3.0.3
info:
  title: Mid Agent Runtime Hardening Dependency API
  version: 0.1.0
  x-contract-level: L1
paths:
  /deps/metadata/query:
    post:
      operationId: queryMetadata
      summary: 元数据与知识检索
      x-requirements:
        - AC-MARH-05
        - AC-MARH-06
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/MetadataQueryRequest'
      responses:
        '200':
          description: 查询成功
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/MetadataQueryResponse'

  /deps/guardrail/output-filter:
    post:
      operationId: filterOutput
      summary: 输出护栏过滤
      x-requirements:
        - AC-MARH-01
        - AC-MARH-02
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/OutputFilterRequest'
      responses:
        '200':
          description: 过滤结果
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/OutputFilterResponse'

components:
  schemas:
    MetadataQueryRequest:
      type: object
      required:
        - intent
        - query
      properties:
        intent:
          type: string
        query:
          type: string
        metadata_filter:
          type: object
          additionalProperties: true
        top_k:
          type: integer
          minimum: 1
          maximum: 20

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

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

    OutputFilterRequest:
      type: object
      required:
        - text
      properties:
        text:
          type: string
        mode:
          type: string
          enum: [agent, micro_flow, fixed, transfer]
        context:
          type: object
          additionalProperties: true

    OutputFilterResponse:
      type: object
      required:
        - blocked
        - filtered_text
      properties:
        blocked:
          type: boolean
        filtered_text:
          type: string
        rule_id:
          type: string
        reason:
          type: string
