openapi: 3.1.0
info:
  title: RTT/12 Aggregator API
  version: "2026.1"
  description: |
    Aggregation endpoint for RTT/12. Merges unifiedTopology,
    dashboardModel, and pipelineMetadata into a single coherent
    aggregate model.

servers:
  - url: /api

paths:
  /aggregate:
    post:
      summary: Aggregate RTT/12 models
      description: |
        Merges unifiedTopology, dashboardModel, and pipelineMetadata
        into a single RTT/12 aggregate structure.
      operationId: aggregateModels

      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/AggregateRequest"

      responses:
        "200":
          description: Successful aggregation
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/AggregateResponse"

        "400":
          description: Invalid request payload
        "500":
          description: Internal aggregation error

components:
  schemas:

    AggregateRequest:
      type: object
      required:
        - unifiedTopology
        - dashboardModel
        - pipelineMetadata
      properties:
        unifiedTopology:
          $ref: "#/components/schemas/UnifiedTopology"
        dashboardModel:
          $ref: "#/components/schemas/DashboardModel"
        pipelineMetadata:
          $ref: "#/components/schemas/PipelineMetadata"

    AggregateResponse:
      type: object
      properties:
        ok:
          type: boolean
        result:
          $ref: "#/components/schemas/AggregateModel"
        error:
          type: string
          nullable: true

    UnifiedTopology:
      type: object
      required:
        - clusters
        - regimeSurfaces
        - coherenceDrift
        - gpuAligned
        - metadata
      properties:
        clusters:
          type: array
          items: { type: object }
        regimeSurfaces:
          type: array
          items: { type: object }
        coherenceDrift:
          type: array
          items: { type: object }
        gpuAligned:
          type: array
          items: { type: object }
        metadata:
          type: object

    DashboardModel:
      type: object
      required:
        - clusters
        - regimeSurfaces
        - coherenceDrift
        - gpuAligned
        - metadata
        - isEmpty
      properties:
        clusters:
          type: array
          items: { type: object }
        regimeSurfaces:
          type: array
          items: { type: object }
        coherenceDrift:
          type: array
          items: { type: object }
        gpuAligned:
          type: array
          items: { type: object }
        metadata:
          type: object
        isEmpty:
          type: boolean

    PipelineMetadata:
      type: object
      required:
        - engine
        - version
        - pipeline
        - validated
      properties:
        engine:
          type: string
        version:
          type: string
        pipeline:
          type: string
        validated:
          type: boolean

    AggregateModel:
      type: object
      properties:
        unifiedTopology:
          $ref: "#/components/schemas/UnifiedTopology"
        dashboardModel:
          $ref: "#/components/schemas/DashboardModel"
        pipelineMetadata:
          $ref: "#/components/schemas/PipelineMetadata"
        metadata:
          type: object
          properties:
            engine:
              type: string
            version:
              type: string
            pipeline:
              type: string
            aggregated:
              type: boolean

