openapi: 3.1.0
info:
  title: Operation Run Detail Page Contract
  version: 1.0.0
  description: >-
    Internal reference contract for the canonical operation-run detail page. The route
    still returns rendered HTML; the structured schema below documents the decision-first
    page payload that must be derivable before rendering. This is not a public API commitment.
paths:
  /admin/operations/{run}:
    get:
      summary: Canonical operation-run detail page
      description: >-
        Returns the rendered canonical run-detail page. The vendor media type documents
        the internal structured page model used to drive the enterprise-detail surface.
      parameters:
        - name: run
          in: path
          required: true
          schema:
            type: integer
      responses:
        '200':
          description: Rendered canonical run detail page
          content:
            text/html:
              schema:
                type: string
            application/vnd.tenantpilot.operation-run-detail+json:
              schema:
                $ref: '#/components/schemas/OperationRunDetailPage'
        '403':
          description: Viewer is in scope but lacks the required capability
        '404':
          description: Run is not visible because it does not exist or tenant/workspace entitlement is missing
components:
  schemas:
    OperationRunDetailPage:
      type: object
      required:
        - header
        - decisionZone
        - supportingGroups
        - mainSections
        - technicalSections
      properties:
        header:
          $ref: '#/components/schemas/PageHeader'
        decisionZone:
          $ref: '#/components/schemas/DecisionZone'
        supportingGroups:
          type: array
          items:
            $ref: '#/components/schemas/SupportingGroup'
        mainSections:
          type: array
          items:
            $ref: '#/components/schemas/DetailSection'
        technicalSections:
          type: array
          items:
            $ref: '#/components/schemas/DetailSection'
        attentionBanners:
          type: array
          items:
            $ref: '#/components/schemas/AttentionBanner'
    PageHeader:
      type: object
      required:
        - title
        - statusBadges
        - keyFacts
      properties:
        title:
          type: string
        subtitle:
          type:
            - string
            - 'null'
        statusBadges:
          type: array
          items:
            $ref: '#/components/schemas/Badge'
        keyFacts:
          type: array
          items:
            $ref: '#/components/schemas/Fact'
        primaryActions:
          type: array
          items:
            $ref: '#/components/schemas/PageAction'
        descriptionHint:
          type:
            - string
            - 'null'
    DecisionZone:
      type: object
      required:
        - executionState
        - outcome
        - primaryNextStep
      properties:
        executionState:
          $ref: '#/components/schemas/Fact'
        outcome:
          $ref: '#/components/schemas/Fact'
        artifactTruth:
          oneOf:
            - $ref: '#/components/schemas/Fact'
            - type: 'null'
        resultMeaning:
          oneOf:
            - $ref: '#/components/schemas/Fact'
            - type: 'null'
        resultTrust:
          oneOf:
            - $ref: '#/components/schemas/Fact'
            - type: 'null'
        primaryNextStep:
          $ref: '#/components/schemas/PrimaryNextStep'
        compactCounts:
          oneOf:
            - $ref: '#/components/schemas/CountPresentation'
            - type: 'null'
        attentionNote:
          type:
            - string
            - 'null'
    PrimaryNextStep:
      type: object
      required:
        - text
        - source
      properties:
        text:
          type: string
        source:
          type: string
          enum:
            - operator_explanation
            - artifact_truth
            - blocked_reason
            - lifecycle_attention
            - ops_ux
            - none_required
        secondaryGuidance:
          type: array
          items:
            type: string
    CountPresentation:
      type: object
      properties:
        summaryLine:
          type:
            - string
            - 'null'
        primaryFacts:
          type: array
          items:
            $ref: '#/components/schemas/Fact'
        diagnosticFacts:
          type: array
          items:
            $ref: '#/components/schemas/Fact'
    SupportingGroup:
      type: object
      required:
        - kind
        - title
      properties:
        kind:
          type: string
          enum:
            - guidance
            - lifecycle
            - timing
            - metadata
        title:
          type: string
        description:
          type:
            - string
            - 'null'
        items:
          type: array
          items:
            $ref: '#/components/schemas/Fact'
    DetailSection:
      type: object
      required:
        - id
        - title
      properties:
        id:
          type: string
        kind:
          type:
            - string
            - 'null'
        title:
          type: string
        description:
          type:
            - string
            - 'null'
        collapsible:
          type: boolean
        collapsed:
          type: boolean
        items:
          type: array
          items:
            $ref: '#/components/schemas/Fact'
    AttentionBanner:
      type: object
      required:
        - tone
        - title
        - body
      properties:
        tone:
          type: string
          enum:
            - info
            - amber
            - rose
            - slate
        title:
          type: string
        body:
          type: string
    Fact:
      type: object
      required:
        - label
        - value
      properties:
        label:
          type: string
        value:
          type: string
        hint:
          type:
            - string
            - 'null'
        badge:
          oneOf:
            - $ref: '#/components/schemas/Badge'
            - type: 'null'
    Badge:
      type: object
      required:
        - label
      properties:
        label:
          type: string
        color:
          type:
            - string
            - 'null'
        icon:
          type:
            - string
            - 'null'
        iconColor:
          type:
            - string
            - 'null'
    PageAction:
      type: object
      required:
        - label
        - destructive
        - requiresConfirmation
        - visible
        - openInNewTab
      properties:
        label:
          type: string
        placement:
          type:
            - string
            - 'null'
        url:
          type:
            - string
            - 'null'
        actionName:
          type:
            - string
            - 'null'
        destructive:
          type: boolean
        requiresConfirmation:
          type: boolean
        visible:
          type: boolean
        icon:
          type:
            - string
            - 'null'
        openInNewTab:
          type: boolean
